ATLAS Offline Software
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Rivet_i Class Reference

Interface to the Rivet analysis package. More...

#include <Rivet_i.h>

Inheritance diagram for Rivet_i:
Collaboration diagram for Rivet_i:

Public Member Functions

 Rivet_i (const std::string &name, ISvcLocator *pSvcLocator)
 Standard algorithm constructor. More...
 
virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE () override
 Initialise the Rivet interface and Athena services. More...
 
virtual StatusCode execute () override
 Run the Rivet analyses on one event, which is retrieved from StoreGate. More...
 
virtual StatusCode finalize () override
 Finalise each analysis and commit the plots to an AIDA tree and the THistSvc ROOT tree. More...
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
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 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
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

std::unique_ptr< HepMC::GenEvent > checkEvent (const HepMC::GenEvent &event, const EventContext &ctx)
 Book an AIDA::IDataPointSet into the THistSvc as a TH1D at path. More...
 
void MeV2GeV (HepMC::GenEvent &event)
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

std::string m_stream
 A pointer to the THistSvc. More...
 
std::string m_file
 The base file name to write results to. More...
 
std::string m_preload
 
std::string m_anapath
 The analysis plugin search path. More...
 
bool m_ignorebeams
 Whether to avoid the beam consistency checks. More...
 
bool m_needsConversion
 Do we need to convert xAOD::Truth back to HepMC::GenEvemt? More...
 
bool m_patchBeams
 Flag to insert beam protons when they are unavailable in the event. More...
 
ToolHandle< IxAODtoHepMCToolm_xAODtoHepMCTool {this, "HepMCTool", "xAODtoHepMCTool"}
 A tool to convert xAOD::Truth to HepMC::GenEvent. More...
 
bool m_doRootHistos
 Will we convert Rivet's internal histo format into a ROOT histo for streaming with THistSvc? More...
 
std::string m_runname
 The name of the run (prepended to plot paths). More...
 
std::string m_genEventKey
 The GenEvent StoreGate key (default "GEN_EVENT") More...
 
Rivet::AnalysisHandler * m_analysisHandler
 A Rivet analysis handler. More...
 
std::vector< std::string > m_analysisNames
 A list of names of the analyses to run (set from the job properties) More...
 
double m_crossSection
 The cross section for this run of events, set from the job properties. More...
 
double m_crossSection_uncert
 The uncertainity of the cross section for this run of events, set from the job properties. More...
 
bool m_init
 Flag to determine whether Rivet init has already happened (in execute()) More...
 
bool m_skipweights
 Skip variation weights and only run nominal. More...
 
std::string m_matchWeights
 String of weight names (or regex) to select multiweights. More...
 
std::string m_unmatchWeights
 String of weight names (or regex) to veto multiweights. More...
 
std::string m_nominalWeightName
 String to specify non-standard nominal weight. More...
 
double m_weightcap
 Weight cap to set allowed maximum for weights. More...
 
SG::ReadHandleKey< xAOD::EventInfom_evtInfoKey
 
DataObjIDColl m_extendedExtraObjects
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Interface to the Rivet analysis package.

Author
James Monk jmonk.nosp@m.@cer.nosp@m.n.ch
Andy Buckley andy..nosp@m.buck.nosp@m.ley@c.nosp@m.ern..nosp@m.ch
Christian Gutschow chris.nosp@m..g@c.nosp@m.ern.c.nosp@m.h

Definition at line 31 of file Rivet_i.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ Rivet_i()

Rivet_i::Rivet_i ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Standard algorithm constructor.

Convert to inherit from GenBase, now we're developing Rivet 2 interfacing for R19+ only.

Definition at line 35 of file Rivet_i.cxx.

