StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFttUtil.cxx
1 #include "StEvent/StFttCollection.h"
2 #include "StEvent/StFttCluster.h"
3 
4 #include "StMuDSTMaker/COMMON/StMuFttCluster.h"
5 #include "StMuDSTMaker/COMMON/StMuFttRawHit.h"
6 #include "StMuDSTMaker/COMMON/StMuFttPoint.h"
7 // #include "StMuDSTMaker/COMMON/StMuFttInfo.h"
8 #include "StMuDSTMaker/COMMON/StMuFttUtil.h"
9 #include "StMuDSTMaker/COMMON/StMuFttCollection.h"
10 #include "StMuDSTMaker/COMMON/StMuDst.h"
11 #include "StMuDSTMaker/COMMON/StMuEvent.h"
12 #include "StEvent/StEvent.h"
13 #include "St_base/StMessMgr.h"
14 #include "StEvent/StEventTypes.h"
15 #include "StEvent/StTriggerData.h"
16 #include "StEvent/StContainers.h"
17 
18 #include <algorithm> // For std::find
19 #include <iterator> // For std::distance
20 
21 #include "TCollection.h" // For TIter
22 #include "TRefArray.h"
23 #include "TVector3.h"
24 
25 ClassImp(StMuFttUtil)
26 
28 {
29 }
30 
31 StMuFttUtil::~StMuFttUtil()
32 {
33 }
34 
35 StMuFttCollection* StMuFttUtil::getMuFtt(StFttCollection *fttcol)
36 {
37  LOG_DEBUG << "StMuFttUtil::getMuFtt" << endm;
38  if(!fttcol) return NULL;
40  fillMuFtt(muFtt,fttcol);
41  return muFtt;
42 } // getMuFtt
43 
44 StFttCollection* StMuFttUtil::getFtt(StMuFttCollection* muFtt)
45 {
46  if(!muFtt) return NULL;
47 
49  fillFtt(ftt,muFtt);
50  return ftt;
51 } //getFtt
52 
53 void StMuFttUtil::fillMuFtt(StMuFttCollection *muFtt,StFttCollection *fttcol)
54 {
55  LOG_INFO << "fillMuFtt" << endm;
56  if(!fttcol) return;
57  if(!muFtt) return;
58 
59  fillMuFttRawHits(muFtt, fttcol);
60  fillMuFttPoints(muFtt, fttcol);
61  fillMuFttClusters(muFtt, fttcol);
62 
63  // rebuild the pointers that give cluster <-> hit, cluster <-> cluster,
64  // and cluster <-> point relationships
65  rebuildRelationships( fttcol, muFtt );
66 } // fillMuFtt
67 
68 void StMuFttUtil::fillFtt(StFttCollection* fttcol,StMuFttCollection* muFtt)
69 {
70  if(!muFtt) return;
71  if(!fttcol) return;
72  fillFttRawHits(fttcol, muFtt);
73 } // fillFtt
74 
75 void StMuFttUtil::fillMuFttRawHits(StMuFttCollection* muFtt,
76  StFttCollection* fttcol) {
77  LOG_INFO << "fillMuFttRawHits" << endm;
78  const StSPtrVecFttRawHit& vecHit = fttcol->rawHits();
79  for(unsigned int i=0; i<fttcol->numberOfRawHits(); i++){
80 
81  StMuFttRawHit* muFttHit = muFtt->addRawHit();
82  muFttHit->set( vecHit[i] );
83  // store in memory map between StEvent and StMuDst version for associations
84  mMapHits[ fttcol->rawHits()[i] ] = muFttHit;
85  } // for i
86 } // fillMuFttRawHits
87 
88 void StMuFttUtil::rebuildRelationships(StFttCollection* fttcol,
89  StMuFttCollection* muFtt ) {
90 
91 
92 } // rebuildRelationships(...)
93 
94 
95 void StMuFttUtil::fillMuFttClusters(StMuFttCollection* muFtt,
96  StFttCollection* fttcol) {
97  LOG_INFO << "fillMuFttClusters" << endm;
98  const StSPtrVecFttCluster& vecClu = fttcol->clusters();
99  for(unsigned int i=0; i<fttcol->numberOfClusters(); i++){
100 
101  StMuFttCluster* muFttCluster = muFtt->addCluster();
102  muFttCluster->set( vecClu[i] );
103  // store in memory map between StEvent and StMuDst version for associations
104  mMapClusters[ fttcol->clusters()[i] ] = muFttCluster;
105  } // for i
106 } //fillMuFttClusters
107 
108 void StMuFttUtil::fillMuFttPoints(StMuFttCollection* muFtt,
109  StFttCollection* fttcol) {
110  LOG_INFO << "fillMuFttPoints" << endm;
111  const StSPtrVecFttPoint& vecPoint = fttcol->points();
112  for(unsigned int i=0; i<fttcol->numberOfPoints(); i++){
113 
114  StMuFttPoint* muFttPoint = muFtt->addPoint();
115  muFttPoint->set( vecPoint[i] );
116  // store in memory map between StEvent and StMuDst version for associations
117  mMapPoints[ fttcol->points()[i] ] = muFttPoint;
118  } // for i
119 } // fillMuFttPoints
120 
121 void StMuFttUtil::fillFttRawHits(StFttCollection* fttcol,
122  StMuFttCollection* muFtt) {
123  // Using TIter to iterate is safe in the case of hits being NULL
124  TIter next(muFtt->getRawHitArray());
125  StMuFttRawHit* muHit(NULL);
126  while ((muHit = static_cast<StMuFttRawHit*>(next()))) {
127  fttcol->addRawHit(new StFttRawHit);
128  StFttRawHit* hit = fttcol->rawHits().back();
129  hit->setRaw(
130  muHit->sector(), muHit->rdo(), muHit->feb(),
131  muHit->vmm(), muHit->channel(), muHit->adc(),
132  muHit->bcid(), muHit->tb(), muHit->dbcid() );
133  } // while
134 } // fillFttHits