ATLAS Offline Software
Loading...
Searching...
No Matches
MergeMcEventCollTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MCTRUTHSIMALGS_MERGEMCEVENTCOLLTOOL_H
6#define MCTRUTHSIMALGS_MERGEMCEVENTCOLLTOOL_H
7
9
10#include "Gaudi/Property.h"
11#include "GaudiKernel/ServiceHandle.h"
12#include "GaudiKernel/PhysicalConstants.h"
13
14#include <utility> /* pair */
15
17
20#include "AtlasHepMC/HeavyIon.h"
29public:
30 MergeMcEventCollTool(const std::string& type,
31 const std::string& name,
32 const IInterface* parent);
33 virtual StatusCode initialize() override final;
36 virtual StatusCode prepareEvent(const EventContext& ctx, unsigned int nInputEvents) override final;
39 virtual StatusCode mergeEvent(const EventContext& ctx) override final;
42 virtual StatusCode processBunchXing(int bunchXing,
43 SubEventIterator bSubEvents,
44 SubEventIterator eSubEvents) override final;
45
48 // virtual bool toProcess(int bunchXing) const;
49
50 virtual StatusCode processAllSubEvents(const EventContext& ctx) override final;
51
52private:
53 //** The types used to classify the events. NOPUTYPE is used both as the number of types, and to flag a reject (no type)
55
56 //** Add the required information from the current GenEvent to the output McEventCollection
57 StatusCode processEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex, int pileupType);
58 //** Special case of processEvent for the first (signal) GenEvent
59 StatusCode processFirstSubEvent(const McEventCollection *pMcEvtColl);
60 //** Add the required sub-set of the information from the current GenEvent to the output McEventCollection
61 StatusCode processUnfilteredEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex, int pileupType);
62 //** This is for events which have already been truth-filtered. Add the whole GenEvent to the output McEventCollection
63 StatusCode processTruthFilteredEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex, int pileupType);
64 //** Remove any empty background GenEvents from the output McEventCollection
66 //** Print out detailed debug info if required.
68 //** Ensure that any GenEvent::HeavyIon info is stored in the signal GenEvent.
69 StatusCode saveHeavyIonInfo(const McEventCollection *pMcEvtColl);
70 //** Classify the current GenParticle according to the MC Truth Taskforce requirements
71 MergeMcEventCollTool::puType classifyVertex(const HepMC::ConstGenParticlePtr& pCurrentVertexParticle, const HepMC::ConstGenVertexPtr& pCurrentParticleProductionVertex, double currentEventTime);
72 //** Check if the current GenVertex contains beam particles
73 bool isInitialCollisionVertex(const HepMC::ConstGenVertexPtr& pCurrentVertex) const;
74 //** Check whether the current McEventCollection has already been truth-filtered
75 bool isTruthFiltertedMcEventCollection(const McEventCollection *pMcEvtColl) const;
76 //** Map from GenEvent to puType FIXME: Simpler to key the map on GenEvent* ?
77 typedef std::map<std::pair<int,int>, int> PileUpBackgroundMap;
79 //** Update the map of GenEvent->puType
80 void updateClassificationMap(int signal_process_id, int event_number, int hack, int classification, bool firstUpdateForThisEvent);
81
82 ServiceHandle<PileUpMergeSvc> m_pMergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", "Handle for the PileUpMergeSvc (provides input McEventCollections)"};
83 //** New McEventCollection to be written out to file
85 StringProperty m_truthCollInputKey{this, "TruthCollInputKey", "TruthEvent", "Name of input McEventCollection"};
86 StringProperty m_truthCollOutputKey{this, "TruthCollOutputKey", "TruthEvent", "Name of output McEventCollection"};
87 BooleanProperty m_keepUnstable{this, "KeepUnstable", false, "Do not cut unstable particles"};
88 DoubleProperty m_absEtaMax{this, "AbsEtaMax", 5.0, "Eta cut-off for INTIME GenParticles"};
89 DoubleProperty m_absEtaMax_outOfTime{this,"OutOfTimeAbsEtaMax", 3.0, "Eta cut-off for OUTOFTIME GenParticles"};
90 DoubleProperty m_lowTimeToKeep{this, "LowTimeToKeep", -51.0, "leading edge in ns of the time window to keep if SaveOutOfTimePileUp is true"};
91 DoubleProperty m_highTimeToKeep{this, "HighTimeToKeep", 51.0, "trailing edge in ns of the time window to keep if SaveOutOfTimePileUp is true"};
92 //** Radius acceptance cut on production vertex of all stable particles (in mm)
93 DoubleProperty m_rRange{this, "rRange", 20.0*Gaudi::Units::mm, "rRange of production vertex in mm"};
94 //** Radius acceptance squared to speed up cut
95 double m_r2Range{400.0};
96 //** Cut on Z coordinate of production vertex in mm, to distinguish between minbias and cavern background categories
97 DoubleProperty m_zRange{this, "zRange", 200.0*Gaudi::Units::mm, "z range of production vertex in mm"};
98 DoubleProperty m_ptMin{this, "ptMin", 0.4*Gaudi::Units::GeV, "Minimum threshold for pT for selected pileup particles in MeV"};
99 DoubleProperty m_minKinE{this, "EKinMin", 1.0*Gaudi::Units::MeV, "Minimum threshold for Kinetic Energy of selected cavern events in MeV"};
100 //** save minimum bias events in the t0 bunch xing
101 BooleanProperty m_saveInTimePileup{this, "SaveInTimeMinBias", true, "save min bias particles in the t0 xing"};
102 //** save minbias events which are "close" by (within [ m_lowTimeToKeep, m_highTimeToKeep ])
103 BooleanProperty m_saveOutOfTimePileup{this, "SaveOutOfTimeMinBias", true, "save out of time min bias particles in the [LowTimeToKeep:HighTimeToKeep] range"};
104 //** save as well the rest of minbias
105 BooleanProperty m_saveRestOfPileup{this, "SaveRestOfMinBias", false, "save the rest of out of time min bias particles as well"};
106 //** save as well the cavern background
107 BooleanProperty m_saveCavernBackground{this, "SaveCavernBackground", true, "save the cavern background as well"};
108 //** do the slimming - flag to do slimming or not
109 BooleanProperty m_doSlimming{this, "DoSlimming", true, "flag to do the slimming or save everything"};
110 //** Should any details of GenEvents corresponding to each puType be saved?
112 //** The index (before sorting) within the McEventCollection where the background events start
114 //** Bool to indicate that the next GenEvent is a new signal event
115 bool m_newevent{true};
116 //** The total number of GenEvents that will be passed for the current signal event
117 unsigned int m_nInputMcEventColls{0};
118 //** How many background events have been read so far for this signal event
119 unsigned int m_nBkgEventsReadSoFar{0};
120 //** Ensure that the collision GenVertex objects of minbias background events are saved.
121 BooleanProperty m_addBackgroundCollisionVertices{this, "AddBackgroundCollisionVertices", true, "ensure that the collision GenVertex objects of minbias background events are saved."};
122 //** Should empty GenEvents be removed from the output McEventCollection?
123 BooleanProperty m_compressOutputCollection{this, "CompressOutputCollection", false, "Remove all empty GenEvents from the output McEventCollection"};
124 //** Just save the Signal GenEvent
125 BooleanProperty m_onlySaveSignalTruth{this, "OnlySaveSignalTruth", false, "Just save the Signal GenEvent"};
126 //** Temporary store for the true signal event number
128
129};
130#endif //MCTRUTHSIMALGS_MERGEMCEVENTCOLLTOOL_H
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
helper base class IPileUpTool::toProcess().
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
virtual StatusCode mergeEvent(const EventContext &ctx) override final
called at the end of the subevts loop.
virtual StatusCode prepareEvent(const EventContext &ctx, unsigned int nInputEvents) override final
called before the subevts loop.
BooleanProperty m_addBackgroundCollisionVertices
BooleanProperty m_onlySaveSignalTruth
ServiceHandle< PileUpMergeSvc > m_pMergeSvc
BooleanProperty m_saveRestOfPileup
MergeMcEventCollTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override final
bool isInitialCollisionVertex(const HepMC::ConstGenVertexPtr &pCurrentVertex) const
DoubleProperty m_absEtaMax_outOfTime
McEventCollection * m_pOvrlMcEvColl
PileUpBackgroundMap m_backgroundClassificationMap
StatusCode processTruthFilteredEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex, int pileupType)
StatusCode processUnfilteredEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex, int pileupType)
virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
called for each active bunch-crossing to process current SubEvents bunchXing is in ns
BooleanProperty m_saveOutOfTimePileup
DoubleProperty m_highTimeToKeep
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
return false if not interested in certain xing times (in ns) implemented by default in PileUpToolBase...
BooleanProperty m_keepUnstable
StringProperty m_truthCollInputKey
StatusCode processEvent(const McEventCollection *pMcEvtColl, const double currentEventTime, const int currentBkgEventIndex, int pileupType)
MergeMcEventCollTool::puType classifyVertex(const HepMC::ConstGenParticlePtr &pCurrentVertexParticle, const HepMC::ConstGenVertexPtr &pCurrentParticleProductionVertex, double currentEventTime)
bool isTruthFiltertedMcEventCollection(const McEventCollection *pMcEvtColl) const
void printDetailsOfMergedMcEventCollection() const
std::map< std::pair< int, int >, int > PileUpBackgroundMap
StatusCode saveHeavyIonInfo(const McEventCollection *pMcEvtColl)
BooleanProperty m_compressOutputCollection
BooleanProperty m_saveInTimePileup
unsigned int m_startingIndexForBackground
StatusCode processFirstSubEvent(const McEventCollection *pMcEvtColl)
StatusCode compressOutputMcEventCollection()
StringProperty m_truthCollOutputKey
void updateClassificationMap(int signal_process_id, int event_number, int hack, int classification, bool firstUpdateForThisEvent)
BooleanProperty m_saveCavernBackground
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60