StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
EEmcL3Tracks.cxx
1 // $Id: EEmcL3Tracks.cxx,v 1.10 2003/09/11 19:41:02 zolnie Exp $
2 // $Log: EEmcL3Tracks.cxx,v $
3 // Revision 1.10 2003/09/11 19:41:02 zolnie
4 // updates for gcc3.2
5 //
6 // Revision 1.9 2003/09/05 15:04:21 zolnie
7 // remove Stiostream/iostream from the source code
8 //
9 // Revision 1.8 2003/09/02 17:57:55 perev
10 // gcc 3.2 updates + WarnOff
11 //
12 // Revision 1.7 2003/06/02 17:34:35 zolnie
13 // fixed bug in EEmcHelix
14 //
15 // Revision 1.6 2003/05/31 02:31:30 zolnie
16 // bring the changes back
17 //
18 // Revision 1.4 2003/05/30 21:07:52 zolnie
19 // added track length and number of points
20 //
21 // Revision 1.3 2003/05/27 19:11:44 zolnie
22 // added dE/dx info
23 //
24 // Revision 1.2 2003/05/26 14:44:34 zolnie
25 // rewritten implementation of EEmcL3Tracks using TClonesArray
26 // introduced a common Makefile and mklinkdef.pl
27 //
28 // Revision 1.1 2003/05/20 19:22:59 zolnie
29 // new additions for ..... :)
30 //
31 
32 //#include <Stiostream.h>
33 #include <cmath>
34 #include "EEmcL3Tracks.h"
35 
36 ClassImp(EEmcHelix)
37 
38 EEmcHelix::EEmcHelix(Float_t x , Float_t y , Float_t z,
39  Float_t px, Float_t py, Float_t pz,
40  Int_t q , Float_t B ,
41  Int_t np, Float_t l , Int_t flag)
42 {
43  mOx=x; mOy=y; mOz=z;
44  mPx=px; mPy=py; mPz=pz;
45  mQ = q;
46  mB = B;
47  mPoints = np;
48  mLength = l;
49  mFlag = flag;
50 }
51 
52 
53 EEmcHelix::EEmcHelix(const EEmcHelix &h)
54 {
55  h.getOrigin (mOx,mOy,mOz);
56  h.getMomentum(mPx,mPy,mPz);
57  mQ = h.Q();
58  mB = h.B();
59  mPoints = h.Points();
60  mLength = h.Length();
61  mFlag = h.Flag();
62 };
63 
64 
65 void
66 EEmcHelix :: print(FILE *fd) const
67 {
68  fprintf(fd,"\torigin : %+f %+f %+f\n",mOx,mOy,mOz);
69  fprintf(fd,"\tmomentum: %+f %+f %+f\n",mPx,mPy,mPz);
70  fprintf(fd,"\tcharge : %+1d\tfield : %+f\n",mQ,mB);
71  fprintf(fd,"\tpoints : %2d \tlength: %+f\n",mPoints,mLength);
72  fprintf(fd,"\tflag : %2d (0x%04x)\n",mFlag,mFlag);
73 }
74 
75 
76 
77 ClassImp(EEmcL3Tracks)
78 
79 
80 const Int_t EEmcL3Tracks::mAllocTracks=32;
81 
82 //--------------------------------------------------
83 //
84 //--------------------------------------------------
86  mHelix = new TClonesArray("EEmcHelix",1000);
87  mDedx = new Float_t[mAllocTracks];
88  mTrackSize = mAllocTracks;
89  clear();
90 }
91 
92 //--------------------------------------------------
93 //
94 //--------------------------------------------------
95 EEmcL3Tracks::~EEmcL3Tracks()
96 {
97  if(mHelix) delete mHelix;
98  if(mDedx) delete [] mDedx;
99 }
100 
101 
102 
103 int
104 EEmcL3Tracks::add(EEmcHelix &h, Float_t de)
105 {
106  // add dEdx
107  if(mNTracks >= mTrackSize ) {
108  Int_t newSize = mTrackSize + mAllocTracks;
109  Float_t *newDedx = new Float_t[newSize];
110  memcpy(newDedx,mDedx,mTrackSize*sizeof(Float_t));
111  delete [] mDedx;
112  mDedx = newDedx;
113  mTrackSize = newSize;
114  //cerr << "more " << mTrackSize << endl;
115  }
116 
117  TClonesArray &helices = *mHelix;
118  mDedx[mNTracks] = de;
119  EEmcHelix *helix = new(helices[mNTracks]) EEmcHelix(h);
120  mNTracks++;
121  //if(helix) helix->print();
122  return ( (helix==NULL) ? 1 : 0 );
123 }
124 
125 
126 //--------------------------------------------------
127 //
128 //--------------------------------------------------
129 void
130 EEmcL3Tracks::clear()
131 {
132  mHelix->Clear();
133  mNTracks=0;
134  mVertX = mVertY = mVertZ = MAXFLOAT;
135 }
136 
137 
138 
139 EEmcHelix*
140 EEmcL3Tracks::getHelix (int i)
141 {
142  return (0<=i && i<mNTracks) ? ((EEmcHelix *)(mHelix->At(i))) : NULL;
143 }
144 
145 
146 
147 
148 
149 //--------------------------------------------------
150 //
151 //--------------------------------------------------
152 void EEmcL3Tracks :: print(FILE *fd) const
153 {
154  fprintf(fd,"L3 tracks %d:\n",mNTracks);
155  if(mNTracks<=0) return;
156  fprintf(fd,"\tvertex: (%+8.3f %+8.3f %+8.3f)\n",mVertX,mVertY,mVertZ);
157  for(Int_t i=0;i<mHelix->GetEntries();i++) {
158  fprintf(fd,"\ttrack#%d dE/dx=%g\n",i,mDedx[i]);
159  ((EEmcHelix *)(mHelix->At(i)))->print(fd);
160  }
161 }
162 
163 
164