ATLAS Offline Software
Loading...
Searching...
No Matches
InDetPhysValMonitoringTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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} ));
125 ATH_CHECK(m_grlTool.retrieve(EnableTool{m_useGRL}));
126
127 ATH_MSG_DEBUG("m_useVertexTruthMatchTool ====== " <<m_useVertexTruthMatchTool);
128 if (m_truthSelectionTool.get() ) {
129 m_truthCutFlow = CutFlow(m_truthSelectionTool->nCuts());
130 }
131
132 m_monPlots = std::make_unique<InDetRttPlots>
133 (nullptr, static_cast<std::string>(m_dirName) + static_cast<std::string>(m_folder),
134 getFilledPlotConfig()); // m_detailLevel := DEBUG, enable expert histograms
135
136 ATH_CHECK( m_trkParticleName.initialize() );
137 ATH_CHECK( m_truthParticleName.initialize( (m_pileupSwitch == "HardScatter" or m_pileupSwitch == "All") and not m_truthParticleName.key().empty() ) );
138 if (not m_truthParticleName.key().empty()) {
139 // create decor handle keys for truth particle decorations which are needed by CachedGetAssocTruth
140 // The existence of the handles is good enough to ensure that data dependencies are propagated
141 // and that the decorations exist when this tool is being called. Albeit not very elegant
142 // there is no need to create decor handles for the keys and use those instead of static
143 // accessors. To keep changes minimal the original static accessors are not replaced.
144 std::vector<std::string> trk_decorations;
148 "" /* no configurable prefix*/,
149 trk_decorations,
151 }
152 ATH_CHECK( m_vertexContainerName.initialize( not m_vertexContainerName.empty() ) );
153 ATH_CHECK( m_truthVertexContainerName.initialize( not m_truthVertexContainerName.key().empty() ) );
154 ATH_CHECK( m_eventInfoContainerName.initialize() );
155
156 ATH_CHECK( m_truthEventName.initialize( (m_pileupSwitch == "HardScatter" or m_pileupSwitch == "All") and not m_truthEventName.key().empty() ) );
157 ATH_CHECK( m_truthPileUpEventName.initialize( (m_pileupSwitch == "PileUp" or m_pileupSwitch == "All") and not m_truthPileUpEventName.key().empty() ) );
158 ATH_CHECK( m_jetContainerName.initialize( m_doTrackInJetPlots and not m_jetContainerName.key().empty()) );
159
160 std::vector<std::string> required_float_track_decorations {"d0","hitResiduals_residualLocX","d0err"};
161 std::vector<std::string> required_int_track_decorations {};
162 std::vector<std::string> required_float_truth_decorations {"d0"};
163 std::vector<std::string> required_int_truth_decorations {};
164 std::vector<std::string> required_int_jet_decorations {"HadronConeExclTruthLabelID"};
165 // The CSV file is for storing event data related to track overlay ML training purposes.
166 if (!m_setCSVName.empty()) {
168 ATH_MSG_INFO("Accessing csv file with name " <<m_setCSVName<< "...");
169 m_datfile <<"EvtNumber,PdgID,Px,Py,Pz,E,Pt,Eta,Phi,Mass,numPU,numvtx,MatchProb"<<std::endl;
170 }
171 std::string empty_prefix;
172 IDPVM::addReadDecoratorHandleKeys(*this, m_trkParticleName, empty_prefix, required_float_track_decorations, m_floatTrkDecor);
173 IDPVM::addReadDecoratorHandleKeys(*this, m_trkParticleName, empty_prefix, required_int_truth_decorations, m_intTrkDecor);
174 if (!m_truthParticleName.key().empty()) {
175 IDPVM::addReadDecoratorHandleKeys(*this, m_truthParticleName, empty_prefix, required_float_truth_decorations, m_floatTruthDecor);
176 IDPVM::addReadDecoratorHandleKeys(*this, m_truthParticleName, empty_prefix, required_int_truth_decorations, m_intTruthDecor);
177 }
179 IDPVM::addReadDecoratorHandleKeys(*this, m_jetContainerName, empty_prefix, required_int_jet_decorations, m_intJetDecor);
180 }
181
183
185 return StatusCode::SUCCESS;
186}
187
188
190
191
192 InDetRttPlotConfig rttConfig;
193 rttConfig.detailLevel = m_detailLevel;
194
195 rttConfig.isITk = m_isITk;
196
201
203 rttConfig.doHitEffPlot = m_doHitLevelPlots;
204
209
212
214
220
222
225
227 if (m_truthParticleName.key().empty()){
228 rttConfig.doFakePlots = false;
229 rttConfig.doMissingTruthFakePlots = false;
230 rttConfig.doHitsFakeTracksPlots = false;
231 rttConfig.doHitsUnlinkedTracksPlots = false;
232 rttConfig.doEffPlots = false;
233 rttConfig.doResolutionPlotPrim = false;
234 rttConfig.doResolutionPlotPrim_truthFromB = false;
235 rttConfig.doResolutionPlotSecd = false;
236 rttConfig.doHitsMatchedTracksPlots = false;
237 rttConfig.doVertexTruthMatchingPlots = false;
238 rttConfig.doHardScatterVertexTruthMatchingPlots = false;
239 rttConfig.doEfficienciesPerAuthor = false;
240 rttConfig.doFakesPerAuthor = false;
241 rttConfig.doResolutionsPerAuthor = false;
242 rttConfig.doNtupleTruthToReco = false;
243 rttConfig.doTrkInJetPlots_fake_bjets = false;
244 rttConfig.doTrkInJetPlots_matched_bjets = false;
245 rttConfig.doTrkInJetPlots_unlinked_bjets = false;
246 rttConfig.doTrkInJetPlots_truthFromB = false;
247 rttConfig.doResolutionPlotPrim_truthFromB = false;
248 }
249
251 if (m_onlyFillMatched){
252 rttConfig.doTrackParameters = false;
253 rttConfig.doNTracks = false;
254 rttConfig.doHitResidualPlot = false;
255 rttConfig.doHitEffPlot = false;
256 rttConfig.doHitsRecoTracksPlots = false;
257 rttConfig.doTrtExtensionPlots = false;
258 rttConfig.doFakePlots = false;
259 rttConfig.doMissingTruthFakePlots = false;
260 rttConfig.doHitsFakeTracksPlots = false;
261 rttConfig.doHitsUnlinkedTracksPlots = 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_unlinked = false;
274 rttConfig.doTrkInJetPlots_unlinked_bjets = false;
275 rttConfig.doTrkInJetPlots_truthFromB = false;
276 }
277
278 // For IDTIDE derivation
279 // disable the vertex plots since no covariance from IDTIDE
280 if (m_doIDTIDEPlots){
281 rttConfig.doVertexPlots = false;
282 rttConfig.doVerticesVsMuPlots = false;
283 rttConfig.doHardScatterVertexPlots = false;
284 rttConfig.doVertexTruthMatchingPlots = false;
286 rttConfig.doTrkInJetPlots = true;
287 rttConfig.doTrkInJetPlots_bjets = true;
288 rttConfig.doTrkInJetPlots_matched = true;
289 rttConfig.doTrkInJetPlots_matched_bjets = true;
290 rttConfig.doTrkInJetPlots_fake = true;
291 rttConfig.doTrkInJetPlots_fake_bjets = true;
292 rttConfig.doTrkInJetPlots_unlinked = true;
293 rttConfig.doTrkInJetPlots_unlinked_bjets = true;
294 rttConfig.doTrkInJetPlots_truthFromB = true;
295 }
296
298 if (m_detailLevel < 200){
299 rttConfig.doResolutionPlotSecd = false;
300 rttConfig.doHitsMatchedTracksPlots = false;
301 rttConfig.doHitsFakeTracksPlots = false;
302 rttConfig.doHitsUnlinkedTracksPlots = false;
303 rttConfig.doVertexTruthMatchingPlots = false;
304 rttConfig.doFakesPerAuthor = false;
305 rttConfig.doTrackParametersPerAuthor = false;
306 rttConfig.doEfficienciesPerAuthor = false;
307 rttConfig.doResolutionsPerAuthor = false;
308 rttConfig.doTrkInJetPlots_matched = false;
309 rttConfig.doTrkInJetPlots_fake = false;
310 rttConfig.doTrkInJetPlots_unlinked = false;
311 rttConfig.doTrkInJetPlots_matched_bjets = false;
312 rttConfig.doTrkInJetPlots_fake_bjets = false;
313 rttConfig.doTrkInJetPlots_unlinked_bjets = false;
314 }
315
316 return rttConfig;
317}
318
319StatusCode
321 ATH_MSG_DEBUG("Filling hists " << name() << "...");
322 // function object could be used to retrieve truth: IDPVM::CachedGetAssocTruth getTruth;
323
324 // Get the Event Context
325 const EventContext& ctx = Gaudi::Hive::currentContext();
326
327 // retrieve trackParticle container
329 if (not trackHandle.isValid()) {
330 ATH_MSG_ERROR("Invalid trackname = " << m_trkParticleName << "!");
331 return StatusCode::FAILURE;
332 }
333 const xAOD::TrackParticleContainer* tracks = trackHandle.cptr();
334
335 SG::ReadHandle<xAOD::TruthPileupEventContainer> truthPileupEventContainer;
336 if( not m_truthPileUpEventName.key().empty()) {
338 }
339
341 if (not pie.isValid()){
342 ATH_MSG_WARNING("Shouldn't happen - EventInfo is buggy, setting mu to 0");
343 }
344
345 // FIX-ME: I'm not sure if we should stop execution if EventInfo is not valid ...
346 // it is used after as if they assume it is valid
347 if (m_useGRL and pie.isValid() and !pie->eventType(xAOD::EventInfo::IS_SIMULATION)) {
348 if (!m_grlTool->passRunLB(*pie)) {
349 ATH_MSG_VERBOSE("GRL veto");
350 return StatusCode::SUCCESS;
351 }
352 }
353
354 std::vector<const xAOD::TruthParticle*> truthParticlesVec = getTruthParticles(ctx);
355
356 // Mark the truth particles in our vector as "selected".
357 // This is needed because we later access the truth matching via xAOD decorations, where we do not 'know' about membership to this vector.
359 const xAOD::EventInfo *eventInfo = nullptr;
360 ATH_CHECK (evtStore()->retrieve (eventInfo, "EventInfo"));
361 IDPVM::CachedGetAssocTruth getAsTruth; // only cache one way, track->truth, not truth->tracks
362
363 unsigned int truthMu = 0;
364 float actualMu = 0.;
365 if(not m_truthPileUpEventName.key().empty() and truthPileupEventContainer.isValid()){
366 truthMu = static_cast<int>( truthPileupEventContainer->size() );
367 }
368 if(pie.isValid()) actualMu = pie->actualInteractionsPerCrossing();
369
370 // This is questionable but kept for backward compatibility for now
371 float puEvents = truthMu>0 ? truthMu : actualMu;
372
373 const xAOD::Vertex* primaryvertex = nullptr;
374 unsigned int nVertices = 0;
375 float beamSpotWeight = 1;
376
377 if(not m_vertexContainerName.key().empty()){
378 ATH_MSG_DEBUG("Getting number of pu interactings per event");
379
380 ATH_MSG_DEBUG("Filling vertex plots");
382 ATH_CHECK(vertices.isValid());
383
384 nVertices = not vertices->empty() ? vertices->size() : 0;
385 beamSpotWeight = pie->beamSpotWeight();
386 ATH_MSG_DEBUG("beamSpotWeight is equal to " << beamSpotWeight);
387 if(m_doPRW){
388 float prwWeight = 1;
390 if(readDecorHandle.isAvailable()) prwWeight = readDecorHandle(*pie);
391 ATH_MSG_DEBUG("Applying pileup weight equal to " << prwWeight);
392 beamSpotWeight *= prwWeight;
393 }
394
395 if (vertices.isValid() and not vertices->empty()) {
396 ATH_MSG_DEBUG("Number of vertices retrieved for this event " << vertices->size());
397 //Find the HS vertex following the user-configured strategy
398 primaryvertex = m_hardScatterSelectionTool->getHardScatter(vertices.get());
399 if (!primaryvertex){
402 ATH_MSG_DEBUG("Failed to find a hard scatter vertex in this event.");
403 }
404 //Filling plots for all reconstructed vertices and the hard-scatter
405 ATH_MSG_DEBUG("Filling vertices info monitoring plots");
406
407 // Fill vectors of truth HS and PU vertices
408 std::pair<std::vector<const xAOD::TruthVertex*>, std::vector<const xAOD::TruthVertex*>> truthVertices = getTruthVertices(ctx);
409 std::vector<const xAOD::TruthVertex*> truthHSVertices = truthVertices.first;
410 std::vector<const xAOD::TruthVertex*> truthPUVertices = truthVertices.second;
411
412 // Decorate vertices
414 ATH_CHECK(m_vtxValidTool->matchVertices(*vertices));
415 ATH_MSG_DEBUG("Hard scatter classification type: " << InDetVertexTruthMatchUtils::classifyHardScatter(*vertices) << ", vertex container size = " << vertices->size());
416 }
417 m_monPlots->fill(*vertices, primaryvertex, truthHSVertices, truthPUVertices, actualMu, beamSpotWeight);
418
419 ATH_MSG_DEBUG("Filling vertex/event info monitoring plots");
420 //Filling vertexing plots for the reconstructed hard-scatter as a function of mu
421 m_monPlots->fill(*vertices, truthMu, actualMu, beamSpotWeight);
422 } else {
423 //FIXME: Does this happen for single particles?
424 ATH_MSG_WARNING("Skipping vertexing plots.");
425 }
426 }
427
428 if( not m_truthVertexContainerName.key().empty()){
429 // get truth vertex container name - m_truthVertexContainerName
431
432 //
433 //Get the HS vertex position from the truthVertexContainer
434 //FIXME: Add plots w.r.t truth HS positions (vertexing plots)
435 //
436 const xAOD::TruthVertex* truthVertex = nullptr;
437 if (truthVrt.isValid()) {
438 const auto& stdVertexContainer = truthVrt->stdcont();
439 //First truth particle vertex?
440 auto findVtx = std::find_if(stdVertexContainer.rbegin(), stdVertexContainer.rend(), acceptTruthVertex);
441 truthVertex = (findVtx == stdVertexContainer.rend()) ? nullptr : *findVtx;
442 } else {
443 ATH_MSG_WARNING("Cannot open " << m_truthVertexContainerName.key() << " truth vertex container");
444 }
445 if (not truthVertex) ATH_MSG_INFO ("Truth vertex did not pass cuts");
446 }
447 //
448 //Counters for cutflow
449 //
450 unsigned int nSelectedTruthTracks(0), nSelectedRecoTracks(0), nSelectedMatchedTracks(0), nAssociatedTruth(0), nMissingAssociatedTruth(0), nTruths(0);
451
452 CutFlow tmp_truth_cutflow( m_truthSelectionTool.get() ? m_truthSelectionTool->nCuts() : 0 );
453
454 //
455 //Loop over all reconstructed tracks
456 //
457 // If writing ntuples, use a truth-to-track(s) cache to handle truth matching.
458 // Based on the assumption that multiple tracks can (albeit rarely) share the same truth association.
459 std::map<const xAOD::TruthParticle*, std::vector<const xAOD::TrackParticle*>> cacheTruthMatching {};
460 //
461 std::vector<const xAOD::TrackParticle*> selectedTracks {};
462 selectedTracks.reserve(tracks->size());
463 unsigned int nTrackTOT = 0;
464 unsigned int nTrackCentral = 0;
465 unsigned int nTrackPt1GeV = 0;
466 for (const auto *const thisTrack: *tracks) {
467 //FIXME: Why is this w.r.t the primary vertex?
468 const asg::AcceptData& accept = m_trackSelectionTool->accept(*thisTrack, primaryvertex);
469 if (m_useTrackSelection and not accept) continue;
470 fillTrackCutFlow(accept); //?? Is this equal???
471
472 selectedTracks.push_back(thisTrack);
473 //Number of selected reco tracks
474 nSelectedRecoTracks++;
475
476 //Fill plots for selected reco tracks, hits / perigee / ???
477 nTrackTOT++;
478 if (thisTrack->pt() >= (1 * Gaudi::Units::GeV))
479 nTrackPt1GeV++;
480 if (std::abs(thisTrack->eta()) < 2.5)
481 nTrackCentral++;
482 m_monPlots->fill(*thisTrack, beamSpotWeight);
483 m_monPlots->fill(*thisTrack, puEvents, nVertices, beamSpotWeight); //fill mu dependent plots
484 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
485 float prob = getMatchingProbability(*thisTrack);
486
487 // This is where the Fake, and Really Fake fillers need to go. Where would the really really fakes go?
488 if (associatedTruth) {
489 nAssociatedTruth++;
490
491 // if there is associated truth also a truth selection tool was retrieved.
494 //FIXME: What is this for???
495 tmp_truth_cutflow.update( passed.missingCuts() );
496 }
497
498 if ((not std::isnan(prob)) and (prob > m_lowProb) and passed and (not m_usingSpecialPileupSwitch or isSelectedByPileupSwitch(*associatedTruth)) ) {
499 nSelectedMatchedTracks++;
500 bool truthIsFromB = false;
501 if ( m_doTruthOriginPlots and m_trackTruthOriginTool->isFrom(associatedTruth, 5) ) {
502 truthIsFromB = true;
503 }
504 m_monPlots->fill(*thisTrack, *associatedTruth, truthIsFromB, puEvents, beamSpotWeight); // Make plots requiring matched truth
505 }
506 }
507
508 const bool isAssociatedTruth = associatedTruth != nullptr;
509 const bool isFake = not std::isnan(prob) ? (prob < m_lowProb) : true;
510
511 if(!isAssociatedTruth) nMissingAssociatedTruth++;
512 m_monPlots->fillFakeRate(*thisTrack, isFake, isAssociatedTruth, puEvents, beamSpotWeight);
513
515 // Decorate track particle with extra flags
516 decorateTrackParticle(*thisTrack, accept);
517
518 if (isAssociatedTruth) {
519 // Decorate truth particle with extra flags
520 decorateTruthParticle(*associatedTruth, m_truthSelectionTool->accept(associatedTruth));
521
522 // Cache truth-to-track associations
523 auto cachedAssoc = cacheTruthMatching.find(associatedTruth);
524 // Check if truth particle already present in cache
525 if (cachedAssoc == cacheTruthMatching.end()) {
526 // If not yet present, add truth-to-track association in cache
527 cacheTruthMatching[associatedTruth] = {thisTrack};
528 }
529 else {
530 // If already present, cache additional track associations (here multiple track particle can be linked to the same truth particle)
531 cachedAssoc->second.push_back(thisTrack);
532 }
533 }
535 // Fill track only entries with dummy truth values
536 m_monPlots->fillNtuple(*thisTrack, primaryvertex);
537 }
538 }
539 }
541 // Now fill all truth-to-track associations
542 // Involves some double-filling of truth particles in cases where multiple tracks share the same truth association,
543 // these duplicates can be filtered in the ntuple by selecting only the 'best matched' truth-associated track particles.
544 for (auto& cachedAssoc: cacheTruthMatching) {
545 const xAOD::TruthParticle* thisTruth = cachedAssoc.first;
546
547 // Decorate that this truth particle is being filled to prevent double counting in truth particle loop
548 m_dec_hasTruthFilled(*thisTruth) = true;
549
550 // Sort all associated tracks by truth match probability
551 std::sort(cachedAssoc.second.begin(), cachedAssoc.second.end(),
552 [](const xAOD::TrackParticle* t1, const xAOD::TrackParticle* t2) { return getMatchingProbability(*t1) > getMatchingProbability(*t2); }
553 );
554
556 // Fill all tracks associated to to this truth particle, also recording 'truth match ranking' as index in probability-sorted vector of matched tracks
557 for (int itrack = 0; itrack < (int) cachedAssoc.second.size(); itrack++) {
558 const xAOD::TrackParticle* thisTrack = cachedAssoc.second[itrack];
559
560 // Fill track entries with truth association
561 m_monPlots->fillNtuple(*thisTrack, *thisTruth, primaryvertex, itrack);
562 }
563 }
564 }
565 }
566
567 m_monPlots->fill(nTrackTOT, nTrackCentral, nTrackPt1GeV, truthMu, actualMu, nVertices, beamSpotWeight);
568
569 //FIXME: I don't get why... this is here
570 if (m_truthSelectionTool.get()) {
571 ATH_MSG_DEBUG( CutFlow(tmp_truth_cutflow).report(m_truthSelectionTool->names()) );
572 std::lock_guard<std::mutex> lock(m_mutex);
573 m_truthCutFlow.merge(std::move(tmp_truth_cutflow));
574 }
575
576 //
577 //TruthParticle loop to fill efficiencies
578 //
579 for (int itruth = 0; itruth < (int) truthParticlesVec.size(); itruth++) { // Outer loop over all truth particles
580 nTruths++;
581 const xAOD::TruthParticle* thisTruth = truthParticlesVec[itruth];
582
583 // if the vector of truth particles is not empty also a truthSelectionTool was retrieved
584 const IAthSelectionTool::CutResult accept = m_truthSelectionTool->accept(thisTruth);
585 if (accept) {
586 ++nSelectedTruthTracks; // total number of truth which pass cuts per event
587 bool isEfficient(false); // weight for the trackeff histos
588 float matchingProbability{};
589 m_monPlots->fill(*thisTruth, beamSpotWeight); // This is filling truth-only plots
590
592 auto cachedAssoc = cacheTruthMatching.find(thisTruth);
593 // Check if truth particle already present in cache
594 if (cachedAssoc == cacheTruthMatching.end()) {
595 // If not yet present, then no track associated
596 cacheTruthMatching[thisTruth] = {};
597 }
598 m_monPlots->fillDuplicate(*thisTruth, cacheTruthMatching[thisTruth], beamSpotWeight);
599 }
600
601 //
602 //Loop over reco tracks to find the match
603 //
604 const xAOD::TrackParticle* matchedTrack = nullptr;
605 for (const auto& thisTrack: selectedTracks) { // Inner loop over selected track particleis
606 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
607 if (associatedTruth && associatedTruth == thisTruth) {
608 float prob = getMatchingProbability(*thisTrack);
609 if (not std::isnan(prob) && prob > m_lowProb) {
610 matchingProbability = prob;
611 isEfficient = true;
612 matchedTrack = thisTrack;
613 break;
614 }
615 }
616 }
617 if (!m_setCSVName.empty()) {
618 m_datfile <<eventInfo->eventNumber()<<","<<thisTruth->pdgId()<<","<<thisTruth->px()/ Gaudi::Units::GeV<<","
619 <<thisTruth->py()/ Gaudi::Units::GeV<<","<<thisTruth->pz()/ Gaudi::Units::GeV<<","
620 <<thisTruth->e()/ Gaudi::Units::GeV<<","<<thisTruth->pt()/ Gaudi::Units::GeV<<","
621 <<thisTruth->eta()<<","<<thisTruth->phi()<<","<<thisTruth->m()/ Gaudi::Units::GeV<<","
622 <<puEvents<<","<<nVertices<<","<<matchingProbability<<std::endl;
623 }
624 if (!thisTruth){
625 ATH_MSG_ERROR("An error occurred: Truth particle for tracking efficiency calculation is a nullptr");
626 }
627 else if (isEfficient && !matchedTrack){
628 ATH_MSG_ERROR("Something went wrong - we log a truth particle as reconstructed, but the reco track is a nullptr! Bailing out... ");
629 }
630 else{
631 ATH_MSG_DEBUG("Filling efficiency plots info monitoring plots");
632 m_monPlots->fillEfficiency(*thisTruth, matchedTrack, isEfficient, truthMu, actualMu, beamSpotWeight);
634 ATH_MSG_DEBUG("Filling technical efficiency plots info monitoring plots");
635 static const SG::ConstAccessor< float > nSilHitsAcc("nSilHits");
636 if (nSilHitsAcc.isAvailable(*thisTruth)) {
637 if (nSilHitsAcc(*thisTruth) >= m_minHits.value().at(getIndexByEta(*thisTruth))){
638 m_monPlots->fillTechnicalEfficiency(*thisTruth, isEfficient,
639 truthMu, actualMu, beamSpotWeight);
640 }
641 } else {
642 ATH_MSG_DEBUG("Cannot fill technical efficiency. Missing si hit information for truth particle.");
643 }
644 }
645 }
646 }
647
649 // Skip if already filled in track loop
650 if (hasTruthFilled(*thisTruth)) continue;
651
652 // Decorate truth particle with extra flags
653 decorateTruthParticle(*thisTruth, accept);
654
655 // Fill truth only entries with dummy track values
656 m_monPlots->fillNtuple(*thisTruth);
657 }
658 }
659
660 if (nSelectedRecoTracks == nMissingAssociatedTruth) {
661 if (not m_truthParticleName.key().empty()) {
662 ATH_MSG_DEBUG("NO TRACKS had associated truth.");
663 }
664 } else {
665 ATH_MSG_DEBUG(nAssociatedTruth << " tracks out of " << tracks->size() << " had associated truth.");
666 }
667
668 m_monPlots->fillCounter(nSelectedRecoTracks, InDetPerfPlot_nTracks::SELECTEDRECO, beamSpotWeight);
669 m_monPlots->fillCounter(tracks->size(), InDetPerfPlot_nTracks::ALLRECO, beamSpotWeight);
670 m_monPlots->fillCounter(nSelectedTruthTracks, InDetPerfPlot_nTracks::SELECTEDTRUTH, beamSpotWeight);
671 m_monPlots->fillCounter(nTruths, InDetPerfPlot_nTracks::ALLTRUTH, beamSpotWeight);
672 m_monPlots->fillCounter(nAssociatedTruth, InDetPerfPlot_nTracks::ALLASSOCIATEDTRUTH, beamSpotWeight);
673 m_monPlots->fillCounter(nSelectedMatchedTracks, InDetPerfPlot_nTracks::MATCHEDRECO, beamSpotWeight);
674
675 // Tracking In Dense Environment
678 getAsTruth,
679 truthParticlesVec,
680 *tracks,
681 primaryvertex,
682 beamSpotWeight) );
683 }
684 return StatusCode::SUCCESS;
685}
686
688 // Decorate outcome of track selection
689 m_dec_passedTrackSelection(track) = (bool)(passed);
690}
691
693 // Decorate outcome of truth selection
694 m_dec_passedTruthSelection(truth) = (bool)(passed);
695
696 // Decorate if selected by pileup switch
698}
699
701 if (!m_acc_hasTruthFilled.isAvailable(truth)) {
702 ATH_MSG_DEBUG("Truth particle not yet filled in ntuple");
703 return false;
704 }
705 return m_acc_hasTruthFilled(truth);
706}
707
709 if (!m_acc_selectedByPileupSwitch.isAvailable(truth)) {
710 ATH_MSG_DEBUG("Selected by pileup switch decoration requested from a truth particle but not available");
711 return false;
712 }
713 return m_acc_selectedByPileupSwitch(truth);
714}
715
716void InDetPhysValMonitoringTool::markSelectedByPileupSwitch(const std::vector<const xAOD::TruthParticle*> & truthParticles) const{
717 for (const auto& thisTruth: truthParticles) {
718 m_dec_selectedByPileupSwitch(*thisTruth) = true;
719 }
720}
721
722StatusCode
724 ATH_MSG_INFO("Booking hists " << name() << "with detailed level: " << m_detailLevel);
725 m_monPlots->initialize();
726 std::vector<HistData> hists = m_monPlots->retrieveBookedHistograms();
727 for (const auto& hist : hists) {
728 ATH_CHECK(regHist(hist.first, hist.second, all)); // ??
729 }
730 // do the same for Efficiencies, but there's a twist:
731 std::vector<EfficiencyData> effs = m_monPlots->retrieveBookedEfficiencies();
732 for (auto& eff : effs) {
733 // reg**** in the monitoring baseclass doesnt have a TEff version, but TGraph *
734 // pointers just get passed through, so we use that method after an ugly cast
735 ATH_CHECK(regGraph(reinterpret_cast<TGraph*>(eff.first), eff.second, all)); // ??
736 }
737 // register trees for ntuple writing
739 std::vector<TreeData> trees = m_monPlots->retrieveBookedTrees();
740 for (auto& t : trees) {
741 ATH_CHECK(regTree(t.first, t.second, all));
742 }
743 }
744
745 return StatusCode::SUCCESS;
746}
747
748StatusCode
750 ATH_MSG_INFO("Finalising hists " << name() << "...");
751 //TODO: ADD Printouts for Truth??
753 ATH_MSG_INFO("");
754 ATH_MSG_INFO("Now Cutflow for track cuts:");
755 ATH_MSG_INFO("");
756 for (int i = 0; i < (int) m_trackCutflow.size(); ++i) {
757 ATH_MSG_INFO("number after " << m_trackCutflowNames[i] << ": " << m_trackCutflow[i]);
758 }
759 }
760
761 ATH_MSG_INFO("");
762 ATH_MSG_INFO("Cutflow for truth tracks:");
763 if (m_truthSelectionTool.get()) {
764 ATH_MSG_INFO("Truth selection report: " << m_truthCutFlow.report( m_truthSelectionTool->names()) );
765 }
766 if (endOfRunFlag()) {
767 m_monPlots->finalize();
768 }
769 ATH_MSG_INFO("Successfully finalized hists");
770 return StatusCode::SUCCESS;
771}
772
773const std::vector<const xAOD::TruthParticle*>
774InDetPhysValMonitoringTool::getTruthParticles(const EventContext& ctx) const {
775
776 std::vector<const xAOD::TruthParticle*> tempVec {};
777
778 if (m_pileupSwitch == "All") {
779 if (m_truthParticleName.key().empty()) {
780 return tempVec;
781 }
783 if (not truthParticleContainer.isValid()) {
784 return tempVec;
785 }
786 tempVec.insert(tempVec.begin(), truthParticleContainer->begin(), truthParticleContainer->end());
787 } else {
788 if (m_pileupSwitch == "HardScatter") {
789 // get truthevent container to separate out pileup and hardscatter truth particles
790 if (not m_truthEventName.key().empty()) {
792 const xAOD::TruthEvent* event = (truthEventContainer.isValid()) ? truthEventContainer->at(0) : nullptr;
793 if (not event) {
794 return tempVec;
795 }
796 const auto& links = event->truthParticleLinks();
797 tempVec.reserve(event->nTruthParticles());
798 for (const auto& link : links) {
799 if (link.isValid()){
800 tempVec.push_back(*link);
801 }
802 }
803 }
804 } else if (m_pileupSwitch == "PileUp") {
805 if (not m_truthPileUpEventName.key().empty()) {
806 ATH_MSG_VERBOSE("getting TruthPileupEvents container");
807 // get truth particles from all pileup events
809 if (truthPileupEventContainer.isValid()) {
810 const unsigned int nPileup = truthPileupEventContainer->size();
811 tempVec.reserve(nPileup * 200); // quick initial guess, will still save some time
812 for (unsigned int i(0); i != nPileup; ++i) {
813 const auto *eventPileup = truthPileupEventContainer->at(i);
814 // get truth particles from each pileup event
815 int ntruth = eventPileup->nTruthParticles();
816 ATH_MSG_VERBOSE("Adding " << ntruth << " truth particles from TruthPileupEvents container");
817 const auto& links = eventPileup->truthParticleLinks();
818 for (const auto& link : links) {
819 if (link.isValid()){
820 tempVec.push_back(*link);
821 }
822 }
823 }
824 } else {
825 ATH_MSG_ERROR("no entries in TruthPileupEvents container!");
826 }
827 }
828 } else {
829 ATH_MSG_ERROR("bad value for PileUpSwitch");
830 }
831 }
832 return tempVec;
833}
834
835std::pair<const std::vector<const xAOD::TruthVertex*>, const std::vector<const xAOD::TruthVertex*>>
836InDetPhysValMonitoringTool::getTruthVertices(const EventContext& ctx) const {
837
838 std::vector<const xAOD::TruthVertex*> truthHSVertices = {};
839 truthHSVertices.reserve(5);
840 std::vector<const xAOD::TruthVertex*> truthPUVertices = {};
841 truthPUVertices.reserve(100);
842 const xAOD::TruthVertex* truthVtx = nullptr;
843
844 bool doHS = false;
845 bool doPU = false;
846 if (m_pileupSwitch == "All") {
847 doHS = true;
848 doPU = true;
849 }
850 else if (m_pileupSwitch == "HardScatter") {
851 doHS = true;
852 }
853 else if (m_pileupSwitch == "PileUp") {
854 doPU = true;
855 }
856 else {
857 ATH_MSG_ERROR("Bad value for PileUpSwitch: " << m_pileupSwitch);
858 }
859
860 if (doHS) {
861 if (not m_truthEventName.key().empty()) {
862 ATH_MSG_VERBOSE("Getting HS TruthEvents container.");
864 if (truthEventContainer.isValid()) {
865 for (const auto *const evt : *truthEventContainer) {
866 truthVtx = evt->signalProcessVertex();
867 if (truthVtx) {
868 truthHSVertices.push_back(truthVtx);
869 }
870 }
871 }
872 else {
873 ATH_MSG_ERROR("No entries in TruthEvents container!");
874 }
875 }
876 }
877
878 if (doPU) {
879 if (not m_truthPileUpEventName.key().empty()) {
880 ATH_MSG_VERBOSE("Getting PU TruthEvents container.");
882 if (truthPileupEventContainer.isValid()) {
883 for (const auto *const evt : *truthPileupEventContainer) {
884 // Get the PU vertex
885 // In all cases tested i_vtx=2 for PU
886 // but better to keep something generic
887 truthVtx = nullptr;
888 size_t i_vtx = 0; size_t n_vtx = evt->nTruthVertices();
889 while(!truthVtx && i_vtx<n_vtx){
890 truthVtx = evt->truthVertex(i_vtx);
891 i_vtx++;
892 }
893
894 if (truthVtx) {
895 truthPUVertices.push_back(truthVtx);
896 }
897 }
898 }
899 else {
900 ATH_MSG_DEBUG("No entries in TruthPileupEvents container");
901 }
902 }
903 }
904
905 return std::make_pair<const std::vector<const xAOD::TruthVertex*>, const std::vector<const xAOD::TruthVertex*>>((const std::vector<const xAOD::TruthVertex*>)truthHSVertices, (const std::vector<const xAOD::TruthVertex*>)truthPUVertices);
906
907}
908
909void
913
914void
915InDetPhysValMonitoringTool::fillCutFlow(const asg::AcceptData& accept, std::vector<std::string>& names,
916 std::vector<int>& cutFlow) {
917 // initialise cutflows
918 if (cutFlow.empty()) {
919 names.emplace_back("preCut");
920 cutFlow.push_back(0);
921 for (unsigned int i = 0; i != accept.getNCuts(); ++i) {
922 cutFlow.push_back(0);
923 names.push_back((std::string) accept.getCutName(i));
924 }
925 }
926 // get cutflow
927 cutFlow[0] += 1;
928 bool cutPositive = true;
929 for (unsigned int i = 0; i != (accept.getNCuts() + 1); ++i) {
930 if (!cutPositive) {
931 continue;
932 }
933 if (accept.getCutResult(i)) {
934 cutFlow[i + 1] += 1;
935 } else {
936 cutPositive = false;
937 }
938 }
939 }
940
942 double absEta = std::abs(truth.eta());
943 if (absEta > m_etaBins.value().back() || absEta < m_etaBins.value().front()) {
944 absEta = std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back());
945 ATH_MSG_INFO("Requesting cut value outside of configured eta range: clamping eta = "
946 << std::abs(truth.eta()) << " to eta= " << absEta);
947 } else
948 absEta = std::clamp(absEta, m_etaBins.value().front(), m_etaBins.value().back());
949 const auto pVal = std::lower_bound(m_etaBins.value().begin(), m_etaBins.value().end(), absEta);
950 const int bin = std::distance(m_etaBins.value().begin(), pVal) - 1;
951 ATH_MSG_DEBUG("Checking (abs(eta)/bin) = (" << absEta << "," << bin << ")");
952 return bin;
953}
954
956 IDPVM::CachedGetAssocTruth& getAsTruth,
957 const std::vector<const xAOD::TruthParticle*>& truthParticles,
958 const xAOD::TrackParticleContainer& tracks,
959 const xAOD::Vertex* primaryvertex,
960 float beamSpotWeight) {
961 // Define accessors
962 static const SG::ConstAccessor<std::vector<ElementLink<xAOD::IParticleContainer> > > ghosttruth("GhostTruth");
963 static const SG::ConstAccessor<int> btagLabel("HadronConeExclTruthLabelID");
964
965 if (truthParticles.empty()) {
966 ATH_MSG_WARNING("No entries in TruthParticles truth particle container. Skipping jet plots.");
967 return StatusCode::SUCCESS;
968 }
969
971 if (not jetHandle.isValid()) {
972 ATH_MSG_WARNING("Cannot open jet container " << m_jetContainerName.key() << ". Skipping jet plots.");
973 return StatusCode::SUCCESS;
974 }
975 const xAOD::JetContainer* jets = jetHandle.cptr();
976
977 // loop on jets
978 for (const xAOD::Jet *const thisJet: *jets) {
979 // pass jet cuts
980 if (not passJetCuts(*thisJet)) continue;
981 // check if b-jet
982 bool isBjet = false;
983 if (not btagLabel.isAvailable(*thisJet)){
984 ATH_MSG_WARNING("Failed to extract b-tag truth label from jet");
985 } else {
986 isBjet = (btagLabel(*thisJet) == 5);
987 }
988
989 // Retrieve associated ghost truth particles
990 if(not ghosttruth.isAvailable(*thisJet)) {
991 ATH_MSG_WARNING("Failed to extract ghost truth particles from jet");
992 } else {
993 for(const ElementLink<xAOD::IParticleContainer>& el : ghosttruth(*thisJet)) {
994 if (not el.isValid()) continue;
995
996 const xAOD::TruthParticle *truth = static_cast<const xAOD::TruthParticle*>(*el);
997 // Check delta R between track and jet axis
998 if (thisJet->p4().DeltaR(truth->p4()) > m_maxTrkJetDR) {
999 continue;
1000 }
1001 // Apply truth selection cuts
1002 const IAthSelectionTool::CutResult accept = m_truthSelectionTool->accept(truth);
1003 if(!accept) continue;
1004
1005 bool isEfficient(false);
1006
1007 for (const auto *thisTrack: tracks) {
1008 if (m_useTrackSelection and not (m_trackSelectionTool->accept(*thisTrack, primaryvertex))) {
1009 continue;
1010 }
1011
1012 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
1013 if (associatedTruth and associatedTruth == truth) {
1014 float prob = getMatchingProbability(*thisTrack);
1015 if (not std::isnan(prob) && prob > m_lowProb) {
1016 isEfficient = true;
1017 break;
1018 }
1019 }
1020 }
1021
1022 bool truthIsFromB = false;
1023 if ( m_doTruthOriginPlots and m_trackTruthOriginTool->isFrom(truth, 5) ) {
1024 truthIsFromB = true;
1025 }
1026 m_monPlots->fillEfficiency(*truth, *thisJet, isEfficient, isBjet, truthIsFromB, beamSpotWeight);
1027 }
1028 } // ghost truth
1029
1030 // loop on tracks
1031 for (const xAOD::TrackParticle *thisTrack: tracks) {
1032 if (m_useTrackSelection and not (m_trackSelectionTool->accept(*thisTrack, primaryvertex))) {
1033 continue;
1034 }
1035
1036 if (thisJet->p4().DeltaR(thisTrack->p4()) > m_maxTrkJetDR) {
1037 continue;
1038 }
1039
1040 float prob = getMatchingProbability(*thisTrack);
1041 if(std::isnan(prob)) prob = 0.0;
1042
1043 const xAOD::TruthParticle* associatedTruth = getAsTruth.getTruth(thisTrack);
1044 const bool unlinked = (associatedTruth==nullptr);
1045 const bool isFake = (associatedTruth && prob < m_lowProb);
1046 bool truthIsFromB = false;
1047 if ( m_doTruthOriginPlots and m_trackTruthOriginTool->isFrom(associatedTruth, 5) ) {
1048 truthIsFromB = true;
1049 }
1050 m_monPlots->fill(*thisTrack, *thisJet, isBjet, isFake, unlinked, truthIsFromB, beamSpotWeight);
1051 if (associatedTruth){
1052 m_monPlots->fillFakeRate(*thisTrack, *thisJet, isFake, isBjet, truthIsFromB, beamSpotWeight);
1053 }
1054 }
1055
1056 } // loop on jets
1057
1058 return StatusCode::SUCCESS;
1059}
1060
1061bool
1063 const float jetPt = jet.pt();
1064 const float jetEta = std::abs(jet.eta());
1065
1066 if (jetEta < m_jetAbsEtaMin) return false;
1067 if (jetEta > m_jetAbsEtaMax) return false;
1068 if (jetPt < m_jetPtMin) return false;
1069 if (jetPt > m_jetPtMax) return false;
1070 return true;
1071}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
header file for truth selection in this package
Helper class to provide constant type-safe access to aux data.
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::AuxElement::Decorator< bool > m_dec_passedTrackSelection
SG::ReadHandleKey< xAOD::VertexContainer > m_vertexContainerName
Primary vertex container's name.
std::pair< const std::vector< const xAOD::TruthVertex * >, const std::vector< const xAOD::TruthVertex * > > getTruthVertices(const EventContext &ctx) const
const std::vector< const xAOD::TruthParticle * > getTruthParticles(const EventContext &ctx) const
SG::AuxElement::Accessor< bool > m_acc_hasTruthFilled
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_truthParticleName
TruthParticle container's name.
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
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::AuxElement::Accessor< bool > m_acc_selectedByPileupSwitch
SG::AuxElement::Decorator< bool > m_dec_selectedByPileupSwitch
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::AuxElement::Decorator< bool > m_dec_hasTruthFilled
ToolHandle< InDet::IInDetTrackTruthOriginTool > m_trackTruthOriginTool
BooleanProperty m_useTrackSelection
Properties to fine-tune the tool behaviour.
void fillTrackCutFlow(const asg::AcceptData &accept)
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::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.
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
SG::AuxElement::Decorator< bool > m_dec_passedTruthSelection
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.
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
bool doTrkInJetPlots_unlinked_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 (and unlinked)
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