ATLAS Offline Software
Loading...
Searching...
No Matches
McEventCollectionCnv_p6.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
6
7// McEventCollectionCnv_p6.cxx
8// Implementation file for class McEventCollectionCnv_p6
9// Author: S.Binet<binet@cern.ch>
11
12// STL includes
13#include <utility>
14#include <cmath>
15#include <cfloat> // for DBL_EPSILON
16
17// GeneratorObjectsTPCnv includes
19#include "HepMcDataPool.h"
20#include "HepMC3AccessStrings.h"
23#include "GaudiKernel/ThreadLocalContext.h"
25
26using namespace GeneratorObjectsTPCnv;
27
28static const std::set<std::string> attributes_to_ignore {
29 "barcodes","barcode",
30 "flows","flow1","flow2","flow3",
31 "theta", "phi",
32 "mpi",
33 "signal_process_id",
34 "signal_vertex_id",
35 "filterWeight", "filterHT", "filterMET",
36 "event_scale","alphaQCD","alphaQED","random_states","weights",
37 "GenCrossSection","GenPdfInfo","GenHeavyIon"};
38
40// Constructors
42
44 Base_t( ),
45 m_isPileup(false),m_hepMCWeightSvc("HepMCWeightSvc","McEventCollectionCnv_p6")
46{}
47
49 Base_t( rhs ),
50 m_isPileup(false),m_hepMCWeightSvc("HepMCWeightSvc","McEventCollectionCnv_p6")
51{}
52
55{
56 if ( this != &rhs ) {
57 Base_t::operator=( rhs );
59 }
60 return *this;
61}
62
64// Destructor
66
68= default;
69
70
72 McEventCollection* transObj,
73 MsgStream& msg )
74{
75 const EventContext& ctx = Gaudi::Hive::currentContext();
76
77 msg << MSG::DEBUG << "Loading McEventCollection from persistent state..."
78 << endmsg;
79
80 // elements are managed by DataPool
81 if (!m_isPileup) {
82 transObj->clear(SG::VIEW_ELEMENTS);
83 }
84 HepMC::DataPool datapools;
85 const unsigned int nVertices = persObj->m_genVertices.size();
86 datapools.vtx.prepareToAdd(nVertices);
87 const unsigned int nParts = persObj->m_genParticles.size();
88 datapools.part.prepareToAdd(nParts);
89 const unsigned int nEvts = persObj->m_genEvents.size();
90 datapools.evt.prepareToAdd(nEvts);
91
92 transObj->reserve( nEvts );
93 for ( std::vector<GenEvent_p6>::const_iterator
94 itr = persObj->m_genEvents.begin(),
95 itrEnd = persObj->m_genEvents.end();
96 itr != itrEnd;
97 ++itr ) {
98 const GenEvent_p6& persEvt = *itr;
99 HepMC::GenEvent * genEvt(nullptr);
100 if(m_isPileup) {
101 genEvt = new HepMC::GenEvent();
102 } else {
103 genEvt = datapools.getGenEvent();
104 }
105#ifdef HEPMC3
106 genEvt->add_attribute (barcodesStr, std::make_shared<HepMC::GenEventBarcodes>());
107 for (unsigned int i = 0; i < persEvt.m_e_attribute_id.size(); ++i) {
108 if (attributes_to_ignore.count(persEvt.m_e_attribute_name[i])) continue;
109 genEvt->add_attribute(persEvt.m_e_attribute_name[i], std::make_shared<HepMC3::StringAttribute>(persEvt.m_e_attribute_string[i]), persEvt.m_e_attribute_id[i]);
110 }
112
113 genEvt->add_attribute(signalProcessIdStr, std::make_shared<HepMC3::IntAttribute>(persEvt.m_signalProcessId));
114 genEvt->set_event_number(persEvt.m_eventNbr);
115 genEvt->add_attribute(mpiStr, std::make_shared<HepMC3::IntAttribute>(persEvt.m_mpi));
116 genEvt->add_attribute(eventScaleStr, std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_eventScale));
117 genEvt->add_attribute(alphaQcdStr, std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQCD));
118 genEvt->add_attribute(alphaQedStr, std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_alphaQED));
119 genEvt->add_attribute(filterWeightStr, std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_filterWeight));
120 genEvt->add_attribute(filterHtStr, std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_filterHT));
121 genEvt->add_attribute(filterMetStr, std::make_shared<HepMC3::DoubleAttribute>(persEvt.m_filterMET));
122 genEvt->weights()= persEvt.m_weights;
123 genEvt->add_attribute(randomStatesStr, std::make_shared<HepMC3::VectorLongIntAttribute>(persEvt.m_randomStates));
124
125 genEvt->set_units(static_cast<HepMC3::Units::MomentumUnit>(persEvt.m_momentumUnit),
126 static_cast<HepMC3::Units::LengthUnit>(persEvt.m_lengthUnit));
127
128 //restore weight names from the dedicated svc (which was keeping them in metadata for efficiency)
129 if(!genEvt->run_info()) {
130 HepMC3::GenRunInfoData ri_read;
131 ri_read.weight_names = m_hepMCWeightSvc->weightNameVec(ctx);
132 ri_read.tool_name = std::vector<std::string>();
133 ri_read.tool_version = std::vector<std::string>();
134 ri_read.tool_description = std::vector<std::string>();
135 ri_read.attribute_name = persEvt.m_r_attribute_name;
136 ri_read.attribute_string = persEvt.m_r_attribute_string;
137 auto ri = std::make_shared<HepMC3::GenRunInfo>();
138 ri->read_data(ri_read);
139 genEvt->set_run_info(std::move(ri));
140 }
141 // cross-section restore
142
143 if (!persEvt.m_crossSection.empty()) {
144 auto cs = std::make_shared<HepMC3::GenCrossSection>();
145 const std::vector<double>& xsection = persEvt.m_crossSection;
146 genEvt->set_cross_section(cs);
147 if( static_cast<bool>(xsection[0]) )
148 cs->set_cross_section(xsection[2],xsection[1]);
149 else
150 cs->set_cross_section(-1.0, -1.0);
151 }
152
153 // heavyIon restore
154 if (!persEvt.m_heavyIon.empty()) {
155 auto hi = std::make_shared<HepMC3::GenHeavyIon>();
156 const std::vector<float>& hIon = persEvt.m_heavyIon;
157 //AV NOTE THE ORDER
158 hi->set(
159 static_cast<int>(hIon[12]), // Ncoll_hard
160 static_cast<int>(hIon[11]), // Npart_proj
161 static_cast<int>(hIon[10]), // Npart_targ
162 static_cast<int>(hIon[9]), // Ncoll
163 static_cast<int>(hIon[8]), // spectator_neutrons
164 static_cast<int>(hIon[7]), // spectator_protons
165 static_cast<int>(hIon[6]), // N_Nwounded_collisions
166 static_cast<int>(hIon[5]), // Nwounded_N_collisions
167 static_cast<int>(hIon[4]), // Nwounded_Nwounded_collisions
168 hIon[3], // impact_parameter
169 hIon[2], // event_plane_angle
170 hIon[1], // eccentricity
171 hIon[0] ); // sigma_inel_NN
172 genEvt->set_heavy_ion(std::move(hi));
173 }
174
175
176
177 // pdfinfo restore
178 if (!persEvt.m_pdfinfo.empty())
179 {
180 const std::vector<double>& pdf = persEvt.m_pdfinfo;
181 HepMC3::GenPdfInfoPtr pi = std::make_shared<HepMC3::GenPdfInfo>();
182 pi->set(static_cast<int>(pdf[8]), // id1
183 static_cast<int>(pdf[7]), // id2
184 pdf[4], // x1
185 pdf[3], // x2
186 pdf[2], // scalePDF
187 pdf[1], // pdf1
188 pdf[0], // pdf2
189 static_cast<int>(pdf[6]), // pdf_id1
190 static_cast<int>(pdf[5]));// pdf_id2
191 genEvt->set_pdf_info(std::move(pi));
192 }
193 transObj->push_back( genEvt );
194
195 // create a temporary map associating the barcode of an end-vtx to its
196 // particle.
197 // As not all particles are stable (d'oh!) we take 50% of the number of
198 // particles as an initial size of the hash-map (to prevent re-hash)
199 ParticlesMap_t partToEndVtx( (persEvt.m_particlesEnd - persEvt.m_particlesBegin)/2 );
200 // This is faster than the HepMC::barcode_to_vertex
201 std::map<int, HepMC::GenVertexPtr> brc_to_vertex;
202
203 // create the vertices
204 const unsigned int endVtx = persEvt.m_verticesEnd;
205 for ( unsigned int iVtx = persEvt.m_verticesBegin; iVtx != endVtx; ++iVtx ) {
206 auto vtx = createGenVertex( *persObj, persObj->m_genVertices[iVtx], partToEndVtx, datapools, genEvt );
207 brc_to_vertex[persObj->m_genVertices[iVtx].m_barcode] = std::move(vtx);
208 } //> end loop over vertices
209
210 // set the signal process vertex
211 const int sigProcVtx = persEvt.m_signalProcessVtx;
212 if ( sigProcVtx != 0 && brc_to_vertex.count(sigProcVtx) ) {
213 HepMC::set_signal_process_vertex(genEvt, brc_to_vertex[sigProcVtx] );
214 }
215
216 // connect particles to their end vertices
217 for (auto & p : partToEndVtx) {
218 if ( brc_to_vertex.count(p.second) ) {
219 auto decayVtx = brc_to_vertex[p.second];
220 decayVtx->add_particle_in( p.first );
221 } else {
222 msg << MSG::ERROR << "GenParticle points to null end vertex !!" << endmsg;
223 }
224 }
225 // set the beam particles
226 const int beamPart1 = persEvt.m_beamParticle1;
227 const int beamPart2 = persEvt.m_beamParticle2;
228 if ( beamPart1 != 0 && beamPart2 != 0 ) {
229 genEvt->set_beam_particles(HepMC::barcode_to_particle(genEvt, beamPart1),
230 HepMC::barcode_to_particle(genEvt, beamPart2));
231 }
232
233#else
234 genEvt->m_signal_process_id = persEvt.m_signalProcessId;
235 genEvt->m_event_number = persEvt.m_eventNbr;
236 genEvt->m_mpi = persEvt.m_mpi;
237 genEvt->m_event_scale = persEvt.m_eventScale;
238 genEvt->m_alphaQCD = persEvt.m_alphaQCD;
239 genEvt->m_alphaQED = persEvt.m_alphaQED;
240 genEvt->m_signal_process_vertex = 0;
241 genEvt->m_beam_particle_1 = 0;
242 genEvt->m_beam_particle_2 = 0;
243 genEvt->m_weights = persEvt.m_weights;
244 genEvt->m_random_states = persEvt.m_randomStates;
245 genEvt->m_vertex_barcodes.clear();
246 genEvt->m_particle_barcodes.clear();
247 genEvt->m_momentum_unit = static_cast<HepMC::Units::MomentumUnit>(persEvt.m_momentumUnit);
248 genEvt->m_position_unit = static_cast<HepMC::Units::LengthUnit>(persEvt.m_lengthUnit);
249
250 //restore weight names from the dedicated svc (which was keeping them in metadata for efficiency)
251 genEvt->m_weights.m_names = m_hepMCWeightSvc->weightNames(ctx);
252
253 // cross-section restore
254 if( genEvt->m_cross_section )
255 delete genEvt->m_cross_section;
256 genEvt->m_cross_section = 0;
257
258 if (!persEvt.m_crossSection.empty()) {
259 genEvt->m_cross_section = new HepMC::GenCrossSection();
260 const std::vector<double>& xsection = persEvt.m_crossSection;
261 if( static_cast<bool>(xsection[0]) )
262 genEvt->m_cross_section->set_cross_section(xsection[2],xsection[1]);
263 }
264
265 // heavyIon restore
266 if(genEvt->m_heavy_ion )
267 delete genEvt->m_heavy_ion;
268 genEvt->m_heavy_ion = 0;
269 if (!persEvt.m_heavyIon.empty()) {
270 const std::vector<float>& hIon = persEvt.m_heavyIon;
271 genEvt->m_heavy_ion = new HepMC::HeavyIon
272 (
273 static_cast<int>(hIon[12]), // Ncoll_hard
274 static_cast<int>(hIon[11]), // Npart_proj
275 static_cast<int>(hIon[10]), // Npart_targ
276 static_cast<int>(hIon[9]), // Ncoll
277 static_cast<int>(hIon[8]), // spectator_neutrons
278 static_cast<int>(hIon[7]), // spectator_protons
279 static_cast<int>(hIon[6]), // N_Nwounded_collisions
280 static_cast<int>(hIon[5]), // Nwounded_N_collisions
281 static_cast<int>(hIon[4]), // Nwounded_Nwounded_collisions
282 hIon[3], // impact_parameter
283 hIon[2], // event_plane_angle
284 hIon[1], // eccentricity
285 hIon[0] ); // sigma_inel_NN
286 }
287
288
289
290 // pdfinfo restore
291 if(genEvt->m_pdf_info)
292 delete genEvt->m_pdf_info;
293 genEvt->m_pdf_info = 0;
294 if (!persEvt.m_pdfinfo.empty()) {
295 const std::vector<double>& pdf = persEvt.m_pdfinfo;
296 genEvt->m_pdf_info = new HepMC::PdfInfo
297 (
298 static_cast<int>(pdf[8]), // id1
299 static_cast<int>(pdf[7]), // id2
300 pdf[4], // x1
301 pdf[3], // x2
302 pdf[2], // scalePDF
303 pdf[1], // pdf1
304 pdf[0], // pdf2
305 static_cast<int>(pdf[6]), // pdf_id1
306 static_cast<int>(pdf[5]) // pdf_id2
307 );
308 }
309
310 transObj->push_back( genEvt );
311
312 // create a temporary map associating the barcode of an end-vtx to its
313 // particle.
314 // As not all particles are stable (d'oh!) we take 50% of the number of
315 // particles as an initial size of the hash-map (to prevent re-hash)
316 ParticlesMap_t partToEndVtx( (persEvt.m_particlesEnd-
317 persEvt.m_particlesBegin)/2 );
318
319 // create the vertices
320 const unsigned int endVtx = persEvt.m_verticesEnd;
321 for ( unsigned int iVtx= persEvt.m_verticesBegin; iVtx != endVtx; ++iVtx ) {
322 genEvt->add_vertex( createGenVertex( *persObj,
323 persObj->m_genVertices[iVtx],
324 partToEndVtx,
325 datapools ) );
326 } //> end loop over vertices
327
328 // set the signal process vertex
329 const int sigProcVtx = persEvt.m_signalProcessVtx;
330 if ( sigProcVtx != 0 ) {
331 genEvt->set_signal_process_vertex( genEvt->barcode_to_vertex( sigProcVtx ) );
332 }
333
334 // connect particles to their end vertices
335 for ( ParticlesMap_t::iterator
336 p = partToEndVtx.begin(),
337 endItr = partToEndVtx.end();
338 p != endItr;
339 ++p ) {
340 auto decayVtx = HepMC::barcode_to_vertex(genEvt, p->second );
341 if ( decayVtx ) {
342 decayVtx->add_particle_in( p->first );
343 } else {
344 msg << MSG::ERROR
345 << "GenParticle points to null end vertex !!"
346 << endmsg;
347 }
348 }
349
350 // set the beam particles
351 const int beamPart1 = persEvt.m_beamParticle1;
352 const int beamPart2 = persEvt.m_beamParticle2;
353 if ( beamPart1 != 0 && beamPart2 !=0 ) {
354 genEvt->set_beam_particles(genEvt->barcode_to_particle(beamPart1),
355 genEvt->barcode_to_particle(beamPart2));
356 }
357
358#endif
359
360
361 } //> end loop over m_genEvents
362
363 msg << MSG::DEBUG << "Loaded McEventCollection from persistent state [OK]"
364 << endmsg;
365}
366
368 McEventCollection_p6* persObj,
369 MsgStream& msg )
370{
371 const EventContext& ctx = Gaudi::Hive::currentContext();
372
373 msg << MSG::DEBUG << "Creating persistent state of McEventCollection..."
374 << endmsg;
375 persObj->m_genEvents.reserve( transObj->size() );
376
377 const std::pair<unsigned int,unsigned int> stats = nbrParticlesAndVertices( transObj );
378 persObj->m_genParticles.reserve( stats.first );
379 persObj->m_genVertices.reserve ( stats.second );
380
381 const McEventCollection::const_iterator itrEnd = transObj->end();
382 for ( McEventCollection::const_iterator itr = transObj->begin();
383 itr != itrEnd;
384 ++itr ) {
385 const unsigned int nPersVtx = persObj->m_genVertices.size();
386 const unsigned int nPersParts = persObj->m_genParticles.size();
387 const HepMC::GenEvent* genEvt = *itr;
388#ifdef HEPMC3
389 //save the weight names to metadata via the HepMCWeightSvc
390 auto ri = genEvt->run_info();
391 HepMC3::GenRunInfoData ri_data;
392 if (ri) {
393 ri->write_data(ri_data);
394 if (!ri_data.weight_names.empty()) {
395 m_hepMCWeightSvc->setWeightNames( names_to_name_index_map(ri_data.weight_names), ctx ).ignore();
396 } else {
397 //AV : This to be decided if one would like to have default names.
398 //std::vector<std::string> names{"0"};
399 //m_hepMCWeightSvc->setWeightNames( names_to_name_index_map(names), ctx );
400 }
401 }
402
403 auto A_mpi=genEvt->attribute<HepMC3::IntAttribute>(mpiStr);
404 auto A_signal_process_id=genEvt->attribute<HepMC3::IntAttribute>(signalProcessIdStr);
405 auto A_event_scale=genEvt->attribute<HepMC3::DoubleAttribute>(eventScaleStr);
406 auto A_alphaQCD=genEvt->attribute<HepMC3::DoubleAttribute>(alphaQcdStr);
407 auto A_alphaQED=genEvt->attribute<HepMC3::DoubleAttribute>(alphaQedStr);
408 auto A_filterWeight=genEvt->attribute<HepMC3::DoubleAttribute>(filterWeightStr);
409 auto A_filterHT=genEvt->attribute<HepMC3::DoubleAttribute>(filterHtStr);
410 auto A_filterMET=genEvt->attribute<HepMC3::DoubleAttribute>(filterMetStr);
411 auto signal_process_vertex = HepMC::signal_process_vertex(genEvt);
412
413 // If signal vertex not found on the vertices, look on the event (Sherpa)
414 if (!signal_process_vertex) {
415 auto event_spv = genEvt->attribute<HepMC3::IntAttribute>("signal_process_vertex");
416
417 // If the attribute exists, get the vertex
418 if (event_spv) signal_process_vertex = genEvt->vertices().at(-event_spv->value()-1);
419 }
420
421 auto A_random_states=genEvt->attribute<HepMC3::VectorLongIntAttribute>("random_states");
422 auto beams=genEvt->beams();
423 persObj->m_genEvents.
424 emplace_back(A_signal_process_id?(A_signal_process_id->value()):-1,
425 genEvt->event_number(),
426 A_mpi?(A_mpi->value()):-1,
427 A_event_scale?(A_event_scale->value()):0.0,
428 A_alphaQCD?(A_alphaQCD->value()):0.0,
429 A_alphaQED?(A_alphaQED->value()):0.0,
430 A_filterWeight?(A_filterWeight->value()):1.0,
431 A_filterHT?(A_filterHT->value()):-13.,
432 A_filterMET?(A_filterMET->value()):-13.0,
433 signal_process_vertex?HepMC::barcode(signal_process_vertex):0,
434 !beams.empty()?HepMC::barcode(beams[0]):0,
435 beams.size()>1?HepMC::barcode(beams[1]):0,
436 genEvt->weights(),
437 A_random_states?(A_random_states->value()):std::vector<long>(),
438 std::vector<double>(), // cross section
439 std::vector<float>(), // heavyion
440 std::vector<double>(), // pdf info
441 genEvt->momentum_unit(),
442 genEvt->length_unit(),
443 nPersVtx,
444 nPersVtx + genEvt->vertices().size(),
445 nPersParts,
446 nPersParts + genEvt->particles().size() );
447 {
448 GenEvent_p6& persEvt = persObj->m_genEvents.back();
449 std::map< std::string, std::map<int, std::shared_ptr<HepMC3::Attribute> > > e_atts = genEvt->attributes();
450 persEvt.m_e_attribute_name.clear();
451 persEvt.m_e_attribute_id.clear();
452 persEvt.m_e_attribute_string.clear();
453 for (auto& attmap: e_atts) {
454 if (attributes_to_ignore.count(attmap.first)) continue;
455 if (attmap.first == "ShadowParticle") continue;
456 if (attmap.first == "ShadowParticleId") continue;
457 for (auto& att: attmap.second) {
458 persEvt.m_e_attribute_name.push_back(attmap.first);
459 persEvt.m_e_attribute_id.push_back(att.first);
460 std::string st;
461 att.second->to_string(st);
464 persEvt.m_e_attribute_string.push_back(std::move(st));
465 }
466 }
467 persEvt.m_r_attribute_name.clear();
468 persEvt.m_r_attribute_string.clear();
469 if (ri) {
470 persEvt.m_r_attribute_string = std::move(ri_data.attribute_string);
471 persEvt.m_r_attribute_name = std::move(ri_data.attribute_name);
472 /*** This is for the future
473 persEvt.m_r_tool_name = ri_data.tool_name;
474 persEvt.m_r_tool_version = ri_data.tool_version;
475 persEvt.m_r_tool_description = ri_data.tool_description;
476 */
477 }
478 //Actually, with this piece there is no need to treat the CS and HI separately.
479 }
480 //HepMC::GenCrossSection encoding
481 if (genEvt->cross_section()) {
482 auto cs=genEvt->cross_section();
483 GenEvent_p6& persEvt = persObj->m_genEvents.back();
484 std::vector<double>& crossSection = persEvt.m_crossSection;
485 crossSection.resize(3);
486 crossSection[2] = cs->xsec();
487 crossSection[1] = cs->xsec_err();
488 crossSection[0] = static_cast<double>(cs->is_valid());
491 if (crossSection[2] < 0) {
492 crossSection[2] = 0.0;
493 if (crossSection[1] < 0) {
494 crossSection[1] = 0.0;
495 }
496 crossSection[0] = 0.0;
497 }
498
499 }
500
501 //HepMC::HeavyIon encoding
502 if (genEvt->heavy_ion()) {
503 auto hi=genEvt->heavy_ion();
504 GenEvent_p6& persEvt = persObj->m_genEvents.back();
505 std::vector<float>& heavyIon = persEvt.m_heavyIon;
506 heavyIon.resize(13);
507 heavyIon[12] = static_cast<float>(hi->Ncoll_hard);
508 heavyIon[11] = static_cast<float>(hi->Npart_proj);
509 heavyIon[10] = static_cast<float>(hi->Npart_targ);
510 heavyIon[9] = static_cast<float>(hi->Ncoll);
511 heavyIon[8] = static_cast<float>(hi->spectator_neutrons);
512 heavyIon[7] = static_cast<float>(hi->spectator_protons);
513 heavyIon[6] = static_cast<float>(hi->N_Nwounded_collisions);
514 heavyIon[5] = static_cast<float>(hi->Nwounded_N_collisions);
515 heavyIon[4] = static_cast<float>(hi->Nwounded_Nwounded_collisions);
516 heavyIon[3] = hi->impact_parameter;
517 heavyIon[2] = hi->event_plane_angle;
518 heavyIon[1] = hi->eccentricity;
519 heavyIon[0] = hi->sigma_inel_NN;
520 }
521
522 //PdfInfo encoding
523 if (genEvt->pdf_info()) {
524 auto pi=genEvt->pdf_info();
525 GenEvent_p6& persEvt = persObj->m_genEvents.back();
526 std::vector<double>& pdfinfo = persEvt.m_pdfinfo;
527 pdfinfo.resize(9);
528 pdfinfo[8] = static_cast<double>(pi->parton_id[0]);
529 pdfinfo[7] = static_cast<double>(pi->parton_id[1]);
530 pdfinfo[6] = static_cast<double>(pi->pdf_id[0]);
531 pdfinfo[5] = static_cast<double>(pi->pdf_id[1]);
532 pdfinfo[4] = pi->x[0];
533 pdfinfo[3] = pi->x[1];
534 pdfinfo[2] = pi->scale;
535 pdfinfo[1] = pi->xf[0];
536 pdfinfo[0] = pi->xf[1];
537 }
538
539 // create vertices
540 for (const auto& v: genEvt->vertices()) {
541 writeGenVertex( v, *persObj );
542 }
543#else
544 const int signalProcessVtx = genEvt->m_signal_process_vertex
545 ? genEvt->m_signal_process_vertex->barcode()
546 : 0;
547 const int beamParticle1Barcode = genEvt->m_beam_particle_1
548 ? genEvt->m_beam_particle_1->barcode()
549 : 0;
550 const int beamParticle2Barcode = genEvt->m_beam_particle_2
551 ? genEvt->m_beam_particle_2->barcode()
552 : 0;
553
554 //save the weight names to metadata via the HepMCWeightSvc
555 m_hepMCWeightSvc->setWeightNames( genEvt->m_weights.m_names, ctx ).ignore();
556
557
558 persObj->m_genEvents.
559 push_back( GenEvent_p6( genEvt->m_signal_process_id,
560 genEvt->m_event_number,
561 genEvt->mpi(), // number of multi particle interactions
562 genEvt->m_event_scale,
563 genEvt->m_alphaQCD,
564 genEvt->m_alphaQED,
565 1, // dummy value as this does not exist in HepMC2::GenEvent
566 signalProcessVtx,
567 beamParticle1Barcode, // barcodes of beam particles
568 beamParticle2Barcode,
569 genEvt->m_weights.m_weights,
570 genEvt->m_random_states,
571 std::vector<double>(), // cross section
572 std::vector<float>(), // heavyion
573 std::vector<double>(), // pdf info
574 genEvt->m_momentum_unit,
575 genEvt->m_position_unit,
576 nPersVtx,
577 nPersVtx + genEvt->vertices_size(),
578 nPersParts,
579 nPersParts + genEvt->particles_size() ) );
580 //HepMC::GenCrossSection encoding
581 if (genEvt->m_cross_section) {
582 GenEvent_p6& persEvt = persObj->m_genEvents.back();
583 std::vector<double>& crossSection = persEvt.m_crossSection;
584 crossSection.resize(3);
585 crossSection[2] = genEvt->m_cross_section->m_cross_section;
586 crossSection[1] = genEvt->m_cross_section->m_cross_section_error;
587 crossSection[0] = static_cast<double>(genEvt->m_cross_section->m_is_set);
588 }
589
590 //HepMC::HeavyIon encoding
591 if (genEvt->m_heavy_ion) {
592 GenEvent_p6& persEvt = persObj->m_genEvents.back();
593 std::vector<float>& heavyIon = persEvt.m_heavyIon;
594 heavyIon.resize(13);
595 heavyIon[12] = static_cast<float>(genEvt->m_heavy_ion->m_Ncoll_hard);
596 heavyIon[11] = static_cast<float>(genEvt->m_heavy_ion->m_Npart_proj);
597 heavyIon[10] = static_cast<float>(genEvt->m_heavy_ion->m_Npart_targ);
598 heavyIon[9] = static_cast<float>(genEvt->m_heavy_ion->m_Ncoll);
599 heavyIon[8] = static_cast<float>(genEvt->m_heavy_ion->m_spectator_neutrons);
600 heavyIon[7] = static_cast<float>(genEvt->m_heavy_ion->m_spectator_protons);
601 heavyIon[6] = static_cast<float>(genEvt->m_heavy_ion->m_N_Nwounded_collisions);
602 heavyIon[5] = static_cast<float>(genEvt->m_heavy_ion->m_Nwounded_N_collisions);
603 heavyIon[4] = static_cast<float>(genEvt->m_heavy_ion->m_Nwounded_Nwounded_collisions);
604 heavyIon[3] = genEvt->m_heavy_ion->m_impact_parameter;
605 heavyIon[2] = genEvt->m_heavy_ion->m_event_plane_angle;
606 heavyIon[1] = genEvt->m_heavy_ion->m_eccentricity;
607 heavyIon[0] = genEvt->m_heavy_ion->m_sigma_inel_NN;
608 }
609
610 //PdfInfo encoding
611 if (genEvt->m_pdf_info) {
612 GenEvent_p6& persEvt = persObj->m_genEvents.back();
613 std::vector<double>& pdfinfo = persEvt.m_pdfinfo;
614 pdfinfo.resize(9);
615 pdfinfo[8] = static_cast<double>(genEvt->m_pdf_info->m_id1);
616 pdfinfo[7] = static_cast<double>(genEvt->m_pdf_info->m_id2);
617 pdfinfo[6] = static_cast<double>(genEvt->m_pdf_info->m_pdf_id1);
618 pdfinfo[5] = static_cast<double>(genEvt->m_pdf_info->m_pdf_id2);
619 pdfinfo[4] = genEvt->m_pdf_info->m_x1;
620 pdfinfo[3] = genEvt->m_pdf_info->m_x2;
621 pdfinfo[2] = genEvt->m_pdf_info->m_scalePDF;
622 pdfinfo[1] = genEvt->m_pdf_info->m_pdf1;
623 pdfinfo[0] = genEvt->m_pdf_info->m_pdf2;
624 }
625
626 // create vertices
627 const HepMC::GenEvent::vertex_const_iterator endVtx=genEvt->vertices_end();
628 for ( HepMC::GenEvent::vertex_const_iterator i = genEvt->vertices_begin();
629 i != endVtx;
630 ++i ) {
631 writeGenVertex( **i, *persObj );
632 }
633#endif
634
635 } //> end loop over GenEvents
636
637 msg << MSG::DEBUG << "Created persistent state of HepMC::GenEvent [OK]" << endmsg;
638}
639
640
643 const GenVertex_p6& persVtx,
644 ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools
645 ,HepMC::GenEvent* parent
646 ) const
647{
648 HepMC::GenVertexPtr vtx(nullptr);
649 if(m_isPileup) {
651 } else {
652 vtx = datapools.getGenVertex();
653 }
654 if (parent ) parent->add_vertex(vtx);
655#ifdef HEPMC3
656 vtx->set_position(HepMC::FourVector( persVtx.m_x , persVtx.m_y , persVtx.m_z ,persVtx.m_t ));
657 //AV ID cannot be assigned in HepMC3. And its meaning in HepMC2 is not clear.
658 vtx->set_status(HepMC::new_vertex_status_from_old(persVtx.m_id, persVtx.m_barcode)); // UPDATED STATUS VALUE TO NEW SCHEME
659 // cast from std::vector<float> to std::vector<double>
660 std::vector<double> weights( persVtx.m_weights.begin(), persVtx.m_weights.end() );
661 vtx->add_attribute("weights",std::make_shared<HepMC3::VectorDoubleAttribute>(weights));
662 HepMC::suggest_barcode (vtx, persVtx.m_barcode);
663 // handle the in-going (orphans) particles
664 const unsigned int nPartsIn = persVtx.m_particlesIn.size();
665 for ( unsigned int i = 0; i != nPartsIn; ++i ) {
666 createGenParticle( persEvt.m_genParticles[persVtx.m_particlesIn[i]], partToEndVtx, datapools, vtx, false );
667 }
668
669 // now handle the out-going particles
670 const unsigned int nPartsOut = persVtx.m_particlesOut.size();
671 for ( unsigned int i = 0; i != nPartsOut; ++i ) {
672 createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]], partToEndVtx, datapools, vtx );
673 }
674#else
675 vtx->m_position.setX( persVtx.m_x );
676 vtx->m_position.setY( persVtx.m_y );
677 vtx->m_position.setZ( persVtx.m_z );
678 vtx->m_position.setT( persVtx.m_t );
679 vtx->m_particles_in.clear();
680 vtx->m_particles_out.clear();
681 vtx->m_id = HepMC::new_vertex_status_from_old(persVtx.m_id, persVtx.m_barcode); // UPDATED STATUS VALUE TO NEW SCHEME
682 vtx->m_weights.m_weights.reserve( persVtx.m_weights.size() );
683 vtx->m_weights.m_weights.assign ( persVtx.m_weights.begin(),
684 persVtx.m_weights.end() );
685 vtx->m_event = 0;
686 vtx->m_barcode = persVtx.m_barcode;
687
688 // handle the in-going (orphans) particles
689 const unsigned int nPartsIn = persVtx.m_particlesIn.size();
690 for ( unsigned int i = 0; i != nPartsIn; ++i ) {
692 partToEndVtx,
693 datapools );
694 }
695
696 // now handle the out-going particles
697 const unsigned int nPartsOut = persVtx.m_particlesOut.size();
698 for ( unsigned int i = 0; i != nPartsOut; ++i ) {
699 vtx->add_particle_out( createGenParticle( persEvt.m_genParticles[persVtx.m_particlesOut[i]],
700 partToEndVtx,
701 datapools ) );
702 }
703#endif
704
705 return vtx;
706}
707
710 ParticlesMap_t& partToEndVtx, HepMC::DataPool& datapools ,const HepMC::GenVertexPtr& parent, bool add_to_output ) const
711{
712 HepMC::GenParticlePtr p(nullptr);
713 if (m_isPileup) {
715 } else {
716 p = datapools.getGenParticle();
717 }
718 if (parent) add_to_output?parent->add_particle_out(p):parent->add_particle_in(p);
719#ifdef HEPMC3
720 p->set_pdg_id( persPart.m_pdgId);
721 p->set_status(HepMC::new_particle_status_from_old(persPart.m_status, persPart.m_barcode)); // UPDATED STATUS VALUE TO NEW SCHEME
722 p->add_attribute("phi",std::make_shared<HepMC3::DoubleAttribute>(persPart.m_phiPolarization));
723 p->add_attribute("theta",std::make_shared<HepMC3::DoubleAttribute>(persPart.m_thetaPolarization));
724 HepMC::suggest_barcode (p, persPart.m_barcode);
725 p->set_generated_mass(persPart.m_generated_mass);
726
727 // Note: do the E calculation in extended (long double) precision.
728 // That happens implicitly on x86 with optimization on; saying it
729 // explicitly ensures that we get the same results with and without
730 // optimization. (If this is a performance issue for platforms
731 // other than x86, one could change to double for those platforms.)
732 if ( 0 == persPart.m_recoMethod ) {
733 double temp_e = std::sqrt( (long double)(persPart.m_px)*persPart.m_px +
734 (long double)(persPart.m_py)*persPart.m_py +
735 (long double)(persPart.m_pz)*persPart.m_pz +
736 (long double)(persPart.m_m) *persPart.m_m );
737 p->set_momentum( HepMC::FourVector(persPart.m_px,persPart.m_py,persPart.m_pz,temp_e));
738 } else {
739 const int signM2 = ( persPart.m_m >= 0. ? 1 : -1 );
740 const double persPart_ene =
741 std::sqrt( std::abs((long double)(persPart.m_px)*persPart.m_px +
742 (long double)(persPart.m_py)*persPart.m_py +
743 (long double)(persPart.m_pz)*persPart.m_pz +
744 signM2* (long double)(persPart.m_m)* persPart.m_m));
745 const int signEne = ( persPart.m_recoMethod == 1 ? 1 : -1 );
746 p->set_momentum(HepMC::FourVector( persPart.m_px,
747 persPart.m_py,
748 persPart.m_pz,
749 signEne * persPart_ene ));
750 }
751
752 // setup flow
753 std::vector<int> flows;
754 const unsigned int nFlow = persPart.m_flow.size();
755 for ( unsigned int iFlow= 0; iFlow != nFlow; ++iFlow ) {
756 flows.push_back(persPart.m_flow[iFlow].second );
757 }
758 //We construct it here as vector w/o gaps.
759 p->add_attribute("flows", std::make_shared<HepMC3::VectorIntAttribute>(flows));
760#else
761 p->m_pdg_id = persPart.m_pdgId;
762 p->m_status = HepMC::new_particle_status_from_old(persPart.m_status, persPart.m_barcode); // UPDATED STATUS VALUE TO NEW SCHEME
763 p->m_polarization.m_theta= static_cast<double>(persPart.m_thetaPolarization);
764 p->m_polarization.m_phi = static_cast<double>(persPart.m_phiPolarization );
765 p->m_production_vertex = 0;
766 p->m_end_vertex = 0;
767 p->m_barcode = persPart.m_barcode;
768 p->m_generated_mass = static_cast<double>(persPart.m_generated_mass);
769
770 // Note: do the E calculation in extended (long double) precision.
771 // That happens implicitly on x86 with optimization on; saying it
772 // explicitly ensures that we get the same results with and without
773 // optimization. (If this is a performance issue for platforms
774 // other than x86, one could change to double for those platforms.)
775 if ( 0 == persPart.m_recoMethod ) {
776
777 p->m_momentum.setPx( persPart.m_px);
778 p->m_momentum.setPy( persPart.m_py);
779 p->m_momentum.setPz( persPart.m_pz);
780 double temp_e = std::sqrt( (long double)(persPart.m_px)*persPart.m_px +
781 (long double)(persPart.m_py)*persPart.m_py +
782 (long double)(persPart.m_pz)*persPart.m_pz +
783 (long double)(persPart.m_m) *persPart.m_m );
784 p->m_momentum.setE( temp_e);
785 } else {
786 const int signM2 = ( persPart.m_m >= 0. ? 1 : -1 );
787 const double persPart_ene =
788 std::sqrt( std::abs((long double)(persPart.m_px)*persPart.m_px +
789 (long double)(persPart.m_py)*persPart.m_py +
790 (long double)(persPart.m_pz)*persPart.m_pz +
791 signM2* (long double)(persPart.m_m)* persPart.m_m));
792 const int signEne = ( persPart.m_recoMethod == 1 ? 1 : -1 );
793 p->m_momentum.set( persPart.m_px,
794 persPart.m_py,
795 persPart.m_pz,
796 signEne * persPart_ene );
797 }
798
799 // setup flow
800 const unsigned int nFlow = persPart.m_flow.size();
801 p->m_flow.clear();
802 for ( unsigned int iFlow= 0; iFlow != nFlow; ++iFlow ) {
803 p->m_flow.set_icode( persPart.m_flow[iFlow].first,
804 persPart.m_flow[iFlow].second );
805 }
806#endif
807
808 if ( persPart.m_endVtx != 0 ) {
809 partToEndVtx[p] = persPart.m_endVtx;
810 }
811
812 return p;
813}
814
815#ifdef HEPMC3
817 McEventCollection_p6& persEvt )
818{
819 const HepMC::FourVector& position = vtx->position();
820 auto A_weights=vtx->attribute<HepMC3::VectorDoubleAttribute>("weights");
821 auto A_barcode=vtx->attribute<HepMC3::IntAttribute>("barcode");
822 std::vector<float> weights;
823 if (A_weights) {
824 auto weights_d = A_weights->value();
825 for (auto& w: weights_d) weights.push_back(w);
826 }
827 persEvt.m_genVertices.emplace_back( position.x(),
828 position.y(),
829 position.z(),
830 position.t(),
831 HepMC::old_vertex_status_from_new(vtx->status()), // REVERTED STATUS VALUE TO OLD SCHEME
832 weights.begin(),
833 weights.end(),
834 A_barcode?(A_barcode->value()):vtx->id() );
835 GenVertex_p6& persVtx = persEvt.m_genVertices.back();
836
837 // we write only the orphans in-coming particles and beams
838 persVtx.m_particlesIn.reserve(vtx->particles_in().size());
839 for (const auto& p: vtx->particles_in()) {
840 if ( !p->production_vertex() || p->production_vertex()->id() == 0 ) {
841 persVtx.m_particlesIn.push_back( writeGenParticle( p, persEvt ) );
842 }
843 }
844
845 persVtx.m_particlesOut.reserve(vtx->particles_out().size());
846 for (const auto& p: vtx->particles_out()) {
847 persVtx.m_particlesOut.push_back( writeGenParticle( p, persEvt ) );
848 }
849
850 }
851#else
852void McEventCollectionCnv_p6::writeGenVertex( const HepMC::GenVertex& vtx,
853 McEventCollection_p6& persEvt ) const
854{
855 const HepMC::FourVector& position = vtx.m_position;
856 persEvt.m_genVertices.push_back(
857 GenVertex_p6( position.x(),
858 position.y(),
859 position.z(),
860 position.t(),
861 HepMC::old_vertex_status_from_new(vtx.m_id), // REVERTED STATUS VALUE TO OLD SCHEME
862 vtx.m_weights.m_weights.begin(),
863 vtx.m_weights.m_weights.end(),
864 vtx.m_barcode ) );
865 GenVertex_p6& persVtx = persEvt.m_genVertices.back();
866
867 // we write only the orphans in-coming particles
868 const std::vector<HepMC::GenParticlePtr>::const_iterator endInVtx = vtx.m_particles_in.end();
869 persVtx.m_particlesIn.reserve(vtx.m_particles_in.size());
870 for ( std::vector<HepMC::GenParticlePtr>::const_iterator p = vtx.m_particles_in.begin();
871 p != endInVtx;
872 ++p ) {
873 if ( 0 == (*p)->production_vertex() ) {
874 persVtx.m_particlesIn.push_back( writeGenParticle( **p, persEvt ) );
875 }
876 }
877
878 const std::vector<HepMC::GenParticlePtr>::const_iterator endOutVtx = vtx.m_particles_out.end();
879 persVtx.m_particlesOut.reserve(vtx.m_particles_out.size());
880 for ( std::vector<HepMC::GenParticlePtr>::const_iterator p = vtx.m_particles_out.begin();
881 p != endOutVtx;
882 ++p ) {
883 persVtx.m_particlesOut.push_back( writeGenParticle( **p, persEvt ) );
884 }
885
886 return;
887}
888#endif
889
890#ifdef HEPMC3
892 McEventCollection_p6& persEvt )
893{
894 const HepMC::FourVector mom = p->momentum();
895 const double ene = mom.e();
896 const double m2 = mom.m2();
897
898 // Definitions of Bool isTimeLilike, isSpacelike and isLightlike according to HepLorentzVector definition
899 const bool useP2M2 = !(m2 > 0) && // !isTimelike
900 (m2 < 0) && // isSpacelike
901 !(std::abs(m2) < 2.0*DBL_EPSILON*ene*ene); // !isLightlike
902 auto A_flows=p->attribute<HepMC3::VectorIntAttribute>("flows");
903 auto A_phi=p->attribute<HepMC3::DoubleAttribute>("phi");
904 auto A_theta=p->attribute<HepMC3::DoubleAttribute>("theta");
905
906 const short recoMethod = ( !useP2M2 ? 0: ( ene >= 0.? 1: 2 ) );
907 persEvt.m_genParticles.
908 emplace_back( mom.px(),
909 mom.py(),
910 mom.pz(),
911 mom.m(),
912 p->pdg_id(),
913 HepMC::old_particle_status_from_new(p->status()), // REVERTED STATUS VALUE TO OLD SCHEME
914 A_flows?(A_flows->value().size()):0,
915 A_theta?(A_theta->value()):0.0,
916 A_phi?(A_phi->value()):0.0,
917 p->production_vertex()? HepMC::barcode(p->production_vertex()):0,
918 p->end_vertex()? HepMC::barcode(p->end_vertex()):0,
920 p->generated_mass(),
921 recoMethod );
922
923 std::vector< std::pair<int,int> > flow_hepmc2;
924 if(A_flows) flow_hepmc2=vector_to_vector_int_int(A_flows->value());
925 persEvt.m_genParticles.back().m_flow.assign( flow_hepmc2.begin(),flow_hepmc2.end() );
926
927 // we return the index of the particle in the big vector of particles
928 // (contained by the persistent GenEvent)
929 return (persEvt.m_genParticles.size() - 1);
930
931}
932#else
933int McEventCollectionCnv_p6::writeGenParticle( const HepMC::GenParticle& p,
934 McEventCollection_p6& persEvt ) const
935{
936 const HepMC::FourVector& mom = p.m_momentum;
937 const double ene = mom.e();
938 const double m2 = mom.m2();
939
940 // Definitions of Bool isTimeLilike, isSpacelike and isLightlike according to HepLorentzVector definition
941 const bool useP2M2 = !(m2 > 0) && // !isTimelike
942 (m2 < 0) && // isSpacelike
943 !(std::abs(m2) < 2.0*DBL_EPSILON*ene*ene); // !isLightlike
944
945 const short recoMethod = ( !useP2M2
946 ? 0
947 : ( ene >= 0. //*GeV
948 ? 1
949 : 2 ) );
950
951 persEvt.m_genParticles.
952 push_back( GenParticle_p6( mom.px(),
953 mom.py(),
954 mom.pz(),
955 mom.m(),
956 p.m_pdg_id,
957 HepMC::old_particle_status_from_new(p.m_status), // REVERTED STATUS VALUE TO OLD SCHEME
958 p.m_flow.size(),
959 p.m_polarization.theta(),
960 p.m_polarization.phi(),
961 p.m_production_vertex
962 ? p.m_production_vertex->barcode()
963 : 0,
964 p.m_end_vertex
965 ? p.m_end_vertex->barcode()
966 : 0,
967 p.m_barcode,
968 p.m_generated_mass,
969 recoMethod ) );
970 persEvt.m_genParticles.back().m_flow.assign( p.m_flow.begin(),
971 p.m_flow.end() );
972
973 // we return the index of the particle in the big vector of particles
974 // (contained by the persistent GenEvent)
975 return (persEvt.m_genParticles.size() - 1);
976}
977#endif
978
#define endmsg
static const std::set< std::string > attributes_to_ignore
#define pi
void prepareToAdd(unsigned int size)
Prepare to add cached elements.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
double m_alphaQED
value of the QED coupling.
int m_momentumUnit
HepMC::Units::MomentumUnit casted to int.
int m_signalProcessId
Id of the processus being generated.
Definition GenEvent_p6.h:81
unsigned int m_particlesBegin
Begin position in the vector of particles composing this event.
std::vector< double > m_crossSection
Container of HepMC::GenCrossSection object translated to vector<double>.
int m_mpi
Number of multi particle interactions.
Definition GenEvent_p6.h:89
int m_eventNbr
Event number.
Definition GenEvent_p6.h:85
std::vector< long int > m_randomStates
Container of random numbers for the generator states.
std::vector< std::string > m_r_attribute_name
Attribute name for run info.
unsigned int m_verticesEnd
End position in the vector of vertices composing this event.
std::vector< int > m_e_attribute_id
We define those exactly as in the HepMC3::GenEvent.
unsigned int m_verticesBegin
Begin position in the vector of vertices composing this event.
std::vector< double > m_pdfinfo
Container of HepMC::PdfInfo object translated to vector<double> for simplicity.
std::vector< double > m_weights
Weights for this event.
int m_beamParticle1
Barcode of the beam particle 1.
std::vector< std::string > m_e_attribute_string
Attribute serialized as string for event.
int m_signalProcessVtx
Barcode of the GenVertex holding the signal process.
int m_beamParticle2
Barcode of the beam particle 2.
unsigned int m_particlesEnd
End position in the vector of particles composing this event.
double m_eventScale
Energy scale.
Definition GenEvent_p6.h:93
double m_alphaQCD
value of the QCD coupling.
Definition GenEvent_p6.h:97
int m_lengthUnit
HepMC::Units::LengthUnit casted to int.
std::vector< std::string > m_r_attribute_string
Attribute serialized as string for run info.
double m_filterWeight
value of the extra weight introduced during reweighting events in filter and value of some variables ...
std::vector< std::string > m_e_attribute_name
Attribute name for event.
std::vector< float > m_heavyIon
Container of HepMC::HeavyIon object translated to vector<double>.
float m_py
y-component of the 4-momentum of this particle
float m_m
m-component of the 4-momentum of this particle
int m_barcode
barcode of this particles (uniquely identifying this particle within a given GenEvent)
std::vector< std::pair< int, int > > m_flow
Flow for this particle.
int m_status
Status of this particle, as defined for HEPEVT.
int m_endVtx
Barcode of the decay vertex of this particle.
short m_recoMethod
switch to know which method to chose to better recover the original HepLorentzVector.
float m_generated_mass
mass of this particle when it was generated
float m_phiPolarization
phi polarization
float m_pz
z-component of the 4-momentum of this particle
int m_pdgId
identity of this particle, according to the Particle Data Group notation
float m_thetaPolarization
polarization
float m_px
x-component of the 4-momentum of this particle
int m_barcode
barcode of this vertex (uniquely identifying a vertex within an event)
float m_t
t-coordinate of the vertex
std::vector< float > m_weights
Weights for this vertex.
float m_x
x-coordinate of the vertex
std::vector< int > m_particlesIn
collection of barcodes of in-going particles connected to this vertex
int m_id
Id of this vertex.
float m_z
z-coordinate of the vertex
float m_y
y-coordinate of the vertex
std::vector< int > m_particlesOut
collection of barcodes of out-going particles connected to this vertex
McEventCollectionCnv_p6()
Default constructor:
HepMC::GenParticlePtr createGenParticle(const GenParticle_p6 &p, ParticlesMap_t &partToEndVtx, HepMC::DataPool &datapools, const HepMC::GenVertexPtr &parent=nullptr, bool add_to_output=true) const
Create a transient GenParticle from a persistent one (vers.1) It returns the new GenParticle.
virtual void persToTrans(const McEventCollection_p6 *persObj, McEventCollection *transObj, MsgStream &log)
Method creating the transient representation of McEventCollection from its persistent representation ...
virtual ~McEventCollectionCnv_p6()
Destructor.
ServiceHandle< IHepMCWeightSvc > m_hepMCWeightSvc
HepMC::GenVertexPtr createGenVertex(const McEventCollection_p6 &persEvts, const GenVertex_p6 &vtx, ParticlesMap_t &bcToPart, HepMC::DataPool &datapools, HepMC::GenEvent *parent=nullptr) const
Create a transient GenVertex from a persistent one (version 1) It returns the new GenVertex.
McEventCollectionCnv_p6 & operator=(const McEventCollectionCnv_p6 &rhs)
Assignement operator.
void writeGenVertex(const HepMC::GenVertex &vtx, McEventCollection_p6 &persEvt) const
Method to write a persistent GenVertex object.
std::unordered_map< HepMC::GenParticlePtr, int > ParticlesMap_t
T_AthenaPoolTPCnvBase< McEventCollection, McEventCollection_p6 > Base_t
int writeGenParticle(const HepMC::GenParticle &p, McEventCollection_p6 &persEvt) const
Method to write a persistent GenParticle object It returns the index of the persistent GenParticle in...
virtual void transToPers(const McEventCollection *transObj, McEventCollection_p6 *persObj, MsgStream &log)
Method creating the persistent representation McEventCollection_p6 from its transient representation ...
std::vector< GenParticle_p6 > m_genParticles
The vector of persistent representation of GenParticles.
std::vector< GenEvent_p6 > m_genEvents
The vector of persistent representation of GenEvents.
std::vector< GenVertex_p6 > m_genVertices
The vector of persistent representation of GenVertices.
This defines the McEventCollection, which is really just an ObjectVector of McEvent objectsFile: Gene...
void set_signal_process_vertex(GenEvent *e, T v)
Definition GenEvent.h:670
GenParticle * barcode_to_particle(const GenEvent *e, int id)
Definition GenEvent.h:648
int barcode(const T *p)
Definition Barcode.h:16
GenVertex * barcode_to_vertex(const GenEvent *e, int id)
Definition GenEvent.h:647
HepMC::GenVertex * GenVertexPtr
Definition GenVertex.h:59
bool suggest_barcode(T &p, int i)
Definition GenEvent.h:690
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition GenVertex.h:64
int new_vertex_status_from_old(const int oldStatus, const int barcode)
Get vertex status in the new scheme from the barcode and status in the old scheme.
int old_vertex_status_from_new(const int newStatus)
Get vertex status in the old scheme from the status in the new scheme.
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
Definition GenParticle.h:39
int new_particle_status_from_old(const int oldStatus, const int barcode)
Get particle status in the new scheme from the barcode and status in the old scheme.
int old_particle_status_from_new(const int newStatus)
Get particle status in the old scheme from the status in the new scheme.
GenParticle * GenParticlePtr
Definition GenParticle.h:37
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
GenVertex * signal_process_vertex(const GenEvent *e)
Definition GenEvent.h:645
const HepMC::GenVertex * ConstGenVertexPtr
Definition GenVertex.h:60
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const Amg::Vector3D & position() const
Method to retrieve the position of the Intersection.
HepMC::GenParticlePtr getGenParticle()
GenPartPool_t part
an arena of HepMC::GenParticle for efficient object instantiation
HepMC::GenEvent * getGenEvent()
HepMC::GenVertexPtr getGenVertex()
GenVtxPool_t vtx
an arena of HepMC::GenVertex for efficient object instantiation
GenEvtPool_t evt
an arena of HepMC::GenEvent for efficient object instantiation
MsgStream & msg
Definition testRead.cxx:32