/[PAMELA software]/DarthVader/TrackerLevel2/inc/TrkLevel2.h
ViewVC logotype

Contents of /DarthVader/TrackerLevel2/inc/TrkLevel2.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.45 - (show annotations) (download)
Thu Feb 27 11:24:42 2014 UTC (10 years, 9 months ago) by pam-fi
Branch: MAIN
Changes since 1.44: +2 -0 lines
File MIME type: text/plain
Added new tracking algorythm

1 /**
2 * \file TrkLevel2.h
3 * \author Elena Vannuccini
4 */
5 #ifndef trklevel2_h
6 #define trklevel2_h
7
8 #include <TObject.h>
9 #include <TObjArray.h>
10 #include <TClonesArray.h>
11 #include <TRefArray.h>
12 #include <TRef.h>
13
14 #include <TrkParams.h>
15 #include <TrkLevel1.h>
16
17 // z-coordinate of track state-vector reference-plane
18 #define ZINI 23.5 ///< z-coordinate of track state-vector reference-plane.
19 // (mechanical) z-coordinate of the tracker planes
20 #define ZTRK6 -22.22
21 #define ZTRK5 -13.31
22 #define ZTRK4 -4.41
23 #define ZTRK3 4.49
24 #define ZTRK2 13.39
25 #define ZTRK1 22.29
26 // magnet cavity dimensions
27 #define ZMAGNHIGH 21.83
28 #define ZMAGNLOW -21.83
29 #define XMAGNHIGH 8.07
30 #define XMAGNLOW -8.07
31 #define YMAGNHIGH 6.57
32 #define YMAGNLOW -6.57
33 // tof planes
34 #define ZS11 53.74
35 #define ZS12 53.04
36 #define ZS21 23.94
37 #define ZS22 23.44
38 #define ZS31 -23.49
39 #define ZS32 -24.34
40
41 // (mechanical) x/y-coordinates of magnet cavity
42 /* #define XTRKL -8.1 */
43 /* #define XTRKR 8.1 */
44 /* #define YTRKL -6.6 */
45 /* #define YTRKR 6.6 */
46
47 /**
48 * \brief Class to describe, by points, a particle trajectory in the apparatus.
49 *
50 * The idea is to create it by integrating the equations of motion, given the
51 * track state vector and the z coordinates where to evaluate track position.
52 */
53 // ==================================================================
54 class Trajectory : public TObject{
55 private:
56
57 public:
58
59 int npoint; ///< number of evaluated points along the trajectory
60 float* x; //[npoint]
61 float* y; //[npoint]
62 float* z; //[npoint]
63 float* thx; //[npoint]
64 float* thy; //[npoint]
65 float* tl; //[npoint]
66
67 Trajectory();
68 Trajectory(int n);
69 Trajectory(int n, float* pz);
70 ~Trajectory(){Delete();}
71 void Dump();
72 void Delete();
73
74 int DoTrack(float* al, float zini);
75 int DoTrack(float* al){ return DoTrack(al,23.5); }
76
77 int DoTrack2(float* al, float zini);
78 int DoTrack2(float* al){ return DoTrack2(al,23.5); }
79
80 float GetLength(){float l=0; for(int i=0; i<npoint;i++)l=l+tl[i]; return l;}
81 float GetLength(int,int);
82
83 ClassDef(Trajectory,3);
84
85 };
86 /**
87 * \brief Class to describe fitted tracks.
88 *
89 * A track is defined by the measured coordinates associated to it, the
90 * track status vector, plus other quantities.
91 * A track may have an "image", due to the ambiguity in the y view.
92 *
93 * Cluster flags: xgood[6], ygood[6]
94 *
95 * xgood/ygood = +/- 0lsccccccc
96 * ccccccc ID (1-7483647) of the included cluster
97 * s sensor number (1,2 - increasing y)
98 * l ladder number (1,2,3 - increasing x)
99 * +/- does-not/does include bad strips
100 *
101 */
102 // ==================================================================
103 class TrkTrack : public TObject {
104
105 private:
106
107 public:
108
109 int seqno; ///<stored track sequential number
110 int image; ///<sequential number of track-image
111
112 /*! @brief Track state vector.
113 *
114 * This is the track state vector on reference plane defined by #ZINI.
115 *
116 * al[0]: X coordinate [cm]
117 * al[1]: Y coordinate [cm]
118 * al[2]: sin theta (altitude; theta = 0 is normal incidence)
119 * al[3]: phi (azimuth; phi = 0 is negative X axis)
120 * al[4]: deflection (with sign) [1/GV]
121 *
122 */
123 float al[5];
124 float coval[5][5]; ///<covariance matrix
125 int xgood[6]; ///<cluster id for x-view (0 = view not included in the fit)
126 int ygood[6]; ///<cluster id for y-view (0 = view not included in the fit)
127 float xm[6]; ///<measured x coordinates
128 float ym[6]; ///<measured y coordinates
129 float zm[6]; ///<measured z coordinates
130 float resx[6]; ///<spatial resolution on X view
131 float resy[6]; ///<spatial resolution on y view
132 float tailx[6]; ///<spatial resolution tail on X view
133 float taily[6]; ///<spatial resolution tail on y view
134 float chi2; ///<chi2
135 int nstep; ///<n.step
136 float xv[6]; ///<calculated x coordinates
137 float yv[6]; ///<calculated y coordinates
138 float zv[6]; ///<calculated z coordinates
139 float axv[6]; ///<calculated angles (deg) on x view
140 float ayv[6]; ///<calculated angles (deg) on y view
141 float dedx_x[6]; ///<dE/dx in MIP (<0 if saturated)
142 float dedx_y[6]; ///<dE/dx in MIP (<0 if saturated)
143 int multmaxx[6]; ///<cluster multiplicity and strip of maximum on x view
144 int multmaxy[6]; ///<cluster multiplicity and strip of maximum on y view
145 float seedx[6]; ///< seed of the cluster x
146 float seedy[6]; ///< seed of the cluster y
147 float xpu[6]; ///< x coordinate in pitch units
148 float ypu[6]; ///< y coordinate in pitch units
149
150 float xGF[14]; ///<calculated x coordinates on GF reference planes
151 float yGF[14]; ///<calculated y coordinates on GF reference planes
152
153 TrkTrack();
154 TrkTrack(const TrkTrack&);
155
156 ~TrkTrack(){ Delete(); }
157
158 void Dump();
159 void Clear();
160 void Clear(Option_t *option){Clear();}
161 void Delete();
162 void Copy(TrkTrack&);
163 // void Set();
164
165 Int_t GetSeqNo(){return seqno;} ///< Returns the track sequential number
166 Int_t GetImageSeqNo(){return image;} ///< Returns the track image sequential number
167 Bool_t HasImage(){return !(image==-1);} ///< Returns true if the track has an image
168 int DoTrack(Trajectory* t); ///< Evaluates the trajectory in the apparatus.
169 int DoTrack2(Trajectory* t); ///< Evaluates the trajectory in the apparatus.
170 float BdL(){return 0;} ///< Evaluates the integral of B*dL along the track.
171 Int_t GetNX(){Int_t n=0; for(Int_t i=0; i<6; i++)n+=(Int_t)XGood(i); return n;}
172 Int_t GetNY(){Int_t n=0; for(Int_t i=0; i<6; i++)n+=(Int_t)YGood(i); return n;}
173 Int_t GetNXY(){Int_t n=0; for(Int_t i=0; i<6; i++)n+=(Int_t)YGood(i)*XGood(i); return n;}
174 Int_t GetNtot(){return GetNX()+GetNY();}
175 Float_t GetRigidity();
176 Float_t GetDeflection();
177 Bool_t IsSaturated(int,int);
178 Bool_t IsSaturated(int);
179 Bool_t IsSaturated();
180 Bool_t IsBad(int,int);
181 Float_t GetDEDX();
182 Float_t GetDEDX(int ip);
183 Float_t GetDEDX(int ip,int iv);
184 Int_t GetLeverArmXY();
185 Int_t GetLeverArmX();
186 Int_t GetLeverArmY();
187 Float_t GetChi2X();
188 Float_t GetChi2Y();
189 Float_t GetLnLX();
190 Float_t GetLnLY();
191
192 Float_t GetEffectiveAngle(int ip, int iv);
193
194 void SetMeasure(double *xmeas, double *ymeas, double *zmeas);
195 void SetResolution(double *rx, double *ry);
196 void SetTail(double *tx, double *ty, double factor);
197 void SetStudentParam(int flag);
198 void SetGood(int *xg, int *yg);
199 void LoadField(TString s);
200 void Fit(double pfixed, int& fail, int iprint, int froml1);
201 void Fit(double pfixed, int& fail, int iprint){ Fit(pfixed,fail,iprint,0); }
202 void FitReset();
203 void SetTrackingMode(int trackmode);
204 void SetPrecisionFactor(double fact);
205 void SetStepMin(int istepmin);
206 void SetDeltaB(int id, double db);
207
208 Bool_t IsInsideCavity(float);
209 Bool_t IsInsideCavity(){ return IsInsideCavity(0.); }
210 Bool_t IsInsideAcceptance(float);
211 Bool_t IsInsideAcceptance(){ return IsInsideAcceptance(0.); }
212 Bool_t IsInsideGFSurface(const char*,float);
213 Bool_t IsInsideGFSurface(const char* surf){ return IsInsideGFSurface(surf,0.); }
214
215 Bool_t EvaluateClusterPositions();
216
217 void FillMiniStruct(cMini2track&);
218 void SetFromMiniStruct(cMini2track*);
219 void FillMiniStruct(){ extern cMini2track track_; FillMiniStruct(track_); };
220 void SetFromMiniStruct(){extern cMini2track track_; SetFromMiniStruct(&track_);};
221
222 Int_t GetClusterX_ID(int ip);
223 Int_t GetClusterY_ID(int ip);
224 Int_t GetLadder(int ip);
225 Int_t GetSensor(int ip);
226 Bool_t XGood(int ip){ return GetClusterX_ID(ip)!=-1; }
227 Bool_t YGood(int ip){ return GetClusterY_ID(ip)!=-1; }
228 void ResetXGood(int ip){ xgood[ip]=0; }
229 void ResetYGood(int ip){ ygood[ip]=0; }
230 /* void SetXGood(int ip, int clid, int is); */
231 /* void SetYGood(int ip, int clid, int is); */
232 void SetXGood(int ip, int clid, int il, int is, bool bad);
233 void SetYGood(int ip, int clid, int il, int is, bool bad);
234 void SetXGood(int ip, int clid, int il, int is){ SetXGood(ip,clid,il,is,false); }
235 void SetYGood(int ip, int clid, int il, int is){ SetYGood(ip,clid,il,is,false); }
236
237
238 Bool_t BadClusterX(int ip){ return IsBad(ip,0); }
239 Bool_t BadClusterY(int ip){ return IsBad(ip,1); }
240
241 Bool_t SaturatedClusterX(int ip){ return IsSaturated(ip,0); }
242 Bool_t SaturatedClusterY(int ip){ return IsSaturated(ip,1); }
243
244 Int_t GetClusterX_Multiplicity(int ip){ return (Int_t)(multmaxx[ip]/10000); }
245 Int_t GetClusterY_Multiplicity(int ip){ return (Int_t)(multmaxy[ip]/10000); }
246 Int_t GetClusterX_MaxStrip(int ip){ return (Int_t)(multmaxx[ip]%10000); }
247 Int_t GetClusterY_MaxStrip(int ip){ return (Int_t)(multmaxy[ip]%10000); }
248 Float_t GetClusterX_Seed(int ip){ return seedx[ip]; }
249 Float_t GetClusterY_Seed(int ip){ return seedy[ip]; }
250 /* Float_t GetClusterX_oordinatePU(int ip); */
251 /* Float_t GetClusterY_CoordinatePU(int ip); */
252
253 Float_t GetYav();
254 Float_t GetXav();
255 Float_t GetZav();
256
257 Int_t GetNColumns();
258
259 Float_t GetDEDX_max(int ip, int iv);
260 Float_t GetDEDX_max(int iv){ return GetDEDX_max(-1,iv); }
261 Float_t GetDEDX_max(){ return GetDEDX_max(-1,-1); }
262 Float_t GetDEDX_min(int ip, int iv);
263 Float_t GetDEDX_min(int iv){ return GetDEDX_min(-1,iv); }
264 Float_t GetDEDX_min(){ return GetDEDX_min(-1,-1); }
265
266 Float_t GetResidual_max(int ip, int iv);
267 Float_t GetResidual_max(int iv){ return GetResidual_max(-1,iv); }
268 Float_t GetResidual_max(){ return GetResidual_max(-1,-1); }
269 Float_t GetResidual_av(int ip, int iv);
270 Float_t GetResidual_av(int iv){ return GetResidual_av(-1,iv); }
271 Float_t GetResidual_av(){ return GetResidual_av(-1,-1); }
272
273 Int_t GetClusterX_Multiplicity_max();
274 Int_t GetClusterX_Multiplicity_min();
275 Int_t GetClusterY_Multiplicity_max();
276 Int_t GetClusterY_Multiplicity_min();
277
278 Float_t GetClusterX_Seed_min();
279 Float_t GetClusterY_Seed_min();
280
281 TrkTrack* GetTrkTrack(){return this;}
282
283 friend class TrkLevel2;
284
285 ClassDef(TrkTrack,5);
286
287 };
288 /**
289 * \brief Class to describe single clusters ("singlets").
290 *
291 * Single clusters are clusters not associated to any track.
292 */
293 class TrkSinglet : public TObject {
294
295 private:
296
297
298 public:
299
300 int plane; ///<plane
301 float coord[2]; ///<coordinate (on sensor 1 and 2)
302 float sgnl; ///<cluster signal in MIP (<0 if saturated)
303 int multmax; ///<cluster multiplicity and strip of maximum
304
305 TrkSinglet();
306 TrkSinglet(const TrkSinglet&);
307 ~TrkSinglet(){Delete();}
308
309 void Dump();
310 void Clear();
311 void Clear(Option_t *option){Clear();}
312 void Delete(){Clear();};
313 Float_t GetSignal(){return fabs(sgnl);}
314 Bool_t IsSaturated(){return (sgnl<0); }
315
316 Bool_t IsBad() { return multmax<=0; }
317 Int_t GetCluster_Multiplicity(){ return (Int_t)(abs(multmax)/10000); }
318 Int_t GetCluster_MaxStrip() { return (Int_t)(abs(multmax)%10000); }
319
320
321 friend class TrkLevel2;
322
323 ClassDef(TrkSinglet,4);
324
325 };
326
327 /**
328 * \brief Class to describe tracker LEVEL2 data.
329 *
330 * A tracker events is defined by some general variables, plus the collection of all the fitted tracks and all
331 * single clusters on X and Y views.
332 * Tracks and single clusters ("singlets") are described by the classes TrkTrack and TrkSinglet respectivelly.
333 *
334 * Each track may have an "image", due to the ambiguity on the Y view, which is stored also.
335 * Thus, the number of stored tracks ( ntrk() ) differs from the number of "physical" tracks ( GetNTracks() ).
336 * Proper methods allow to sort tracks and select the physical ones ( GetTracks() ).
337 *
338 * The event status indicates the processing status of data from each DSP, according to the following
339 * notation:
340 *
341 * LSB --> 0 missing packet
342 * 1 CRC error
343 * 2 on-line software alarm (latch-up, timeout ecc...)
344 * 3 jump in the trigger counter
345 * 4 decode error
346 * 5 n.clusters > maximum number (level1 processing)
347 * 6
348 * 7
349 * 8 n.clusters > maximum value (level2 processing)
350 * 9 n.couples per plane > maximum values (vector dimention)
351 * 10 n.doublets > maximum values
352 * 11 n.triplets > maximum values
353 * 12 n.yz-clouds > maximum values
354 * 13 n.xz-clouds > maximum values
355 * 14 n.candidate-tracks > maximum values
356 * 15 n.couples per plane > maximum values (for Hough transform)
357 * MSB --> 16
358 *
359 *
360 * For all data processed before June 2007 the event status was coded according to
361 * a different rule:
362 *
363 * Status of level1 processing
364 * 0 -- OK
365 * 1 -- missing packet
366 * 2 -- 1 CRC error
367 * 3 -- 2 on-line software alarm (latch-up flags asserted or n.transmitted-words = 0)
368 * 4 -- 3 jump in the trigger counter
369 * 10 -- 4 decode error
370 * 11 -- 5 n.clusters > maximum number (for level1 processing)
371 * Status of level2 processing
372 * 21 -- 0 n.clusters > maximum value (for level2 processing)
373 * 22 -- 1 n.couples per plane > maximum values (vector dimention)
374 * 23 -- 2 n.doublets > maximum values
375 * 24 -- 3 n.triplets > maximum values
376 * 25 -- 4 n.yz-clouds > maximum values
377 * 26 -- 5 n.xz-clouds > maximum values
378 * 27 -- 6 n.candidate-tracks > maximum values
379 * 28 -- 7 n.couples per plane > maximum values (for Hough transform)
380 *
381 *
382 */
383 class TrkLevel2 : public TObject {
384
385 private:
386
387 public:
388
389 Int_t good[12]; ///< event status
390 UInt_t VKmask[12]; ///< Viking-chip mask
391 UInt_t VKflag[12]; ///< Viking-chip flag
392
393 TClonesArray *Track; ///< fitted tracks
394 TClonesArray *SingletX; ///< x singlets
395 TClonesArray *SingletY; ///< y singlets
396
397 TrkLevel2();
398 // TrkLevel2(cTrkLevel2 *);
399 ~TrkLevel2(){Delete();}
400
401 void Clear();
402 void Clear(Option_t *option){Clear();}
403 void Delete();
404 void Set();
405 int UnpackError(){ for(int i=0; i<12; i++)if(!StatusCheck(i,0x12))return 1; return 0;}
406
407 int ntrk() {return Track->GetEntries();} ///< number of stored track
408 int nclsx(){return SingletX->GetEntries();} ///< number of x singlets
409 int nclsy(){return SingletY->GetEntries();} ///< number of y singlets
410
411 void Dump();
412 void SetFromLevel2Struct(cTrkLevel2 *, TrkLevel1 *);
413 void SetFromLevel2Struct(cTrkLevel2 *s2){ SetFromLevel2Struct(s2, NULL); }
414 void SetFromLevel2Struct(TrkLevel1 *l1) { SetFromLevel2Struct(&level2event_, l1); }
415 void SetFromLevel2Struct() { SetFromLevel2Struct(&level2event_); }
416 void GetLevel2Struct(cTrkLevel2 *) const;
417 void LoadField(TString);
418 float GetBX(float* v){return TrkParams::GetBX(v);} ///< Bx (kGauss)
419 float GetBY(float* v){return TrkParams::GetBY(v);} ///< By (kGauss)
420 float GetBZ(float* v){return TrkParams::GetBZ(v);} ///< Bz (kGauss)
421 Float_t GetZTrk(Int_t);
422 Float_t GetXTrkLeft(){return XMAGNLOW;}
423 Float_t GetXTrkRight(){return XMAGNHIGH;}
424 Float_t GetYTrkLeft(){return YMAGNLOW;}
425 Float_t GetYTrkRight(){return YMAGNHIGH;}
426
427 Bool_t IsMaskedVK(int,int);
428 Bool_t GetVKMask(int,int);
429 Bool_t GetVKFlag(int,int);
430
431 TrkSinglet *GetSingletX(int);
432 TrkSinglet *GetSingletY(int);
433
434 TrkTrack *GetStoredTrack(int i);
435 Int_t GetSeqNo(Int_t i) {return (((TrkTrack *)Track->At(i))->seqno);} ///< Returns track sequential number
436
437 TRefArray *GetTracks_NFitSorted();
438 TRefArray *GetTracks(){return this->GetTracks_NFitSorted();}
439
440 Int_t GetNTracks();
441 TrkTrack* GetTrack(int i);
442 TrkTrack* GetTrackImage(int i);
443
444 TrkLevel2* GetTrkLevel2(){return this;}
445 TClonesArray* GetTrackArray(){return Track;}///< returns pointer to the track array
446
447 void StatusDump(int view);
448 Bool_t StatusCheck(int view, int flagmask);
449
450 ClassDef(TrkLevel2,3);
451
452 };
453
454 #endif

  ViewVC Help
Powered by ViewVC 1.1.23