CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TotemTransport Class Reference

#include <TotemTransport.h>

Inheritance diagram for TotemTransport:
BaseProtonTransport

Public Member Functions

void process (const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine) override
 
 TotemTransport (const edm::ParameterSet &ps)
 
 ~TotemTransport () override
 
- Public Member Functions inherited from BaseProtonTransport
void addPartToHepMC (const HepMC::GenEvent *, HepMC::GenEvent *)
 
void ApplyBeamCorrection (HepMC::GenParticle *p)
 
void ApplyBeamCorrection (TLorentzVector &p)
 
 BaseProtonTransport (const edm::ParameterSet &iConfig)
 
double beamEnergy ()
 
double beamMomentum ()
 
void clear ()
 
std::vector< LHCTransportLink > & getCorrespondenceMap ()
 
virtual ~BaseProtonTransport ()
 

Private Member Functions

LHCOpticsApproximatorReadParameterization (const std::string &, const std::string &)
 
bool transportProton (HepMC::GenParticle *)
 

Private Attributes

LHCOpticsApproximatorm_aprox_ip_150_l_
 
LHCOpticsApproximatorm_aprox_ip_150_r_
 
double m_beampipe_aperture_radius_
 
std::string m_model_ip_150_l_name_
 
std::string m_model_ip_150_r_name_
 

Additional Inherited Members

- Protected Types inherited from BaseProtonTransport
enum  TransportMode { TransportMode::HECTOR, TransportMode::TOTEM, TransportMode::OPTICALFUNCTIONS }
 
- Protected Member Functions inherited from BaseProtonTransport
void setBeamFileNames (const std::string &nam1, const std::string &nam2)
 
void setBeamParameters (double stx, double sty, double sx, double sy, double se)
 
void setCrossingAngles (double cx45, double cx56, double cy45, double cy56)
 
- Protected Attributes inherited from BaseProtonTransport
bool bApplyZShift_
 
std::string beam1Filename_ {""}
 
std::string beam2Filename_ {""}
 
CLHEP::HepRandomEngine * engine_ {nullptr}
 
double etaCut_
 
double fCrossingAngleX_45_ {0.0}
 
double fCrossingAngleX_56_ {0.0}
 
double fCrossingAngleY_45_ {0.0}
 
double fCrossingAngleY_56_ {0.0}
 
double fPPSRegionStart_45_
 
double fPPSRegionStart_56_
 
std::map< unsigned int, TLorentzVector > m_beamPart
 
std::vector< LHCTransportLinkm_CorrespondenceMap
 
std::map< unsigned int, double > m_xAtTrPoint
 
std::map< unsigned int, double > m_yAtTrPoint
 
TransportMode MODE
 
double momentumCut_
 
bool produceHitsRelativeToBeam_
 
bool useBeamPositionFromLHCInfo_
 
bool verbosity_
 

Detailed Description

Definition at line 19 of file TotemTransport.h.

Constructor & Destructor Documentation

◆ TotemTransport()

TotemTransport::TotemTransport ( const edm::ParameterSet ps)

Definition at line 9 of file TotemTransport.cc.

References BaseProtonTransport::beam1Filename_, BaseProtonTransport::beam2Filename_, edm::errors::Configuration, Exception, BaseProtonTransport::fPPSRegionStart_56_, edm::ParameterSet::getParameter(), m_aprox_ip_150_l_, m_aprox_ip_150_r_, m_model_ip_150_l_name_, m_model_ip_150_r_name_, BaseProtonTransport::MODE, ReadParameterization(), BaseProtonTransport::setBeamFileNames(), BaseProtonTransport::setBeamParameters(), BaseProtonTransport::setCrossingAngles(), AlCaHLTBitMon_QueryRunRegistry::string, fftjetcommon_cfi::sx, fftjetcommon_cfi::sy, and BaseProtonTransport::TOTEM.