35  :
36  AthAlgorithm(name, pSvcLocator),
37  m_needsConversion(false),
39  m_init(false)
40 {
41  // Options
42  declareProperty("McEventKey", m_genEventKey="GEN_EVENT");
43  declareProperty("Analyses", m_analysisNames);
44  declareProperty("CrossSection", m_crossSection=0.0);
45  declareProperty("CrossSectionUncertainty", m_crossSection_uncert=0.0);
46  declareProperty("Stream", m_stream="/Rivet");
47  declareProperty("RunName", m_runname="");
48  declareProperty("HistoFile", m_file="Rivet.yoda.gz");
49  declareProperty("HistoPreload", m_preload="");
50  declareProperty("AnalysisPath", m_anapath="");
51  declareProperty("IgnoreBeamCheck", m_ignorebeams=false);
52  declareProperty("DoRootHistos", m_doRootHistos=false);
53  declareProperty("SkipWeights", m_skipweights=false);
54  declareProperty("MatchWeights", m_matchWeights="");
55  declareProperty("UnmatchWeights", m_unmatchWeights="");
56  declareProperty("NominalWeightName", m_nominalWeightName="");
57  declareProperty("WeightCap", m_weightcap=-1.0);
58  declareProperty("AddMissingBeamParticles",m_patchBeams=false);
59 }

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

virtual StatusCode initialize Rivet_i::ATLAS_NOT_THREAD_SAFE ( )
overridevirtual

Initialise the Rivet interface and Athena services.

Pass a list of analyses to the Rivet AnalysisHandler, which dynamically loads the necessary libraries (including user-written analyses).

◆ checkEvent()

std::unique_ptr< HepMC::GenEvent > Rivet_i::checkEvent ( const HepMC::GenEvent &  event,
const EventContext &  ctx 
)
private

Book an AIDA::IDataPointSet into the THistSvc as a TH1D at path.

Parameters
pathBook an AIDA::IDataPointSet into the THistSvc as a TGraph at path
path

Definition at line 258 of file Rivet_i.cxx.

