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

Print MC event details for a range of event numbers. More...

#include <PrintMC.h>

Inheritance diagram for PrintMC:
Collaboration diagram for PrintMC:

Public Member Functions

 PrintMC (const std::string &name, ISvcLocator *pSvcLocator)
 
virtual StatusCode initialize () override
 
virtual StatusCode execute () override
 
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

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

SG::ReadHandleKey< xAOD::EventInfom_evtInfoKey
 
std::string m_keyout
 
bool m_VerboseOutput
 
std::string m_printsty
 
bool m_vertexinfo
 
uint64_t m_firstEvt
 
uint64_t m_lastEvt
 
bool m_trustHepMC
 
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
 

Utility event-mangling functions

Todo:
Replace with HepMC units when available
ServiceHandle< IPartPropSvc > m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
 Handle on the particle property service. More...
 
SG::ReadHandleKey< McEventCollectionm_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
 Const handle to the MC event collection. More...
 
void GeVToMeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1000. More...
 
void MeVToGeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1/1000. More...
 
void cmTomm (HepMC::GenEvent *evt)
 Scale event lengths by x 10. More...
 
void mmTocm (HepMC::GenEvent *evt)
 Scale event lengths by x 1/10. More...
 

Detailed Description

Print MC event details for a range of event numbers.

Definition at line 12 of file PrintMC.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

◆ PrintMC()

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

Definition at line 21 of file PrintMC.cxx.

22  : GenBase(name, pSvcLocator)
23 {
24  // Declare JO interface
25  declareProperty("VerboseOutput", m_VerboseOutput=true, "Print out detailed information or not");
26  declareProperty("PrintStyle", m_printsty="Barcode", "Type of info to print out: 'Barcode' or 'Vertex'");
27  declareProperty("VertexInfo", m_vertexinfo=false, "Print out vertex information");
28  declareProperty("TrustHepMC", m_trustHepMC=false, "Use the event numbers in the HepMC record to choose the events to print");
29  declareProperty("FirstEvent", m_firstEvt=1, "Lowest event number to print");
30  declareProperty("LastEvent", m_lastEvt=100000000, "Highest event number to print");
31 }

Member Function Documentation

◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/2]

HepMC::GenEvent* event GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inlineinherited

Access the current signal event (first in the McEventCollection)

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

Definition at line 76 of file GenBase.h.

76  {
77  if (events()->empty())
78  ATH_MSG_ERROR("McEventCollection is empty during first event access");
79  return *(events()->begin());
80  }

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/2]

McEventCollection* events GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inherited

Access the current event's McEventCollection.

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

◆ cmTomm()

void GenBase::cmTomm ( HepMC::GenEvent *  evt)
protectedinherited

Scale event lengths by x 10.

Definition at line 81 of file GenBase.cxx.

81  {
82  for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
83  const HepMC::FourVector fv((*vtx)->position().x() * 10,
84  (*vtx)->position().y() * 10,
85  (*vtx)->position().z() * 10,
86  (*vtx)->position().t() * 10);
87  (*vtx)->set_position(fv);
88  }
89 }

◆ 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; }

◆ event_const()

const HepMC::GenEvent* GenBase::event_const ( ) const
inlineinherited

Access the current signal event (const)

Definition at line 83 of file GenBase.h.

83  {
84  if (events_const()->empty())
85  ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
86  return *(events_const()->begin());
87  }

◆ events_const() [1/2]

const McEventCollection* GenBase::events_const ( ) const
inlineinherited

Access the current event's McEventCollection (const)

Definition at line 96 of file GenBase.h.

96  {
97  return events_const( getContext() );
98  }

◆ events_const() [2/2]

const McEventCollection* GenBase::events_const ( const EventContext &  ctx) const
inlineinherited

Definition at line 99 of file GenBase.h.

99  {
101  if (!ret.isValid())
102  ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
103  return ret.cptr();
104  }

