Skip to content
Snippets Groups Projects
Commit c885bd18 authored by Graeme Stewart's avatar Graeme Stewart
Browse files

Tagging Rivet_i-02-04-01 (Rivet_i-02-04-01)

	* Fix CMakeLists.txt for missing GSL dependency
	* https://gitlab.cern.ch/atlas/aogt6/commit/49c5bee8464d75cd74eddaf5149a1a5645902706
        * Tagging as Rivet_i-02-04-01

2015-10-26  Andy Buckley  <andy.buckley@cern.ch>

	* Tagging: Rivet_i-02-04-00

	* Add conversion-to-ROOT for Histo2D types (only guaranteed for Rivet >= 2.4 and corresponding YODA)

2015-07-29  James Monk  <jmonk@cern.ch>

	* Add WeightName property so that weight can be selected in the case of multiple input weights

	* Always make a copy of the input GenEvent
parent 5cad50a1
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ find_package( HepMC ) ...@@ -21,6 +21,7 @@ find_package( HepMC )
find_package( ROOT COMPONENTS Matrix Core Tree MathCore Hist RIO pthread ) find_package( ROOT COMPONENTS Matrix Core Tree MathCore Hist RIO pthread )
find_package( Rivet ) find_package( Rivet )
find_package( YODA ) find_package( YODA )
find_package( GSL )
# Remove the --as-needed linker flags: # Remove the --as-needed linker flags:
atlas_disable_as_needed() atlas_disable_as_needed()
...@@ -30,12 +31,12 @@ atlas_add_library( Rivet_iLib ...@@ -30,12 +31,12 @@ atlas_add_library( Rivet_iLib
src/*.cxx src/*.cxx
PUBLIC_HEADERS Rivet_i PUBLIC_HEADERS Rivet_i
INCLUDE_DIRS ${RIVET_INCLUDE_DIRS} INCLUDE_DIRS ${RIVET_INCLUDE_DIRS}
PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${YODA_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${YODA_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS} ${GSL_INCLUDE_DIRS}
LINK_LIBRARIES ${RIVET_LIBRARIES} AthenaBaseComps GaudiKernel LINK_LIBRARIES ${RIVET_LIBRARIES} AthenaBaseComps GaudiKernel
PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} ${HEPMC_LIBRARIES} ${YODA_LIBRARIES} ${FASTJET_LIBRARIES} AthenaKernel GeneratorObjects PathResolver ) PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${GSL_LIBRARIES} ${ROOT_LIBRARIES} ${HEPMC_LIBRARIES} ${YODA_LIBRARIES} ${FASTJET_LIBRARIES} AthenaKernel GeneratorObjects PathResolver )
atlas_add_component( Rivet_i atlas_add_component( Rivet_i
src/components/*.cxx src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${YODA_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS} ${RIVET_INCLUDE_DIRS} INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${YODA_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS} ${RIVET_INCLUDE_DIRS} ${GSL_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} ${HEPMC_LIBRARIES} ${YODA_LIBRARIES} ${FASTJET_LIBRARIES} ${RIVET_LIBRARIES} AthenaBaseComps GaudiKernel AthenaKernel GeneratorObjects PathResolver Rivet_iLib ) LINK_LIBRARIES ${Boost_LIBRARIES} ${GSL_LIBRARIES} ${ROOT_LIBRARIES} ${HEPMC_LIBRARIES} ${YODA_LIBRARIES} ${FASTJET_LIBRARIES} ${RIVET_LIBRARIES} AthenaBaseComps GaudiKernel AthenaKernel GeneratorObjects PathResolver Rivet_iLib )
...@@ -105,6 +105,9 @@ private: ...@@ -105,6 +105,9 @@ private:
/// The cross section for this run of events, set from the job properties. /// The cross section for this run of events, set from the job properties.
double m_crossSection; double m_crossSection;
/// The name of the weight to use in case the input HepMC contains multiple weights
std::string m_weightName;
/// Flag to determine whether Rivet init has already happened (in execute()) /// Flag to determine whether Rivet init has already happened (in execute())
bool m_init; bool m_init;
......
...@@ -33,3 +33,4 @@ end_private ...@@ -33,3 +33,4 @@ end_private
## Athena stuff ## Athena stuff
apply_pattern named_dual_use_library library="Rivet_i" files="*.cxx" apply_pattern named_dual_use_library library="Rivet_i" files="*.cxx"
apply_pattern declare_joboptions files="*.py" apply_pattern declare_joboptions files="*.py"
...@@ -48,6 +48,7 @@ Rivet_i::Rivet_i(const std::string& name, ISvcLocator* pSvcLocator) : ...@@ -48,6 +48,7 @@ Rivet_i::Rivet_i(const std::string& name, ISvcLocator* pSvcLocator) :
declareProperty("McEventKey", m_genEventKey="GEN_EVENT"); declareProperty("McEventKey", m_genEventKey="GEN_EVENT");
declareProperty("Analyses", m_analysisNames); declareProperty("Analyses", m_analysisNames);
declareProperty("CrossSection", m_crossSection=-1.0); declareProperty("CrossSection", m_crossSection=-1.0);
declareProperty("WeightName", m_weightName="");
declareProperty("Stream", m_stream="/Rivet"); declareProperty("Stream", m_stream="/Rivet");
declareProperty("RunName", m_runname=""); declareProperty("RunName", m_runname="");
declareProperty("HistoFile", m_file="Rivet.yoda"); declareProperty("HistoFile", m_file="Rivet.yoda");
...@@ -187,6 +188,11 @@ StatusCode Rivet_i::execute() { ...@@ -187,6 +188,11 @@ StatusCode Rivet_i::execute() {
// ATH_MSG_ALWAYS("CHK1 BEAM ENERGY = " << checkedEvent->beam_particles().first->momentum().e()); // ATH_MSG_ALWAYS("CHK1 BEAM ENERGY = " << checkedEvent->beam_particles().first->momentum().e());
// ATH_MSG_ALWAYS("CHK1 UNITS == MEV = " << std::boolalpha << (checkedEvent->momentum_unit() == HepMC::Units::MEV)); // ATH_MSG_ALWAYS("CHK1 UNITS == MEV = " << std::boolalpha << (checkedEvent->momentum_unit() == HepMC::Units::MEV));
if(!checkedEvent) {
ATH_MSG_ERROR("Check on HepMC event failed!");
return StatusCode::FAILURE;
}
// Initialize Rivet (on the first event only) // Initialize Rivet (on the first event only)
if (!m_init) { if (!m_init) {
m_analysisHandler->init(*checkedEvent); m_analysisHandler->init(*checkedEvent);
...@@ -196,8 +202,7 @@ StatusCode Rivet_i::execute() { ...@@ -196,8 +202,7 @@ StatusCode Rivet_i::execute() {
// Analyse the event // Analyse the event
m_analysisHandler->analyze(*checkedEvent); m_analysisHandler->analyze(*checkedEvent);
// Delete the modified event copy delete checkedEvent;
if (checkedEvent != event) delete checkedEvent;
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -220,18 +225,35 @@ StatusCode Rivet_i::finalize() { ...@@ -220,18 +225,35 @@ StatusCode Rivet_i::finalize() {
const string basename = ao->path().substr(ao->path().rfind("/")+1); // There should always be >= 1 slash const string basename = ao->path().substr(ao->path().rfind("/")+1); // There should always be >= 1 slash
// Convert YODA histos to heap-allocated ROOT objects and register // Convert YODA histos to heap-allocated ROOT objects and register
/// @todo Counter
if (ao->type() == "Histo1D") { if (ao->type() == "Histo1D") {
TH1* h = (TH1*) YODA::toTH1D(*boost::dynamic_pointer_cast<YODA::Histo1D>(ao)).Clone(basename.c_str()); TH1* h = (TH1*) YODA::toTH1D(*boost::dynamic_pointer_cast<YODA::Histo1D>(ao)).Clone(basename.c_str());
CHECK(m_histSvc->regHist(m_stream + path, h)); CHECK(m_histSvc->regHist(m_stream + path, h));
ATH_MSG_INFO("TH1D " + path + " created from YODA::Histo1D"); ATH_MSG_INFO("TH1D " + path + " created from YODA::Histo1D");
} else if (ao->type() == "Histo2D") {
TH2* h = (TH2*) YODA::toTH2D(*boost::dynamic_pointer_cast<YODA::Histo2D>(ao)).Clone(basename.c_str());
CHECK(m_histSvc->regHist(m_stream + path, h));
ATH_MSG_INFO("TH2 " + path + " created from YODA::Histo2D");
// } else if (ao->type() == "Profile2D") {
// TProfile2D* h = (TProfile2D*) YODA::toTProfile2D(*boost::dynamic_pointer_cast<YODA::Profile2D>(ao)).Clone(basename.c_str());
// CHECK(m_histSvc->regHist(m_stream + path, h));
// ATH_MSG_INFO("TProfile2D " + path + " created from YODA::Profile2D");
} else if (ao->type() == "Profile1D") { } else if (ao->type() == "Profile1D") {
TH1* h = (TH1*) YODA::toTProfile(*boost::dynamic_pointer_cast<YODA::Profile1D>(ao)).Clone(basename.c_str()); TH1* h = (TH1*) YODA::toTProfile(*boost::dynamic_pointer_cast<YODA::Profile1D>(ao)).Clone(basename.c_str());
CHECK(m_histSvc->regHist(m_stream + path, h)); CHECK(m_histSvc->regHist(m_stream + path, h));
ATH_MSG_INFO("TProfile " + path + " created from YODA::Profile1D"); ATH_MSG_INFO("TProfile " + path + " created from YODA::Profile1D");
// } else if (ao->type() == "Scatter1D") {
// TGraph* g = (TGraph*) YODA::toTGraph(*boost::dynamic_pointer_cast<YODA::Scatter1D>(ao)).Clone(basename.c_str());
// CHECK(m_histSvc->regGraph(m_stream + path, g));
// ATH_MSG_INFO("TGraph " + path + " created from YODA::Scatter2D");
} else if (ao->type() == "Scatter2D") { } else if (ao->type() == "Scatter2D") {
TGraph* g = (TGraph*) YODA::toTGraph(*boost::dynamic_pointer_cast<YODA::Scatter2D>(ao)).Clone(basename.c_str()); TGraph* g = (TGraph*) YODA::toTGraph(*boost::dynamic_pointer_cast<YODA::Scatter2D>(ao)).Clone(basename.c_str());
CHECK(m_histSvc->regGraph(m_stream + path, g)); CHECK(m_histSvc->regGraph(m_stream + path, g));
ATH_MSG_INFO("TGraph " + path + " created from YODA::Scatter2D"); ATH_MSG_INFO("TGraph " + path + " created from YODA::Scatter2D");
// } else if (ao->type() == "Scatter3D") {
// TGraph* g = (TGraph*) YODA::toTGraph(*boost::dynamic_pointer_cast<YODA::Scatter3D>(ao)).Clone(basename.c_str());
// CHECK(m_histSvc->regGraph(m_stream + path, g));
// ATH_MSG_INFO("TGraph " + path + " created from YODA::Scatter2D");
} else { } else {
ATH_MSG_WARNING("Couldn't convert YODA histo " + path + " to ROOT: unsupported data type " + ao->type()); ATH_MSG_WARNING("Couldn't convert YODA histo " + path + " to ROOT: unsupported data type " + ao->type());
} }
...@@ -255,6 +277,20 @@ bool cmpGenParticleByEDesc(const HepMC::GenParticle* a, const HepMC::GenParticle ...@@ -255,6 +277,20 @@ bool cmpGenParticleByEDesc(const HepMC::GenParticle* a, const HepMC::GenParticle
const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
std::vector<HepMC::GenParticle*> beams; std::vector<HepMC::GenParticle*> beams;
HepMC::GenEvent* modEvent = new HepMC::GenEvent(*event);
if(m_weightName != ""){
if(event->weights().has_key(m_weightName)){
double weight = event->weights()[m_weightName];
modEvent->weights().clear();
modEvent->weights()[m_weightName] = weight;
}else{
ATH_MSG_ERROR("Weight named " + m_weightName + " could not be found in the HepMC event!");
delete modEvent;
return (HepMC::GenEvent*)0;
}
}
if (!event->valid_beam_particles()) { if (!event->valid_beam_particles()) {
for (HepMC::GenEvent::particle_const_iterator p = event->particles_begin(); p != event->particles_end(); ++p) { for (HepMC::GenEvent::particle_const_iterator p = event->particles_begin(); p != event->particles_end(); ++p) {
if (!(*p)->production_vertex() && (*p)->pdg_id() != 0) { if (!(*p)->production_vertex() && (*p)->pdg_id() != 0) {
...@@ -283,9 +319,8 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { ...@@ -283,9 +319,8 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
#endif #endif
if (scalefactor == 1.0 && event->valid_beam_particles()) { if (scalefactor == 1.0 && event->valid_beam_particles()) {
return event; return modEvent;
} else { } else {
HepMC::GenEvent* modEvent = new HepMC::GenEvent(*event);
if (scalefactor != 1.0) { if (scalefactor != 1.0) {
// ATH_MSG_ALWAYS("RESCALING * " << scalefactor); // ATH_MSG_ALWAYS("RESCALING * " << scalefactor);
for (HepMC::GenEvent::particle_iterator p = modEvent->particles_begin(); p != modEvent->particles_end(); ++p) { for (HepMC::GenEvent::particle_iterator p = modEvent->particles_begin(); p != modEvent->particles_end(); ++p) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment