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