CbmRoot
L1Branch.h
Go to the documentation of this file.
1 /*
2  *====================================================================
3  *
4  * CBM Level 1 Reconstruction
5  *
6  * Authors: I.Kisel, S.Gorbunov
7  *
8  * e-mail : ikisel@kip.uni-heidelberg.de
9  *
10  *====================================================================
11  *
12  * L1 branch class
13  *
14  *====================================================================
15  */
16 
17 #ifndef L1Branch_H
18 #define L1Branch_H
19 
20 #include "../CbmL1Def.h"
21 #include "L1StsHit.h"
22 #include <vector>
23 
24 class L1Triplet;
25 
26 
27 struct L1Branch {
29  : //Quality(0),
30  ista(0)
31  , Momentum(0)
32  , NHits(0)
33  , chi2(0)
34  , CandIndex(0)
35  , StsHits() {
36  // L1Branch():Momentum(0),chi2(0),NHits(0),Lengtha(0),ista(0) , StsHits(){
37  StsHits.resize(12);
38  }
39 
40  // unsigned short int Quality;
41  unsigned char ista;
42  // fscal Quality;
43  // unsigned char iN; // iStation(3b) + nHits(5b)
44  char Momentum, NHits;
45  // char Lengtha;
47  int CandIndex;
48 
49 
51 
52  // static bool compareCand(const L1Branch *a, const L1Branch *b){
53  //
54  // if (a->Lengtha != b->Lengtha) return (a->Lengtha > b->Lengtha);
55  //
56  // if (a->ista != b->ista ) return (a->ista < b->ista );
57  //
58  // if (a->chi2 != b->chi2 )return (a->chi2 < b->chi2 );
59  // //return (a->chi2 < b->chi2 );
60  // // return (a->CandIndex < b->CandIndex );
61  // return (a->CandIndex > b->CandIndex );
62  //
63  // }
64 
65  // inline static bool compareCand(const L1Branch &a, const L1Branch &b){
66  //
67  //
68  //
69  // if (a.Lengtha != b.Lengtha) return (a.Lengtha > b.Lengtha);
70  //
71  //
72  // // if (a.time_dif != b.time_dif) return (a.time_dif < b.time_dif);
73  //
74  //
75  // if (a.ista != b.ista ) return (a.ista < b.ista );
76  //
77  //
78  //
79  // if (a.chi2 != b.chi2 ) return (a.chi2 < b.chi2 );
80  //
81  // return (a.CandIndex < b.CandIndex );
82  // // return (a->CandIndex < b->CandIndex );
83  // // return (a.CandIndex < b.CandIndex );
84  //
85  // }
86 
87  inline static bool compareCand(const L1Branch& a, const L1Branch& b) {
88 
89  if (a.NHits != b.NHits) return (a.NHits > b.NHits);
90 
91  if (a.ista != b.ista)
92  return (a.ista < b.ista);
93 
94  else
95  return (a.chi2 < b.chi2);
96  }
97 
98 
99  // static bool compareChi2(const L1Branch &a, const L1Branch &b){
100  // return (a.Quality > b.Quality );
101  // }
102 
103  // static bool compareChi2(const L1Branch &a, const L1Branch &b){
104  // if (a.Lengtha != b.Lengtha) return (a.Lengtha > b.Lengtha);
105  //
106  // if (a.chi2 != b.chi2 )return (a.chi2 < b.chi2 );
107  // //return (a->chi2 < b->chi2 );
108  // // return (a->CandIndex < b->CandIndex );
109  // return (a.CandIndex >= b.CandIndex );
110  // }
111 
112 
113  // static bool compareChi2(const L1Branch &a, const L1Branch &b){
114  // return (a.Quality > b.Quality );
115  //}
116 
117  void Set(unsigned char iStation, unsigned char Length, float Chi2, float Qp) {
118  NHits = Length;
119  ista = iStation;
120  // iN = ( (static_cast<unsigned char>( Chi2 ))<<3 ) + (Level%8);
121  //unsigned short int ista_l = 16-iStation;
122  float tmp = sqrt(Chi2) / 3.5 * 255;
123  if (tmp > 255) tmp = 255;
124  // unsigned short int chi_2 = 255 - static_cast<unsigned char>( tmp );
125  // Quality = (Length<<12) + (ista_l<<8) + chi_2;
126  Momentum = 1.0 / fabs(Qp);
127  // chi2 = chi_2;
128  chi2 = Chi2;
129  }
130 
131  // void SetLength( unsigned char Length ){
132  // Quality += - (Quality*(4096)) + (Length/(4096));
133  // }
134 
135  // static bool compareChi2Q(const L1Branch &a, const L1Branch &b){
138  // if (a.Lengtha != b.Lengtha) return (a.Lengtha > b.Lengtha);
139  //
140  // if (a.ista != b.ista ) return (a.ista < b.ista );
141  //
142  // return (a.chi2 < b.chi2 );
143  // }
144  // static bool comparePChi2(const L1Branch *a, const L1Branch *b){
145  // return compareChi2(*a,*b);
146  // }
147  static bool compareMomentum(const L1Branch& a, const L1Branch& b) {
148  return (a.Momentum > b.Momentum);
149  }
150  static bool comparePMomentum(const L1Branch* a, const L1Branch* b) {
151  return compareMomentum(*a, *b);
152  }
153 };
154 
155 #endif
fscal
float fscal
Definition: L1/vectors/P4_F32vec4.h:250
L1Branch::Momentum
char Momentum
Definition: L1Branch.h:44
L1Branch::ista
unsigned char ista
Definition: L1Branch.h:41
L1Triplet
Definition: L1Triplet.h:4
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
L1Branch::compareCand
static bool compareCand(const L1Branch &a, const L1Branch &b)
Definition: L1Branch.h:87
L1Branch::StsHits
L1Vector< THitI > StsHits
Definition: L1Branch.h:50
L1Branch::comparePMomentum
static bool comparePMomentum(const L1Branch *a, const L1Branch *b)
Definition: L1Branch.h:150
L1Vector< THitI >
L1Branch::NHits
char NHits
Definition: L1Branch.h:44
L1Branch::Set
void Set(unsigned char iStation, unsigned char Length, float Chi2, float Qp)
Definition: L1Branch.h:117
L1Branch::chi2
fscal chi2
Definition: L1Branch.h:46
L1Branch
Definition: L1Branch.h:27
L1Branch::L1Branch
L1Branch()
Definition: L1Branch.h:28
L1Branch::CandIndex
int CandIndex
Definition: L1Branch.h:47
L1Branch::compareMomentum
static bool compareMomentum(const L1Branch &a, const L1Branch &b)
Definition: L1Branch.h:147
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
L1StsHit.h