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

#include <GenAodValidationTool.h>

Inheritance diagram for GenAodValidationTool:
Collaboration diagram for GenAodValidationTool:

Public Member Functions

 GenAodValidationTool (const std::string &type, const std::string &name, const IInterface *parent)
 Constructor with parameters:
virtual ~GenAodValidationTool ()
 Destructor:
StatusCode initialize ()
 Athena Algorithm's Hooks.
StatusCode execute ()
StatusCode finalize ()
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Inline methods:

Protected Types

typedef ToolHandle< IIOHepMcToolHepMcTool_t
 shorthand for lazy people (good coders are lazy people, aren't they ?)

Protected Member Functions

 GenAodValidationTool ()
 Default constructor:
virtual StatusCode initializeTool ()
 Non-const methods:
virtual StatusCode finalizeTool ()
virtual StatusCode executeTool ()
 Main method to perform the validation.
virtual StatusCode executeTool (const McEventCollection *refMcEvents, const McEventCollection *checkMcEvents)
 Main method to perform the validation:
virtual StatusCode executeTool (const HepMC::GenEvent *refMcEvents, const HepMC::GenEvent *checkMcEvents)
 Main method to perform the validation (directly onto the GenEvents):
bool compareVtx (const HepMC::ConstGenVertexPtr &vtx1, const HepMC::ConstGenVertexPtr &vtx2) const
 Check that 2 given vertices are the same:
bool compareParts (const HepMC::ConstGenParticlePtr &p1, const HepMC::ConstGenParticlePtr &p2) const
 Check that 2 given particles are the same:
StatusCode setupHepMcWriterTools ()
 Request pointers to the HepMcWriterTools to be able to write out HepMC::GenEvent for further comparison (off-framework).
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

StringProperty m_refMcEventsName
 Location of the reference McEventCollection.
StringProperty m_checkMcEventsName
 Location of the 'to-be-validated' McEventCollection.
StringProperty m_hardVtxOutFileName
 Name of the output text file which will contain the hard-scattering vertices.
std::ofstream * m_outFile
 Pointer to the output text file containing hard-scattering vertices.
HepMcTool_t m_refMcEventWriter
 Tool to write the reference HepMC::GenEvent into a dedicated file.
HepMcTool_t m_checkMcEventWriter
 Tool to write the 'to-be-checked' HepMC::GenEvent into a dedicated file.
unsigned int m_nAnalysedEvents
 Counter of analysed events.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 31 of file GenAodValidationTool.h.

Member Typedef Documentation

◆ HepMcTool_t

typedef ToolHandle<IIOHepMcTool> GenAodValidationTool::HepMcTool_t
protected

shorthand for lazy people (good coders are lazy people, aren't they ?)

Definition at line 135 of file GenAodValidationTool.h.

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ GenAodValidationTool() [1/2]

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

Constructor with parameters:

Public methods:

Constructors

Definition at line 41 of file GenAodValidationTool.cxx.

43 :
44 TruthParticleValidationBaseTool( type, name, parent ),
45 m_outFile( nullptr )
46{
47 //
48 // Property declaration
49 //
50
51 declareProperty( "RefMcEvents",
52 m_refMcEventsName = "TruthEvent",
53 "StoreGate location of the reference McEventCollection" );
54
55 declareProperty( "CheckMcEvents",
56 m_checkMcEventsName = "GEN_AOD",
57 "Location of the 'to-be-validated' McEventCollection" );
58
59 declareProperty( "HardScatteringVtxOutputFile",
60 m_hardVtxOutFileName = "hepmc.hard.vtx.txt",
61 "Name of the output text file which will contain the "
62 "hard-scattering vertices" );
63
64 declareProperty( "RefHepMcWriterTool",
65 m_refMcEventWriter = HepMcTool_t( "HepMcWriterTool",
66 this ),
67 "Tool to write the reference HepMC::GenEvent into a dedicated file" );
68
69 declareProperty( "CheckHepMcWriterTool",
70 m_checkMcEventWriter = HepMcTool_t( "HepMcWriterTool",
71 this ),
72 "Tool to write the \"to-be-checked\" HepMC::GenEvent "
73 "into a dedicated file" );
74
75}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< IIOHepMcTool > HepMcTool_t
shorthand for lazy people (good coders are lazy people, aren't they ?)
StringProperty m_hardVtxOutFileName
Name of the output text file which will contain the hard-scattering vertices.
HepMcTool_t m_checkMcEventWriter
Tool to write the 'to-be-checked' HepMC::GenEvent into a dedicated file.
StringProperty m_checkMcEventsName
Location of the 'to-be-validated' McEventCollection.
std::ofstream * m_outFile
Pointer to the output text file containing hard-scattering vertices.
StringProperty m_refMcEventsName
Location of the reference McEventCollection.
HepMcTool_t m_refMcEventWriter
Tool to write the reference HepMC::GenEvent into a dedicated file.
TruthParticleValidationBaseTool()
Default constructor:

◆ ~GenAodValidationTool()

GenAodValidationTool::~GenAodValidationTool ( )
virtual

Destructor:

Destructor.

Definition at line 79 of file GenAodValidationTool.cxx.

80{
81 ATH_MSG_DEBUG("Calling destructor");
82
83 if ( m_outFile ) {
84 m_outFile->close();
85 delete m_outFile;
86 m_outFile = nullptr;
87 }
88
89}
#define ATH_MSG_DEBUG(x)

◆ GenAodValidationTool() [2/2]

GenAodValidationTool::GenAodValidationTool ( )
protected

Default constructor:

Member Function Documentation

◆ compareParts()

bool GenAodValidationTool::compareParts ( const HepMC::ConstGenParticlePtr & p1,
const HepMC::ConstGenParticlePtr & p2 ) const
protected

Check that 2 given particles are the same:

  • 4-mom
  • id
  • status
  • flow
  • polarization

Definition at line 307 of file GenAodValidationTool.cxx.

308{
309 if ( !p1 || !p2 ) {
310 ATH_MSG_ERROR("One of particles is a NULL pointer !!" << endmsg
311 << " p1: " << p1 << endmsg
312 << " p2: " << p2);
313 return false;
314 }
315
316 if ( HepMC::barcode(p1) != HepMC::barcode(p2) ) {
317 return false;
318 }
319
320 const HepMC::FourVector hlv1 = p1->momentum();
321 const int id1 = p1->pdg_id();
322 const int status1 = p1->status();
323 auto flow1 = HepMC::flow(p1);
324 auto pol1 = HepMC::polarization(p1);
325
326 const HepMC::FourVector hlv2 = p2->momentum();
327 const int id2 = p2->pdg_id();
328 const int status2 = p2->status();
329 auto flow2 = HepMC::flow(p2);
330 auto pol2 = HepMC::polarization(p2);
331
332 const bool isOK = ( hlv1 == hlv2 &&
333 id1 == id2 &&
334 status1 == status2 &&
335 flow1 == flow2 &&
336 pol1 == pol2 );
337
338
339 if ( !isOK ) {
341 ("=============================" << endmsg
342 << "\thlv: " << std::boolalpha << (hlv1 == hlv2 ) << endmsg
343 << "\tid: " << std::boolalpha << (id1 == id2 ) << endmsg
344 << "\tstatus: " << std::boolalpha << (status1 == status2) << endmsg
345 << "\tflow: " << std::boolalpha << (flow1 == flow2 ) << endmsg
346 << "\tpolar: " << std::boolalpha << (pol1 == pol2 ) << endmsg
347 << "=============================");
348 }
349
350 return isOK;
351}
#define endmsg
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
const std::string flow2
const std::string flow1
int barcode(const T *p)
Definition Barcode.h:15
HepMC3::FourVector FourVector
Polarization polarization(const T &a)
int flow(const HepMC3::GenParticlePtr &p, int i)
Definition Flow.h:13

◆ compareVtx()

bool GenAodValidationTool::compareVtx ( const HepMC::ConstGenVertexPtr & vtx1,
const HepMC::ConstGenVertexPtr & vtx2 ) const
protected

Check that 2 given vertices are the same:

  • check same number of branches
  • check same particles (4-mom + id + status)

Definition at line 269 of file GenAodValidationTool.cxx.

270{
271 if ( !vtx1 || !vtx2 ) {
272 ATH_MSG_ERROR("One of vertices is a NULL pointer !!" << endmsg
273 << " vtx1: " << vtx1 << endmsg
274 << " vtx2: " << vtx2);
275 return false;
276 }
277 auto inVtx1 = vtx1->particles_in();
278 auto inVtx2 = vtx2->particles_in();
279 if (inVtx1.size() != inVtx2.size()) {
280 ATH_MSG_ERROR("Not the same number of branches !!" << endmsg << " in: " << inVtx1.size() << "\t" << inVtx2.size());
281 return false;
282 }
283 std::sort(inVtx1.begin(), inVtx1.end(), [](auto& a, auto& b) -> bool{return a->momentum().pz() > b->momentum().pz(); });
284 std::sort(inVtx2.begin(), inVtx2.end(), [](auto& a, auto& b) -> bool{return a->momentum().pz() > b->momentum().pz(); });
285 for (size_t i=0; i<inVtx1.size(); ++i){
286 if ( compareParts( inVtx1.at(i), inVtx2.at(i) ) ) continue;
287 ATH_MSG_ERROR("In-going particles are NOT matching !!");
288 return false;
289 }
290 auto outVtx1 = vtx1->particles_out();
291 auto outVtx2 = vtx2->particles_out();
292 if (outVtx1.size() != outVtx2.size()) {
293 ATH_MSG_ERROR("Not the same number of branches !!" << endmsg << " out: " << outVtx1.size() << "\t" << outVtx2.size());
294 return false;
295 }
296 std::sort(outVtx1.begin(), outVtx1.end(), [](auto& a, auto& b) -> bool{return a->momentum().pz() > b->momentum().pz(); });
297 std::sort(outVtx2.begin(), outVtx2.end(), [](auto& a, auto& b) -> bool{return a->momentum().pz() > b->momentum().pz(); });
298 for (size_t i=0; i<outVtx1.size(); ++i){
299 if ( compareParts( outVtx1.at(i), outVtx2.at(i) ) ) continue;
300 ATH_MSG_ERROR("Out-going particles are NOT matchiutg !!");
301 return false;
302 }
303 return true;
304}
static Double_t a
bool compareParts(const HepMC::ConstGenParticlePtr &p1, const HepMC::ConstGenParticlePtr &p2) const
Check that 2 given particles are the same:
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode TruthParticleValidationBaseTool::execute ( )
virtualinherited

Implements ITruthParticleValidationTool.

Definition at line 78 of file TruthParticleValidationBaseTool.cxx.

79{
81 return executeTool();
82}
unsigned int m_nAnalysedEvents
Counter of analysed events.
virtual StatusCode executeTool()=0
Main method to perform the validation.

◆ executeTool() [1/3]

StatusCode GenAodValidationTool::executeTool ( )
protectedvirtual

Main method to perform the validation.

Just a wrapper around the more API-detailed method.

Implements TruthParticleValidationBaseTool.

Definition at line 132 of file GenAodValidationTool.cxx.

133{
134 // retrieve reference McEventCollection
135 const McEventCollection * refMcEvents = nullptr;
136 if ( evtStore()->retrieve( refMcEvents, m_refMcEventsName ).isFailure() ||
137 nullptr == refMcEvents ) {
138 ATH_MSG_ERROR("Could not retrieve reference McEventCollection at ["
139 << m_refMcEventsName << "] !!");
140 return StatusCode::FAILURE;
141 } else {
142 ATH_MSG_VERBOSE("Successfully retrieved reference McEventCollection at ["
143 << m_refMcEventsName << "]");
144
145 if ( !m_refMcEventWriter ||
146 m_refMcEventWriter->execute().isFailure() ) {
147 ATH_MSG_WARNING("Failed to write the reference GenEvent !!");
148 }
149 }
150
151 // retrieve checking McEventCollection
152 const McEventCollection * checkMcEvents = nullptr;
153 if ( evtStore()->retrieve(checkMcEvents, m_checkMcEventsName).isFailure() ||
154 nullptr == checkMcEvents ) {
155 ATH_MSG_ERROR("Could not retrieve 'to-be-validated' McEventCollection at ["
156 << m_checkMcEventsName << "] !!");
157 return StatusCode::FAILURE;
158 } else {
160 ("Successfully retrieved 'to-be-validated' McEventCollection at ["
161 << m_checkMcEventsName << "]");
162
163 if ( !m_checkMcEventWriter ||
164 m_checkMcEventWriter->execute().isFailure() ) {
165 ATH_MSG_WARNING("Failed to write the reference GenEvent !!");
166 }
167 }
168
169 return executeTool( refMcEvents, checkMcEvents );
170}
#define ATH_MSG_VERBOSE(x)
ServiceHandle< StoreGateSvc > & evtStore()
virtual StatusCode executeTool()
Main method to perform the validation.

◆ executeTool() [2/3]

StatusCode GenAodValidationTool::executeTool ( const HepMC::GenEvent * refMcEvents,
const HepMC::GenEvent * checkMcEvents )
protectedvirtual

Main method to perform the validation (directly onto the GenEvents):

  • check that each vertex is identical to the original one
  • check that missing particles are not there for a good reason

Definition at line 209 of file GenAodValidationTool.cxx.

211{
212 if ( nullptr == refMcEvts ) {
213 ATH_MSG_ERROR("NULL pointer to reference HepMC::GenEvent !!");
214 return StatusCode::FAILURE;
215 }
216
217 if ( nullptr == checkMcEvts ) {
218 ATH_MSG_ERROR("NULL pointer to the 'to-be-validated' HepMC::GenEvent !!");
219 return StatusCode::FAILURE;
220 }
221
222 const unsigned int evtNbr = refMcEvts->event_number();
223 (*m_outFile) << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
224 << std::endl
225 << "Event: " << evtNbr
226 << std::endl;
227
228 std::map<int,int> ref_bc_to_id;
229 const auto& refvertices = refMcEvts->vertices();
230 for ( const auto& vtx: refvertices) {
231 // AV: this algorthm is not very correct
232 int partonsin = 0;
233 int showerout = 0;
234 for (auto& p: vtx->particles_in()) if (MC::isQuark(p) || MC::isGluon(p)) partonsin++;
235 for (auto& p: vtx->particles_out()) if (p->pdg_id() == 91||p->pdg_id() == 92||p->pdg_id() == 94) showerout++;
236 if ( partonsin >= 2 && showerout == 0 ) {
237 ref_bc_to_id[HepMC::barcode(vtx)] = vtx->id();
238 }
239 }
240 std::map<int,int> che_bc_to_id;
241 const auto& chevertices = checkMcEvts->vertices();
242 for (const auto& checkVtx: chevertices) {
243 che_bc_to_id[HepMC::barcode(checkVtx)] = checkVtx->id();
244 }
245 std::set<int> allbarcodes;
246 for (const auto &[bc,id]: ref_bc_to_id) allbarcodes.insert(bc);
247 for (const auto &[bc,id]: che_bc_to_id) allbarcodes.insert(bc);
248 for (const auto &bc: allbarcodes){
249 auto ref_it = ref_bc_to_id.find(bc);
250 auto che_it = che_bc_to_id.find(bc);
251 if (ref_it == ref_bc_to_id.end()) {ATH_MSG_WARNING("In Event [" << evtNbr << "]: got null ref-vertex (barcode: " << bc << ")"); continue; }
252 if (che_it == che_bc_to_id.end()) {ATH_MSG_WARNING("Output GenEvent is missing the selected HardScattering Vtx !!"<< " (" << bc << ")"); continue; }
253 if (-ref_it->second > int(refvertices.size()) ) { continue; }
254 if (-che_it->second > int(chevertices.size()) ) { continue; }
255 const auto& refvtx = refvertices[-ref_it->second-1];
256 const auto& chevtx = chevertices[-che_it->second-1];
257 (*m_outFile) << refvtx << std::endl;
258 (*m_outFile) << chevtx << std::endl;
259 (*m_outFile) << "---------" << std::endl;
260 if ( !compareVtx( refvtx, chevtx ) ) {
261 ATH_MSG_WARNING("Selected HardScattering vertices are NOT the same !!"<< " at Event [" << evtNbr << "]"<< " refVtx = " << refvtx<<" chevtx = " << chevtx);
262 }
263 }
264 (*m_outFile) << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
265
266 return StatusCode::SUCCESS;
267}
bool compareVtx(const HepMC::ConstGenVertexPtr &vtx1, const HepMC::ConstGenVertexPtr &vtx2) const
Check that 2 given vertices are the same:
bool isQuark(const T &p)
PDG rule 2: Quarks and leptons are numbered consecutively starting from 1 and 11 respectively; to do ...
bool isGluon(const T &p)

◆ executeTool() [3/3]

StatusCode GenAodValidationTool::executeTool ( const McEventCollection * refMcEvents,
const McEventCollection * checkMcEvents )
protectedvirtual

Main method to perform the validation:

  • check that each vertex is identical to the original one
  • check that missing particles are not there for a good reason

Definition at line 173 of file GenAodValidationTool.cxx.

175{
176 if ( nullptr == refMcEvents ) {
177 ATH_MSG_ERROR("NULL pointer to reference McEventCollection !!");
178 return StatusCode::FAILURE;
179 }
180
181 if ( nullptr == checkMcEvents ) {
182 ATH_MSG_ERROR("NULL pointer to the 'to-be-validated' McEventCollection !!");
183 return StatusCode::FAILURE;
184 }
185
186 if ( refMcEvents->size() != checkMcEvents->size() ) {
187 ATH_MSG_ERROR("McEventCollections to be compared don't have the same size !"
188 << endmsg
189 << "Ref: " << refMcEvents->size() << endmsg
190 << "Current: " << checkMcEvents->size());
191 }
192
193 const unsigned int nMaxEvts = std::min( refMcEvents->size(),
194 checkMcEvents->size() );
195 for ( unsigned int iEvt = 0; iEvt != nMaxEvts; ++iEvt ) {
196
197 if ( executeTool( (*refMcEvents)[iEvt],
198 (*checkMcEvents)[iEvt] ).isFailure() ) {
199 ATH_MSG_WARNING("Could not VALIDATE this event ["
200 << (*refMcEvents)[iEvt]->event_number()
201 << "] !!");
202 }
203 }
204
205 return StatusCode::SUCCESS;
206}
size_type size() const noexcept
Returns the number of elements in the collection.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode TruthParticleValidationBaseTool::finalize ( )
virtualinherited

Implements ITruthParticleValidationTool.

Definition at line 64 of file TruthParticleValidationBaseTool.cxx.

65{
66 ATH_MSG_INFO("Finalizing " << name() << "...");
67 ATH_MSG_INFO("Analysed [" << m_nAnalysedEvents << "] events.");
68
69 // Give the concrete (derived) tool a chance to finalize itself
70 if ( finalizeTool().isFailure() ) {
71 ATH_MSG_ERROR("Could not finalize concrete tool !");
72 return StatusCode::FAILURE;
73 }
74
75 return StatusCode::SUCCESS;
76}
#define ATH_MSG_INFO(x)

◆ finalizeTool()

StatusCode GenAodValidationTool::finalizeTool ( )
protectedvirtual

Reimplemented from TruthParticleValidationBaseTool.

Definition at line 125 of file GenAodValidationTool.cxx.

126{
127 ATH_MSG_INFO("Finalizing " << name() << "...");
128
129 return StatusCode::SUCCESS;
130}

◆ initialize()

StatusCode TruthParticleValidationBaseTool::initialize ( )
virtualinherited

Athena Algorithm's Hooks.

Implements ITruthParticleValidationTool.

Definition at line 49 of file TruthParticleValidationBaseTool.cxx.

50{
51 ATH_MSG_INFO("Initializing " << name() << "...");
52
53 // Give the concrete (derived) tool a chance to initialize itself
54 if ( initializeTool().isFailure() ) {
55 ATH_MSG_ERROR("Could not initialize concrete tool !");
56 return StatusCode::FAILURE;
57 }
58
59 // initializing the event counter
61 return StatusCode::SUCCESS;
62}
virtual StatusCode initializeTool()
I/O operators.

◆ initializeTool()

StatusCode GenAodValidationTool::initializeTool ( )
protectedvirtual

Non-const methods:

Reimplemented from TruthParticleValidationBaseTool.

Definition at line 96 of file GenAodValidationTool.cxx.

97{
98 ATH_MSG_INFO("Initializing " << name() << "...");
99
100 if ( m_outFile ) {
101 delete m_outFile;
102 m_outFile = nullptr;
103 }
104 m_outFile = new std::ofstream( m_hardVtxOutFileName.value().c_str(),
105 std::ios::trunc );
106 if ( !m_outFile || !m_outFile->is_open() || m_outFile->bad() ) {
107 ATH_MSG_ERROR("Could not open output Hard-Scattering vertices file at : "
108 << m_hardVtxOutFileName.value());
109 if ( m_outFile ) {
110 delete m_outFile;
111 m_outFile = nullptr;
112 }
113 return StatusCode::FAILURE;
114 }
115
116 // retrieve and configure HepMC writer tools
117 if ( setupHepMcWriterTools().isFailure() ) {
118 ATH_MSG_ERROR("Could not configure the HepMC::GenEvent writer tools !!");
119 return StatusCode::FAILURE;
120 }
121
122 return StatusCode::SUCCESS;
123}
StatusCode setupHepMcWriterTools()
Request pointers to the HepMcWriterTools to be able to write out HepMC::GenEvent for further comparis...

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & ITruthParticleValidationTool::interfaceID ( )
inlinestaticinherited

Inline methods:

Definition at line 65 of file ITruthParticleValidationTool.h.

66{
68}
static const InterfaceID IID_ITruthParticleValidationTool("ITruthParticleValidationTool", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setupHepMcWriterTools()

StatusCode GenAodValidationTool::setupHepMcWriterTools ( )
protected

Request pointers to the HepMcWriterTools to be able to write out HepMC::GenEvent for further comparison (off-framework).

Definition at line 353 of file GenAodValidationTool.cxx.

354{
355 ATH_CHECK( m_refMcEventWriter.retrieve() );
356 ATH_CHECK( m_checkMcEventWriter.retrieve() );
357
358 // now we configure the tools
359 SmartIF<IProperty> prop{m_refMcEventWriter.get()};
360 ATH_CHECK( prop.isValid() );
361 ATH_CHECK( prop->setProperty("McEvents", m_refMcEventsName.value()) );
362
364 ATH_CHECK( prop.isValid() );
365 ATH_CHECK( prop->setProperty("McEvents", m_checkMcEventsName.value()) );
366
367 return StatusCode::SUCCESS;
368}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_checkMcEventsName

StringProperty GenAodValidationTool::m_checkMcEventsName
protected

Location of the 'to-be-validated' McEventCollection.

Definition at line 122 of file GenAodValidationTool.h.

◆ m_checkMcEventWriter

HepMcTool_t GenAodValidationTool::m_checkMcEventWriter
protected

Tool to write the 'to-be-checked' HepMC::GenEvent into a dedicated file.

Definition at line 143 of file GenAodValidationTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_hardVtxOutFileName

StringProperty GenAodValidationTool::m_hardVtxOutFileName
protected

Name of the output text file which will contain the hard-scattering vertices.

Default = "hepmc.hard.vtx.txt"

Definition at line 127 of file GenAodValidationTool.h.

◆ m_nAnalysedEvents

unsigned int TruthParticleValidationBaseTool::m_nAnalysedEvents
protectedinherited

Counter of analysed events.

Definition at line 75 of file TruthParticleValidationBaseTool.h.

◆ m_outFile

std::ofstream* GenAodValidationTool::m_outFile
protected

Pointer to the output text file containing hard-scattering vertices.

Definition at line 131 of file GenAodValidationTool.h.

◆ m_refMcEventsName

StringProperty GenAodValidationTool::m_refMcEventsName
protected

Location of the reference McEventCollection.

Definition at line 118 of file GenAodValidationTool.h.

◆ m_refMcEventWriter

HepMcTool_t GenAodValidationTool::m_refMcEventWriter
protected

Tool to write the reference HepMC::GenEvent into a dedicated file.

Definition at line 139 of file GenAodValidationTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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