using namespace std;
#include "TRandom.h"
#include <time.h>
#include <iostream>
#include <iomanip>
#include <math.h>
#include "TMath.h"
#include "TIterator.h"
#include "TObjArray.h"
#include "phyanadef.h"
#include "hphysicsevent.h"
#include "hparticle.h"
#include "hades.h"
#include "hiterator.h"
#include "hcategory.h"
#include "hlinearcategory.h"
#include "hphysicsconstants.h"
#include "hrecevent.h"
#include "hlocation.h"
HPhysicsEvent::HPhysicsEvent(void) {
fPartCat = 0;
fPartArray = 0;
iterPart=0;
for(Int_t i=0;i<50;i++) data[i] = new TObjArray();
}
HPhysicsEvent::HPhysicsEvent(HCategory *cat) {
fPartCat = cat;
fPartArray = 0;
iterPart = (HIterator *)fPartCat->MakeIterator("native");
for(Int_t i=0;i<50;i++) data[i] = new TObjArray();
}
HPhysicsEvent::HPhysicsEvent(TClonesArray *array) {
fPartCat = 0;
fPartArray = array;
iterPart = (TIterator *)fPartArray->MakeIterator();
for(Int_t i=0;i<50;i++) data[i] = new TObjArray();
}
Float_t HPhysicsEvent::sumPt(TObjArray *array) {
HParticle *part = 0;
Double_t sum = 0;
TIterator *iter = array->MakeIterator();
while ((part=(HParticle*) iter->Next())!=0) sum += part->Pt();
return sum;
}
Float_t HPhysicsEvent::sumEt(TObjArray *array) {
HParticle *part = 0;
Double_t sum = 0;
TIterator *iter = array->MakeIterator();
while ((part=(HParticle*) iter->Next())!=0)
sum += part->E()*sin(part->Theta());
return sum;
}
Float_t HPhysicsEvent::sumMt(TObjArray *array) {
HParticle *part = 0;
Double_t sum = 0;
TIterator *iter = array->MakeIterator();
while ((part=(HParticle*) iter->Next())!=0) sum += part->Mt();
return sum;
}
Int_t HPhysicsEvent::mult(TObjArray *array) {
return array->GetEntriesFast();
}
void HPhysicsEvent::printEvent() {
HParticle *part = 0;
Int_t count = 0;
Float_t r2d=57.29578;
iterPart->Reset();
while ((part=(HParticle*) iterPart->Next())!=0) {
if(part->getPid()>0)
printf(" %3i) pid = %3s P = %7.2f theta = %6.2f phi = %6.2f\n",
count,HPhysicsConstants::pid(part->getPid()),part->P(),part->Theta()*r2d,part->Phi()*r2d);
else
printf(" %3i) pid = -- P = %7.2f theta = %6.2f phi = %6.2f\n",
count,part->P(),part->Theta()*r2d,part->Phi()*r2d);
count++;
}
printf("\n");
return;
}
TObjArray* HPhysicsEvent::getParticles(Int_t pid) {
count++; if(count==50) count=0;
HParticle *part = 0;
data[count]->Clear();
iterPart->Reset();
while ((part=(HParticle*) iterPart->Next())!=0)
if(pid == part->getPid() || pid == -1) data[count]->Add(part);
return data[count];
}
TObjArray* HPhysicsEvent::getParticles(const Char_t *name) {
count++; if(count==50) count=0;
HParticle *part = 0;
data[count]->Clear();
HPhysicsConstants *table;
Int_t pid;
iterPart->Reset();
if(strcmp(name,"hadrons") == 0 || strcmp(name,"leptons") == 0
|| strcmp(name,"pions") == 0 || strcmp(name,"noId") == 0 ) {
while ((part=(HParticle*) iterPart->Next())!=0) {
pid = part->getPid();
if(strcmp(name,"hadrons") == 0)
if( pid == table->pid("pi-") || pid == table->pid("pi+") ||
pid == table->pid("K-") || pid == table->pid("K+") ||
pid == table->pid("p") || pid == table->pid("d") )
data[count]->Add(part);
if(strcmp(name,"pions") == 0)
if( pid == table->pid("pi-") || pid == table->pid("pi+") )
data[count]->Add(part);
if(strcmp(name,"leptons") == 0)
if( pid == table->pid("e-") || pid == table->pid("e+") )
data[count]->Add(part);
if(strcmp(name,"noId") == 0)
if( pid == 0 )
data[count]->Add(part);
}
return data[count];
}
else return getParticles(HPhysicsConstants::pid(name));
}
ClassImp(HPhysicsEvent)
Last change: Sat May 22 13:06:42 2010
Last generated: 2010-05-22 13:06
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.