258  {
259  auto modEvent = std::make_unique<HepMC::GenEvent>(event);
260 
261  if (!m_needsConversion) {
262  // overwrite the HEPMC dummy event number with the proper ATLAS event number
264  modEvent->set_event_number(static_cast<int>(evtInfo->eventNumber()));
265  }
266 
267  // weight-name cleaning
268 #ifdef HEPMC3
269  std::shared_ptr<HepMC3::GenRunInfo> modRunInfo;
270  if (event.run_info()) {
271  modRunInfo = std::make_shared<HepMC3::GenRunInfo>(*(event.run_info().get()));
272  if (event.run_info()->weight_names().empty() && event.weights().size() == 1) {
273  modRunInfo->set_weight_names({"Default"});
274  }
275  }
276  else {
277  ATH_MSG_DEBUG("No run info, event weights size is " << event.weights().size() );
278  modRunInfo = std::make_shared<HepMC3::GenRunInfo>();
279  std::vector<std::string> w_names;
280  for (size_t i = 0; i < event.weights().size(); i++) { w_names.push_back(std::string("badweight") + std::to_string(i)); }
281  modRunInfo->set_weight_names(w_names);
282  }
283  modEvent->set_run_info(modRunInfo);
284  std::vector<std::string> w_names = modEvent->weight_names();
285  if (w_names.size()) {
286  std::vector<std::pair<std::string,std::string> > w_subs = {
287  {" nominal ",""},
288  {" set = ","_"},
289  {" = ","_"},
290  {"=",""},
291  {",",""},
292  {".",""},
293  {":",""},
294  {" ","_"},
295  {"#","num"},
296  {"\n","_"},
297  {"/","over"}
298  };
299  for (std::string& wname : w_names) {
300  for (const auto& sub : w_subs) {
301  size_t start_pos = wname.find(sub.first);
302  while (start_pos != std::string::npos) {
303  wname.replace(start_pos, sub.first.length(), sub.second);
304  start_pos = wname.find(sub.first);
305  }
306  }
307  }
308  modEvent->run_info()->set_weight_names(w_names);
309  }
310 #else
311  const HepMC::WeightContainer& old_wc = event.weights();
312  std::vector<std::string> old_wnames = old_wc.weight_names();
313  if (old_wnames.size()) {
314  HepMC::WeightContainer& new_wc = modEvent->weights();
315  new_wc.clear();
316  std::vector<std::pair<std::string,std::string> > w_subs = {
317  {" nominal ",""},
318  {" set = ","_"},
319  {" = ","_"},
320  {"=",""},
321  {",",""},
322  {".",""},
323  {":",""},
324  {" ","_"},
325  {"#","num"},
326  {"\n","_"},
327  {"/","over"}
328  };
329  std::map<std::string, double> new_name_to_value;
330  std::map<std::string, std::string> old_name_to_new_name;
331  for (const std::string& old_name : old_wnames) {
332  std::string wname = std::string(old_name);
333  double value = old_wc[old_name];
334  for (const auto& sub : w_subs) {
335  size_t start_pos = wname.find(sub.first);
336  while (start_pos != std::string::npos) {
337  wname.replace(start_pos, sub.first.length(), sub.second);
338  start_pos = wname.find(sub.first);
339  }
340  }
341  new_name_to_value[wname] = value;
342  old_name_to_new_name[old_name] = wname;
343  }
344  auto itEnd = old_name_to_new_name.end();
345  for (const std::string& old_name : old_wnames) {
346  if (old_name_to_new_name.find(old_name) == itEnd) continue;
347  const std::string& new_name = old_name_to_new_name[old_name];
348  new_wc[ new_name ] = new_name_to_value[new_name];
349  }
350  // end of weight-name cleaning
351  }
352 #endif
353 
354 #ifdef HEPMC3
355  modEvent->set_units(HepMC3::Units::GEV, HepMC3::Units::MM);
356  if (modEvent->particles().size() == 1) modEvent->set_beam_particles(modEvent->particles().front(), modEvent->particles().front());
357  if (m_patchBeams) {
358  // workaround in case beam particles were missing in xAOD::Truth
359  // first work out centre-of-mass energy
360  double etotal = 0;
361  for (const auto& p : modEvent->particles()) {
362  if (!MC::isStable(p)) continue;
363  etotal += p->momentum().e();
364  }
365  const double ebeam = 0.5*etotal;
366  // create dummy beam particles
367  HepMC::GenParticlePtr b1 = std::make_shared<HepMC::GenParticle>(HepMC::FourVector(0,0,ebeam,ebeam),2212,4);
368  HepMC::GenParticlePtr b2 = std::make_shared<HepMC::GenParticle>(HepMC::FourVector(0,0,-1*ebeam,ebeam),2212,4);
369  // remove particles incorrectly labelled as beam particles
370  std::vector<HepMC::GenParticlePtr> notBeams;
371  for (const HepMC::GenParticlePtr& p : modEvent->beams()) {
372  if (!MC::isBeam(p)) notBeams.push_back(p);
373  }
374  //AV: the loop is over shared pointers! Should be const auto&
375  for (const auto& bp : notBeams) bp->production_vertex()->remove_particle_out(bp);
376  // add dummy beam particles
377  modEvent->set_beam_particles(b1, b2);
378  }
379  if (modEvent->beams().front()->momentum().e() > 50000.0) {
380  MeV2GeV(*modEvent);
381  }
382 #else
383  modEvent->use_units(HepMC::Units::GEV, HepMC::Units::MM);
384  if (modEvent->particles_size() == 1) modEvent->set_beam_particles(*modEvent->particles_begin(), *modEvent->particles_begin());
385  if (modEvent->beam_particles().first->momentum().e() > 50000.0) {
386  MeV2GeV(*modEvent);
387  }
388 #endif
389 
390  return modEvent;
391 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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

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

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation 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.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation 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.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation 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.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation 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.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

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

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

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evtStore() [1/2]

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

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

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ execute()

StatusCode Rivet_i::execute ( )
overridevirtual

Run the Rivet analyses on one event, which is retrieved from StoreGate.

Todo:
Replace with new GenBase functionality
Todo:
Actually use back(), for the most recent event, or throw an exception if more than one event found?
Todo:
Replace with new GenBase const_event() functionality

Definition at line 137 of file Rivet_i.cxx.

137  {
138  ATH_MSG_DEBUG("Rivet_i execute");
139 
140  const EventContext& ctx = getContext();
141 
143  ATH_MSG_DEBUG("Rivet_i needs xAOD::Truth to HepMC::GenEvent conversion? " << m_needsConversion);
144 
145  std::unique_ptr<HepMC::GenEvent> checkedEvent;
146  if (m_needsConversion) {
147  const xAOD::TruthEventContainer* truthCollection = nullptr;
148  if (evtStore()->retrieve(truthCollection, "TruthEvents").isFailure()) {
149  ATH_MSG_ERROR("Could not retrieve TruthEvents collection, aborting.");
150  return StatusCode::FAILURE;
151  }
152 
154  ATH_MSG_DEBUG("Attempt xAOD::Truth to HepMC::GenEvent conversion.");
155  std::vector<HepMC::GenEvent>&& hepmc_evts = m_xAODtoHepMCTool->getHepMCEvents(truthCollection, eventInfo.cptr());
156 
157  if (hepmc_evts.empty()) {
158  ATH_MSG_ERROR("Conversion didn't yield HepMC::GenEvent, aborting.");
159  return StatusCode::FAILURE;
160  }
161  checkedEvent = checkEvent(std::move(hepmc_evts[0]), ctx);
162  }
163  else {
164  // Get the event collection
166  const McEventCollection* eventCollection = nullptr;
167  StatusCode sc = evtStore()->retrieve(eventCollection, m_genEventKey);
168  if (sc.isFailure() || eventCollection == 0) {
169  ATH_MSG_ERROR("Unable to retrieve event collection from StoreGate with key " << m_genEventKey);
170  return StatusCode::FAILURE;
171  } else {
172  ATH_MSG_DEBUG("Retrieved event collection from StoreGate with key " << m_genEventKey);
173  }
174 
175  // Get the first event in the event collection
178  const HepMC::GenEvent* event = eventCollection->front();
179  if (event == nullptr) {
180  ATH_MSG_ERROR("Rivet_i received a null HepMC event");
181  return StatusCode::FAILURE;
182  }
183 
184  // Modify the event units etc. if necessary
185  checkedEvent = checkEvent(*event, ctx);
186  }
187 
188  if(!checkedEvent) {
189  ATH_MSG_ERROR("Check on HepMC event failed!");
190  return StatusCode::FAILURE;
191  }
192 
193  // Initialize Rivet (on the first event only)
194  if (!m_init) {
195  m_analysisHandler->init(*checkedEvent);
196  m_init = true;
197  }
198 
199  // Analyse the event
200  m_analysisHandler->analyze(*checkedEvent);
201 
202  return StatusCode::SUCCESS;
203 }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::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

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51 {
52  // If we didn't find any symlinks to add, just return the collection
53  // from the base class. Otherwise, return the extended collection.
54  if (!m_extendedExtraObjects.empty()) {
56  }
57  return Algorithm::extraOutputDeps();
58 }

◆ finalize()

StatusCode Rivet_i::finalize ( )
overridevirtual

Finalise each analysis and commit the plots to an AIDA tree and the THistSvc ROOT tree.

Definition at line 206 of file Rivet_i.cxx.

206  {
207  ATH_MSG_INFO("Rivet_i finalizing");
208 
209  // Setting cross-section in Rivet
210  // If no user-specified cross-section available,
211  // take whatever is in the GenEvent
213 
214  // Call Rivet finalize
215  m_analysisHandler->finalize();
216 
217 
218 
219  // Write out YODA file (add .yoda suffix if missing)
220  if (m_file.find(".yoda") == std::string::npos) m_file += ".yoda.gz";
221  auto pos = m_file.find(".gz.");
222  if (pos == std::string::npos) {
223  m_analysisHandler->writeData(m_file);
224  }
225  else {//filename is e.g. something.yoda.gz.1
226  //write to output file name without the ".1"
227  m_analysisHandler->writeData(m_file.substr(0, pos)+".gz");
228  // then rename it as the requested output filename
229  if (std::rename((m_file.substr(0, pos)+".gz").c_str(), m_file.c_str()) !=0) {
230  std::string error_msg = "Impossible to rename ";
231  error_msg += m_file.substr(0, pos)+".gz";
232  error_msg += " as ";
233  error_msg += m_file;
234  ATH_MSG_ERROR(error_msg.c_str());
235  return StatusCode::FAILURE;
236  }
237  }
238 
239  return StatusCode::SUCCESS;
240 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Algorithm > >::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.

◆ MeV2GeV()

void Rivet_i::MeV2GeV ( HepMC::GenEvent &  event)
private

Definition at line 393 of file Rivet_i.cxx.

393  {
394 #ifdef HEPMC3
395  for (auto& p: evt.particles()) {
396  p->set_momentum(p->momentum()*0.001);
397 #else
398  for (HepMC::GenParticlePtr p: evt) {
399  const HepMC::FourVector& mom = p->momentum();
400  p->set_momentum(HepMC::FourVector (mom.px()*0.001,
401  mom.py()*0.001,
402  mom.pz()*0.001,
403  mom.e()*0.001));
404 #endif
405  p->set_generated_mass(p->generated_mass()*0.001);
406  }
407 }

◆ msg() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

MsgStream& AthCommonMsg< Algorithm >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::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< Algorithm > >::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< Algorithm > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

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

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, PyAthena::Alg, and AthHistogramAlgorithm.

Definition at line 66 of file AthAlgorithm.cxx.

66  {
68 
69  if (sc.isFailure()) {
70  return sc;
71  }
72  ServiceHandle<ICondSvc> cs("CondSvc",name());
73  for (auto h : outputHandles()) {
74  if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75  // do this inside the loop so we don't create the CondSvc until needed
76  if ( cs.retrieve().isFailure() ) {
77  ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78  return StatusCode::SUCCESS;
79  }
80  if (cs->regHandle(this,*h).isFailure()) {
81  sc = StatusCode::FAILURE;
82  ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83  << " with CondSvc");
84  }
85  }
86  }
87  return sc;
88 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::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< Algorithm > >::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) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_analysisHandler

Rivet::AnalysisHandler* Rivet_i::m_analysisHandler
private

A Rivet analysis handler.

Definition at line 113 of file Rivet_i.h.

◆ m_analysisNames

std::vector<std::string> Rivet_i::m_analysisNames
private

A list of names of the analyses to run (set from the job properties)

Definition at line 116 of file Rivet_i.h.

◆ m_anapath

std::string Rivet_i::m_anapath
private

The analysis plugin search path.

This will be used to internally set RIVET_ANALYSIS_PATH, if not already set in the environment.

Definition at line 80 of file Rivet_i.h.

◆ m_crossSection

double Rivet_i::m_crossSection
private

The cross section for this run of events, set from the job properties.

Definition at line 119 of file Rivet_i.h.

◆ m_crossSection_uncert

double Rivet_i::m_crossSection_uncert
private

The uncertainity of the cross section for this run of events, set from the job properties.

Definition at line 122 of file Rivet_i.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doRootHistos

bool Rivet_i::m_doRootHistos
private

Will we convert Rivet's internal histo format into a ROOT histo for streaming with THistSvc?

The default is yes Currently (03.01.12) there is no conversion for 2D distributions, in which case you want to set this to False

Definition at line 104 of file Rivet_i.h.

◆ m_evtInfoKey

SG::ReadHandleKey<xAOD::EventInfo> Rivet_i::m_evtInfoKey
private
Initial value:
{this
, "EventInfo"
, "EventInfo"
, "ReadHandleKey for xAOD::EventInfo" }

Definition at line 142 of file Rivet_i.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_file

std::string Rivet_i::m_file
private

The base file name to write results to.

Definition at line 72 of file Rivet_i.h.

◆ m_genEventKey

std::string Rivet_i::m_genEventKey
private

The GenEvent StoreGate key (default "GEN_EVENT")

Definition at line 110 of file Rivet_i.h.

◆ m_ignorebeams

bool Rivet_i::m_ignorebeams
private

Whether to avoid the beam consistency checks.

Default is false: checks will be made to ensure that the supplied events have beams of the sort that the analysis was written to expect.

Definition at line 86 of file Rivet_i.h.

◆ m_init

bool Rivet_i::m_init
private

Flag to determine whether Rivet init has already happened (in execute())

Definition at line 125 of file Rivet_i.h.

◆ m_matchWeights

std::string Rivet_i::m_matchWeights
private

String of weight names (or regex) to select multiweights.

Definition at line 131 of file Rivet_i.h.

◆ m_needsConversion

bool Rivet_i::m_needsConversion
private

Do we need to convert xAOD::Truth back to HepMC::GenEvemt?

Default is false: assume user runs on EVNT files

Definition at line 91 of file Rivet_i.h.

◆ m_nominalWeightName

std::string Rivet_i::m_nominalWeightName
private

String to specify non-standard nominal weight.

Definition at line 137 of file Rivet_i.h.

◆ m_patchBeams

bool Rivet_i::m_patchBeams
private

Flag to insert beam protons when they are unavailable in the event.

Definition at line 94 of file Rivet_i.h.

◆ m_preload

std::string Rivet_i::m_preload
private

Definition at line 75 of file Rivet_i.h.

◆ m_runname

std::string Rivet_i::m_runname
private

The name of the run (prepended to plot paths).

Definition at line 107 of file Rivet_i.h.

◆ m_skipweights

bool Rivet_i::m_skipweights
private

Skip variation weights and only run nominal.

Definition at line 128 of file Rivet_i.h.

◆ m_stream

std::string Rivet_i::m_stream
private

A pointer to the THistSvc.

The stream name for storing the output plots under (default "/Rivet")

Definition at line 69 of file Rivet_i.h.

◆ m_unmatchWeights

std::string Rivet_i::m_unmatchWeights
private

String of weight names (or regex) to veto multiweights.

Definition at line 134 of file Rivet_i.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_weightcap

double Rivet_i::m_weightcap
private

Weight cap to set allowed maximum for weights.

Definition at line 140 of file Rivet_i.h.

◆ m_xAODtoHepMCTool

ToolHandle<IxAODtoHepMCTool> Rivet_i::m_xAODtoHepMCTool {this, "HepMCTool", "xAODtoHepMCTool"}
private

A tool to convert xAOD::Truth to HepMC::GenEvent.

Definition at line 97 of file Rivet_i.h.


The documentation for this class was generated from the following files:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Rivet_i::m_init
bool m_init
Flag to determine whether Rivet init has already happened (in execute())
Definition: Rivet_i.h:125
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Rivet_i::m_anapath
std::string m_anapath
The analysis plugin search path.
Definition: Rivet_i.h:80
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Rivet_i::m_patchBeams
bool m_patchBeams
Flag to insert beam protons when they are unavailable in the event.
Definition: Rivet_i.h:94
HepMC::GenParticlePtr
GenParticle * GenParticlePtr
Definition: GenParticle.h:37
Rivet_i::m_xAODtoHepMCTool
ToolHandle< IxAODtoHepMCTool > m_xAODtoHepMCTool
A tool to convert xAOD::Truth to HepMC::GenEvent.
Definition: Rivet_i.h:97
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
Rivet_i::m_genEventKey
std::string m_genEventKey
The GenEvent StoreGate key (default "GEN_EVENT")
Definition: Rivet_i.h:110
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
MM
@ MM
Definition: RegSelEnums.h:38
athena.value
value
Definition: athena.py:124
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
Rivet_i::m_stream
std::string m_stream
A pointer to the THistSvc.
Definition: Rivet_i.h:69
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
Rivet_i::m_doRootHistos
bool m_doRootHistos
Will we convert Rivet's internal histo format into a ROOT histo for streaming with THistSvc?
Definition: Rivet_i.h:104
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthAlgorithm.cxx:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Rivet_i::m_needsConversion
bool m_needsConversion
Do we need to convert xAOD::Truth back to HepMC::GenEvemt?
Definition: Rivet_i.h:91
Rivet_i::m_nominalWeightName
std::string m_nominalWeightName
String to specify non-standard nominal weight.
Definition: Rivet_i.h:137
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
lumiFormat.i
int i
Definition: lumiFormat.py:85
Rivet_i::m_unmatchWeights
std::string m_unmatchWeights
String of weight names (or regex) to veto multiweights.
Definition: Rivet_i.h:134
Rivet_i::MeV2GeV
void MeV2GeV(HepMC::GenEvent &event)
Definition: Rivet_i.cxx:393
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Rivet_i::m_crossSection_uncert
double m_crossSection_uncert
The uncertainity of the cross section for this run of events, set from the job properties.
Definition: Rivet_i.h:122
DataVector::front
const T * front() const
Access the first element in the collection as an rvalue.
GEV
#define GEV
Definition: PrintPhotonSF.cxx:24
Rivet_i::m_analysisNames
std::vector< std::string > m_analysisNames
A list of names of the analyses to run (set from the job properties)
Definition: Rivet_i.h:116
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
Rivet_i::m_crossSection
double m_crossSection
The cross section for this run of events, set from the job properties.
Definition: Rivet_i.h:119
McEventCollection
This defines the McEventCollection, which is really just an ObjectVector of McEvent objects.
Definition: McEventCollection.h:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
Rivet_i::m_file
std::string m_file
The base file name to write results to.
Definition: Rivet_i.h:72
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
Rivet_i::m_ignorebeams
bool m_ignorebeams
Whether to avoid the beam consistency checks.
Definition: Rivet_i.h:86
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Rivet_i::m_skipweights
bool m_skipweights
Skip variation weights and only run nominal.
Definition: Rivet_i.h:128
AthAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Definition: AthAlgorithm.h:79
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition: HepMCHelpers.h:45
Rivet_i::m_matchWeights
std::string m_matchWeights
String of weight names (or regex) to select multiweights.
Definition: Rivet_i.h:131
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Rivet_i::checkEvent
std::unique_ptr< HepMC::GenEvent > checkEvent(const HepMC::GenEvent &event, const EventContext &ctx)
Book an AIDA::IDataPointSet into the THistSvc as a TH1D at path.
Definition: Rivet_i.cxx:258
MC::isBeam
bool isBeam(const T &p)
Identify if the particle is beam particle.
Definition: HepMCHelpers.h:39
Rivet_i::m_preload
std::string m_preload
Definition: Rivet_i.h:75
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
AthAlgorithm::AthAlgorithm
AthAlgorithm()
Default constructor:
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
Rivet_i::m_weightcap
double m_weightcap
Weight cap to set allowed maximum for weights.
Definition: Rivet_i.h:140
Rivet_i::m_analysisHandler
Rivet::AnalysisHandler * m_analysisHandler
A Rivet analysis handler.
Definition: Rivet_i.h:113
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
Rivet_i::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
Definition: Rivet_i.h:142
fitman.k
k
Definition: fitman.py:528
ServiceHandle< ICondSvc >
Rivet_i::m_runname
std::string m_runname
The name of the run (prepended to plot paths).
Definition: Rivet_i.h:107