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
146
147
150 std::bitset<Trk::TrackInfo::NumberOfTrackRecoInfo> reco_info;
151 std::bitset<Trk::TrackInfo::NumberOfTrackProperties> pattern_properties;
153
154
155 for (const Trk::Track* track : rec) {
156
158 recoClassification = -999;
159 int thisEventIndex = -999;
160
163 author_found[
Author] =
true;
164 reco_info |=
track->info().patternRecognition();
165 pattern_properties |=
track->info().properties();
166 }
167 else {
168
169 }
170 if (!para) {
172 }
173 else {
174 Eta = std::abs(para->
eta());
179 else Region = ETA_OUTSIDE;
180 }
181
183 {
184 continue;
185 }
186
187 TrackTruthCollection::const_iterator
found;
188 TrackTruth trtruth;
189 double trprob = 0;
190
191 if (!truthMap) {
192
193 truth_missing=true;
194 }
195 else {
196 ElementLink<TrackCollection> tracklink;
199 const ElementLink<TrackCollection> tracklink2=tracklink;
200
201 found = truthMap->find(tracklink2);
202 if(!(found == truthMap->end())){
203 trtruth=
found->second;
206 rttMap.insert(std::pair<HepMcParticleLink,float>(hmpl,trtruth.
probability()));
207
209 }
210
211 }
212
213
215
217 tracks.m_counter[
kTracks_rec][TRACK_ALL][ETA_ALL]++;
218
219 if (thisEventIndex==0)
220 {
222 tracks.m_counter[
kTracks_rec][TRACK_ALL_SIGNAL][ETA_ALL]++;
223 }
224
225
226
227 std::unique_ptr<Trk::TrackSummary> cleanup;
228 const Trk::TrackSummary*
summary =
track->trackSummary();
229
230 if (useTrackSummary) {
231 if (!
track->trackSummary()) {
232 cleanup = trkSummaryTool->
summary(ctx, *track);
234 }
235
237 }
238
239
240
241
242
243 if (!truthMap) {
244 truth_missing=true;
245 }
246 else {
247
248 if (found == truthMap->end()) {
249
250
252 tracks.m_counter[
kTracks_rec][TRACK_NOHEPMCPARTICLELINK][ETA_ALL]++;
254 }
255 else{
256
257
261 tracks.m_counter[
kTracks_rec][TRACK_NOHEPMCPARTICLELINK][ETA_ALL]++;
263 }
264 else {
265
268
269 if (trprob <
m_cuts.fakeTrackCut)
270 {
272 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB][ETA_ALL]++;
273 if (thisEventIndex==0)
274 {
276 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB_SIGNAL][ETA_ALL]++;
277 }
279 }
280 if (trprob <
m_cuts.fakeTrackCut2) {
282 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2][ETA_ALL]++;
283 if (thisEventIndex==0)
284 {
286 tracks.m_counter[
kTracks_rec][TRACK_LOWTRUTHPROB2_SIGNAL][ETA_ALL]++;
287 }
289 }
290 }
291 }
292 }
293
294
295
296 EHitsCounter part_type = ( recoClassification==TRACK_PRIMARY
298 : ( recoClassification==TRACK_SECONDARY
301 for (
const Trk::TrackStateOnSurface* hit : *
track->trackStateOnSurfaces()) {
302 if(hit){
303 const Trk::MeasurementBase* mesh =hit->measurementOnTrack();
304 if (mesh) {
305 const Trk::RIO_OnTrack* rio{} ;
307 assert(dynamic_cast<const Trk::RIO_OnTrack*>(mesh)!=nullptr);
308 rio = static_cast<const Trk::RIO_OnTrack*>(mesh);
309 } else {
310
312 assert(dynamic_cast<const Trk::CompetingRIOsOnTrack*>(mesh) !=nullptr);
313 auto comprot = static_cast<const Trk::CompetingRIOsOnTrack*>(mesh);
314 rio = &comprot->rioOnTrack(comprot->indexOfMaxAssignProb());
315 }
316 }
317
318
319 if (rio) {
320
322 continue;
323
328 hits.m_counter[part_type][HIT_ALL][ETA_ALL]++;
329 }
330
332 int HitDet = HIT_UNKNOWN;
333 int HitLayer = N_HITTYPES;
334 bool part_type_for_all=true;
335 if (idHelper->
is_trt(
id)){
336 HitDet=HIT_TRT_ALL;
337 }
338 else if (idHelper->
is_sct(
id)){
339 HitDet=HIT_SCT_ALL;
340 if (sctID) {
342 case 0: HitLayer = HIT_SCT1; break;
343 case 1: HitLayer = HIT_SCT2; break;
344 case 2: HitLayer = HIT_SCT3; break;
345 case 3: HitLayer = HIT_SCT4; break;
346 case 4: case 5: case 6: case 7: case 8: HitLayer = HIT_SCT5TO9; break;
347 default: HitLayer = HIT_UNKNOWN; break;
348 }
349 }
350 }
352 part_type_for_all=false;
353 HitDet = HIT_PIXEL_ALL;
354 if (pixelID) {
356 case 0: HitLayer = HIT_PIX1; break;
357 case 1: HitLayer = HIT_PIX2; break;
358 case 2: HitLayer = HIT_PIX3; break;
359 default: HitLayer = HIT_UNKNOWN;
360 }
361 }
362 }
363
368 hits.m_counter[part_type][HitDet][ETA_ALL]++;
369 }
370
371 if (HitLayer<N_HITTYPES) {
375 hits.m_counter[part_type][HitLayer][
Region]++;
376 hits.m_counter[part_type][HitLayer][ETA_ALL]++;
377 }
378 }
379 }
380 }
381 }
382 }
383 }
384
385
386
389 int classification=-999;
390 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth) {
391 classification=-999;
392 bool inTimePileup = truth->second == 0 || (truth->second >= (
int)*inTimeStart && truth->second <= (
int)*inTimeEnd);
393
395
396
397 Eta = std::abs(
particle->momentum().pseudoRapidity());
402 else Region = ETA_OUTSIDE;
404 {
405 continue;
406 }
408 tracks.m_counter[
kTracks_gen][TRACK_ALL][ETA_ALL] ++;
409 if (inTimePileup) tracks.m_counter[
kTracks_gen][TRACK_ALL_SIGNAL][ETA_ALL]++;
411
412
414
415 if(classification==TRACK_PRIMARY){
416 tracks.m_counter[
kTracks_gen][TRACK_PRIMARY][ETA_ALL] ++;
418 }
419 if(classification==TRACK_SECONDARY){
420 tracks.m_counter[
kTracks_gen][TRACK_SECONDARY][ETA_ALL] ++;
422 }
423
424
425 bool matched = false;
426 int nmatched = 0;
427
429 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
430 if(rttIter != rttMap.end()){
431 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
432 if(imap->second >
m_cuts.matchTrackCut){
433 matched = true;
434 nmatched++;
435 }
436 }
437 }
438 if (matched) {
440 tracks.m_counter[
kTracks_gen][TRACK_MATCHED][ETA_ALL]++;
441 if (inTimePileup)
442 {
444 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SIGNAL][ETA_ALL]++;
445 }
446 if(nmatched > 1){
448 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH][ETA_ALL]+= nmatched-1;
449 }
450 if(classification==TRACK_PRIMARY){
452 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_PRIMARY][ETA_ALL]++;
453 if(nmatched > 1){
455 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_PRIMARY][ETA_ALL] += nmatched-1;
456 }
457 }
458 if(classification==TRACK_SECONDARY){
460 tracks.m_counter[
kTracks_gen][TRACK_MATCHED_SECONDARY][ETA_ALL]++;
461 if(nmatched > 1){
463 tracks.m_counter[
kTracks_gen][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
464 }
465 }
466 }
467 }
468
469
470
471
474 classification=-999;
475
476 for (
auto truth =
gen.begin(); truth !=
gen.end(); ++truth)
477 {
478 if (truth->second != 0)
479 continue;
480
481 classification=-999;
482
484
485
486 Eta = std::abs(
particle->momentum().pseudoRapidity());
491 else Region = ETA_OUTSIDE;
493 {
494 continue;
495 }
498
499
501
502 if(classification==TRACK_PRIMARY){
505 }
506 if(classification==TRACK_SECONDARY){
509 }
510
511
512 bool matched = false;
513 int nmatched = 0;
514
516 recoToTruthMap::iterator rttIter=rttMap.find(hmpl2);
517 if(rttIter != rttMap.end()){
518 for(imap = rttMap.lower_bound(hmpl2); imap !=rttMap.upper_bound(hmpl2); ++imap){
519 if(imap->second >
m_cuts.matchTrackCut){
520 matched = true;
521 nmatched++;
522 }
523 }
524 }
525 if (matched) {
528 if(nmatched > 1){
531 }
532 if(classification==TRACK_PRIMARY){
535 if(nmatched > 1){
538 }
539 }
540 if(classification==TRACK_SECONDARY){
543 if(nmatched > 1){
545 tracks.m_counter[
kTracks_gen_signal][TRACK_MULTMATCH_SECONDARY][ETA_ALL] += nmatched-1;
546 }
547 }
548 }
549 }
550
551 if (truth_missing) {
553 }
554 m_tracks += tracks;
556 m_trackSummarySum += trackSummarySum;
558 if (author_found[i]) {
560 }
561 }
562 {
564 m_recoInfo |= reco_info;
565 m_patternProperties |= pattern_properties;
566 }
567}
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