10  : BaseProtonTransport(iConfig),
11  m_model_ip_150_r_name_(iConfig.getParameter<std::string>("Model_IP_150_R_Name")),
12  m_model_ip_150_l_name_(iConfig.getParameter<std::string>("Model_IP_150_L_Name")),
13  m_beampipe_aperture_radius_(iConfig.getParameter<double>("BeampipeApertureRadius")) {
15  std::string s1 = iConfig.getParameter<std::string>("Beam1Filename");
16  std::string s2 = iConfig.getParameter<std::string>("Beam2Filename");
17  setBeamFileNames(s1, s2);
18  double cax45 = iConfig.getParameter<double>("halfCrossingAngleXSector45");
19  double cax56 = iConfig.getParameter<double>("halfCrossingAngleXSector56");
20  setCrossingAngles(cax45, cax56, 0.0, 0.0);
21  double stx = iConfig.getParameter<double>("BeamDivergenceX");
22  double sty = iConfig.getParameter<double>("BeamDivergenceY");
23  double sx = iConfig.getParameter<double>("BeamSigmaX");
24  double sy = iConfig.getParameter<double>("BeamSigmaY");
25  double se = iConfig.getParameter<double>("BeamEnergyDispersion");
26  setBeamParameters(stx, sty, sx, sy, se);
27 
28  if (fPPSRegionStart_56_ > 0)
29  fPPSRegionStart_56_ *= -1; // make sure sector 56 has negative position, as TOTEM convention
30 
31  edm::LogVerbatim("TotemTransport")
32  << "=============================================================================\n"
33  << " Bulding LHC Proton transporter based on TOTEM model\n"
34  << "=============================================================================\n";
35 
38 
39  if (m_aprox_ip_150_r_ == nullptr || m_aprox_ip_150_l_ == nullptr) {
40  edm::LogError("TotemTransport") << "Parameterisation " << m_model_ip_150_r_name_ << " or " << m_model_ip_150_l_name_
41  << " missing in file. Cannot proceed. ";
42  throw edm::Exception(edm::errors::Configuration) << "TotemTransport is not properly initialized";
43  }
44  edm::LogVerbatim("TotemTransport") << "Parameterizations read from file, pointers:" << m_aprox_ip_150_r_ << " "
45  << m_aprox_ip_150_l_ << " ";
46 }
Log< level::Info, true > LogVerbatim
BaseProtonTransport(const edm::ParameterSet &iConfig)
std::string m_model_ip_150_l_name_
Log< level::Error, false > LogError
void setBeamParameters(double stx, double sty, double sx, double sy, double se)
LHCOpticsApproximator * m_aprox_ip_150_r_
std::string m_model_ip_150_r_name_
double m_beampipe_aperture_radius_
LHCOpticsApproximator * m_aprox_ip_150_l_
void setCrossingAngles(double cx45, double cx56, double cy45, double cy56)
void setBeamFileNames(const std::string &nam1, const std::string &nam2)
LHCOpticsApproximator * ReadParameterization(const std::string &, const std::string &)

◆ ~TotemTransport()

TotemTransport::~TotemTransport ( )
override

Definition at line 47 of file TotemTransport.cc.

47 {}

Member Function Documentation

◆ process()

void TotemTransport::process ( const HepMC::GenEvent ev,
const edm::EventSetup es,
CLHEP::HepRandomEngine *  engine 
)
overridevirtual

Implements BaseProtonTransport.

Definition at line 52 of file TotemTransport.cc.

References BaseProtonTransport::clear(), BaseProtonTransport::engine_, BaseProtonTransport::etaCut_, GenParticle::GenParticle, mps_splice::line, BaseProtonTransport::m_beamPart, BaseProtonTransport::momentumCut_, and transportProton().

54  {
55  clear();
56  engine_ = engine; // the engine needs to be updated for each event
57 
58  HepMC::GenEvent evt(*ievt);
59 
60  for (HepMC::GenEvent::particle_const_iterator eventParticle = evt.particles_begin();
61  eventParticle != evt.particles_end();
62  ++eventParticle) {
63  if (!((*eventParticle)->status() == 1 && (*eventParticle)->pdg_id() == 2212))
64  continue;
65 
66  if (!(fabs((*eventParticle)->momentum().eta()) > etaCut_ && fabs((*eventParticle)->momentum().pz()) > momentumCut_))
67  continue; // discard protons outside kinematic acceptance
68 
69  unsigned int line = (*eventParticle)->barcode();
70  HepMC::GenParticle* gpart = (*eventParticle);
71  if (gpart->pdg_id() != 2212)
72  continue; // only transport stable protons
73  if (gpart->status() != 1)
74  continue;
75  if (m_beamPart.find(line) != m_beamPart.end()) // assures this protons has not been already propagated
76  continue;
77 
78  transportProton(gpart);
79  }
80 }
CLHEP::HepRandomEngine * engine_
bool transportProton(HepMC::GenParticle *)
std::map< unsigned int, TLorentzVector > m_beamPart

