StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventScavenger.cxx
1 /***************************************************************************
2  *
3  * $Id: StEventScavenger.cxx,v 2.10 2011/02/01 19:47:36 ullrich Exp $
4  *
5  * Author: Thomas Ullrich, Sep 2000
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StEventScavenger.cxx,v $
13  * Revision 2.10 2011/02/01 19:47:36 ullrich
14  * Added HLT branch and hooks.
15  *
16  * Revision 2.9 2010/08/31 19:55:13 fisyak
17  * Remove SoftwareMonitors
18  *
19  * Revision 2.8 2002/01/19 00:14:16 ullrich
20  * Corrected typo.
21  *
22  * Revision 2.7 2002/01/17 02:06:29 ullrich
23  * Added the removal of objects recently added to StEvent.
24  *
25  * Revision 2.6 2001/06/10 21:02:49 perev
26  * Solaris: <typeinfo> removed
27  *
28  * Revision 2.5 2001/04/05 04:00:49 ullrich
29  * Replaced all (U)Long_t by (U)Int_t and all redundant ROOT typedefs.
30  *
31  * Revision 2.4 2001/03/16 04:59:24 ullrich
32  * Added missing method removeTriggerDetectorCollection().
33  *
34  * Revision 2.3 2000/10/16 21:06:32 ullrich
35  * Added new method: removeTpcHitsNotOnTracks()
36  *
37  * Revision 2.2 2000/09/27 02:53:23 ullrich
38  * No delete, create only zombies.
39  *
40  * Revision 2.1 2000/09/25 18:03:13 ullrich
41  * Initial Revision.
42  *
43  **************************************************************************/
44 #include "StEventScavenger.h"
45 #include "StEventTypes.h"
46 
47 bool StEventScavenger::removeEventSummary(StEvent* evt)
48 {
49  if (evt && evt->summary()) {
50  evt->summary()->makeZombie();
51  return true;
52  }
53  else
54  return false;
55 }
56 
57 bool StEventScavenger::removeL3Trigger(StEvent* evt)
58 {
59  if (evt && evt->l3Trigger()) {
60  evt->l3Trigger()->makeZombie();
61  return true;
62  }
63  else
64  return false;
65 }
66 
67 bool StEventScavenger::removeV0Vertices(StEvent* evt)
68 {
69  if (!evt) return false;
70  StSPtrVecV0Vertex &vec = evt->v0Vertices();
71  for (unsigned int i=0; i<vec.size(); i++)
72  vec[i]->makeZombie();
73  return true;
74 }
75 
76 bool StEventScavenger::removeXiVertices(StEvent* evt)
77 {
78  if (!evt) return false;
79  StSPtrVecXiVertex &vec = evt->xiVertices();
80  for (unsigned int i=0; i<vec.size(); i++)
81  vec[i]->makeZombie();
82  return true;
83 }
84 
85 bool StEventScavenger::removeKinkVertices(StEvent* evt)
86 {
87  if (!evt) return false;
88  StSPtrVecKinkVertex &vec = evt->kinkVertices();
89  for (unsigned int i=0; i<vec.size(); i++)
90  vec[i]->makeZombie();
91  return true;
92 }
93 
94 bool StEventScavenger::removeCalibrationVertices(StEvent* evt)
95 {
96  if (!evt) return false;
97  for (unsigned int i=0; i<evt->numberOfCalibrationVertices(); i++)
98  evt->calibrationVertex(i)->makeZombie();
99  return true;
100 }
101 
102 bool StEventScavenger::removeTpcHitCollection(StEvent* evt)
103 {
104  if (evt && evt->tpcHitCollection()) {
105  StTpcHitCollection *theHits = evt->tpcHitCollection();
106  for (unsigned int n=0; n<theHits->numberOfSectors(); n++)
107  for (unsigned int m=0; m<theHits->sector(n)->numberOfPadrows(); m++)
108  for (unsigned int h=0; h<theHits->sector(n)->padrow(m)->hits().size(); h++)
109  theHits->sector(n)->padrow(m)->hits()[h]->makeZombie();
110  theHits->makeZombie();
111  return true;
112  }
113  else
114  return false;
115 }
116 
117 bool StEventScavenger::removeTpcHitsNotOnTracks(StEvent* evt)
118 {
119  if (evt && evt->tpcHitCollection()) {
120  // first remove all hits not associated with a track at all
121  StTpcHitCollection *theHits = evt->tpcHitCollection();
122  for (unsigned int n=0; n<theHits->numberOfSectors(); n++)
123  for (unsigned int m=0; m<theHits->sector(n)->numberOfPadrows(); m++)
124  for (unsigned int h=0; h<theHits->sector(n)->padrow(m)->hits().size(); h++)
125  if (theHits->sector(n)->padrow(m)->hits()[h]->trackReferenceCount() == 0)
126  theHits->sector(n)->padrow(m)->hits()[h]->makeZombie();
127  // now all hits associated with zombie tracks
128  StSPtrVecTrackNode& nodes = evt->trackNodes();
129  for (unsigned int i = 0; i < nodes.size(); i++) { // loop nodes
130  StTrackNode* node = nodes[i];
131  for (unsigned int j = 0; j < node->entries(); j++) { // loop tracks in node
132  if (node->track(j)->isZombie()) {
133  StTrack* track = node->track(j);
134  StTrackDetectorInfo* info = track->detectorInfo();
135  if (info) {
136  StPtrVecHit& hitList = info->hits();
137  for (unsigned int k = 0; k < hitList.size(); k++) // loop hits
138  if (hitList[k]->detector() == kTpcId) hitList[k]->makeZombie();
139  }
140  }
141  }
142  }
143  return true;
144  }
145  else
146  return false;
147 }
148 
149 bool StEventScavenger::removeFtpcHitCollection(StEvent* evt)
150 {
151  if (evt && evt->ftpcHitCollection()) {
152  StFtpcHitCollection *theHits = evt->ftpcHitCollection();
153  for (unsigned int n=0; n<theHits->numberOfPlanes(); n++)
154  for (unsigned int m=0; m<theHits->plane(n)->numberOfSectors(); m++)
155  for (unsigned int h=0; h<theHits->plane(n)->sector(m)->hits().size(); h++)
156  theHits->plane(n)->sector(m)->hits()[h]->makeZombie();
157  theHits->makeZombie();
158  return true;
159  }
160  else
161  return false;
162 }
163 
164 bool StEventScavenger::removeSvtHitCollection(StEvent* evt)
165 {
166  if (evt && evt->svtHitCollection()) {
167  StSvtHitCollection *theHits = evt->svtHitCollection();
168  for (unsigned int n=0; n<theHits->numberOfBarrels(); n++)
169  for (unsigned int m=0; m<theHits->barrel(n)->numberOfLadders(); m++)
170  for (unsigned int k=0; k<theHits->barrel(n)->ladder(k)->numberOfWafers(); k++)
171  for (unsigned int h=0; h<theHits->barrel(n)->ladder(m)->wafer(k)->hits().size(); h++)
172  theHits->barrel(n)->ladder(m)->wafer(k)->hits()[h]->makeZombie();
173  theHits->makeZombie();
174  return true;
175  }
176  else
177  return false;
178 }
179 
180 bool StEventScavenger::removeSsdHitCollection(StEvent* evt)
181 {
182  if (evt && evt->ssdHitCollection()) {
183  StSsdHitCollection *theHits = evt->ssdHitCollection();
184  for (unsigned int m=0; m<theHits->numberOfLadders(); m++)
185  for (unsigned int k=0; k<theHits->ladder(k)->numberOfWafers(); k++)
186  for (unsigned int h=0; h<theHits->ladder(m)->wafer(k)->hits().size(); h++)
187  theHits->ladder(m)->wafer(k)->hits()[h]->makeZombie();
188  theHits->makeZombie();
189  return true;
190  }
191  else
192  return false;
193 }
194 
195 bool StEventScavenger::removeEmcCollection(StEvent* evt)
196 {
197  if (evt && evt->emcCollection()) {
198  evt->emcCollection()->makeZombie();
199  return true;
200  }
201  else
202  return false;
203 }
204 
205 bool StEventScavenger::removeRichCollection(StEvent* evt)
206 {
207  if (evt && evt->richCollection()) {
208  evt->richCollection()->makeZombie();
209  return true;
210  }
211  else
212  return false;
213 }
214 
215 bool StEventScavenger::removeTriggerDetectorCollection(StEvent* evt)
216 {
217  if (evt && evt->triggerDetectorCollection()) {
218  evt->triggerDetectorCollection()->makeZombie();
219  return true;
220  }
221  else
222  return false;
223 }
224 
225 bool StEventScavenger::removeFpdCollection(StEvent* evt)
226 {
227  if (evt && evt->fpdCollection()) {
228  evt->fpdCollection()->makeZombie();
229  return true;
230  }
231  else
232  return false;
233 }
234 
235 bool StEventScavenger::removeTofCollection(StEvent* evt)
236 {
237  if (evt && evt->tofCollection()) {
238  evt->tofCollection()->makeZombie();
239  return true;
240  }
241  else
242  return false;
243 }
244 
245 bool StEventScavenger::removeHltEvent(StEvent* evt)
246 {
247  if (evt && evt->hltEvent()) {
248  evt->hltEvent()->makeZombie();
249  return true;
250  }
251  else
252  return false;
253 }
254 
255 bool StEventScavenger::remove(StTrack* track)
256 {
257  if (!track) return false;
258 
259  track->makeZombie();
260 
261  //
262  // Scan all tracks in node. If all are zombies we can
263  // make the node a zombie too. We also remove the detector
264  // info associated with the track if no other living
265  // track is using it.
266  //
267  StTrackNode* node = track->node();
268  StTrackDetectorInfo* info = track->detectorInfo();
269  unsigned int nTimesUsed = 0;
270  unsigned int nZombies = 0;
271  StTrack *someTrack;
272  if (node) {
273  unsigned int i;
274  for (i=0; i<node->entries(); i++) {
275  someTrack = node->track(i);
276  if (someTrack->isZombie()) nZombies++;
277  if (someTrack != track && !someTrack->isZombie() &&
278  someTrack->detectorInfo() == info) nTimesUsed++;
279  }
280  if (node->entries() == nZombies) node->makeZombie();
281  }
282  if (info && nTimesUsed < 1) info->makeZombie();
283 
284  return true;
285 }