◆ 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 PrintMC::execute ( )
overridevirtual
Todo:
Avoid use of unprotected std::cout: stringstream + MsgStream would be better
Todo:
I get the feeling VerboseOutput is being abused here...
Todo:
Looks like misuse of the verbose output flag
Todo:
Isn't this if (m_VerboseOutput... redundant?
Todo:
Isn't this if (m_VerboseOutput... redundant?
Todo:
Is there no better way to detect unspecified masses than == 0? Final state photons should be 0

Reimplemented from GenBase.

Definition at line 53 of file PrintMC.cxx.

53  {
54  // If output already turned off by passing last dumped event, just return
56  if (!m_VerboseOutput) return StatusCode::SUCCESS;
57 
58  // Loop over all events in McEventCollection
59 
60  for (const HepMC::GenEvent* evt : *events_const()) {
61 
62  // Get event number from HepMC
63  uint64_t evtnum = std::max(0,evt->event_number());
64  // Override with evtnum from Athena if enabled and functional
65  if (!m_trustHepMC) {
67  evtnum = evtInfo->eventNumber();
68  }
69 
70  // Return immediately if event number is outside the print range
71  if (evtnum < m_firstEvt) {
72  return StatusCode::SUCCESS;
73  }
74  if (evtnum > m_lastEvt) {
76  m_VerboseOutput = false;
77  return StatusCode::SUCCESS;
78  }
79 
80  // Printout header
81  ATH_MSG_INFO(">>> PrintMC from execute");
82 
83  // VERTEX format
85  if (m_VerboseOutput && m_printsty == "Vertex") {
86  HepMC::Print::line(std::cout, *evt); // standard HepMC dump of vertex list
87  }
88  // BARCODE format
90  else if (m_VerboseOutput && m_printsty == "Barcode") {
91  drawLine(std::cout);
92 
93  std::cout << "GenEvent: #" << evt->event_number()
94  << " ID=" << HepMC::signal_process_id(evt)
95  << " SignalProcessGenVertex Barcode: "
97  std::cout << " Entries this event: " << evt->vertices_size() << " vertices, "
98  << evt->particles_size() << " particles.\n";
99 #ifdef HEPMC3
100  if (evt->heavy_ion()) {
101  std::cout << " HeavyIon: jatt=" << evt->heavy_ion()->Ncoll_hard
102  << " np=" << evt->heavy_ion()->Npart_proj
103  << " nt=" << evt->heavy_ion()->Npart_targ
104  << " ncoll=" << evt->heavy_ion()->Ncoll
105  << " specn=" << evt->heavy_ion()->spectator_neutrons
106  << " specp=" << evt->heavy_ion()->spectator_protons
107  << " n01=" << evt->heavy_ion()->N_Nwounded_collisions
108  << " n10=" << evt->heavy_ion()->Nwounded_N_collisions
109  << " n11=" << evt->heavy_ion()->Nwounded_Nwounded_collisions
110  << " impact=" << evt->heavy_ion()->impact_parameter
111  << " evplane=" << evt->heavy_ion()->event_plane_angle
112  << " ecc=" << evt->heavy_ion()->eccentricity
113  << " sigmaNNinel=" << evt->heavy_ion()->sigma_inel_NN
114  << std::endl;
115  }
116  else {
117  std::cout << "HeavyIon: EMPTY"
118  << std::endl;
119  }
120 
121 
122  // Weights
123  std::cout << " Weights(" << evt->weights().size() << ")=";
124  for ( auto wgt = evt->weights().begin();
125  wgt != evt->weights().end(); wgt++ ) { std::cout << *wgt << " "; }
126  std::cout << "\n";
127  std::cout << " EventScale " << (evt->attribute<HepMC3::DoubleAttribute>("event_scale")? evt->attribute<HepMC3::DoubleAttribute>("event_scale")->value():0.0)
128  << " [energy] \t alphaQCD=" << (evt->attribute<HepMC3::DoubleAttribute>("alphaQCD")? evt->attribute<HepMC3::DoubleAttribute>("alphaQCD")->value():0.0)
129  << "\t alphaQED=" << (evt->attribute<HepMC3::DoubleAttribute>("alphaQED")? evt->attribute<HepMC3::DoubleAttribute>("alphaQED")->value():0.0) << std::endl;
130 
131  if (evt->pdf_info()) {
132  std::cout << "PdfInfo: id1=" << evt->pdf_info()->parton_id[0]
133  << " id2=" << evt->pdf_info()->parton_id[1]
134  << " x1=" << evt->pdf_info()->x[0]
135  << " x2=" << evt->pdf_info()->x[1]
136  << " q=" << evt->pdf_info()->scale
137  << " xpdf1=" << evt->pdf_info()->pdf_id[0]
138  << " xpdf2=" << evt->pdf_info()->pdf_id[1]
139  << std::endl;
140  }
141  else {
142  std::cout << "PdfInfo: EMPTY"
143  << std::endl;
144  }
145 #else
146  if (evt->heavy_ion()) {
147  std::cout << " HeavyIon: jatt=" << evt->heavy_ion()->Ncoll_hard()
148  << " np=" << evt->heavy_ion()->Npart_proj()
149  << " nt=" << evt->heavy_ion()->Npart_targ()
150  << " ncoll=" << evt->heavy_ion()->Ncoll()
151  << " specn=" << evt->heavy_ion()->spectator_neutrons()
152  << " specp=" << evt->heavy_ion()->spectator_protons()
153  << " n01=" << evt->heavy_ion()->N_Nwounded_collisions()
154  << " n10=" << evt->heavy_ion()->Nwounded_N_collisions()
155  << " n11=" << evt->heavy_ion()->Nwounded_Nwounded_collisions()
156  << " impact=" << evt->heavy_ion()->impact_parameter()
157  << " evplane=" << evt->heavy_ion()->event_plane_angle()
158  << " ecc=" << evt->heavy_ion()->eccentricity()
159  << " sigmaNNinel=" << evt->heavy_ion()->sigma_inel_NN()
160  << std::endl;
161  }
162  else {
163  std::cout << "HeavyIon: EMPTY"
164  << std::endl;
165  }
166 
167 
168  // Weights
169  std::cout << " Weights(" << evt->weights().size() << ")=";
170  for (double w : evt->weights()) {
171  std::cout << w << " ";
172  }
173  std::cout << "\n";
174  std::cout << " EventScale " << evt->event_scale()
175  << " [energy] \t alphaQCD=" << evt->alphaQCD()
176  << "\t alphaQED=" << evt->alphaQED() << std::endl;
177 
178  if (evt->pdf_info()) {
179  std::cout << "PdfInfo: id1=" << evt->pdf_info()->id1()
180  << " id2=" << evt->pdf_info()->id2()
181  << " x1=" << evt->pdf_info()->x1()
182  << " x2=" << evt->pdf_info()->x2()
183  << " q=" << evt->pdf_info()->scalePDF()
184  << " xpdf1=" << evt->pdf_info()->pdf1()
185  << " xpdf2=" << evt->pdf_info()->pdf2()
186  << std::endl;
187  }
188  else {
189  std::cout << "PdfInfo: EMPTY"
190  << std::endl;
191  }
192 #endif
193 
194  // Print a legend to describe the particle info
195  char particle_legend[120];
196  sprintf( particle_legend," %9s %8s %-15s %4s %8s %8s (%9s,%9s,%9s,%9s,%9s)",
197  "Barcode","PDG ID","Name","Stat","ProdVtx","DecayVtx","Px","Py","Pz","E ","m");
198  std::cout << std::endl;
199  std::cout << " GenParticle Legend\n" << particle_legend << "\n";
200  if (m_vertexinfo) {
201  sprintf( particle_legend," %60s (%9s,%9s,%9s,%9s)"," ","Vx","Vy","Vz","Vct ");
202  std::cout << particle_legend << std::endl;
203  }
204  drawLine(std::cout);
205 
206  // Print all particles
207  for (auto p: *evt) {
208  int p_bcode = HepMC::barcode(p);
209  int p_pdg_id = p->pdg_id();
210  HepMC::FourVector mom=p->momentum();
211  int p_stat = p->status();
212  int p_prodvtx = p->production_vertex()?HepMC::barcode(p->production_vertex()):0;
213  int p_endvtx = p->end_vertex()?HepMC::barcode(p->end_vertex()):0;
214  HepMC::FourVector prodvtx=p->production_vertex()?p->production_vertex()->position():HepMC::FourVector(0.0,0.0,0.0,0.0);
215  // Access the PDG table to get the particle name (and mass?)
216  std::string sname;
217  double p_mass = p->generated_mass();
218  const HepPDT::ParticleData* ap = particleData(std::abs(p_pdg_id));
219  if (!ap) {
220  ATH_MSG_DEBUG("PID " << std::abs(p_pdg_id) << " is not in particle data table");
221  } else {
222  const double p_charge = ap->charge() * (p_pdg_id < 0 ? -1 : 1); // assuming that charged leptons are in the PDT...
223  // Build particle name string
224  sname = ap->name();
225  if (p_charge < 0) {
226  const size_t plusidx = sname.rfind("+");
227  if (plusidx != std::string::npos) {
228  sname.replace(plusidx, 1, "-");
229  }
230  }
231  }
232  // PDG table missing or exceptions
233  // quarks & gluons
234  if (p_pdg_id == 21) sname="g";
235  else if (p_pdg_id == 1) sname="d";
236  else if (p_pdg_id == -1) sname="d~";
237  else if (p_pdg_id == 2) sname="u";
238  else if (p_pdg_id == -2) sname="u~";
239  else if (p_pdg_id == 3) sname="s";
240  else if (p_pdg_id == -3) sname="s~";
241  else if (p_pdg_id == 4) sname="c";
242  else if (p_pdg_id == -4) sname="c~";
243  else if (p_pdg_id == 5) sname="b";
244  else if (p_pdg_id == -5) sname="b~";
245  else if (p_pdg_id == 6) sname="t";
246  else if (p_pdg_id == -6) sname="t~";
247  // shower-specific
248  else if (p_pdg_id == 91) sname="cluster";
249  else if (p_pdg_id == 92) sname="string";
250  else if (p_pdg_id == 9922212) sname="remn";
251  else if (p_pdg_id == 2101) sname="ud";
252  else if (p_pdg_id == 2203) sname="uu";
253 
254  // Calc mass if missing
256  if (p_mass == 0 && (p_stat == 2 || (p_stat != 1 && p_pdg_id != 22))) {
257  p_mass = mom.m();
258  }
259 
260  const char* p_name = sname.c_str() ;
261  char particle_entries[120];
262  sprintf(particle_entries, " %9i %8i %-15s %4i %8i %8i (%+9.3g,%+9.3g,%+9.3g,%+9.3g,%9.3g)",
263  p_bcode, p_pdg_id, p_name, p_stat, p_prodvtx, p_endvtx, mom.px(), mom.py(),mom.pz(), mom.e(), p_mass);
264  std::cout << particle_entries << "\n";
265  if (m_vertexinfo) {
266  sprintf(particle_entries," %60s (%+9.3g,%+9.3g,%+9.3g,%+9.3g)"," ",prodvtx.x(), prodvtx.y(),prodvtx.z(), prodvtx.t());
267  std::cout << particle_entries << "\n";
268  }
269  }
270 
271  }
272 
273  }
274  // End of execution for each event
275  return StatusCode::SUCCESS;
276 }

