9 #include <StEventTypes.h>
11 #include <StMuDSTMaker/COMMON/StMuTrack.h>
12 #include <StMuDSTMaker/COMMON/StMuDst.h>
13 #include <StMuDSTMaker/COMMON/StMuEvent.h>
14 #include <StMuDSTMaker/COMMON/StMuTriggerIdCollection.h>
15 #include <StMuDSTMaker/COMMON/StMuPrimaryVertex.h>
17 #include <StEmcUtil/geometry/StEmcGeom.h>
18 #include <StEmcUtil/projection/StEmcPosition.h>
19 #include <StEmcUtil/database/StBemcTables.h>
20 #include <StEmcUtil/others/emcDetectorName.h>
21 #include <StEmcRawMaker/defines.h>
23 #include <St_db_Maker/St_db_Maker.h>
24 #include <StEmcADCtoEMaker/StEmcADCtoEMaker.h>
25 #include <StDetectorDbMaker/StDetectorDbTriggerID.h>
28 #include <StEmcPool/StPhotonCommon/MyEvent.h>
29 #include <StEmcPool/StPhotonCommon/MyPoint.h>
30 #include <StEmcPool/StPhotonCommon/MyMcTrack.h>
32 #include "StMyEventMaker.h"
37 const
char *type,const
char *coll,Bool_t debug):
StMaker(name)
41 if(strcmp(type,
"real")!=0){
42 cout<<
"not running on real data??"<<endl;
50 if(strcmp(coll,
"dAu")==0){
57 if(strcmp(coll,
"pp04")==0){
64 if(strcmp(coll,
"pp05")==0){
71 if(strcmp(coll,
"auau200")==0){
85 StMyEventMaker::~StMyEventMaker()
90 Int_t StMyEventMaker::Init()
93 h_EvSum=
new TH1F(
"h_EvSum",
"see code for details",22,-1.5,20.5);
95 mEventTree=
new TTree(
"mEventTree",
"tree with my event structure");
96 mEventTree->Branch(
"branch",
"MyEvent",&mEvent);
110 return StMaker::Init();
116 if(mDebug) cout<<endl<<
"#### processing event "<<mN<<endl<<endl;
119 StEmcGeom *bemcGeom=StEmcGeom::getEmcGeom(
"bemc");
123 if(mDebug) cout <<
"********* no StMuDst*"<<endl;
127 if(mDebug) cout<<
"number of primverts: "<<mu->numberOfPrimaryVertices()<<endl;
131 if(mDebug) cout <<
"********* no StMuEvent*"<<endl;
136 mRunId=muEvent->runId();
137 mEventId=muEvent->eventId();
138 if(mDebug) cout<<
"starting run: "<<mRunId<<
" and event: "<<mEventId<<endl;
141 if(mDebug) cout<<
"event corrupted!"<<endl;
146 if(mRunId!=mRunPrev){
149 if(mDebug) cout<<
"prescales: "<<DetDbTrigId.getPsL0(i)<<endl<<endl;
150 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[0])
151 mPs_mb=DetDbTrigId.getPsL0(i);
152 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[1])
153 mPs_mb2=DetDbTrigId.getPsL0(i);
154 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[2])
155 mPs_ht1=DetDbTrigId.getPsL0(i);
156 if(DetDbTrigId.getL0OfflineTrgId(i)==mTrig[3])
157 mPs_ht2=DetDbTrigId.getPsL0(i);
163 mDate=(Int_t)mDbMaker->GetDateTime().GetDate();
164 mTime=(Int_t)mDbMaker->GetDateTime().GetTime();
170 Float_t zdcVertex=0.;
176 zdcEast=ZDC.adcSum(east);
177 zdcWest=ZDC.adcSum(west);
178 zdcVertex=ZDC.vertexZ();
180 bbcEast=BBC.adcSumEastLarge();
181 bbcWest=BBC.adcSumWestLarge();
184 int west=BBC.tdcEarliestWest();
185 int east=BBC.tdcEarliestEast();
187 float BBCVertexZ = 10.77 + 2.82*diff;
194 mEvent=
new MyEvent(mRunId,mEventId,mDate,mTime);
196 if(mDebug) cout<<
"couldn't create MyEvent*"<<endl;
204 vPos=muVert->position();
219 if(fabs(vPos.z())>30.){
220 if(mDebug) cout<<
"vertex out of range"<<endl;
227 if(muEvent->triggerIdCollection().nominal().isTrigger(mTrig[0])||
228 muEvent->triggerIdCollection().nominal().isTrigger(mTrig[1])) mTrigger+=1;
229 if(muEvent->triggerIdCollection().nominal().isTrigger(mTrig[2])) mTrigger+=2;
230 if(muEvent->triggerIdCollection().nominal().isTrigger(mTrig[3])) mTrigger+=4;
231 if(muEvent->triggerIdCollection().nominal().isTrigger(2002)) mTrigger+=8;
234 if(mDebug) cout<<
"nothing more useless than an event with no trigger!"<<endl;
240 if(mDebug) cout<<
"no StEmcCollection"<<endl;
247 if(mDebug) cout<<
"no emcDet!!"<<endl;
254 Int_t hiTowStatus=-1;
255 Float_t hiTowEnergy=0.;
257 for(UInt_t m=1;m<=emcDet->numberOfModules();m++){
260 if(mDebug) cout<<
"no emcMod for module "<<m<<endl;
263 StSPtrVecEmcRawHit& modHits=emcMod->hits();
264 for(UInt_t h=0;h<modHits.size();h++){
265 Int_t adc=modHits[h]->adc();
266 Float_t nrg=modHits[h]->energy();
267 if(adc>hiTowAdc && nrg>0.){
270 bemcGeom->getId(m,modHits[h]->eta(),modHits[h]->sub(),hiTowId);
275 if(hiTowId>0) mBemcTables->
getStatus(BTOW,hiTowId,hiTowStatus);
279 Int_t nGlobalTracks=0;
280 Int_t nGoodPrimaries=0;
281 Int_t nGoodPrimBarrel=0;
282 Int_t nGoodGlobals=0;
284 Float_t TpcPtBarrelWest=0.;
289 for(Int_t i=0;i<nPrimTracks;i++){
291 if(ptrack->bad())
continue;
292 if(ptrack->
dca().mag()<3. && ptrack->
nHitsFit()>15){
295 if(fabs(ptrack->
eta() - 0.5)<0.5){
297 TpcPtBarrelWest+=ptrack->
momentum().mag();
303 for(Int_t i=0;i<nGlobalTracks;i++){
305 if(gtrack->bad())
continue;
306 if(gtrack->
dca().mag()<3. && gtrack->
nHitsFit()>15)
312 if(mAUAU200) ftpcRefMultTracks=muEvent->
refMult();
313 if(mDebug) cout<<
"event has refMult: "<<ftpcRefMultTracks<<endl;
317 Float_t EnergyNeutral=0.;
320 StSPtrVecEmcPoint& barrelPoints=emcCol->barrelPoints();
321 for(UInt_t i=0;i<barrelPoints.size();i++){
325 if(!calcDistanceTrackToPoint(pt,mu,dist)){
326 cout<<
"wrong bfield or no event pointer (shouldn't see this)"<<endl;
330 if(pt->position().pseudoRapidity()>0.0)
331 EnergyNeutral+=pt->energy();
333 StPtrVecEmcCluster& etaClus=pt->cluster(kBarrelSmdEtaStripId);
334 StPtrVecEmcCluster& phiClus=pt->cluster(kBarrelSmdPhiStripId);
337 Float_t etaEnergy=0.;
338 Float_t phiEnergy=0.;
341 if(etaClus.size()>0){
343 StPtrVecEmcRawHit& hE=clE->hit();
345 etaEnergy=clE->energy();
346 etaWidth=clE->sigmaEta();
348 if(phiClus.size()>0){
350 StPtrVecEmcRawHit& hP=clP->hit();
352 phiEnergy=clP->energy();
353 phiWidth=clP->sigmaPhi();
356 if( mAUAU200 && (nEtaHits<1||nPhiHits<1) ){
361 mypt->setEnergy(pt->energy());
362 mypt->setQuality((Int_t)pt->quality());
363 mypt->setPosition(pt->position().x(),pt->position().y(),pt->position().z());
364 mypt->setDistanceToTrack(dist);
365 mypt->setHitsEta(nEtaHits);
366 mypt->setWidthEta(etaWidth);
367 mypt->setEnergyEta(etaEnergy);
368 mypt->setHitsPhi(nPhiHits);
369 mypt->setWidthPhi(phiWidth);
370 mypt->setEnergyPhi(phiEnergy);
372 mEvent->addPoint(mypt);
378 mEvent->setPrescale(0,mPs_mb);
379 mEvent->setPrescale(1,mPs_mb2);
380 mEvent->setPrescale(2,mPs_ht1);
381 mEvent->setPrescale(3,mPs_ht2);
382 mEvent->setHighTowerAdc(hiTowAdc);
383 mEvent->setHighTowerId(hiTowId);
384 mEvent->setHighTowerStatus(hiTowStatus);
385 mEvent->setHighTowerEnergy(hiTowEnergy);
386 mEvent->setVertex(vPos.x(),vPos.y(),vPos.z());
387 mEvent->setTrigger(mTrigger);
388 mEvent->setGoodPrimaries(nGoodPrimaries);
389 mEvent->setGoodPrimBarrel(nGoodPrimBarrel);
390 mEvent->setGoodGlobals(nGoodGlobals);
391 mEvent->setRefMult(ftpcRefMultTracks);
392 mEvent->setEnergyInBarrel(EnergyNeutral);
393 mEvent->setMomentumInTpc(TpcPt);
394 mEvent->setMomentumInTpcWest(TpcPtBarrelWest);
395 mEvent->setCtbSum(mips);
396 mEvent->setBbcSumEast(bbcEast);
397 mEvent->setBbcSumWest(bbcWest);
398 mEvent->setZdcSumEast(zdcEast);
399 mEvent->setZdcSumWest(zdcWest);
400 mEvent->setZdcVertexZ(zdcVertex);
401 mEvent->setBbcVertexZ(BBCVertexZ);
414 void StMyEventMaker::saveHistograms()
416 if(mDebug) cout<<
"************ saving histograms ****************"<<endl;
417 TFile *hfile=(TFile*)gROOT->FindObject(mFileName);
418 if(hfile) hfile->Close();
419 hfile=
new TFile(mFileName,
"RECREATE");
427 Bool_t StMyEventMaker::calcDistanceTrackToPoint(
StEmcPoint *point,
StMuDst *currMuDst,Float_t &distanceToTrack)
430 if(!muEv)
return kFALSE;
431 Double_t bFld=muEv->magneticField()/10.;
432 if(mDebug) cout<<
"summary()->magneticField()="<<bFld<<
"(Tesla)"<<endl;
435 if(mDebug) cout<<
"wrong/no BField!"<<endl;
441 distanceToTrack=999.;
445 for(Int_t i=0;i<ntracks;i++){
447 if(track->bad())
continue;
450 Bool_t projOK=emcPosition->
projTrack(&pos,&mom,&helix,bFld,230.705,1);
451 if(!projOK)
continue;
452 Float_t d=(pos - point->position()).mag();
454 if(d<distanceToTrack&&d>0.) distanceToTrack=d;
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
static TObjArray * globalTracks()
returns pointer to the global tracks list
StThreeVectorF primaryVertexPosition(int vtx_id=-1) const
The StMuDst is supposed to be structured in 'physical events'. Therefore there is only 1 primary vert...
Bool_t isCorrupted()
Returns if BTOW is corrupted or not.
UShort_t nHitsFit() const
Return total number of hits used in fit.
Accessor to the database for trigger id information.
void loadTables(StMaker *anyMaker)
load tables.
Double_t eta() const
Returns pseudo rapidity at point of dca to primary vertex.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
unsigned short refMult(int vtx_id=-1)
Reference multiplicity of charged particles as defined in StEventUtilities/StuRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
const StThreeVectorF & momentum() const
Returns 3-momentum at dca to primary vertex.
StThreeVectorF dca(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex.
static StEmcCollection * emcCollection()
returns pointer to current StEmcCollection
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.
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
unsigned short refMultFtpcEast(int vtx_id=-1)
Reference multiplicity of particles in the east FTPC as defined in StEventUtilities/StuFtpcRefMult.hh for vertex vtx_id (-1 is default index from StMuDst)