ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPhysValMonitoringTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10#include "GaudiKernel/SystemOfUnits.h"
11
14#include "InDetRttPlots.h"
17#include "CachedGetAssocTruth.h"
18
19#include "safeDecorator.h"
20//
31
33//
34#include <algorithm>
35#include <limits>
36#include <cmath> // to get std::isnan(), std::abs etc.
37// #include <functional> // to get std::plus
38#include <utility>
39#include <cstdlib> // to getenv
40#include <vector>
41
43
44namespace { // utility functions used here
45
46 // get truth/track matching probability
47 float
48 getMatchingProbability(const xAOD::TrackParticle& trackParticle) {
49 float result(std::numeric_limits<float>::quiet_NaN());
50
51 static const SG::ConstAccessor<float> truthMatchProbabilityAcc("truthMatchProbability");
52 if (truthMatchProbabilityAcc.isAvailable(trackParticle)) {
53 result = truthMatchProbabilityAcc(trackParticle);
54 }
55 return result;
56 }
57
58 template <class T>
59 inline float
60 safelyGetEta(const T& pTrk, const float safePtThreshold = 0.1) {
61 return (pTrk->pt() > safePtThreshold) ? (pTrk->eta()) : std::nan("");
62 }
63
64 // general utility function to check value is in range
65 template <class T>
66 inline bool
67 inRange(const T& value, const T& minVal, const T& maxVal) {
68 return not ((value < minVal)or(value > maxVal));
69 }
70
71 template<class T>
72 inline bool
73 inRange(const T& value, const T& absoluteMax) {
74 return not (std::abs(value) > absoluteMax);
75 }
76
77 // Cuts on various objects
78
79 // general utility function to return bin index given a value and the upper endpoints of each bin
80 template <class T>
81 unsigned int
82 binIndex(const T& val, const std::vector<T>& partitions) {// signature should allow other containers
83 unsigned int i(0);
84 bool nf = true;
85
86 while (nf and i != partitions.size()) {
87 nf = (val > partitions[i++]);
88 }
89 return nf ? i : i - 1;
90 }
91
92 bool
93 acceptTruthVertex(const xAOD::TruthVertex* vtx) {
94 const float x(vtx->x()), y(vtx->y()), z(vtx->z());
95 const float vrtR2 = (x * x + y * y); // radial distance squared
96
97 return inRange(z, 500.f) and not (vrtR2 > 1); // units?
98 }
99
100 const std::vector<float> ETA_PARTITIONS = {
101 2.7, 3.5, std::numeric_limits<float>::infinity()
102 };
103
104}// namespace
105
107InDetPhysValMonitoringTool::InDetPhysValMonitoringTool(const std::string& type, const std::string& name,
108 const IInterface* parent) :
109 ManagedMonitorToolBase(type, name, parent){
110}
111
113
114StatusCode
117 // Get the track selector tool only if m_useTrackSelection is true;
118 // first check for consistency i.e. that there is a trackSelectionTool if you ask
119 // for trackSelection
120 ATH_CHECK(m_trackSelectionTool.retrieve(EnableTool {m_useTrackSelection} ));
121 ATH_CHECK(m_truthSelectionTool.retrieve(EnableTool {not m_truthParticleName.key().empty()} ));
122 ATH_CHECK(m_vtxValidTool.retrieve(EnableTool {m_useVertexTruthMatchTool}));
123 ATH_CHECK(m_trackTruthOriginTool.retrieve( EnableTool {m_doTruthOriginPlots} ));
124
125 ATH_CHECK(m_hardScatterSelectionTool.retrieve(EnableTool
126 {not m_vertexContainerName.key().empty() &&
127 not m_hardScatterSelectionTool.empty()}));
128
129 ATH_CHECK(m_grlTool.retrieve(EnableTool{m_useGRL}));
130
131 ATH_MSG_DEBUG("m_useVertexTruthMatchTool ====== " <<m_useVertexTruthMatchTool);
132 if (m_truthSelectionTool.get() ) {
133 m_truthCutFlow = CutFlow(m_truthSelectionTool->nCuts());
134 }
135
136 m_monPlots = std::make_unique<InDetRttPlots>
137 (nullptr, static_cast<std::string>(m_dirName) + static_cast<std::string>(m_folder),
138 getFilledPlotConfig()); // m_detailLevel := DEBUG, enable expert histograms
139
140 ATH_CHECK( m_trkParticleName.initialize() );
141 ATH_CHECK( m_truthParticleName.initialize( (m_pileupSwitch == "HardScatter" or m_pileupSwitch == "All") and not m_truthParticleName.key().empty() ) );
142 if (not m_truthParticleName.key().empty()) {
143 // create decor handle keys for truth particle decorations which are needed by CachedGetAssocTruth
144 // The existence of the handles is good enough to ensure that data dependencies are propagated
145 // and that the decorations exist when this tool is being called. Albeit not very elegant
146 // there is no need to create decor handles for the keys and use those instead of static
147 // accessors. To keep changes minimal the original static accessors are not replaced.
148 std::vector<std::string> trk_decorations;
152 "" /* no configurable prefix*/,
153 trk_decorations,
155 }
156 ATH_CHECK( m_vertexContainerName.initialize( not m_vertexContainerName.empty() ) );
157 ATH_CHECK( m_truthVertexContainerName.initialize( not m_truthVertexContainerName.key().empty() ) );
158 ATH_CHECK( m_eventInfoContainerName.initialize() );
159
160 ATH_CHECK( m_truthEventName.initialize( (m_pileupSwitch == "HardScatter" or m_pileupSwitch == "All") and not m_truthEventName.key().empty() ) );
161 ATH_CHECK( m_truthPileUpEventName.initialize( (m_pileupSwitch == "PileUp" or m_pileupSwitch == "All") and not m_truthPileUpEventName.key().empty() ) );
162 ATH_CHECK( m_jetContainerName.initialize( m_doTrackInJetPlots and not m_jetContainerName.key().empty()) );
163
164 std::vector<std::string> required_float_track_decorations {"d0","hitResiduals_residualLocX","d0err"};
165 std::vector<std::string> required_int_track_decorations {};
166 std::vector<std::string> required_float_truth_decorations {"d0"};
167 std::vector<std::string> required_int_truth_decorations {};
168 std::vector<std::string> required_int_jet_decorations {"HadronConeExclTruthLabelID"};
169 // The CSV file is for storing event data related to track overlay ML training purposes.
170 if (!m_setCSVName.empty()) {
172 ATH_MSG_INFO("Accessing csv file with name " <<m_setCSVName<< "...");
173 m_datfile <<"EvtNumber,PdgID,Px,Py,Pz,E,Pt,Eta,Phi,Mass,numPU,numvtx,MatchProb"<<std::endl;
174 }
175 std::string empty_prefix;
176 IDPVM::addReadDecoratorHandleKeys(*this, m_trkParticleName, empty_prefix, required_float_track_decorations, m_floatTrkDecor);
177 IDPVM::addReadDecoratorHandleKeys(*this, m_trkParticleName, empty_prefix, required_int_truth_decorations, m_intTrkDecor);
178 if (!m_truthParticleName.key().empty()) {
179 IDPVM::addReadDecoratorHandleKeys(*this, m_truthParticleName, empty_prefix, required_float_truth_decorations, m_floatTruthDecor);
180 IDPVM::addReadDecoratorHandleKeys(*this, m_truthParticleName, empty_prefix, required_int_truth_decorations, m_intTruthDecor);
181 }
183 IDPVM::addReadDecoratorHandleKeys(*this, m_jetContainerName, empty_prefix, required_int_jet_decorations, m_intJetDecor);
184 }
185
187
189 return StatusCode::SUCCESS;
190}
191
192
194
195
196 InDetRttPlotConfig rttConfig;
197 rttConfig.detailLevel = m_detailLevel;
198
199 rttConfig.isITk = m_isITk;
200 rttConfig.hasHGTDReco = m_hasHGTDReco;
201
205
207 rttConfig.doHitEffPlot = m_doHitLevelPlots;
208
212
215
217
223
225
228
230
232 if (m_truthParticleName.key().empty()){
233 rttConfig.doFakePlots = false;
234 rttConfig.doHitsFakeTracksPlots = false;
235 rttConfig.doEffPlots = false;
236 rttConfig.doResolutionPlotPrim = false;
237 rttConfig.doResolutionPlotPrim_truthFromB = false;
238 rttConfig.doResolutionPlotSecd = false;
239 rttConfig.doHitsMatchedTracksPlots = false;
240 rttConfig.doVertexTruthMatchingPlots = false;
241 rttConfig.doHardScatterVertexTruthMatchingPlots = false;
242 rttConfig.doEfficienciesPerAuthor = false;
243 rttConfig.doFakesPerAuthor = false;
244 rttConfig.doResolutionsPerAuthor = false;
245 rttConfig.doNtupleTruthToReco = false;
246 rttConfig.doTrkInJetPlots_fake_bjets = false;
247 rttConfig.doTrkInJetPlots_matched_bjets = false;
248 rttConfig.doTrkInJetPlots_truthFromB = false;
249 rttConfig.doResolutionPlotPrim_truthFromB = false;
250 }
251
253 if (m_onlyFillMatched){
254 rttConfig.doTrackParameters = false;
255 rttConfig.doNTracks = false;
256 rttConfig.doHitResidualPlot = false;
257 rttConfig.doHitEffPlot = false;
258 rttConfig.doHitsRecoTracksPlots = false;
259 rttConfig.doTrtExtensionPlots = false;
260 rttConfig.doFakePlots = false;
261 rttConfig.doHitsFakeTracksPlots = false;
262 rttConfig.doVertexPlots = false;
263 rttConfig.doVerticesVsMuPlots = false;
264 rttConfig.doHardScatterVertexPlots = false;
265 rttConfig.doVertexTruthMatchingPlots = false;
267 rttConfig.doTrkInJetPlots = false;
268 rttConfig.doTrkInJetPlots_bjets = false;
269 rttConfig.doTrkInJetPlots_matched = false;
270 rttConfig.doTrkInJetPlots_matched_bjets = false;
271 rttConfig.doTrkInJetPlots_fake = false;
272 rttConfig.doTrkInJetPlots_fake_bjets = false;
273 rttConfig.doTrkInJetPlots_truthFromB = false;
274 }
275
276 // For IDTIDE derivation
277 // disable the vertex plots since no covariance from IDTIDE
278 if (m_doIDTIDEPlots){
279 rttConfig.doVertexPlots = false;
280 rttConfig.doVerticesVsMuPlots = false;
281 rttConfig.doHardScatterVertexPlots = false;
282 rttConfig.doVertexTruthMatchingPlots = false;
284 rttConfig.doTrkInJetPlots = true;
285 rttConfig.doTrkInJetPlots_bjets = true;
286 rttConfig.doTrkInJetPlots_matched = true;
287 rttConfig.doTrkInJetPlots_matched_bjets = true;
288 rttConfig.doTrkInJetPlots_fake = true;
289 rttConfig.doTrkInJetPlots_fake_bjets = true;
290 rttConfig.doTrkInJetPlots_truthFromB = true;
291 }
292
294 if (m_detailLevel < 200){
295 rttConfig.doResolutionPlotSecd = false;
296 rttConfig.doHitsMatchedTracksPlots = false;
297 rttConfig.doHitsFakeTracksPlots = false;
298 rttConfig.doFakesPerAuthor = false;
299 rttConfig.doTrackParametersPerAuthor = false;
300 rttConfig.doEfficienciesPerAuthor = false;
301 rttConfig.doResolutionsPerAuthor = false;
302 rttConfig.doTrkInJetPlots_matched = false;
303 rttConfig.doTrkInJetPlots_fake = false;
304 rttConfig.doTrkInJetPlots_matched_bjets = false;
305 rttConfig.doTrkInJetPlots_fake_bjets = false;
306 }
307
308 return rttConfig;
309}
310
311StatusCode
313 ATH_MSG_DEBUG("Filling hists " << name() << "...");
314 // function object could be used to retrieve truth: IDPVM::CachedGetAssocTruth getTruth;
315
316 // retrieve trackParticle container
318 if (not trackHandle.isValid()) {
319 ATH_MSG_ERROR("Invalid trackname = " << m_trkParticleName << "!");
320 return StatusCode::FAILURE;
321 }
322 const xAOD::TrackParticleContainer* tracks = trackHandle.cptr();
323
324 SG::ReadHandle<xAOD::TruthPileupEventContainer> truthPileupEventContainer;
325 if( not m_truthPileUpEventName.key().empty()) {
327 }
328
330 if (not pie.isValid()){
331 ATH_MSG_WARNING("Shouldn't happen - EventInfo is buggy, setting mu to 0");
332 }
333
334 // FIX-ME: I'm not sure if we should stop execution if EventInfo is not valid ...
335 // it is used after as if they assume it is valid
336 if (m_useGRL and pie.isValid() and !pie->eventType(xAOD::EventInfo::IS_SIMULATION)) {
337 if (!m_grlTool->passRunLB(*pie)) {
338 ATH_MSG_VERBOSE("GRL veto");
339 return StatusCode::SUCCESS;
340 }
341 }
342
343 std::vector<const xAOD::TruthParticle*> truthParticlesVec = getTruthParticles(ctx);
344
345 // Mark the truth particles in our vector as "selected".
346 // This is needed because we later access the truth matching via xAOD decorations, where we do not 'know' about membership to this vector.
348 const xAOD::EventInfo *eventInfo = nullptr;
349 ATH_CHECK (evtStore()->retrieve (eventInfo, "EventInfo"));
350 IDPVM::CachedGetAssocTruth getAsTruth; // only cache one way, track->truth, not truth->tracks
351
352 unsigned int truthMu = 0;
353 float actualMu = 0.;
354 if(not m_truthPileUpEventName.key().empty() and truthPileupEventContainer.isValid()){
355 truthMu = static_cast<int>( truthPileupEventContainer->size() );
356 }
357 if(pie.isValid()) actualMu = pie->actualInteractionsPerCrossing();
358
359 // This is questionable but kept for backward compatibility for now
360 float puEvents = truthMu>0 ? truthMu : actualMu;
361
362 const xAOD::Vertex* primaryvertex = nullptr;
363 unsigned int nVertices = 0;
364 float beamSpotWeight = 1;
365
366 if(not m_vertexContainerName.key().empty()){
367 ATH_MSG_DEBUG("Getting number of pu interactings per event");
368
369 ATH_MSG_DEBUG("Filling vertex plots");
371 ATH_CHECK(vertices.isValid());
372
373 nVertices = not vertices->empty() ? vertices->size() : 0;
374 beamSpotWeight = pie->beamSpotWeight();
375 ATH_MSG_DEBUG("beamSpotWeight is equal to " << beamSpotWeight);
376 if(m_doPRW){
377 float prwWeight = 1;
379 if(readDecorHandle.isAvailable()) prwWeight = readDecorHandle(*pie);
380 ATH_MSG_DEBUG("Applying pileup weight equal to " << prwWeight);
381 beamSpotWeight *= prwWeight;
382 }
383
384 if (vertices.isValid() and not vertices->empty()) {
385 ATH_MSG_DEBUG("Number of vertices retrieved for this event " << vertices->size());
386 //Find the HS vertex following the user-configured strategy
387 if (m_hardScatterSelectionTool.empty()) {
388 for (const xAOD::Vertex* vertex : *vertices){
389 if(vertex->vertexType()==xAOD::VxType::PriVtx){
390 primaryvertex = vertex;
391 break;
392 }
393 }
394 } else {
395 primaryvertex = m_hardScatterSelectionTool->getHardScatter(vertices.get());
396 }
397
398 if (!primaryvertex){
401 ATH_MSG_DEBUG("Failed to find a hard scatter vertex in this event.");
402 }
403 //Filling plots for all reconstructed vertices and the hard-scatter
404 ATH_MSG_DEBUG("Filling vertices info monitoring plots");
405
406 // Fill vectors of truth HS and PU vertices
407 std::pair<std::vector<const xAOD::TruthVertex*>, std::vector<const xAOD::TruthVertex*>> truthVertices = getTruthVertices(ctx);
408 std::vector<const xAOD::TruthVertex*> truthHSVertices = truthVertices.first;
409 std::vector<const xAOD::TruthVertex*> truthPUVertices = truthVertices.second;
410
411 // Decorate vertices
413 ATH_CHECK(m_vtxValidTool->matchVertices(*vertices));
414 ATH_MSG_DEBUG("Hard scatter classification type: " << InDetVertexTruthMatchUtils::classifyHardScatter(*vertices) << ", vertex container size = " << vertices->size());
415 }
416 m_monPlots->fill(*vertices, primaryvertex, truthHSVertices, truthPUVertices, actualMu, beamSpotWeight);
417
418 ATH_MSG_DEBUG("Filling vertex/event info monitoring plots");
419 //Filling vertexing plots for the reconstructed hard-scatter as a function of mu
420 m_monPlots->fill(*vertices, truthMu, actualMu, beamSpotWeight);
421 } else {
422 //FIXME: Does this happen for single particles?
423 ATH_MSG_WARNING("Skipping vertexing plots.");
424 }
425 }
426
427 if( not m_truthVertexContainerName.key().empty()){
428 // get truth vertex container name - m_truthVertexContainerName
430
431 //
432 //Get the HS vertex position from the truthVertexContainer
433 //FIXME: Add plots w.r.t truth HS positions (vertexing plots)
434 //
435 const xAOD::TruthVertex* truthVertex = nullptr;
436 if (truthVrt.isValid()) {
437 const auto& stdVertexContainer = truthVrt->stdcont();
438 //First truth particle vertex?
439 auto findVtx = std::find_if(stdVertexContainer.rbegin(), stdVertexContainer.rend(), acceptTruthVertex);
440 truthVertex = (findVtx == stdVertexContainer.rend()) ? nullptr : *findVtx;
441 } else {
442 ATH_MSG_WARNING("Cannot open " << m_truthVertexContainerName.key() << " truth vertex container");
443 }
444 if (not truthVertex) ATH_MSG_INFO ("Truth vertex did not pass cuts");
445 }
446 //
447 //Counters for cutflow
448 //
449 unsigned int nSelectedTruthTracks(0), nSelectedRecoTracks(0), nSelectedMatchedTracks(0), nAssociatedTruth(0), nMissingAssociatedTruth(0), nTruths(0);
450
451 CutFlow tmp_truth_cutflow( m_truthSelectionTool.get() ? m_truthSelectionTool->nCuts() : 0 );
452
453 //
454 //Loop over all reconstructed tracks
455 //
456 // If writing ntuples, use a truth-to-track(s) cache to handle truth matching.
457 // Based on the assumption that multiple tracks can (albeit rarely) share the same truth association.
458 std::map<const xAOD::TruthParticle*, std::vector<const xAOD::TrackParticle*>> cacheTruthMatching {};
459 //
460 std::vector<const xAOD::TrackParticle*> selectedTracks {};
461 selectedTracks.reserve(tracks->size());
462 unsigned int nTrackTOT = 0;
463 unsigned int nTrackCentral = 0;
464 unsigned int nTrackPt1GeV = 0;
465 for (const auto *const thisTrack: *tracks) {
466 //FIXME: Why is this w.r.t the primary vertex?
467 const asg::AcceptData& accept = m_trackSelectionTool->accept(*thisTrack, primaryvertex);
468 if (m_useTrackSelection and not accept) continue;
469 fillTrackCutFlow(accept); //?? Is this equal???
470
471 selectedTracks.push_back(thisTrack);
472 //Number of selected reco tracks
473 nSelectedRecoTracks++;
474
475 //Fill plots for selected reco tracks, hits / perigee / ???
476 nTrackTOT++;
477 if (thisTrack->pt() >= (1 * Gaudi::Units::GeV))
478 nTrackPt1GeV++;
479 if (std::abs(thisTrack->eta()) < 2.5)
480 nTrackCentral++;
481 m_monPlots->fill(*thisTrack, beamSpotWeight);
482 m_monPlots->fill(*thisTrack, puEvents, nVertices, beamSpotWeight); //fill mu dependent plots
483 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
484 float prob = getMatchingProbability(*thisTrack);
485
486 // This is where the Fake, and Really Fake fillers need to go. Where would the really really fakes go?
487 if (associatedTruth) {
488 nAssociatedTruth++;
489
490 // if there is associated truth also a truth selection tool was retrieved.
493 //FIXME: What is this for???
494 tmp_truth_cutflow.update( passed.missingCuts() );
495 }
496
497 if ((not std::isnan(prob)) and (prob > m_lowProb) and passed and (not m_usingSpecialPileupSwitch or isSelectedByPileupSwitch(*associatedTruth)) ) {
498 nSelectedMatchedTracks++;
499 bool truthIsFromB = false;
500 if ( m_doTruthOriginPlots and m_trackTruthOriginTool->isFrom(associatedTruth, 5) ) {
501 truthIsFromB = true;
502 }
503 m_monPlots->fill(*thisTrack, *associatedTruth, truthIsFromB, puEvents, beamSpotWeight); // Make plots requiring matched truth
504 }
505 }
506
507 const bool isAssociatedTruth = associatedTruth != nullptr;
508 const bool isFake = not std::isnan(prob) ? (prob < m_lowProb) : true;
509
510 if(!isAssociatedTruth) nMissingAssociatedTruth++;
511 m_monPlots->fillFakeRate(*thisTrack, isFake, puEvents, beamSpotWeight);
512
514 // Decorate track particle with extra flags
515 decorateTrackParticle(*thisTrack, accept);
516
517 if (isAssociatedTruth) {
518 // Decorate truth particle with extra flags
519 decorateTruthParticle(*associatedTruth, m_truthSelectionTool->accept(associatedTruth));
520
521 // Cache truth-to-track associations
522 auto cachedAssoc = cacheTruthMatching.find(associatedTruth);
523 // Check if truth particle already present in cache
524 if (cachedAssoc == cacheTruthMatching.end()) {
525 // If not yet present, add truth-to-track association in cache
526 cacheTruthMatching[associatedTruth] = {thisTrack};
527 }
528 else {
529 // If already present, cache additional track associations (here multiple track particle can be linked to the same truth particle)
530 cachedAssoc->second.push_back(thisTrack);
531 }
532 }
534 // Fill track only entries with dummy truth values
535 m_monPlots->fillNtuple(*thisTrack, primaryvertex);
536 }
537 }
538 }
540 // Now fill all truth-to-track associations
541 // Involves some double-filling of truth particles in cases where multiple tracks share the same truth association,
542 // these duplicates can be filtered in the ntuple by selecting only the 'best matched' truth-associated track particles.
543 for (auto& cachedAssoc: cacheTruthMatching) {
544 const xAOD::TruthParticle* thisTruth = cachedAssoc.first;
545
546 // Decorate that this truth particle is being filled to prevent double counting in truth particle loop
547 m_dec_hasTruthFilled(*thisTruth) = true;
548
549 // Sort all associated tracks by truth match probability
550 std::sort(cachedAssoc.second.begin(), cachedAssoc.second.end(),
551 [](const xAOD::TrackParticle* t1, const xAOD::TrackParticle* t2) { return getMatchingProbability(*t1) > getMatchingProbability(*t2); }
552 );
553
555 // Fill all tracks associated to to this truth particle, also recording 'truth match ranking' as index in probability-sorted vector of matched tracks
556 for (int itrack = 0; itrack < (int) cachedAssoc.second.size(); itrack++) {
557 const xAOD::TrackParticle* thisTrack = cachedAssoc.second[itrack];
558
559 // Fill track entries with truth association
560 m_monPlots->fillNtuple(*thisTrack, *thisTruth, primaryvertex, itrack);
561 }
562 }
563 }
564 }
565
566 m_monPlots->fill(nTrackTOT, nTrackCentral, nTrackPt1GeV, truthMu, actualMu, nVertices, beamSpotWeight);
567
568 //FIXME: I don't get why... this is here
569 if (m_truthSelectionTool.get()) {
570 ATH_MSG_DEBUG( CutFlow(tmp_truth_cutflow).report(m_truthSelectionTool->names()) );
571 std::lock_guard<std::mutex> lock(m_mutex);
572 m_truthCutFlow.merge(std::move(tmp_truth_cutflow));
573 }
574
575 //
576 //TruthParticle loop to fill efficiencies
577 //
578 for (int itruth = 0; itruth < (int) truthParticlesVec.size(); itruth++) { // Outer loop over all truth particles
579 nTruths++;
580 const xAOD::TruthParticle* thisTruth = truthParticlesVec[itruth];
581
582 // if the vector of truth particles is not empty also a truthSelectionTool was retrieved
583 const IAthSelectionTool::CutResult accept = m_truthSelectionTool->accept(thisTruth);
584 if (accept) {
585 ++nSelectedTruthTracks; // total number of truth which pass cuts per event
586 bool isEfficient(false); // weight for the trackeff histos
587 float matchingProbability{};
588 m_monPlots->fill(*thisTruth, beamSpotWeight); // This is filling truth-only plots
589
591 auto cachedAssoc = cacheTruthMatching.find(thisTruth);
592 // Check if truth particle already present in cache
593 if (cachedAssoc == cacheTruthMatching.end()) {
594 // If not yet present, then no track associated
595 cacheTruthMatching[thisTruth] = {};
596 }
597 m_monPlots->fillDuplicate(*thisTruth, cacheTruthMatching[thisTruth], beamSpotWeight);
598 }
599
600 //
601 //Loop over reco tracks to find the match
602 //
603 const xAOD::TrackParticle* matchedTrack = nullptr;
604 for (const auto& thisTrack: selectedTracks) { // Inner loop over selected track particleis
605 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
606 if (associatedTruth && associatedTruth == thisTruth) {
607 float prob = getMatchingProbability(*thisTrack);
608 if (not std::isnan(prob) && prob > m_lowProb) {
609 matchingProbability = prob;
610 isEfficient = true;
611 matchedTrack = thisTrack;
612 break;
613 }
614 }
615 }
616 if (!m_setCSVName.empty()) {
617 m_datfile <<eventInfo->eventNumber()<<","<<thisTruth->pdgId()<<","<<thisTruth->px()/ Gaudi::Units::GeV<<","
618 <<thisTruth->py()/ Gaudi::Units::GeV<<","<<thisTruth->pz()/ Gaudi::Units::GeV<<","
619 <<thisTruth->e()/ Gaudi::Units::GeV<<","<<thisTruth->pt()/ Gaudi::Units::GeV<<","
620 <<thisTruth->eta()<<","<<thisTruth->phi()<<","<<thisTruth->m()/ Gaudi::Units::GeV<<","
621 <<puEvents<<","<<nVertices<<","<<matchingProbability<<std::endl;
622 }
623 if (!thisTruth){
624 ATH_MSG_ERROR("An error occurred: Truth particle for tracking efficiency calculation is a nullptr");
625 }
626 else if (isEfficient && !matchedTrack){
627 ATH_MSG_ERROR("Something went wrong - we log a truth particle as reconstructed, but the reco track is a nullptr! Bailing out... ");
628 }
629 else{
630 ATH_MSG_DEBUG("Filling efficiency plots info monitoring plots");
631 m_monPlots->fillEfficiency(*thisTruth, matchedTrack, isEfficient, truthMu, actualMu, beamSpotWeight);
633 ATH_MSG_DEBUG("Filling technical efficiency plots info monitoring plots");
634 static const SG::ConstAccessor< float > nSilHitsAcc("nSilHits");
635 if (nSilHitsAcc.isAvailable(*thisTruth)) {
636 if (nSilHitsAcc(*thisTruth) >= m_minHits.value().at(getIndexByEta(*thisTruth))){
637 m_monPlots->fillTechnicalEfficiency(*thisTruth, isEfficient,
638 truthMu, actualMu, beamSpotWeight);
639 }
640 } else {
641 ATH_MSG_DEBUG("Cannot fill technical efficiency. Missing si hit information for truth particle.");
642 }
643 }
644 }
645 }
646
647 if (m_fillTruthToRecoNtuple && thisTruth) {
648 // Skip if already filled in track loop
649 if (hasTruthFilled(*thisTruth)) continue;
650
651 // Decorate truth particle with extra flags
652 decorateTruthParticle(*thisTruth, accept);
653
654 // Fill truth only entries with dummy track values
655 m_monPlots->fillNtuple(*thisTruth);
656 }
657 }
658
659 if (nSelectedRecoTracks == nMissingAssociatedTruth) {
660 if (not m_truthParticleName.key().empty()) {
661 ATH_MSG_DEBUG("NO TRACKS had associated truth.");
662 }
663 } else {
664 ATH_MSG_DEBUG(nAssociatedTruth << " tracks out of " << tracks->size() << " had associated truth.");
665 }
666
667 m_monPlots->fillCounter(nSelectedRecoTracks, InDetPerfPlot_nTracks::SELECTEDRECO, beamSpotWeight);
668 m_monPlots->fillCounter(tracks->size(), InDetPerfPlot_nTracks::ALLRECO, beamSpotWeight);
669 m_monPlots->fillCounter(nSelectedTruthTracks, InDetPerfPlot_nTracks::SELECTEDTRUTH, beamSpotWeight);
670 m_monPlots->fillCounter(nTruths, InDetPerfPlot_nTracks::ALLTRUTH, beamSpotWeight);
671 m_monPlots->fillCounter(nAssociatedTruth, InDetPerfPlot_nTracks::ALLASSOCIATEDTRUTH, beamSpotWeight);
672 m_monPlots->fillCounter(nSelectedMatchedTracks, InDetPerfPlot_nTracks::MATCHEDRECO, beamSpotWeight);
673
674 // Tracking In Dense Environment
677 getAsTruth,
678 truthParticlesVec,
679 *tracks,
680 primaryvertex,
681 beamSpotWeight) );
682 }
683 return StatusCode::SUCCESS;
684}
685
687 // Decorate outcome of track selection
688 m_dec_passedTrackSelection(track) = (bool)(passed);
689}
690
692 // Decorate outcome of truth selection
693 m_dec_passedTruthSelection(truth) = (bool)(passed);
694
695 // Decorate if selected by pileup switch
697}
698
700 if (!m_acc_hasTruthFilled.isAvailable(truth)) {
701 ATH_MSG_DEBUG("Truth particle not yet filled in ntuple");
702 return false;
703 }
704 return m_acc_hasTruthFilled(truth);
705}
706
708 if (!m_acc_selectedByPileupSwitch.isAvailable(truth)) {
709 ATH_MSG_DEBUG("Selected by pileup switch decoration requested from a truth particle but not available");
710 return false;
711 }
712 return m_acc_selectedByPileupSwitch(truth);
713}
714
715void InDetPhysValMonitoringTool::markSelectedByPileupSwitch(const std::vector<const xAOD::TruthParticle*> & truthParticles) const{
716 for (const auto& thisTruth: truthParticles) {
717 m_dec_selectedByPileupSwitch(*thisTruth) = true;
718 }
719}
720
721StatusCode
723 ATH_MSG_INFO("Booking hists " << name() << "with detailed level: " << m_detailLevel);
724 m_monPlots->initialize();
725 std::vector<HistData> hists = m_monPlots->retrieveBookedHistograms();
726 for (const auto& hist : hists) {
727 ATH_CHECK(regHist(hist.first, hist.second, all)); // ??
728 }
729 // do the same for Efficiencies, but there's a twist:
730 std::vector<EfficiencyData> effs = m_monPlots->retrieveBookedEfficiencies();
731 for (auto& eff : effs) {
732 // reg**** in the monitoring baseclass doesnt have a TEff version, but TGraph *
733 // pointers just get passed through, so we use that method after an ugly cast
734 ATH_CHECK(regGraph(reinterpret_cast<TGraph*>(eff.first), eff.second, all)); // ??
735 }
736 // register trees for ntuple writing
738 std::vector<TreeData> trees = m_monPlots->retrieveBookedTrees();
739 for (auto& t : trees) {
740 ATH_CHECK(regTree(t.first, t.second, all));
741 }
742 }
743
744 return StatusCode::SUCCESS;
745}
746
747StatusCode
749 ATH_MSG_INFO("Finalising hists " << name() << "...");
750 //TODO: ADD Printouts for Truth??
752 ATH_MSG_INFO("");
753 ATH_MSG_INFO("Now Cutflow for track cuts:");
754 ATH_MSG_INFO("");
755 for (int i = 0; i < (int) m_trackCutflow.size(); ++i) {
756 ATH_MSG_INFO("number after " << m_trackCutflowNames[i] << ": " << m_trackCutflow[i]);
757 }
758 }
759
760 ATH_MSG_INFO("");
761 ATH_MSG_INFO("Cutflow for truth tracks:");
762 if (m_truthSelectionTool.get()) {
763 ATH_MSG_INFO("Truth selection report: " << m_truthCutFlow.report( m_truthSelectionTool->names()) );
764 }
765 if (endOfRunFlag()) {
766 m_monPlots->finalize();
767 }
768 ATH_MSG_INFO("Successfully finalized hists");
769 return StatusCode::SUCCESS;
770}
771
772const std::vector<const xAOD::TruthParticle*>
773InDetPhysValMonitoringTool::getTruthParticles(const EventContext& ctx) const {
774
775 std::vector<const xAOD::TruthParticle*> tempVec {};
776
777 if (m_pileupSwitch == "All") {
778 if (m_truthParticleName.key().empty()) {
779 return tempVec;
780 }
782 if (not truthParticleContainer.isValid()) {
783 return tempVec;
784 }
785 tempVec.insert(tempVec.begin(), truthParticleContainer->begin(), truthParticleContainer->end());
786 } else {
787 if (m_pileupSwitch == "HardScatter") {
788 // get truthevent container to separate out pileup and hardscatter truth particles
789 if (not m_truthEventName.key().empty()) {
791 const xAOD::TruthEvent* event = (truthEventContainer.isValid()) ? truthEventContainer->at(0) : nullptr;
792 if (not event) {
793 return tempVec;
794 }
795 const auto& links = event->truthParticleLinks();
796 tempVec.reserve(event->nTruthParticles());
797 for (const auto& link : links) {
798 if (link.isValid()){
799 tempVec.push_back(*link);
800 }
801 }
802 }
803 } else if (m_pileupSwitch == "PileUp") {
804 if (not m_truthPileUpEventName.key().empty()) {
805 ATH_MSG_VERBOSE("getting TruthPileupEvents container");
806 // get truth particles from all pileup events
808 if (truthPileupEventContainer.isValid()) {
809 const unsigned int nPileup = truthPileupEventContainer->size();
810 tempVec.reserve(nPileup * 200); // quick initial guess, will still save some time
811 for (unsigned int i(0); i != nPileup; ++i) {
812 const auto *eventPileup = truthPileupEventContainer->at(i);
813 // get truth particles from each pileup event
814 int ntruth = eventPileup->nTruthParticles();
815 ATH_MSG_VERBOSE("Adding " << ntruth << " truth particles from TruthPileupEvents container");
816 const auto& links = eventPileup->truthParticleLinks();
817 for (const auto& link : links) {
818 if (link.isValid()){
819 tempVec.push_back(*link);
820 }
821 }
822 }
823 } else {
824 ATH_MSG_ERROR("no entries in TruthPileupEvents container!");
825 }
826 }
827 } else {
828 ATH_MSG_ERROR("bad value for PileUpSwitch");
829 }
830 }
831 return tempVec;
832}
833
834std::pair<std::vector<const xAOD::TruthVertex*>, std::vector<const xAOD::TruthVertex*>>
835InDetPhysValMonitoringTool::getTruthVertices(const EventContext& ctx) const {
836
837 std::vector<const xAOD::TruthVertex*> truthHSVertices = {};
838 truthHSVertices.reserve(5);
839 std::vector<const xAOD::TruthVertex*> truthPUVertices = {};
840 truthPUVertices.reserve(100);
841 const xAOD::TruthVertex* truthVtx = nullptr;
842
843 bool doHS = false;
844 bool doPU = false;
845 if (m_pileupSwitch == "All") {
846 doHS = true;
847 doPU = true;
848 }
849 else if (m_pileupSwitch == "HardScatter") {
850 doHS = true;
851 }
852 else if (m_pileupSwitch == "PileUp") {
853 doPU = true;
854 }
855 else {
856 ATH_MSG_ERROR("Bad value for PileUpSwitch: " << m_pileupSwitch);
857 }
858
859 if (doHS) {
860 if (not m_truthEventName.key().empty()) {
861 ATH_MSG_VERBOSE("Getting HS TruthEvents container.");
863 if (truthEventContainer.isValid()) {
864 for (const auto *const evt : *truthEventContainer) {
865 truthVtx = evt->signalProcessVertex();
866 if (truthVtx) {
867 truthHSVertices.push_back(truthVtx);
868 }
869 }
870 }
871 else {
872 ATH_MSG_ERROR("No entries in TruthEvents container!");
873 }
874 }
875 }
876
877 if (doPU) {
878 if (not m_truthPileUpEventName.key().empty()) {
879 ATH_MSG_VERBOSE("Getting PU TruthEvents container.");
881 if (truthPileupEventContainer.isValid()) {
882 for (const auto *const evt : *truthPileupEventContainer) {
883 // Get the PU vertex
884 // In all cases tested i_vtx=2 for PU
885 // but better to keep something generic
886 truthVtx = nullptr;
887 size_t i_vtx = 0; size_t n_vtx = evt->nTruthVertices();
888 while(!truthVtx && i_vtx<n_vtx){
889 truthVtx = evt->truthVertex(i_vtx);
890 i_vtx++;
891 }
892
893 if (truthVtx) {
894 truthPUVertices.push_back(truthVtx);
895 }
896 }
897 }
898 else {
899 ATH_MSG_DEBUG("No entries in TruthPileupEvents container");
900 }
901 }
902 }
903
904 return {std::move(truthHSVertices), std::move(truthPUVertices)};
905}
906
907void
911
912void
913InDetPhysValMonitoringTool::fillCutFlow(const asg::AcceptData& accept, std::vector<std::string>& names,
914 std::vector<int>& cutFlow) {
915 // initialise cutflows
916 if (cutFlow.empty()) {
917 names.emplace_back("preCut");
918 cutFlow.push_back(0);
919 for (unsigned int i = 0; i != accept.getNCuts(); ++i) {
920 cutFlow.push_back(0);
921 names.push_back((std::string) accept.getCutName(i));
922 }
923 }
924 // get cutflow
925 cutFlow[0] += 1;
926 bool cutPositive = true;
927 for (unsigned int i = 0; i != (accept.getNCuts() + 1); ++i) {
928 if (!cutPositive) {
929 continue;
930 }
931 if (accept.getCutResult(i)) {
932 cutFlow[i + 1] += 1;
933 } else {
934 cutPositive = false;
935 }
936 }
937 }
938
940 double absEta = std::abs(truth.eta());
941 if (absEta > m_etaBins.value().back() || absEta < m_etaBins.value().front()) {
942 absEta = std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back());
943 ATH_MSG_INFO("Requesting cut value outside of configured eta range: clamping eta = "
944 << std::abs(truth.eta()) << " to eta= " << absEta);
945 } else
946 absEta = std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back());
947 const auto pVal = std::lower_bound(m_etaBins.value().begin(), m_etaBins.value().end(), absEta);
948 const int bin = std::distance(m_etaBins.value().begin(), pVal) - 1;
949 ATH_MSG_DEBUG("Checking (abs(eta)/bin) = (" << absEta << "," << bin << ")");
950 return bin;
951}
952
954 IDPVM::CachedGetAssocTruth& getAsTruth,
955 const std::vector<const xAOD::TruthParticle*>& truthParticles,
956 const xAOD::TrackParticleContainer& tracks,
957 const xAOD::Vertex* primaryvertex,
958 float beamSpotWeight) {
959 // Define accessors
960 static const SG::ConstAccessor<std::vector<ElementLink<xAOD::IParticleContainer> > > ghosttruth("GhostTruth");
961 static const SG::ConstAccessor<int> btagLabel("HadronConeExclTruthLabelID");
962
963 if (truthParticles.empty()) {
964 ATH_MSG_WARNING("No entries in TruthParticles truth particle container. Skipping jet plots.");
965 return StatusCode::SUCCESS;
966 }
967
969 if (not jetHandle.isValid()) {
970 ATH_MSG_WARNING("Cannot open jet container " << m_jetContainerName.key() << ". Skipping jet plots.");
971 return StatusCode::SUCCESS;
972 }
973 const xAOD::JetContainer* jets = jetHandle.cptr();
974
975 // loop on jets
976 for (const xAOD::Jet *const thisJet: *jets) {
977 // pass jet cuts
978 if (not passJetCuts(*thisJet)) continue;
979 // check if b-jet
980 bool isBjet = false;
981 if (not btagLabel.isAvailable(*thisJet)){
982 ATH_MSG_WARNING("Failed to extract b-tag truth label from jet");
983 } else {
984 isBjet = (btagLabel(*thisJet) == 5);
985 }
986
987 // Retrieve associated ghost truth particles
988 if(not ghosttruth.isAvailable(*thisJet)) {
989 ATH_MSG_WARNING("Failed to extract ghost truth particles from jet");
990 } else {
991 for(const ElementLink<xAOD::IParticleContainer>& el : ghosttruth(*thisJet)) {
992 if (not el.isValid()) continue;
993
994 const xAOD::TruthParticle *truth = static_cast<const xAOD::TruthParticle*>(*el);
995
996 // Check if ghost truth is in event TruthParticle vector
997 if (m_pileupSwitch != "All") {
998 if (std::find(truthParticles.begin(), truthParticles.end(), truth) == truthParticles.end()) {
999 continue;
1000 }
1001 }
1002
1003 // Check delta R between track and jet axis
1004 if (thisJet->p4().DeltaR(truth->p4()) > m_maxTrkJetDR) {
1005 continue;
1006 }
1007 // Apply truth selection cuts
1008 const IAthSelectionTool::CutResult accept = m_truthSelectionTool->accept(truth);
1009 if(!accept) continue;
1010
1011 bool isEfficient(false);
1012
1013 for (const auto *thisTrack: tracks) {
1014 if (m_useTrackSelection and not (m_trackSelectionTool->accept(*thisTrack, primaryvertex))) {
1015 continue;
1016 }
1017
1018 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
1019 if (associatedTruth and associatedTruth == truth) {
1020 float prob = getMatchingProbability(*thisTrack);
1021 if (not std::isnan(prob) && prob > m_lowProb) {
1022 isEfficient = true;
1023 break;
1024 }
1025 }
1026 }
1027
1028 bool truthIsFromB = false;
1029 if ( m_doTruthOriginPlots and m_trackTruthOriginTool->isFrom(truth, 5) ) {
1030 truthIsFromB = true;
1031 }
1032 m_monPlots->fillEfficiency(*truth, *thisJet, isEfficient, isBjet, truthIsFromB, beamSpotWeight);
1033 }
1034 } // ghost truth
1035
1036 // loop on tracks
1037 for (const xAOD::TrackParticle *thisTrack: tracks) {
1038 if (m_useTrackSelection and not (m_trackSelectionTool->accept(*thisTrack, primaryvertex))) {
1039 continue;
1040 }
1041
1042 if (thisJet->p4().DeltaR(thisTrack->p4()) > m_maxTrkJetDR) {
1043 continue;
1044 }
1045
1046 float prob = getMatchingProbability(*thisTrack);
1047 if(std::isnan(prob)) prob = 0.0;
1048
1049 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
1050 const bool isFake = (associatedTruth && prob < m_lowProb);
1051 bool truthIsFromB = false;
1052 if ( m_doTruthOriginPlots and m_trackTruthOriginTool->isFrom(associatedTruth, 5) ) {
1053 truthIsFromB = true;
1054 }
1055 m_monPlots->fill(*thisTrack, *thisJet, isBjet, isFake, truthIsFromB, beamSpotWeight);
1056 if (associatedTruth){
1057 m_monPlots->fillFakeRate(*thisTrack, *thisJet, isFake, isBjet, truthIsFromB, beamSpotWeight);
1058 }
1059 }
1060
1061 } // loop on jets
1062
1063 return StatusCode::SUCCESS;
1064}
1065
1066bool
1068 const float jetPt = jet.pt();
1069 const float jetEta = std::abs(jet.eta());
1070
1071 if (jetEta < m_jetAbsEtaMin) return false;
1072 if (jetEta > m_jetAbsEtaMax) return false;
1073 if (jetPt < m_jetPtMin) return false;
1074 if (jetPt > m_jetPtMax) return false;
1075 return true;
1076}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
header file for truth selection in this package
Helper class to provide constant type-safe access to aux data.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
header file for class of same name
header file for class of same name
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
bool inRange(const double *boundaries, const double value, const double tolerance=0.02)
#define y
#define x
#define z
ServiceHandle< StoreGateSvc > & evtStore()
void update(bool)
Definition CutFlow.h:192
size_type size() const noexcept
Returns the number of elements in the collection.
static void neededTrackParticleDecorations(std::vector< std::string > &decorations)
const xAOD::TruthParticle * getTruth(const xAOD::TrackParticle *const trackParticle)
bool passJetCuts(const xAOD::Jet &jet) const
ToolHandle< InDet::IInDetHardScatterSelectionTool > m_hardScatterSelectionTool
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerName
Primary vertex container's name.
const std::vector< const xAOD::TruthParticle * > getTruthParticles(const EventContext &ctx) const
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleName
TruthParticle container's name.
std::unique_ptr< InDetRttPlots > m_monPlots
histograms
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
SG::ReadDecorHandleKey< xAOD::EventInfo > m_weight_pileup_key
bool isSelectedByPileupSwitch(const xAOD::TruthParticle &truth) const
SG::ReadHandleKey< xAOD::TruthPileupEventContainer > m_truthPileUpEventName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trkParticleName
TrackParticle container's name.
static void fillCutFlow(const asg::AcceptData &accept, std::vector< std::string > &names, std::vector< int > &cutFlow)
InDetPhysValMonitoringTool()
prevent default construction
SG::Decorator< bool > m_dec_passedTrackSelection
std::vector< SG::ReadDecorHandleKey< xAOD::JetContainer > > m_intJetDecor
int getIndexByEta(const xAOD::TruthParticle &truth) const
Utility function for evaluation of technical efficiency.
ToolHandle< InDet::IInDetTrackSelectionTool > m_trackSelectionTool
SG::Decorator< bool > m_dec_selectedByPileupSwitch
ToolHandle< InDet::IInDetTrackTruthOriginTool > m_trackTruthOriginTool
SG::Accessor< bool > m_acc_selectedByPileupSwitch
BooleanProperty m_useTrackSelection
Properties to fine-tune the tool behaviour.
void fillTrackCutFlow(const asg::AcceptData &accept)
SG::Decorator< bool > m_dec_passedTruthSelection
SG::ReadHandleKey< xAOD::TruthVertexContainer > m_truthVertexContainerName
Truth vertex container's name.
std::vector< SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > > m_floatTrkDecor
ToolHandle< IInDetVertexTruthMatchTool > m_vtxValidTool
void decorateTrackParticle(const xAOD::TrackParticle &track, const asg::AcceptData &passed) const
void decorateTruthParticle(const xAOD::TruthParticle &truth, const IAthSelectionTool::CutResult &passed) const
std::pair< std::vector< const xAOD::TruthVertex * >, std::vector< const xAOD::TruthVertex * > > getTruthVertices(const EventContext &ctx) const
std::vector< SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > > m_floatTruthDecor
std::vector< SG::ReadDecorHandleKey< xAOD::TruthParticleContainer > > m_intTruthDecor
InDetRttPlotConfig getFilledPlotConfig() const
Generate an Rtt config struct based on the user-passed properties.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoContainerName
EventInfo container name.
virtual StatusCode fillHistograms(const EventContext &ctx)
An inheriting class should either override this function or fillHists().
SG::ReadHandleKey< xAOD::TruthEventContainer > m_truthEventName
ToolHandle< IGoodRunsListSelectionTool > m_grlTool
SG::ReadHandleKey< xAOD::JetContainer > m_jetContainerName
bool hasTruthFilled(const xAOD::TruthParticle &truth) const
void markSelectedByPileupSwitch(const std::vector< const xAOD::TruthParticle * > &truthParticles) const
virtual ~InDetPhysValMonitoringTool()
Destructor.
std::vector< SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > > m_linkTrkDecor
ToolHandle< IAthSelectionTool > m_truthSelectionTool
StatusCode fillHistogramsTrackingInDenseEnvironment(const EventContext &ctx, IDPVM::CachedGetAssocTruth &getAsTruth, const std::vector< const xAOD::TruthParticle * > &truthParticles, const xAOD::TrackParticleContainer &tracks, const xAOD::Vertex *primaryvertex, float beamSpotWeight)
std::vector< SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > > m_intTrkDecor
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
std::vector< std::string > m_trackCutflowNames
virtual StatusCode regHist(TH1 *h, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
virtual StatusCode regTree(TTree *t, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TTree to be included in the output stream using logical parameters that describe it.
ManagedMonitorToolBase(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode regGraph(TGraph *g, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TGraph to be included in the output stream using logical parameters that describe the gra...
Helper class to provide constant type-safe access to aux data.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
Handle class for reading a decoration on an object.
bool isAvailable()
Test to see if this variable exists in the store, for the referenced object.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
@ IS_SIMULATION
true: simulation, false: data
uint64_t eventNumber() const
The current event's event number.
virtual double m() const override final
The mass of the particle.
int pdgId() const
PDG ID code.
float px() const
The x component of the particle's momentum.
virtual double e() const override final
The total energy of the particle.
virtual double pt() const override final
The transverse momentum ( ) of the particle.
float py() const
The y component of the particle's momentum.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
float pz() const
The z component of the particle's momentum.
float z() const
Vertex longitudinal distance along the beam line form the origin.
float y() const
Vertex y displacement.
float x() const
Vertex x displacement.
dict partitions
Definition DeMoScan.py:65
void addReadDecoratorHandleKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::ReadDecorHandleKey< T_Cont > > &decor_out)
float safelyGetEta(const T &pTrk, const float safePtThreshold=0.1)
Safely get eta.
unsigned int binIndex(const T &val, const std::vector< T > &partitions)
general utility function to return bin index given a value and the upper endpoints of each bin
HardScatterType classifyHardScatter(const xAOD::VertexContainer &vxContainer)
STL namespace.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
@ PriVtx
Primary vertex.
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TruthEvent_v1 TruthEvent
Typedef to implementation.
Definition TruthEvent.h:17
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
implementation file for function of same name
helper struct - steer the configuration from the parent tool's side
bool doTrkInJetPlots_matched_bjets
int detailLevel
detail level (kept for compatibility)
bool doNtupleTruthToReco
Ntuple functionality.
bool doEfficienciesPerAuthor
per author plots
bool doHitsRecoTracksPlotsPerAuthor
bool doEffPlots
Efficiency and duplicate plots - require truth, optionally matching reco.
bool doFakePlots
Fake plots.
bool doResolutionPlotPrim
Resolution and "matched track" plots - filled if both reco and truth exist.
bool doVertexTruthMatchingPlots
Vertexing plots - truth requirement.
bool doVertexPlots
Vertexing plots - no truth requirement.
bool doHardScatterVertexTruthMatchingPlots
bool doTrackParameters
Plots for (selected) tracks, not necessarily truth matched.
bool doTrkInJetPlots
Plots for tracks in jets.
bool doResolutionPlotPrim_truthFromB