◆ 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 }

◆ GeVToMeV()

void GenBase::GeVToMeV ( HepMC::GenEvent *  evt)
protectedinherited

Scale event energies/momenta by x 1000.

Todo:
Add HepMC units awareness and do it differently when HepMC provides this functionality directly (and reference-based FourVector accessors)

Definition at line 61 of file GenBase.cxx.

61  {
62  for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
63  const HepMC::FourVector fv((*p)->momentum().px() * 1000,
64  (*p)->momentum().py() * 1000,
65  (*p)->momentum().pz() * 1000,
66  (*p)->momentum().e() * 1000);
67  (*p)->set_momentum(fv);
68  (*p)->set_generated_mass(1000 * (*p)->generated_mass());
69  }
70 }

◆ initialize()

StatusCode PrintMC::initialize ( )
overridevirtual

Reimplemented from GenBase.

Definition at line 34 of file PrintMC.cxx.

34  {
37 
38  // Check settings
39  if (m_printsty != "Barcode" && m_printsty != "Vertex") {
40  ATH_MSG_ERROR("Unknown PrintStyle: " << m_printsty << "! Choose Barcode/Vertex");
41  return StatusCode::FAILURE;
42  }
43 
44  // Check that last > first
46 
47  return StatusCode::SUCCESS;
48 }

