ATLAS Offline Software
Loading...
Searching...
No Matches
MergeTruthJetsTool Class Reference

an algorithm to merge truth jet collections in the overlay store More...

#include <MergeTruthJetsTool.h>

Inheritance diagram for MergeTruthJetsTool:
Collaboration diagram for MergeTruthJetsTool:

Public Member Functions

 MergeTruthJetsTool (const std::string &type, const std::string &name, const IInterface *parent)
StatusCode initialize () override final
 Initialize.
virtual StatusCode prepareEvent (const EventContext &ctx, unsigned int nInputEvents) override final
 called before the subevts loop.
virtual StatusCode mergeEvent (const EventContext &ctx) override final
 called at the end of the subevts loop.
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
virtual StatusCode processAllSubEvents (const EventContext &ctx) override final
 Merge the Truth JetContainers using the PileUpMergeSvc.
virtual void resetFilter () override final
 implementation of filter reset

Private Member Functions

virtual double processJetContainer (const xAOD::JetContainer *inputJetContainer, xAOD::JetContainer *outputJetContainer, const double &ptCut, const float &timeOfBCID, int eventNumber)
 JetContainer Loop.

Private Attributes

ServiceHandle< PileUpMergeSvcm_pMergeSvc {this, "PileUpMergeSvc", "PileUpMergeSvc", ""}
Gaudi::Property< std::string > m_inputJetCollKey {this, "InputTruthJetCollKey", "AntiKt4TruthJets", ""}
Gaudi::Property< std::string > m_inTimeOutputJetCollKey {this, "InTimeOutputTruthJetCollKey", "InTimeAntiKt4TruthJets", ""}
Gaudi::Property< std::string > m_outOfTimeOutputJetCollKey {this, "OutOfTimeTruthJetCollKey", "OutOfTimeAntiKt4TruthJets", ""}
Gaudi::Property< double > m_inTimePtCut {this, "InTimePtCut", 10.0*Gaudi::Units::GeV, ""}
Gaudi::Property< double > m_outOfTimePtCut {this, "OutOfTimePtCut", 15.0*Gaudi::Units::GeV, ""}
Gaudi::Property< bool > m_activateFilter {this, "ActivateFilter", false, ""}
Gaudi::Property< bool > m_includeSignalJets {this, "IncludeSignalJets", false, ""}
std::unique_ptr< xAOD::JetContainerm_inTimeOutputJetContainer {}
std::unique_ptr< xAOD::JetAuxContainerm_inTimeOutputJetAuxContainer {}
std::unique_ptr< xAOD::JetContainerm_outOfTimeOutputJetContainer {}
std::unique_ptr< xAOD::JetAuxContainerm_outOfTimeOutputJetAuxContainer {}
bool m_first_event {true}
double m_signal_max_pT {-1.0}
double m_pileup_max_pT {-1.0}

structors and AlgTool implementation

virtual bool toProcess (int bunchXing) const override
 the method this base class helps implementing
virtual bool filterPassed () const override
 dummy implementation of passing filter
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing
Gaudi::Property< int > m_vetoPileUpTruthLinks
bool m_filterPassed {true}

Detailed Description

an algorithm to merge truth jet collections in the overlay store

Definition at line 24 of file MergeTruthJetsTool.h.

Constructor & Destructor Documentation

◆ MergeTruthJetsTool()

MergeTruthJetsTool::MergeTruthJetsTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 11 of file MergeTruthJetsTool.cxx.

14 : PileUpToolBase(type, name, parent)
15{
16}
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)

Member Function Documentation

◆ filterPassed()

virtual bool PileUpToolBase::filterPassed ( ) const
inlineoverridevirtualinherited

dummy implementation of passing filter

Definition at line 49 of file PileUpToolBase.h.

49{ return m_filterPassed; }

◆ initialize()

StatusCode MergeTruthJetsTool::initialize ( )
finaloverridevirtual

Initialize.

Reimplemented from PileUpToolBase.

Definition at line 18 of file MergeTruthJetsTool.cxx.

