CMS 3D CMS Logo

OpticalFunctionsTransport.cc
Go to the documentation of this file.
3 
5  : BaseProtonTransport(iConfig),
6  lhcInfoLabel_(iConfig.getParameter<std::string>("lhcInfoLabel")),
7  opticsLabel_(iConfig.getParameter<std::string>("opticsLabel")),
8  useEmpiricalApertures_(iConfig.getParameter<bool>("useEmpiricalApertures")),
9  empiricalAperture45_xi0_int_(iConfig.getParameter<double>("empiricalAperture45_xi0_int")),
10  empiricalAperture45_xi0_slp_(iConfig.getParameter<double>("empiricalAperture45_xi0_slp")),
11  empiricalAperture45_a_int_(iConfig.getParameter<double>("empiricalAperture45_a_int")),
12  empiricalAperture45_a_slp_(iConfig.getParameter<double>("empiricalAperture45_a_slp")),
13  empiricalAperture56_xi0_int_(iConfig.getParameter<double>("empiricalAperture56_xi0_int")),
14  empiricalAperture56_xi0_slp_(iConfig.getParameter<double>("empiricalAperture56_xi0_slp")),
15  empiricalAperture56_a_int_(iConfig.getParameter<double>("empiricalAperture56_a_int")),
16  empiricalAperture56_a_slp_(iConfig.getParameter<double>("empiricalAperture56_a_slp")),
17  produceHitsRelativeToBeam_(iConfig.getParameter<bool>("produceHitsRelativeToBeam")) {
19 }
21  const edm::EventSetup& iSetup,
22  CLHEP::HepRandomEngine* _engine) {
23  this->clear();
24 
28 
29  engine_ = _engine; // the engine needs to be updated for each event
30 
31  for (HepMC::GenEvent::particle_const_iterator eventParticle = evt->particles_begin();
32  eventParticle != evt->particles_end();
33  ++eventParticle) {
34  if (!((*eventParticle)->status() == 1 && (*eventParticle)->pdg_id() == 2212))
35  continue;
36 
37  if (!(fabs((*eventParticle)->momentum().eta()) > etaCut_ && fabs((*eventParticle)->momentum().pz()) > momentumCut_))
38  continue; // discard protons outside kinematic acceptance
39 
40  unsigned int line = (*eventParticle)->barcode();
41  HepMC::GenParticle* gpart = (*eventParticle);
42  if (gpart->pdg_id() != 2212)
43  continue; // only transport stable protons
44  if (gpart->status() != 1)
45  continue;
46  if (m_beamPart.find(line) != m_beamPart.end()) // assures this protons has not been already propagated
47  continue;
48 
49  transportProton(gpart);
50  }
51 }
52 
54  const HepMC::FourVector& vtx_cms = in_trk->production_vertex()->position(); // in mm
55  const HepMC::FourVector& mom_cms = in_trk->momentum();
56 
57  // transformation to LHC/TOTEM convention
58  HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t());
59  HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t());
60 
61  // determine the LHC arm and related parameters
62  unsigned int arm = 3;
63  double beamMomentum = 0.;
64  double xangle = 0.;
65  double empiricalAperture_xi0_int, empiricalAperture_xi0_slp;
66  double empiricalAperture_a_int, empiricalAperture_a_slp;
67 
68  if (mom_lhc.z() < 0) // sector 45
69  {
70  arm = 0;
73  empiricalAperture_xi0_int = empiricalAperture45_xi0_int_;
74  empiricalAperture_xi0_slp = empiricalAperture45_xi0_slp_;
75  empiricalAperture_a_int = empiricalAperture45_a_int_;
76  empiricalAperture_a_slp = empiricalAperture45_a_slp_;
77  } else { // sector 56
78  arm = 1;
81  empiricalAperture_xi0_int = empiricalAperture56_xi0_int_;
82  empiricalAperture_xi0_slp = empiricalAperture56_xi0_slp_;
83  empiricalAperture_a_int = empiricalAperture56_a_int_;
84  empiricalAperture_a_slp = empiricalAperture56_a_slp_;
85  }
86 
87  // calculate kinematics for optics parametrisation
88  const double p = mom_lhc.rho();
89  const double xi = 1. - p / beamMomentum;
90  const double th_x_phys = mom_lhc.x() / p;
91  const double th_y_phys = mom_lhc.y() / p;
92  const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + xangle);
93  const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z());
94 
95  if (verbosity_) {
96  LogDebug("OpticalFunctionsTransport")
97  << "simu: xi = " << xi << ", th_x_phys = " << th_x_phys << ", th_y_phys = " << th_y_phys
98  << ", vtx_lhc_eff_x = " << vtx_lhc_eff_x << ", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl;
99  }
100 
101  // check empirical aperture
103  const auto& xangle = lhcInfo_->crossingAngle();
104  const double xi_th = (empiricalAperture_xi0_int + xangle * empiricalAperture_xi0_slp) +
105  (empiricalAperture_a_int + xangle * empiricalAperture_a_slp) * th_x_phys;
106 
107  if (xi > xi_th) {
108  if (verbosity_) {
109  LogDebug("OpticalFunctionsTransport") << "stop because of empirical appertures";
110  }
111  return false;
112  }
113  }
114 
115  // transport the proton into each pot/scoring plane
116  for (const auto& ofp : (*opticalFunctions_)) {
117  CTPPSDetId rpId(ofp.first);
118  const unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
119 
120  // first check the arm
121  if (rpId.arm() != arm)
122  continue;
123 
124  if (verbosity_)
125  LogDebug("OpticalFunctionsTransport") << " RP " << rpDecId << std::endl;
126 
127  // transport proton
129  vtx_lhc_eff_x * 1E-1, th_x_phys, vtx_lhc_eff_y * 1E-1, th_y_phys, xi}; // conversions: mm -> cm
130 
132  ofp.second.transport(k_in, k_out, true);
133 
134  double b_x = k_out.x * 1E1, b_y = k_out.y * 1E1; // conversions: cm -> mm
135  double a_x = k_out.th_x, a_y = k_out.th_y;
136 
137  // if needed, subtract beam position and angle
139  // determine beam position
140  LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_in = {0., 0., 0., 0., 0.};
142  ofp.second.transport(k_be_in, k_be_out, true);
143 
144  a_x -= k_be_out.th_x;
145  a_y -= k_be_out.th_y;
146  b_x -= k_be_out.x * 1E1;
147  b_y -= k_be_out.y * 1E1; // conversions: cm -> mm
148  }
149 
150  const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1; // conversion: cm --> mm
151 
152  if (verbosity_) {
153  LogDebug("OpticalFunctionsTransport")
154  << " proton transported: a_x = " << a_x << " rad, a_y = " << a_y << " rad, b_x = " << b_x
155  << " mm, b_y = " << b_y << " mm, z = " << z_scoringPlane << " mm" << std::endl;
156  }
157  unsigned int line = in_trk->barcode();
158  double px = -p * a_x;
159  double py = p * a_y;
160  double pz = std::copysign(sqrt(p * p - px * px - py * py), mom_cms.z());
161  double e = sqrt(px * px + py * py + pz * pz + ProtonMassSQ);
162  TLorentzVector p_out(px, py, pz, e);
163  m_beamPart[line] = p_out;
164  m_xAtTrPoint[line] = -b_x;
165  m_yAtTrPoint[line] = b_y;
166  return true;
167  }
168  return false;
169 }
electrons_cff.bool
bool
Definition: electrons_cff.py:372
BaseProtonTransport::TransportMode::OPTICALFUNCTIONS
OpticalFunctionsTransport.h
OpticalFunctionsTransport::opticsLabel_
std::string opticsLabel_
Definition: OpticalFunctionsTransport.h:33
LHCInterpolatedOpticalFunctionsSet::Kinematics
proton kinematics description
Definition: LHCInterpolatedOpticalFunctionsSet.h:28
OpticalFunctionsTransport::empiricalAperture45_a_int_
double empiricalAperture45_a_int_
Definition: OpticalFunctionsTransport.h:40
OpticalFunctionsTransport::empiricalAperture45_xi0_int_
double empiricalAperture45_xi0_int_
Definition: OpticalFunctionsTransport.h:40
OpticalFunctionsTransport::lhcInfoLabel_
std::string lhcInfoLabel_
Definition: OpticalFunctionsTransport.h:32
BaseProtonTransport::clear
void clear()
Definition: BaseProtonTransport.cc:111
BaseProtonTransport::MODE
TransportMode MODE
Definition: BaseProtonTransport.h:42
OpticalFunctionsTransport::empiricalAperture45_a_slp_
double empiricalAperture45_a_slp_
Definition: OpticalFunctionsTransport.h:40
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
OpticalFunctionsTransport::transportProton
bool transportProton(const HepMC::GenParticle *)
Definition: OpticalFunctionsTransport.cc:53
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CTPPSBeamParameters::getHalfXangleX56
double getHalfXangleX56() const
Definition: CTPPSBeamParameters.cc:67
BaseProtonTransport::verbosity_
bool verbosity_
Definition: BaseProtonTransport.h:51
hybridSuperClusters_cfi.xi
xi
Definition: hybridSuperClusters_cfi.py:10
OpticalFunctionsTransport::process
void process(const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine) override
Definition: OpticalFunctionsTransport.cc:20
CTPPSBeamParameters::getBeamMom56
double getBeamMom56() const
Definition: CTPPSBeamParameters.cc:53
CTPPSBeamParameters::getHalfXangleX45
double getHalfXangleX45() const
Definition: CTPPSBeamParameters.cc:65
year_2016_postTS2_cff.rpId
rpId
Definition: year_2016_postTS2_cff.py:23
BaseProtonTransport::momentumCut_
double momentumCut_
Definition: BaseProtonTransport.h:65
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
OpticalFunctionsTransport::lhcInfo_
edm::ESHandle< LHCInfo > lhcInfo_
Definition: OpticalFunctionsTransport.h:35
OpticalFunctionsTransport::empiricalAperture56_a_slp_
double empiricalAperture56_a_slp_
Definition: OpticalFunctionsTransport.h:42
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
LHCInfo::crossingAngle
const float crossingAngle() const
Definition: LHCInfo.cc:182
LHCInterpolatedOpticalFunctionsSet::Kinematics::y
double y
Definition: LHCInterpolatedOpticalFunctionsSet.h:31
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
OpticalFunctionsTransport::empiricalAperture56_a_int_
double empiricalAperture56_a_int_
Definition: OpticalFunctionsTransport.h:42
OpticalFunctionsTransport::empiricalAperture56_xi0_int_
double empiricalAperture56_xi0_int_
Definition: OpticalFunctionsTransport.h:42
LHCInterpolatedOpticalFunctionsSet::Kinematics::x
double x
Definition: LHCInterpolatedOpticalFunctionsSet.h:29
OpticalFunctionsTransport::produceHitsRelativeToBeam_
bool produceHitsRelativeToBeam_
Definition: OpticalFunctionsTransport.h:45
LHCInfoRcd
Definition: LHCInfoRcd.h:24
OpticalFunctionsTransport::beamParameters_
edm::ESHandle< CTPPSBeamParameters > beamParameters_
Definition: OpticalFunctionsTransport.h:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
OpticalFunctionsConfig_cfi.xangle
xangle
Definition: OpticalFunctionsConfig_cfi.py:17
LHCInterpolatedOpticalFunctionsSet::Kinematics::th_y
double th_y
Definition: LHCInterpolatedOpticalFunctionsSet.h:32
ProtonMassSQ
static const double ProtonMassSQ
Definition: PPSUnitConversion.h:6
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
BaseProtonTransport::etaCut_
double etaCut_
Definition: BaseProtonTransport.h:64
BaseProtonTransport::m_beamPart
std::map< unsigned int, TLorentzVector > m_beamPart
Definition: BaseProtonTransport.h:47
CTPPSDetId
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:31
OpticalFunctionsTransport::opticalFunctions_
edm::ESHandle< LHCInterpolatedOpticalFunctionsSetCollection > opticalFunctions_
Definition: OpticalFunctionsTransport.h:37
BaseProtonTransport
Definition: BaseProtonTransport.h:17
edm::EventSetup
Definition: EventSetup.h:57
CTPPSBeamParameters::getBeamMom45
double getBeamMom45() const
Definition: CTPPSBeamParameters.cc:52
BaseProtonTransport::engine_
CLHEP::HepRandomEngine * engine_
Definition: BaseProtonTransport.h:45
get
#define get
CTPPSBeamParametersRcd
Definition: CTPPSBeamParametersRcd.h:14
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
GenParticle.GenParticle
GenParticle
Definition: GenParticle.py:18
std
Definition: JetResolutionObject.h:76
OpticalFunctionsTransport::empiricalAperture56_xi0_slp_
double empiricalAperture56_xi0_slp_
Definition: OpticalFunctionsTransport.h:42
BaseProtonTransport::m_yAtTrPoint
std::map< unsigned int, double > m_yAtTrPoint
Definition: BaseProtonTransport.h:49
OpticalFunctionsTransport::empiricalAperture45_xi0_slp_
double empiricalAperture45_xi0_slp_
Definition: OpticalFunctionsTransport.h:40
OpticalFunctionsTransport::OpticalFunctionsTransport
OpticalFunctionsTransport(const edm::ParameterSet &ps)
Definition: OpticalFunctionsTransport.cc:4
CTPPSDetId.h
BaseProtonTransport::m_xAtTrPoint
std::map< unsigned int, double > m_xAtTrPoint
Definition: BaseProtonTransport.h:48
BaseProtonTransport::beamMomentum
double beamMomentum()
Definition: BaseProtonTransport.h:38
LHCInterpolatedOpticalFunctionsSet::Kinematics::th_x
double th_x
Definition: LHCInterpolatedOpticalFunctionsSet.h:30
OpticalFunctionsTransport::useEmpiricalApertures_
bool useEmpiricalApertures_
Definition: OpticalFunctionsTransport.h:39
mps_splice.line
line
Definition: mps_splice.py:76
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
CTPPSInterpolatedOpticsRcd
Definition: CTPPSInterpolatedOpticsRcd.h:13