ATLAS Offline Software
xAODTruthCnvAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "xAODTruthCnvAlg.h"
5 
7 #include "AthLinks/ElementLink.h"
8 
9 #include "GaudiKernel/MsgStream.h"
10 #include "GaudiKernel/DataSvc.h"
11 #include "GaudiKernel/PhysicalConstants.h"
12 #include "StoreGate/ReadHandle.h"
13 #include "StoreGate/WriteHandle.h"
14 
15 #include "xAODTruth/TruthEvent.h"
18 
22 
26 
27 #include "xAODTruth/TruthVertex.h"
30 
33 
36 
37 #include "AtlasHepMC/GenVertex.h"
38 #include "AtlasHepMC/GenParticle.h"
40 
41 bool isSeparatorGenEvent(const HepMC::GenEvent *genEvt) {
42  // Separator defined by pid==0 and eventNumber==-1 as per
43  // https://twiki.cern.ch/twiki/bin/viewauth/AtlasComputing/PileupDigitization#Arrangement_of_Truth_Information
44  const int pid = HepMC::signal_process_id(genEvt);
45  const int eventNumber = genEvt->event_number();
46  return (pid==0 && eventNumber==-1);
47 }
48 
49 using namespace std;
50 
51 namespace xAODMaker {
52 
53 
54  xAODTruthCnvAlg::xAODTruthCnvAlg( const string& name, ISvcLocator* svcLoc )
55  : AthReentrantAlgorithm( name, svcLoc )
56  , m_metaStore( "MetaDataStore", name )
57  , m_firstBeginRun(true)
58  {
59  // leaving metadata alone for now--to be updated
60  declareProperty( "MetaObjectName", m_metaName = "TruthMetaData" );
61  declareProperty( "MetaDataStore", m_metaStore );
62  }
63 
64 
67  ATH_MSG_FATAL( "Contradictory xAOD truth pile-up setting: all pile-up AND in-time alone requested simultaneously. Check settings." );
68  return StatusCode::FAILURE;
69  }
70 
71  if (m_writeMetaData) {
72  ATH_CHECK( m_meta.initialize (m_metaStore, m_metaName) );
73  }
74 
75  // initialize handles
77 
78  // only if doing full truth
84  if (!m_lheTruthParticleContainerKey.empty()){
86  }
87 
89 
90  ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", name());
91  ATH_CHECK(incSvc.retrieve());
92  incSvc->addListener( this, "BeginRun", 10);
93 
94  ATH_MSG_DEBUG("AODContainerName = " << m_aodContainerKey.key() );
95  ATH_MSG_DEBUG("xAOD TruthEventContainer name = " << m_xaodTruthEventContainerKey.key() );
96  ATH_MSG_DEBUG("xAOD TruthPileupEventContainer name = " << m_xaodTruthPUEventContainerKey.key() );
97  ATH_MSG_DEBUG("xAOD TruthParticleContainer name = " << m_xaodTruthParticleContainerKey.key() );
98  ATH_MSG_DEBUG("xAOD TruthVertexContainer name = " << m_xaodTruthVertexContainerKey.key() );
99  if (!m_lheTruthParticleContainerKey.empty()){
100  ATH_MSG_DEBUG("xAOD TruthLHEParticleContainer name = " << m_lheTruthParticleContainerKey.key() );
101  }
102 
103  if (m_doAllPileUp) ATH_MSG_INFO( "All pile-up truth (including out-of-time) will be written" );
104  if (m_doInTimePileUp) ATH_MSG_INFO( "In-time pile-up truth (but not out-of-time) will be written" );
105  if (!m_doAllPileUp && !m_doInTimePileUp) ATH_MSG_INFO( "No pile-up truth will be written" );
106 
107  return StatusCode::SUCCESS;
108  }
109 
110 
111  StatusCode xAODTruthCnvAlg::execute (const EventContext& ctx) const {
112 
114  ATH_CHECK(truthLinkVec.record(std::make_unique<xAODTruthParticleLinkVector>()));
115 
116  // Retrieve the HepMC truth:
118  // validity check is only really needed for serial running. Remove when MT is only way.
119  if (!mcColl.isValid()) {
120  ATH_MSG_ERROR("Could not retrieve HepMC with key:" << m_aodContainerKey.key());
121  return StatusCode::FAILURE;
122  } else {
123  ATH_MSG_DEBUG( "Retrieved HepMC with key: " << m_aodContainerKey.key() );
124  }
125 
126  // **************************************************************
127  // Create the xAOD containers and their auxiliary stores:
128  // **************************************************************
129  // Signal event
131  ATH_CHECK(xTruthEventContainer.record(std::make_unique<xAOD::TruthEventContainer>(),
132  std::make_unique<xAOD::TruthEventAuxContainer>()));
133  ATH_MSG_DEBUG( "Recorded TruthEventContainer with key: " << m_xaodTruthEventContainerKey.key() );
134 
135  // Pile-up events
136  SG::WriteHandle<xAOD::TruthPileupEventContainer> xTruthPileupEventContainer;
139  ATH_CHECK(xTruthPileupEventContainer.record(std::make_unique<xAOD::TruthPileupEventContainer>(),
140  std::make_unique<xAOD::TruthPileupEventAuxContainer>()));
141  ATH_MSG_DEBUG( "Recorded TruthPileupEventContainer with key: " << m_xaodTruthPUEventContainerKey.key() );
142  }
143 
144  // Particles
146  ATH_CHECK(xTruthParticleContainer.record(std::make_unique<xAOD::TruthParticleContainer>(),
147  std::make_unique<xAOD::TruthParticleAuxContainer>()));
148  ATH_MSG_DEBUG( "Recorded TruthParticleContainer with key: " << m_xaodTruthParticleContainerKey.key() );
149  // Vertices
151  ATH_CHECK(xTruthVertexContainer.record(std::make_unique<xAOD::TruthVertexContainer>(),
152  std::make_unique<xAOD::TruthVertexAuxContainer>()));
153  ATH_MSG_DEBUG( "Recorded TruthVertexContainer with key: " << m_xaodTruthVertexContainerKey.key() );
154 
155  // To keep track of whether we wrote an LHE event already or not
156 #ifdef HEPMC3
157  bool hadLHERecord = false;
158 #endif
159 
160  // ***********************************************************************************
161  // Create the xAOD objects
162  // This consists of three parts:
163  // (1) For each Athena event, loop over the GenEvents and build TruthEvent collections
164  // In principle there can be more than one GenEvent per event
165  // (2) For each GenEvent, loop over the GenParticles. For each GenParticle:
166  // (a) Create a TruthParticle.
167  // (b) Call fillParticle
168  // (c) Add the TruthParticle to the TruthParticle container, and add
169  // an EL to this TruthParticle to the truthParticles in TruthEvent
170  // (call this EL eltp)
171  // (d) For the GenVertex * that's this particle's production vertex,
172  // (i) see if it is in tempMap. If not, add it.
173  // (ii) add a copy of eltp (the EL to this truth particle) to map[gv].second
174  // (e) For the GenVertex * that's this particle's decay vertex,
175  // (i) see if it is in tempMap. If not, add it.
176  // (ii) add a copy of eltp (the EL to this truth particle) to map[gv].first
177  // (3) Iterate over tempMap. For each GenVertex *:
178  // (a) Create a TruthVertex
179  // (b) Call fillVertex
180  // (c) Add the TruthVertex to the TruthTruth container, and add an EL to this TruthVertex
181  // to the truthVertices in TruthEvent. (call this EL eltv)
182  // (d) call tv->setIncomingParticles(mapiter.second.first) <- I think mapiter.second.first is the first of the pair
183  // (e) call tv->setOutgoingParticles(mapiter.second.second)
184  // (f) Iterate through the incomingParticles, and set the decay vertex EL as eltv.
185  // (g) Iterate through the outgoingParticles, and set the incoming vertex EL as eltv.
186  //
187  // Comment lines below follow this recipe
188  // ************************************************************************************
189 
190  // (1) Build TruthEvents
191  ATH_MSG_DEBUG("Number of GenEvents in this Athena event = " << mcColl->size());
192 #ifdef HEPMC3
193  bool newAttributesPresent(false);
194 #endif
195  for (unsigned int cntr = 0; cntr < mcColl->size(); ++cntr) {
196  const HepMC::GenEvent* genEvt = (*mcColl)[cntr];
197  bool isSignalProcess(false);
198  if (cntr==0) {
199  isSignalProcess=true;
200 #ifdef HEPMC3
201  auto bunchCrossingTime = genEvt->attribute<HepMC3::IntAttribute>("BunchCrossingTime");
202  if (bunchCrossingTime) {
203  newAttributesPresent = true;
204  ATH_MSG_VERBOSE("New attributes present.");
205  }
206  else {
207  ATH_MSG_VERBOSE("New attributes missing.");
208  }
209 #else
210  ATH_MSG_VERBOSE("New attributes missing.");
211 #endif
212  }
213  if (cntr>0) {
214  // Handle pile-up events
215  if (!m_doInTimePileUp && !m_doAllPileUp) break;
216  isSignalProcess=false;
217 #ifdef HEPMC3
218  auto bunchCrossingTime = genEvt->attribute<HepMC3::IntAttribute>("BunchCrossingTime");
219  if (bunchCrossingTime) {
220  // New approach based on checking the bunch crossing
221  // time directly.
222  if (m_doInTimePileUp && std::abs(bunchCrossingTime->value()) > 0) {
223  // Skip out-of-time pile-up events
224  continue;
225  }
226  }
227  else {
228  // Old approach based on McEventCollection structure. If
229  // in-time pileup only is requested, loop stops when the
230  // separator GenEvent between out-of-time and in-time is
231  // reached
232  if (m_doInTimePileUp && isSeparatorGenEvent(genEvt)) {
233  if (newAttributesPresent) {
234  // Old structure with new Attributes?! Check all
235  // GenEvents just in case.
236  ATH_MSG_VERBOSE("New-style, but seeing separator GenEvents");
237  continue;
238  }
239  // Old structure - stop at the first separator
240  // GenEvent.
241  break;
242  }
243  }
244 #else
245  // Old approach based on McEventCollection structure. If
246  // in-time pileup only is requested, loop stops when the
247  // separator GenEvent between out-of-time and in-time is
248  // reached
249  if (m_doInTimePileUp && isSeparatorGenEvent(genEvt)) {
250  // Old structure - stop at the first separator
251  // GenEvent.
252  break;
253  }
254 #endif
255  }
256 
257  xAOD::TruthEvent* xTruthEvent = new xAOD::TruthEvent();
258  xAOD::TruthPileupEvent* xTruthPileupEvent = new xAOD::TruthPileupEvent();
259 
260 
261  if (isSignalProcess) {
262  xTruthEventContainer->push_back( xTruthEvent );
263  // Cross-section
264  auto crossSection = genEvt->cross_section();
265 #ifdef HEPMC3
266  xTruthEvent->setCrossSection(crossSection ? (float)crossSection->xsec() : -1);
267  xTruthEvent->setCrossSectionError(crossSection ? (float)crossSection->xsec_err() : -1);
268 #else
269  xTruthEvent->setCrossSection(crossSection ? (float)crossSection->cross_section() : -1);
270  xTruthEvent->setCrossSectionError(crossSection ? (float)crossSection->cross_section_error() : -1);
271 #endif
272 
273  if (m_writeMetaData) {
274  //The mcChannelNumber is used as a unique identifier for which truth meta data belongs to
277  if (evtInfo.isValid()) {
278  mcChannelNumber = evtInfo->mcChannelNumber();
279  if (mcChannelNumber==0) mcChannelNumber = evtInfo->runNumber();
280  }
281  else {
282  ATH_MSG_FATAL("Faied to retrieve EventInfo");
283  return StatusCode::FAILURE;
284  }
285 
286  ATH_CHECK( m_meta.maybeWrite (mcChannelNumber, *genEvt, m_metaFields) );
287  }
288  // Event weights
289  vector<float> weights;
290  for (const double& w : genEvt->weights()) weights.push_back((float)(w));
291  //AV This to be decided. It is always a good idea to have a default weight 1.0.
292  //if (weights.empty()) weights.push_back(1.0);
293  xTruthEvent->setWeights(weights);
294 
295  // Heavy ion info
296  auto const hiInfo = genEvt->heavy_ion();
297  if (hiInfo) {
298 #ifdef HEPMC3
299  /* Please note HepMC3 as well as more recent HePMC2 versions have more Hi parameters */
300  xTruthEvent->setHeavyIonParameter(hiInfo->Ncoll_hard, xAOD::TruthEvent::NCOLLHARD);
301  xTruthEvent->setHeavyIonParameter(hiInfo->Npart_proj, xAOD::TruthEvent::NPARTPROJ);
302  xTruthEvent->setHeavyIonParameter(hiInfo->Npart_targ, xAOD::TruthEvent::NPARTTARG);
303  xTruthEvent->setHeavyIonParameter(hiInfo->Ncoll, xAOD::TruthEvent::NCOLL);
304  xTruthEvent->setHeavyIonParameter(hiInfo->spectator_neutrons, xAOD::TruthEvent::SPECTATORNEUTRONS);
305  xTruthEvent->setHeavyIonParameter(hiInfo->spectator_protons, xAOD::TruthEvent::SPECTATORPROTONS);
306  xTruthEvent->setHeavyIonParameter(hiInfo->N_Nwounded_collisions, xAOD::TruthEvent::NNWOUNDEDCOLLISIONS);
307  xTruthEvent->setHeavyIonParameter(hiInfo->Nwounded_N_collisions, xAOD::TruthEvent::NWOUNDEDNCOLLISIONS);
308  xTruthEvent->setHeavyIonParameter(hiInfo->Nwounded_Nwounded_collisions, xAOD::TruthEvent::NWOUNDEDNWOUNDEDCOLLISIONS);
309  xTruthEvent->setHeavyIonParameter((float)hiInfo->impact_parameter, xAOD::TruthEvent::IMPACTPARAMETER);
310  xTruthEvent->setHeavyIonParameter((float)hiInfo->event_plane_angle, xAOD::TruthEvent::EVENTPLANEANGLE);
311  xTruthEvent->setHeavyIonParameter((float)hiInfo->eccentricity, xAOD::TruthEvent::ECCENTRICITY);
312  xTruthEvent->setHeavyIonParameter((float)hiInfo->sigma_inel_NN, xAOD::TruthEvent::SIGMAINELNN);
313 #else
314  xTruthEvent->setHeavyIonParameter(hiInfo->Ncoll_hard(), xAOD::TruthEvent::NCOLLHARD);
315  xTruthEvent->setHeavyIonParameter(hiInfo->Npart_proj(), xAOD::TruthEvent::NPARTPROJ);
316  xTruthEvent->setHeavyIonParameter(hiInfo->Npart_targ(), xAOD::TruthEvent::NPARTTARG);
317  xTruthEvent->setHeavyIonParameter(hiInfo->Ncoll(), xAOD::TruthEvent::NCOLL);
318  xTruthEvent->setHeavyIonParameter(hiInfo->spectator_neutrons(), xAOD::TruthEvent::SPECTATORNEUTRONS);
319  xTruthEvent->setHeavyIonParameter(hiInfo->spectator_protons(), xAOD::TruthEvent::SPECTATORPROTONS);
320  xTruthEvent->setHeavyIonParameter(hiInfo->N_Nwounded_collisions(), xAOD::TruthEvent::NNWOUNDEDCOLLISIONS);
321  xTruthEvent->setHeavyIonParameter(hiInfo->Nwounded_N_collisions(), xAOD::TruthEvent::NWOUNDEDNCOLLISIONS);
322  xTruthEvent->setHeavyIonParameter(hiInfo->Nwounded_Nwounded_collisions(), xAOD::TruthEvent::NWOUNDEDNWOUNDEDCOLLISIONS);
323  xTruthEvent->setHeavyIonParameter(hiInfo->impact_parameter(), xAOD::TruthEvent::IMPACTPARAMETER);
324  xTruthEvent->setHeavyIonParameter(hiInfo->event_plane_angle(), xAOD::TruthEvent::EVENTPLANEANGLE);
325  xTruthEvent->setHeavyIonParameter(hiInfo->eccentricity(), xAOD::TruthEvent::ECCENTRICITY);
326  xTruthEvent->setHeavyIonParameter(hiInfo->sigma_inel_NN(), xAOD::TruthEvent::SIGMAINELNN);
327 #endif
328  // This doesn't yet exist in our version of HepMC
329  // xTruthEvent->setHeavyIonParameter(hiInfo->centrality(),xAOD::TruthEvent::CENTRALITY);
330  }
331 
332  // Parton density info
333  // This will exist 99% of the time, except for e.g. cosmic or particle gun simulation
334  auto const pdfInfo = genEvt->pdf_info();
335  if (pdfInfo) {
336 #ifdef HEPMC3
337  xTruthEvent->setPdfInfoParameter(pdfInfo->parton_id[0], xAOD::TruthEvent::PDGID1);
338  xTruthEvent->setPdfInfoParameter(pdfInfo->parton_id[1], xAOD::TruthEvent::PDGID2);
339  xTruthEvent->setPdfInfoParameter(pdfInfo->pdf_id[1], xAOD::TruthEvent::PDFID1);
340  xTruthEvent->setPdfInfoParameter(pdfInfo->pdf_id[1], xAOD::TruthEvent::PDFID2);
341 
342  xTruthEvent->setPdfInfoParameter((float)pdfInfo->x[0], xAOD::TruthEvent::X1);
343  xTruthEvent->setPdfInfoParameter((float)pdfInfo->x[1], xAOD::TruthEvent::X2);
344  xTruthEvent->setPdfInfoParameter((float)pdfInfo->scale, xAOD::TruthEvent::Q);
345  xTruthEvent->setPdfInfoParameter((float)pdfInfo->xf[0], xAOD::TruthEvent::XF1);
346  xTruthEvent->setPdfInfoParameter((float)pdfInfo->xf[1], xAOD::TruthEvent::XF2);
347 #else
348  xTruthEvent->setPdfInfoParameter(pdfInfo->id1(), xAOD::TruthEvent::PDGID1);
349  xTruthEvent->setPdfInfoParameter(pdfInfo->id2(), xAOD::TruthEvent::PDGID2);
350  xTruthEvent->setPdfInfoParameter(pdfInfo->pdf_id1(), xAOD::TruthEvent::PDFID1);
351  xTruthEvent->setPdfInfoParameter(pdfInfo->pdf_id2(), xAOD::TruthEvent::PDFID2);
352 
353  xTruthEvent->setPdfInfoParameter((float)pdfInfo->x1(), xAOD::TruthEvent::X1);
354  xTruthEvent->setPdfInfoParameter((float)pdfInfo->x2(), xAOD::TruthEvent::X2);
355  xTruthEvent->setPdfInfoParameter((float)pdfInfo->scalePDF(), xAOD::TruthEvent::Q);
356  xTruthEvent->setPdfInfoParameter((float)pdfInfo->pdf1(), xAOD::TruthEvent::XF1);
357  xTruthEvent->setPdfInfoParameter((float)pdfInfo->pdf2(), xAOD::TruthEvent::XF2);
358 #endif
359  }
360 
361  // Handle LHE particles, only supported for HEPMC3
362 #ifdef HEPMC3
363  auto lhe_record_attribute = genEvt->attribute<HepMC::ShortEventAttribute>("LHERecord");
364 
365  if (lhe_record_attribute && !hadLHERecord && !m_lheTruthParticleContainerKey.empty()){
366  hadLHERecord=true;
367  // The event had an LHE record, so let's record it. This will only happen once per event.
369  ATH_CHECK(xTruthLHEParticleContainer.record(std::make_unique<xAOD::TruthParticleContainer>(),
370  std::make_unique<xAOD::TruthParticleAuxContainer>()));
371  ATH_MSG_DEBUG( "Recorded TruthLHEParticleContainer with key: " << m_lheTruthParticleContainerKey.key() );
372  // The LHE record is stored in a struct with old-style LHE format, so we have to re-encode it
373  for (int nPart=0;nPart<lhe_record_attribute->NUP;++nPart) {
374  // Create TruthParticle
375  xAOD::TruthParticle* xTruthParticle = new xAOD::TruthParticle();
376  // Put particle into container;
377  xTruthLHEParticleContainer->push_back( xTruthParticle );
378  // Copy LHE info into the new particle; good description is in https://arxiv.org/abs/hep-ph/0609017
379  xTruthParticle->setPdgId( lhe_record_attribute->IDUP[nPart] );
380  xTruthParticle->setBarcode( nPart+1 );
381  xTruthParticle->setStatus( lhe_record_attribute->ISTUP[nPart] );
382  xTruthParticle->setPx( lhe_record_attribute->PUP[nPart][0] );
383  xTruthParticle->setPy( lhe_record_attribute->PUP[nPart][1] );
384  xTruthParticle->setPz( lhe_record_attribute->PUP[nPart][2] );
385  xTruthParticle->setE( lhe_record_attribute->PUP[nPart][3] );
386  xTruthParticle->setM( lhe_record_attribute->PUP[nPart][4] );
387  } // End of loop over particles
388  } // End of if we found the LHE record attribute
389  else if (hadLHERecord){
390  ATH_MSG_WARNING("Truth record appeared to have two LHE records; this should not be possible");
391  }
392 #else
393  if (!m_lheTruthParticleContainerKey.empty()){
394  ATH_MSG_WARNING("HEPMC2 does not support LHE truth record storage. Skipping.");
395  }
396 #endif
397  }else{//not isSignalProcess
398  xTruthPileupEventContainer->push_back( xTruthPileupEvent );
399  }
400 
401  // (2) Build particles and vertices
402  // Map for building associations between particles and vertices
403  // The pair in the map is the (incomingParticles . outgoingParticles) of the given vertex
404  // If signal process vertex is a disconnected vertex (no incoming/outgoing particles), add it manually
405  VertexMap vertexMap;
406  VertexMap::iterator mapItr;
407  vector<HepMC::ConstGenVertexPtr> vertices;
408 
409  // Check signal process vertex
410  // If this is a disconnected vertex, add it manually or won't be added from the loop over particles below.
411  auto disconnectedSignalProcessVtx = HepMC::signal_process_vertex(genEvt); // Get the signal process vertex
412  if (disconnectedSignalProcessVtx) {
413  if (disconnectedSignalProcessVtx->particles_in_size() == 0 && disconnectedSignalProcessVtx->particles_out_size() == 0 ) {
414  //This is a disconnected vertex, add it manually
415  vertices.push_back (disconnectedSignalProcessVtx);
416  }
417  } else {
418  ATH_MSG_WARNING("Signal process vertex pointer not valid in HepMC Collection for GenEvent #" << cntr << " / " << mcColl->size());
419  }
420 
421  // Get the beam particles
422  pair<HepMC::ConstGenParticlePtr,HepMC::ConstGenParticlePtr> beamParticles;
423  bool genEvt_valid_beam_particles=false;
424 #ifdef HEPMC3
425  auto beamParticles_vec = genEvt->beams();
426  genEvt_valid_beam_particles=(beamParticles_vec.size()>1);
427  if (genEvt_valid_beam_particles){beamParticles.first=beamParticles_vec[0]; beamParticles.second=beamParticles_vec[1]; }
428  // We want to process particles in barcode order.
429  auto bcmapatt = genEvt->attribute<HepMC::GenEventBarcodes>("barcodes"); // FIXME barcode-based
430  if (!bcmapatt) ATH_MSG_ERROR("TruthParticleCnvTool.cxx: Event does not contain barcodes attribute");
431  std::map<int, HepMC3::ConstGenParticlePtr> bcmap = bcmapatt->barcode_to_particle_map();
432  xTruthParticleContainer->reserve(bcmap.size());
433  for (const auto &[genPartBarcode,part]: bcmap) {
434 #else
435  genEvt_valid_beam_particles=genEvt->valid_beam_particles();
436  if ( genEvt_valid_beam_particles ) beamParticles = genEvt->beam_particles();
437  xTruthParticleContainer->reserve(genEvt->particles_size());
438  for (auto part: *genEvt) {
439  int genPartBarcode = HepMC::barcode(part); // FIXME barcode-based
440 #endif
441  // (a) create TruthParticle
442  xAOD::TruthParticle* xTruthParticle = new xAOD::TruthParticle();
443  // (b) Put particle into container;
444  xTruthParticleContainer->push_back( xTruthParticle );
445  fillParticle(xTruthParticle, part); // (c) Copy HepMC info into the new particle
446  // (d) Build Event<->Particle element link
447  const ElementLink<xAOD::TruthParticleContainer> eltp(*xTruthParticleContainer, xTruthParticleContainer->size()-1);
448  if (isSignalProcess) xTruthEvent->addTruthParticleLink(eltp);
449  if (!isSignalProcess) xTruthPileupEvent->addTruthParticleLink(eltp);
450 
451  // Create link between HepMC and xAOD truth
452  if (isSignalProcess) truthLinkVec->push_back(new xAODTruthParticleLink(HepMcParticleLink(genPartBarcode,0,HepMcParticleLink::IS_POSITION, HepMcParticleLink::IS_BARCODE), eltp)); // FIXME barcode-based
453  if (!isSignalProcess) truthLinkVec->push_back(new xAODTruthParticleLink(HepMcParticleLink(genPartBarcode,genEvt->event_number(), HepMcParticleLink::IS_EVENTNUM, HepMcParticleLink::IS_BARCODE), eltp)); // FIXME barcode-based
454 
455  // Is this one of the beam particles?
456  if (genEvt_valid_beam_particles) {
457  if (isSignalProcess) {
458  if (part == beamParticles.first) xTruthEvent->setBeamParticle1Link(eltp);
459  if (part == beamParticles.second) xTruthEvent->setBeamParticle2Link(eltp);
460  }
461  }
462  // (e) Particle's production vertex
463  auto productionVertex = part->production_vertex();
464  // Skip the dummy vertex that HepMC3 adds
465  // Can distinguish it from real vertices because it has
466  // a null event pointer.
467  if (productionVertex && productionVertex->parent_event() != nullptr) {
468  VertexParticles& parts = vertexMap[productionVertex];
469  if (parts.incoming.empty() && parts.outgoing.empty())
470  vertices.push_back (productionVertex);
471  parts.outgoingEL.push_back(eltp);
472  parts.outgoing.push_back(xTruthParticle);
473  }
474  //
475  // else maybe want to keep track that this is the production vertex
476  //
477  // (f) Particle's decay vertex
478  auto decayVertex = part->end_vertex();
479  if (decayVertex) {
480  VertexParticles& parts = vertexMap[decayVertex];
481  if (parts.incoming.empty() && parts.outgoing.empty())
482  vertices.push_back (decayVertex);
483  parts.incomingEL.push_back(eltp);
484  parts.incoming.push_back(xTruthParticle);
485  }
486 
487  } // end of loop over particles
488 
489  // (3) Loop over the map
490  auto signalProcessVtx = HepMC::signal_process_vertex(genEvt); // Get the signal process vertex
491  xTruthVertexContainer->reserve(vertices.size());
492  for (const auto& vertex : vertices) {
493  const auto& parts = vertexMap[vertex];
494  // (a) create TruthVertex
495  xAOD::TruthVertex* xTruthVertex = new xAOD::TruthVertex();
496  // (b) Put particle into container (so has store)
497  xTruthVertexContainer->push_back( xTruthVertex );
498  fillVertex(xTruthVertex, vertex); // (c) Copy HepMC info into the new vertex
499  // (d) Build Event<->Vertex element link
500  ElementLink<xAOD::TruthVertexContainer> eltv(*xTruthVertexContainer, xTruthVertexContainer->size()-1);
501  // Mark if this is the signal process vertex
502  if (vertex == signalProcessVtx && isSignalProcess) xTruthEvent->setSignalProcessVertexLink(eltv);
503  if (isSignalProcess) xTruthEvent->addTruthVertexLink(eltv);
504  if (!isSignalProcess) xTruthPileupEvent->addTruthVertexLink(eltv);
505  // (e) Assign incoming particles to the vertex, from the map
506  xTruthVertex->setIncomingParticleLinks( parts.incomingEL );
507  // (f) Assign outgoing particles to the vertex, from the map
508  xTruthVertex->setOutgoingParticleLinks( parts.outgoingEL );
509  // (g) Set Particle<->Vertex links for incoming particles
510  for (xAOD::TruthParticle* p : parts.incoming) p->setDecayVtxLink(eltv);
511  // (h) Set Particle<->Vertex links for incoming particles
512  for (xAOD::TruthParticle* p : parts.outgoing) p->setProdVtxLink(eltv);
513  } //end of loop over vertices
514 
515  // Delete the event that wasn't used
516  if (isSignalProcess) delete xTruthPileupEvent;
517  if (!isSignalProcess) delete xTruthEvent;
518 
519  } // end of loop over McEventCollection
520 
521 
522  std::stable_sort(truthLinkVec->begin(), truthLinkVec->end(), SortTruthParticleLink());
523  ATH_MSG_VERBOSE("Summarizing truth link size: " << truthLinkVec->size() );
524 
525  return StatusCode::SUCCESS;
526  }
527 
528  void xAODTruthCnvAlg::handle(const Incident& incident) {
529  if (m_firstBeginRun && incident.type()==IncidentType::BeginRun) {
530  m_firstBeginRun = false;
531  ServiceHandle<StoreGateSvc> inputStore("StoreGateSvc/InputMetaDataStore", name());
532  if(inputStore.retrieve().isFailure()) {
533  ATH_MSG_ERROR("Failed to retrieve Input Metadata Store");
534  return;
535  }
536  const IOVMetaDataContainer* tagInfo{nullptr};
537  if(inputStore->retrieve(tagInfo,"/TagInfo").isFailure()) {
538  ATH_MSG_WARNING("Failed to retrieve /TagInfo metadata from the input store");
539  return;
540  }
541  if(tagInfo->payloadContainer()->size()>0) {
542  CondAttrListCollection* tagInfoPayload = tagInfo->payloadContainer()->at(0);
543  if(tagInfoPayload->size()>0) {
544  const CondAttrListCollection::AttributeList& al = tagInfoPayload->attributeList(0);
545  if (al.exists("lhefGenerator")){
546  m_metaFields.lhefGenerator = al["lhefGenerator"].data<std::string>();
547  }
548 
549  if (al.exists("generators")){
550  m_metaFields.generators = al["generators"].data<std::string>();
551  }
552 
553  if (al.exists("evgenProcess")){
554  m_metaFields.evgenProcess = al["evgenProcess"].data<std::string>();
555  }
556 
557  if (al.exists("evgenTune")){
558  m_metaFields.evgenTune = al["evgenTune"].data<std::string>();
559  }
560 
561  if (al.exists("hardPDF")){
562  m_metaFields.hardPDF = al["hardPDF"].data<std::string>();
563  }
564 
565  if (al.exists("softPDF")){
566  m_metaFields.softPDF = al["softPDF"].data<std::string>();
567  }
568  }
569  }
570  else {
571  ATH_MSG_WARNING("Empty Tag Info metadata!");
572  }
573  }
574  }
575 
576 
577  // A helper to set up a TruthVertex (without filling the ELs)
579  // id was renamed to status in HepMC3.
580  tv->setId(HepMC::old_vertex_status_from_new(HepMC::status(gv))); // For now convert the status back to the old scheme
581  tv->setBarcode(HepMC::barcode(gv)); // FIXME barcode-based
582  tv->setX(gv->position().x());
583  tv->setY(gv->position().y());
584  tv->setZ(gv->position().z());
585  tv->setT(gv->position().t());
586  }
587 
588 
589  // A helper to set up a TruthParticle (without filling the ELs)
591  tp->setPdgId(gp->pdg_id());
592  tp->setBarcode(HepMC::barcode(gp)); // FIXME barcode-based
593  tp->setStatus(HepMC::old_particle_status_from_new(HepMC::status(gp))); // For now convert the status back to the old scheme
594 
595  auto pol = HepMC::polarization(gp);
596  if (pol.is_defined()) {
597  tp->setPolarizationParameter(pol.theta(), xAOD::TruthParticle::polarizationTheta);
598  tp->setPolarizationParameter(pol.phi(), xAOD::TruthParticle::polarizationPhi);
599  }
600 
601  tp->setM(gp->generated_mass());
602  tp->setPx(gp->momentum().px());
603  tp->setPy(gp->momentum().py());
604  tp->setPz(gp->momentum().pz());
605  tp->setE(gp->momentum().e());
606  }
607 
608 
609  StatusCode
611  const std::string& metaName)
612  {
613  ATH_CHECK( metaStore.retrieve() );
614 
615  auto md = std::make_unique<xAOD::TruthMetaDataContainer>();
616  m_tmd = md.get();
617 
618  auto aux = std::make_unique<xAOD::TruthMetaDataAuxContainer>();
619  md->setStore( aux.get() );
620 
621  // Record the trigger configuration metadata into it:
622  CHECK( metaStore->record( std::move (aux), metaName + "Aux." ) );
623  CHECK( metaStore->record( std::move (md), metaName ) );
624  return StatusCode::SUCCESS;
625  }
626 
627 
628  StatusCode
630  const HepMC::GenEvent& genEvt,
631  const MetadataFields& metaFields)
632  {
633  // This bit needs to be serialized.
634  lock_t lock (m_mutex);
635 
636  //Inserting in a (unordered_)set returns an <iterator, boolean> pair, where the boolean
637  //is used to check if the key already exists (returns false in the case it exists)
638  if( m_existingMetaDataChan.insert(mcChannelNumber).second ) {
639  m_tmd->push_back (std::make_unique <xAOD::TruthMetaData>());
640  xAOD::TruthMetaData* md = m_tmd->back();
641 
642 #ifdef HEPMC3
645  std::vector<std::string> orderedWeightNameVec;
646  if (!genEvt.run_info()) {
647  for (size_t i=0; i<genEvt.weights().size();i++) orderedWeightNameVec.push_back(std::to_string(i));
648  } else {
649  if (!genEvt.run_info()->weight_names().empty()) {
650  orderedWeightNameVec = genEvt.weight_names();
651  } else {
652  //AV This to be decided. It is always a good idea to have a default weight 1.0.
653  //orderedWeightNameVec.push_back("0");
654  }
655  }
656  md->setWeightNames(orderedWeightNameVec);
657 #else
658  // FIXME: class member protection violation here.
659  // This appears to be because WeightContainer has no public methods
660  // to get information about the weight names.
661  const auto& weightNameMap = genEvt.weights().m_names;
662  std::vector<std::string> orderedWeightNameVec;
663  orderedWeightNameVec.reserve( weightNameMap.size() );
664  for (const auto& entry: weightNameMap) {
665  orderedWeightNameVec.push_back(entry.first);
666  }
667 
668  //The map from the HepMC record pairs the weight names with a corresponding index,
669  //it is not guaranteed that the indices are ascending when iterating over the map
670  std::sort(orderedWeightNameVec.begin(), orderedWeightNameVec.end(),
671  [&](const std::string& i, const std::string& j){return weightNameMap.at(i) < weightNameMap.at(j);});
672 
674  md->setWeightNames( orderedWeightNameVec );
675 #endif
676 
677  if(!metaFields.lhefGenerator.empty()) {
678  md->setLhefGenerator(metaFields.lhefGenerator);
679  }
680  if(!metaFields.generators.empty()) {
681  md->setGenerators(metaFields.generators);
682  }
683  if(!metaFields.evgenProcess.empty()) {
684  md->setEvgenProcess(metaFields.evgenProcess);
685  }
686  if(!metaFields.evgenTune.empty()) {
687  md->setEvgenTune(metaFields.evgenTune);
688  }
689  if(!metaFields.hardPDF.empty()) {
690  md->setHardPDF(metaFields.hardPDF);
691  }
692  if(!metaFields.softPDF.empty()) {
693  md->setSoftPDF(metaFields.softPDF);
694  }
695  }
696 
697  return StatusCode::SUCCESS;
698  }
699 
700 
701 
702 } // namespace xAODMaker
DataVector::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::TruthParticle_v1::setStatus
void setStatus(int value)
Set status code.
HepMC::old_vertex_status_from_new
int old_vertex_status_from_new(const int newStatus)
Get vertex status in the old scheme from the status in the new scheme.
Definition: MagicNumbers.h:421
xAOD::TruthEvent_v1::X2
@ X2
[float]
Definition: TruthEvent_v1.h:80
xAOD::TruthEvent_v1::setCrossSection
void setCrossSection(float value)
Set the cross-section.
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
xAODMaker::xAODTruthCnvAlg::m_xaodTruthParticleContainerKey
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_xaodTruthParticleContainerKey
Definition: xAODTruthCnvAlg.h:138
xAOD::TruthEvent_v1::XF2
@ XF2
[float]
Definition: TruthEvent_v1.h:86
xAOD::TruthEvent_v1::setSignalProcessVertexLink
void setSignalProcessVertexLink(const TruthVertexLink_t &link)
Set pointer to a vertex representing the primary beam interaction point.
IOVMetaDataContainer
This class is a container for conditions data. It is intended to be used to store conditions data fro...
Definition: IOVMetaDataContainer.h:37
xAOD::TruthEvent_v1::ECCENTRICITY
@ ECCENTRICITY
[float]
Definition: TruthEvent_v1.h:142
HepMC::polarization
Polarization polarization(const T &a)
Definition: Polarization.h:47
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAODMaker::xAODTruthCnvAlg::m_lheTruthParticleContainerKey
SG::WriteHandleKey< xAOD::TruthParticleContainer > m_lheTruthParticleContainerKey
Definition: xAODTruthCnvAlg.h:144
xAOD::TruthEvent_v1::setWeights
void setWeights(const std::vector< float > &weights)
Set the event weights.
xAOD::TruthEvent_v1::NPARTPROJ
@ NPARTPROJ
[int]
Definition: TruthEvent_v1.h:132
xAODMaker::xAODTruthCnvAlg::m_xaodTruthEventContainerKey
SG::WriteHandleKey< xAOD::TruthEventContainer > m_xaodTruthEventContainerKey
The key for the output xAOD truth containers.
Definition: xAODTruthCnvAlg.h:134
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle< McEventCollection >
xAOD::TruthParticle_v1::setE
void setE(float value)
Set the energy of the particle.
Definition: TruthParticle_v1.cxx:235
AthCommonDataStore< AthCommonMsg< Gaudi::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:635
xAOD::TruthParticle_v1::setBarcode
void setBarcode(int value)
Set barcode.
TruthVertexContainer.h
TruthParticleContainer.h
xAOD::TruthMetaData_v1::setSoftPDF
void setSoftPDF(const std::string &value)
GenVertex.h
xAOD::TruthEvent
TruthEvent_v1 TruthEvent
Typedef to implementation.
Definition: TruthEvent.h:17
xAOD::TruthEvent_v1::PDFID2
@ PDFID2
[int]
Definition: TruthEvent_v1.h:78
xAOD::TruthEvent_v1::setBeamParticle2Link
void setBeamParticle2Link(const TruthParticleLink_t &pcl2)
Set one incoming beam particle.
xAODMaker::xAODTruthCnvAlg::MetadataFields::lhefGenerator
std::string lhefGenerator
Definition: xAODTruthCnvAlg.h:84
TruthPileupEvent.h
xAOD::TruthEvent_v1::setHeavyIonParameter
bool setHeavyIonParameter(int value, HIParam parameter)
Set an integer HI parameter.
Definition: TruthEvent_v1.cxx:162
xAOD::TruthEvent_v1::IMPACTPARAMETER
@ IMPACTPARAMETER
[float]
Definition: TruthEvent_v1.h:140
xAOD::TruthVertex_v1::setT
void setT(float value)
Set the vertex time.
ParticleTest.tp
tp
Definition: ParticleTest.py:25
xAOD::TruthPileupEvent_v1
Class describing a pile-up truth event in the MC record.
Definition: TruthPileupEvent_v1.h:23
xAOD::TruthParticle_v1::setPx
void setPx(float value)
Set the x component of the particle's momentum.
xAOD::TruthVertex_v1::setIncomingParticleLinks
void setIncomingParticleLinks(const TPLinks_t &links)
Set all the incoming particles.
xAODMaker::xAODTruthCnvAlg::MetadataFields
Definition: xAODTruthCnvAlg.h:83
xAOD::TruthEvent_v1::NWOUNDEDNWOUNDEDCOLLISIONS
@ NWOUNDEDNWOUNDEDCOLLISIONS
[int]
Definition: TruthEvent_v1.h:139
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
xAODMaker
Definition: StoreGateSvc.h:72
xAODMaker::xAODTruthCnvAlg::m_metaName
std::string m_metaName
SG key and name for meta data.
Definition: xAODTruthCnvAlg.h:159
xAODMaker::xAODTruthCnvAlg::MetaDataWriter::lock_t
std::lock_guard< std::mutex > lock_t
Definition: xAODTruthCnvAlg.h:106
xAOD::TruthVertex_v1::setY
void setY(float value)
Set the y displacement of the vertex.
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
TruthPileupEventContainer.h
xAOD::mcChannelNumber
mcChannelNumber
Definition: EventInfo_v1.cxx:197
xAOD::TruthVertex_v1::setOutgoingParticleLinks
void setOutgoingParticleLinks(const TPLinks_t &links)
Set all the outgoing particles.
GenParticle.h
std::stable_sort
void stable_sort(std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, std::reverse_iterator< DataModel_detail::iterator< DVL > > end, Compare comp)
Specialization of stable_sort for DataVector/List.
Definition: DVL_algorithms.h:711
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
xAODMaker::xAODTruthCnvAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition: xAODTruthCnvAlg.cxx:111
xAODMaker::xAODTruthCnvAlg::fillParticle
static void fillParticle(xAOD::TruthParticle *tp, const HepMC::ConstGenParticlePtr &gp)
Definition: xAODTruthCnvAlg.cxx:590
TruthMetaData.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
xAOD::TruthEventBase_v1::addTruthParticleLink
void addTruthParticleLink(const TruthParticleLink_t &plink)
Add one truth particle.
Definition: TruthEventBase_v1.cxx:68
xAOD::TruthMetaData_v1::setWeightNames
void setWeightNames(const std::vector< std::string > &value)
xAODMaker::xAODTruthCnvAlg::m_doInTimePileUp
Gaudi::Property< bool > m_doInTimePileUp
Definition: xAODTruthCnvAlg.h:149
TruthParticleAuxContainer.h
xAOD::EventInfo_v1::mcChannelNumber
uint32_t mcChannelNumber() const
The MC generator's channel number.
xAODMaker::xAODTruthCnvAlg::MetadataFields::generators
std::string generators
Definition: xAODTruthCnvAlg.h:85
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
WriteHandle.h
Handle class for recording to StoreGate.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
xAOD::TruthParticle_v1::setM
void setM(float value)
Also store the mass.
Definition: TruthParticle_v1.cxx:241
xAOD::TruthEvent_v1::NPARTTARG
@ NPARTTARG
[int]
Definition: TruthEvent_v1.h:133
xAODMaker::xAODTruthCnvAlg::fillVertex
static void fillVertex(xAOD::TruthVertex *tv, const HepMC::ConstGenVertexPtr &gv)
These functions do not set up ELs, just the other variables.
Definition: xAODTruthCnvAlg.cxx:578
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::TruthEvent_v1::NNWOUNDEDCOLLISIONS
@ NNWOUNDEDCOLLISIONS
[int]
Definition: TruthEvent_v1.h:137
HepMC::old_particle_status_from_new
int old_particle_status_from_new(const int newStatus)
Get particle status in the old scheme from the status in the new scheme.
Definition: MagicNumbers.h:412
xAODMaker::xAODTruthCnvAlg::m_firstBeginRun
bool m_firstBeginRun
Tag Info.
Definition: xAODTruthCnvAlg.h:168
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::TruthMetaData_v1::setMcChannelNumber
void setMcChannelNumber(uint32_t value)
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
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
TruthMetaDataAuxContainer.h
xAODMaker::xAODTruthCnvAlg::MetaDataWriter::maybeWrite
StatusCode maybeWrite(uint32_t mcChannelNumber, const HepMC::GenEvent &genEvt, const MetadataFields &metaFields)
Definition: xAODTruthCnvAlg.cxx:629
xAODMaker::xAODTruthCnvAlg::m_xaodTruthPUEventContainerKey
SG::WriteHandleKey< xAOD::TruthPileupEventContainer > m_xaodTruthPUEventContainerKey
Definition: xAODTruthCnvAlg.h:136
xAOD::TruthEvent_v1::setPdfInfoParameter
bool setPdfInfoParameter(int value, PdfParam parameter)
Set an integer PDF info parameter.
Definition: TruthEvent_v1.cxx:75
xAOD::TruthEvent_v1::SIGMAINELNN
@ SIGMAINELNN
[float]
Definition: TruthEvent_v1.h:143
xAODMaker::xAODTruthCnvAlg::MetadataFields::evgenTune
std::string evgenTune
Definition: xAODTruthCnvAlg.h:87
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition: Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
xAODMaker::xAODTruthCnvAlg::MetadataFields::softPDF
std::string softPDF
Definition: xAODTruthCnvAlg.h:89
ParticleGun_EoverP_Config.pid
pid
Definition: ParticleGun_EoverP_Config.py:62
xAOD::TruthParticle_v1::setPy
void setPy(float value)
Set the y component of the particle's momentum.
xAODMaker::xAODTruthCnvAlg::handle
virtual void handle(const Incident &incident) override
Incident handler.
Definition: xAODTruthCnvAlg.cxx:528
xAOD::TruthEvent_v1
Class describing a signal truth event in the MC record.
Definition: TruthEvent_v1.h:35
xAODMaker::xAODTruthCnvAlg::m_aodContainerKey
SG::ReadHandleKey< McEventCollection > m_aodContainerKey
The key of the input AOD truth container.
Definition: xAODTruthCnvAlg.h:130
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TruthPileupEvent
TruthPileupEvent_v1 TruthPileupEvent
Typedef to implementation.
Definition: TruthPileupEvent.h:15
xAOD::TruthEvent_v1::setCrossSectionError
void setCrossSectionError(float value)
Set the cross-section error.
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
CondAttrListCollection::attributeList
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
Definition: CondAttrListCollection.h:401
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
xAOD::TruthVertex
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition: TruthVertex.h:15
xAODMaker::xAODTruthCnvAlg::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition: xAODTruthCnvAlg.cxx:65
xAOD::TruthEvent_v1::SPECTATORNEUTRONS
@ SPECTATORNEUTRONS
[int]
Definition: TruthEvent_v1.h:135
xAOD::TruthEvent_v1::XF1
@ XF1
[float]
Definition: TruthEvent_v1.h:85
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAODMaker::xAODTruthCnvAlg::MetadataFields::evgenProcess
std::string evgenProcess
Definition: xAODTruthCnvAlg.h:86
xAODMaker::xAODTruthCnvAlg::m_xaodTruthVertexContainerKey
SG::WriteHandleKey< xAOD::TruthVertexContainer > m_xaodTruthVertexContainerKey
Definition: xAODTruthCnvAlg.h:140
xAOD::TruthMetaData_v1::setGenerators
void setGenerators(const std::string &value)
xAODMaker::xAODTruthCnvAlg::m_metaFields
MetadataFields m_metaFields
Definition: xAODTruthCnvAlg.h:169
TruthVertex.h
IOVMetaDataContainer.h
This class is a container for conditions data. It is intended to be used to store conditions data fro...
TruthVertexAuxContainer.h
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
xAOD::TruthMetaData_v1
Class describing meta data for truth records.
Definition: TruthMetaData_v1.h:28
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
xAOD::TruthParticle_v1::setPdgId
void setPdgId(int pid)
Set PDG ID code.
xAODMaker::xAODTruthCnvAlg::m_evtInfo
SG::ReadHandleKey< xAOD::EventInfo > m_evtInfo
Event Info.
Definition: xAODTruthCnvAlg.h:165
xAOD::TruthEvent_v1::EVENTPLANEANGLE
@ EVENTPLANEANGLE
[float]
Definition: TruthEvent_v1.h:141
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MagicNumbers.h
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
xAOD::TruthEvent_v1::PDGID1
@ PDGID1
[int]
Definition: TruthEvent_v1.h:75
xAODMaker::xAODTruthCnvAlg::MetadataFields::hardPDF
std::string hardPDF
Definition: xAODTruthCnvAlg.h:88
errorcheck.h
Helpers for checking error return status codes and reporting errors.
xAOD::crossSection
crossSection
Definition: TruthEvent_v1.cxx:33
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAODMaker::xAODTruthCnvAlg::VertexParticles
Type for tracking particles connected to a single vertex.
Definition: xAODTruthCnvAlg.h:116
weights
Definition: herwig7_interface.h:38
xAOD::TruthEvent_v1::SPECTATORPROTONS
@ SPECTATORPROTONS
[int]
Definition: TruthEvent_v1.h:136
xAOD::TruthVertex_v1::setId
void setId(int value)
Obsolete function Set vertex ID code HepMC2 id == HepMC3 status, i.e.
xAOD::TruthMetaData_v1::setHardPDF
void setHardPDF(const std::string &value)
xAOD::TruthEvent_v1::NCOLL
@ NCOLL
[int]
Definition: TruthEvent_v1.h:134
xAODTruthCnvAlg.h
xAODMaker::xAODTruthCnvAlg::m_truthLinkContainerKey
SG::WriteHandleKey< xAODTruthParticleLinkVector > m_truthLinkContainerKey
Definition: xAODTruthCnvAlg.h:142
xAODMaker::xAODTruthCnvAlg::VertexMap
std::map< HepMC::ConstGenVertexPtr, VertexParticles > VertexMap
Convenience handle for a map of vtx ptrs -> connected particles.
Definition: xAODTruthCnvAlg.h:123
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
xAODMaker::xAODTruthCnvAlg::m_writeMetaData
Gaudi::Property< bool > m_writeMetaData
option to disable writing of metadata (e.g. if running a filter on xAOD in generators)
Definition: xAODTruthCnvAlg.h:162
xAOD::TruthEvent_v1::X1
@ X1
[float]
Definition: TruthEvent_v1.h:79
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::TruthVertex_v1::setZ
void setZ(float value)
Set the vertex's longitudinal distance from the origin.
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::TruthVertex_v1::setBarcode
void setBarcode(int value)
Set barcode.
xAOD::TruthEvent_v1::PDGID2
@ PDGID2
[int]
Definition: TruthEvent_v1.h:76
xAOD::TruthParticle_v1::polarizationTheta
@ polarizationTheta
Polarization in ( )
Definition: TruthParticle_v1.h:319
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
xAODMaker::xAODTruthCnvAlg::MetaDataWriter::initialize
StatusCode initialize(ServiceHandle< StoreGateSvc > &metaStore, const std::string &metaName)
Definition: xAODTruthCnvAlg.cxx:610
xAOD::TruthParticle_v1::polarizationPhi
@ polarizationPhi
Polarization in ( )
Definition: TruthParticle_v1.h:318
xAOD::TruthParticle_v1::setPz
void setPz(float value)
Set the z component of the particle's momentum.
TruthEventAuxContainer.h
xAODMaker::xAODTruthCnvAlg::m_metaStore
ServiceHandle< StoreGateSvc > m_metaStore
Connection to the metadata store.
Definition: xAODTruthCnvAlg.h:157
doL1CaloHVCorrections.parts
parts
Definition: doL1CaloHVCorrections.py:334
TruthPileupEventAuxContainer.h
xAODMaker::xAODTruthCnvAlg::m_doAllPileUp
Gaudi::Property< bool > m_doAllPileUp
Pile-up options.
Definition: xAODTruthCnvAlg.h:148
HepMC::ConstGenVertexPtr
const HepMC::GenVertex * ConstGenVertexPtr
Definition: GenVertex.h:60
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
ReadHandle.h
Handle class for reading from StoreGate.
xAOD::TruthMetaData_v1::setLhefGenerator
void setLhefGenerator(const std::string &value)
xAOD::TruthMetaData_v1::setEvgenTune
void setEvgenTune(const std::string &value)
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
HepMC::status
int status(const T &p)
Definition: MagicNumbers.h:138
TruthParticle.h
TruthEventContainer.h
isSeparatorGenEvent
bool isSeparatorGenEvent(const HepMC::GenEvent *genEvt)
Definition: xAODTruthCnvAlg.cxx:41
xAOD::TruthEvent_v1::Q
@ Q
[float]
Definition: TruthEvent_v1.h:82
xAOD::TruthEvent_v1::PDFID1
@ PDFID1
[int]
Definition: TruthEvent_v1.h:77
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
xAOD::TruthEventBase_v1::addTruthVertexLink
void addTruthVertexLink(const TruthVertexLink_t &vlink)
Add one truth vertex.
Definition: TruthEventBase_v1.cxx:129
xAOD::TruthMetaData_v1::setEvgenProcess
void setEvgenProcess(const std::string &value)
xAOD::TruthEvent_v1::NWOUNDEDNCOLLISIONS
@ NWOUNDEDNCOLLISIONS
[int]
Definition: TruthEvent_v1.h:138
TruthEvent.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
xAOD::TruthEvent_v1::setBeamParticle1Link
void setBeamParticle1Link(const TruthParticleLink_t &pcl1)
Set one incoming beam particle.
xAOD::TruthVertex_v1::setX
void setX(float value)
Set the x displacement of the vertex.
ServiceHandle< IIncidentSvc >
xAOD::TruthEvent_v1::NCOLLHARD
@ NCOLLHARD
[int]
Definition: TruthEvent_v1.h:131
HepMC::signal_process_vertex
GenVertex * signal_process_vertex(const GenEvent *e)
Definition: GenEvent.h:625