StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFtpcGeantReader.cc
1 // $Id: StFtpcGeantReader.cc,v 1.4 2007/01/15 07:49:22 jcs Exp $
2 //
3 // $Log: StFtpcGeantReader.cc,v $
4 // Revision 1.4 2007/01/15 07:49:22 jcs
5 // replace printf, cout and gMesMgr with Logger
6 //
7 // Revision 1.3 2004/01/28 01:41:15 jeromel
8 // Change OST to OS everywhere since defaultoption is now not to print
9 // the date.
10 //
11 // Revision 1.2 2003/10/07 12:40:29 jcs
12 // created member functions to extract ftpc plane and sector number from the GEANT volume id
13 //
14 // Revision 1.1 2000/09/18 14:27:42 hummler
15 // add StFtpcGeantReader
16 //
17 //
18 
19 #include "StFtpcGeantReader.hh"
20 
21 #include <math.h>
22 #include "StMessMgr.h"
23 
24 StFtpcGeantReader::StFtpcGeantReader(St_g2t_vertex *vertex,
25  St_g2t_track *track,
26  St_g2t_ftp_hit *hit)
27 {
28  vertexTable = vertex->GetTable();
29  nVertices = vertex->GetNRows();
30  trackTable = track->GetTable();
31  nTracks = track->GetNRows();
32  hitTable = hit->GetTable();
33  nHits = hit->GetNRows();
34 }
35 
36 StFtpcGeantReader::~StFtpcGeantReader()
37 {
38 }
39 
40 Int_t StFtpcGeantReader::nextTrackHit(Int_t i)
41 {
42  if(i>=0 && i<nHits)
43  {
44  return hitTable[i].next_tr_hit_p-1;
45  }
46  else
47  {
48  LOG_WARN << "StFtpcGeantReader: nextTrackHit index out of range, using 0" << endm;
49  return hitTable[0].next_tr_hit_p-1;
50  }
51 }
52 
53 Int_t StFtpcGeantReader::track(Int_t i)
54 {
55  if(i>=0 && i<nHits)
56  {
57  return hitTable[i].track_p-1;
58  }
59  else
60  {
61  LOG_WARN << "StFtpcGeantReader: track index out of range, using 0" << endm;
62  return hitTable[0].track_p-1;
63  }
64 }
65 
66 Int_t StFtpcGeantReader::geantVolume(Int_t i)
67 {
68  if(i>=0 && i<nHits)
69  {
70  return hitTable[i].volume_id;
71  }
72  else
73  {
74  LOG_WARN << "StFtpcGeantReader: geantVolume index out of range, using 0" << endm;
75  return hitTable[0].volume_id;
76  }
77 }
78 Int_t StFtpcGeantReader::geantPlane(Int_t GeantVolume)
79 {
80  // from the Geant VolumeId, the plane number {1,20} (West,East)
81 
82  return (GeantVolume/1000 -1)*10 + GeantVolume/10 % 100;
83 }
84 Int_t StFtpcGeantReader::geantSector(Int_t GeantVolume)
85 {
86  // from the Geant VolumeId, the sector number {1,6}
87  return GeantVolume%10 ;
88 }
89 
90 Float_t StFtpcGeantReader::energyLoss(Int_t i)
91 {
92  if(i>=0 && i<nHits)
93  {
94  return hitTable[i].de;
95  }
96  else
97  {
98  LOG_WARN << "StFtpcGeantReader: energyLoss index out of range, using 0" << endm;
99  return hitTable[0].de;
100  }
101 }
102 
103 Float_t StFtpcGeantReader::segmentLength(Int_t i)
104 {
105  if(i>=0 && i<nHits)
106  {
107  return hitTable[i].ds;
108  }
109  else
110  {
111  LOG_WARN << "StFtpcGeantReader: segmentLength index out of range, using 0" << endm;
112  return hitTable[0].ds;
113  }
114 }
115 
116 Float_t StFtpcGeantReader::pLocalX(Int_t i)
117 {
118  if(i>=0 && i<nHits)
119  {
120  return hitTable[i].p[0];
121  }
122  else
123  {
124  LOG_WARN << "StFtpcGeantReader: pLocalX index out of range, using 0" << endm;
125  return hitTable[0].p[0];
126  }
127 }
128 
129 Float_t StFtpcGeantReader::pLocalY(Int_t i)
130 {
131  if(i>=0 && i<nHits)
132  {
133  return hitTable[i].p[1];
134  }
135  else
136  {
137  LOG_WARN << "StFtpcGeantReader: pLocalY index out of range, using 0" << endm;
138  return hitTable[0].p[1];
139  }
140 }
141 
142 Float_t StFtpcGeantReader::pLocalZ(Int_t i)
143 {
144  if(i>=0 && i<nHits)
145  {
146  return hitTable[i].p[2];
147  }
148  else
149  {
150  LOG_WARN << "StFtpcGeantReader: pLocalZ index out of range, using 0" << endm;
151  return hitTable[0].p[2];
152  }
153 }
154 
155 Float_t StFtpcGeantReader::timeOfFlight(Int_t i)
156 {
157  if(i>=0 && i<nHits)
158  {
159  return hitTable[i].tof;
160  }
161  else
162  {
163  LOG_WARN << "StFtpcGeantReader: timeOfFlight index out of range, using 0" << endm;
164  return hitTable[0].tof;
165  }
166 }
167 
168 Float_t StFtpcGeantReader::x(Int_t i)
169 {
170  if(i>=0 && i<nHits)
171  {
172  return hitTable[i].x[0];
173  }
174  else
175  {
176  LOG_WARN << "StFtpcGeantReader: x index out of range, using 0" << endm;
177  return hitTable[0].x[0];
178  }
179 }
180 
181 Float_t StFtpcGeantReader::y(Int_t i)
182 {
183  if(i>=0 && i<nHits)
184  {
185  return hitTable[i].x[1];
186  }
187  else
188  {
189  LOG_WARN << "StFtpcGeantReader: y index out of range, using 0" << endm;
190  return hitTable[0].x[1];
191  }
192 }
193 
194 Float_t StFtpcGeantReader::z(Int_t i)
195 {
196  if(i>=0 && i<nHits)
197  {
198  return hitTable[i].x[2];
199  }
200  else
201  {
202  LOG_WARN << "StFtpcGeantReader: z index out of range, using 0" << endm;
203  return hitTable[0].x[2];
204  }
205 }
206 
207 Int_t StFtpcGeantReader::trackType(Int_t i)
208 {
209  if(i>=0 && i<nHits)
210  {
211  return hitTable[i].track_type;
212  }
213  else
214  {
215  LOG_WARN << "StFtpcGeantReader: trackType index out of range, using 0" << endm;
216  return hitTable[0].track_type;
217  }
218 }
219 
220 Int_t StFtpcGeantReader::trackPid(Int_t i)
221 {
222  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
223  {
224  return trackTable[hitTable[i].track_p-1].ge_pid;
225  }
226  else
227  {
228  LOG_WARN << "StFtpcGeantReader: geantPid index out of range, using 0" << endm;
229  return trackTable[0].ge_pid;
230  }
231 }
232 
233 Int_t StFtpcGeantReader::hitsOnTrack(Int_t i)
234 {
235  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
236  {
237  return trackTable[hitTable[i].track_p-1].n_ftp_hit;
238  }
239  else
240  {
241  LOG_WARN << "StFtpcGeantReader: hitsOnTrack index out of range, using 0" << endm;
242  return trackTable[0].n_ftp_hit;
243  }
244 }
245 
246 Int_t StFtpcGeantReader::firstHitOnTrack(Int_t i)
247 {
248  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
249  {
250  return trackTable[hitTable[i].track_p-1].hit_ftp_p-1;
251  }
252  else
253  {
254  LOG_WARN << "StFtpcGeantReader: firstHitOnTrack index out of range, using 0" << endm;
255  return trackTable[0].hit_ftp_p-1;
256  }
257 }
258 
259 Int_t StFtpcGeantReader::isShower(Int_t i)
260 {
261  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
262  {
263  return trackTable[hitTable[i].track_p-1].is_shower;
264  }
265  else
266  {
267  LOG_WARN << "StFtpcGeantReader: isShower index out of range, using 0" << endm;
268  return trackTable[0].is_shower;
269  }
270 }
271 
272 Int_t StFtpcGeantReader::trackVertex(Int_t i)
273 {
274  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
275  {
276  return trackTable[hitTable[i].track_p-1].start_vertex_p-1;
277  }
278  else
279  {
280  LOG_WARN << "StFtpcGeantReader: trackVertex index out of range, using 0" << endm;
281  return trackTable[0].start_vertex_p-1;
282  }
283 }
284 
285 Float_t StFtpcGeantReader::trackCharge(Int_t i)
286 {
287  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
288  {
289  return trackTable[hitTable[i].track_p-1].charge;
290  }
291  else
292  {
293  LOG_WARN << "StFtpcGeantReader: trackCharge index out of range, using 0" << endm;
294  return trackTable[0].charge;
295  }
296 }
297 
298 Float_t StFtpcGeantReader::trackEnergy(Int_t i)
299 {
300  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
301  {
302  return trackTable[hitTable[i].track_p-1].e;
303  }
304  else
305  {
306  LOG_WARN << "StFtpcGeantReader: trackEnergy index out of range, using 0" << endm;
307  return trackTable[0].e;
308  }
309 }
310 
311 Float_t StFtpcGeantReader::trackEta(Int_t i)
312 {
313  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
314  {
315  return trackTable[hitTable[i].track_p-1].eta;
316  }
317  else
318  {
319  LOG_WARN << "StFtpcGeantReader: trackEta index out of range, using 0" << endm;
320  return trackTable[0].eta;
321  }
322 }
323 
324 Float_t StFtpcGeantReader::pVertexX(Int_t i)
325 {
326  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
327  {
328  return trackTable[hitTable[i].track_p-1].p[0];
329  }
330  else
331  {
332  LOG_WARN << "StFtpcGeantReader: pVertexX index out of range, using 0" << endm;
333  return trackTable[0].p[0];
334  }
335 }
336 
337 Float_t StFtpcGeantReader::pVertexY(Int_t i)
338 {
339  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
340  {
341  return trackTable[hitTable[i].track_p-1].p[1];
342  }
343  else
344  {
345  LOG_WARN << "StFtpcGeantReader: pVertexY index out of range, using 0" << endm;
346  return trackTable[0].p[1];
347  }
348 }
349 
350 Float_t StFtpcGeantReader::pVertexZ(Int_t i)
351 {
352  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
353  {
354  return trackTable[hitTable[i].track_p-1].p[2];
355  }
356  else
357  {
358  LOG_WARN << "StFtpcGeantReader: pVertexZ index out of range, using 0" << endm;
359  return trackTable[0].p[2];
360  }
361 }
362 
363 Float_t StFtpcGeantReader::pTVertex(Int_t i)
364 {
365  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
366  {
367  return trackTable[hitTable[i].track_p-1].pt;
368  }
369  else
370  {
371  LOG_WARN << "StFtpcGeantReader: pTVertex index out of range, using 0" << endm;
372  return trackTable[0].pt;
373  }
374 }
375 
376 Float_t StFtpcGeantReader::pTotalVertex(Int_t i)
377 {
378  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
379  {
380  return trackTable[hitTable[i].track_p-1].ptot;
381  }
382  else
383  {
384  LOG_WARN << "StFtpcGeantReader: pTotalVertex index out of range, using 0" << endm;
385  return trackTable[0].ptot;
386  }
387 }
388 
389 Float_t StFtpcGeantReader::rapidityVertex(Int_t i)
390 {
391  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks)
392  {
393  return trackTable[hitTable[i].track_p-1].rapidity;
394  }
395  else
396  {
397  LOG_WARN << "StFtpcGeantReader: rapidityVertex index out of range, using 0" << endm;
398  return trackTable[0].rapidity;
399  }
400 }
401 
402 Int_t StFtpcGeantReader::productionProcess(Int_t i)
403 {
404  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks
405  && trackTable[hitTable[i].track_p-1].start_vertex_p>0
406  && trackTable[hitTable[i].track_p-1].start_vertex_p<=nVertices)
407  {
408  return vertexTable[trackTable[hitTable[i].track_p-1].start_vertex_p-1].ge_proc;
409  }
410  else
411  {
412  LOG_WARN << "StFtpcGeantReader: productionProcess index out of range, using 0" << endm;
413  return vertexTable[0].ge_proc;
414  }
415 }
416 
417 Float_t StFtpcGeantReader::vertexX(Int_t i)
418 {
419  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks
420  && trackTable[hitTable[i].track_p-1].start_vertex_p>0
421  && trackTable[hitTable[i].track_p-1].start_vertex_p<=nVertices)
422  {
423  return vertexTable[trackTable[hitTable[i].track_p-1].start_vertex_p-1].ge_x[0];
424  }
425  else
426  {
427  LOG_WARN << "StFtpcGeantReader: vertexX index out of range, using 0" << endm;
428  return vertexTable[0].ge_x[0];
429  }
430 }
431 
432 Float_t StFtpcGeantReader::vertexY(Int_t i)
433 {
434  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks
435  && trackTable[hitTable[i].track_p-1].start_vertex_p>0
436  && trackTable[hitTable[i].track_p-1].start_vertex_p<=nVertices)
437  {
438  return vertexTable[trackTable[hitTable[i].track_p-1].start_vertex_p-1].ge_x[1];
439  }
440  else
441  {
442  LOG_WARN << "StFtpcGeantReader: vertexY index out of range, using 0" << endm;
443  return vertexTable[0].ge_x[1];
444  }
445 }
446 
447 Float_t StFtpcGeantReader::vertexZ(Int_t i)
448 {
449  if(i>=0 && i<nHits && hitTable[i].track_p>0 && hitTable[i].track_p<=nTracks
450  && trackTable[hitTable[i].track_p-1].start_vertex_p>0
451  && trackTable[hitTable[i].track_p-1].start_vertex_p<=nVertices)
452  {
453  return vertexTable[trackTable[hitTable[i].track_p-1].start_vertex_p-1].ge_x[2];
454  }
455  else
456  {
457  LOG_WARN << "StFtpcGeantReader: vertexZ index out of range, using 0" << endm;
458  return vertexTable[0].ge_x[2];
459  }
460 }
461 
462