StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcMtdHit.cc
1 //
2 //
3 
4 #include <assert.h>
5 #include "StMcMtdHit.hh"
6 #include "StMcTrack.hh"
7 #include "StParticleDefinition.hh"
8 #include "tables/St_g2t_mtd_hit_Table.h"
9 
10 
11 ClassImp(StMcMtdHit);
12 //___________________________________________________________________________
13 StMcMtdHit::StMcMtdHit()
14 {
15  mBackleg=0;
16  mModule=0;
17  mCell=0;
18  mPathLength=0;
19  mParentTrackId=0;
20 }
21 //___________________________________________________________________________
22 StMcMtdHit::~StMcMtdHit() {/* noop */ }
23 
24 // //___________________________________________________________________________
25 // int StMcMtdHit::operator==(const StMcMtdHit& h) const
26 // {
27 // //we have some options here -- include 2nd line or no??
28 // // Hits are from the same particle and the same tower(cell)
29 // return h.mBackleg == mBackleg && h.mModule == mModule && h.mCell == mCell
30 // && h.mPathLength == mPathLength && h.mTime == mTime
31 // && h.mTof == mTof && h.mCharge == mCharge
32 // && h.mPosition == mPosition
33 // && ( (h.mParentTrack == mParentTrack) || (h.mParentTrackId == mParentTrackId) );
34 //
35 // }
36 
37 //___________________________________________________________________________
38 int StMcMtdHit::operator!=(const StMcMtdHit& h) const
39 {
40  return !(*this == h); // use operator==()
41 }
42 
43 // //___________________________________________________________________________
44 // void StMcMtdHit::operator+=(const StMcMtdHit& h)
45 // {
46 // //we have some options here
47 // //if(*this == h) mdE += h.dE(); // use operator==()
48 // //if(*this.sameCell(h)) mdE += h.dE();
49 // mdE += h.dE();
50 // mCharge += h.charge();
51 // }
52 
53 //___________________________________________________________________________
54 bool StMcMtdHit::sameCell(const StMcMtdHit& h) const
55 {
56  // Hits are from the same cell(tower)
57  // For transition from MC hits to raw hits
58  return h.mBackleg == mBackleg && h.mModule == mModule && h.mCell == mCell;
59 }
60 
61 
62 ostream& operator<<(ostream& os, const StMcMtdHit & h)
63 {
64  os << "MtdHit\t"
65  << " backleg: " << h.backleg()
66  << " mod: " << h.module()
67  << " cell: " << h.cell()
68  << " dE: " << h.dE()
69  << " pathL: " << h.pathLength()
70  << " tof (simu): " << h.tof()
71  << " position: " << h.position();
72  if(h.parentTrack()) {
73  StMcTrack* t=h.parentTrack();
74  if(t->particleDefinition()){
75  os << " | g2t key : " << t->key()
76  << " Name: "<<(t->particleDefinition()->name()).c_str();
77  }
78  }
79  else os <<" Parent track undefined ";
80  return os;
81 }
82 //___________________________________________________________________________
83 StMcMtdHit::StMcMtdHit(g2t_mtd_hit_st* pt):
84  StMcHit(StThreeVectorF(pt->x[0], pt->x[1], pt->x[2]),
85  StThreeVectorF(pt->p[0], pt->p[1], pt->p[2]),
86  pt->de, pt->ds, pt->tof, pt->id, pt->volume_id, 0)
87 {
88  const static float kMtdPadWidth = 3.8 + 0.6;
89  const static int kNCell = 12;
90 
91  int volume_id = pt->volume_id;
92  int ires = volume_id/100;
93  mPathLength = pt->s_track;
94  mModule = ires%10;
95  mBackleg = ires/10;
96  mCell = Int_t((pt->x[1] + kMtdPadWidth * kNCell/2) / kMtdPadWidth) + 1;
97  mParentTrackId = 0;
98 }
99 
Definition: tof.h:15
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144