CMS 3D CMS Logo

HectorTransport.cc
Go to the documentation of this file.
3 #include <CLHEP/Random/RandGauss.h>
4 #include "TLorentzVector.h"
5 //Hector headers
6 #include "H_BeamLine.h"
7 #include "H_BeamParticle.h"
8 #include <memory>
9 
10 #include <string>
11 
13 
15  : BaseProtonTransport(iConfig), m_beamline45(nullptr), m_beamline56(nullptr) {
16  // Create LHC beam line
17  MODE = TransportMode::HECTOR; // defines the MODE for the transport
18  beam1Filename_ = iConfig.getParameter<std::string>("Beam1Filename");
19  beam2Filename_ = iConfig.getParameter<std::string>("Beam2Filename");
20  fCrossingAngleX_45 = iConfig.getParameter<double>("halfCrossingAngleXSector45");
21  fCrossingAngleX_56 = iConfig.getParameter<double>("halfCrossingAngleXSector56");
22  fCrossingAngleY_45 = iConfig.getParameter<double>("halfCrossingAngleYSector45");
23  fCrossingAngleY_56 = iConfig.getParameter<double>("halfCrossingAngleYSector56");
24  beamEnergy_ = iConfig.getParameter<double>("BeamEnergy");
25  m_sigmaSTX = iConfig.getParameter<double>("BeamDivergenceX");
26  m_sigmaSTY = iConfig.getParameter<double>("BeamDivergenceY");
27  m_sigmaSX = iConfig.getParameter<double>("BeamSigmaX");
28  m_sigmaSY = iConfig.getParameter<double>("BeamSigmaY");
29  m_sig_E = iConfig.getParameter<double>("BeamEnergyDispersion");
30  fBeamXatIP = iConfig.getUntrackedParameter<double>("BeamXatIP", 0.);
31  fBeamYatIP = iConfig.getUntrackedParameter<double>("BeamYatIP", 0.);
32  produceHitsRelativeToBeam_ = iConfig.getParameter<bool>("produceHitsRelativeToBeam");
33 
34  //PPS
35  edm::LogInfo("ProtonTransport") << "=============================================================================\n"
36  << " Bulding LHC Proton transporter based on HECTOR model\n"
37  << "=============================================================================\n";
38  setBeamLine();
39 }
40 //
41 // this method is the same for all propagator, but since transportProton is different for each derived class
42 // it needes to be overriden
43 //
45  const edm::EventSetup& iSetup,
46  CLHEP::HepRandomEngine* _engine) {
47  this->clear();
48 
49  engine_ = _engine; // the engine needs to be updated for each event
50 
51  for (HepMC::GenEvent::particle_const_iterator eventParticle = evt->particles_begin();
52  eventParticle != evt->particles_end();
53  ++eventParticle) {
54  if (!((*eventParticle)->status() == 1 && (*eventParticle)->pdg_id() == 2212))
55  continue;
56 
57  if (!(fabs((*eventParticle)->momentum().eta()) > etaCut_ && fabs((*eventParticle)->momentum().pz()) > momentumCut_))
58  continue; // discard protons outside kinematic acceptance
59 
60  unsigned int line = (*eventParticle)->barcode();
61  HepMC::GenParticle* gpart = (*eventParticle);
62 
63  if (gpart->pdg_id() != 2212)
64  continue; // only transport stable protons
65  if (gpart->status() != 1)
66  continue;
67  if (m_beamPart.find(line) != m_beamPart.end())
68  continue; // assures this protons has not been already propagated
69 
70  transportProton(gpart);
71  }
72 }
74  edm::LogInfo("ProtonTransport") << "Starting proton transport using HECTOR method\n";
75 
76  double px, py, pz, e;
77  unsigned int line = (gpart)->barcode();
78 
79  double mass = gpart->generatedMass();
80  double charge = 1.;
81 
82  // Momentum in LHC ref. frame
83  px = -gpart->momentum().px();
84  py = gpart->momentum().py();
85  pz = -gpart->momentum().pz();
86  e = gpart->momentum().e();
87 
88  int direction = (pz > 0) ? 1 : -1; // in relation to LHC ref frame
89 
90  double XforPosition = -gpart->production_vertex()->position().x(); //mm in the ref. frame of LHC
91  double YforPosition = gpart->production_vertex()->position().y(); //mm
92  double ZforPosition = -gpart->production_vertex()->position().z(); //mm
93  double fCrossingAngleX = (pz < 0) ? fCrossingAngleX_45 : fCrossingAngleX_56;
94  double fCrossingAngleY = (pz < 0) ? fCrossingAngleY_45 : fCrossingAngleY_56;
95 
96  H_BeamParticle h_p(mass, charge);
97  h_p.set4Momentum(px, py, pz, e);
98  //
99  // shift the starting position of the track to Z=0 if configured so (all the variables below are still in cm)
100  XforPosition = XforPosition - ZforPosition * (px / pz + fCrossingAngleX * urad); // theta ~=tan(theta)
101  YforPosition = YforPosition - ZforPosition * (py / pz + fCrossingAngleY * urad);
102  ZforPosition = 0.;
103 
104  // set position, but do not invert the coordinate for the angles (TX,TY) because it is done by set4Momentum
105  h_p.setPosition(XforPosition * mm_to_um, YforPosition * mm_to_um, h_p.getTX(), h_p.getTY(), 0.);
106 
107  bool is_stop;
108  float x1_ctpps;
109  float y1_ctpps;
110 
111  H_BeamLine* _beamline = nullptr;
112  double _targetZ = 0;
113  switch (direction) {
114  case 1:
115  _beamline = &*m_beamline56; // negative side propagation
116  _targetZ = fPPSRegionStart_56;
117  break;
118  case -1:
119  _beamline = &*m_beamline45;
120  _targetZ = fPPSRegionStart_45;
121  break;
122  }
123  // insert protection for NULL beamlines here
124  h_p.computePath(&*_beamline);
125  is_stop = h_p.stopped(&*_beamline);
126  if (verbosity_)
127  LogDebug("HectorTransportEventProcessing")
128  << "HectorTransport:filterPPS: barcode = " << line << " is_stop= " << is_stop;
129  if (is_stop) {
130  return false;
131  }
132  //
133  //propagating
134  //
135  h_p.propagate(_targetZ);
136  x1_ctpps = h_p.getX();
137  y1_ctpps = h_p.getY();
138 
139  double thx = h_p.getTX();
140  double thy = h_p.getTY();
141 
143  H_BeamParticle p_beam(mass, charge);
144  p_beam.set4Momentum(0., 0., beamMomentum_, beamEnergy_);
145  p_beam.setPosition(0., 0., fCrossingAngleX * urad, fCrossingAngleY * urad, 0.);
146  p_beam.computePath(&*_beamline);
147  thx -= p_beam.getTX();
148  thy -= p_beam.getTY();
149  x1_ctpps -= p_beam.getX();
150  y1_ctpps -= p_beam.getY();
151  }
152 
153  double partP = sqrt(pow(h_p.getE(), 2) - ProtonMassSQ);
154  double theta = sqrt(thx * thx + thy * thy) * urad;
155 
156  // copy the kinematic changing to CMS ref. frame, only the negative Pz needs to be changed
157  TLorentzVector p_out(-tan(thx * urad) * partP * cos(theta),
158  tan(thy * urad) * partP * cos(theta),
159  -direction * partP * cos(theta),
160  h_p.getE());
161 
162  m_beamPart[line] = p_out;
163  m_xAtTrPoint[line] = -x1_ctpps * um_to_mm; // move to CMS ref. frame
164  m_yAtTrPoint[line] = y1_ctpps * um_to_mm;
165  if (verbosity_)
166  LogDebug("HectorTransportEventProcessing")
167  << "HectorTransport:filterPPS: barcode = " << line << " x= " << x1_ctpps << " y= " << y1_ctpps;
168 
169  return true;
170 }
174 
175  // construct beam line for PPS (forward 1 backward 2):
176  if (fPPSBeamLineLength_ > 0.) {
177  m_beamline45 = std::make_unique<H_BeamLine>(
178  -1, fPPSBeamLineLength_ + 0.1); // it is needed to move too (direction, length, beamEnergy_)
179  m_beamline45->fill(b2.fullPath(), 1, "IP5");
180  m_beamline56 = std::make_unique<H_BeamLine>(
181  1, fPPSBeamLineLength_ + 0.1); // the same as above, it requires a change in HECTOR
182  m_beamline56->fill(b1.fullPath(), 1, "IP5");
183  } else {
184  if (verbosity_)
185  LogDebug("HectorTransportSetup") << "HectorTransport: WARNING: lengthctpps= " << fPPSBeamLineLength_;
186  return false;
187  }
188  if (verbosity_) {
189  edm::LogInfo("HectorTransportSetup") << "===================================================================\n"
190  << " * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n"
191  << " * * \n"
192  << " * --<--<-- A fast simulator --<--<-- * \n"
193  << " * | --<--<-- of particle --<--<-- * \n"
194  << " * ----HECTOR----< * \n"
195  << " * | -->-->-- transport through-->-->-- * \n"
196  << " * -->-->-- generic beamlines -->-->-- * \n"
197  << " * * \n"
198  << " * JINST 2:P09005 (2007) * \n"
199  << " * X Rouby, J de Favereau, K Piotrzkowski (CP3) * \n"
200  << " * http://www.fynu.ucl.ac.be/hector.html * \n"
201  << " * * \n"
202  << " * Center for Cosmology, Particle Physics and Phenomenology * \n"
203  << " * Universite catholique de Louvain * \n"
204  << " * Louvain-la-Neuve, Belgium * \n"
205  << " * * \n"
206  << " * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n"
207  << " HectorTransport configuration: \n"
208  << " Beam line length = " << fPPSBeamLineLength_ << "\n"
209  << " PPS Region Start 44 = " << fPPSRegionStart_45 << "\n"
210  << " PPS Region Start 56 = " << fPPSRegionStart_56 << "\n"
211  << "===================================================================\n";
212  }
213  if (verbosity_) {
214  edm::LogInfo("HectorTransportSetup") << "====================================================================\n"
215  << " Forward beam line elements \n";
216  m_beamline45->showElements();
217  edm::LogInfo("HectorTransportSetup") << "====================================================================\n"
218  << " Backward beam line elements \n";
219  m_beamline56->showElements();
220  }
221  return true;
222 }
BaseProtonTransport::beam2Filename_
std::string beam2Filename_
Definition: BaseProtonTransport.h:55
BaseProtonTransport::beamMomentum_
double beamMomentum_
Definition: BaseProtonTransport.h:64
BaseProtonTransport::m_sigmaSTY
double m_sigmaSTY
Definition: BaseProtonTransport.h:70
BaseProtonTransport::clear
void clear()
Definition: BaseProtonTransport.cc:109
BaseProtonTransport::MODE
TransportMode MODE
Definition: BaseProtonTransport.h:42
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
HectorTransport::transportProton
bool transportProton(const HepMC::GenParticle *)
propagate the particles through a beamline to PPS
Definition: HectorTransport.cc:73
BaseProtonTransport::verbosity_
bool verbosity_
Definition: BaseProtonTransport.h:51
BaseProtonTransport::fPPSRegionStart_45
double fPPSRegionStart_45
Definition: BaseProtonTransport.h:57
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
BaseProtonTransport::TransportMode::HECTOR
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
b2
static constexpr float b2
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
um_to_mm
static const double um_to_mm
Definition: PPSUnitConversion.h:11
BaseProtonTransport::momentumCut_
double momentumCut_
Definition: BaseProtonTransport.h:67
BaseProtonTransport::m_sig_E
double m_sig_E
Definition: BaseProtonTransport.h:73
BaseProtonTransport::m_sigmaSY
double m_sigmaSY
Definition: BaseProtonTransport.h:72
PPSUtilities.h
BaseProtonTransport::fPPSRegionStart_56
double fPPSRegionStart_56
Definition: BaseProtonTransport.h:58
BaseProtonTransport::beam1Filename_
std::string beam1Filename_
Definition: BaseProtonTransport.h:54
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
b1
static constexpr float b1
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
edm::FileInPath
Definition: FileInPath.h:64
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
mm_to_um
static const double mm_to_um
Definition: PPSUnitConversion.h:13
BaseProtonTransport::m_sigmaSX
double m_sigmaSX
Definition: BaseProtonTransport.h:71
HectorTransport::fPPSBeamLineLength_
static constexpr double fPPSBeamLineLength_
Definition: HectorTransport.h:46
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
HectorTransport::process
void process(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine) override
Definition: HectorTransport.cc:44
BaseProtonTransport::fCrossingAngleY_45
double fCrossingAngleY_45
Definition: BaseProtonTransport.h:61
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
BaseProtonTransport::fCrossingAngleX_45
double fCrossingAngleX_45
Definition: BaseProtonTransport.h:59
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
ProtonMassSQ
static const double ProtonMassSQ
Definition: PPSUnitConversion.h:6
HectorTransport::m_beamline56
std::unique_ptr< H_BeamLine > m_beamline56
Definition: HectorTransport.h:61
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
BaseProtonTransport::etaCut_
double etaCut_
Definition: BaseProtonTransport.h:66
BaseProtonTransport::fBeamXatIP
double fBeamXatIP
Definition: BaseProtonTransport.h:74
HectorTransport::HectorTransport
HectorTransport(const edm::ParameterSet &ps)
Definition: HectorTransport.cc:14
BaseProtonTransport::m_beamPart
std::map< unsigned int, TLorentzVector > m_beamPart
Definition: BaseProtonTransport.h:47
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
urad
static const double urad
Definition: PPSUnitConversion.h:10
BaseProtonTransport
Definition: BaseProtonTransport.h:17
edm::EventSetup
Definition: EventSetup.h:58
BaseProtonTransport::engine_
CLHEP::HepRandomEngine * engine_
Definition: BaseProtonTransport.h:45
BaseProtonTransport::fCrossingAngleY_56
double fCrossingAngleY_56
Definition: BaseProtonTransport.h:62
HectorTransport.h
HectorTransport::m_beamline45
std::unique_ptr< H_BeamLine > m_beamline45
Definition: HectorTransport.h:60
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
BaseProtonTransport::m_yAtTrPoint
std::map< unsigned int, double > m_yAtTrPoint
Definition: BaseProtonTransport.h:49
BaseProtonTransport::m_sigmaSTX
double m_sigmaSTX
Definition: BaseProtonTransport.h:69
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
BaseProtonTransport::beamEnergy_
double beamEnergy_
Definition: BaseProtonTransport.h:65
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
BaseProtonTransport::m_xAtTrPoint
std::map< unsigned int, double > m_xAtTrPoint
Definition: BaseProtonTransport.h:48
BaseProtonTransport::fCrossingAngleX_56
double fCrossingAngleX_56
Definition: BaseProtonTransport.h:60
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
BaseProtonTransport::fBeamYatIP
double fBeamYatIP
Definition: BaseProtonTransport.h:75
HectorTransport::produceHitsRelativeToBeam_
bool produceHitsRelativeToBeam_
Definition: HectorTransport.h:44
mps_splice.line
line
Definition: mps_splice.py:76
HectorTransport::~HectorTransport
~HectorTransport() override
Definition: HectorTransport.cc:12
HectorTransport::setBeamLine
bool setBeamLine()
Definition: HectorTransport.cc:171
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37