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
265#ifdef HEPMC3
267#else
269#endif
271
272 if (trprob <
m_cuts.fakeTrackCut)
273 {
275 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB][ETA_ALL]++;
276 if (thisEventIndex==0)
277 {
279 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB_SIGNAL][ETA_ALL]++;
280 }
282 }
283 if (trprob <
m_cuts.fakeTrackCut2) {
285 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2][ETA_ALL]++;
286 if (thisEventIndex==0)
287 {
289 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2_SIGNAL][ETA_ALL]++;
290 }
292 }
293 }
294 }
295 }
296
297
298
299 EHitsCounter part_type = ( recoClassification==TRACK_PRIMARY
301 : ( recoClassification==TRACK_SECONDARY
304 for (
const Trk::TrackStateOnSurface* hit : *
track->trackStateOnSurfaces()) {
305 if(hit){
306 const Trk::MeasurementBase* mesh =hit->measurementOnTrack();
307 if (mesh) {
308 const Trk::RIO_OnTrack* rio{} ;
310 assert(dynamic_cast<const Trk::RIO_OnTrack*>(mesh)!=nullptr);
311 rio = static_cast<const Trk::RIO_OnTrack*>(mesh);
312 } else {
313
315 assert(dynamic_cast<const Trk::CompetingRIOsOnTrack*>(mesh) !=nullptr);
316 auto comprot = static_cast<const Trk::CompetingRIOsOnTrack*>(mesh);
317 rio = &comprot->rioOnTrack(comprot->indexOfMaxAssignProb());
318 }
319 }
320
321
322 if (rio) {
323
325 continue;
326
331 hits.m_counter[part_type][HIT_ALL][ETA_ALL]++;
332 }
333
335 int HitDet = HIT_UNKNOWN;
336 int HitLayer = N_HITTYPES;
337 bool part_type_for_all=true;
338 if (idHelper->
is_trt(
id)){
339 HitDet=HIT_TRT_ALL;
340 }
341 else if (idHelper->
is_sct(
id)){
342 HitDet=HIT_SCT_ALL;
343 if (sctID) {
345 case 0: HitLayer = HIT_SCT1; break;
346 case 1: HitLayer = HIT_SCT2; break;
347 case 2: HitLayer = HIT_SCT3; break;
348 case 3: HitLayer = HIT_SCT4; break;
349 case 4: case 5: case 6: case 7: case 8: HitLayer = HIT_SCT5TO9; break;
350 default: HitLayer = HIT_UNKNOWN; break;
351 }
352 }
353 }
355 part_type_for_all=false;
356 HitDet = HIT_PIXEL_ALL;
357 if (pixelID) {
359 case 0: HitLayer = HIT_PIX1; break;
360 case 1: HitLayer = HIT_PIX2; break;
361 case 2: HitLayer = HIT_PIX3; break;
362 default: HitLayer = HIT_UNKNOWN;
363 }
364 }
365 }
366
371 hits.m_counter[part_type][HitDet][ETA_ALL]++;
372 }
373
374 if (HitLayer<N_HITTYPES) {
378 hits.m_counter[part_type][HitLayer][
Region]++;
379 hits.m_counter[part_type][HitLayer][ETA_ALL]++;
380 }
381 }
382 }
383 }
384 }
385 }
386 }
387
388
389
392 int classification=-999;
393 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth) {
394 classification=-999;
395 bool inTimePileup = truth->second == 0 || (truth->second >= (
int)*inTimeStart && truth->second <= (
int)*inTimeEnd);
396
398
399
400 Eta = std::abs(
particle->momentum().pseudoRapidity());
405 else Region = ETA_OUTSIDE;
407 {
408 continue;
409 }
411 tracks.m_counter[
kTracks_gen][TRACK_ALL][ETA_ALL] ++;
412 if (inTimePileup) tracks.m_counter[
kTracks_gen][TRACK_ALL_SIGNAL][ETA_ALL]++;
414
415
417
418 if(classification==TRACK_PRIMARY){
419 tracks.m_counter[
kTracks_gen][TRACK_PRIMARY][ETA_ALL] ++;
421 }
422 if(classification==TRACK_SECONDARY){
423 tracks.m_counter[
kTracks_gen][TRACK_SECONDARY][ETA_ALL] ++;
425 }
426
427
428 bool matched = false;
429 int nmatched = 0;
430
432 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
433 if(rttIter != rttMap.end()){
434 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
435 if(imap->second >
m_cuts.matchTrackCut){
436 matched = true;
437 nmatched++;
438 }
439 }
440 }
441 if (matched) {
443 tracks.m_counter[
kTracks_gen][TRACK_MATCHED][ETA_ALL]++;
444 if (inTimePileup)
445 {
447 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SIGNAL][ETA_ALL]++;
448 }
449 if(nmatched > 1){
451 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH][ETA_ALL]+= nmatched-1;
452 }
453 if(classification==TRACK_PRIMARY){
455 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_PRIMARY][ETA_ALL]++;
456 if(nmatched > 1){
458 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_PRIMARY][ETA_ALL] += nmatched-1;
459 }
460 }
461 if(classification==TRACK_SECONDARY){
463 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SECONDARY][ETA_ALL]++;
464 if(nmatched > 1){
466 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
467 }
468 }
469 }
470 }
471
472
473
474
477 classification=-999;
478
479 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth)
480 {
481 if (truth->second != 0)
482 continue;
483
484 classification=-999;
485
487
488
489 Eta = std::abs(
particle->momentum().pseudoRapidity());
494 else Region = ETA_OUTSIDE;
496 {
497 continue;
498 }
501
502
504
505 if(classification==TRACK_PRIMARY){
508 }
509 if(classification==TRACK_SECONDARY){
512 }
513
514
515 bool matched = false;
516 int nmatched = 0;
517
519 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
520 if(rttIter != rttMap.end()){
521 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
522 if(imap->second >
m_cuts.matchTrackCut){
523 matched = true;
524 nmatched++;
525 }
526 }
527 }
528 if (matched) {
531 if(nmatched > 1){
534 }
535 if(classification==TRACK_PRIMARY){
538 if(nmatched > 1){
541 }
542 }
543 if(classification==TRACK_SECONDARY){
546 if(nmatched > 1){
548 tracks.m_counter[
kTracks_gen_signal][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
549 }
550 }
551 }
552 }
553
554 if (truth_missing) {
556 }
557 m_tracks += tracks;
559 m_trackSummarySum += trackSummarySum;
561 if (author_found[i]) {
563 }
564 }
565 {
567 m_recoInfo |= reco_info;
568 m_patternProperties |= pattern_properties;
569 }
570}
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 cptr() const
Dereference.
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.
const GenParticle * ConstGenParticlePtr
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
ParametersBase< TrackParametersDim, Charged > TrackParameters