◆ ReadParameterization()

LHCOpticsApproximator * TotemTransport::ReadParameterization ( const std::string &  m_model_name,
const std::string &  rootfile 
)
private

Definition at line 180 of file TotemTransport.cc.

References f, MillePedeFileConverter_cfg::fileName, and doHarvest::rootfile.

Referenced by TotemTransport().

181  {
183  TFile* f = TFile::Open(fileName.fullPath().c_str(), "read");
184  if (!f) {
185  edm::LogError("TotemTransport") << "File " << fileName << " not found. Exiting.";
186  return nullptr;
187  }
188  edm::LogVerbatim("TotemTransport") << "Root file opened, pointer:" << f;
189 
190  // read parametrization
191  LHCOpticsApproximator* aprox = (LHCOpticsApproximator*)f->Get(m_model_name.c_str());
192  f->Close();
193  return aprox;
194 }
Log< level::Info, true > LogVerbatim
Log< level::Error, false > LogError
double f[11][100]
Class finds the parametrisation of MADX proton transport and transports the protons according to it 5...

◆ transportProton()

bool TotemTransport::transportProton ( HepMC::GenParticle *  in_trk)
private

Definition at line 86 of file TotemTransport.cc.

References BaseProtonTransport::ApplyBeamCorrection(), MillePedeFileConverter_cfg::e, BaseProtonTransport::fCrossingAngleX_45_, BaseProtonTransport::fCrossingAngleX_56_, BaseProtonTransport::fPPSRegionStart_45_, BaseProtonTransport::fPPSRegionStart_56_, mps_splice::line, LogDebug, m_aprox_ip_150_l_, m_aprox_ip_150_r_, BaseProtonTransport::m_beamPart, m_beampipe_aperture_radius_, BaseProtonTransport::m_xAtTrPoint, BaseProtonTransport::m_yAtTrPoint, ProtonMassSQ, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, mathSSE::sqrt(), LHCOpticsApproximator::Transport_m_GeV(), urad, and BaseProtonTransport::verbosity_.

Referenced by process().

