CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ()
 
void setBeamEnergy (double e)
 
virtual ~BaseProtonTransport ()
 

Private Member Functions

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

Private Attributes

LHCOpticsApproximatorm_aprox_ip_150_l = nullptr
 
LHCOpticsApproximatorm_aprox_ip_150_r = nullptr
 
double m_beampipe_aperture_radius
 
double m_fEtacut
 
double m_fMomentumMin
 
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 Attributes inherited from BaseProtonTransport
bool bApplyZShift
 
std::string beam1Filename_
 
std::string beam2Filename_
 
double beamEnergy_
 
double beamMomentum_
 
CLHEP::HepRandomEngine * engine_
 
double etaCut_
 
double fCrossingAngleX_45
 
double fCrossingAngleX_56
 
double fCrossingAngleY_45
 
double fCrossingAngleY_56
 
double fPPSRegionStart_45
 
double fPPSRegionStart_56
 
std::map< unsigned int,
TLorentzVector > 
m_beamPart
 
std::vector< LHCTransportLinkm_CorrespondenceMap
 
double m_sig_E
 
double m_sigmaSTX
 
double m_sigmaSTY
 
double m_sigmaSX
 
double m_sigmaSY
 
std::map< unsigned int, double > m_xAtTrPoint
 
std::map< unsigned int, double > m_yAtTrPoint
 
TransportMode MODE
 
double momentumCut_
 
int NEvent
 
bool produceHitsRelativeToBeam_
 
bool useBeamPositionFromLHCInfo_
 
bool verbosity_
 

Detailed Description

Definition at line 23 of file TotemTransport.h.

Constructor & Destructor Documentation

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

Definition at line 10 of file TotemTransport.cc.

References BaseProtonTransport::beam1Filename_, BaseProtonTransport::beam2Filename_, BaseProtonTransport::beamEnergy_, beamvalidation::exit(), BaseProtonTransport::fCrossingAngleX_45, BaseProtonTransport::fCrossingAngleX_56, 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::m_sig_E, BaseProtonTransport::m_sigmaSTX, BaseProtonTransport::m_sigmaSTY, BaseProtonTransport::m_sigmaSX, BaseProtonTransport::m_sigmaSY, BaseProtonTransport::MODE, ReadParameterization(), AlCaHLTBitMon_QueryRunRegistry::string, and BaseProtonTransport::TOTEM.

12  m_model_ip_150_r_name(iConfig.getParameter<std::string>("Model_IP_150_R_Name")),
13  m_model_ip_150_l_name(iConfig.getParameter<std::string>("Model_IP_150_L_Name")),
14  m_beampipe_aperture_radius(iConfig.getParameter<double>("BeampipeApertureRadius")) {
16  beam1Filename_ = iConfig.getParameter<std::string>("Beam1Filename");
17  beam2Filename_ = iConfig.getParameter<std::string>("Beam2Filename");
18  fCrossingAngleX_45 = iConfig.getParameter<double>("halfCrossingAngleSector45");
19  fCrossingAngleX_56 = iConfig.getParameter<double>("halfCrossingAngleSector56");
20  beamEnergy_ = iConfig.getParameter<double>("BeamEnergy");
21  m_sigmaSTX = iConfig.getParameter<double>("BeamDivergenceX");
22  m_sigmaSTY = iConfig.getParameter<double>("BeamDivergenceY");
23  m_sigmaSX = iConfig.getParameter<double>("BeamSigmaX");
24  m_sigmaSY = iConfig.getParameter<double>("BeamSigmaY");
25  m_sig_E = iConfig.getParameter<double>("BeamEnergyDispersion");
26 
27  if (fPPSRegionStart_56 > 0)
28  fPPSRegionStart_56 *= -1; // make sure sector 56 has negative position, as TOTEM convention
29 
30  edm::LogInfo("TotemTransport") << "=============================================================================\n"
31  << " Bulding LHC Proton transporter based on TOTEM model\n"
32  << "=============================================================================\n";
33 
36 
37  if (m_aprox_ip_150_r == nullptr || m_aprox_ip_150_l == nullptr) {
38  edm::LogError("TotemTransport") << "Parameterisation " << m_model_ip_150_r_name << " or " << m_model_ip_150_l_name
39  << " missing in file. Cannot proceed. ";
40  exit(1);
41  }
42  edm::LogInfo("TotemTransport") << "Parameterizations read from file, pointers:" << m_aprox_ip_150_r << " "
43  << m_aprox_ip_150_l << " ";
44 }
BaseProtonTransport(const edm::ParameterSet &iConfig)
std::string m_model_ip_150_r_name
Log< level::Error, false > LogError
LHCOpticsApproximator * m_aprox_ip_150_l
std::string m_model_ip_150_l_name
Log< level::Info, false > LogInfo
double m_beampipe_aperture_radius
LHCOpticsApproximator * ReadParameterization(const std::string &, const std::string &)
LHCOpticsApproximator * m_aprox_ip_150_r
TotemTransport::~TotemTransport ( )
inlineoverride

Definition at line 26 of file TotemTransport.h.

26 {};

Member Function Documentation

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

Implements BaseProtonTransport.

Definition at line 49 of file TotemTransport.cc.

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

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

Definition at line 176 of file TotemTransport.cc.

References validate-o2o-wbm::f, and MillePedeFileConverter_cfg::fileName.

Referenced by TotemTransport().

177  {
179  TFile* f = TFile::Open(fileName.fullPath().c_str(), "read");
180  if (!f) {
181  edm::LogError("TotemTransport") << "File " << fileName << " not found. Exiting.";
182  return nullptr;
183  }
184  edm::LogInfo("TotemTransport") << "Root file opened, pointer:" << f;
185 
186  // read parametrization
187  LHCOpticsApproximator* aprox = (LHCOpticsApproximator*)f->Get(m_model_name.c_str());
188  f->Close();
189  return aprox;
190 }
Log< level::Error, false > LogError
Class finds the parametrisation of MADX proton transport and transports the protons according to it 5...
Log< level::Info, false > LogInfo
bool TotemTransport::transportProton ( const HepMC::GenParticle *  in_trk)
private

Definition at line 82 of file TotemTransport.cc.

References BaseProtonTransport::ApplyBeamCorrection(), alignCSCRings::e, BaseProtonTransport::fCrossingAngleX_45, BaseProtonTransport::fCrossingAngleX_56, BaseProtonTransport::fPPSRegionStart_45, BaseProtonTransport::fPPSRegionStart_56, geometryCSVtoXML::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, mathSSE::sqrt(), LHCOpticsApproximator::Transport_m_GeV(), urad, and BaseProtonTransport::verbosity_.

Referenced by process().

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

Member Data Documentation

LHCOpticsApproximator* TotemTransport::m_aprox_ip_150_l = nullptr
private

Definition at line 35 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

LHCOpticsApproximator* TotemTransport::m_aprox_ip_150_r = nullptr
private

Definition at line 34 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

double TotemTransport::m_beampipe_aperture_radius
private

Definition at line 40 of file TotemTransport.h.

Referenced by transportProton().

double TotemTransport::m_fEtacut
private

Definition at line 41 of file TotemTransport.h.

double TotemTransport::m_fMomentumMin
private

Definition at line 42 of file TotemTransport.h.

std::string TotemTransport::m_model_ip_150_l_name
private

Definition at line 38 of file TotemTransport.h.

Referenced by TotemTransport().

std::string TotemTransport::m_model_ip_150_r_name
private

Definition at line 37 of file TotemTransport.h.

Referenced by TotemTransport().