BmnRoot
Loading...
Searching...
No Matches
L1Algo.h
Go to the documentation of this file.
1
2#ifndef L1Algo_h
3#define L1Algo_h 1
4
5// #define TBB // TODO: Doesn't work now. Renew
6
8// #define PULLS // triplets pulls
9// #define TRIP_PERFORMANCE // triplets efficiencies
10// #define DOUB_PERFORMANCE // doublets efficiencies
11// #define DRAW // event display
12// #define XXX // time debug
13// #define COUNTERS diff counters (hits, doublets, ... )
14
15// #define TRACKS_FROM_TRIPLETS
16// #define DO_NOT_SELECT_TRIPLETS
17// #define TRACKS_FROM_TRIPLETS_ITERATION kAllPrimIter
18
19#define LAST_ITERATION kAllSecIter
20#define FIND_GAPED_TRACKS // use triplets with gaps
21#define USE_RL_TABLE
22#ifndef TRACKS_FROM_TRIPLETS
23#define EXTEND_TRACKS
24#endif
25#define MERGE_CLONES
26#define AZ // 260223 - AZ modifications
27
28
29#include "L1Field.h"
30#include "L1Station.h"
31#include "L1StsHit.h"
32#include "L1Triplet.h"
33#include "L1Branch.h"
34#include "L1Track.h"
35#include "L1TrackPar.h"
36
37#include "L1Portion.h"
38#include "L1HitPoint.h"
39#include "L1Strip.h"
40#include "L1Grid.h"
41
42#include <iostream>
43#include <vector>
44#include <map>
45
46using std::vector;
47using std::map;
48
49#ifdef PULLS
50#define TRIP_PERFORMANCE
51class L1AlgoPulls;
52#endif
53#ifdef TRIP_PERFORMANCE
54template<int NHits> class L1AlgoEfficiencyPerformance;
55#endif
56#ifdef DOUB_PERFORMANCE
57template<int NHits> class L1AlgoEfficiencyPerformance;
58#endif
59
60class L1Algo{
61 public:
63 NStations(0), // number of all detector stations
64 NMvdStations(0), // number of mvd stations
65 fRadThick(),
66 vStsStrips(), // strips positions created from hits. Front strips
67 vStsStripsB(), // back strips
68 vStsZPos(), // all possible z-positions of hits
69 vStsHits(), // hits as a combination of front-, backstrips and z-position
70 vSFlag(), // information of hits station & using hits in tracks(),
71 vSFlagB(),
72 isec(-1), // iteration
75 RealIHit(0), // index in vStsHits indexed by index in vStsHitsUnusde
76 vTracks(), // reconstructed tracks
77 vRecoHits(), // packed hits of reconstructed tracks
78 CATime(0), // time of trackfinding
79 FIRSTCASTATION(0),
80
81 TRACK_CHI2_CUT(10.),
82 TRIPLET_CHI2_CUT(5.),
83 DOUBLET_CHI2_CUT(5.),
84
85 MaxDZ(0),
86 Pick_gather(0),
87 PickNeighbour(0), // (PickNeighbour < dp/dp_error) => triplets are neighbours
88 MaxInvMom(0), // max considered q/p for tracks
89 MaxSlope(0),
90 targX(0), targY(0), targZ(0), // target coor
91 targB(), // field in the target point
92 TargetXYInfo(), // target constraint [cm]
93 vtxFieldRegion(),// really doesn't used
94 vtxFieldValue(), // field at teh vertex position.
95 vTriplets(), // container for triplets got in finding
96 fTrackingLevel(0), fGhostSuppression(0), // really doesn't used
97 fMomentumCutOff(0)// really doesn't used
98 {}
99
100 void Init( const fscal geo[] );
101#ifdef TBB2
102 void SetData( const vector< L1StsHit > & StsHits_,
103 const vector< L1Strip > & StsStrips_,
104 const vector< L1Strip > & StsStripsB_,
105 const vector< fscal > & StsZPos_,
106 const vector< unsigned char > & SFlag_,
107 const vector< unsigned char > & SFlagB_,
108 const THitI* StsHitsStartIndex_,
109 const THitI* StsHitsStopIndex_ );
110 void PrintHits();
111#endif
113 void CATrackFinder();
114
116 void KFTrackFitter_simple(); // version, which use procedured used during the reconstruction
117 void L1KFTrackFitter( bool extrapolateToTheEndOfSTS = false ); // version from SIMD-KF benchmark
118
120 // filled in CbmL1::ReadEvent();
121
122 enum{ MaxNStations = 12 };
123 int NStations, // number of all detector stations
124 NMvdStations; // number of mvd stations
125 L1Station vStations[MaxNStations] _fvecalignment; // station info
126
127 vector<L1Material> fRadThick; // material for each station
128
129 vector< L1Strip > vStsStrips, // strips positions created from hits. Front strips
130 vStsStripsB; // back strips
131 vector< fscal > vStsZPos; // all possible z-positions of hits
132 vector< L1StsHit > vStsHits; // hits as a combination of front-, backstrips and z-position
133 L1Grid vGrid[MaxNStations]; // hits as a combination of front-, backstrips and z-position
134 vector< unsigned char > vSFlag, // information of hits station & using hits in tracks;
136 THitI StsHitsStartIndex[MaxNStations+1], StsHitsStopIndex[MaxNStations+1]; // station-bounders in vStsHits array
137
139
140 int isec; // iteration
141 vector< L1StsHit > *vStsHitsUnused;
142 std::vector< L1HitPoint > *vStsHitPointsUnused;
143 THitI *RealIHit; // index in vStsHits indexed by index in vStsHitsUnused
145#ifdef AZ
146 vector<int> vStsHits2Unus; //AZ-230323
147 vector<L1HitPoint> vAllHitPoints; //AZ-240223
148#endif
149
151 vector< L1Track > vTracks; // reconstructed tracks
152 vector< THitI > vRecoHits; // packed hits of reconstructed tracks
153
154 double CATime; // time of trackfinding
155
156 friend class CbmL1;
157
158 L1FieldValue GetvtxFieldValue() {return vtxFieldValue;}
159
160 private:
161
163
164 const L1FieldValue& GetVtxFieldValue() const {return vtxFieldValue;}
165 const L1FieldRegion& GetVtxFieldRegion() const {return vtxFieldRegion;}
167
168 void GetHitCoor(const L1StsHit& _h, fscal &_x, fscal &_y, fscal &_z, const L1Station &sta);
169 void StripsToCoor(const fscal &u, const fscal &v, fscal &x, fscal &y, const L1Station &sta) const; // convert strip positions to coordinates
170 void StripsToCoor(const fvec &u, const fvec &v, fvec &x, fvec &y, const L1Station &sta) const;
171 L1HitPoint CreateHitPoint(const L1StsHit &hit, char ista); // full the hit point by hit information.
172
173
175
176 void CAFindTrack(int ista,
177 L1Branch& best_tr, unsigned char &best_L, fscal &best_chi2,
178 const L1Triplet* curr_trip,
179 L1Branch &curr_tr, unsigned char &curr_L, fscal &curr_chi2,
180 int &NCalls );
181
182 void CleanTriplets(bool isClean = 0
183#ifdef COUNTERS
184 ,unsigned int* nlevels = 0
185#endif
186 ); // isClean = true - find neighbours only
187
194 void BranchFitterFast(const L1Branch &t, L1TrackPar& T, const bool dir, const fvec qp0 = 0., const bool initParams = true);
195
197 void BranchFitter(const L1Branch &t, L1TrackPar& T, const bool dir, const fvec qp0 = 0., const bool initParams = true);
198
204 void FindMoreHits(L1Branch &t, L1TrackPar& T, const bool dir, const fvec qp0 = 0.0);
205
208 fscal BranchExtender(L1Branch &t);
209
211 void InvertCholetsky(fvec a[15]);
212 void MultiplySS(fvec const C[15], fvec const V[15], fvec K[5][5]);
213 void MultiplyMS(fvec const C[5][5], fvec const V[15], fvec K[15]);
214 void MultiplySR(fvec const C[15], fvec const r_in[5], fvec r_out[5]);
215 void FilterTracks(fvec const r[5], fvec const C[15], fvec const m[5], fvec const V[15], fvec R[5], fvec W[15], fvec *chi2);
216 void CAMergeClones();
217
219 unsigned char GetFStation( unsigned char flag ){ return flag/4; }
220 bool GetFUsed ( unsigned char flag ){ return (flag&0x02)!=0; }
221// bool GetFUsedD ( unsigned char flag ){ return (flag&0x01)!=0; }
222
223 void SetFStation ( unsigned char &flag, unsigned int iStation ){ flag = iStation*4 + (flag%4); }
224 void SetFUsed ( unsigned char &flag ){ flag |= 0x02; }
225// void SetFUsedD ( unsigned char &flag ){ flag |= 0x01; }
226 void SetFUnUsed ( unsigned char &flag ){ flag &= 0xFC; }
227// void SetFUnUsedD ( unsigned char &flag ){ flag &= 0xFE; }
228
230 void f10( // input
231 int start_lh, int n1, L1HitPoint *vStsHits_l,
232 // output
233 fvec *u_front, fvec *u_back, fvec *zPos,
234 THitI *hitsl_1,
235 fvec *du_front = 0, fvec *du_back = 0 //AZ
236 );
237
239 void f11( // input
240 int istal, int istam,
241 int n1_V,
242
243 fvec *u_front, fvec *u_back, fvec *zPos,
244 // output
245 L1TrackPar *T_1, L1FieldRegion *fld_1,
246 fvec *du_front = 0, fvec *du_back = 0 //AZ
247 );
248
250 void f20( // input
251 int n1, L1Station &stam,
252 L1HitPoint *vStsHits_l, L1HitPoint *vStsHits_m, int NHits_m,
253 L1TrackPar *T_1,
254 THitI *hitsl_1,
255 // output
256 int &n2,
257 vector<THitI> &i1_2,
258 int &start_mhit,
259#ifdef DOUB_PERFORMANCE
260 vector<THitI> &hitsl_2,
261#endif // DOUB_PERFORMANCE
262 vector<THitI> &hitsm_2,
263 vector<bool> &lmDuplets
264 );
267 void f30( // input
268 L1HitPoint *vStsHits_r, L1Station &stam, L1Station &star,
269
270 int istam, int istar,
271 L1HitPoint *vStsHits_m,
272 L1TrackPar *T_1,L1FieldRegion *fld_1,
273 THitI *hitsl_1,
274
275 int n2,
276 vector<THitI> &hitsm_2,
277 vector<THitI> &i1_2,
278
279 const vector<bool> &mrDuplets,
280 // output
281 int &n3,
283 vector<THitI> &hitsl_3, vector<THitI> &hitsm_3, vector<THitI> &hitsr_3,
285 nsL1::vector<fvec>::TSimd *du_front_3 = 0, nsL1::vector<fvec>::TSimd *du_back_3 = 0 //AZ
286 );
287
289 void f31( // input
290 int n3_V,
291 L1Station &star,
293 // output
295 nsL1::vector<fvec>::TSimd *du_front = 0, nsL1::vector<fvec>::TSimd *du_back = 0 //AZ
296 );
297
299 void f32( // input
300 int n3, int istal,
302 vector<THitI> &hitsl_3, vector<THitI> &hitsm_3, vector<THitI> &hitsr_3,
303 int nIterations = 0
304 );
305
307 void f4( // input
308 int n3, int istal, int istam, int istar,
310 vector<THitI> &hitsl_3, vector<THitI> &hitsm_3, vector<THitI> &hitsr_3,
311 // output
312 unsigned int &nstaltriplets,
313 vector<L1Triplet> &vTriplets_part,
314 unsigned int *TripStartIndexH, unsigned int *TripStopIndexH
315// #ifdef XXX
316// ,unsigned int &stat_n_trip
317// #endif
318 );
319
321 void f5( // input
322 // output
323 unsigned int *TripStartIndexH, unsigned int *TripStopIndexH,
324 int *nlevel
325 );
326
328 void DupletsStaPort( // input
329 int istal, int istam,
330 unsigned int ip,
331 vector< int>& n_g1, unsigned int *portionStopIndex,
332
333 // output
334 L1TrackPar *T_1,
335 L1FieldRegion *fld_1,
336 THitI *hitsl_1,
337
338 vector<bool> &lmDuplets,
339
340 int &n_2,
341 vector<THitI> &i1_2,
342 vector<THitI> &hitsm_2
343 );
344
346 void TripletsStaPort( // input
347 int istal, int istam, int istar,
348 unsigned int& nstaltriplets,
349 L1TrackPar *T_1,
350 L1FieldRegion *fld_1,
351 THitI *hitsl_1,
352
353 int &n_2, unsigned int *portionStopIndex,
354 vector<THitI> &i1_2,
355 vector<THitI> &hitsm_2,
356
357 const vector<bool> &mrDuplets,
358
359 // output
360 vector<L1Triplet> *vTriplets_part,
361 unsigned int *TripStartIndexH, unsigned int *TripStopIndexH
362 );
363
365
366 void GuessVec( L1TrackPar &t, fvec *xV, fvec *yV, fvec *zV, fvec *Sy, fvec *wV, int NHits, fvec *zCur = 0 );
367 void FilterFirst( L1TrackPar &track,fvec &x, fvec &y, L1Station &st );
368
369#ifdef TBB
370 enum {
371 nthreads = 3, // number of threads
372 nblocks = 1 // number of stations on one thread
373 };
374
375 friend class ParalleledDup;
376 friend class ParalleledTrip;
377#endif // TBB
378#ifdef TBB2
379 public:
380 int thrId;
381#endif // TBB2
382 private:
383
385
387
388 int FIRSTCASTATION; //first station used in CA
389
390 // fNFindIterations - set number of interation for trackfinding
391 // itetation of finding:
392#ifdef FIND_GAPED_TRACKS
393 enum { kFastPrimIter, // primary fast tracks
394 kAllPrimIter, // primary all tracks
395 kAllPrimJumpIter, // primary tracks with jumped triplets
396 kAllSecIter, // secondary all tracks
397 kAllPrimEIter, // primary all electron tracks
398 kAllSecEIter, // secondary all electron tracks
399
400 kFastPrimJumpIter, // primary fast tracks with jumped triplets
401 kFastPrimIter2,
402 kAllSecJumpIter // secondary tracks with jumped triplets
403 };
404#ifdef TRACKS_FROM_TRIPLETS
405 enum { fNFindIterations = TRACKS_FROM_TRIPLETS_ITERATION+1 }; // TODO investigate kAllPrimJumpIter & kAllSecJumpIter
406#else
407 enum { fNFindIterations = LAST_ITERATION+1 }; // TODO investigate kAllPrimJumpIter & kAllSecJumpIter
408#endif
409#else
410 enum { fNFindIterations = 3 };
411 enum { kFastPrimIter = 0, // primary fast tracks
412 kAllPrimIter, // primary all tracks
413 kAllSecIter, // secondary all tracks
414 kFastPrimJumpIter, // disabled
415 kAllPrimJumpIter, // disabled
416 kFastPrimIter2,
417 kAllSecJumpIter
418 };
419#endif // FIND_GAPED_TRACKS
420
421 const float TRACK_CHI2_CUT; // = 10.0; // cut for tracks candidates. per one DoF
422 float TRIPLET_CHI2_CUT; // = 5.0; // cut for selecting triplets before collecting tracks.per one DoF
423 float DOUBLET_CHI2_CUT;
424
425
426 fvec MaxDZ; // correction in order to take into account overlaping and iff z. if sort by y then it is max diff between same station's modules (~0.4cm)
427
429 fvec Pick_gather; // coefficient for size of region for attaching additional hits to track
430 float PickNeighbour; // (PickNeighbour < dp/dp_error) => triplets are neighbours
431 fvec MaxInvMom; // max considered q/p for tracks
432 fvec MaxSlope; // max slope (tx\ty) in prim vertex
433 fvec targX, targY, targZ; // target coor
434 L1FieldValue targB _fvecalignment; // field in the target point
435 L1XYMeasurementInfo TargetXYInfo _fvecalignment; // target constraint [cm]
436
438 enum {
439 multiCoeff = 1, // central - 1, mbias -
440
441 coeff = 64/4,
442
443 Portion = 1024/coeff, // portion of left hits
444
445 MaxPortionDoublets = 10000/5 * 64/2 /coeff /*/ multiCoeff*/*1,
446 MaxPortionTriplets = 10000*5 * 64/2 /coeff /*/ multiCoeff*/*1,
447 MaxNPortion = 40 * coeff / multiCoeff,
448
449
450 MaxArrSize = MaxNPortion*MaxPortionDoublets/MaxNStations //200000, // standart size of big arrays // mas be 40000 for normal work in cbmroot!
451 };
452
453 L1FieldRegion vtxFieldRegion _fvecalignment;// really doesn't used
454 L1FieldValue vtxFieldValue _fvecalignment; // field at teh vertex position.
455
456 vector <L1Triplet> vTriplets; // container for triplets got in finding
457 int TripStartIndex[MaxNStations-2], TripStopIndex[MaxNStations-2]; // containers for stations bounders in vTriplets. indices are from start to stop-1
458
459 int fTrackingLevel, fGhostSuppression; // really doesn't used
460 float fMomentumCutOff;// really doesn't used
461
463#ifdef PULLS
464 L1AlgoPulls* fL1Pulls;
465#endif
466#ifdef TRIP_PERFORMANCE
467 L1AlgoEfficiencyPerformance<3>* fL1Eff_triplets;
468 L1AlgoEfficiencyPerformance<3>* fL1Eff_triplets2;
469#endif
470#ifdef DOUB_PERFORMANCE
471 L1AlgoEfficiencyPerformance<2>* fL1Eff_doublets;
472#endif
473#ifdef DRAW
474 friend class L1AlgoDraw;
475#endif
476
477private:
478 L1Algo(const L1Algo&);
479 void operator=(const L1Algo&);
481
482#endif
vector< Double_t > W(vector< Double_t > dist, Double_t sig)
Definition BmnMath.cxx:878
class L1Algo _fvecalignment
#define LAST_ITERATION
Debug features.
Definition L1Algo.h:19
unsigned int THitI
Definition L1StsHit.h:6
float fscal
Definition P4_F32vec4.h:232
__m128 v
Definition P4_F32vec4.h:1
__m128 m
Definition P4_F32vec4.h:27
Definition CbmL1.h:49
vector< unsigned char > vSFlag
Definition L1Algo.h:134
THitI * RealIHit
Definition L1Algo.h:143
L1Station vStations[MaxNStations] _fvecalignment
Definition L1Algo.h:125
int NStations
Definition L1Algo.h:123
THitI StsHitsStopIndex[MaxNStations+1]
Definition L1Algo.h:136
vector< L1Strip > vStsStrips
Definition L1Algo.h:129
@ MaxNStations
Definition L1Algo.h:122
double CATime
Definition L1Algo.h:154
vector< L1HitPoint > vAllHitPoints
Definition L1Algo.h:147
vector< L1Track > vTracks
--— Output data --—
Definition L1Algo.h:151
vector< unsigned char > vSFlagB
Definition L1Algo.h:135
THitI StsHitsUnusedStartIndex[MaxNStations+1]
Definition L1Algo.h:144
THitI StsHitsStartIndex[MaxNStations+1]
Definition L1Algo.h:136
vector< THitI > vRecoHits
Definition L1Algo.h:152
int NMvdStations
Definition L1Algo.h:124
vector< L1StsHit > vStsHits
Definition L1Algo.h:132
int isec
— data used during finding iterations
Definition L1Algo.h:140
vector< L1StsHit > * vStsHitsUnused
Definition L1Algo.h:141
std::vector< L1HitPoint > * vStsHitPointsUnused
Definition L1Algo.h:142
vector< L1Strip > vStsStripsB
Definition L1Algo.h:130
vector< int > vStsHits2Unus
Definition L1Algo.h:146
void CATrackFinder()
The main procedure - find tracks.
vector< fscal > vStsZPos
Definition L1Algo.h:131
THitI StsHitsUnusedStopIndex[MaxNStations+1]
Definition L1Algo.h:144
void L1KFTrackFitter(bool extrapolateToTheEndOfSTS=false)
void KFTrackFitter_simple()
Track fitting procedures.
L1Grid vGrid[MaxNStations]
Definition L1Algo.h:133
L1FieldValue GetvtxFieldValue()
Definition L1Algo.h:158
void Init(const fscal geo[])
Definition L1Algo.cxx:3
vector< L1Material > fRadThick
Definition L1Algo.h:127
L1Algo()
Definition L1Algo.h:62
contain strips positions and coordinates of hit
Definition L1HitPoint.h:6
std::vector< T > TSimd