using namespace std;
#include <iostream>
#include <iomanip>
#include <math.h>
#include <time.h>
#include "TMath.h"
#include "hades.h"
#include "hcategory.h"
#include "hcutleptonid.h"
#include "hcuthadronid.h"
#include "hcuttrack.h"
#include "hdebug.h"
#include "hevent.h"
#include "hgeomvector.h"
#include "hgeomvolume.h"
#include "hgeomtransform.h"
#include "hiterator.h"
#include "hkicktrack.h"
#include "hlinearcategory.h"
#include "hlocation.h"
#include "hpartialevent.h"
#include "hparticle.h"
#include "hparticlefiller.h"
#include "hphysicsconstants.h"
#include "hrecevent.h"
#include "hrichhit.h"
#include "hruntimedb.h"
#include "hspecgeompar.h"
#include "hspectrometer.h"
#include "kickdef.h"
#include "phyanadef.h"
#include "richdef.h"
HParticleFiller::HParticleFiller(void) {
fPartCat=0;
fKickTrackCat=0;
fRichHitCat=0;
iterTracks=0;
iterRings=0;
kSkip = kFALSE;
trackCuts = 0;
leptonCuts = 0;
hadronIdCuts = 0;
}
HParticleFiller::HParticleFiller(const Text_t *name,const Text_t *title,Bool_t skip) :
HReconstructor(name,title) {
fPartCat=0;
fKickTrackCat=0;
fRichHitCat=0;
iterTracks=0;
iterRings=0;
fSpecGeometry=0;
kSkip = skip;
trackCuts = 0;
leptonCuts = 0;
hadronIdCuts = 0;
}
Bool_t HParticleFiller::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) {
Error("init","RichHit not found in input file");
return kFALSE;
}
iterRings = (HIterator *)fRichHitCat->MakeIterator("native");
fPartCat=gHades->getCurrentEvent()->getCategory(catParticle);
if (!fPartCat) {
fPartCat = new HLinearCategory("HParticle",1000);
if (fPartCat) gHades->getCurrentEvent()->addCategory(catParticle,
fPartCat,"PhyAna");
else {
Error("init","Unable to setup output");
return kFALSE;
}
}
return kTRUE;
}
Int_t HParticleFiller::execute(void) {
HParticle *part = 0;
HKickTrack *track = 0;
HRichHit *ring = 0;
HLocation loc;
Int_t nLeptons = 0;
Int_t nPart = 0;
iterTracks->Reset();
while ((track=(HKickTrack*) iterTracks->Next())!=0) {
if(trackCuts && !trackCuts->check(track)) continue;
part = (HParticle*) fPartCat->getNewSlot(loc);
if(part != 0) {
part = new(part) HParticle;
part->setTrackId( fKickTrackCat->getIndex(track) );
part->setIndex(nPart);
fillMomenta(track,part);
fillVertex(track,part);
iterRings->Reset();
while ((ring=(HRichHit*) 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(nPart == 0 && kSkip == kTRUE) return kSkipEvent;
return 0;
}
void HParticleFiller::fillMomenta(HKickTrack *track, HParticle *part) {
Float_t px,py,pz,en,mass;
HGeomVector alpha;
HGeomVector alphaLocal;
HGeomTransform &transSec = fSpecGeometry->getSector( track->getSector() )->getTransform();
alphaLocal.setX(sin(track->getTheta())*cos(track->getPhi()));
alphaLocal.setY(sin(track->getTheta())*sin(track->getPhi()));
alphaLocal.setZ(cos(track->getTheta()));
alpha = transSec.getRotMatrix() * alphaLocal;
px = alpha.getX() * track->getP();
py = alpha.getY() * track->getP();
pz = alpha.getZ() * track->getP();
if(part->getPid()) mass = HPhysicsConstants::mass(part->getPid());
else mass = sqrt(track->getMass());
en = sqrt( mass*mass + px*px + py*py + pz*pz );
part->SetPxPyPzE(px,py,pz,en);
}
void HParticleFiller::fillVertex(HKickTrack *track, HParticle *part) {
part->setR(track->getR());
part->setZ(track->getZ());
}
void HParticleFiller::makeLepton(HRichHit *ring, HParticle *part) {
Float_t mass;
HKickTrack *track = (HKickTrack*) fKickTrackCat->getObject(part->getTrackId());
if(track->getCharge() == 1) part->setPid("e+");
if(track->getCharge() == -1) part->setPid("e-");
mass = HPhysicsConstants::mass("e-");
part->SetE(sqrt( part->P()*part->P() + mass*mass ));
}
ClassImp(HParticleFiller)
Last change: Sat May 22 13:06:36 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.