ATLAS Offline Software
HiggsTruthCategoryTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // TruthRivetTools includes
7 
8 #include <mutex>
9 
11 : asg::AsgTool( name ),
12  m_higgsTemplateCrossSections( nullptr )
13 {
14  // cannot be set to true until the issue with the beam protons in the truth event record is fixed..
15  // see JIRA ticket: https://its.cern.ch/jira/browse/ATLASRECTS-3072?filter=-2
16  m_outHistos = false;
17 }
18 
19 
21  ATH_MSG_INFO ("Initializing " << name() << "...");
22  // Rivet analysis :: Higgs truth event classifier class
24  // create an instance of the Rivet analysis handler
25  m_rivetAnaHandler = std::make_unique<Rivet::AnalysisHandler>();
26  // Add the Higgs truth classifier class to the handler
28  return StatusCode::SUCCESS;
29 }
30 
32  ATH_MSG_INFO (" ====================================================== ");
33  ATH_MSG_INFO (" ---- Finalizing" << name() << "...");
34  ATH_MSG_INFO (" ====================================================== ");
35  if ( !m_outHistos ){
36  //this seems to thrown an exception
37  //higgsTemplateCrossSections->printClassificationSummary( );
38  }
39  else{
40  // TODO:: update the tool properly deal with output files/paths
41  m_rivetAnaHandler->finalize();
42  m_rivetAnaHandler->writeData("HiggsTruthCategoryTool.yoda");
43  }
44  ATH_MSG_INFO (" ====================================================== ");
45  return StatusCode::SUCCESS;
46 }
47 
48 HTXS::HiggsClassification* HiggsTruthCategoryTool :: getHiggsTruthCategoryObject (const HepMC::GenEvent& HepMCEvent, const HTXS::HiggsProdMode prodMode) const {
49  if ( !m_isInitialized.test_and_set() ) {
50  [&]() {
52  m_rivetAnaHandler->init(HepMCEvent);
53  }();
54  }
55  // fill histos if flag is specified
56  // if ( m_outHistos ) rivetAnaHandler->analyze(HepMCEvent);
57 
58  // get the category output object containing the template cross section category,
59  // and Higgs, V-boson, jets 4-vectors
60  const Rivet::HiggsClassification htxs_cat_rivet = m_higgsTemplateCrossSections->classifyEvent(const_cast<HepMC::GenEvent&>(HepMCEvent),prodMode);
61  return HTXS::Rivet2Root(htxs_cat_rivet);
62 }
HiggsTruthCategoryTool::m_higgsTemplateCrossSections
Rivet::HiggsTemplateCrossSections * m_higgsTemplateCrossSections
Definition: HiggsTruthCategoryTool.h:51
HiggsTruthCategoryTool::m_outHistos
bool m_outHistos
Definition: HiggsTruthCategoryTool.h:57
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Rivet::HiggsTemplateCrossSections
Rivet routine for classifying MC events according to the Higgs template cross section categories.
Definition: HiggsTemplateCrossSections.h:33
asg
Definition: DataHandleTestTool.h:28
Rivet::HiggsTemplateCrossSections::classifyEvent
HiggsClassification classifyEvent(const Event &event, const HTXS::HiggsProdMode prodMode) const
Main classificaion method.
Definition: HiggsTemplateCrossSections.h:126
HiggsTruthCategoryTool.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HiggsTruthCategoryTool::HiggsTruthCategoryTool
HiggsTruthCategoryTool(const std::string &name)
Definition: HiggsTruthCategoryTool.cxx:10
HiggsTruthCategoryTool::m_rivetAnaHandler
std::unique_ptr< Rivet::AnalysisHandler > m_rivetAnaHandler
Definition: HiggsTruthCategoryTool.h:50
HTXS::HiggsProdMode
HiggsProdMode
Higgs production modes, corresponding to input sample.
Definition: HiggsTemplateCrossSectionsDefs.h:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
HiggsTruthCategoryTool::getHiggsTruthCategoryObject
HTXS::HiggsClassification * getHiggsTruthCategoryObject(const HepMC::GenEvent &HepMCEvent, const HTXS::HiggsProdMode prodMode) const override
Definition: HiggsTruthCategoryTool.cxx:48
HiggsTruthCategoryTool::finalize
StatusCode finalize() override
Definition: HiggsTruthCategoryTool.cxx:31
Rivet::HiggsTemplateCrossSections::setHiggsProdMode
void setHiggsProdMode(HTXS::HiggsProdMode prodMode)
Sets the Higgs production mode.
Definition: HiggsTemplateCrossSections.h:626
HiggsTruthCategoryTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: HiggsTruthCategoryTool.cxx:20