◆ 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.

◆ MeVToGeV()

void GenBase::MeVToGeV ( HepMC::GenEvent *  evt)
protectedinherited

Scale event energies/momenta by x 1/1000.

Definition at line 71 of file GenBase.cxx.

71  {
72  for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
73  const HepMC::FourVector fv((*p)->momentum().px() / 1000,
74  (*p)->momentum().py() / 1000,
75  (*p)->momentum().pz() / 1000,
76  (*p)->momentum().e() / 1000);
77  (*p)->set_momentum(fv);
78  (*p)->set_generated_mass((*p)->generated_mass() / 1000);
79  }
80 }

◆ mmTocm()

void GenBase::mmTocm ( HepMC::GenEvent *  evt)
protectedinherited

Scale event lengths by x 1/10.

Definition at line 90 of file GenBase.cxx.

90  {
91  for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
92  const HepMC::FourVector fv((*vtx)->position().x() / 10,
93  (*vtx)->position().y() / 10,
94  (*vtx)->position().z() / 10,
95  (*vtx)->position().t() / 10);
96  (*vtx)->set_position(fv);
97  }
98 }

◆ 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.

◆ particleData()

const HepPDT::ParticleData* GenBase::particleData ( int  pid) const
inlineinherited

Access an element in the particle data table.

