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:
ProtonTransport

Public Member Functions

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

Private Member Functions

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

Private Attributes

LHCOpticsApproximatorm_aprox_ip_150_l = 0
 
LHCOpticsApproximatorm_aprox_ip_150_r = 0
 
double m_beampipe_aperture_radius
 
double m_fEtacut
 
double m_fMomentumMin
 
std::string m_model_ip_150_l_name
 
double m_model_ip_150_l_zmax
 
double m_model_ip_150_l_zmin
 
std::string m_model_ip_150_r_name
 
double m_model_ip_150_r_zmax
 
double m_model_ip_150_r_zmin
 
std::string m_model_root_file_l
 
std::string m_model_root_file_r
 
edm::FileInPath m_opticsFileBeam1_
 
edm::FileInPath m_opticsFileBeam2_
 
edm::ParameterSet m_parameters
 
edm::ESHandle< ParticleDataTablem_pdt
 
edm::EDGetTokenT< edm::HepMCProductm_protonsToken_
 
bool m_verbosity
 
double m_Zin_
 
double m_Zout_
 

Additional Inherited Members

- Protected Types inherited from ProtonTransport
enum  TransportMode { TransportMode::HECTOR, TransportMode::TOTEM }
 
- Protected Attributes inherited from ProtonTransport
bool bApplyZShift
 
CLHEP::HepRandomEngine * engine
 
double fBeamEnergy
 
double fBeamMomentum
 
double fBeamXatIP
 
double fBeamYatIP
 
double fCrossingAngle_45
 
double fCrossingAngle_56
 
double fPPSRegionStart_45
 
double fPPSRegionStart_56
 
double fVtxMeanX
 
double fVtxMeanY
 
double fVtxMeanZ
 
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
 
bool m_verbosity
 
std::map< unsigned int, double > m_xAtTrPoint
 
std::map< unsigned int, double > m_yAtTrPoint
 
TransportMode MODE
 
int NEvent
 

Detailed Description

Definition at line 22 of file TotemTransport.h.

Constructor & Destructor Documentation

TotemTransport::TotemTransport ( const edm::ParameterSet ps,
bool  verbosity 
)

Definition at line 12 of file TotemTransport.cc.

References ProtonTransport::bApplyZShift, beamvalidation::exit(), ProtonTransport::fBeamEnergy, ProtonTransport::fBeamMomentum, ProtonTransport::fBeamXatIP, ProtonTransport::fBeamYatIP, ProtonTransport::fCrossingAngle_45, ProtonTransport::fCrossingAngle_56, ProtonTransport::fPPSRegionStart_45, ProtonTransport::fPPSRegionStart_56, ProtonTransport::fVtxMeanX, ProtonTransport::fVtxMeanY, ProtonTransport::fVtxMeanZ, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_aprox_ip_150_l, m_aprox_ip_150_r, m_model_ip_150_l_name, m_model_ip_150_l_zmax, m_model_ip_150_r_name, m_model_ip_150_r_zmax, m_model_root_file_l, m_model_root_file_r, m_parameters, ProtonTransport::m_sig_E, ProtonTransport::m_sigmaSTX, ProtonTransport::m_sigmaSTY, ProtonTransport::MODE, ProtonMassSQ, ReadParameterization(), mathSSE::sqrt(), and ProtonTransport::TOTEM.

