Adds hit, track and matching information for each event.
131{
132
134
135 recoToTruthMap::const_iterator imap;
136
138
142 int recoClassification = 0;
143 bool truth_missing=false;
144
149 std::bitset<Trk::TrackInfo::NumberOfTrackRecoInfo> reco_info;
150 std::bitset<Trk::TrackInfo::NumberOfTrackProperties> pattern_properties;
152
153
154 for (const Trk::Track* track : rec) {
155
157 recoClassification = -999;
158 int thisEventIndex = -999;
159
162 author_found[
Author] =
true;
163 reco_info |=
track->info().patternRecognition();
164 pattern_properties |=
track->info().properties();
165 }
166 else {
167
168 }
169 if (!para) {
171 }
172 else {
173 Eta = std::abs(para->
eta());
178 else Region = ETA_OUTSIDE;
179 }
180
182 {
183 continue;
184 }
185
186 TrackTruthCollection::const_iterator
found;
187 TrackTruth trtruth;
188 double trprob = 0;
189
190 if (!truthMap) {
191
192 truth_missing=true;
193 }
194 else {
195 ElementLink<TrackCollection> tracklink;
198 const ElementLink<TrackCollection> tracklink2=tracklink;
199
200 found = truthMap->find(tracklink2);
201 if(!(found == truthMap->end())){
202 trtruth=
found->second;
205 rttMap.insert(std::pair<HepMcParticleLink,float>(hmpl,trtruth.
probability()));
206
208 }
209
210 }
211
212
214
216 tracks.m_counter[
kTracks_rec][TRACK_ALL][ETA_ALL]++;
217
218 if (thisEventIndex==0)
219 {
221 tracks.m_counter[
kTracks_rec][TRACK_ALL_SIGNAL][ETA_ALL]++;
222 }
223
224
225
226 std::unique_ptr<Trk::TrackSummary> cleanup;
227 const Trk::TrackSummary*
summary =
track->trackSummary();
228
229 if (useTrackSummary) {
230 if (!
track->trackSummary()) {
231 cleanup = trkSummaryTool->
summary(ctx, *track);
233 }
234
236 }
237
238
239
240
241
242 if (!truthMap) {
243 truth_missing=true;
244 }
245 else {
246
247 if (found == truthMap->end()) {
248
249
251 tracks.m_counter[
kTracks_rec][TRACK_NOHEPMCPARTICLELINK][ETA_ALL]++;
253 }
254 else{
255
256
260 tracks.m_counter[
kTracks_rec][TRACK_NOHEPMCPARTICLELINK][ETA_ALL]++;
262 }
263 else {
264
267
268 if (trprob <
m_cuts.fakeTrackCut)
269 {
271 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB][ETA_ALL]++;
272 if (thisEventIndex==0)
273 {
275 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB_SIGNAL][ETA_ALL]++;
276 }
278 }
279 if (trprob <
m_cuts.fakeTrackCut2) {
281 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2][ETA_ALL]++;
282 if (thisEventIndex==0)
283 {
285 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2_SIGNAL][ETA_ALL]++;
286 }
288 }
289 }
290 }
291 }
292
293
294
295 EHitsCounter part_type = ( recoClassification==TRACK_PRIMARY
297 : ( recoClassification==TRACK_SECONDARY
300 for (
const Trk::TrackStateOnSurface* hit : *
track->trackStateOnSurfaces()) {
301 if(hit){
302 const Trk::MeasurementBase* mesh =hit->measurementOnTrack();
303 if (mesh) {
304 const Trk::RIO_OnTrack* rio{} ;
306 assert(dynamic_cast<const Trk::RIO_OnTrack*>(mesh)!=nullptr);
307 rio = static_cast<const Trk::RIO_OnTrack*>(mesh);
308 } else {
309
311 assert(dynamic_cast<const Trk::CompetingRIOsOnTrack*>(mesh) !=nullptr);
312 auto comprot = static_cast<const Trk::CompetingRIOsOnTrack*>(mesh);
313 rio = &comprot->rioOnTrack(comprot->indexOfMaxAssignProb());
314 }
315 }
316
317
318 if (rio) {
319
321 continue;
322
327 hits.m_counter[part_type][HIT_ALL][ETA_ALL]++;
328 }
329
331 int HitDet = HIT_UNKNOWN;
332 int HitLayer = N_HITTYPES;
333 bool part_type_for_all=true;
334 if (idHelper->
is_trt(
id)){
335 HitDet=HIT_TRT_ALL;
336 }
337 else if (idHelper->
is_sct(
id)){
338 HitDet=HIT_SCT_ALL;
339 if (sctID) {
341 case 0: HitLayer = HIT_SCT1; break;
342 case 1: HitLayer = HIT_SCT2; break;
343 case 2: HitLayer = HIT_SCT3; break;
344 case 3: HitLayer = HIT_SCT4; break;
345 case 4: case 5: case 6: case 7: case 8: HitLayer = HIT_SCT5TO9; break;
346 default: HitLayer = HIT_UNKNOWN; break;
347 }
348 }
349 }
351 part_type_for_all=false;
352 HitDet = HIT_PIXEL_ALL;
353 if (pixelID) {
355 case 0: HitLayer = HIT_PIX1; break;
356 case 1: HitLayer = HIT_PIX2; break;
357 case 2: HitLayer = HIT_PIX3; break;
358 default: HitLayer = HIT_UNKNOWN;
359 }
360 }
361 }
362
367 hits.m_counter[part_type][HitDet][ETA_ALL]++;
368 }
369
370 if (HitLayer<N_HITTYPES) {
374 hits.m_counter[part_type][HitLayer][
Region]++;
375 hits.m_counter[part_type][HitLayer][ETA_ALL]++;
376 }
377 }
378 }
379 }
380 }
381 }
382 }
383
384
385
388 int classification=-999;
389 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth) {
390 classification=-999;
391 bool inTimePileup = truth->second == 0 || (truth->second >= (
int)*inTimeStart && truth->second <= (
int)*inTimeEnd);
392
394
395
396 Eta = std::abs(
particle->momentum().pseudoRapidity());
401 else Region = ETA_OUTSIDE;
403 {
404 continue;
405 }
407 tracks.m_counter[
kTracks_gen][TRACK_ALL][ETA_ALL] ++;
408 if (inTimePileup) tracks.m_counter[
kTracks_gen][TRACK_ALL_SIGNAL][ETA_ALL]++;
410
411
413
414 if(classification==TRACK_PRIMARY){
415 tracks.m_counter[
kTracks_gen][TRACK_PRIMARY][ETA_ALL] ++;
417 }
418 if(classification==TRACK_SECONDARY){
419 tracks.m_counter[
kTracks_gen][TRACK_SECONDARY][ETA_ALL] ++;
421 }
422
423
424 bool matched = false;
425 int nmatched = 0;
426
428 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
429 if(rttIter != rttMap.end()){
430 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
431 if(imap->second >
m_cuts.matchTrackCut){
432 matched = true;
433 nmatched++;
434 }
435 }
436 }
437 if (matched) {
439 tracks.m_counter[
kTracks_gen][TRACK_MATCHED][ETA_ALL]++;
440 if (inTimePileup)
441 {
443 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SIGNAL][ETA_ALL]++;
444 }
445 if(nmatched > 1){
447 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH][ETA_ALL]+= nmatched-1;
448 }
449 if(classification==TRACK_PRIMARY){
451 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_PRIMARY][ETA_ALL]++;
452 if(nmatched > 1){
454 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_PRIMARY][ETA_ALL] += nmatched-1;
455 }
456 }
457 if(classification==TRACK_SECONDARY){
459 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SECONDARY][ETA_ALL]++;
460 if(nmatched > 1){
462 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
463 }
464 }
465 }
466 }
467
468
469
470
473 classification=-999;
474
475 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth)
476 {
477 if (truth->second != 0)
478 continue;
479
480 classification=-999;
481
483
484
485 Eta = std::abs(
particle->momentum().pseudoRapidity());
490 else Region = ETA_OUTSIDE;
492 {
493 continue;
494 }
497
498
500
501 if(classification==TRACK_PRIMARY){
504 }
505 if(classification==TRACK_SECONDARY){
508 }
509
510
511 bool matched = false;
512 int nmatched = 0;
513
515 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
516 if(rttIter != rttMap.end()){
517 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
518 if(imap->second >
m_cuts.matchTrackCut){
519 matched = true;
520 nmatched++;
521 }
522 }
523 }
524 if (matched) {
527 if(nmatched > 1){
530 }
531 if(classification==TRACK_PRIMARY){
534 if(nmatched > 1){
537 }
538 }
539 if(classification==TRACK_SECONDARY){
542 if(nmatched > 1){
544 tracks.m_counter[
kTracks_gen_signal][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
545 }
546 }
547 }
548 }
549
550 if (truth_missing) {
552 }
553 m_tracks += tracks;
555 m_trackSummarySum += trackSummarySum;
557 if (author_found[i]) {
559 }
560 }
561 {
563 m_recoInfo |= reco_info;
564 m_patternProperties |= pattern_properties;
565 }
566}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
bool is_sct(Identifier id) const
bool is_pixel(Identifier id) const
bool is_trt(Identifier id) const
bool setElement(ElementType element)
Set link to point to an Element (slowest).
bool setStorableObject(BaseConstReference data, bool replace=false)
Set link storable to data object pointed by data (slower).
bool isValid() const
Validity check.
HepMC::ConstGenParticlePtr scptr() const
Dereference/smart pointer.
index_type eventIndex() const
Return the event number of the referenced GenEvent.
bool PassTrackCuts(const Trk::TrackParameters *para) const
defines 'good' reco tracks
std::atomic< bool > m_author_found[Trk::TrackInfo::NumberOfTrackFitters]
Number of tracking authors found.
Counter4D< kNTrackSummaryCounter, N_TRACKTYPES, N_ETAREGIONS, kNSummaryTypes, int > TrackSummaryCounter
type statistics.
std::multimap< HepMcParticleLink, float > recoToTruthMap
map containing reco track and matched truth track barcode
Counter< kNTracksCounter, N_TRACKTYPES, N_ETAREGIONS, int > TracksCounter
void setSummaryStat(track_types track_i, eta_region region_i, const Trk::TrackSummary *summary, TrackSummaryCounter &trackSummarySum) const
int ClassifyParticle(const HepMC::ConstGenParticlePtr &particle, const double prob) const
classifies gen particle as primary, secondary or truncated
Counter< kNHitsCounter, N_HITTYPES, N_ETAREGIONS, int > HitsCounter
std::atomic< long > m_events
Number of events.
int layer_disk(const Identifier &id) const
int layer_disk(const Identifier &id) const
float probability() const
const HepMcParticleLink & particleLink() const
virtual bool type(MeasurementBaseType::Type type) const =0
Interface method checking the type.
double eta() const
Access method for pseudorapidity - from momentum.
Identifier identify() const
return the identifier -extends MeasurementBase
@ NumberOfTrackFitters
maximum number of enums
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
ParametersBase< TrackParametersDim, Charged > TrackParameters