Definition at line 126 of file GenBase.h.

126  {
127  return pdt().particle(HepPDT::ParticleID(std::abs(pid)));
128  }

◆ particleTable()

const HepPDT::ParticleDataTable& GenBase::particleTable ( ) const
inlineinherited

Get a particle data table.

Definition at line 118 of file GenBase.h.

118  {
119  return *(m_ppSvc->PDT());
120  }

◆ partPropSvc()

const ServiceHandle<IPartPropSvc> GenBase::partPropSvc ( ) const
inlineinherited

Access the particle property service.

Definition at line 113 of file GenBase.h.

113  {
114  return m_ppSvc;
115  }

◆ pdt()

const HepPDT::ParticleDataTable& GenBase::pdt ( ) const
inlineinherited

Shorter alias to get a particle data table.

Definition at line 123 of file GenBase.h.

123 { return particleTable(); }

◆ 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_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_evtInfoKey

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

Definition at line 20 of file PrintMC.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_firstEvt

uint64_t PrintMC::m_firstEvt
private

Definition at line 29 of file PrintMC.h.

◆ m_keyout

std::string PrintMC::m_keyout
private

Definition at line 25 of file PrintMC.h.

◆ m_lastEvt

uint64_t PrintMC::m_lastEvt
private

Definition at line 30 of file PrintMC.h.

◆ m_mcEventKey