13  : ProtonTransport(),
14  m_parameters(iConfig.getParameter<edm::ParameterSet>("BeamProtTransportSetup")),
15  m_verbosity(iConfig.getParameter<bool>("Verbosity")),
20  m_model_ip_150_r_zmin(m_parameters.getParameter<double>("Model_IP_150_R_Zmin")),
21  m_model_ip_150_r_zmax(m_parameters.getParameter<double>("Model_IP_150_R_Zmax")),
22  m_model_ip_150_l_zmin(m_parameters.getParameter<double>("Model_IP_150_L_Zmin")),
23  m_model_ip_150_l_zmax(m_parameters.getParameter<double>("Model_IP_150_L_Zmax")),
24  m_beampipe_aperture_radius(m_parameters.getParameter<double>("BeampipeApertureRadius")) {
25  fBeamEnergy = m_parameters.getParameter<double>("sqrtS");
26  m_sigmaSTX = m_parameters.getParameter<double>("beamDivergenceX");
27  m_sigmaSTY = m_parameters.getParameter<double>("beamDivergenceY");
28  m_sig_E = m_parameters.getParameter<double>("beamEnergyDispersion");
29  fCrossingAngle_45 = m_parameters.getParameter<double>("halfCrossingAngleSector45");
30  fCrossingAngle_56 = m_parameters.getParameter<double>("halfCrossingAngleSector56");
31  fVtxMeanX = iConfig.getParameter<double>("VtxMeanX");
32  fVtxMeanY = iConfig.getParameter<double>("VtxMeanY");
33  fVtxMeanZ = iConfig.getParameter<double>("VtxMeanZ");
36  bApplyZShift = m_parameters.getParameter<bool>("ApplyZShift");
37 
39  edm::LogInfo("ProtonTransport") << "=============================================================================\n"
40  << " Bulding LHC Proton transporter based on TOTEM model\n"
41  << "=============================================================================\n";
42 
44 
47 
50 
51  if (m_aprox_ip_150_r == nullptr || m_aprox_ip_150_l == nullptr) {
52  edm::LogError("ProtonTransport") << "Parameterisation " << m_model_ip_150_r_name << " or " << m_model_ip_150_l_name
53  << " missing in file. Cannot proceed. ";
54  exit(1);
55  }
56  edm::LogInfo("TotemRPProtonTransportSetup")
57  << "Parameterizations read from file, pointers:" << m_aprox_ip_150_r << " " << m_aprox_ip_150_l << " ";
58 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
double fPPSRegionStart_45
edm::ParameterSet m_parameters
double m_model_ip_150_l_zmax
double m_model_ip_150_l_zmin
TransportMode MODE
std::string m_model_ip_150_r_name
double fCrossingAngle_45
LHCOpticsApproximator * m_aprox_ip_150_l
double fCrossingAngle_56
std::string m_model_ip_150_l_name
T sqrt(T t)
Definition: SSEVec.h:19
double fPPSRegionStart_56
std::string m_model_root_file_l
double m_model_ip_150_r_zmin
std::string m_model_root_file_r
double m_beampipe_aperture_radius
LHCOpticsApproximator * ReadParameterization(const std::string &, const std::string &)
LHCOpticsApproximator * m_aprox_ip_150_r
static const double ProtonMassSQ
double m_model_ip_150_r_zmax
def exit(msg="")
TotemTransport::TotemTransport ( )
TotemTransport::~TotemTransport ( )
override

Definition at line 11 of file TotemTransport.cc.

References ProtonTransport::clear().

11 { this->clear(); }

Member Function Documentation

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

Adds the stable protons from the event ev to a beamline

Implements ProtonTransport.

Definition at line 59 of file TotemTransport.cc.

References ProtonTransport::addPartToHepMC(), ProtonTransport::engine, GenParticle::GenParticle, mps_splice::line, ProtonTransport::m_beamPart, and transportProton().

61  {
62  engine = _engine;
63 
64  for (HepMC::GenEvent::particle_const_iterator eventParticle = evt->particles_begin();
65  eventParticle != evt->particles_end();
66  ++eventParticle) {
67  if (!((*eventParticle)->status() == 1 && (*eventParticle)->pdg_id() == 2212))
68  continue;
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 /*&& gpart->status()<83 */)
74  continue;
75  if (m_beamPart.find(line) != m_beamPart.end())
76  continue;
77 
78  transportProton(gpart);
79  }
80  addPartToHepMC(const_cast<HepMC::GenEvent*>(evt));
81 }
std::map< unsigned int, TLorentzVector > m_beamPart
bool transportProton(const HepMC::GenParticle *)
void addPartToHepMC(HepMC::GenEvent *)
CLHEP::HepRandomEngine * engine
LHCOpticsApproximator * TotemTransport::ReadParameterization ( const std::string &  m_model_name,
const std::string &  rootfile 
)
private

Definition at line 170 of file TotemTransport.cc.

References f, and MillePedeFileConverter_cfg::fileName.

Referenced by TotemTransport().

171  {
173  TFile* f = TFile::Open(fileName.fullPath().c_str(), "read");
174  if (!f) {
175  edm::LogError("TotemRPProtonTransportSetup") << "File " << fileName << " not found. Exiting.";
176  return nullptr;
177  }
178  edm::LogInfo("TotemRPProtonTransportSetup") << "Root file opened, pointer:" << f;
179 
180  // read parametrization
181  LHCOpticsApproximator* aprox = (LHCOpticsApproximator*)f->Get(m_model_name.c_str());
182  f->Close();
183  return aprox;
184 }
double f[11][100]
Class finds the parametrisation of MADX proton transport and transports the protons according to it 5...
bool TotemTransport::transportProton ( const HepMC::GenParticle *  in_trk)
private

