CbmRoot
CbmL1MCTrack.cxx
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 Monte Carlo information
13  *
14  *====================================================================
15  */
16 
17 #include "CbmL1MCTrack.h"
18 #include "CbmL1.h"
19 #include "CbmL1Constants.h"
20 #include "L1Algo/L1Algo.h"
21 
23  double q_,
24  TVector3 vr,
25  TLorentzVector vp,
26  int _ID,
27  int _mother_ID,
28  int _pdg)
29  : mass(mass_)
30  , q(q_)
31  , p(0)
32  , x(0)
33  , y(0)
34  , z(0)
35  , px(0)
36  , py(0)
37  , pz(0)
38  , time(0)
39  , ID(_ID)
40  , iFile(0)
41  , iEvent(0)
42  , mother_ID(_mother_ID)
43  , pdg(_pdg)
44  , Points()
45  , StsHits()
46  , nMCContStations(0)
47  , nHitContStations(0)
48  , maxNStaMC(0)
49  , maxNSensorMC(0)
50  , maxNStaHits(0)
51  , nStations(0)
52  , nMCStations(0)
53  , isReconstructable(0)
54  , isAdditional()
55  , rTracks()
56  , tTracks() {
57  x = vr.X();
58  y = vr.Y();
59  z = vr.Z();
60  px = vp.Px();
61  py = vp.Py();
62  pz = vp.Pz();
63  p = sqrt(fabs(px * px + py * py + pz * pz));
64 };
65 
66 // CbmL1MCTrack::CbmL1MCTrack(TmpMCPoints &mcPoint, TVector3 vr, TLorentzVector vp, int ID, int mother_ID):
67 // ID(_ID), mother_ID(_mother_ID)
68 // {
69 // mass = mcPoint->mass;
70 // q = mcPoint->q;
71 // pdg = mcPoint->pdg;
72 //
73 // x = vr.X();
74 // y = vr.Y();
75 // z = vr.Z();
76 // px = vp.Px();
77 // py = vp.Py();
78 // pz = vp.Pz();
79 // p = sqrt( fabs(px*px + py*py + pz*pz ));
80 // };
81 
83  CbmL1* L1 = CbmL1::Instance();
84  // get stsHits
85  StsHits.clear();
86  for (unsigned int iP = 0; iP < Points.size(); iP++) {
87  CbmL1MCPoint* point = &(L1->vMCPoints[Points[iP]]);
88  for (unsigned int iH = 0; iH < point->hitIds.size(); iH++) {
89  const int iih = point->hitIds[iH];
90  if (std::find(StsHits.begin(), StsHits.end(), iih) == StsHits.end())
91  StsHits.push_back(iih);
92  }
93  }
94 
100 } // void CbmL1MCTrack::Init()
101 
102 
104  // if ( Points.size() == 0 ) return 0;
105 
106  CbmL1* L1 = CbmL1::Instance();
107  int counter = 0;
108  for (unsigned int iP = 0; iP < Points.size(); iP++) {
109  if (L1->vMCPoints_in_Time_Slice[Points[iP]] > 0) counter++;
110  };
111  return (Points.size() > 0) ? float(counter) / float(Points.size()) : 0;
112 }
113 
114 
116  CbmL1* L1 = CbmL1::Instance();
117 
118  int nPoints = Points.size();
119  nMCContStations = 0;
120  int istaold = -1, ncont = 0;
121  for (int ih = 0; ih < nPoints; ih++) {
122  CbmL1MCPoint& h = L1->vMCPoints[Points[ih]];
123  int ista = h.iStation;
124  if (ista - istaold == 1)
125  ncont++;
126  else if (ista - istaold > 1) {
127  if (nMCContStations < ncont) nMCContStations = ncont;
128  ncont = 1;
129  }
130  if (ista <= istaold) continue; // backward direction
131  istaold = ista;
132  }
133  if (nMCContStations < ncont) nMCContStations = ncont;
134 }; // void CbmL1MCTrack::CalculateMCCont()
135 
137  CbmL1* L1 = CbmL1::Instance();
138  L1Algo* algo = L1->algo;
139 
140  int nhits = StsHits.size();
141  nHitContStations = 0;
142  int istaold = -1, ncont = 0;
143  {
144  for (int ih = 0; ih < nhits; ih++) {
145  int jh = StsHits[ih];
146  const L1StsHit& h = (*algo->vStsHits)[jh];
147  int ista = (*algo->vSFlag)[h.f] / 4;
148 
149  if (ista - istaold == 1)
150  ncont++;
151  else if (ista - istaold > 1) {
152  if (nHitContStations < ncont) nHitContStations = ncont;
153  ncont = 1;
154  }
155 
156  if (
157  !(ista
158  >= istaold)) { // tracks going in backward direction are not reconstructable
159  nHitContStations = 0;
160  return;
161  }
162  if (ista == istaold) continue; // backward direction
163  istaold = ista;
164  }
165  }
166  if (nHitContStations < ncont) nHitContStations = ncont;
167 
168 
169 }; // void CbmL1MCTrack::CalculateHitCont()
170 
172  CbmL1* L1 = CbmL1::Instance();
173 
174  maxNStaHits = 0;
175  nStations = 0;
176  int lastSta = -1;
177  int cur_maxNStaHits = 0;
178  for (unsigned int iH = 0; iH < StsHits.size(); iH++) {
179  CbmL1HitStore& sh = L1->vHitStore[StsHits[iH]];
180  if (sh.iStation == lastSta) {
181  cur_maxNStaHits++;
182  } else { // new station
183  if (
184  !(sh.iStation
185  > lastSta)) { // tracks going in backward direction are not reconstructable
186  maxNStaHits = 0;
187  return;
188  }
189  if (cur_maxNStaHits > maxNStaHits) maxNStaHits = cur_maxNStaHits;
190  cur_maxNStaHits = 1;
191  lastSta = sh.iStation;
192  nStations++;
193  }
194  };
195  if (cur_maxNStaHits > maxNStaHits) maxNStaHits = cur_maxNStaHits;
196  // cout << pdg << " " << p << " " << StsHits.size() << " > " << maxNStaHits << endl;
197 }; // void CbmL1MCTrack::CalculateHitCont()
198 
200  CbmL1* L1 = CbmL1::Instance();
201 
202  maxNStaMC = 0;
203  maxNSensorMC = 0;
204  nMCStations = 0;
205  int lastSta = -1;
206  float lastz = -1;
207  int cur_maxNStaMC = 0, cur_maxNSensorMC = 0;
208  for (unsigned int iH = 0; iH < Points.size(); iH++) {
209  CbmL1MCPoint& mcP = L1->vMCPoints[Points[iH]];
210  if (mcP.iStation == lastSta)
211  cur_maxNStaMC++;
212  else { // new station
213  if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
214  cur_maxNStaMC = 1;
215  lastSta = mcP.iStation;
216  nMCStations++;
217  }
218 
219  if (mcP.z == lastz) // TODO: works incorrect because of different z
220  cur_maxNSensorMC++;
221  else { // new z
222  if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
223  cur_maxNSensorMC = 1;
224  lastz = mcP.z;
225  }
226  };
227  if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
228  if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
229  // cout << pdg << " " << p << " " << Points.size() << " > " << maxNStaMC << " " << maxNSensorMC << endl;
230 }; // void CbmL1MCTrack::CalculateMaxNStaMC()
231 
232 
234  CbmL1* L1 = CbmL1::Instance();
235 
236  bool f = 1;
237 
238  // reject very slow tracks from analysis
240  // detected at least in 4 stations
241  // f &= (nMCContStations >= 4);
242 
243  // maximul 4 layers for a station.
244  // f &= (maxNStaHits <= 4);
245  f &= (maxNStaMC <= 4);
246  // f &= (maxNSensorMC <= 1);
247  if (L1->fPerformance == 4)
249  & (Fraction_MC() > 0.5);
250  if (L1->fPerformance == 3)
253  if (L1->fPerformance == 2)
255  f & (nStations >= CbmL1Constants::MinNStations); // QA definition
256  if (L1->fPerformance == 1)
258  f & (nHitContStations >= CbmL1Constants::MinNStations); // L1 definition
259 
260  if (Points.size() > 0) {
263  & (nHitContStations >= 3)
264  & (L1->vMCPoints[Points[0]].iStation == 0);
266  } else
267  isAdditional = 0;
268 }; // bool CbmL1MCTrack::IsReconstructable()
L1Algo::vStsHits
const vector< L1StsHit > * vStsHits
Definition: L1Algo.h:344
h
Generates beam ions for transport simulation.
Definition: CbmBeamGenerator.h:17
f
float f
Definition: L1/vectors/P4_F32vec4.h:24
L1Algo.h
CbmL1MCTrack::Init
void Init()
Definition: CbmL1MCTrack.cxx:82
CbmL1::algo
L1Algo * algo
Definition: CbmL1.h:119
CbmL1MCPoint
Definition: CbmL1MCPoint.h:23
CbmL1HitStore::iStation
int iStation
Definition: CbmL1.h:97
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
CbmL1MCTrack::nStations
int nStations
Definition: CbmL1MCTrack.h:131
CbmL1MCTrack::CalculateMaxNStaMC
void CalculateMaxNStaMC()
Definition: CbmL1MCTrack.cxx:199
CbmL1MCTrack::y
double y
Definition: CbmL1MCTrack.h:31
CbmL1MCTrack::x
double x
Definition: CbmL1MCTrack.h:31
CbmL1MCTrack::maxNStaMC
int maxNStaMC
Definition: CbmL1MCTrack.h:127
CbmL1HitStore
Definition: CbmL1.h:94
CbmL1.h
L1StsHit
Definition: L1StsHit.h:12
CbmL1MCTrack::px
double px
Definition: CbmL1MCTrack.h:31
CbmL1Constants.h
CbmL1MCTrack::CalculateMCCont
void CalculateMCCont()
Definition: CbmL1MCTrack.cxx:115
CbmL1MCTrack::nMCContStations
int nMCContStations
Definition: CbmL1MCTrack.h:125
CbmL1MCTrack::nHitContStations
int nHitContStations
Definition: CbmL1MCTrack.h:126
CbmL1MCTrack::py
double py
Definition: CbmL1MCTrack.h:31
CbmL1MCTrack::maxNSensorMC
int maxNSensorMC
Definition: CbmL1MCTrack.h:128
CbmL1MCTrack.h
CbmL1::Instance
static CbmL1 * Instance()
Definition: CbmL1.h:129
CbmL1MCTrack::CalculateIsReconstructable
void CalculateIsReconstructable()
Definition: CbmL1MCTrack.cxx:233
CbmL1MCTrack::CbmL1MCTrack
CbmL1MCTrack()
Definition: CbmL1MCTrack.h:36
CbmL1MCTrack::p
double p
Definition: CbmL1MCTrack.h:31
CbmL1MCTrack::Points
vector< int > Points
Definition: CbmL1MCTrack.h:33
CbmL1MCTrack::z
double z
Definition: CbmL1MCTrack.h:31
CbmL1MCPoint::iStation
int iStation
Definition: CbmL1MCPoint.h:61
CbmL1Constants::MinRecoMom
const double MinRecoMom
Performance constants.
Definition: CbmL1Constants.h:6
CbmL1MCTrack::isAdditional
bool isAdditional
Definition: CbmL1MCTrack.h:135
L1Algo::vSFlag
const vector< unsigned char > * vSFlag
Definition: L1Algo.h:350
L1Algo
Definition: L1Algo.h:79
CbmL1MCPoint::hitIds
vector< int > hitIds
Definition: CbmL1MCPoint.h:73
CbmL1MCTrack::maxNStaHits
int maxNStaHits
Definition: CbmL1MCTrack.h:129
CbmL1MCTrack::isReconstructable
bool isReconstructable
Definition: CbmL1MCTrack.h:134
CbmL1MCPoint::z
double z
Definition: CbmL1MCPoint.h:56
counter
int counter
Definition: CbmMvdSensorDigiToHitTask.cxx:72
CbmL1MCTrack::Fraction_MC
float Fraction_MC()
Definition: CbmL1MCTrack.cxx:103
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
fabs
friend F32vec4 fabs(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:60
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmL1MCTrack::pz
double pz
Definition: CbmL1MCTrack.h:31
CbmL1::vMCPoints_in_Time_Slice
vector< int > vMCPoints_in_Time_Slice
Definition: CbmL1.h:199
ID
int ID
Definition: CbmMvdSensorDigiToHitTask.cxx:71
CbmL1MCTrack::StsHits
vector< int > StsHits
Definition: CbmL1MCTrack.h:34
CbmL1MCTrack::CalculateMaxNStaHits
void CalculateMaxNStaHits()
Definition: CbmL1MCTrack.cxx:171
CbmL1::vMCPoints
vector< CbmL1MCPoint > vMCPoints
Definition: CbmL1.h:197
CbmL1
Definition: CbmL1.h:113
CbmL1::vHitStore
vector< CbmL1HitStore > vHitStore
Definition: CbmL1.h:180
CbmL1::fPerformance
Int_t fPerformance
Definition: CbmL1.h:247
CbmL1Constants::MinNStations
const double MinNStations
Definition: CbmL1Constants.h:11
CbmL1MCTrack::nMCStations
int nMCStations
Definition: CbmL1MCTrack.h:132
CbmL1MCTrack::CalculateHitCont
void CalculateHitCont()
Definition: CbmL1MCTrack.cxx:136