CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::HepMC3Product Class Reference

#include <HepMC3Product.h>

Public Member Functions

void addHepMCData (HepMC3::GenEvent *evt)
 
void applyVtxGen (HepMC3::FourVector const *vtxShift)
 
void applyVtxGen (HepMC3::FourVector const &vtxShift)
 
void boostToLab (TMatrixD const *lorentz, std::string const &type)
 
const HepMC3::GenEventData * GetEvent () const
 
 HepMC3Product ()
 
 HepMC3Product (HepMC3::GenEvent *evt)
 
bool isPBoostApplied () const
 
bool isVtxBoostApplied () const
 
bool isVtxGenApplied () const
 
 ~HepMC3Product ()
 

Private Attributes

HepMC3::GenEventData evt_
 
bool isPBoostApplied_
 
bool isVtxBoostApplied_
 
bool isVtxGenApplied_
 

Detailed Description

Definition at line 22 of file HepMC3Product.h.

Constructor & Destructor Documentation

◆ HepMC3Product() [1/2]

edm::HepMC3Product::HepMC3Product ( )
inline

Definition at line 24 of file HepMC3Product.h.

◆ HepMC3Product() [2/2]

HepMC3Product::HepMC3Product ( HepMC3::GenEvent *  evt)
explicit

Definition at line 19 of file HepMC3Product.cc.

References addHepMCData().

20  : isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) {
21  addHepMCData(evt);
22 }
void addHepMCData(HepMC3::GenEvent *evt)

◆ ~HepMC3Product()

HepMC3Product::~HepMC3Product ( )
default

Member Function Documentation

◆ addHepMCData()

void HepMC3Product::addHepMCData ( HepMC3::GenEvent *  evt)

Definition at line 26 of file HepMC3Product.cc.

References evt_.

Referenced by HepMC3Product().

26 { evt->write_data(evt_); }
HepMC3::GenEventData evt_
Definition: HepMC3Product.h:43

◆ applyVtxGen() [1/2]

void edm::HepMC3Product::applyVtxGen ( HepMC3::FourVector const *  vtxShift)
inline

Definition at line 31 of file HepMC3Product.h.

References applyVtxGen().

Referenced by applyVtxGen().

31 { applyVtxGen(*vtxShift); }
void applyVtxGen(HepMC3::FourVector const *vtxShift)
Definition: HepMC3Product.h:31

◆ applyVtxGen() [2/2]

void HepMC3Product::applyVtxGen ( HepMC3::FourVector const &  vtxShift)

Definition at line 28 of file HepMC3Product.cc.

References evt_, isVtxGenApplied(), and isVtxGenApplied_.

28  {
29  //std::cout<< " applyVtxGen called " << isVtxGenApplied_ << endl;
30  //fTimeOffset = 0;
31  if (isVtxGenApplied())
32  return;
33  HepMC3::GenEvent evt;
34  evt.read_data(evt_);
35  evt.shift_position_by(vtxShift);
36  evt.write_data(evt_);
37  isVtxGenApplied_ = true;
38  return;
39 }
bool isVtxGenApplied() const
Definition: HepMC3Product.h:38
HepMC3::GenEventData evt_
Definition: HepMC3Product.h:43

◆ boostToLab()

void HepMC3Product::boostToLab ( TMatrixD const *  lorentz,
std::string const &  type 
)

Definition at line 41 of file HepMC3Product.cc.

References evt_, isPBoostApplied(), isPBoostApplied_, isVtxBoostApplied(), and isVtxBoostApplied_.