Definition at line 82 of file TotemTransport.cc.

References ProtonTransport::ApplyBeamCorrection(), MillePedeFileConverter_cfg::e, ProtonTransport::fBeamXatIP, ProtonTransport::fBeamYatIP, ProtonTransport::fCrossingAngle_45, ProtonTransport::fCrossingAngle_56, ProtonTransport::fVtxMeanX, ProtonTransport::fVtxMeanY, ProtonTransport::fVtxMeanZ, mps_splice::line, LogDebug, m_aprox_ip_150_l, m_aprox_ip_150_r, ProtonTransport::m_beamPart, m_beampipe_aperture_radius, m_model_ip_150_l_zmax, m_model_ip_150_l_zmin, m_model_ip_150_r_zmax, m_model_ip_150_r_zmin, m_verbosity, ProtonTransport::m_xAtTrPoint, ProtonTransport::m_yAtTrPoint, m_Zin_, m_Zout_, ProtonMassSQ, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, mathSSE::sqrt(), funct::tan(), LHCOpticsApproximator::Transport_m_GeV(), and urad.

Referenced by process().

82  {
83  edm::LogInfo("ProtonTransport") << "Starting proton transport using TOTEM method\n";
84  ApplyBeamCorrection(const_cast<HepMC::GenParticle*>(in_trk));
85 
86  const HepMC::GenVertex* in_pos = in_trk->production_vertex();
87  const HepMC::FourVector in_mom = in_trk->momentum();
88  //
89  // ATTENTION: HepMC uses mm, vertex config of CMS uses cm and SimTransport uses mm
90  //
91  double in_position[3] = {(in_pos->position().x() - fVtxMeanX * cm) / meter + fBeamXatIP * mm / meter,
92  (in_pos->position().y() - fVtxMeanY * cm) / meter + fBeamYatIP * mm / meter,
93  (in_pos->position().z() - fVtxMeanZ * cm) / meter}; // move to z=0 if configured below
94 
95  // (bApplyZShift) -- The TOTEM parameterization requires the shift to z=0
96  double fCrossingAngle = (in_mom.z() > 0) ? fCrossingAngle_45 : -fCrossingAngle_56;
97  in_position[0] = in_position[0] +
98  (tan((long double)fCrossingAngle * urad) - ((long double)in_mom.x()) / ((long double)in_mom.z())) *
99  in_position[2];
100  in_position[1] = in_position[1] - ((long double)in_mom.y()) / ((long double)in_mom.z()) * in_position[2];
101  in_position[2] = 0.;
102  //
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("ProtonTransport") << "before transport ->"
107  << " position: " << in_position[0] << ", " << in_position[1] << ", " << in_position[2]
108  << " momentum: " << in_momentum[0] << ", " << in_momentum[1] << ", "
109  << in_momentum[2];
110 
111  LHCOpticsApproximator* approximator_ = nullptr;
112  if (in_mom.z() > 0) {
113  approximator_ = m_aprox_ip_150_l;
116  } else {
117  approximator_ = m_aprox_ip_150_r;
120  }
121 
122  bool invert_beam_coord_system =
123  true; // it doesn't matter the option here, it is hard coded as TRUE inside LHCOpticsApproximator!
124 
125  bool tracked = approximator_->Transport_m_GeV(
126  in_position, in_momentum, out_position, out_momentum, invert_beam_coord_system, m_Zout_ - m_Zin_);
127 
128  if (!tracked)
129  return false;
130 
131  edm::LogInfo("ProtonTransport") << "after transport -> "
132  << "position: " << out_position[0] << ", " << out_position[1] << ", "
133  << out_position[2] << "momentum: " << out_momentum[0] << ", " << out_momentum[1]
134  << ", " << out_momentum[2];
135 
136  if (out_position[0] * out_position[0] + out_position[1] * out_position[1] >
138  edm::LogInfo("ProtonTransport") << "Proton ouside beampipe";
139  edm::LogInfo("ProtonTransport") << "===== END Transport "
140  << "====================";
141  return false;
142  }
143 
144  TVector3 out_pos(out_position[0] * meter, out_position[1] * meter, out_position[2] * meter);
145  TVector3 out_mom(out_momentum[0], out_momentum[1], out_momentum[2]);
146  edm::LogInfo("TotemRPProtonTransportModel") << "output -> "
147  << "position: ";
148  out_pos.Print();
149  edm::LogInfo("TotemRPProtonTransportModel") << " momentum: ";
150  out_mom.Print();
151  double px = -out_momentum[0];
152  double py = out_momentum[1]; // this need to be checked again, since it seems an invertion is occuring in the prop.
153  double pz = out_momentum[2];
154  double e = sqrt(px * px + py * py + pz * pz + ProtonMassSQ);
155  TLorentzVector p_out(px, py, pz, e);
156  double x1_ctpps = -out_position[0] * meter; // Totem parameterization uses meter, one need it in millimeter
157  double y1_ctpps = -out_position[1] * meter;
158 
159  unsigned int line = in_trk->barcode();
160 
161  if (m_verbosity)
162  LogDebug("ProtonTransportEventProcessing")
163  << "ProtonTransport:filterPPS: barcode = " << line << " x= " << x1_ctpps << " y= " << y1_ctpps;
164 
165  m_beamPart[line] = p_out;
166  m_xAtTrPoint[line] = x1_ctpps;
167  m_yAtTrPoint[line] = y1_ctpps;
168  return true;
169 }
#define LogDebug(id)
void ApplyBeamCorrection(HepMC::GenParticle *p)
double m_model_ip_150_l_zmax
double m_model_ip_150_l_zmin
std::map< unsigned int, TLorentzVector > m_beamPart
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
std::map< unsigned int, double > m_yAtTrPoint
static const double urad
double fCrossingAngle_45
LHCOpticsApproximator * m_aprox_ip_150_l
std::map< unsigned int, double > m_xAtTrPoint
double fCrossingAngle_56
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double m_model_ip_150_r_zmin
Class finds the parametrisation of MADX proton transport and transports the protons according to it 5...
double m_beampipe_aperture_radius
LHCOpticsApproximator * m_aprox_ip_150_r
static const double ProtonMassSQ
double m_model_ip_150_r_zmax

