StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuTofUtil.cxx
1 #include "StEvent.h"
2 #include "StTrack.h"
3 #include "StTofCollection.h"
4 #include "StMuTofUtil.h"
5 #include "StMuTofHitCollection.h"
6 
7 ClassImp(StMuTofUtil)
8 
10 { }
11 
12 StMuTofUtil::~StMuTofUtil()
13 { }
14 
15 StMuTofHitCollection* StMuTofUtil::getMuTofHit(StTofCollection *tofcol)
16 {
17  if(!tofcol) return NULL;
19  fillMuTofHit(muTofHit, tofcol);
20  return muTofHit;
21 }
22 
23 void StMuTofUtil::fillMuTofHit(StMuTofHitCollection* muTofHit, StTofCollection* tofcol)
24 {
25  // run 5 - dongx
26  if(!tofcol || (!tofcol->dataPresent()&&!tofcol->rawdataPresent())) return;
27  if(!muTofHit) return;
28 
29 
30  if( ( tofcol->cellsPresent() || tofcol->slatsPresent() ) &&
31  tofcol->hitsPresent() ) {
32  StSPtrVecTofHit &tofHits = tofcol->tofHits();
33  StSPtrVecTofCell &tofCell = tofcol->tofCells();
34  StSPtrVecTofSlat &tofSlat = tofcol->tofSlats();
35 
36  for(size_t i=0; i < tofHits.size(); i++) {
37  StMuTofHit* tofMuHit = new StMuTofHit();
38  tofMuHit->setIconf(1);
39  tofMuHit->setTrayIndex(tofHits[i]->trayIndex());
40  tofMuHit->setModuleIndex(tofHits[i]->moduleIndex());
41  tofMuHit->setCellIndex(tofHits[i]->cellIndex());
42  tofMuHit->setDaqIndex(tofHits[i]->daqIndex());
43  tofMuHit->setTimeOfFlight(tofHits[i]->timeOfFlight());
44  tofMuHit->setPathLength(tofHits[i]->pathLength());
45  tofMuHit->setBeta(tofHits[i]->beta());
46  tofMuHit->setAssociatedTrackId(tofHits[i]->associatedTrack()->key());
47  if(tofHits[i]->trayIndex()!=0&&tofHits[i]->moduleIndex()!=0) { // tofr
48  tofMuHit->setADC((int)tofCell[tofHits[i]->cellCollIndex()]->adc());
49  StThreeVectorD hitpos = tofCell[tofHits[i]->cellCollIndex()]->position();
50  StThreeVectorF hitpos1((Float_t)(hitpos.x()),(Float_t)(hitpos.y()),(Float_t)(hitpos.z()));
51  tofMuHit->setProjectedPoint(hitpos1);
52  // tofMuHit->setProjectedPoint((StThreeVectorF&)tofCell[tofHits[i]->cellCollIndex()]->position());
53  } else { // tofp
54  tofMuHit->setADC((int)tofSlat[tofHits[i]->cellCollIndex()]->adc());
55  tofMuHit->setProjectedPoint((StThreeVectorF&)tofSlat[tofHits[i]->cellCollIndex()]->position());
56  }
57  tofMuHit->settofExpectedAsElectron(tofHits[i]->tofExpectedAsElectron());
58  tofMuHit->settofExpectedAsPion(tofHits[i]->tofExpectedAsPion());
59  tofMuHit->settofExpectedAsKaon(tofHits[i]->tofExpectedAsKaon());
60  tofMuHit->settofExpectedAsProton(tofHits[i]->tofExpectedAsProton());
61  tofMuHit->setsigmaElectron(tofHits[i]->sigmaElectron());
62  tofMuHit->setsigmaPion(tofHits[i]->sigmaPion());
63  tofMuHit->setsigmaKaon(tofHits[i]->sigmaKaon());
64  tofMuHit->setsigmaProton(tofHits[i]->sigmaProton());
65  //tofMuHit->setparticleHypothesis(int);
66 
67  muTofHit->push_back(tofMuHit);
68  }
69 
70  }
71  return;
72 }