86  {
87  //
88  edm::LogVerbatim("TotemTransport") << "Starting proton transport using TOTEM method\n";
89  //
90  ApplyBeamCorrection(in_trk);
91 
92  const HepMC::GenVertex* in_pos = in_trk->production_vertex();
93  const HepMC::FourVector in_mom = in_trk->momentum();
94  //
95  // ATTENTION: HepMC uses mm, vertex config of CMS uses cm and SimTransport uses mm
96  //
97  double in_position[3] = {in_pos->position().x(), in_pos->position().y(), in_pos->position().z()}; //in LHC ref. frame
98 
99  double crossingAngleX = (in_mom.z() > 0) ? fCrossingAngleX_45_ : fCrossingAngleX_56_;
100 
101  // Move the position to z=0. Do it in the CMS ref frame. Totem parameterization does the rotation internatlly
102  in_position[0] =
103  in_position[0] - in_position[2] * (in_mom.x() / in_mom.z() - crossingAngleX * urad); // in CMS ref. frame
104  in_position[1] = in_position[1] - in_position[2] * (in_mom.y() / (in_mom.z()));
105  in_position[2] = 0.;
106  double in_momentum[3] = {in_mom.x(), in_mom.y(), in_mom.z()};
107  double out_position[3];
108  double out_momentum[3];
109  edm::LogVerbatim("TotemTransport") << "before transport ->"
110  << " position: " << in_position[0] << ", " << in_position[1] << ", "
111  << in_position[2] << " momentum: " << in_momentum[0] << ", " << in_momentum[1]
112  << ", " << in_momentum[2];
113 
114  LHCOpticsApproximator* approximator = nullptr;
115  double zin;
116  double zout;
117  if (in_mom.z() > 0) {
118  approximator = m_aprox_ip_150_l_;
119  zin = 0.0; // Totem propagations assumes the starting point at 0 (zero)
120  zout = fPPSRegionStart_45_;
121  } else {
122  approximator = m_aprox_ip_150_r_;
123  zin = 0.0; // Totem propagations assumes the starting point at 0 (zero)
124  zout = fPPSRegionStart_56_;
125  }
126 
127  bool invert_beam_coord_system =
128  true; // it doesn't matter the option here, it is hard coded as TRUE inside LHCOpticsApproximator!
129 
130  bool tracked = approximator->Transport_m_GeV(
131  in_position, in_momentum, out_position, out_momentum, invert_beam_coord_system, zout - zin);
132 
133  if (!tracked)
134  return false;
135 
136  edm::LogVerbatim("TotemTransport") << "after transport -> "
137  << "position: " << out_position[0] << ", " << out_position[1] << ", "
138  << out_position[2] << "momentum: " << out_momentum[0] << ", " << out_momentum[1]
139  << ", " << out_momentum[2];
140 
141  if (out_position[0] * out_position[0] + out_position[1] * out_position[1] >
143  edm::LogVerbatim("TotemTransport") << "Proton ouside beampipe\n"
144  << "===== END Transport "
145  << "====================";
146  return false;
147  }
148 
149  TVector3 out_pos(out_position[0] * meter, out_position[1] * meter, out_position[2] * meter);
150  TVector3 out_mom(out_momentum[0], out_momentum[1], out_momentum[2]);
151 
152  if (verbosity_) {
153  LogDebug("TotemTransport") << "output -> position: ";
154  out_pos.Print();
155  LogDebug("TotemTransport") << " momentum: ";
156  out_mom.Print();
157  }
158 
159  double px = -out_momentum[0]; // calculates px by means of TH_X, which is in the LHC ref. frame.
160  double py = out_momentum[1]; // this need to be checked again, since it seems an invertion is occuring in the prop.
161  double pz =
162  out_momentum[2]; // totem calculates output pz already in the CMS ref. frame, it doesn't need to be converted
163  double e = sqrt(px * px + py * py + pz * pz + ProtonMassSQ);
164  TLorentzVector p_out(px, py, pz, e);
165  double x1_ctpps = -out_position[0] * meter; // Totem parameterization uses meter, one need it in millimeter
166  double y1_ctpps = out_position[1] * meter;
167 
168  unsigned int line = in_trk->barcode();
169 
170  if (verbosity_)
171  LogDebug("TotemTransport") << "TotemTransport:filterPPS: barcode = " << line << " x= " << x1_ctpps
172  << " y= " << y1_ctpps;
173 
174  m_beamPart[line] = p_out;
175  m_xAtTrPoint[line] = x1_ctpps;
176  m_yAtTrPoint[line] = y1_ctpps;
177  return true;
178 }
Log< level::Info, true > LogVerbatim
bool Transport_m_GeV(double in_pos[3], double in_momentum[3], double out_pos[3], double out_momentum[3], bool check_apertures, double z2_z1_dist) const
pos, momentum: x,y,z; pos in m, momentum in GeV/c
static const double urad
LHCOpticsApproximator * m_aprox_ip_150_r_
T sqrt(T t)
Definition: SSEVec.h:19
double m_beampipe_aperture_radius_
Class finds the parametrisation of MADX proton transport and transports the protons according to it 5...
LHCOpticsApproximator * m_aprox_ip_150_l_
std::map< unsigned int, double > m_xAtTrPoint
void ApplyBeamCorrection(HepMC::GenParticle *p)
std::map< unsigned int, TLorentzVector > m_beamPart
static const double ProtonMassSQ
std::map< unsigned int, double > m_yAtTrPoint
#define LogDebug(id)

Member Data Documentation

◆ m_aprox_ip_150_l_

LHCOpticsApproximator* TotemTransport::m_aprox_ip_150_l_
private

Definition at line 31 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

◆ m_aprox_ip_150_r_

LHCOpticsApproximator* TotemTransport::m_aprox_ip_150_r_
private

Definition at line 30 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

◆ m_beampipe_aperture_radius_

double TotemTransport::m_beampipe_aperture_radius_
private

Definition at line 36 of file TotemTransport.h.

Referenced by transportProton().

◆ m_model_ip_150_l_name_

std::string TotemTransport::m_model_ip_150_l_name_
private

Definition at line 34 of file TotemTransport.h.

Referenced by TotemTransport().

◆ m_model_ip_150_r_name_

std::string TotemTransport::m_model_ip_150_r_name_
private

Definition at line 33 of file TotemTransport.h.

Referenced by TotemTransport().