using namespace std;
#include <iostream>
#include <iomanip>
#include <math.h>
#include <time.h>
#include "TMath.h"
#include "hades.h"
#include "hcategory.h"
#include "hdebug.h"
#include "hevent.h"
#include "hiterator.h"
#include "hkicktrack.h"
#include "hlinearcategory.h"
#include "hlocation.h"
#include "hpartialevent.h"
#include "hparticlesim.h"
#include "hparticlesimfiller.h"
#include "hphysicsconstants.h"
#include "hrecevent.h"
#include "hrichhitsim.h"
#include "hruntimedb.h"
#include "hspectrometer.h"
#include "kickdef.h"
#include "phyanadef.h"
#include "richdef.h"
#include "hcuttrack.h"
#include "hcutleptonid.h"
#include "hcuthadronid.h"
#include "hparticlesrc.h"
#include "hgeantkine.h"
HParticleSimFiller::HParticleSimFiller(void) {
fGeantKineCat=0;
fPartSrcCat=0;
iterGeant=0;
}
HParticleSimFiller::HParticleSimFiller(const Text_t *name,const Text_t *title,Bool_t skip) :
HParticleFiller(name,title,skip) {
fGeantKineCat=0;
fPartSrcCat=0;
iterGeant=0;
}
Bool_t HParticleSimFiller::init(void) {
HRuntimeDb *rtdb = gHades->getRuntimeDb();
fSpecGeometry = (HSpecGeomPar *)rtdb->getContainer("SpecGeomPar");
fKickTrackCat = gHades->getCurrentEvent()->getCategory(catKickTrack);
if (!fKickTrackCat) {
Error("init","KickTrack not found in input file");
return kFALSE;
}
iterTracks = (HIterator *)fKickTrackCat->MakeIterator("native");
fRichHitCat = gHades->getCurrentEvent()->getCategory(catRichHit);
if (!fRichHitCat) return kFALSE;
iterRings = (HIterator *)fRichHitCat->MakeIterator("native");
fPartCat=gHades->getCurrentEvent()->getCategory(catParticle);
if (!fPartCat) {
fPartCat = new HLinearCategory("HParticleSim",1000);
if (fPartCat) gHades->getCurrentEvent()->addCategory(catParticle,
fPartCat,"PhyAna");
else {
Error("init","Unable to setup output");
return kFALSE;
}
}
fGeantKineCat = gHades->getCurrentEvent()->getCategory(catGeantKine);
if (fGeantKineCat) {
iterGeant = (HIterator *)fGeantKineCat->MakeIterator("native");
fPartSrcCat=gHades->getCurrentEvent()->getCategory(catParticleSrc);
if (!fPartSrcCat) {
fPartSrcCat = new HLinearCategory("HParticleSrc",1000);
if (fPartSrcCat) gHades->getCurrentEvent()->addCategory(catParticleSrc,
fPartSrcCat,"PhyAna");
else {
Error("init","Unable to setup output");
return kFALSE;
}
}
}
return kTRUE;
}
Int_t HParticleSimFiller::execute(void) {
HParticleSim *part = 0;
HKickTrack *track = 0;
HRichHitSim *ring = 0;
HLocation loc;
Int_t nPart = 0;
Int_t nLeptons = 0;
iterTracks->Reset();
while ((track=(HKickTrack*) iterTracks->Next())!=0) {
if(trackCuts && !trackCuts->check(track)) continue;
part = (HParticleSim*) fPartCat->getNewSlot(loc);
if(part != 0) {
part = new(part) HParticleSim;
part->setTrackId( fKickTrackCat->getIndex(track) );
part->setIndex(nPart);
fillMomenta(track,part);
fillVertex(track,part);
iterRings->Reset();
while ((ring=(HRichHitSim*) iterRings->Next())!=0) {
if(leptonCuts && !leptonCuts->check(ring,part)) continue;
part->setRingId(fRichHitCat->getIndex(ring));
makeLepton(ring,part);
nLeptons++;
}
if( !part->getPid() ) {
if(hadronIdCuts) part->setPid( hadronIdCuts->getPid(track) );
else part->setPid( track->getPID() );
}
fillMomenta(track,part);
nPart++;
}
}
if(fGeantKineCat) fillParticleSrc();
if(nPart == 0 && kSkip == kTRUE) return kSkipEvent;
return 0;
}
void HParticleSimFiller::fillParticleSrc(void) {
Int_t nPart;
Int_t iParent,iMedium,iMech,iTrack,iPid,iTrackParent,iPidParent;
Int_t iParentParent,iMediumParent,iMechParent;
Bool_t isFromSource,isDetectable;
Float_t px,py,pz,en,mass;
Float_t x,y,z,r,theta,phi;
nPart = 0;
HGeantKine *kine = 0;
HGeantKine *kineParent = 0;
HParticleSrc *partSrc = 0;
HLocation loc;
iterGeant->Reset();
while ((kine=(HGeantKine*) iterGeant->Next())!=0) {
isFromSource = isDetectable = kFALSE;
kine->getParticle(iTrack,iPid);
kine->getCreator(iParent,iMedium,iMech);
if(iParent == 0) isFromSource = kTRUE;
if(iPid != HPhysicsConstants::pid("g")
&& iPid != HPhysicsConstants::pid("n") )
isDetectable = kTRUE;
if(iPid == HPhysicsConstants::pid("e-")
|| iPid == HPhysicsConstants::pid("e+") ) {
kineParent =(HGeantKine*) fGeantKineCat->getObject(iParent-1);
kineParent->getParticle(iTrackParent,iPidParent);
kineParent->getCreator(iParentParent,iMediumParent,iMechParent);
if(iPidParent == HPhysicsConstants::pid("eta")
|| iPidParent == HPhysicsConstants::pid("pi0") )
isFromSource = kTRUE;
if(iPidParent == HPhysicsConstants::pid("g") && iParentParent!= 0) {
kineParent =(HGeantKine*) fGeantKineCat->getObject(iParentParent-1);
kineParent->getParticle(iTrackParent,iPidParent);
if(iPidParent == HPhysicsConstants::pid("pi0") ) {
isFromSource = kTRUE;
}
}
}
if(isFromSource && isDetectable) {
partSrc = (HParticleSrc*) fPartSrcCat->getNewSlot(loc);
if(partSrc != 0) {
partSrc = new(partSrc) HParticleSrc;
partSrc->setIndex(nPart);
partSrc->setPid(iPid);
partSrc->setTrackNumber(iTrack);
kine->getMomentum(px,py,pz);
mass = HPhysicsConstants::mass(iPid);
en = sqrt( px*px + py*py + pz*pz + mass*mass);
partSrc->SetPxPyPzE(px,py,pz,en);
kine->getVertex(x,y,z);
theta = partSrc->Theta();
phi = partSrc->Phi();
r = y*cos(phi) - x*sin(phi);
z = - ( x*cos(phi) + y*sin(phi) ) * cos(theta)/sin(theta) ;
partSrc->setR(r);
partSrc->setZ(z);
nPart++;
}
}
}
return;
}
ClassImp(HParticleSimFiller)
Last change: Sat May 22 13:06:38 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.