19{
20 ATH_MSG_DEBUG ( "Initializing " << name());
21 ATH_CHECK(m_pMergeSvc.retrieve());
22 return StatusCode::SUCCESS;
23}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
ServiceHandle< PileUpMergeSvc > m_pMergeSvc

◆ mergeEvent()

StatusCode MergeTruthJetsTool::mergeEvent ( const EventContext & ctx)
finaloverridevirtual

called at the end of the subevts loop.

Not (necessarily) able to access SubEvents

Definition at line 94 of file MergeTruthJetsTool.cxx.

95{
96 ATH_MSG_VERBOSE ( "mergeEvent" );
97
98 // Veto event when m_pileup_max_pT>m_signal_max_pT
100 ATH_MSG_INFO ( "Highest pT Jet in Hard-scatter event = " << m_signal_max_pT
101 << ", highest pT jet in a background event = " << m_pileup_max_pT
102 << ". Therefore filtering this hard-scatter event." );
103 m_filterPassed = false;
104 }
105
106 ATH_CHECK( evtStore()->record( std::move( m_inTimeOutputJetContainer ),
108 ATH_CHECK( evtStore()->record( std::move( m_inTimeOutputJetAuxContainer
109 ), m_inTimeOutputJetCollKey + "Aux." ) );
110
111 ATH_CHECK( evtStore()->record( std::move( m_outOfTimeOutputJetContainer
113 ATH_CHECK( evtStore()->record( std::move(
115 ) );
116
117 return StatusCode::SUCCESS;
118}
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
std::unique_ptr< xAOD::JetContainer > m_outOfTimeOutputJetContainer
std::unique_ptr< xAOD::JetAuxContainer > m_outOfTimeOutputJetAuxContainer
Gaudi::Property< bool > m_activateFilter
std::unique_ptr< xAOD::JetAuxContainer > m_inTimeOutputJetAuxContainer
std::unique_ptr< xAOD::JetContainer > m_inTimeOutputJetContainer
Gaudi::Property< std::string > m_inTimeOutputJetCollKey
Gaudi::Property< std::string > m_outOfTimeOutputJetCollKey

◆ prepareEvent()

StatusCode MergeTruthJetsTool::prepareEvent ( const EventContext & ctx,
unsigned int nInputEvents )
finaloverridevirtual

called before the subevts loop.

Not (necessarily) able to access SubEvents

Definition at line 25 of file MergeTruthJetsTool.cxx.

26{
27 ATH_MSG_VERBOSE ( "prepareEvent()" );
28 ATH_MSG_DEBUG ( "prepareEvent: there are " << nInputEvents << " subevents in this event." );
29 m_first_event = true;
30
31 m_inTimeOutputJetContainer = std::make_unique< xAOD::JetContainer >();
32 m_inTimeOutputJetAuxContainer = std::make_unique< xAOD::JetAuxContainer >();
34
35 m_outOfTimeOutputJetContainer = std::make_unique< xAOD::JetContainer >();
36 m_outOfTimeOutputJetAuxContainer = std::make_unique< xAOD::JetAuxContainer >();
38
39 return StatusCode::SUCCESS;
40}

◆ processAllSubEvents()

StatusCode MergeTruthJetsTool::processAllSubEvents ( const EventContext & ctx)
finaloverridevirtual

Merge the Truth JetContainers using the PileUpMergeSvc.

Reimplemented from PileUpToolBase.

Definition at line 120 of file MergeTruthJetsTool.cxx.

121{
122 ATH_MSG_VERBOSE ( "processAllSubEvents()" );
123
124 m_first_event = true;
125
126 m_inTimeOutputJetContainer = std::make_unique< xAOD::JetContainer >();
127 m_inTimeOutputJetAuxContainer = std::make_unique< xAOD::JetAuxContainer >();
129
130 m_outOfTimeOutputJetContainer = std::make_unique< xAOD::JetContainer >();
131 m_outOfTimeOutputJetAuxContainer = std::make_unique< xAOD::JetAuxContainer >();
133
135 TruthJetList truthList;
136 if ( (m_pMergeSvc->retrieveSubEvtsData(m_inputJetCollKey.value(), truthList)).isSuccess() ) {
137 if (!truthList.empty()) {
138 //now merge all collections into one
139 TruthJetList::const_iterator jetColl_iter(truthList.begin());
140 const TruthJetList::const_iterator endOfJetColls(truthList.end());
141 while (jetColl_iter!=endOfJetColls) {
142 const int eventNumber = (jetColl_iter)->first.index();
143 //FIXME we are forced to do a deep copy
144 if (static_cast<int>((jetColl_iter)->first.time())==0) {
145 if (m_first_event) {
146 //FIXME this may not be robust in the case that there is no TruthJet container from the signal event.
147 m_signal_max_pT = this->processJetContainer(&(*((jetColl_iter)->second)), nullptr, 0.0, 0.0, eventNumber);
149 (void)this->processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer.get(), m_inTimePtCut, 0.0, eventNumber);
150 }
151 else {
152 ATH_MSG_VERBOSE ( "Don't include signal events in output Truth Jet Containers.");
153 }
154 m_first_event=false;
155 ++jetColl_iter;
156 continue;
157 }
158 const double pileup_this_pT=this->processJetContainer(&(*((jetColl_iter)->second)), m_inTimeOutputJetContainer.get(), m_inTimePtCut, 0.0, eventNumber);
159 ATH_MSG_VERBOSE ( "highest jet pT in the current background event = " << pileup_this_pT);
160 if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT;
161 ATH_MSG_DEBUG ( "highest in-time background jet pT so far = " << m_pileup_max_pT);
162 }
163 else {
164 const float timeOfBCID(static_cast<float>((jetColl_iter)->first.time()));
165 (void)this->processJetContainer(&(*((jetColl_iter)->second)), m_outOfTimeOutputJetContainer.get(), m_outOfTimePtCut, timeOfBCID, eventNumber);
166 }
167 //signal is always the first event, so if the first event
168 //wasn't in-time, then the signal collection was missing and
169 //we should skip further checks.
170 if(m_first_event) {m_first_event=false;}
171 ++jetColl_iter;
172 }
173 }
174 else {
175 ATH_MSG_DEBUG ( "processAllSubEvents: TruthJetList is empty" );
176 }
177 }
178 else {
179 ATH_MSG_ERROR ( "processAllSubEvents: Can not find TruthJetList" );
180 }
181 // Veto event when m_pileup_max_pT>m_signal_max_pT
183 ATH_MSG_INFO ( "Highest pT Jet in Hard-scatter event = " << m_signal_max_pT
184 << ", highest pT jet in a background event = " << m_pileup_max_pT
185 << ". Therefore filtering this hard-scatter event." );
186 m_filterPassed = false;
187 }
188 ATH_CHECK( evtStore()->record( std::move( m_inTimeOutputJetContainer ),
190 ATH_CHECK( evtStore()->record( std::move( m_inTimeOutputJetAuxContainer
191 ), m_inTimeOutputJetCollKey + "Aux." ) );
192
193 ATH_CHECK( evtStore()->record( std::move( m_outOfTimeOutputJetContainer
195 ATH_CHECK( evtStore()->record( std::move(
197 ) );
198
199 return StatusCode::SUCCESS;
200}
#define ATH_MSG_ERROR(x)
Gaudi::Property< std::string > m_inputJetCollKey
virtual double processJetContainer(const xAOD::JetContainer *inputJetContainer, xAOD::JetContainer *outputJetContainer, const double &ptCut, const float &timeOfBCID, int eventNumber)
JetContainer Loop.
Gaudi::Property< double > m_inTimePtCut
Gaudi::Property< bool > m_includeSignalJets
Gaudi::Property< double > m_outOfTimePtCut
bool first
Definition DeMoScan.py:534
std::list< value_t > type
type of the collection of timed data object

◆ processBunchXing()

StatusCode MergeTruthJetsTool::processBunchXing ( int bunchXing,
SubEventIterator bSubEvents,
SubEventIterator eSubEvents )
finaloverridevirtual

called for each active bunch-crossing to process current SubEvents bunchXing is in ns

Reimplemented from PileUpToolBase.

Definition at line 42 of file MergeTruthJetsTool.cxx.

45{
46 ATH_MSG_VERBOSE ( "processBunchXing()" );
47 SubEventIterator iEvt(bSubEvents);
48 while (iEvt != eSubEvents) {
49 const xAOD::JetContainer* inputJetContainer(nullptr);
50 if (m_pMergeSvc->retrieveSingleSubEvtData(m_inputJetCollKey.value(), inputJetContainer,
51 bunchXing, iEvt).isSuccess()) {
52 ATH_MSG_VERBOSE("Found an xAOD::JetContainer in storeGate.");
53 if ( !inputJetContainer ) {
54 ATH_MSG_ERROR("Unable to retrieve input jet container: " << m_inputJetCollKey);
55 return StatusCode::FAILURE;
56 }
57 ATH_MSG_DEBUG ( "processBunchXing: bunch Crossing = " << bunchXing << " JetContainer size = " << inputJetContainer->size());
58 const int eventNumber{iEvt->index()};
59 if (bunchXing==0) {
60 if (m_first_event) {//FIXME this may not be robust in the case that there is no TruthJet container from the signal event.
61 m_signal_max_pT = this->processJetContainer(&(*inputJetContainer), nullptr, 0.0, 0.0, eventNumber);
62 ATH_MSG_DEBUG ( "Setting m_signal_max_pT = " << m_signal_max_pT);
64 (void)this->processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer.get(), m_inTimePtCut, 0.0, eventNumber);
65 }
66 else {
67 ATH_MSG_VERBOSE ( "Don't include signal events in output Truth Jet Containers.");
68 }
69 m_first_event=false;
70 ++iEvt;
71 continue;
72 }
73 const double pileup_this_pT=this->processJetContainer(&(*inputJetContainer), m_inTimeOutputJetContainer.get(), m_inTimePtCut, 0.0, eventNumber);
74 ATH_MSG_VERBOSE ( "highest jet pT in the current background event = " << pileup_this_pT);
75 if (pileup_this_pT>m_pileup_max_pT) m_pileup_max_pT=pileup_this_pT;
76 ATH_MSG_DEBUG ( "highest in-time background jet pT so far = " << m_pileup_max_pT);
77 }
78 else {
79 const float timeOfBCID(static_cast<float>(iEvt->time()));
80 (void)this->processJetContainer(&(*inputJetContainer), m_outOfTimeOutputJetContainer.get(), m_outOfTimePtCut, timeOfBCID, eventNumber);
81 }
82 }
83 else {
84 ATH_MSG_DEBUG ( "processBunchXing: No JetContainers found." );
85 }
86 ++iEvt;
87 }
88 //signal is always the first event, so even if we didn't see
89 //anything should set this to false here.
90 if(m_first_event) {m_first_event=false;}
91 return StatusCode::SUCCESS;
92}
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
JetContainer_v1 JetContainer
Definition of the current "jet container version".

◆ processJetContainer()

double MergeTruthJetsTool::processJetContainer ( const xAOD::JetContainer * inputJetContainer,
xAOD::JetContainer * outputJetContainer,
const double & ptCut,
const float & timeOfBCID,
int eventNumber )
privatevirtual

JetContainer Loop.

Definition at line 203 of file MergeTruthJetsTool.cxx.

204{
205 const static SG::AuxElement::Accessor< float > timingAccessor("Timing");
206 const static SG::AuxElement::Accessor< int > eventNumberAccessor("pileupEventNumber");
207 double max_pT=-1.;
208 for (const xAOD::Jet *origTruthJet : *inputJetContainer) {
209 if (not origTruthJet) continue;
210 try {
211 if (origTruthJet->pt()<ptCut) {
212 ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << origTruthJet->pt() << " GeV failed ptCut of " << ptCut << "GeV." );
213 continue;
214 }
215 if (max_pT<origTruthJet->pt()) max_pT=origTruthJet->pt();
216 ATH_MSG_VERBOSE( "processJetContainer: Jet with pT = " << origTruthJet->pt() << " GeV passed ptCut of " << ptCut << "GeV." );
217 }
218 catch (...) {
219 ATH_MSG_ERROR ( "Failed to find Truth jet pT for Jet in a BCID at time = " << timeOfBCID );
220 }
221 if (!outputJetContainer) continue;
222 xAOD::Jet* outputTruthJet = new xAOD::Jet();
223 outputJetContainer->push_back(outputTruthJet);
224 *outputTruthJet = *origTruthJet; // deep-copy
225 if (timingAccessor.isAvailable(*origTruthJet)) {
226 timingAccessor(*outputTruthJet) = timeOfBCID + timingAccessor(*origTruthJet);
227 } else {
228 timingAccessor(*outputTruthJet) = timeOfBCID;
229 }
230 // add the pile-up event number
231 eventNumberAccessor(*outputTruthJet) = eventNumber;
232 }
233 return max_pT;
234}
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
Jet_v1 Jet
Definition of the current "jet version".

◆ resetFilter()

virtual void MergeTruthJetsTool::resetFilter ( )
inlinefinaloverridevirtual

implementation of filter reset

Reimplemented from PileUpToolBase.

Definition at line 49 of file MergeTruthJetsTool.h.

◆ toProcess()

virtual bool PileUpToolBase::toProcess ( int bunchXing) const
inlineoverridevirtualinherited

the method this base class helps implementing

Reimplemented in MergeHijingParsTool, and MergeTrackRecordCollTool.

Definition at line 32 of file PileUpToolBase.h.

32 {
33 //closed interval [m_firstXing,m_lastXing]
34 return !((m_firstXing > bunchXing) || (bunchXing > m_lastXing));
35 }
Gaudi::Property< int > m_firstXing
Gaudi::Property< int > m_lastXing

Member Data Documentation

◆ m_activateFilter

Gaudi::Property<bool> MergeTruthJetsTool::m_activateFilter {this, "ActivateFilter", false, ""}
private

Definition at line 60 of file MergeTruthJetsTool.h.

60{this, "ActivateFilter", false, ""};

◆ m_filterPassed

bool PileUpToolBase::m_filterPassed {true}
protectedinherited

Definition at line 60 of file PileUpToolBase.h.

60{true};

◆ m_first_event

bool MergeTruthJetsTool::m_first_event {true}
private

Definition at line 66 of file MergeTruthJetsTool.h.

66{true};

◆ m_firstXing

Gaudi::Property<int> PileUpToolBase::m_firstXing
protectedinherited
Initial value:
{this, "FirstXing", -999,
"First bunch-crossing in which det is live"}

Definition at line 54 of file PileUpToolBase.h.

54 {this, "FirstXing", -999,
55 "First bunch-crossing in which det is live"};

◆ m_includeSignalJets

Gaudi::Property<bool> MergeTruthJetsTool::m_includeSignalJets {this, "IncludeSignalJets", false, ""}
private

Definition at line 61 of file MergeTruthJetsTool.h.

61{this, "IncludeSignalJets", false, ""};

◆ m_inputJetCollKey

Gaudi::Property<std::string> MergeTruthJetsTool::m_inputJetCollKey {this, "InputTruthJetCollKey", "AntiKt4TruthJets", ""}
private

Definition at line 55 of file MergeTruthJetsTool.h.

55{this, "InputTruthJetCollKey", "AntiKt4TruthJets", ""};

◆ m_inTimeOutputJetAuxContainer

std::unique_ptr< xAOD::JetAuxContainer > MergeTruthJetsTool::m_inTimeOutputJetAuxContainer {}
private

Definition at line 63 of file MergeTruthJetsTool.h.

63{};

◆ m_inTimeOutputJetCollKey

Gaudi::Property<std::string> MergeTruthJetsTool::m_inTimeOutputJetCollKey {this, "InTimeOutputTruthJetCollKey", "InTimeAntiKt4TruthJets", ""}
private

Definition at line 56 of file MergeTruthJetsTool.h.

56{this, "InTimeOutputTruthJetCollKey", "InTimeAntiKt4TruthJets", ""};

◆ m_inTimeOutputJetContainer

std::unique_ptr< xAOD::JetContainer > MergeTruthJetsTool::m_inTimeOutputJetContainer {}
private

Definition at line 62 of file MergeTruthJetsTool.h.

62{};

◆ m_inTimePtCut

Gaudi::Property<double> MergeTruthJetsTool::m_inTimePtCut {this, "InTimePtCut", 10.0*Gaudi::Units::GeV, ""}
private

Definition at line 58 of file MergeTruthJetsTool.h.

58{this, "InTimePtCut", 10.0*Gaudi::Units::GeV, ""};

◆ m_lastXing

Gaudi::Property<int> PileUpToolBase::m_lastXing
protectedinherited
Initial value:
{this, "LastXing", 999,
"Last bunch-crossing in which det is live"}

Definition at line 56 of file PileUpToolBase.h.

56 {this, "LastXing", 999,
57 "Last bunch-crossing in which det is live"};

◆ m_outOfTimeOutputJetAuxContainer

std::unique_ptr< xAOD::JetAuxContainer > MergeTruthJetsTool::m_outOfTimeOutputJetAuxContainer {}
private

Definition at line 65 of file MergeTruthJetsTool.h.

65{};

◆ m_outOfTimeOutputJetCollKey

Gaudi::Property<std::string> MergeTruthJetsTool::m_outOfTimeOutputJetCollKey {this, "OutOfTimeTruthJetCollKey", "OutOfTimeAntiKt4TruthJets", ""}
private

Definition at line 57 of file MergeTruthJetsTool.h.

57{this, "OutOfTimeTruthJetCollKey", "OutOfTimeAntiKt4TruthJets", ""};

◆ m_outOfTimeOutputJetContainer

std::unique_ptr< xAOD::JetContainer > MergeTruthJetsTool::m_outOfTimeOutputJetContainer {}
private

Definition at line 64 of file MergeTruthJetsTool.h.

64{};

◆ m_outOfTimePtCut

Gaudi::Property<double> MergeTruthJetsTool::m_outOfTimePtCut {this, "OutOfTimePtCut", 15.0*Gaudi::Units::GeV, ""}
private

Definition at line 59 of file MergeTruthJetsTool.h.

59{this, "OutOfTimePtCut", 15.0*Gaudi::Units::GeV, ""};

◆ m_pileup_max_pT

double MergeTruthJetsTool::m_pileup_max_pT {-1.0}
private

Definition at line 68 of file MergeTruthJetsTool.h.

68{-1.0};

◆ m_pMergeSvc

ServiceHandle<PileUpMergeSvc> MergeTruthJetsTool::m_pMergeSvc {this, "PileUpMergeSvc", "PileUpMergeSvc", ""}
private

Definition at line 54 of file MergeTruthJetsTool.h.

54{this, "PileUpMergeSvc", "PileUpMergeSvc", ""};

◆ m_signal_max_pT

double MergeTruthJetsTool::m_signal_max_pT {-1.0}
private

Definition at line 67 of file MergeTruthJetsTool.h.

67{-1.0};

◆ m_vetoPileUpTruthLinks

Gaudi::Property<int> PileUpToolBase::m_vetoPileUpTruthLinks
protectedinherited
Initial value:
{this, "VetoPileUpTruthLinks", true,
"Ignore links to suppressed pile-up truth"}

Definition at line 58 of file PileUpToolBase.h.

58 {this, "VetoPileUpTruthLinks", true,
59 "Ignore links to suppressed pile-up truth"};

The documentation for this class was generated from the following files: