Adds hit, track and matching information for each event.
130{
131
133
134 recoToTruthMap::const_iterator imap;
135
137
141 int recoClassification = 0;
142 bool truth_missing=false;
143
148 std::bitset<Trk::TrackInfo::NumberOfTrackRecoInfo> reco_info;
149 std::bitset<Trk::TrackInfo::NumberOfTrackProperties> pattern_properties;
151
152
153 for (const Trk::Track* track : rec) {
154
156 recoClassification = -999;
157 int thisEventIndex = -999;
158
161 author_found[
Author] =
true;
162 reco_info |=
track->info().patternRecognition();
163 pattern_properties |=
track->info().properties();
164 }
165 else {
166
167 }
168 if (!para) {
170 }
171 else {
172 Eta = std::abs(para->
eta());
177 else Region = ETA_OUTSIDE;
178 }
179
181 {
182 continue;
183 }
184
185 TrackTruthCollection::const_iterator
found;
186 TrackTruth trtruth;
187 double trprob = 0;
188
189 if (!truthMap) {
190
191 truth_missing=true;
192 }
193 else {
194 ElementLink<TrackCollection> tracklink;
197 const ElementLink<TrackCollection> tracklink2=tracklink;
198
199 found = truthMap->find(tracklink2);
200 if(!(found == truthMap->end())){
201 trtruth=
found->second;
204 rttMap.insert(std::pair<HepMcParticleLink,float>(hmpl,trtruth.
probability()));
205
207 }
208
209 }
210
211
213
215 tracks.m_counter[
kTracks_rec][TRACK_ALL][ETA_ALL]++;
216
217 if (thisEventIndex==0)
218 {
220 tracks.m_counter[
kTracks_rec][TRACK_ALL_SIGNAL][ETA_ALL]++;
221 }
222
223
224
225 std::unique_ptr<Trk::TrackSummary> cleanup;
226 const Trk::TrackSummary*
summary =
track->trackSummary();
227
228 if (useTrackSummary) {
229 if (!
track->trackSummary()) {
230 cleanup = trkSummaryTool->
summary(*track);
232 }
233
235 }
236
237
238
239
240
241 if (!truthMap) {
242 truth_missing=true;
243 }
244 else {
245
246 if (found == truthMap->end()) {
247
248
250 tracks.m_counter[
kTracks_rec][TRACK_NOHEPMCPARTICLELINK][ETA_ALL]++;
252 }
253 else{
254
255
259 tracks.m_counter[
kTracks_rec][TRACK_NOHEPMCPARTICLELINK][ETA_ALL]++;
261 }
262 else {
263
264#ifdef HEPMC3
266#else
268#endif
270
271 if (trprob <
m_cuts.fakeTrackCut)
272 {
274 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB][ETA_ALL]++;
275 if (thisEventIndex==0)
276 {
278 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB_SIGNAL][ETA_ALL]++;
279 }
281 }
282 if (trprob <
m_cuts.fakeTrackCut2) {
284 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2][ETA_ALL]++;
285 if (thisEventIndex==0)
286 {
288 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2_SIGNAL][ETA_ALL]++;
289 }
291 }
292 }
293 }
294 }
295
296
297
298 EHitsCounter part_type = ( recoClassification==TRACK_PRIMARY
300 : ( recoClassification==TRACK_SECONDARY
303 for (
const Trk::TrackStateOnSurface* hit : *
track->trackStateOnSurfaces()) {
304 if(hit){
305 const Trk::MeasurementBase* mesh =hit->measurementOnTrack();
306 if (mesh) {
307 const Trk::RIO_OnTrack* rio{} ;
309 assert(dynamic_cast<const Trk::RIO_OnTrack*>(mesh)!=nullptr);
310 rio = static_cast<const Trk::RIO_OnTrack*>(mesh);
311 } else {
312
314 assert(dynamic_cast<const Trk::CompetingRIOsOnTrack*>(mesh) !=nullptr);
315 auto comprot = static_cast<const Trk::CompetingRIOsOnTrack*>(mesh);
316 rio = &comprot->rioOnTrack(comprot->indexOfMaxAssignProb());
317 }
318 }
319
320
321 if (rio) {
322
324 continue;
325
330 hits.m_counter[part_type][HIT_ALL][ETA_ALL]++;
331 }
332
334 int HitDet = HIT_UNKNOWN;
335 int HitLayer = N_HITTYPES;
336 bool part_type_for_all=true;
337 if (idHelper->
is_trt(
id)){
338 HitDet=HIT_TRT_ALL;
339 }
340 else if (idHelper->
is_sct(
id)){
341 HitDet=HIT_SCT_ALL;
342 if (sctID) {
344 case 0: HitLayer = HIT_SCT1; break;
345 case 1: HitLayer = HIT_SCT2; break;
346 case 2: HitLayer = HIT_SCT3; break;
347 case 3: HitLayer = HIT_SCT4; break;
348 case 4: case 5: case 6: case 7: case 8: HitLayer = HIT_SCT5TO9; break;
349 default: HitLayer = HIT_UNKNOWN; break;
350 }
351 }
352 }
354 part_type_for_all=false;
355 HitDet = HIT_PIXEL_ALL;
356 if (pixelID) {
358 case 0: HitLayer = HIT_PIX1; break;
359 case 1: HitLayer = HIT_PIX2; break;
360 case 2: HitLayer = HIT_PIX3; break;
361 default: HitLayer = HIT_UNKNOWN;
362 }
363 }
364 }
365
370 hits.m_counter[part_type][HitDet][ETA_ALL]++;
371 }
372
373 if (HitLayer<N_HITTYPES) {
377 hits.m_counter[part_type][HitLayer][
Region]++;
378 hits.m_counter[part_type][HitLayer][ETA_ALL]++;
379 }
380 }
381 }
382 }
383 }
384 }
385 }
386
387
388
391 int classification=-999;
392 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth) {
393 classification=-999;
394 bool inTimePileup = truth->second == 0 || (truth->second >= (
int)*inTimeStart && truth->second <= (
int)*inTimeEnd);
395
397
398
399 Eta = std::abs(
particle->momentum().pseudoRapidity());
404 else Region = ETA_OUTSIDE;
406 {
407 continue;
408 }
410 tracks.m_counter[
kTracks_gen][TRACK_ALL][ETA_ALL] ++;
411 if (inTimePileup) tracks.m_counter[
kTracks_gen][TRACK_ALL_SIGNAL][ETA_ALL]++;
413
414
416
417 if(classification==TRACK_PRIMARY){
418 tracks.m_counter[
kTracks_gen][TRACK_PRIMARY][ETA_ALL] ++;
420 }
421 if(classification==TRACK_SECONDARY){
422 tracks.m_counter[
kTracks_gen][TRACK_SECONDARY][ETA_ALL] ++;
424 }
425
426
427 bool matched = false;
428 int nmatched = 0;
429
431 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
432 if(rttIter != rttMap.end()){
433 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
434 if(imap->second >
m_cuts.matchTrackCut){
435 matched = true;
436 nmatched++;
437 }
438 }
439 }
440 if (matched) {
442 tracks.m_counter[
kTracks_gen][TRACK_MATCHED][ETA_ALL]++;
443 if (inTimePileup)
444 {
446 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SIGNAL][ETA_ALL]++;
447 }
448 if(nmatched > 1){
450 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH][ETA_ALL]+= nmatched-1;
451 }
452 if(classification==TRACK_PRIMARY){
454 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_PRIMARY][ETA_ALL]++;
455 if(nmatched > 1){
457 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_PRIMARY][ETA_ALL] += nmatched-1;
458 }
459 }
460 if(classification==TRACK_SECONDARY){
462 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SECONDARY][ETA_ALL]++;
463 if(nmatched > 1){
465 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
466 }
467 }
468 }
469 }
470
471
472
473
476 classification=-999;
477
478 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth)
479 {
480 if (truth->second != 0)
481 continue;
482
483 classification=-999;
484
486
487
488 Eta = std::abs(
particle->momentum().pseudoRapidity());
493 else Region = ETA_OUTSIDE;
495 {
496 continue;
497 }
500
501
503
504 if(classification==TRACK_PRIMARY){
507 }
508 if(classification==TRACK_SECONDARY){
511 }
512
513
514 bool matched = false;
515 int nmatched = 0;
516
518 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
519 if(rttIter != rttMap.end()){
520 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
521 if(imap->second >
m_cuts.matchTrackCut){
522 matched = true;
523 nmatched++;
524 }
525 }
526 }
527 if (matched) {
530 if(nmatched > 1){
533 }
534 if(classification==TRACK_PRIMARY){
537 if(nmatched > 1){
540 }
541 }
542 if(classification==TRACK_SECONDARY){
545 if(nmatched > 1){
547 tracks.m_counter[
kTracks_gen_signal][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
548 }
549 }
550 }
551 }
552
553 if (truth_missing) {
555 }
556 m_tracks += tracks;
558 m_trackSummarySum += trackSummarySum;
560 if (author_found[i]) {
562 }
563 }
564 {
566 m_recoInfo |= reco_info;
567 m_patternProperties |= pattern_properties;
568 }
569}
bool is_sct(Identifier id) const
bool is_pixel(Identifier id) const
bool is_trt(Identifier id) const
bool setElement(ElementType element)
Set to point to an element.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
bool isValid() const
Validity check.
HepMC::ConstGenParticlePtr cptr() const
Dereference.
HepMC::ConstGenParticlePtr scptr() const
Dereference/smart pointer.
index_type eventIndex() const
Return the event number of the referenced GenEvent.
Counter4D< kNTrackSummaryCounter, N_TRACKTYPES, N_ETAREGIONS, kNSummaryTypes, int > TrackSummaryCounter
type statistics.
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.
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.
const GenParticle * ConstGenParticlePtr
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
ParametersBase< TrackParametersDim, Charged > TrackParameters