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::GenEvent * GetEvent () const
 
const HepMC3::GenEvent & getHepMCData () const
 
 HepMC3Product ()
 
 HepMC3Product (HepMC3::GenEvent *evt)
 
 HepMC3Product (HepMC3Product const &orig)
 
 HepMC3Product (HepMC3Product &&orig)
 
bool isPBoostApplied () const
 
bool isVtxBoostApplied () const
 
bool isVtxGenApplied () const
 
HepMC3Productoperator= (HepMC3Product const &other)
 
HepMC3Productoperator= (HepMC3Product &&other)
 
void swap (HepMC3Product &other)
 
virtual ~HepMC3Product ()
 

Private Attributes

HepMC3::GenEvent * evt_
 
bool isPBoostApplied_
 
bool isVtxBoostApplied_
 
bool isVtxGenApplied_
 

Detailed Description

Definition at line 21 of file HepMC3Product.h.

Constructor & Destructor Documentation

◆ HepMC3Product() [1/4]

edm::HepMC3Product::HepMC3Product ( )
inline

Definition at line 23 of file HepMC3Product.h.

23 : evt_(nullptr), isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) {}
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ HepMC3Product() [2/4]

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

Definition at line 19 of file HepMC3Product.cc.

20  : evt_(evt), isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) {}
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ ~HepMC3Product()

HepMC3Product::~HepMC3Product ( )
virtual

Definition at line 22 of file HepMC3Product.cc.

References evt_, isPBoostApplied_, isVtxBoostApplied_, and isVtxGenApplied_.

22  {
23  delete evt_;
24  evt_ = nullptr;
25  isVtxGenApplied_ = false;
26  isVtxBoostApplied_ = false;
27  isPBoostApplied_ = false;
28 }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ HepMC3Product() [3/4]

HepMC3Product::HepMC3Product ( HepMC3Product const &  orig)

Definition at line 116 of file HepMC3Product.cc.

References evt_, isPBoostApplied_, isVtxBoostApplied_, isVtxGenApplied_, and trackingPlots::other.

116  : evt_(nullptr) {
117  if (other.evt_)
118  evt_ = new HepMC3::GenEvent(*other.evt_);
119  isVtxGenApplied_ = other.isVtxGenApplied_;
120  isVtxBoostApplied_ = other.isVtxBoostApplied_;
121  isPBoostApplied_ = other.isPBoostApplied_;
122  //fTimeOffset = other.fTimeOffset;
123 }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ HepMC3Product() [4/4]

HepMC3Product::HepMC3Product ( HepMC3Product &&  orig)

Definition at line 142 of file HepMC3Product.cc.

References trackingPlots::other, and swap().

142 : evt_(nullptr) { swap(other); }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50
void swap(HepMC3Product &other)

Member Function Documentation

◆ addHepMCData()

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

Definition at line 30 of file HepMC3Product.cc.

References evt_.

30  {
31  // evt->print();
32  // cout <<sizeof (evt) <<" " << sizeof ( HepMC::GenEvent) << endl;
33  evt_ = evt;
34 
35  // same story about vertex smearing - GenEvent won't know it...
36  // in fact, would be better to implement CmsGenEvent...
37 }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ applyVtxGen() [1/2]

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

Definition at line 30 of file HepMC3Product.h.

References applyVtxGen().

Referenced by applyVtxGen().

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

◆ applyVtxGen() [2/2]

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

Definition at line 39 of file HepMC3Product.cc.

References evt_, isVtxGenApplied(), and isVtxGenApplied_.

39  {
40  //std::cout<< " applyVtxGen called " << isVtxGenApplied_ << endl;
41  //fTimeOffset = 0;
42  if (isVtxGenApplied())
43  return;
44  evt_->shift_position_by(vtxShift);
45  isVtxGenApplied_ = true;
46  return;
47 }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50
bool isVtxGenApplied() const
Definition: HepMC3Product.h:39

◆ boostToLab()

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

Definition at line 49 of file HepMC3Product.cc.

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

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

◆ GetEvent()

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

Definition at line 37 of file HepMC3Product.h.

References evt_.

37 { return evt_; }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ getHepMCData()

const HepMC3::GenEvent & HepMC3Product::getHepMCData ( ) const

Definition at line 113 of file HepMC3Product.cc.

References evt_.

113 { return *evt_; }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50

◆ isPBoostApplied()

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

Definition at line 41 of file HepMC3Product.h.

References isPBoostApplied_.

Referenced by boostToLab().

41 { return isPBoostApplied_; }

◆ isVtxBoostApplied()

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

Definition at line 40 of file HepMC3Product.h.

References isVtxBoostApplied_.

Referenced by boostToLab().

40 { return isVtxBoostApplied_; }

◆ isVtxGenApplied()

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

Definition at line 39 of file HepMC3Product.h.

References isVtxGenApplied_.

Referenced by applyVtxGen().

39 { return isVtxGenApplied_; }

◆ operator=() [1/2]

HepMC3Product & HepMC3Product::operator= ( HepMC3Product const &  other)

Definition at line 135 of file HepMC3Product.cc.

References trackingPlots::other, swap(), and groupFilesInBlocks::temp.

135  {
137  swap(temp);
138  return *this;
139 }
void swap(HepMC3Product &other)

◆ operator=() [2/2]

HepMC3Product & HepMC3Product::operator= ( HepMC3Product &&  other)

Definition at line 143 of file HepMC3Product.cc.

References trackingPlots::other, and swap().

143  {
144  swap(other);
145  return *this;
146 }
void swap(HepMC3Product &other)

◆ swap()

void HepMC3Product::swap ( HepMC3Product other)

Definition at line 126 of file HepMC3Product.cc.

References evt_, isPBoostApplied_, isVtxBoostApplied_, isVtxGenApplied_, trackingPlots::other, and edm::swap().

Referenced by HepMC3Product(), and operator=().

126  {
127  std::swap(evt_, other.evt_);
128  std::swap(isVtxGenApplied_, other.isVtxGenApplied_);
129  std::swap(isVtxBoostApplied_, other.isVtxBoostApplied_);
130  std::swap(isPBoostApplied_, other.isPBoostApplied_);
131  //std::swap(fTimeOffset, other.fTimeOffset);
132 }
HepMC3::GenEvent * evt_
Definition: HepMC3Product.h:50
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112

Member Data Documentation

◆ evt_

HepMC3::GenEvent* edm::HepMC3Product::evt_
private

◆ isPBoostApplied_

bool edm::HepMC3Product::isPBoostApplied_
private

Definition at line 54 of file HepMC3Product.h.

Referenced by boostToLab(), HepMC3Product(), isPBoostApplied(), swap(), and ~HepMC3Product().

◆ isVtxBoostApplied_

bool edm::HepMC3Product::isVtxBoostApplied_
private

Definition at line 53 of file HepMC3Product.h.

Referenced by boostToLab(), HepMC3Product(), isVtxBoostApplied(), swap(), and ~HepMC3Product().

◆ isVtxGenApplied_

bool edm::HepMC3Product::isVtxGenApplied_
private

Definition at line 52 of file HepMC3Product.h.

Referenced by applyVtxGen(), HepMC3Product(), isVtxGenApplied(), swap(), and ~HepMC3Product().