41  {
42  //std::cout << "from boostToLab:" << std::endl;
43  HepMC3::GenEvent evt;
44  evt.read_data(evt_);
45 
46  if (lorentz == nullptr) {
47  //std::cout << " lorentz = 0 " << std::endl;
48  return;
49  }
50 
51  //lorentz->Print();
52 
53  TMatrixD tmplorentz(*lorentz);
54  //tmplorentz.Print();
55 
56  if (type == "vertex") {
57  if (isVtxBoostApplied()) {
58  //std::cout << " isVtxBoostApplied true " << std::endl;
59  return;
60  }
61 
62  for (const HepMC3::GenVertexPtr& vt : evt.vertices()) {
63  // change basis to lorentz boost definition: (t,x,z,y)
64  TMatrixD p4(4, 1);
65  p4(0, 0) = vt->position().t();
66  p4(1, 0) = vt->position().x();
67  p4(2, 0) = vt->position().z();
68  p4(3, 0) = vt->position().y();
69 
70  TMatrixD p4lab(4, 1);
71  p4lab = tmplorentz * p4;
72  //std::cout << " vertex lorentz: " << p4lab(1,0) << " " << p4lab(3,0) << " " << p4lab(2,0) << std::endl;
73  vt->set_position(HepMC3::FourVector(p4lab(1, 0), p4lab(3, 0), p4lab(2, 0), p4lab(0, 0)));
74  }
75 
76  isVtxBoostApplied_ = true;
77  } else if (type == "momentum") {
78  if (isPBoostApplied()) {
79  //std::cout << " isPBoostApplied true " << std::endl;
80  return;
81  }
82 
83  for (const HepMC3::GenParticlePtr& part : evt.particles()) {
84  // change basis to lorentz boost definition: (E,Px,Pz,Py)
85  TMatrixD p4(4, 1);
86  p4(0, 0) = part->momentum().e();
87  p4(1, 0) = part->momentum().x();
88  p4(2, 0) = part->momentum().z();
89  p4(3, 0) = part->momentum().y();
90 
91  TMatrixD p4lab(4, 1);
92  p4lab = tmplorentz * p4;
93  //std::cout << " momentum lorentz: " << p4lab(1,0) << " " << p4lab(3,0) << " " << p4lab(2,0) << std::endl;
94  part->set_momentum(HepMC3::FourVector(p4lab(1, 0), p4lab(3, 0), p4lab(2, 0), p4lab(0, 0)));
95  }
96 
97  isPBoostApplied_ = true;
98  } else {
99  edm::LogWarning("GeneratorProducts") << "no type found for boostToLab(std::string), options are vertex or momentum";
100  //throw edm::Exception(edm::errors::Configuration, "GeneratorProducts")
101  // << "no type found for boostToLab(std::string), options are vertex or momentum \n";
102  }
103 
104  evt.write_data(evt_);
105  return;
106 }
bool isPBoostApplied() const
Definition: HepMC3Product.h:40
bool isVtxBoostApplied() const
Definition: HepMC3Product.h:39
edm::Ptr< GenParticle > GenParticlePtr
persistent reference to a GenParticle
part
Definition: HCALResponse.h:20
Log< level::Warning, false > LogWarning
HepMC3::GenEventData evt_
Definition: HepMC3Product.h:43

◆ GetEvent()

const HepMC3::GenEventData* edm::HepMC3Product::GetEvent ( ) const
inline

Definition at line 36 of file HepMC3Product.h.

References evt_.

Referenced by RivetAnalyzer::analyze(), and HTXSRivetProducer::produce().

36 { return &evt_; }
HepMC3::GenEventData evt_
Definition: HepMC3Product.h:43

◆ isPBoostApplied()

bool edm::HepMC3Product::isPBoostApplied ( ) const
inline

Definition at line 40 of file HepMC3Product.h.

References isPBoostApplied_.

Referenced by boostToLab().

40 { return isPBoostApplied_; }

◆ isVtxBoostApplied()

bool edm::HepMC3Product::isVtxBoostApplied ( ) const
inline

Definition at line 39 of file HepMC3Product.h.

References isVtxBoostApplied_.

Referenced by boostToLab().

39 { return isVtxBoostApplied_; }

◆ isVtxGenApplied()

bool edm::HepMC3Product::isVtxGenApplied ( ) const
inline

Definition at line 38 of file HepMC3Product.h.

References isVtxGenApplied_.

Referenced by applyVtxGen().

38 { return isVtxGenApplied_; }

Member Data Documentation

◆ evt_

HepMC3::GenEventData edm::HepMC3Product::evt_
private

Definition at line 43 of file HepMC3Product.h.

Referenced by addHepMCData(), applyVtxGen(), boostToLab(), and GetEvent().

◆ isPBoostApplied_

bool edm::HepMC3Product::isPBoostApplied_
private

Definition at line 47 of file HepMC3Product.h.

Referenced by boostToLab(), and isPBoostApplied().

◆ isVtxBoostApplied_

bool edm::HepMC3Product::isVtxBoostApplied_
private

Definition at line 46 of file HepMC3Product.h.

Referenced by boostToLab(), and isVtxBoostApplied().

◆ isVtxGenApplied_

bool edm::HepMC3Product::isVtxGenApplied_
private

Definition at line 45 of file HepMC3Product.h.

Referenced by applyVtxGen(), and isVtxGenApplied().