StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcMicroUtil.cxx
1 #include "StEmcMicroUtil.h"
2 #include "StEvent.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"
9 
10 ClassImp(StEmcMicroUtil)
11 
13 {
14  for(Int_t i =0;i<4;i++) mGeo[i]=StEmcGeom::getEmcGeom(detname[i].Data());
15 }
16 StEmcMicroUtil::~StEmcMicroUtil()
17 {
18  //if(mV0Tracks) delete mV0Tracks;
19 }
20 void StEmcMicroUtil::clearGarbage()
21 {
22  for(Int_t i=0;i<mNV0Tracks;i++)
23  {
24  if(mV0Tracks[i]) { delete mV0Tracks[i]; mV0Tracks[i]=NULL; }
25  }
26  mNV0Tracks=0;
27 }
29 {
30  if(!event) return NULL;
31 
32  mStEvent = event;
34 
35  return mMicroEvent;
36 }
38 {
39  if(!event) return NULL;
40 
41  mMicroEvent = event;
43 
44  return mStEvent;
45 }
47 {
48  mMicroEvent = new StEmcMicroEvent();
51  if(mDoSaveV0) processStEventV0();
52  if(mDoSaveEmc) processStEventEMC();
53  if(mDoSaveFpd) processStEventFPD();
54 }
56 {
57  cout <<"filling general info\n";
58 
59  //Magnetic field
60  Float_t BF=0.5;
61  StEventSummary* summary = mStEvent->summary();
62  if(summary) BF = summary->magneticField()/10.;
63  mMicroEvent->setBField(BF);
64 
65  StL0Trigger* pTrigger = mStEvent->l0Trigger();
66  if(pTrigger)
67  {
68  mMicroEvent->setL0TriggerWord(pTrigger->triggerWord());
69  mMicroEvent->setToken(pTrigger->triggerToken());
70  mMicroEvent->setBunchCrossing(pTrigger->bunchCrossingId());
71  mMicroEvent->setBunchCrossing7bit(pTrigger->bunchCrossingId7bit(mStEvent->runId()));
72  //mMicroEvent->setBunchCrossing7bit(pTrigger->bunchCrossingId7bit());
73  mMicroEvent->setSpinBits(pTrigger->spinBits());
74  }
75 
76  // Get event id
77  mMicroEvent->setEventID((Int_t)(mStEvent->id()));
78  mMicroEvent->setRunID((Int_t)(mStEvent->runId()));
79  mMicroEvent->setEventTime((Int_t)mStEvent->time());
80 
81  // Get primary vertex position (if any)
82  StPrimaryVertex* primaryVertex = mStEvent->primaryVertex(0);
83  if(primaryVertex)
84  {
85  const StThreeVectorF& vertex = primaryVertex->position();
86  mMicroEvent->setVertexPos(vertex.x(),vertex.y(),vertex.z());
87  // Get initial multiplicity before TrackCuts
88  UInt_t origMult = primaryVertex->numberOfDaughters();
89  mMicroEvent->setOrigMult(origMult);
90  }
91 
92  // include trigger (ZDC, CTB and BBC)
93  Int_t ctb = 0;
94  Int_t zdce = 0;
95  Int_t zdcw = 0;
96  Float_t zdcvz = 0;
97 
98  Int_t bbcw = 0;
99  Int_t bbce = 0;
100  Int_t bbcnh = 0;
101  Float_t bbcvz = 0;
102 
103  StTriggerDetectorCollection *triggers = mStEvent->triggerDetectorCollection();
104  if (triggers)
105  {
106  StCtbTriggerDetector &CTB = triggers->ctb();
107  StZdcTriggerDetector &ZDC = triggers->zdc();
108  StBbcTriggerDetector &BBC = triggers->bbc();
109  StEmcTriggerDetector &EMC = triggers->emc();
110  // get CTB
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);
114 
115  //get ZDCe and ZDCw
116  zdce = (Int_t)ZDC.adcSum(east);
117  zdcw = (Int_t)ZDC.adcSum(west);
118  zdcvz = (Float_t)ZDC.vertexZ();
119 
120  bbcw = (Int_t)BBC.adcSumWest();
121  bbce = (Int_t)BBC.adcSumEast();
122  bbcnh = (Int_t)BBC.nHitAll();
123  bbcvz = (Float_t)BBC.zVertex();
124 
125  for(Int_t i=0;i<300;i++)
126  {
127  Int_t HT = EMC.highTower(i);
128  Int_t PA = EMC.patch(i);
129  mMicroEvent->setHighTower(i,HT);
130  mMicroEvent->setPatch(i,PA);
131  }
132  }
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);
141 }
143 {
144  cout <<"filling tracks\n";
145  int totalp=0,goodp=0,totalg=0,goodg=0;
146 
147  StSPtrVecTrackNode& trackNode = mStEvent->trackNodes();
148  for (unsigned int j=0; j < trackNode.size(); j++)
149  {
150  StTrack* gTrack = (trackNode[j]->track(global));
151  StTrack* pTrack = (trackNode[j]->track(primary));
152 
153  // first primary track
154  if (pTrack && mDoSavePrimaries)// && pTrack->flag() > 0)
155  {
156  totalp++;
157  if(mPFilter->accept(pTrack))
158  {
159  // Instantiate new StEmcMicroTrack
160  StEmcMicroTrack* MicroPTrack = new StEmcMicroTrack();
161  createTrack(pTrack,MicroPTrack);
162  if(MicroPTrack)
163  {
164  MicroPTrack->setTrackNodeNumber(j);
165  mMicroEvent->addPrimaryTrack(MicroPTrack);
166  goodp++;
167  }
168  }
169  }
170 
171  if (gTrack && mDoSaveGlobals)
172  {
173  totalg++;
174  if (mGFilter->accept(gTrack))
175  {
176  StEmcMicroTrack* MicroGTrack=new StEmcMicroTrack();
177  createTrack(gTrack,MicroGTrack);
178  if(MicroGTrack)
179  {
180  MicroGTrack->setTrackNodeNumber(j);
181  mMicroEvent->addGlobalTrack(MicroGTrack);
182  goodg++;
183  }
184  }
185  }
186  }
187  cout <<"Total primary tracks = "<<totalp<<" good = "<<goodp<<endl;
188  cout <<"Total global tracks = "<<totalg<<" good = "<<goodg<<endl;
189  cout <<"finished filing tracks\n";
190 }
192 {
193  StThreeVectorF p = track->geometry()->momentum();
194  if(p.mag()==0) return;
195 
196  StThreeVectorF o = track->geometry()->origin();
197 
198  MicroTrack->setP(p.mag());
199  MicroTrack->setEta(p.pseudoRapidity());
200  MicroTrack->setPhi(p.phi());
201  MicroTrack->setCurvature(track->geometry()->curvature());
202 
203  MicroTrack->setFlag(track->flag());
204 
205  MicroTrack->setOrigin(o.x(),o.y(),o.z());
206 
207  MicroTrack->setCharge(track->geometry()->charge());
208 
209  MicroTrack->setDca(track->impactParameter());
210 
211  Float_t dcaSigned = calcDcaSigned(track);
212  MicroTrack->setDcaSigned(dcaSigned);
213 
214  MicroTrack->setChi2((Float_t)(track->fitTraits().chi2()));
215  MicroTrack->setFitPts(track->fitTraits().numberOfFitPoints());
216  MicroTrack->setMaxPts(track->numberOfPossiblePoints());
217 
218  if(track->detectorInfo())
219  MicroTrack->setNhits(track->detectorInfo()->numberOfPoints(kTpcId));
220 
221  // dE/dx
222  StPtrVecTrackPidTraits traits = track->pidTraits(kTpcId);
223  unsigned int size = traits.size();
224 
225  if (size)
226  {
227  StDedxPidTraits* pid;
228  for (unsigned int i = 0; i < traits.size(); i++)
229  {
230  pid = dynamic_cast<StDedxPidTraits*>(traits[i]);
231  if (pid && pid->method() == kTruncatedMeanId) break;
232  }
233  assert(pid);
234 
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);
241  }
242 
243  MicroTrack->setTrackLength(track->length());
244 
245  return;
246 }
248 {
249 
250  // find the distance between the center of the circle and pos (vertex).
251  // if the radius of curvature > distance, then call it positive
252  // Bum Choi
253  StThreeVectorF pos = mStEvent->primaryVertex(0)->position();
254 
255  double xCenter = track->geometry()->helix().xcenter();
256  double yCenter = track->geometry()->helix().ycenter();
257  double radius = 1.0/track->geometry()->helix().curvature();
258 
259  double dPosCenter = ::sqrt( (pos.x() - xCenter) * (pos.x() - xCenter) +
260  (pos.y() - yCenter) * (pos.y() - yCenter));
261 
262  return (Float_t) (radius - dPosCenter);
263 }
265 {
266  cout <<"Filling V0īs\n";
267  Int_t nV=0;
268  StSPtrVecV0Vertex& v0=mStEvent->v0Vertices();
269  if(v0.size()==0) return;
270 
271  for(Int_t i = 0;i<(Int_t)v0.size();i++)
272  {
273  StV0Vertex *v = v0[i];
274  if(v) if(mGFilter->accept(v))
275  {
276  nV++;
277  StEmcMicroV0* mv = new StEmcMicroV0();
278 
279  for(Int_t j=0;j<2;j++)
280  {
281  StTrack* tr = v->daughter(j);
282  if(tr)
283  {
284  StEmcMicroTrack *mtr = new StEmcMicroTrack();
285  createTrack(tr,mtr);
286  if(mtr) mv->setDaughter(j,mtr);
287  }
288  }
289  StThreeVectorF pos=v->position();
290  mv->setVertex(pos.x(),pos.y(),pos.z());
291  mMicroEvent->addV0(mv);
292  }
293  }
294  cout <<"Total V0īs accepted = "<<nV<<endl;
295 }
297 {
298  StEmcCollection* emccol=mStEvent->emcCollection();
299  if(!emccol) return;
301 
302  Int_t HitsId[18000];
303 
304  // starting by hits;
305 
306  for(Int_t d=0; d<4; d++)
307  {
308  Int_t EmcDet=d+1;
309  for(Int_t i=0;i<18000;i++) HitsId[i]=-1;
310 
311  StDetectorId id = static_cast<StDetectorId>(d+kBarrelEmcTowerId);
312  StEmcDetector* detector=emccol->detector(id);
313  if(!detector) cout <<detname[d].Data()<<" not loaded\n";
314  if(detector)
315  {
316  // hits first
317  cout <<"Filling hits for detector "<<detname[d].Data()<<endl;
318 
319  Int_t HitIndex=0;
320  for(UInt_t j=1;j<121;j++)
321  {
322  StEmcModule* module = detector->module(j);
323  if(module)
324  {
325  StSPtrVecEmcRawHit& rawHit=module->hits();
326  Int_t nhits=(Int_t)rawHit.size();
327  if(nhits>0)
328  for(Int_t k=0;k<nhits;k++)
329  {
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();
335 
336  StEmcMicroHit* Microhit = new StEmcMicroHit();
337 
338  Microhit->setModule(m);
339  Microhit->setEta(e);
340  Microhit->setSub(s);
341  Microhit->setAdc(adc);
342  Microhit->setEnergy(energy);
343 
344  Microemc->addHit(EmcDet,Microhit);
345  Int_t rid;
346  mGeo[d]->getId(m,e,s,rid);
347  HitsId[rid-1] = HitIndex;
348  HitIndex++;
349  //delete Microhit; Microhit=NULL;
350  }
351  }
352  }
353 
354  // now clusters
355  if(detector->cluster())
356  {
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;
361  if(totalcluster>0)
362  for(Int_t j=0;j<totalcluster;j++)
363  {
364  StEmcMicroCluster *Microcl=new StEmcMicroCluster();
365 
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());
371 
372  StPtrVecEmcRawHit& rawHit=cluster[j]->hit();
373  Int_t nhit=(Int_t)rawHit.size();
374 
375  for(Int_t k=0;k<nhit;k++)
376  {
377  Int_t m = rawHit[k]->module();
378  Int_t e = rawHit[k]->eta();
379  Int_t s = abs(rawHit[k]->sub());
380  Int_t rid;
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));
384  }
385  Microemc->addCluster(EmcDet,Microcl);
386  //delete Microcl; Microcl=NULL;
387  }
388  } // if detector->cluster
389  } // if detector
390  } // loop detector
391 
392  // now going to points....
393  cout <<"Filling points "<<endl;
394 
395  StSPtrVecEmcPoint& points=emccol->barrelPoints();
396  Int_t npoints=points.size();
397  if(npoints>0)
398  {
399  for(Int_t p=0;p<npoints;p++)
400  {
401  StEmcPoint* point=points[p];
402  StThreeVectorF position=point->position();
403  StEmcMicroPoint *Micropt=new StEmcMicroPoint();
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());
410 
411  for(Int_t d=0;d<4;d++)
412  {
413  Int_t det =d+1;
414  StDetectorId detid=static_cast<StDetectorId>(d+kBarrelEmcTowerId);
415  StPtrVecEmcCluster& cluster=point->cluster(detid);
416  Int_t ptnc=0;
417  ptnc=cluster.size();
418  for(Int_t i=0;i<ptnc;i++) if(cluster[i])
419  {
420  Float_t eta = cluster[i]->eta();
421  Float_t phi = cluster[i]->phi();
422  for(Int_t j=0;j<Microemc->getNClusters(det);j++)
423  {
424  StEmcMicroCluster *cl=Microemc->getCluster(det,j);
425  if(eta == cl->getEta() && phi==cl->getPhi())
426  {
427  Micropt->addCluster(det,cl);
428  goto cont;
429  }
430  }
431  cont: continue;
432  }
433  } // loop detector
434  Microemc->addPoint(Micropt);
435  //delete Micropt; Micropt=NULL;
436  } // loop points
437 
438  }// npoint >0
439 
440  mMicroEvent->setEmc(Microemc);
441  cout <<"Finished filling EMC\n";
442  return;
443 
444 }
446 {
447  cout <<"Filling FPD ...\n";
448  StFpdCollection * fpd = mStEvent->fpdCollection();
449  if(!fpd) return;
450 
451  StFpdMicroCollection *Microfpd = new StFpdMicroCollection();
452 
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());
462 
463  mMicroEvent->setFpd(Microfpd);
464  cout <<"Finished filling FPD\n";
465 
466 }
468 {
469  clearGarbage();
470  mStEvent = new StEvent;
475  return;
476 }
478 {
479  StEventSummary *summary=new StEventSummary();
480  summary->setMagneticField(mMicroEvent->getBField()*10.);
481 
482  mStEvent->setSummary(summary);
483 
484  mStEvent->setRunId(mMicroEvent->getRunID());
485  mStEvent->setId(mMicroEvent->getEventID());
486  mStEvent->setTime(mMicroEvent->getEventTime());
487 
488  StL0Trigger *L0=new StL0Trigger();
489  L0->setTriggerWord(mMicroEvent->getL0TriggerWord());
490  mStEvent->setL0Trigger(L0);
491 
493 
494  //StCtbTriggerDetector &CTB = triggers->ctb();
495  StZdcTriggerDetector &ZDC = triggers->zdc();
496  //StBbcTriggerDetector &BBC = triggers->bbc();
497  StEmcTriggerDetector &EMC = triggers->emc();
498 
499  ZDC.setAdcSum(east,mMicroEvent->getZDCe());
500  ZDC.setAdcSum(west,mMicroEvent->getZDCw());
501  ZDC.setAdcSum((Float_t)(mMicroEvent->getZDCe()+mMicroEvent->getZDCw()));
502  ZDC.setVertexZ(mMicroEvent->getZVertexZDC());
503 
504  for(Int_t i=0;i<300;i++)
505  {
506  EMC.setHighTower(i,mMicroEvent->getHighTower(i));
507  EMC.setPatch(i,mMicroEvent->getPatch(i));
508  }
509 
510  mStEvent->setTriggerDetectorCollection(triggers);
511 
513  StThreeVectorF p(mMicroEvent->getVertexX(),mMicroEvent->getVertexY(),mMicroEvent->getVertexZ());
514  vertex->setPosition(p);
515  mStEvent->addPrimaryVertex(vertex);
516  return;
517 }
519 {
520  //filling tracks
521  // restoring original StEvent track node
522  StSPtrVecTrackNode& node=mStEvent->trackNodes();
523  StPrimaryVertex* vertex = mStEvent->primaryVertex(0);
524 
525  Int_t maxNode=0,gnode,pnode;
526 
527  Int_t ng=mMicroEvent->getNGlobalTrack();
528  Int_t np=mMicroEvent->getNPrimaryTrack();
529 
530  Int_t max=ng;
531  if (np>ng) max=np;
532 
533  for(Int_t i=0;i<max;i++)
534  {
535  if(i<ng) gnode=mMicroEvent->getGlobalTrack(i)->getTrackNode(); else gnode=0;
536  if(i<np) pnode=mMicroEvent->getPrimaryTrack(i)->getTrackNode(); else pnode=0;
537  if(gnode>maxNode) maxNode=gnode;
538  if(pnode>maxNode) maxNode=pnode;
539  }
540  //Int_t nnodes=maxNode+1;
541  StTrackNode *trackNode[10000];
542  for(Int_t i=0;i<10000;i++) trackNode[i] = NULL;
543  // filling tracks
544  for(Int_t i=0;i<max;i++)
545  {
546  if(i<ng) //global tracks
547  {
548  StEmcMicroTrack *gMicroTrack=mMicroEvent->getGlobalTrack(i);
549  gnode = gMicroTrack->getTrackNode();
550  if(!trackNode[gnode]) trackNode[gnode]=new StTrackNode();
551 
552  StGlobalTrack *gTrack = new StGlobalTrack();
553  createTrack(gMicroTrack,gTrack);
554  trackNode[gnode]->addTrack(gTrack);
555  }
556  if(i<np) //primary tracks
557  {
558  StEmcMicroTrack *pMicroTrack=mMicroEvent->getPrimaryTrack(i);
559  pnode = pMicroTrack->getTrackNode();
560  if(!trackNode[pnode]) trackNode[pnode]=new StTrackNode();
561 
562  StPrimaryTrack *pTrack = new StPrimaryTrack();
563  createTrack(pMicroTrack,pTrack);
564  pTrack->setVertex(vertex);
565  vertex->addDaughter(pTrack);
566  trackNode[pnode]->addTrack(pTrack);
567  }
568  }
569  for(Int_t i=0;i<10000;i++) // cleaning empty nodes
570  if(trackNode[i])
571  {
572  Int_t entries=trackNode[i]->entries();
573  if(entries!=0) node.push_back(trackNode[i]);
574  else delete trackNode[i];
575  }
576 
577 }
579 {
580  Float_t psi = MicroTrack->getPhi();
581  Float_t theta=2*atan(exp(-MicroTrack->getEta()));
582  Short_t charge = (Short_t)MicroTrack->getCharge();
583  Float_t curvature= MicroTrack->getCurvature();
584 
585  Track->setLength(MicroTrack->getTrackLength());
586  Track->setImpactParameter(MicroTrack->getDca());
587  StThreeVectorF o(MicroTrack->getOrigin(0),MicroTrack->getOrigin(1),MicroTrack->getOrigin(2));
588  StThreeVectorF p(MicroTrack->getPt()*cos(psi),MicroTrack->getPt()*sin(psi),MicroTrack->getP()*cos(theta));
589 
590  Track->setGeometry(new StHelixModel(charge,psi,curvature,theta,o,p,0));
591  Track->addPidTraits(new StDedxPidTraits(kTpcId,kTruncatedMeanId,MicroTrack->getNdedxPts(),MicroTrack->getDedx(),MicroTrack->getDedxErr()));
592 
594  info->setNumberOfPoints(MicroTrack->getNhits());
595  StSPtrVecTrackDetectorInfo& infoNode = mStEvent->trackDetectorInfo();
596  infoNode.push_back(info);
597  Track->setDetectorInfo(info);
598 
599  Float_t a[2],b[15];
600  a[0]=MicroTrack->getChi2();
601  StTrackFitTraits *traits=new StTrackFitTraits(0,MicroTrack->getFitPts(),a,b);
602  Track->setFitTraits(*traits);
603  delete traits;
604 
605  Track->setFlag((Short_t)MicroTrack->getFlag());
606 
607  return;
608 }
610 {
611  mNV0Tracks=0;
612  Int_t nv0 = mMicroEvent->getNV0();
613  if (nv0==0) return;
614  StSPtrVecV0Vertex& v0=mStEvent->v0Vertices();
615  for(Int_t i=0;i<nv0;i++)
616  {
617  StEmcMicroV0 *mv0 = mMicroEvent->getV0(i);
618  if(mv0)
619  {
620  StV0Vertex *v=new StV0Vertex();
621  for(Int_t j=0;j<2;j++)
622  {
623  StEmcMicroTrack *mt=mv0->getDaughter(j);
624  if(mt)
625  {
626  StGlobalTrack *t=new StGlobalTrack();
627  createTrack(mt,t);
628  if(t)
629  {
630  StThreeVectorF p = t->geometry()->momentum();
631  v->setMomentumOfDaughter((StChargeSign)j,p);
632  v->addDaughter(t);
633  if(mNV0Tracks<MAXV0TRACKS)
634  {
635  mV0Tracks[mNV0Tracks] = t;
636  mNV0Tracks++;
637  }
638  }
639  }
640  }
641  StThreeVectorF pos(mv0->getVertexX(),mv0->getVertexY(),mv0->getVertexZ());
642  v->setPosition(pos);
643  v0.push_back(v);
644  }
645  }
646 
647 }
649 {
650  // filling EMC collection
651  StEmcMicroCollection* MicroEmc=mMicroEvent->getEmc();
652  if(!MicroEmc) return;
653 
654  StEmcCollection *emc=new StEmcCollection();
655  for(Int_t i=0;i<4;i++)
656  {
657  Int_t det=i+1;
658 
659  StDetectorId id = static_cast<StDetectorId>(i+kBarrelEmcTowerId);
660  StEmcDetector* detector = new StEmcDetector(id, 120);
661  emc->setDetector(detector);
662  // hits
663  for(Int_t j=0;j<MicroEmc->getNHits(det);j++)
664  {
665  StEmcMicroHit* hit=MicroEmc->getHit(det,j);
666  Int_t m=hit->getModule();
667  Int_t e=hit->getEta();
668  Int_t s=hit->getSub();
669  Int_t a=hit->getAdc();
670  Float_t energy=hit->getEnergy();
671  StEmcRawHit* rawHit=new StEmcRawHit(id,(UInt_t)m,(UInt_t)e,(UInt_t)s,(UInt_t)a,energy);
672  //cout <<"Hit number "<<j<<" m = "<<m<<" e = "<<e<<" s = "<<s<<" adc = "<<a<<" en = "<<energy<<"\n";
673  detector->addHit(rawHit);
674  }
675  //clusters
676  Int_t nc=MicroEmc->getNClusters(det);
677  if(nc>0)
678  {
680  for(Int_t j=0;j<nc;j++)
681  {
682  StEmcMicroCluster* cl=MicroEmc->getCluster(det,j);
683  StEmcCluster* cluster=new StEmcCluster();
684  Float_t eta=cl->getEta();
685  Float_t seta=cl->getSigmaEta();
686  Float_t phi=cl->getPhi();
687  Float_t sphi=cl->getSigmaPhi();
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);
694 
695  for(Int_t k=0;k<cl->getNHits();k++)
696  {
697  StEmcMicroHit *hit=cl->getHit(k);
698  Int_t m=hit->getModule();
699  Int_t e=hit->getEta();
700  Int_t s=hit->getSub();
701  StEmcModule *module = detector->module(m);
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]);
706  }
707 
708  clusters->addCluster(cluster);
709  }
710  detector->setCluster(clusters);
711  }
712  }
713  // points
714  Float_t mag = mGeo[0]->Radius();
715  for(Int_t i=0; i<MicroEmc->getNPoints();i++)
716  {
717  StEmcMicroPoint *point=MicroEmc->getPoint(i);
718  Float_t eta=point->getEta();
719  Float_t deta=point->getDeltaEta();
720  Float_t phi=point->getPhi();
721  Float_t dphi=point->getDeltaPhi();
722  Float_t en=point->getEnergy();
723  Float_t chi=point->getChiSquare();
724  Float_t theta=2*atan(exp(-eta));
725  Float_t x,y,z;
726  x = mag*sin(theta)*cos(phi);
727  y = mag*sin(theta)*sin(phi);
728  z = mag*cos(theta);
729  StThreeVectorF p(x,y,z);
730  StEmcPoint *pt=new StEmcPoint();
731  pt->setEnergy(en);
732  pt->setChiSquare(chi);
733  pt->setDeltaEta(deta);
734  pt->setDeltaPhi(dphi);
735  pt->setPosition(p);
736  for(Int_t j=0;j<4;j++) // looking for clusters
737  {
738  Int_t det = j+1;
739  if(point->getNClusters(det)>0) for(Int_t l=0;l<point->getNClusters(det);l++)
740  {
741  StEmcMicroCluster *cl=point->getCluster(det,l);
742  Float_t eta=cl->getEta();
743  Float_t phi=cl->getPhi();
744  Float_t e=cl->getEnergy();
745  StDetectorId id = static_cast<StDetectorId>(j+kBarrelEmcTowerId);
746  StEmcDetector *detector=emc->detector(id);
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]);
751  }
752  }
753  emc->addBarrelPoint(pt);
754  }
755  // set emc collection
756  mStEvent->setEmcCollection(emc);
757 }
Int_t getModule()
Return Module number.
Definition: StEmcMicroHit.h:18
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.
Definition: StEmcMicroV0.h:22
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.
Definition: StEmcMicroHit.h:21
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.
Definition: StEmcMicroV0.h:21
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.
Definition: StEmcMicroHit.h:22
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
Definition: StHelix.cc:215
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.
Definition: StEmcMicroV0.h:20
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.
Definition: StEmcMicroHit.h:19
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.
Definition: StEmcMicroV0.h:19
StEmcMicroV0 * getV0(Int_t i) const
Return V0.
StEmcMicroCollection * getEmc() const
Return micro EMC collection.
Int_t getSub()
Return Sub division number.
Definition: StEmcMicroHit.h:20
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.
C++ STL includes.
Definition: AgUStep.h:47
double xcenter() const
aziumth in xy-plane measured from ring center
Definition: StHelix.cc:207
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.