AMSDST
myTrTrack.cxx
Go to the documentation of this file.
1 // Authors: M.Duranti - INFN di Perugia
2 #include "myTrTrack.h"
3 #include "debug.h"
4 #include "TClass.h"
5 
6 using namespace std;
7 
8 //--------------------------------------------------------------------
9 
11 #ifdef _WITHGBATCH_
12 ClassImp(myTrTrackFiller);
13 #endif //#ifdef _WITHGBATCH_
14 
15 //--------------------------------------------------------------------
16 
18 #ifdef PDEBUG
19  printf("In myTrTrack::myTrTrack\n");
20 #endif
21  PRINTDEBUG;
22  init();
23  PRINTDEBUG;
24 }
25 
27 #ifdef PDEBUG
28  printf("In myTrTrack::~myTrTrack\n");
29 #endif
30  PRINTDEBUG;
31  Clear();
32 }
33 
34 void myTrTrack::Clear(Option_t* option){
35 #ifdef PDEBUG
36  printf("In myTrTrack::Clear\n");
37 #endif
38  PRINTDEBUG;
39  kDef = -999999;
40  BitPatternJ = 0;
41  BitPatternXYJ = 0;
42  Nhits = -9999;
43  NhitsX = -9999;
44  NhitsY = -9999;
45  NhitsXY = -9999;
46  Rigidity=9999999;
47  ErrRinv=-999999;
48  Chisq=9999999;
49  NormChisqY=9999999;
50  NormChisqX=9999999;
51  Theta=-999999;
52  Phi=-999999;
53  PRINTDEBUG;
54  Q = -999999;
55  InnerQ = -999999;
56  fill_n(LayerJQ, 9, 0);
57  PRINTDEBUG;
58  fill_n(TrackXOnLayer, 9, 0);
59  fill_n(TrackYOnLayer, 9, 0);
60  PRINTDEBUG;
61  return;
62 }
63 
65 #ifdef PDEBUG
66  printf("In myTrTrack::init\n");
67 #endif
68  PRINTDEBUG;
69  Clear();
70  PRINTDEBUG;
71  return;
72 }
73 
74 Double_t myTrTrack::TkBeta(Double_t MASS) {
75 
76  Double_t tkbeta = 0;
77 
78  // printf("Mass is %f\n", MASS);//only for debug
79  tkbeta=MASS*MASS;
80  tkbeta+=Rigidity*Rigidity;
81  tkbeta=Rigidity/tkbeta;
82  tkbeta*=Rigidity;//b^2 = p^2/(p^2+m^2)
83  tkbeta=sqrt(tkbeta);
84 
85  return tkbeta;
86 }
87 
88 Short_t myTrTrack::span() {
89 
90  Short_t span=-999;
91 
92  PRINTDEBUG;
93 
94  bool HasL1 = ((BitPatternJ)&(1<<0))>>0;
95  bool HasL2 = ((BitPatternJ)&(1<<1))>>1;
96  bool HasL9 = ((BitPatternJ)&(1<<8))>>8;
97  // printf("%d %d ", HasL1, HasL2);//only for debug
98  // for (int ii=2; ii<8; ii++) printf("%d ", ((BitPatternJ)&(1<<ii))>>ii);//only for debug
99  // printf("%d\n", HasL9);//only for debug
100 
101  if (HasL1&HasL9) {
102  // printf("HasL1&HasL9\n");//only for debug
103  if (kDef>0) {
104  span=0;
105  }
106  }
107  else if (HasL1) {
108  // printf("HasL1\n");//only for debug
109  if (kDef>0) {
110  span=1;
111  }
112  }
113  else if (HasL9) {
114  // printf("HasL9\n");//only for debug
115  if (kDef>0) {
116  if (HasL2) {
117  // printf("HasL2\n");//only for debug
118  span=2;
119  }
120  else span=3;
121  }
122  }
123  else {
124  // printf("Inner\n");//only for debug
125  if (kDef>0) {
126  if (HasL2) {
127  // printf("HasL2\n");//only for debug
128  span=4;
129  }
130  else span=5;
131  }
132  }
133 
134  PRINTDEBUG;
135 
136  return span;
137 }
138 
139 //-------------------------------------------------------------------------
140 
141 #ifdef _WITHGBATCH_
142 
143 myTrTrackFiller::myTrTrackFiller():myTrTrack(){
144 #ifdef PDEBUG
145  printf("In myTrTrackFiller::myTrTrackFiller\n");
146 #endif
147  init();
148  PRINTDEBUG;
149 }
150 
151 myTrTrackFiller::~myTrTrackFiller(){
152 #ifdef PDEBUG
153  printf("In myTrTrackFiller::~myTrTrackFiller\n");
154 #endif
155  PRINTDEBUG;
156  Clear();
157 }
158 
159 void myTrTrackFiller::Clear(Option_t* option){
160 #ifdef PDEBUG
161  printf("In myTrTrackFiller::Clear\n");
162 #endif
163  PRINTDEBUG;
164  track=0;
165  PRINTDEBUG;
166  return;
167 }
168 
169 void myTrTrackFiller::init(){
170 #ifdef PDEBUG
171  printf("In myTrTrackFiller::init\n");
172 #endif
173  PRINTDEBUG;
174  Clear();
175  PRINTDEBUG;
176  return;
177 }
178 
179 void myTrTrackFiller::Fill(TrTrackR* _track){
180 #ifdef PDEBUG
181  printf("In myTrTrackFiller::Fill\n");
182 #endif
183  PRINTDEBUG;
184 
185  track=_track;
186 
187  //--------------------TRACKER-----------------------------------
188  if (track) {
189 
190  BitPatternJ=track->GetBitPatternJ();
191  BitPatternXYJ=track->GetBitPatternXYJ();
192 
193  NhitsX = track->GetNhitsX();
194  NhitsY = track->GetNhitsY();
195  NhitsXY = track->GetNhitsXY();
196  Nhits = track->GetNhits();
197 
198  PRINTDEBUG;
199  kDef=0;
200 
201  Rigidity = track->GetRigidity(kDef);
202  ErrRinv = track->GetErrRinv(kDef);
203  Chisq = track->GetChisq(kDef);
204  NormChisqX = track->GetNormChisqX(kDef);
205  NormChisqY = track->GetNormChisqY(kDef);
206  Theta = track->GetTheta(kDef);
207  // theta = PI - track->GetTheta(kDef);
208  // if (theta>PI) {
209  // printf("Folding Theta (%f)\n", theta); //only for debug
210  // theta=PI + track->GetTheta(kDef);
211  // }
212  // else if (theta<(PI/2.0)) {
213  // printf("Theta not valid (%f)\n", theta); //only for debug
214  // }
215  Phi = track->GetPhi(kDef);
216 
217  for (int jlayer=1; jlayer<=9; jlayer++) {
218  static AMSPoint global;
219  static AMSDir dir;
220 #ifdef _B524_
221  int jlayer=layer-1;
222  if (layer==1) jlayer=8;
223  else if (layer==9) jlayer=9;
224  track->InterpolateLayer(layer-1, global, dir, kDef);
225 #else
226  track->InterpolateLayerJ(jlayer, global, dir, kDef);
227 #endif
228  TrackXOnLayer[jlayer-1]=global.x();
229  TrackYOnLayer[jlayer-1]=global.y();
230  }
231 
232 
233 
234  Q = track->GetQ();
235  InnerQ = track->GetInnerQ();
236  for (int ii=0; ii<9; ii++) {
237  LayerJQ[ii] = track->GetLayerJQ(ii+1);
238  }
239 
240  }
241 
242  PRINTDEBUG;
243 
244  return;
245 }
246 
247 #endif //#ifdef _WITHGBATCH_