1 #include "StEmcMicroUtil.h"
3 #include "StEventTypes.h"
4 #include "StEmcMicroEvent.h"
5 #include "SystemOfUnits.h"
6 #include "StEmcUtil/geometry/StEmcGeom.h"
7 #include "StEmcUtil/others/emcDetectorName.h"
8 #include "StEmcUtil/filters/StEmcFilter.h"
14 for(Int_t i =0;i<4;i++) mGeo[i]=StEmcGeom::getEmcGeom(detname[i].Data());
16 StEmcMicroUtil::~StEmcMicroUtil()
20 void StEmcMicroUtil::clearGarbage()
22 for(Int_t i=0;i<mNV0Tracks;i++)
24 if(mV0Tracks[i]) {
delete mV0Tracks[i]; mV0Tracks[i]=NULL; }
30 if(!event)
return NULL;
39 if(!event)
return NULL;
57 cout <<
"filling general info\n";
62 if(summary) BF = summary->magneticField()/10.;
63 mMicroEvent->setBField(BF);
68 mMicroEvent->setL0TriggerWord(pTrigger->triggerWord());
69 mMicroEvent->setToken(pTrigger->triggerToken());
70 mMicroEvent->setBunchCrossing(pTrigger->bunchCrossingId());
71 mMicroEvent->setBunchCrossing7bit(pTrigger->bunchCrossingId7bit(mStEvent->runId()));
73 mMicroEvent->setSpinBits(pTrigger->spinBits());
77 mMicroEvent->setEventID((Int_t)(mStEvent->id()));
78 mMicroEvent->setRunID((Int_t)(mStEvent->runId()));
79 mMicroEvent->setEventTime((Int_t)mStEvent->time());
86 mMicroEvent->setVertexPos(vertex.x(),vertex.y(),vertex.z());
88 UInt_t origMult = primaryVertex->numberOfDaughters();
89 mMicroEvent->setOrigMult(origMult);
111 for (UInt_t slat=0; slat<CTB.numberOfSlats(); slat++)
112 for (UInt_t tray=0; tray<CTB.numberOfTrays();tray++)
113 ctb += (Int_t)CTB.mips(tray,slat,0);
116 zdce = (Int_t)ZDC.adcSum(east);
117 zdcw = (Int_t)ZDC.adcSum(west);
118 zdcvz = (Float_t)ZDC.vertexZ();
120 bbcw = (Int_t)BBC.adcSumWest();
121 bbce = (Int_t)BBC.adcSumEast();
122 bbcnh = (Int_t)BBC.nHitAll();
123 bbcvz = (Float_t)BBC.zVertex();
125 for(Int_t i=0;i<300;i++)
127 Int_t HT = EMC.highTower(i);
128 Int_t PA = EMC.patch(i);
129 mMicroEvent->setHighTower(i,HT);
130 mMicroEvent->setPatch(i,PA);
133 mMicroEvent->setCTB(ctb);
134 mMicroEvent->setZDCe(zdce);
135 mMicroEvent->setZDCw(zdcw);
136 mMicroEvent->setZVertexZDC(zdcvz);
137 mMicroEvent->setBBCw(bbcw);
138 mMicroEvent->setBBCw(bbce);
139 mMicroEvent->setBBCNHits(bbcnh);
140 mMicroEvent->setZVertexBBC(bbcvz);
144 cout <<
"filling tracks\n";
145 int totalp=0,goodp=0,totalg=0,goodg=0;
147 StSPtrVecTrackNode& trackNode = mStEvent->trackNodes();
148 for (
unsigned int j=0; j < trackNode.size(); j++)
150 StTrack* gTrack = (trackNode[j]->track(global));
151 StTrack* pTrack = (trackNode[j]->track(primary));
154 if (pTrack && mDoSavePrimaries)
157 if(mPFilter->
accept(pTrack))
164 MicroPTrack->setTrackNodeNumber(j);
165 mMicroEvent->addPrimaryTrack(MicroPTrack);
171 if (gTrack && mDoSaveGlobals)
174 if (mGFilter->
accept(gTrack))
180 MicroGTrack->setTrackNodeNumber(j);
181 mMicroEvent->addGlobalTrack(MicroGTrack);
187 cout <<
"Total primary tracks = "<<totalp<<
" good = "<<goodp<<endl;
188 cout <<
"Total global tracks = "<<totalg<<
" good = "<<goodg<<endl;
189 cout <<
"finished filing tracks\n";
194 if(p.mag()==0)
return;
198 MicroTrack->setP(p.mag());
199 MicroTrack->setEta(p.pseudoRapidity());
200 MicroTrack->setPhi(p.phi());
201 MicroTrack->setCurvature(track->geometry()->curvature());
203 MicroTrack->setFlag(track->flag());
205 MicroTrack->setOrigin(o.x(),o.y(),o.z());
207 MicroTrack->setCharge(track->geometry()->charge());
209 MicroTrack->setDca(track->impactParameter());
212 MicroTrack->setDcaSigned(dcaSigned);
214 MicroTrack->setChi2((Float_t)(track->fitTraits().chi2()));
215 MicroTrack->setFitPts(track->fitTraits().numberOfFitPoints());
216 MicroTrack->setMaxPts(track->numberOfPossiblePoints());
218 if(track->detectorInfo())
219 MicroTrack->setNhits(track->detectorInfo()->numberOfPoints(kTpcId));
222 StPtrVecTrackPidTraits traits = track->pidTraits(kTpcId);
223 unsigned int size = traits.size();
228 for (
unsigned int i = 0; i < traits.size(); i++)
231 if (pid && pid->method() == kTruncatedMeanId)
break;
235 double dEdX = (double)pid->mean();
236 double npt = (double)pid->numberOfPoints();
237 double dEdXErr = (double)pid->errorOnMean();
238 MicroTrack->setDedxErr(dEdXErr);
239 MicroTrack->setDedx((Float_t) dEdX);
240 MicroTrack->setNdedxPts((Int_t)npt);
243 MicroTrack->setTrackLength(track->length());
255 double xCenter = track->geometry()->helix().
xcenter();
256 double yCenter = track->geometry()->helix().
ycenter();
257 double radius = 1.0/track->geometry()->helix().curvature();
259 double dPosCenter = ::sqrt( (pos.x() - xCenter) * (pos.x() - xCenter) +
260 (pos.y() - yCenter) * (pos.y() - yCenter));
262 return (Float_t) (radius - dPosCenter);
266 cout <<
"Filling V0īs\n";
268 StSPtrVecV0Vertex& v0=mStEvent->v0Vertices();
269 if(v0.size()==0)
return;
271 for(Int_t i = 0;i<(Int_t)v0.size();i++)
274 if(v)
if(mGFilter->
accept(v))
279 for(Int_t j=0;j<2;j++)
286 if(mtr) mv->setDaughter(j,mtr);
290 mv->setVertex(pos.x(),pos.y(),pos.z());
291 mMicroEvent->addV0(mv);
294 cout <<
"Total V0īs accepted = "<<nV<<endl;
306 for(Int_t d=0; d<4; d++)
309 for(Int_t i=0;i<18000;i++) HitsId[i]=-1;
311 StDetectorId
id =
static_cast<StDetectorId
>(d+kBarrelEmcTowerId);
313 if(!detector) cout <<detname[d].Data()<<
" not loaded\n";
317 cout <<
"Filling hits for detector "<<detname[d].Data()<<endl;
320 for(UInt_t j=1;j<121;j++)
325 StSPtrVecEmcRawHit& rawHit=module->hits();
326 Int_t nhits=(Int_t)rawHit.size();
328 for(Int_t k=0;k<nhits;k++)
330 Int_t m = rawHit[k]->module();
331 Int_t e = rawHit[k]->eta();
332 Int_t s = abs(rawHit[k]->sub());
333 Int_t adc = rawHit[k]->adc();
334 Float_t energy = rawHit[k]->energy();
338 Microhit->setModule(m);
341 Microhit->setAdc(adc);
342 Microhit->setEnergy(energy);
344 Microemc->addHit(EmcDet,Microhit);
346 mGeo[d]->getId(m,e,s,rid);
347 HitsId[rid-1] = HitIndex;
355 if(detector->cluster())
357 StSPtrVecEmcCluster& cluster=detector->cluster()->clusters();
358 Int_t totalcluster=(Int_t)cluster.size();
359 cout <<
"Filling clusters for detector "<<detname[d].Data()<<endl;
360 cout <<
"Number of clusters = "<<totalcluster<<endl;
362 for(Int_t j=0;j<totalcluster;j++)
366 Microcl->setEta(cluster[j]->eta());
367 Microcl->setPhi(cluster[j]->phi());
368 Microcl->setSigmaEta(cluster[j]->sigmaEta());
369 Microcl->setSigmaPhi(cluster[j]->sigmaPhi());
370 Microcl->setEnergy(cluster[j]->energy());
372 StPtrVecEmcRawHit& rawHit=cluster[j]->hit();
373 Int_t nhit=(Int_t)rawHit.size();
375 for(Int_t k=0;k<nhit;k++)
377 Int_t m = rawHit[k]->module();
378 Int_t e = rawHit[k]->eta();
379 Int_t s = abs(rawHit[k]->sub());
381 mGeo[d]->getId(m,e,s,rid);
382 Int_t index = HitsId[rid-1];
383 if(index!=-1) Microcl->addHit(Microemc->
getHit(EmcDet,index));
385 Microemc->addCluster(EmcDet,Microcl);
393 cout <<
"Filling points "<<endl;
395 StSPtrVecEmcPoint& points=emccol->barrelPoints();
396 Int_t npoints=points.size();
399 for(Int_t p=0;p<npoints;p++)
404 Micropt->setEta(position.pseudoRapidity());
405 Micropt->setPhi(position.phi());
406 Micropt->setDeltaEta(point->deltaEta());
407 Micropt->setDeltaPhi(point->deltaPhi());
408 Micropt->setEnergy(point->energy());
409 Micropt->setChiSquare(point->chiSquare());
411 for(Int_t d=0;d<4;d++)
414 StDetectorId detid=
static_cast<StDetectorId
>(d+kBarrelEmcTowerId);
415 StPtrVecEmcCluster& cluster=point->cluster(detid);
418 for(Int_t i=0;i<ptnc;i++)
if(cluster[i])
420 Float_t eta = cluster[i]->eta();
421 Float_t phi = cluster[i]->phi();
427 Micropt->addCluster(det,cl);
434 Microemc->addPoint(Micropt);
440 mMicroEvent->setEmc(Microemc);
441 cout <<
"Finished filling EMC\n";
447 cout <<
"Filling FPD ...\n";
453 Microfpd->setToken(fpd->token());
454 Microfpd->setSumAdcNorth(fpd->sumAdcNorth());
455 Microfpd->setSumAdcSouth(fpd->sumAdcSouth());
456 Microfpd->setSumAdcTop(fpd->sumAdcTop());
457 Microfpd->setSumAdcBottom(fpd->sumAdcBottom());
458 Microfpd->setSumAdcPreShower1(fpd->sumAdcPreShower1());
459 Microfpd->setSumAdcPreShower2(fpd->sumAdcPreShower2());
460 Microfpd->setSumAdcSmdX(fpd->sumAdcSmdX());
461 Microfpd->setSumAdcSmdY(fpd->sumAdcSmdY());
463 mMicroEvent->setFpd(Microfpd);
464 cout <<
"Finished filling FPD\n";
480 summary->setMagneticField(mMicroEvent->
getBField()*10.);
482 mStEvent->setSummary(summary);
484 mStEvent->setRunId(mMicroEvent->
getRunID());
490 mStEvent->setL0Trigger(L0);
499 ZDC.setAdcSum(east,mMicroEvent->
getZDCe());
500 ZDC.setAdcSum(west,mMicroEvent->
getZDCw());
501 ZDC.setAdcSum((Float_t)(mMicroEvent->
getZDCe()+mMicroEvent->
getZDCw()));
504 for(Int_t i=0;i<300;i++)
507 EMC.setPatch(i,mMicroEvent->
getPatch(i));
510 mStEvent->setTriggerDetectorCollection(triggers);
514 vertex->setPosition(p);
515 mStEvent->addPrimaryVertex(vertex);
522 StSPtrVecTrackNode& node=mStEvent->trackNodes();
525 Int_t maxNode=0,gnode,pnode;
533 for(Int_t i=0;i<max;i++)
537 if(gnode>maxNode) maxNode=gnode;
538 if(pnode>maxNode) maxNode=pnode;
542 for(Int_t i=0;i<10000;i++) trackNode[i] = NULL;
544 for(Int_t i=0;i<max;i++)
550 if(!trackNode[gnode]) trackNode[gnode]=
new StTrackNode();
554 trackNode[gnode]->addTrack(gTrack);
560 if(!trackNode[pnode]) trackNode[pnode]=
new StTrackNode();
564 pTrack->setVertex(vertex);
565 vertex->addDaughter(pTrack);
566 trackNode[pnode]->addTrack(pTrack);
569 for(Int_t i=0;i<10000;i++)
572 Int_t entries=trackNode[i]->entries();
573 if(entries!=0) node.push_back(trackNode[i]);
574 else delete trackNode[i];
580 Float_t psi = MicroTrack->
getPhi();
581 Float_t theta=2*atan(exp(-MicroTrack->
getEta()));
582 Short_t charge = (Short_t)MicroTrack->
getCharge();
586 Track->setImpactParameter(MicroTrack->
getDca());
590 Track->setGeometry(
new StHelixModel(charge,psi,curvature,theta,o,p,0));
594 info->setNumberOfPoints(MicroTrack->
getNhits());
595 StSPtrVecTrackDetectorInfo& infoNode = mStEvent->trackDetectorInfo();
596 infoNode.push_back(info);
597 Track->setDetectorInfo(info);
602 Track->setFitTraits(*traits);
605 Track->setFlag((Short_t)MicroTrack->
getFlag());
612 Int_t nv0 = mMicroEvent->
getNV0();
614 StSPtrVecV0Vertex& v0=mStEvent->v0Vertices();
615 for(Int_t i=0;i<nv0;i++)
621 for(Int_t j=0;j<2;j++)
631 v->setMomentumOfDaughter((StChargeSign)j,p);
633 if(mNV0Tracks<MAXV0TRACKS)
635 mV0Tracks[mNV0Tracks] = t;
652 if(!MicroEmc)
return;
655 for(Int_t i=0;i<4;i++)
659 StDetectorId
id =
static_cast<StDetectorId
>(i+kBarrelEmcTowerId);
661 emc->setDetector(detector);
663 for(Int_t j=0;j<MicroEmc->
getNHits(det);j++)
673 detector->addHit(rawHit);
680 for(Int_t j=0;j<nc;j++)
688 Float_t e=cl->getEnergy();
689 cluster->setEta(eta);
690 cluster->setPhi(phi);
691 cluster->setSigmaEta(seta);
692 cluster->setSigmaPhi(sphi);
693 cluster->setEnergy(e);
702 StSPtrVecEmcRawHit& rawhits=module->hits();
703 for(Int_t l=0;l<(Int_t)rawhits.size();l++)
704 if(m==(Int_t)rawhits[l]->module() && e==(Int_t)rawhits[l]->eta() && s==(Int_t)abs(rawhits[l]->sub()))
705 cluster->addHit(rawhits[l]);
708 clusters->addCluster(cluster);
710 detector->setCluster(clusters);
714 Float_t mag = mGeo[0]->Radius();
718 Float_t eta=point->
getEta();
720 Float_t phi=point->
getPhi();
724 Float_t theta=2*atan(exp(-eta));
726 x = mag*sin(theta)*cos(phi);
727 y = mag*sin(theta)*sin(phi);
732 pt->setChiSquare(chi);
733 pt->setDeltaEta(deta);
734 pt->setDeltaPhi(dphi);
736 for(Int_t j=0;j<4;j++)
744 Float_t e=cl->getEnergy();
745 StDetectorId
id =
static_cast<StDetectorId
>(j+kBarrelEmcTowerId);
747 StSPtrVecEmcCluster& clusters=detector->cluster()->clusters();
748 for(Int_t k=0;k<(Int_t)clusters.size();k++)
749 if(eta==clusters[k]->eta() && phi==clusters[k]->phi() && e==clusters[k]->energy())
750 pt->addCluster(
id,clusters[k]);
753 emc->addBarrelPoint(pt);
756 mStEvent->setEmcCollection(emc);
Int_t getModule()
Return Module number.
Float_t getSigmaPhi()
Return SigmaPhi of the cluster.
Float_t getOrigin(Int_t i) const
Return Origin of the track (0=X, 1=Y, 2=Z)
Int_t getZDCe() const
Return ZDC east.
Float_t getPt() const
Return PT of the track.
StEmcMicroHit * getHit(Int_t EmcDet, Int_t HitId)
Return Hit for a given EMC sub detector.
StEmcMicroCluster * getCluster(Int_t EmcDet, Int_t ClId)
Return one cluster of the point.
StEmcMicroTrack * getGlobalTrack(Int_t i) const
Return Global track.
void processMicroEvent()
Process StEmcMicroEvent and convert it on StEvent.
Float_t getVertexZ() const
Return vertex Z.
void processMicroEventInfo()
Process StEmcMicroEvent general info.
Int_t getEventTime() const
Return event time (unix time)
void processMicroEventEMC()
Process StEmcMicroEvent EMC collection.
Int_t getAdc()
Return ADC value.
Int_t getNV0() const
Return Number of V0.
Float_t getVertexY() const
Return Vertex Y.
void processStEventEMC()
Process StEvent EMC collection.
Float_t getZVertexZDC() const
Return Z vertex from ZDC.
Float_t getVertexY() const
Return vertex Y.
Float_t getChi2() const
Return ChiSquare of the track.
StEmcMicroTrack * getPrimaryTrack(Int_t i) const
Return Primary track.
Float_t getPhi() const
Return Phi of the track.
Int_t getZDCw() const
Return ZDC west.
Int_t getEventID() const
Return Event Id.
void processStEventTracks()
Process StEvent tracks.
StEmcMicroHit * getHit(Int_t hiId)
Return one hit of the cluster.
void processMicroEventV0()
Process StEmcMicroEvent V0.
Int_t getNhits() const
Return Number of hits of the track.
Float_t getEnergy()
Return Energy of the point.
Float_t getEnergy()
Return Hit energy.
StEvent * getStEvent(StEmcMicroEvent *)
Returns StEvent.
Int_t getNPoints()
Return Number of Points for a given EMC sub detector.
Int_t getHighTower(Int_t i) const
Return EMC High tower ADC.
Int_t getNClusters(Int_t EmcDet)
Return number of cluster of the point for one sub detector.
void processMicroEventTracks()
Process StEmcMicroEvent tracks.
void processStEventV0()
Process StEvent V0.
Int_t getNPrimaryTrack() const
Return Number of Primary track.
UInt_t getL0TriggerWord() const
Return L0 trigger word.
void processStEventFPD()
Process StEvent FPD collection.
Float_t getPhi()
Return Phi of the point.
double ycenter() const
x-center of circle in xy-plane
Float_t getVertexX() const
Return Vertex X.
Float_t getBField() const
Return Magnetic field (tesla)
Float_t getEta()
Return Eta of the point.
Float_t getChiSquare()
Return ChiSquare of the point.
Float_t getSigmaEta()
Return SigmaEta of the cluster.
Short_t getCharge() const
Return Charge of the track.
Bool_t accept(StEvent *)
Returns kTRUE/kFALSE if StEvent is accepted.
Int_t getPatch(Int_t i) const
Return EMC Patch ADC.
Float_t getDca() const
Return DCA of the track.
Float_t getVertexX() const
Return vertex X.
Int_t getNGlobalTrack() const
Return Number of Global track.
Float_t getDedx() const
Return dE/dX of the track.
Float_t getVertexZ() const
Return Vertex Z.
Int_t getFitPts() const
Return Number of fit points of the track.
Float_t getDeltaPhi()
Return DeltaPhi of the point.
Int_t getEta()
Return Eta division number.
Float_t getPhi()
Return Phi of the cluster.
Float_t getDedxErr() const
Return dE/dX error on mean value.
Float_t getDeltaEta()
Return DeltaEta of the point.
Float_t getEta()
Return Eta of the cluster.
StEmcMicroEvent * getMicroEvent(StEvent *)
Returns StEmcMicroEvent.
void processStEventInfo()
Process StEvent general info.
Float_t getCurvature() const
Return Curvature of the track.
Int_t getNClusters(Int_t EmcDet)
Return Number of Cluster for a given EMC sub detector.
void createTrack(StTrack *, StEmcMicroTrack *)
Creates StEmcMicroTrack from StTrack.
Int_t getNdedxPts() const
Return dE/dX number of points of the track.
Int_t getNHits(Int_t EmcDet)
Return Number of Hits for a given EMC sub detector.
StEmcMicroTrack * getDaughter(Int_t i) const
Return daughter.
StEmcMicroV0 * getV0(Int_t i) const
Return V0.
StEmcMicroCollection * getEmc() const
Return micro EMC collection.
Int_t getSub()
Return Sub division number.
Float_t getTrackLength() const
Return track length.
Float_t getP() const
Return P of the track.
Int_t getRunID() const
Return run number.
StEmcMicroPoint * getPoint(Int_t PtId)
Return Point for a given EMC sub detector.
Int_t getNHits()
Return Number of hits of the cluster.
double xcenter() const
aziumth in xy-plane measured from ring center
StEmcMicroCluster * getCluster(Int_t EmcDet, Int_t ClId)
Return Cluster for a given EMC sub detector.
Float_t getEta() const
Return Eta of the track.
Int_t getTrackNode() const
Return track node (useful for StEvent Reconstruction)
Float_t calcDcaSigned(StTrack *)
Calcs DCA signed.
Int_t getFlag() const
Return flag of the track.
void processStEvent()
Process StEvent and convert it on StEmcMicroEvent.