StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StIstHitMaker.cxx
1 /* $Id: StIstHitMaker.cxx,v 1.29 2018/01/04 17:34:38 smirnovd Exp $ */
2 
3 #include "Stypes.h"
4 #include "TNamed.h"
5 #include "TGeoMatrix.h"
6 
7 #include "StIstHitMaker.h"
8 #include "StIstUtil/StIstCollection.h"
9 #include "StIstUtil/StIstCluster.h"
10 #include "StIstUtil/StIstClusterCollection.h"
11 #include "StIstHit.h"
12 #include "StIstHitCollection.h"
13 
14 #include "St_base/StMessMgr.h"
15 #include "StEvent.h"
16 #include "StEventTypes.h"
17 #include "StContainers.h"
18 #include "StEvent/StEnumerations.h"
19 #include "StIstUtil/StIstConsts.h"
20 
21 #include "StIstDbMaker/StIstDb.h"
22 #include "tables/St_istControl_Table.h"
23 
24 ClassImp(StIstHitMaker);
25 
26 
27 StIstHitMaker::StIstHitMaker( const char *name ) : StMaker(name), mSensorTransforms(0)
28 {
29 }
30 
31 
32 Int_t StIstHitMaker::InitRun(Int_t runnumber)
33 {
34  TObjectSet *istDbDataSet = (TObjectSet *) GetDataSet("ist_db");
35  StIstDb *istDb = 0;
36 
37  if (istDbDataSet) {
38  istDb = (StIstDb *) istDbDataSet->GetObject();
39  assert(istDb);
40  }
41  else {
42  LOG_ERROR << "InitRun : no istDb" << endm;
43  return kStErr;
44  }
45 
46  // geometry Db tables
47  mSensorTransforms = istDb->getRotations();
48 
49  return kStOk;
50 }
51 
52 
59 {
60  // Obtain hit collection
61  StEvent *eventPtr = (StEvent *) GetDataSet("StEvent");
62 
63  if (!eventPtr) {
64  LOG_ERROR << "Make() - No StEvent found in the chain. Cannot proceed" << endm;
65  return kStErr;
66  }
67 
68  //input clusters info.
69  TObjectSet *istDataSet = (TObjectSet *) GetDataSet("istRawHitAndCluster");
70 
71  if (!istDataSet) {
72  LOG_WARN << "Make() - istRawHitAndCluster dataset not found. No IST hits will be available for tracking" << endm;
73  return kStWarn;
74  }
75 
76  StIstCollection *istCollectionPtr = (StIstCollection *) istDataSet->GetObject();
77 
78  if ( !istCollectionPtr ) {
79  LOG_WARN << "Make() - StIstCollection not found. No IST hits will be available for tracking" << endm;
80  return kStWarn;
81  }
82 
83  // Get pointer to an existing StIstHitCollection if any
84  StIstHitCollection *istHitCollection = eventPtr->istHitCollection();
85 
86  // If no ist hit collection, create one
87  if (!istHitCollection) {
88  istHitCollection = new StIstHitCollection();
89  eventPtr->setIstHitCollection(istHitCollection);
90  LOG_DEBUG << "Make() - Added new StIstHitCollection to this StEvent" << endm;
91  }
92 
93  unsigned char nClusteringType = -1;
94 
95  for (unsigned char ladderIdx = 0; ladderIdx < kIstNumLadders; ++ladderIdx) {
96  //add new hits from clusters
97 
98  StIstClusterCollection *clusterCollectionPtr = istCollectionPtr->getClusterCollection(ladderIdx );
99 
100  if ( clusterCollectionPtr ) {
101  unsigned int numClusters = clusterCollectionPtr->getNumClusters();
102  LOG_DEBUG << "Make() - Number of clusters found in ladder " << (int)(ladderIdx + 1) << ": " << numClusters << endm;
103 
104  unsigned short idTruth = 0;
105  unsigned char nRawHits = -1, nRawHitsZ = -1, nRawHitsRPhi = -1;
106  unsigned char ladder = -1, sensor = -1;
107  float meanRow = 0., meanColumn = 0., charge = 0., chargeErr = 0.;
108  unsigned char maxTb = -1;
109  int key = -1;
110 
111  for (std::vector< StIstCluster * >::iterator clusterIter = clusterCollectionPtr->getClusterVec().begin(); clusterIter != clusterCollectionPtr->getClusterVec().end(); ++clusterIter) {
112  idTruth = (*clusterIter)->getIdTruth();
113  key = (*clusterIter)->getKey();
114  ladder = (*clusterIter)->getLadder();
115  sensor = (*clusterIter)->getSensor();
116  meanRow = (*clusterIter)->getMeanRow();
117  meanColumn = (*clusterIter)->getMeanColumn();
118  maxTb = (*clusterIter)->getMaxTimeBin();
119  charge = (*clusterIter)->getTotCharge();
120  chargeErr = (*clusterIter)->getTotChargeErr();
121  nRawHits = (*clusterIter)->getNRawHits();
122  nRawHitsZ = (*clusterIter)->getNRawHitsZ();
123  nRawHitsRPhi = (*clusterIter)->getNRawHitsRPhi();
124  nClusteringType = (*clusterIter)->getClusteringType();
125 
126  StIstHit *newHit = new StIstHit(ladder, sensor, charge, chargeErr, maxTb, nRawHits, nRawHitsZ, nRawHitsRPhi);
127  newHit->setId(key);
128  newHit->setIdTruth(idTruth);
129 
130  double local[3];
131  local[0] = 0.5 * kIstSensorActiveSizeRPhi - (meanRow - 0.5) * kIstPadPitchRow; //unit: cm
132  local[1] = 0.;
133  local[2] = (meanColumn - 0.5) * kIstPadPitchColumn - 0.5 * kIstSensorActiveSizeZ; //unit: cm
134  newHit->setLocalPosition(local[0], local[1], local[2]); //set local position on sensor
135 
136  istHitCollection->addHit(newHit);
137  } //cluster loop over
138  }//end clusterCollectionPtr
139 
140  //set global position
141  StIstLadderHitCollection *ladderHitCollection = istHitCollection->ladder(ladderIdx);
142 
143  for (int sensorIdx = 0; sensorIdx < kIstNumSensorsPerLadder; sensorIdx++) {
144  StIstSensorHitCollection *sensorHitCollection = ladderHitCollection->sensor(sensorIdx);
145 
146  for (int idx = 0; idx < (int) sensorHitCollection->hits().size(); idx++ ) {
147  StIstHit *newHit = sensorHitCollection->hits()[idx];
148  double local[3];
149  double global[3];
150  local[0] = newHit->localPosition(0);
151  local[1] = newHit->localPosition(1);
152  local[2] = newHit->localPosition(2);
153 
154  int sensorId = 1000 + ((int)newHit->getLadder() - 1) * kIstNumSensorsPerLadder + (int)newHit->getSensor();
155  TGeoHMatrix *geoMSensorOnGlobal = (TGeoHMatrix *) mSensorTransforms->FindObject(Form("R%04i", sensorId));
156  geoMSensorOnGlobal->LocalToMaster(local, global);
157  StThreeVectorF vecGlobal(global);
158  newHit->setPosition(vecGlobal); //set global position
159  }//end sensor hit collection
160  }//end ladder hit collection
161  } //ladder loop over
162 
163  istHitCollection->setClusteringType(nClusteringType);
164 
165  return kStOk;
166 }
167 
168 
169 /***************************************************************************
170 *
171 * $Log: StIstHitMaker.cxx,v $
172 * Revision 1.29 2018/01/04 17:34:38 smirnovd
173 * [Cosmetic] Remove StRoot/ from include path
174 *
175 * $STAR/StRoot is already in the default path search
176 *
177 * Revision 1.28 2015/01/14 02:29:10 ypwang
178 * minor update in Make() back to version 1.24
179 *
180 * Revision 1.27 2014/10/14 21:06:40 smirnovd
181 * Updated debug and log messages, added doxygen comments. Also other minor whitespace and style changes
182 *
183 * Revision 1.26 2014/10/14 21:06:34 smirnovd
184 * StIstHitMaker: Arranged checks for required containers and objects in a more logical way. Added corresponding log messages
185 *
186 * Revision 1.25 2014/10/14 21:06:29 smirnovd
187 * StIstHitMaker: No point to proceed with cluster-to-tracking-hit conversion if there are no cluster container for this ladder
188 *
189 * Revision 1.24 2014/10/14 21:06:22 smirnovd
190 * StIstHitMaker: No need to check for valid pointer to StIstCollection for each ladder as it has been already verified at the begining of this Make()
191 *
192 * Revision 1.23 2014/10/14 21:05:54 smirnovd
193 * Don't wait until the end of routine to return error codes. Leads to somewhat cleaner code and eliminates if statements
194 *
195 * Revision 1.22 2014/10/13 22:33:04 smirnovd
196 * Minor adjustments to the code and comments
197 *
198 * Revision 1.21 2014/10/13 22:32:57 smirnovd
199 * StIstHitMaker: Renamed data member to more meaningful name conforming with STAR style
200 *
201 * Revision 1.20 2014/10/13 22:28:24 smirnovd
202 * StIstHitMaker: Use local pointer to StIstDb. No need to have a data member
203 *
204 * Revision 1.19 2014/10/13 22:28:11 smirnovd
205 * Removed pointless methods. ::Init() and ::Finish() do not do much. Data members initialized in constructor
206 *
207 * Revision 1.18 2014/10/13 22:28:03 smirnovd
208 * StIstHitMaker: Corrected style with astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f
209 *
210 * Revision 1.17 2014/10/13 22:21:56 smirnovd
211 * Moved CVS log to the end of file and updated doxygen-style comments
212 *
213 * Revision 1.16 2014/08/14 00:49:10 smirnovd
214 * StIstHitMaker: Changed the logic in Make(). Don't create a new StEvent if it is not found in the chain, issue an error instead
215 *
216 * Revision 1.15 2014/08/12 23:08:09 ypwang
217 * remove the cluster number cut per ladder, due to chip occupancy cut was added in raw hit maker which can do the bad column rejection
218 *
219 * Revision 1.14 2014/08/06 18:56:53 ypwang
220 * minor update due to coding style update of the StIstDb method
221 *
222 * Revision 1.13 2014/07/29 20:13:31 ypwang
223 * update the IST DB obtain method
224 *
225 * Revision 1.12 2014/06/27 21:31:40 ypwang
226 * remove data member istHitCollection and related Clear() function
227 *
228 * Revision 1.11 2014/03/25 03:06:53 ypwang
229 * updates on Db table accessory method
230 *
231 * Revision 1.10 2014/03/24 15:55:08 ypwang
232 * minor updates due to returned const pointers in StIstDbMaker
233 *
234 * Revision 1.9 2014/03/18 02:30:25 ypwang
235 * minor typo error correction
236 *
237 * Revision 1.8 2014/03/17 21:41:49 ypwang
238 * update to process hit from cluster collection or existed hit collection
239 *
240 * Revision 1.7 2014/02/26 01:39:27 ypwang
241 * minor updates on hit local position setting: meanColumn/meanRow transform to local position here
242 *
243 * Revision 1.6 2014/02/25 17:10:55 ypwang
244 * minor update due to mClusteringType moved to StIstHitCollection
245 *
246 * Revision 1.5 2014/02/14 14:47:20 ypwang
247 * update due to removal of getNumLadders() member function from StIstCollection
248 *
249 * Revision 1.4 2014/02/08 03:34:16 ypwang
250 * updating scripts
251 *
252 *
253 ****************************************************************************
254 * StIstHitMaker.cxx,v 1.0
255 * Revision 1.0 2013/11/04 16:05:30 Yaping
256 * Initial version
257 ****************************************************************************/
const int kIstNumLadders
24 IST Ladders
Definition: Stypes.h:42
THashList * mSensorTransforms
A list of TGeo transformations for each IST sensor.
Definition: StIstHitMaker.h:30
const int kIstNumSensorsPerLadder
6 sensor per one IST Ladder
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56
Definition: Stypes.h:44
Definition: Stypes.h:41