10 #include <StEventTypes.h>
11 #include <StEmcUtil/geometry/StEmcGeom.h>
12 #include <StEmcUtil/projection/StEmcPosition.h>
13 #include <StEmcUtil/database/StBemcTables.h>
15 #include <StEmcRawMaker/defines.h>
16 #include <StEmcADCtoEMaker/StEmcADCtoEMaker.h>
18 #include <StMcEvent/StMcEvent.hh>
19 #include <StMcEvent/StMcVertex.hh>
20 #include <StMcEvent/StMcTrack.hh>
23 #include <St_DataSet.h>
24 #include <St_DataSetIter.h>
25 #include <tables/St_g2t_event_Table.h>
26 #include <tables/St_particle_Table.h>
27 #include <tables/St_g2t_pythia_Table.h>
29 #include <StDetectorDbMaker/StDetectorDbTriggerID.h>
30 #include <St_db_Maker/St_db_Maker.h>
32 #include <StEmcTriggerMaker/StEmcTriggerMaker.h>
35 #include <StEmcPool/StPhotonCommon/MyEvent.h>
36 #include <StEmcPool/StPhotonCommon/MyPoint.h>
37 #include <StEmcPool/StPhotonCommon/MyMcTrack.h>
39 #include "StPhotonMaker.h"
44 const
char *type,const
char *coll,Bool_t debug):
StMaker(name)
53 if(strcmp(type,
"mc")==0) mMc=kTRUE;
54 else if(strcmp(type,
"embed")==0) mEmbed=kTRUE;
55 else if(strcmp(type,
"pythia")==0) mPythia=kTRUE;
56 else if(strcmp(type,
"hijing")==0) mHijing=kTRUE;
62 if(strcmp(coll,
"dAu")==0){
69 if(strcmp(coll,
"pp04")==0){
76 if(strcmp(coll,
"pp05")==0){
89 StPhotonMaker::~StPhotonMaker()
94 Int_t StPhotonMaker::Init()
97 h_EvSum=
new TH1F(
"h_EvSum",
"see code for details",22,-1.5,20.5);
98 h_bsmdeAdc=
new TH1F(
"h_bsmdeAdc",
"adc",1200,-0.5,1199.5);
99 h_bsmdpAdc=
new TH1F(
"h_bsmdpAdc",
"adc",1200,-0.5,1199.5);
100 h_btowAdc=
new TH1F(
"h_btowAdc",
"adc",1200,-0.5,1199.5);
101 h_bsmdeEn=
new TH1F(
"h_bsmdeEn",
"energy",55,-1.,10.);
102 h_btowEn=
new TH1F(
"h_btowEn",
"energy",55,-1.,10.);
103 h_btowEnVsAdc=
new TH2F(
"h_btowEnVsAdc",
"h_btowEnVsAdc",1200,-0.5,1199.5,100,0.,30.);
105 mEventTree=
new TTree(
"mEventTree",
"tree with my event structure");
106 mEventTree->Branch(
"branch",
"MyEvent",&mEvent);
120 return StMaker::Init();
126 if(mDebug) cout<<endl<<
"#### processing event "<<mN<<endl<<endl;
129 StEmcGeom *bemcGeom=StEmcGeom::getEmcGeom(
"bemc");
132 event = (
StEvent*)GetInputDS(
"StEvent");
135 if(mDebug) cout <<
"************ StMyPhotonMaker::Make() no event pointer!! *********" << endl;
145 if(!mHijing && !mMc && !mPythia && mAdcMaker->
isCorrupted()){
146 if(mDebug) cout<<
"event corrupted!"<<endl;
153 mRunId=
event->runId();
154 mEventId=
event->id();
160 if(mDebug) cout<<
"starting run: "<<mRunId<<
" and event: "<<mEventId<<endl;
163 if(mRunId!=mRunPrev&&mReal){
166 if(mDebug) cout<<
"prescales: "<<DetDbTrigId.getPsL0(i)<<endl<<endl;
167 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[0]) mPs_mb=DetDbTrigId.getPsL0(i);
168 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[1]) mPs_mb2=DetDbTrigId.getPsL0(i);
169 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[2]) mPs_ht1=DetDbTrigId.getPsL0(i);
170 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[3]) mPs_ht2=DetDbTrigId.getPsL0(i);
175 mDate=(Int_t)mDbMaker->GetDateTime().GetDate();
176 mTime=(Int_t)mDbMaker->GetDateTime().GetTime();
182 Float_t zdcVertex=0.;
190 zdcEast=ZDC.adcSum(east);
191 zdcWest=ZDC.adcSum(west);
192 zdcVertex=ZDC.vertexZ();
194 bbcEast=BBC.adcSumEast();
195 bbcWest=BBC.adcSumWest();
199 mEvent=
new MyEvent(mRunId,mEventId,mDate,mTime);
201 if(mDebug) cout<<
"couldn't create MyEvent* !!"<<endl;
209 if(mPythia||mHijing){
210 mc_event=(
StMcEvent*)GetInputDS(
"StMcEvent");
213 if(mDebug) cout<<
"StPhotonMaker::Make() no McEvent"<<endl;
216 mc_pVert=mc_event->primaryVertex();
219 if(mDebug) cout<<
"StPhotonMaker::Make() no mc vertex!"<<endl;
224 mc_event=(
StMcEvent*)GetInputDS(
"StMcEvent");
227 if(mDebug) cout<<
"StPhotonMaker::Make() no McEvent"<<endl;
230 mc_pVert=mc_event->primaryVertex();
233 if(mDebug) cout<<
"StPhotonMaker::Make() no mc vertex!"<<endl;
237 StPtrVecMcTrack& trcks=mc_pVert->daughters();
238 Int_t nDaughters=mc_pVert->numberOfDaughters();
239 if(mDebug) cout<<
"number of MC part. from vertex: "<<nDaughters<<endl;
241 StMcTrackIterator it=trcks.begin();
242 Int_t pid=(*it)->particleDefinition()->pdgEncoding();
243 if(mDebug) cout<<
"daughter pid: "<<pid<<endl;
249 mytr->setEnergy((*it)->energy());
250 if((*it)->stopVertex()){
251 if((*it)->stopVertex()->daughters().size()){
252 mytr->setStopRadius((*it)->stopVertex()->position().perp());
253 if(mDebug) cout<<
"radius: "<<mytr->stopRadius()<<endl;
255 else if(mDebug) cout<<
"no size"<<endl;
257 else if(mDebug) cout<<
"no stop"<<endl;
258 mytr->setMomentum((*it)->momentum().x(),(*it)->momentum().y(),(*it)->momentum().z());
261 v.setX(bemcGeom->Radius()*cos((*it)->momentum().phi()));
262 v.setY(bemcGeom->Radius()*sin((*it)->momentum().phi()));
263 v.setZ(bemcGeom->Radius()/tan((*it)->momentum().theta()));
264 v=v + mc_pVert->position();
266 mytr->setPosition(v.x(),v.y(),v.z());
268 mEvent->setMcTrack(mytr);
271 else if(pid==111||pid==221||pid==2112||pid==-2112||pid==211||pid==130){
275 mytr->setEnergy((*it)->energy());
277 if((*it)->stopVertex()){
278 if((*it)->stopVertex()->daughters().size()){
279 mytr->setStopRadius((*it)->stopVertex()->position().perp());
284 v.setX(bemcGeom->Radius()*cos((*it)->momentum().phi()));
285 v.setY(bemcGeom->Radius()*sin((*it)->momentum().phi()));
286 v.setZ(bemcGeom->Radius()/tan((*it)->momentum().theta()));
287 v=v + mc_pVert->position();
289 mytr->setMomentum((*it)->momentum().x(),(*it)->momentum().y(),(*it)->momentum().z());
290 mytr->setPosition(v.x(),v.y(),v.z());
292 mEvent->setMcTrack(mytr);
296 if((*it)->stopVertex()){
298 StPtrVecMcTrack& gammaTracks=sVert->daughters();
299 for(StMcTrackIterator itd=gammaTracks.begin();itd!=gammaTracks.end();itd++){
300 Int_t pid2=(*itd)->particleDefinition()->pdgEncoding();
303 mytr2->setEnergy((*itd)->energy());
305 if((*itd)->stopVertex()){
306 if((*itd)->stopVertex()->daughters().size()){
307 mytr2->setStopRadius((*it)->stopVertex()->position().perp());
312 vv.setX(bemcGeom->Radius()*cos((*itd)->momentum().phi()));
313 vv.setY(bemcGeom->Radius()*sin((*itd)->momentum().phi()));
314 vv.setZ(bemcGeom->Radius()/tan((*itd)->momentum().theta()));
315 vv=vv + mc_pVert->position();
317 mytr2->setMomentum((*itd)->momentum().x(),(*itd)->momentum().y(),(*itd)->momentum().z());
318 mytr2->setPosition(vv.x(),vv.y(),vv.z());
320 mEvent->addMcPhoton(mytr2);
326 cout<<
"what kind of MC particle is this??? (shouldn't see this)"<<endl;
328 else if(mMc && nDaughters>1){
329 if(mDebug) cout<<
"more than one particle per event"<<endl;
331 StMcTrackIterator it=trcks.begin();
332 Int_t pid=(*it)->particleDefinition()->pdgEncoding();
333 if(mDebug) cout<<
"daughter pid: "<<pid<<endl;
334 if(pid==-2112 || pid==2112 || pid==221){
335 for(UInt_t i=0;i<trcks.size();i++){
336 Float_t neutronenergy=trcks[i]->energy();
339 myTR->setEnergy(neutronenergy);
340 myTR->setMomentum(trcks[i]->momentum().x(),trcks[i]->momentum().y(),trcks[i]->momentum().z());
342 v.setX(bemcGeom->Radius()*cos(trcks[i]->momentum().phi()));
343 v.setY(bemcGeom->Radius()*sin(trcks[i]->momentum().phi()));
344 v.setZ(bemcGeom->Radius()/tan(trcks[i]->momentum().theta()));
345 v=v + mc_pVert->position();
346 myTR->setPosition(v.x(),v.y(),v.z());
347 mEvent->addMcPion(myTR);
354 if(!pVert&&!mc_pVert){
356 if(mDebug) cout<<
"StPhotonMaker::Make() no primary vertex"<<endl;
362 TDataSet *gEvent=GetDataSet(
"geant");
370 St_g2t_pythia *Pg2t_pythia=(St_g2t_pythia*)geantDstI(
"g2t_pythia");
372 g2t_pythia_st *g2t_pythia1=Pg2t_pythia->GetTable();
374 float hard_p=g2t_pythia1->hard_p;
375 mEvent->setPartonPt(hard_p);
379 if(mPythia||mHijing){
380 StPtrVecMcTrack& tracs=mc_event->tracks();
381 for(UInt_t i=0;i<tracs.size();i++){
383 if(tracs[i]->geantId()==7){
384 Float_t pionenergy=tracs[i]->energy();
387 myTR->setEnergy(pionenergy);
388 myTR->setMomentum(tracs[i]->momentum().x(),tracs[i]->momentum().y(),tracs[i]->momentum().z());
390 v.setX(bemcGeom->Radius()*cos(tracs[i]->momentum().phi()));
391 v.setY(bemcGeom->Radius()*sin(tracs[i]->momentum().phi()));
392 v.setZ(bemcGeom->Radius()/tan(tracs[i]->momentum().theta()));
393 v=v + mc_pVert->position();
394 myTR->setPosition(v.x(),v.y(),v.z());
395 mEvent->addMcPion(myTR);
398 if(tracs[i]->geantId()==1){
399 Float_t photonenergy=tracs[i]->energy();
412 myTR->setEnergy(photonenergy);
413 myTR->setMomentum(tracs[i]->momentum().x(),tracs[i]->momentum().y(),tracs[i]->momentum().z());
415 v.setX(bemcGeom->Radius()*cos(tracs[i]->momentum().phi()));
416 v.setY(bemcGeom->Radius()*sin(tracs[i]->momentum().phi()));
417 v.setZ(bemcGeom->Radius()/tan(tracs[i]->momentum().theta()));
418 v=v + mc_pVert->position();
419 myTR->setPosition(v.x(),v.y(),v.z());
420 mEvent->addMcPhoton(myTR);
428 if(mDebug) cout<<
"StPhotonMaker::Make() no primary vertex ****"<<endl;
432 if(mMc||mEmbed||mPythia||mHijing){
433 mc_vPos=mc_pVert->position();
434 if(mMc||mPythia) vPos=mc_vPos;
436 if(mEmbed||mReal||mHijing){
437 if(pVert) vPos=pVert->position();
442 if(mReal&&event->triggerIdCollection()&&
event->triggerIdCollection()->nominal()){
443 if(event->triggerIdCollection()->nominal()->isTrigger(mTrig[0])||
444 event->triggerIdCollection()->nominal()->isTrigger(mTrig[1])) mTrigger+=1;
445 if(event->triggerIdCollection()->nominal()->isTrigger(mTrig[2])) mTrigger+=2;
446 if(event->triggerIdCollection()->nominal()->isTrigger(mTrig[3])) mTrigger+=4;
447 if(event->triggerIdCollection()->nominal()->isTrigger(2002)) mTrigger+=8;
451 assert(triggermaker);
456 if(triggermaker->is2005HT1()) mTrigger+=2;
457 if(triggermaker->is2005HT2()) mTrigger+=4;
460 cout<<
"check timestamp -> triggermaker"<<endl;
467 if(mDate<20050101) assert(0);
468 if(triggermaker->is2005HT1()) mTrigger+=2;
469 if(triggermaker->is2005HT2()) mTrigger+=4;
476 if(mDebug) cout<<
"nothing more useless than an event with no trigger!"<<endl;
482 if(mDebug) cout<<
"no emccollection!!"<<endl;
488 if(mDebug) cout<<
"no emcDet!!"<<endl;
495 Int_t hiTowStatus=-1;
496 Float_t hiTowEnergy=0.;
497 if(mTrigger>1 || mEmbed || mMc){
498 for(UInt_t m=1;m<=emcDet->numberOfModules();m++){
501 if(mDebug) cout<<
"no emcMod for module "<<m<<endl;
504 StSPtrVecEmcRawHit& modHits=emcMod->hits();
505 for(UInt_t h=0;h<modHits.size();h++){
506 Int_t adc=modHits[h]->adc();
507 Float_t nrg=modHits[h]->energy();
511 if(adc>hiTowAdc && nrg>0.){
514 bemcGeom->getId(m,modHits[h]->eta(),modHits[h]->sub(),hiTowId);
519 if(hiTowId>0) mBemcTables->
getStatus(BTOW,hiTowId,hiTowStatus);
530 for(UInt_t m2=1;m2<=bsmdeDet->numberOfModules();m2++){
532 StSPtrVecEmcRawHit& bsmdeHits=bsmdeMod->hits();
533 for(UInt_t h2=0;h2<bsmdeHits.size();h2++){
534 h_bsmdeAdc->Fill(bsmdeHits[h2]->adc());
537 for(UInt_t m2=1;m2<=bsmdpDet->numberOfModules();m2++){
539 StSPtrVecEmcRawHit& bsmdpHits=bsmdpMod->hits();
540 for(UInt_t h2=0;h2<bsmdpHits.size();h2++){
541 h_bsmdpAdc->Fill(bsmdpHits[h2]->adc());
546 StSPtrVecEmcPoint& barrelPoints=emcCol->barrelPoints();
548 Int_t nGoodPrimaries=0;
549 Int_t nGoodPrimBarrel=0;
550 Int_t nGoodGlobals=0;
552 Float_t TpcPtBarrelWest=0.;
553 if(event->primaryVertex()){
554 nPrimTracks=pVert->numberOfDaughters();
555 StSPtrVecTrackNode& trackNode=
event->trackNodes();
556 if(mDebug) cout<<
"number of tracknodes: "<<trackNode.size()<<endl;
557 for(UInt_t j=0;j<trackNode.size();j++){
559 if(track && track->flag()>0 && track->geometry()){
561 Double_t pathlength=track->geometry()->helix().
pathLength(vPos,kFALSE);
562 StThreeVectorD v=track->geometry()->helix().at(pathlength) - vPos;
566 unsigned short numFitPoints=fitTraits.numberOfFitPoints();
567 if(numFitPoints>15&&dca<3.){
569 Float_t tracEta=track->geometry()->momentum().pseudoRapidity();
570 if(tracEta>0.&&tracEta<1.){
572 TpcPtBarrelWest+=track->geometry()->momentum().perp();
574 TpcPt+=track->geometry()->momentum().perp();
578 if(gtrack && gtrack->flag()>0 && gtrack->geometry()){
580 unsigned short numFitPointsG=fitTraitsG.numberOfFitPoints();
581 if(numFitPointsG>15) nGoodGlobals++;
587 Int_t ftpcRefMultTracks=0;
588 if(event->primaryVertex()){
589 const StSPtrVecPrimaryTrack& tracks=pVert->daughters();
590 for(StSPtrVecPrimaryTrackConstIterator iter = tracks.begin(); iter != tracks.end(); iter++){
592 if(!track->geometry()){
593 if(mDebug) cout<<
"no track geometry! -> NEXT"<<endl;
597 if(track->fitTraits().numberOfFitPoints()<6||(track->fitTraits().numberOfFitPoints()>11))
600 if(track->geometry()->momentum().pseudoRapidity()>-2.8||track->geometry()->momentum().pseudoRapidity()<=-3.8)
603 if(track->geometry()->momentum().perp()>=3.)
606 StTrack *glt=track->node()->track(global);
608 if(mDebug) cout<<
"no global track!"<<endl;
611 if(!glt->geometry()){
612 if(mDebug) cout<<
"no geom.!"<<endl;
615 if(glt->geometry()->helix().
distance(vPos)<3.) ftpcRefMultTracks++;
621 Float_t EnergyNeutral=0.;
622 for(UInt_t i=0;i<barrelPoints.size();i++)
628 if(!calcDistanceTrackToPoint(pt,dist)){
629 cout<<
"wrong bfield or no StEvent pointer (shouldn't see this)"<<endl;
631 if(pt->position().pseudoRapidity()>0.0)
632 EnergyNeutral+=pt->energy();
634 StPtrVecEmcCluster& etaClus=pt->cluster(kBarrelSmdEtaStripId);
635 StPtrVecEmcCluster& phiClus=pt->cluster(kBarrelSmdPhiStripId);
638 Float_t etaEnergy=0.;
639 Float_t phiEnergy=0.;
642 if(etaClus.size()>0){
644 StPtrVecEmcRawHit& hE=clE->hit();
646 etaEnergy=clE->energy();
647 etaWidth=clE->sigmaEta();
649 if(phiClus.size()>0){
651 StPtrVecEmcRawHit& hP=clP->hit();
653 phiEnergy=clP->energy();
654 phiWidth=clP->sigmaPhi();
656 mypt->setEnergy(pt->energy());
657 mypt->setQuality((Int_t)pt->quality());
658 mypt->setPosition(pt->position().x(),pt->position().y(),pt->position().z());
659 mypt->setDistanceToTrack(dist);
660 mypt->setHitsEta(nEtaHits);
661 mypt->setWidthEta(etaWidth);
662 mypt->setEnergyEta(etaEnergy);
663 mypt->setHitsPhi(nPhiHits);
664 mypt->setWidthPhi(phiWidth);
665 mypt->setEnergyPhi(phiEnergy);
666 mEvent->addPoint(mypt);
673 mEvent->setPrescale(0,mPs_mb);
674 mEvent->setPrescale(1,mPs_mb2);
675 mEvent->setPrescale(2,mPs_ht1);
676 mEvent->setPrescale(3,mPs_ht2);
677 mEvent->setHighTowerAdc(hiTowAdc);
678 mEvent->setHighTowerId(hiTowId);
679 mEvent->setHighTowerStatus(hiTowStatus);
680 mEvent->setHighTowerEnergy(hiTowEnergy);
681 mEvent->setVertex(vPos.x(),vPos.y(),vPos.z());
682 mEvent->setTrigger(mTrigger);
683 mEvent->setGoodPrimaries(nGoodPrimaries);
684 mEvent->setGoodPrimBarrel(nGoodPrimBarrel);
685 mEvent->setGoodGlobals(nGoodGlobals);
686 mEvent->setRefMult(ftpcRefMultTracks);
687 mEvent->setEnergyInBarrel(EnergyNeutral);
688 mEvent->setMomentumInTpc(TpcPt);
689 mEvent->setMomentumInTpcWest(TpcPtBarrelWest);
690 mEvent->setCtbSum(mips);
691 mEvent->setBbcSumEast(bbcEast);
692 mEvent->setBbcSumWest(bbcWest);
693 mEvent->setZdcSumEast(zdcEast);
694 mEvent->setZdcSumWest(zdcWest);
695 mEvent->setZdcVertexZ(zdcVertex);
697 mEvent->setZdcVertexZ(mc_vPos.z());
716 void StPhotonMaker::saveHistograms()
718 if(mDebug) cout<<
"************ saving histograms ****************"<<endl;
719 TFile *hfile=(TFile*)gROOT->FindObject(mFileName);
720 if(hfile) hfile->Close();
721 hfile=
new TFile(mFileName,
"RECREATE");
746 Bool_t StPhotonMaker::calcDistanceTrackToPoint(
StEmcPoint *point,Float_t &distanceToTrack)
750 if(mDebug) cout<<
"can't get Event pointer"<<endl;
757 bFld = summary->magneticField()/10.;
758 if(mDebug) cout<<
"summary()->magneticField()="<<bFld<<
"(Tesla)"<<endl;
760 if(TMath::Abs(bFld)<0.01&&!mMc){
761 if(mDebug) cout<<
"wrong mBField!"<<endl;
766 StSPtrVecTrackNode& trackNodes =
event->trackNodes();
768 distanceToTrack=999.;
769 for (
size_t nodeIndex=0; nodeIndex<trackNodes.size();nodeIndex++){
770 size_t numberOfTracksInNode=trackNodes[nodeIndex]->entries(global);
771 for(
size_t trackIndex=0; trackIndex<numberOfTracksInNode;trackIndex++){
772 track = trackNodes[nodeIndex]->track(primary,trackIndex);
773 if (track && track->flag()>=0){
774 if(track->geometry()->momentum().mag()<.5)
continue;
776 Bool_t projOK=emcPosition->
projTrack(&pos,&mom,track,bFld,230.705,1);
777 if(!projOK)
continue;
778 Float_t d=(pos - point->position()).mag();
779 if(d<distanceToTrack&&d>0.) distanceToTrack=d;
Bool_t isCorrupted()
Returns if BTOW is corrupted or not.
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
pair< double, double > pathLength(double r) const
path length at given r (cylindrical r)
Accessor to the database for trigger id information.
void loadTables(StMaker *anyMaker)
load tables.
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
Bool_t projTrack(StThreeVectorD *atFinal, StThreeVectorD *momentumAtFinal, const StTrack *const track, Double_t magField, Double_t radius=225.405, Int_t option=1) const
Track projection utility.
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...