CbmRoot
Loading...
Searching...
No Matches
CbmL1MCTrack.cxx
Go to the documentation of this file.
1/* Copyright (C) 2010-2020 Frankfurt Institute for Advanced Studies, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Ivan Kisel, Sergey Gorbunov, Igor Kulakov [committer], Maksym Zyzak */
4
5/*
6 *====================================================================
7 *
8 * CBM Level 1 Reconstruction
9 *
10 * Authors: I.Kisel, S.Gorbunov
11 *
12 * e-mail : ikisel@kip.uni-heidelberg.de
13 *
14 *====================================================================
15 *
16 * L1 Monte Carlo information
17 *
18 *====================================================================
19 */
20
21#include "CbmL1MCTrack.h"
22
23#include "CaDefs.h"
24#include "CaHit.h"
25#include "CbmL1.h"
26#include "CbmL1Constants.h"
27
28#include <Logger.h>
29
30#include <iomanip>
31#include <sstream>
32
33
35
36CbmL1MCTrack::CbmL1MCTrack(double mass_, double q_, TVector3 vr, TLorentzVector vp, int _ID, int _mother_ID, int _pdg,
37 unsigned int _process_ID)
38 : mass(mass_)
39 , q(q_)
40 , p(vp.P())
41 , x(vr.X())
42 , y(vr.Y())
43 , z(vr.Z())
44 , px(vp.Px())
45 , py(vp.Py())
46 , pz(vp.Pz())
47 , ID(_ID)
48 , mother_ID(_mother_ID)
49 , pdg(_pdg)
50 , process_ID(_process_ID)
51{
52}
53
54// CbmL1MCTrack::CbmL1MCTrack(TmpMCPoints &mcPoint, TVector3 vr, TLorentzVector vp, int ID, int mother_ID):
55// ID(_ID), mother_ID(_mother_ID)
56// {
57// mass = mcPoint->mass;
58// q = mcPoint->q;
59// pdg = mcPoint->pdg;
60//
61// x = vr.X();
62// y = vr.Y();
63// z = vr.Z();
64// px = vp.Px();
65// py = vp.Py();
66// pz = vp.Pz();
67// p = sqrt( fabs(px*px + py*py + pz*pz ));
68// };
69
71{
72 CbmL1* L1 = CbmL1::Instance();
73 // get Hits
74 Hits.clear();
75 for (unsigned int iP = 0; iP < Points.size(); iP++) {
76 const auto& point = (L1->GetMCData().GetPoint(Points[iP]));
77 for (unsigned int iih : point.GetHitIndexes()) {
78 if (std::find(Hits.begin(), Hits.end(), iih) == Hits.end()) Hits.push_back_no_warning(iih);
79 }
80 }
81
86}
87
89{
90 CbmL1* L1 = CbmL1::Instance();
91
92 int nPoints = Points.size();
94 int istaold = -1, ncont = 0;
95 for (int ih = 0; ih < nPoints; ih++) {
96 const auto& h = L1->GetMCData().GetPoint(Points[ih]);
97 int ista = h.GetStationId();
98 if (ista - istaold == 1)
99 ncont++;
100 else if (ista - istaold > 1) {
101 if (nMCContStations < ncont) nMCContStations = ncont;
102 ncont = 1;
103 }
104 if (ista <= istaold) continue; // backward direction
105 istaold = ista;
106 }
107 if (nMCContStations < ncont) nMCContStations = ncont;
108}
109
110
112{
113 CbmL1* L1 = CbmL1::Instance();
114
115 int stationNhits[MaxNstations]{0};
116
117 for (unsigned int iH = 0; iH < Hits.size(); iH++) {
119 stationNhits[sh.iStation]++;
120 }
121
122 maxNStaHits = 0;
123 nStations = 0;
125 int ncont = 0;
126
127 for (int ista = 0; ista < L1->fpAlgo->GetParameters().GetNstationsActive(); ista++) {
128 if (maxNStaHits < stationNhits[ista]) {
129 maxNStaHits = stationNhits[ista];
130 }
131 if (stationNhits[ista] > 0) {
132 nStations++;
133 ncont++;
134 }
135 else {
136 if (nHitContStations < ncont) {
137 nHitContStations = ncont;
138 }
139 ncont = 0;
140 }
141 }
142 if (nHitContStations < ncont) nHitContStations = ncont;
143}
144
146{
147 CbmL1* L1 = CbmL1::Instance();
148
149 maxNStaMC = 0;
150 maxNSensorMC = 0;
151 nMCStations = 0;
152 int lastSta = -1;
153 float lastz = -1;
154 int cur_maxNStaMC = 0, cur_maxNSensorMC = 0;
155 for (unsigned int iH = 0; iH < Points.size(); iH++) {
156 const auto& mcP = L1->GetMCData().GetPoint(Points[iH]);
157 if (mcP.GetStationId() == lastSta)
158 cur_maxNStaMC++;
159 else { // new station
160 if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
161 cur_maxNStaMC = 1;
162 lastSta = mcP.GetStationId();
163 nMCStations++;
164 }
165
166 if (mcP.GetZ() == lastz) // TODO: works incorrect because of different z
167 cur_maxNSensorMC++;
168 else { // new z
169 if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
170 cur_maxNSensorMC = 1;
171 lastz = mcP.GetZ();
172 }
173 };
174 if (cur_maxNStaMC > maxNStaMC) maxNStaMC = cur_maxNStaMC;
175 if (cur_maxNSensorMC > maxNSensorMC) maxNSensorMC = cur_maxNSensorMC;
176 // LOG(info) << pdg << " " << p << " " << Points.size() << " > " << maxNStaMC << " " << maxNSensorMC;
177}; // void CbmL1MCTrack::CalculateMaxNStaMC()
178
179
181{
182 CbmL1* L1 = CbmL1::Instance();
183
184 bool f = 1;
185
186 // reject very slow tracks from analysis
188 // detected at least in 4 stations
189 // f &= (nMCContStations >= 4);
190
191 // maximul 4 layers for a station.
192 // f &= (maxNStaHits <= 4);
193 f &= (maxNStaMC <= 4);
194 // f &= (maxNSensorMC <= 1);
196 if (L1->fPerformance == 2) isReconstructable = f & (nStations >= CbmL1Constants::MinNStations); // QA definition
197 if (L1->fPerformance == 1)
199
200 if (Points.size() > 0) {
202 & (nHitContStations >= 3) & (L1->GetMCData().GetPoint(Points[0]).GetStationId() == 0);
204 }
205 else
206 isAdditional = 0;
207}; // bool CbmL1MCTrack::IsReconstructable()
208
209std::string CbmL1MCTrack::ToString(int verbose, bool header) const
210{
211 using std::setfill;
212 using std::setw;
213 std::stringstream msg;
214 if (header) {
215 if (verbose > 0) {
216 msg << setw(8) << setfill(' ') << "ID" << ' ';
217 msg << setw(8) << setfill(' ') << "Mother" << ' ';
218 msg << setw(8) << setfill(' ') << "PDG" << ' ';
219 if (verbose > 1) {
220 msg << setw(8) << setfill(' ') << "N h." << ' ';
221 msg << setw(8) << setfill(' ') << "N p." << ' ';
222 msg << setw(8) << setfill(' ') << "N r.tr." << ' ';
223 if (verbose > 2) {
224 msg << setw(8) << setfill(' ') << "N t.tr." << ' ';
225 }
226 msg << setw(12) << setfill(' ') << "zVTX [cm]" << ' ';
227 msg << setw(12) << setfill(' ') << "t [ns]" << ' ';
228 msg << setw(12) << setfill(' ') << "p [GeV/c]" << ' ';
229 }
230 msg << setw(8) << setfill(' ') << "rec-able" << ' ';
231 msg << setw(8) << setfill(' ') << "rec-ed" << ' ';
232 }
233 }
234 else {
235 if (verbose > 0) {
236 msg << setw(8) << setfill(' ') << ID << ' ';
237 msg << setw(8) << setfill(' ') << mother_ID << ' ';
238 msg << setw(8) << setfill(' ') << pdg << ' ';
239 if (verbose > 1) {
240 msg << setw(8) << setfill(' ') << Hits.size() << ' ';
241 msg << setw(8) << setfill(' ') << Points.size() << ' ';
242 msg << setw(8) << setfill(' ') << rTracks.size() << ' ';
243 if (verbose > 2) {
244 msg << setw(8) << setfill(' ') << tTracks.size() << ' ';
245 }
246 msg << setw(12) << setfill(' ') << z << ' ';
247 msg << setw(12) << setfill(' ') << time << ' ';
248 msg << setw(12) << setfill(' ') << p << ' ';
249 }
250 msg << setw(8) << setfill(' ') << IsReconstructable() << ' ';
251 msg << setw(8) << setfill(' ') << IsReconstructed() << ' ';
252 if (verbose > 1) {
253 msg << "\n\t- point indexes: ";
254 for (int index : Points) {
255 msg << index << ' ';
256 }
257 msg << "\n\t- hit indexes: ";
258 for (int index : Hits) {
259 msg << index << ' ';
260 }
261 msg << "\n\t- reconstructed track indexes: ";
262 for (auto* index : rTracks) {
263 msg << index << ' ';
264 }
265 if (verbose > 2) {
266 msg << "\n\t- touch track indexes: ";
267 for (auto* index : tTracks) {
268 msg << index << ' ';
269 }
270 }
271 }
272 }
273 }
274 return msg.str();
275}
Compile-time constants definition for the CA tracking algorithm.
A generic hit for the CA tracker (header)
Generates beam ions for transport simulation.
int iStation
index of station in active stations array
Definition CbmL1Hit.h:144
cacore::Vector< int > Hits
void CalculateIsReconstructable()
void CalculateMCCont()
cacore::Vector< int > Points
cacore::Vector< CbmL1Track * > rTracks
bool IsReconstructed() const
bool IsReconstructable() const
void CalculateMaxNStaMC()
cacore::Vector< CbmL1Track * > tTracks
bool isReconstructable
void CountHitStations()
CbmL1MCTrack()=default
std::string ToString(int verbose=10, bool header=false) const
String representation of the contents.
Definition CbmL1.h:109
static CbmL1 * Instance()
Pointer to CbmL1 instance.
Definition CbmL1.h:171
Int_t fPerformance
performance mode: 0 - w\o perf. 1 - L1-Efficiency definition. 2 - QA-Eff.definition
Definition CbmL1.h:443
ca::Framework * fpAlgo
Pointer to the L1 track finder algorithm.
Definition CbmL1.h:425
ca::Vector< CbmL1HitDebugInfo > fvHitDebugInfo
Container of hits with extended information.
Definition CbmL1.h:487
const cbm::ca::tools::MCData & GetMCData() const
Gets reference to MC data object.
Definition CbmL1.h:185
const Parameters< fvec > & GetParameters() const
Gets a pointer to the Framework parameters object.
Definition CaFramework.h:87
void push_back_no_warning(Tinput value)
Pushes back a value to the vector without testing for the memory re-alocation.
Definition CaVector.h:188
const auto & GetPoint(int idx) const
Gets a reference to MC point by its index.
const double MinRecoMom
Performance constants.
const int MinNStations
constexpr int MaxNstations
Max number of stations, 2^6 = 64.
Definition CaDefs.h:44