Member Data Documentation

LHCOpticsApproximator* TotemTransport::m_aprox_ip_150_l = 0
private

Definition at line 39 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

LHCOpticsApproximator* TotemTransport::m_aprox_ip_150_r = 0
private

Definition at line 38 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

double TotemTransport::m_beampipe_aperture_radius
private

Definition at line 56 of file TotemTransport.h.

Referenced by transportProton().

double TotemTransport::m_fEtacut
private

Definition at line 59 of file TotemTransport.h.

double TotemTransport::m_fMomentumMin
private

Definition at line 60 of file TotemTransport.h.

std::string TotemTransport::m_model_ip_150_l_name
private

Definition at line 43 of file TotemTransport.h.

Referenced by TotemTransport().

double TotemTransport::m_model_ip_150_l_zmax
private

Definition at line 47 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

double TotemTransport::m_model_ip_150_l_zmin
private

Definition at line 46 of file TotemTransport.h.

Referenced by transportProton().

std::string TotemTransport::m_model_ip_150_r_name
private

Definition at line 42 of file TotemTransport.h.

Referenced by TotemTransport().

double TotemTransport::m_model_ip_150_r_zmax
private

Definition at line 45 of file TotemTransport.h.

Referenced by TotemTransport(), and transportProton().

double TotemTransport::m_model_ip_150_r_zmin
private

Definition at line 44 of file TotemTransport.h.

Referenced by transportProton().

std::string TotemTransport::m_model_root_file_l
private

Definition at line 41 of file TotemTransport.h.

Referenced by TotemTransport().

std::string TotemTransport::m_model_root_file_r
private

Definition at line 40 of file TotemTransport.h.

Referenced by TotemTransport().

edm::FileInPath TotemTransport::m_opticsFileBeam1_
private

Definition at line 52 of file TotemTransport.h.

edm::FileInPath TotemTransport::m_opticsFileBeam2_
private

Definition at line 52 of file TotemTransport.h.

edm::ParameterSet TotemTransport::m_parameters
private

Definition at line 36 of file TotemTransport.h.

Referenced by TotemTransport().

edm::ESHandle<ParticleDataTable> TotemTransport::m_pdt
private

Definition at line 54 of file TotemTransport.h.

edm::EDGetTokenT<edm::HepMCProduct> TotemTransport::m_protonsToken_
private

Definition at line 49 of file TotemTransport.h.

bool TotemTransport::m_verbosity
private

Definition at line 37 of file TotemTransport.h.

Referenced by transportProton().

double TotemTransport::m_Zin_
private

Definition at line 57 of file TotemTransport.h.

Referenced by transportProton().

double TotemTransport::m_Zout_
private

Definition at line 58 of file TotemTransport.h.

Referenced by transportProton().