StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StiPxlHitLoader.cxx
1  /*
2  * $Id: StiPxlHitLoader.cxx,v 1.22 2015/08/14 13:38:07 smirnovd Exp $
3  *
4  * $Log: StiPxlHitLoader.cxx,v $
5  * Revision 1.22 2015/08/14 13:38:07 smirnovd
6  * StiPxlHitLoader: Removed unused code
7  *
8  * This should have been removed when commit 9512a2ea "Reimplemented segmentation
9  * of PXL sensor to two halves." was introduced.
10  *
11  * Revision 1.21 2015/05/21 03:08:46 smirnovd
12  * Revert "Remove throw"
13  *
14  * No value can be immediately seen in the changes.
15  * We need to hear more arguments on why it is better to remove the throw. What is
16  * the point in adding a dummy static local variable that does nothing?
17  * Even if some changes can be defended to be appropriate the same must be done in
18  * StiIstHitLoader and StiSsdHitLoader
19  *
20  * Revision 1.19 2015/03/03 21:15:23 smirnovd
21  * StiIst[Pxl]HitLoader: Allow tracks to share IST and PXL hits by up to 5 times
22  *
23  * Revision 1.18 2015/03/03 21:15:15 smirnovd
24  * Revert sloppy commits "StiIstHit reused 5 times" and "StiPxlHit reused in 5 times"
25  *
26  * The original author (Victor) admitted making a mistake by changing the
27  * warning and error messages. It was not intended
28  *
29  * Revision 1.16 2015/01/21 23:10:59 smirnovd
30  * Made all info/warn/error messages consistent across StiDetectorBuilder's
31  *
32  * Revision 1.15 2015/01/06 20:57:50 smirnovd
33  * Reimplemented segmentation of PXL sensor to two halves.
34  *
35  * In the sensor's local coordinate system the first half is for x<0 and the second
36  * one is for x>0. The notion of inner and outter halves is not critical and in
37  * fact confusing because it depends on the original rotation around the z axis.
38  * For example, two rotations of phi=5 and phi=-175 give us essentially the same
39  * layer but result in swapped inner and outter halves.
40  *
41  * Revision 1.14 2015/01/06 15:47:44 smirnovd
42  * Removed excessive print statements
43  *
44  * Revision 1.13 2015/01/06 15:47:35 smirnovd
45  * Simplified debug output by reusing existing streamers of StHit class and its daughters
46  *
47  * Revision 1.12 2015/01/05 15:40:04 smirnovd
48  * StiXxxHitLoader: Changes in whitespace only
49  *
50  * Revision 1.11 2014/12/19 18:09:01 smirnovd
51  * Do not set StiDetector members _key1 and _key2 as they are not really used anywhere
52  *
53  * Revision 1.10 2014/12/15 21:07:28 qiuh
54  * use local x rahter than row number to distribute hits into different half ladders
55  *
56  * Revision 1.9 2014/11/17 20:37:32 smirnovd
57  * Split PXL sensitive layers in two halves. The change should help to avoid track backward steps in Sti due to ill ordered volumes in r and phi - inspired by Hao Qiu
58  *
59  * Revision 1.8 2014/06/05 14:28:18 genevb
60  * Error about missing hit collection => warning
61  *
62  * Revision 1.7 2014/04/15 18:46:55 smirnovd
63  * Switched to PXL sensitive layer geometry with one Sti volume per ladder centered
64  * at z=0. The loop over sensors removed and the indexing of the volumes changed
65  * accordingly. Update from Jonathan Bouchet
66  *
67  * Revision 1.6 2014/03/27 22:48:08 smirnovd
68  * Minor improvements in feedback
69  *
70  * Revision 1.5 2014/03/07 16:27:46 smirnovd
71  * Updated assignment and extraction of sti (pixel sensor) detectors by keys
72  *
73  * Revision 1.4 2014/03/04 15:36:38 smirnovd
74  * Remove constraint on sectors used in engeneering run in 2013
75  *
76  * Revision 1.3 2014/03/03 23:54:35 smirnovd
77  * Remove extra pointer validation check
78  *
79  * Revision 1.2 2014/02/04 16:56:48 smirnovd
80  * Clean up and improved readability
81  *
82  * Revision 1.1 2014/02/01 19:19:35 smirnovd
83  * Initial commit: Changed files prefix StiPixel... to StiPxl... according to STAR convention
84  *
85  * Revision 1.16 2014/02/01 02:48:07 smirnovd
86  * Improved style format by running astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f
87  *
88  * Revision 1.15 2014/02/01 02:37:17 smirnovd
89  * This commit is intended to sync with what we had in StRoot/StiRnD
90  *
91  * Revision 1.27 2014/01/23 17:38:18 bouchet
92  * *** empty log message ***
93  *
94  * Revision 1.26 2013/03/12 15:04:00 bouchet
95  * StPxlHit navigation to retrieve hits
96  *
97  * Revision 1.24 2012/12/18 20:52:32 bouchet
98  * update for DEV13 geometry
99  *
100  * Revision 1.23 2011/04/22 22:00:18 fisyak
101  * warn off
102  *
103  * Revision 1.22 2009/02/09 02:47:19 andrewar
104  * UPGR15 update. Will break backward compatibility with older geometries.
105  *
106  * Revision 1.21 2008/03/25 20:02:28 andrewar
107  * Removed hit smearing.
108  *
109  * Revision 1.20 2007/10/16 19:50:25 fisyak
110  * rename Hft => Pxl, remove Hpd, Igt and Fst
111  *
112  * Revision 1.19 2007/05/16 15:03:22 andrewar
113  * Removed cout's in favor of LOG_INFO.
114  *
115  * Revision 1.18 2007/03/28 13:33:23 mmiller
116  * Removed cout/printf's.
117  *
118  * Revision 1.17 2006/11/30 20:42:46 andrewar
119  * Fixed sign error in pixel smearing.
120  *
121  * Revision 1.16 2006/11/29 04:19:23 andrewar
122  * Added smearing to hit loader.
123  *
124  * Revision 1.15 2006/11/17 15:39:03 wleight
125  * Changes to make PXL hits work with UPGR05 geometry
126  *
127  * Revision 1.14 2006/02/17 21:37:53 andrewar
128  * Removed streaming of all read pixel hits, added version comments log
129  *
130  */
131 
132 
133 #include <iostream>
134 #include <stdexcept>
135 #include <cmath>
136 #include <stdio.h>
137 #include <stdlib.h>
138 #include "StEvent.h"
139 #include "StEventTypes.h"
140 #include "StDbUtilities/StGlobalCoordinate.hh"
141 #include "Sti/Base/Factory.h"
142 #include "Sti/StiHit.h"
143 #include "StPxlHitCollection.h"
144 #include "StPxlHit.h"
145 #include "Sti/StiHitContainer.h"
146 #include "Sti/StiDetector.h"
147 #include "Sti/StiDetectorBuilder.h"
148 #include "Sti/StiTrackContainer.h"
149 #include "StiPxl/StiPxlDetectorBuilder.h"
150 #include "StiPxlHitLoader.h"
151 #include "StPxlUtil/StPxlConstants.h"
152 
153 
154 StiPxlHitLoader::StiPxlHitLoader()
155  : StiHitLoader<StEvent, StiDetectorBuilder>("PixelHitLoader")
156 {}
157 
158 
159 StiPxlHitLoader::StiPxlHitLoader(StiHitContainer *hitContainer, Factory<StiHit> *hitFactory,
160  StiDetectorBuilder *detector) :
161  StiHitLoader<StEvent, StiDetectorBuilder>("PixelHitLoader", hitContainer, hitFactory, detector)
162 {}
163 
164 
165 void StiPxlHitLoader::loadHits(StEvent *source, Filter<StiTrack> *trackFilter, Filter<StiHit> *hitFilter)
166 {
167  if (!_detector)
168  throw runtime_error("StiPxlHitLoader::loadHits(StEvent*) - FATAL - _detector==0");
169 
170  if (!_hitContainer)
171  throw runtime_error("StiPxlHitLoader::loadHits(StEvent*) - FATAL - _hitContainer==0");
172 
173  StPxlHitCollection *pxlHitCollection = source->pxlHitCollection();
174 
175  if (!pxlHitCollection) {
176  LOG_WARN << "StiPxlHitLoader::loadHits() - StPxlHitCollection not found. "
177  "Check for StPxlSimMaker or StPxlHitMaker options in input chain. "
178  "PXL hits will not be used in tracking" << endm;
179  return;
180  }
181 
182  //Added by Michael Lomnitz (KSU): Loops over Sector/Ladder/Sensor to obtain the whole hit collection
183  UInt_t numberOfSectors = pxlHitCollection->numberOfSectors();
184 
185  for (UInt_t i = 0; i < numberOfSectors; i++)
186  {
187  StPxlSectorHitCollection *pxlSectorHitCollection = pxlHitCollection->sector(i);
188  if ( !pxlSectorHitCollection ) {cout << "No PXLSector hit collection" << endl; return;}
189 
190  UInt_t numberOfLadders = pxlSectorHitCollection->numberOfLadders();
191 
192  for (UInt_t j = 0; j < numberOfLadders; j++)
193  {
194  StPxlLadderHitCollection *pxlLadderHitCollection = pxlSectorHitCollection->ladder(j);
195  if ( !pxlLadderHitCollection ) {cout << "No PXLLadder hit collection" << endl; return;}
196 
197  UInt_t numberOfSensors = pxlLadderHitCollection->numberOfSensors();
198 
199  for (UInt_t l = 0; l < numberOfSensors; l++)
200  {
201  StPxlSensorHitCollection *PxlSensorHitCollection = pxlLadderHitCollection->sensor(l);
202  StSPtrVecPxlHit &pxlHits = PxlSensorHitCollection->hits();
203 
204  LOG_DEBUG << "StiPxlHitLoader::loadHits() - Collection size: " << pxlHits.size() << endm;
205 
206  for (unsigned int iPxlHit = 0; iPxlHit < pxlHits.size(); iPxlHit++)
207  {
208  StPxlHit *pxlHit = pxlHits[iPxlHit];
209 
210  if (!pxlHit)
211  throw runtime_error("StiPxlHitLoader::loadHits(StEvent*) -E- NULL hit in container");
212 
213  if (pxlHit->detector() != kPxlId) continue;
214 
215  LOG_DEBUG << "StiPxlHitLoader::loadHits() - \n"
216  << *pxlHit << "\n"
217  << *static_cast<StMeasuredPoint*>(pxlHit) << endm;
218 
219  // The PXL sensitive layers are split into two halves so, access the corresponding
220  // sensor half to be later associated with this pxlHit
221  int sensorHalf = pxlHit->localPosition(0) < 0 ? 1 : 2;
222  const StiDetector *detector = static_cast<StiPxlDetectorBuilder*>(_detector)->getActiveDetector(pxlHit->sector(), pxlHit->ladder(), sensorHalf);
223 
224  if (!detector)
225  throw runtime_error("StiPxlHitLoader::loadHits(StEvent*) -E- NULL detector pointer");
226 
227  StiHit *stiHit = _hitFactory->getInstance();
228 
229  if (!stiHit) throw runtime_error("StiPxlHitLoader::loadHits(StEvent*) -E- stiHit==0");
230 
231  stiHit->reset();
232 
233  stiHit->setGlobal(detector, pxlHit,
234  pxlHit->position().x(), pxlHit->position().y(),
235  pxlHit->position().z(), pxlHit->charge());
236  // Allow the hit to be shared by up to 5 tracks
237  stiHit->setMaxTimes(5);
238 
239  _hitContainer->add(stiHit);
240  }
241  }
242  }
243  }
244 }
virtual void add(StiHit *)
void setGlobal(const StiDetector *detector, const StMeasuredPoint *stHit, Float_t x, Float_t y, Float_t z, Float_t energy)
Definition: StiHit.cxx:133
Definition: StiHit.h:51
virtual Abstract * getInstance()=0
Get a pointer to instance of objects served by this factory.
void setMaxTimes(int set)
Set the number of times used.
Definition: StiHit.h:142