BmnRoot
Loading...
Searching...
No Matches
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 "CbmL1.h"
18#include "CbmL1MCTrack.h"
19#include "CbmL1Constants.h"
20#include "L1Algo/L1Algo.h"
21
22CbmL1MCTrack::CbmL1MCTrack(double mass_, double q_, TVector3 vr, TLorentzVector vp, int _ID, int _mother_ID, int _pdg):
23 mass(mass_),q(q_),p(0),x(0),y(0),z(0),px(0),py(0),pz(0),ID(_ID), mother_ID(_mother_ID), pdg(_pdg),Points(),StsHits(),
24 nMCContStations(0),nHitContStations(0),maxNStaMC(0),maxNSensorMC(0),maxNStaHits(0),nStations(0),nMCStations(0),isReconstructable(0),isAdditional(),
25 rTracks(),tTracks()
26{
27 x = vr.X();
28 y = vr.Y();
29 z = vr.Z();
30 px = vp.Px();
31 py = vp.Py();
32 pz = vp.Pz();
33 p = sqrt( fabs(px*px + py*py + pz*pz ));
34};
35
36// CbmL1MCTrack::CbmL1MCTrack(TmpMCPoints &mcPoint, TVector3 vr, TLorentzVector vp, int ID, int mother_ID):
37// ID(_ID), mother_ID(_mother_ID)
38// {
39// mass = mcPoint->mass;
40// q = mcPoint->q;
41// pdg = mcPoint->pdg;
42//
43// x = vr.X();
44// y = vr.Y();
45// z = vr.Z();
46// px = vp.Px();
47// py = vp.Py();
48// pz = vp.Pz();
49// p = sqrt( fabs(px*px + py*py + pz*pz ));
50// };
51
53{
55 // get stsHits
56 StsHits.clear();
57 for (unsigned int iP = 0; iP < Points.size(); iP++){
58 CbmL1MCPoint* point = &(L1->vMCPoints[Points[iP]]);
59 for (unsigned int iH = 0; iH < point->hitIds.size(); iH++){
60 const int iih = point->hitIds[iH];
61 if( std::find(StsHits.begin(), StsHits.end(), iih) == StsHits.end() )
62 StsHits.push_back(iih);
63 }
64 }
65
66 CalculateMCCont();
67 CalculateHitCont();
68 CalculateMaxNStaMC();
69 CalculateMaxNStaHits();
70 CalculateIsReconstructable();
71} // void CbmL1MCTrack::Init()
72
73void CbmL1MCTrack::CalculateMCCont()
74{
76
77 int nPoints = Points.size();
78 nMCContStations = 0;
79 int istaold = -1, ncont=0;
80 for( int ih=0; ih<nPoints; ih++ ){
81 CbmL1MCPoint &h = L1->vMCPoints[Points[ih]];
82 int ista = h.iStation;
83 if (ista - istaold == 1) ncont++;
84 else if(ista - istaold > 1){
85 if( nMCContStations < ncont ) nMCContStations = ncont;
86 ncont = 1;
87 }
88 if (ista <= istaold ) continue; // backward direction
89 istaold = ista;
90 }
91 if( nMCContStations < ncont ) nMCContStations = ncont;
92}; // void CbmL1MCTrack::CalculateMCCont()
93
94void CbmL1MCTrack::CalculateHitCont()
95{
97 L1Algo* algo = L1->algo;
98
99 int nhits = StsHits.size();
100 nHitContStations = 0;
101 int istaold = -1, ncont=0;
102 for( int ih=0; ih<nhits; ih++ ){
103 int jh = StsHits[ih];
104 L1StsHit &h = algo->vStsHits[jh];
105 int ista = algo->vSFlag[h.f]/4;
106 if (ista - istaold == 1) ncont++;
107 else if(ista - istaold > 1){
108 if( nHitContStations < ncont ) nHitContStations = ncont;
109 ncont = 1;
110 }
111
112 if ( !( ista >= istaold ) ) { // tracks going in backward direction are not reconstructable
113 nHitContStations = 0;
114 return;
115 }
116 if (ista == istaold ) continue; // backward direction
117 istaold = ista;
118 }
119 if( nHitContStations<ncont ) nHitContStations=ncont;
120}; // void CbmL1MCTrack::CalculateHitCont()
121
122void CbmL1MCTrack::CalculateMaxNStaHits()
123{
125
126 maxNStaHits = 0;
127 nStations = 0;
128 int lastSta = -1;
129 int cur_maxNStaHits = 0;
130 for(unsigned int iH = 0; iH < StsHits.size(); iH++){
131 CbmL1HitStore& sh = L1->vHitStore[StsHits[iH]];
132 if (sh.iStation == lastSta){
133 cur_maxNStaHits++;
134 }
135 else{ // new station
136 if ( !(sh.iStation > lastSta) ) {// tracks going in backward direction are not reconstructable
137 maxNStaHits = 0;
138 return;
139 }
140 if (cur_maxNStaHits > maxNStaHits) maxNStaHits = cur_maxNStaHits;
141 cur_maxNStaHits = 1;
142 lastSta = sh.iStation;
143 nStations++;
144 }
145 };
146 if (cur_maxNStaHits > maxNStaHits) maxNStaHits = cur_maxNStaHits;
147// cout << pdg << " " << p << " " << StsHits.size() << " > " << maxNStaHits << endl;
148}; // void CbmL1MCTrack::CalculateHitCont()
149
150void CbmL1MCTrack::CalculateMaxNStaMC()
151{
153
154 maxNStaMC = 0;
155 maxNSensorMC = 0;
156 nMCStations = 0;
157 int lastSta = -1;
158 float lastz = -1;
159 int cur_maxNStaMC = 0 , cur_maxNSensorMC = 0;
160 for(unsigned int iH = 0; iH < Points.size(); iH++){
161 CbmL1MCPoint& mcP = L1->vMCPoints[Points[iH]];
162 if (mcP.iStation == lastSta)
163 cur_maxNStaMC++;
164 else{ // new station
165 if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
166 cur_maxNStaMC = 1;
167 lastSta = mcP.iStation;
168 nMCStations++;
169 }
170
171 if (mcP.z == lastz) // TODO: works incorrect because of different z
172 cur_maxNSensorMC++;
173 else{ // new z
174 if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
175 cur_maxNSensorMC = 1;
176 lastz = mcP.z;
177 }
178 };
179 if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
180 if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
181// cout << pdg << " " << p << " " << Points.size() << " > " << maxNStaMC << " " << maxNSensorMC << endl;
182}; // void CbmL1MCTrack::CalculateMaxNStaMC()
183
184void CbmL1MCTrack::CalculateIsReconstructable()
185{
187
188 bool f = 1;
189
190 // reject very slow tracks from analysis
192 // detected at least in 4 stations
193 // f &= (nMCContStations >= 4);
194
195 // maximul 4 layers for a station.
196 // f &= (maxNStaHits <= 4);
197 f &= (maxNStaMC <= 4);
198 // f &= (maxNSensorMC <= 1);
199
200 if (L1->fPerformance == 3) isReconstructable = f & (nMCContStations >= CbmL1Constants::MinNStations); // L1-MC
201 if (L1->fPerformance == 2) isReconstructable = f & (nStations >= CbmL1Constants::MinNStations); // QA definition
202 if (L1->fPerformance == 1) isReconstructable = f & (nHitContStations >= CbmL1Constants::MinNStations); // L1 definition
203
204 isAdditional = f &
205 (nHitContStations == nStations) & (nMCContStations == nStations) & (nMCStations == nStations) &
206 (nHitContStations >= 3) &
207 (L1->vMCPoints[Points[0]].iStation == 0);
208 isAdditional &= !isReconstructable;
209}; // bool CbmL1MCTrack::IsReconstructable()
friend F32vec4 sqrt(const F32vec4 &a)
Definition P4_F32vec4.h:34
friend F32vec4 fabs(const F32vec4 &a)
Definition P4_F32vec4.h:52
float f
Definition P4_F32vec4.h:21
int iStation
Definition CbmL1.h:44
vector< int > StsHits
vector< int > Points
Definition CbmL1.h:49
static CbmL1 * Instance()
reconstructed tracks
Definition CbmL1.h:60
vector< unsigned char > vSFlag
Definition L1Algo.h:134
vector< L1StsHit > vStsHits
Definition L1Algo.h:132
TStripI f
Definition L1StsHit.h:12
const double MinNStations
const double MinRecoMom
Performance constants.
#define L1
vector< int > hitIds