std::string GenBase::m_mcEventKey {}
protectedinherited

StoreGate key for the MC event collection (defaults to GEN_EVENT)

Definition at line 137 of file GenBase.h.

◆ m_mcevents_const

SG::ReadHandleKey<McEventCollection> GenBase::m_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
privateinherited

Const handle to the MC event collection.

Definition at line 163 of file GenBase.h.

◆ m_mkMcEvent

BooleanProperty GenBase::m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
protectedinherited

Flag to determine if a new MC event collection should be made if it doesn't exist.

Definition at line 139 of file GenBase.h.

◆ m_ppSvc

ServiceHandle<IPartPropSvc> GenBase::m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
privateinherited

Handle on the particle property service.

Definition at line 160 of file GenBase.h.

◆ m_printsty

std::string PrintMC::m_printsty
private

Definition at line 27 of file PrintMC.h.

◆ m_trustHepMC

bool PrintMC::m_trustHepMC
private

Definition at line 31 of file PrintMC.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_VerboseOutput

bool PrintMC::m_VerboseOutput
private

Definition at line 26 of file PrintMC.h.

◆ m_vertexinfo

bool PrintMC::m_vertexinfo
private

Definition at line 28 of file PrintMC.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
PrintMC::m_lastEvt
uint64_t m_lastEvt
Definition: PrintMC.h:30
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
max
#define max(a, b)
Definition: cfImp.cxx:41
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
GenBase::events_const
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition: GenBase.h:96
SG::ReadHandle< McEventCollection >
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
HepMC::signal_process_id
int signal_process_id(const GenEvent &e)
Definition: GenEvent.h:513
PrintMC::m_firstEvt
uint64_t m_firstEvt
Definition: PrintMC.h:29
PrintMC::m_printsty
std::string m_printsty
Definition: PrintMC.h:27
PrintMC::m_VerboseOutput
bool m_VerboseOutput
Definition: PrintMC.h:26
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HepMC::Print::line
void line(std::ostream &os, const GenEvent &e)
Definition: GenEvent.h:554
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
python.DataFormatRates.events
events
Definition: DataFormatRates.py:105
python.AtlRunQueryParser.ap
ap
Definition: AtlRunQueryParser.py:826
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
PrintMC::m_evtInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfoKey
Definition: PrintMC.h:20
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
PrintMC::m_vertexinfo
bool m_vertexinfo
Definition: PrintMC.h:28
GenBase::m_ppSvc
ServiceHandle< IPartPropSvc > m_ppSvc
Handle on the particle property service.
Definition: GenBase.h:160
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
AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
Return this algorithm's output handles.
ret
T ret(T t)
Definition: rootspy.cxx:260
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
GenBase::m_mcevents_const
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition: GenBase.h:163
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
jobOptions.ParticleID
ParticleID
Definition: jobOptions.decayer.py:85
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
GenBase::particleTable
const HepPDT::ParticleDataTable & particleTable() const
Get a particle data table.
Definition: GenBase.h:118
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
AthAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Definition: AthAlgorithm.h:79
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
GenBase::pdt
const HepPDT::ParticleDataTable & pdt() const
Shorter alias to get a particle data table.
Definition: GenBase.h:123
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
GenBase::GenBase
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: GenBase.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
drawLine
void drawLine(std::ostream &os)
Definition: PrintMC.cxx:16
PrintMC::m_trustHepMC
bool m_trustHepMC
Definition: PrintMC.h:31
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
GenBase::particleData
const HepPDT::ParticleData * particleData(int pid) const
Access an element in the particle data table.
Definition: GenBase.h:126
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
GenBase::initialize
virtual StatusCode initialize() override
Definition: GenBase.cxx:17
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
fitman.k
k
Definition: fitman.py:528
ServiceHandle< ICondSvc >
HepMC::signal_process_vertex
GenVertex * signal_process_vertex(const GenEvent *e)
Definition: GenEvent.h:503