|
ATLAS Offline Software
|
#include <GenAodValidationTool.h>
|
| GenAodValidationTool (const std::string &type, const std::string &name, const IInterface *parent) |
| Constructor with parameters: More...
|
|
virtual | ~GenAodValidationTool () |
| Destructor: More...
|
|
StatusCode | initialize () |
| Athena Algorithm's Hooks. More...
|
|
StatusCode | execute () |
|
StatusCode | finalize () |
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysInitialize () override |
| Perform system initialization for an algorithm. More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
Definition at line 31 of file GenAodValidationTool.h.
◆ HepMcTool_t
shorthand for lazy people (good coders are lazy people, aren't they ?)
Definition at line 135 of file GenAodValidationTool.h.
◆ StoreGateSvc_t
◆ 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.
53 "StoreGate location of the reference McEventCollection" );
57 "Location of the 'to-be-validated' McEventCollection" );
61 "Name of the output text file which will contain the "
62 "hard-scattering vertices" );
67 "Tool to write the reference HepMC::GenEvent into a dedicated file" );
72 "Tool to write the \"to-be-checked\" HepMC::GenEvent "
73 "into a dedicated file" );
◆ ~GenAodValidationTool()
GenAodValidationTool::~GenAodValidationTool |
( |
| ) |
|
|
virtual |
◆ GenAodValidationTool() [2/2]
GenAodValidationTool::GenAodValidationTool |
( |
| ) |
|
|
protected |
◆ compareParts()
Check that 2 given particles are the same:
- 4-mom
- id
- status
- flow
- polarization
Definition at line 406 of file GenAodValidationTool.cxx.
419 const HepMC::FourVector hlv1 =
p1->momentum();
420 const int id1 =
p1->pdg_id();
421 const int status1 =
p1->status();
425 const HepMC::FourVector hlv2 =
p2->momentum();
426 const int id2 =
p2->pdg_id();
427 const int status2 =
p2->status();
431 const bool isOK = ( hlv1 == hlv2 &&
433 status1 == status2 &&
440 (
"=============================" <<
endmsg
441 <<
"\thlv: " << std::boolalpha << (hlv1 == hlv2 ) <<
endmsg
442 <<
"\tid: " << std::boolalpha << (id1 ==
id2 ) <<
endmsg
443 <<
"\tstatus: " << std::boolalpha << (status1 == status2) <<
endmsg
444 <<
"\tflow: " << std::boolalpha << (flow1 == flow2 ) <<
endmsg
445 <<
"\tpolar: " << std::boolalpha << (pol1 == pol2 ) <<
endmsg
446 <<
"=============================");
◆ compareVtx()
Check that 2 given vertices are the same:
- check same number of branches
- check same particles (4-mom + id + status)
Definition at line 310 of file GenAodValidationTool.cxx.
312 if ( !vtx1 || !vtx2 ) {
314 <<
" vtx1: " << vtx1 <<
endmsg
315 <<
" vtx2: " << vtx2);
320 auto inVtx1 = vtx1->particles_in();
321 auto inVtx2 = vtx2->particles_in();
322 if (inVtx1.size() != inVtx2.size()) {
323 ATH_MSG_ERROR(
"Not the same number of branches !!" <<
endmsg <<
" in: " << inVtx1.size() <<
"\t" << inVtx2.size());
326 std::sort(inVtx1.begin(), inVtx1.end(), [](
auto&
a,
auto&
b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
327 std::sort(inVtx2.begin(), inVtx2.end(), [](
auto&
a,
auto&
b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
328 for (
size_t i=0;
i<inVtx1.size(); ++
i){
333 auto outVtx1 = vtx1->particles_out();
334 auto outVtx2 = vtx2->particles_out();
335 if (outVtx1.size() != outVtx2.size()) {
336 ATH_MSG_ERROR(
"Not the same number of branches !!" <<
endmsg <<
" out: " << outVtx1.size() <<
"\t" << outVtx2.size());
339 std::sort(outVtx1.begin(), outVtx1.end(), [](
auto&
a,
auto&
b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
340 std::sort(outVtx2.begin(), outVtx2.end(), [](
auto&
a,
auto&
b) ->
bool{return a->momentum().pz() > b->momentum().pz(); });
341 for (
size_t i=0;
i<outVtx1.size(); ++
i){
347 const int inVtx1 = vtx1->particles_in_size();
348 const int inVtx2 = vtx2->particles_in_size();
350 const int outVtx1 = vtx1->particles_out_size();
351 const int outVtx2 = vtx2->particles_out_size();
353 if ( inVtx1 != inVtx2 || outVtx1 != outVtx2 ) {
355 <<
" in: " << inVtx1 <<
"\t" << inVtx2 <<
endmsg
356 <<
" out: " << outVtx1 <<
"\t" << outVtx2);
360 for ( HepMC::GenVertex::particles_in_const_iterator inPart1 = vtx1->particles_in_const_begin();
361 inPart1 != vtx1->particles_in_const_end();
363 bool inParticleOK =
false;
364 for ( HepMC::GenVertex::particles_in_const_iterator inPart2 = vtx2->particles_in_const_begin();
365 inPart2 != vtx2->particles_in_const_end();
373 if ( !inParticleOK ) {
381 for ( HepMC::GenVertex::particles_out_const_iterator outPart1 = vtx1->particles_out_const_begin();
382 outPart1 != vtx1->particles_out_const_end();
384 bool outParticleOK =
false;
385 for ( HepMC::GenVertex::particles_out_const_iterator outPart2 = vtx2->particles_out_const_begin();
386 outPart2 != vtx2->particles_out_const_end();
389 outParticleOK =
true;
394 if ( !outParticleOK ) {
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
253 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
229 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
338 return PBASE::declareProperty(
name, property,
doc);
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute()
StatusCode TruthParticleValidationBaseTool::execute |
( |
| ) |
|
|
virtualinherited |
◆ 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.
137 nullptr == refMcEvents ) {
138 ATH_MSG_ERROR(
"Could not retrieve reference McEventCollection at ["
140 return StatusCode::FAILURE;
142 ATH_MSG_VERBOSE(
"Successfully retrieved reference McEventCollection at ["
154 nullptr == checkMcEvents ) {
155 ATH_MSG_ERROR(
"Could not retrieve 'to-be-validated' McEventCollection at ["
157 return StatusCode::FAILURE;
160 (
"Successfully retrieved 'to-be-validated' McEventCollection at ["
◆ 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.
212 if (
nullptr == refMcEvts ) {
213 ATH_MSG_ERROR(
"NULL pointer to reference HepMC::GenEvent !!");
214 return StatusCode::FAILURE;
217 if (
nullptr == checkMcEvts ) {
218 ATH_MSG_ERROR(
"NULL pointer to the 'to-be-validated' HepMC::GenEvent !!");
219 return StatusCode::FAILURE;
222 const unsigned int evtNbr = refMcEvts->event_number();
223 (*m_outFile) <<
">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
225 <<
"Event: " << evtNbr
229 std::map<int,int> ref_bc_to_id;
230 const auto& refvertices = refMcEvts->vertices();
231 for (
const auto& vtx: refvertices) {
236 for (
auto&
p: vtx->particles_out())
if (
p->pdg_id() == 91||
p->pdg_id() == 92||
p->pdg_id() == 94) showerout++;
237 if ( partonsin >= 2 && showerout == 0 ) {
241 std::map<int,int> che_bc_to_id;
242 const auto& chevertices = checkMcEvts->vertices();
243 for (
const auto& checkVtx: chevertices) {
246 std::set<int> allbarcodes;
247 for (
const auto &[bc,
id]: ref_bc_to_id) allbarcodes.insert(bc);
248 for (
const auto &[bc,
id]: che_bc_to_id) allbarcodes.insert(bc);
249 for (
const auto &bc: allbarcodes){
250 auto ref_it = ref_bc_to_id.find(bc);
251 auto che_it = che_bc_to_id.find(bc);
252 if (ref_it == ref_bc_to_id.end()) {
ATH_MSG_WARNING(
"In Event [" << evtNbr <<
"]: got null ref-vertex (barcode: " << bc <<
")");
continue; }
253 if (che_it == che_bc_to_id.end()) {
ATH_MSG_WARNING(
"Output GenEvent is missing the selected HardScattering Vtx !!"<<
" (" << bc <<
")");
continue; }
254 if (-ref_it->second >
int(refvertices.size()) ) {
continue; }
255 if (-che_it->second >
int(chevertices.size()) ) {
continue; }
256 const auto& refvtx = refvertices[-ref_it->second-1];
257 const auto& chevtx = chevertices[-che_it->second-1];
258 (*m_outFile) << refvtx << std::endl;
259 (*m_outFile) << chevtx << std::endl;
260 (*m_outFile) <<
"---------" << std::endl;
262 ATH_MSG_WARNING(
"Selected HardScattering vertices are NOT the same !!"<<
" at Event [" << evtNbr <<
"]"<<
" refVtx = " << refvtx<<
" chevtx = " << chevtx);
265 (*m_outFile) <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
267 std::set<int> ref_bc;
268 for (
auto vtxIt = refMcEvts->vertices_begin(); vtxIt != refMcEvts->vertices_end(); ++vtxIt ) {
275 for (
auto p = vtx->particles_in_const_begin();
p!=vtx->particles_in_const_end();++
p )
if (
MC::isQuark(*
p) ||
MC::isGluon(*
p)) partonsin++;
277 for (
auto&
p : *vtx)
if (
p->pdg_id() == 91||
p->pdg_id() == 92||
p->pdg_id() == 94) showerout++;
278 if ( partonsin >= 2 && showerout == 0 ) {
279 ref_bc.insert(vtx->barcode());
282 std::set<int> che_bc;
283 for (
auto vtxIt = checkMcEvts->vertices_begin(); vtxIt != checkMcEvts->vertices_end(); ++vtxIt ) {
285 che_bc.insert(vtx->barcode());
287 std::set<int> allbarcodes;
288 for (
const auto &bc: ref_bc) allbarcodes.insert(bc);
289 for (
const auto &bc: che_bc) allbarcodes.insert(bc);
290 for (
const auto &bc: allbarcodes){
291 auto ref_it = ref_bc.find(bc);
292 auto che_it = che_bc.find(bc);
293 if (ref_it == ref_bc.end()) {
ATH_MSG_WARNING(
"In Event [" << evtNbr <<
"]: got null ref-vertex (barcode: " << bc <<
")");
continue; }
294 if (che_it == che_bc.end()) {
ATH_MSG_WARNING(
"Output GenEvent is missing the selected HardScattering Vtx !!"<<
" (" << bc <<
")");
continue; }
295 const auto refvtx = refMcEvts->barcode_to_vertex(bc);
296 const auto chevtx = checkMcEvts->barcode_to_vertex(bc);
297 (*m_outFile) << refvtx << std::endl;
298 (*m_outFile) << chevtx << std::endl;
299 (*m_outFile) <<
"---------" << std::endl;
301 ATH_MSG_WARNING(
"Selected HardScattering vertices are NOT the same !!"<<
" at Event [" << evtNbr <<
"]"<<
" refVtx = " << refvtx<<
" chevtx = " << chevtx);
304 (*m_outFile) <<
"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
307 return StatusCode::SUCCESS;
◆ executeTool() [3/3]
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.
176 if (
nullptr == refMcEvents ) {
177 ATH_MSG_ERROR(
"NULL pointer to reference McEventCollection !!");
178 return StatusCode::FAILURE;
181 if (
nullptr == checkMcEvents ) {
182 ATH_MSG_ERROR(
"NULL pointer to the 'to-be-validated' McEventCollection !!");
183 return StatusCode::FAILURE;
186 if ( refMcEvents->
size() != checkMcEvents->
size() ) {
187 ATH_MSG_ERROR(
"McEventCollections to be compared don't have the same size !"
190 <<
"Current: " << checkMcEvents->
size());
193 const unsigned int nMaxEvts =
std::min( refMcEvents->
size(),
194 checkMcEvents->
size() );
195 for (
unsigned int iEvt = 0; iEvt != nMaxEvts; ++iEvt ) {
198 (*checkMcEvents)[iEvt] ).isFailure() ) {
200 << (*refMcEvents)[iEvt]->event_number()
205 return StatusCode::SUCCESS;
◆ extraDeps_update_handler()
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 |
◆ finalizeTool()
StatusCode GenAodValidationTool::finalizeTool |
( |
| ) |
|
|
protectedvirtual |
◆ initialize()
StatusCode TruthParticleValidationBaseTool::initialize |
( |
| ) |
|
|
virtualinherited |
◆ initializeTool()
StatusCode GenAodValidationTool::initializeTool |
( |
| ) |
|
|
protectedvirtual |
◆ inputHandles()
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 |
◆ msg() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ outputHandles()
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()
◆ renounceArray()
◆ 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 452 of file GenAodValidationTool.cxx.
458 return StatusCode::FAILURE;
465 return StatusCode::FAILURE;
474 return StatusCode::FAILURE;
482 return StatusCode::FAILURE;
485 return StatusCode::SUCCESS;
◆ sysInitialize()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ m_checkMcEventsName
StringProperty GenAodValidationTool::m_checkMcEventsName |
|
protected |
◆ m_checkMcEventWriter
◆ m_detStore
◆ m_evtStore
◆ 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 |
◆ m_outFile
std::ofstream* GenAodValidationTool::m_outFile |
|
protected |
◆ m_refMcEventsName
StringProperty GenAodValidationTool::m_refMcEventsName |
|
protected |
◆ m_refMcEventWriter
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
Polarization polarization(const T &a)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
TruthParticleValidationBaseTool()
Default constructor:
virtual StatusCode finalizeTool()
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
#define ATH_MSG_VERBOSE(x)
virtual void setOwner(IDataHandleHolder *o)=0
bool isQuark(const T &p)
PDG rule 2: Quarks and leptons are numbered consecutively starting from 1 and 11 respectively; to dot...
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode executeTool()=0
Main method to perform the validation.
int flow(const T &a, int i)
virtual StatusCode initializeTool()
I/O operators.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
#define ATH_MSG_WARNING(x)
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
unsigned int m_nAnalysedEvents
Counter of analysed events.
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>