CMS 3D CMS Logo

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

#include <OpticalFunctionsTransport.h>

Inheritance diagram for OpticalFunctionsTransport:
BaseProtonTransport

Public Member Functions

 OpticalFunctionsTransport (const edm::ParameterSet &ps, edm::ConsumesCollector iC)
 
void process (const HepMC::GenEvent *ev, const edm::EventSetup &es, CLHEP::HepRandomEngine *engine) override
 
 ~OpticalFunctionsTransport () 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

bool transportProton (const HepMC::GenParticle *)
 

Private Attributes

const CTPPSBeamParametersbeamParameters_ {nullptr}
 
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcdbeamParametersToken_
 
const SimBeamSpotObjectsbeamspot_ {nullptr}
 
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcdbeamspotToken_
 
double empiricalAperture45_a_int_
 
double empiricalAperture45_a_slp_
 
double empiricalAperture45_xi0_int_
 
double empiricalAperture45_xi0_slp_
 
double empiricalAperture56_a_int_
 
double empiricalAperture56_a_slp_
 
double empiricalAperture56_xi0_int_
 
double empiricalAperture56_xi0_slp_
 
const LHCInfolhcInfo_ {nullptr}
 
edm::ESGetToken< LHCInfo, LHCInfoRcdlhcInfoToken_
 
unsigned int optFunctionId45_ {0}
 
unsigned int optFunctionId56_ {0}
 
const LHCInterpolatedOpticalFunctionsSetCollectionopticalFunctions_ {nullptr}
 
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcdopticsToken_
 
bool useEmpiricalApertures_
 

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 OpticalFunctionsTransport.h.

Constructor & Destructor Documentation

◆ OpticalFunctionsTransport()

OpticalFunctionsTransport::OpticalFunctionsTransport ( const edm::ParameterSet ps,
edm::ConsumesCollector  iC 
)

Definition at line 4 of file OpticalFunctionsTransport.cc.

References BaseProtonTransport::MODE, and BaseProtonTransport::OPTICALFUNCTIONS.

5  : BaseProtonTransport(iConfig),
6  lhcInfoToken_(iC.esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("lhcInfoLabel")))),
8  opticsToken_(iC.esConsumes(edm::ESInputTag("", iConfig.getParameter<std::string>("opticsLabel")))),
10  useEmpiricalApertures_(iConfig.getParameter<bool>("useEmpiricalApertures")),
11  empiricalAperture45_xi0_int_(iConfig.getParameter<double>("empiricalAperture45_xi0_int")),
12  empiricalAperture45_xi0_slp_(iConfig.getParameter<double>("empiricalAperture45_xi0_slp")),
13  empiricalAperture45_a_int_(iConfig.getParameter<double>("empiricalAperture45_a_int")),
14  empiricalAperture45_a_slp_(iConfig.getParameter<double>("empiricalAperture45_a_slp")),
15  empiricalAperture56_xi0_int_(iConfig.getParameter<double>("empiricalAperture56_xi0_int")),
16  empiricalAperture56_xi0_slp_(iConfig.getParameter<double>("empiricalAperture56_xi0_slp")),
17  empiricalAperture56_a_int_(iConfig.getParameter<double>("empiricalAperture56_a_int")),
18  empiricalAperture56_a_slp_(iConfig.getParameter<double>("empiricalAperture56_a_slp")) {
20 }
BaseProtonTransport(const edm::ParameterSet &iConfig)
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > opticsToken_
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > beamParametersToken_
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamspotToken_

◆ ~OpticalFunctionsTransport()

OpticalFunctionsTransport::~OpticalFunctionsTransport ( )
override

Definition at line 21 of file OpticalFunctionsTransport.cc.

21 {}

Member Function Documentation

◆ process()

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

Implements BaseProtonTransport.

Definition at line 23 of file OpticalFunctionsTransport.cc.

References beamParameters_, beamParametersToken_, beamspot_, beamspotToken_, BaseProtonTransport::clear(), BaseProtonTransport::engine_, BaseProtonTransport::etaCut_, GenParticle::GenParticle, edm::EventSetup::getData(), lhcInfo_, lhcInfoToken_, mps_splice::line, BaseProtonTransport::m_beamPart, BaseProtonTransport::momentumCut_, optFunctionId45_, optFunctionId56_, opticalFunctions_, opticsToken_, and transportProton().

25  {
26  clear();
27 
28  lhcInfo_ = &iSetup.getData(lhcInfoToken_);
29  beamParameters_ = &iSetup.getData(beamParametersToken_);
30  opticalFunctions_ = &iSetup.getData(opticsToken_);
31  beamspot_ = &iSetup.getData(beamspotToken_);
32 
33  // Choose the optical function corresponding to the first station ono each side (it is in lhc ref. frame)
34  optFunctionId45_ = 0;
35  optFunctionId56_ = 0;
36  for (const auto& ofp : (*opticalFunctions_)) {
37  if (ofp.second.getScoringPlaneZ() < 0) {
38  if (optFunctionId45_ == 0)
39  optFunctionId45_ = ofp.first;
40  if (opticalFunctions_->at(optFunctionId45_).getScoringPlaneZ() < ofp.second.getScoringPlaneZ())
41  optFunctionId45_ = ofp.first;
42  }
43  if (ofp.second.getScoringPlaneZ() > 0) {
44  if (optFunctionId56_ == 0)
45  optFunctionId56_ = ofp.first;
46  if (opticalFunctions_->at(optFunctionId56_).getScoringPlaneZ() > ofp.second.getScoringPlaneZ())
47  optFunctionId56_ = ofp.first;
48  }
49  }
50  //
51  engine_ = engine; // the engine needs to be updated for each event
52 
53  for (HepMC::GenEvent::particle_const_iterator eventParticle = evt->particles_begin();
54  eventParticle != evt->particles_end();
55  ++eventParticle) {
56  if (!((*eventParticle)->status() == 1 && (*eventParticle)->pdg_id() == 2212))
57  continue;
58 
59  if (!(fabs((*eventParticle)->momentum().eta()) > etaCut_ && fabs((*eventParticle)->momentum().pz()) > momentumCut_))
60  continue; // discard protons outside kinematic acceptance
61 
62  unsigned int line = (*eventParticle)->barcode();
63  HepMC::GenParticle* gpart = (*eventParticle);
64  if (gpart->pdg_id() != 2212)
65  continue; // only transport stable protons
66  if (gpart->status() != 1)
67  continue;
68  if (m_beamPart.find(line) != m_beamPart.end()) // assures this protons has not been already propagated
69  continue;
70 
71  transportProton(gpart);
72  }
73 }
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > opticsToken_
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > beamParametersToken_
const LHCInterpolatedOpticalFunctionsSetCollection * opticalFunctions_
CLHEP::HepRandomEngine * engine_
edm::ESGetToken< SimBeamSpotObjects, SimBeamSpotObjectsRcd > beamspotToken_
const SimBeamSpotObjects * beamspot_
std::map< unsigned int, TLorentzVector > m_beamPart
const CTPPSBeamParameters * beamParameters_
bool transportProton(const HepMC::GenParticle *)

◆ transportProton()

bool OpticalFunctionsTransport::transportProton ( const HepMC::GenParticle *  in_trk)
private

Definition at line 75 of file OpticalFunctionsTransport.cc.

References funct::abs(), CTPPSDetId::arm(), BaseProtonTransport::beamMomentum(), beamParameters_, beamspot_, cm_to_mm, LHCInfo::crossingAngle(), MillePedeFileConverter_cfg::e, SiPixelPhase1Clusters_cfi::e3, empiricalAperture45_a_int_, empiricalAperture45_a_slp_, empiricalAperture45_xi0_int_, empiricalAperture45_xi0_slp_, empiricalAperture56_a_int_, empiricalAperture56_a_slp_, empiricalAperture56_xi0_int_, empiricalAperture56_xi0_slp_, BaseProtonTransport::fPPSRegionStart_45_, BaseProtonTransport::fPPSRegionStart_56_, CTPPSBeamParameters::getBeamMom45(), CTPPSBeamParameters::getBeamMom56(), CTPPSBeamParameters::getHalfXangleX45(), CTPPSBeamParameters::getHalfXangleX56(), CTPPSBeamParameters::getVtxOffsetX45(), CTPPSBeamParameters::getVtxOffsetY45(), lhcInfo_, mps_splice::line, LogDebug, BaseProtonTransport::m_beamPart, BaseProtonTransport::m_xAtTrPoint, BaseProtonTransport::m_yAtTrPoint, optFunctionId45_, optFunctionId56_, opticalFunctions_, AlCaHLTBitMon_ParallelJobs::p, BaseProtonTransport::produceHitsRelativeToBeam_, ProtonMassSQ, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, CTPPSDetId::rp(), mathSSE::sqrt(), CTPPSDetId::station(), funct::tan(), LHCInterpolatedOpticalFunctionsSet::Kinematics::th_x, LHCInterpolatedOpticalFunctionsSet::Kinematics::th_y, urad, BaseProtonTransport::useBeamPositionFromLHCInfo_, useEmpiricalApertures_, BaseProtonTransport::verbosity_, LHCInterpolatedOpticalFunctionsSet::Kinematics::x, SimBeamSpotObjects::x(), profile_base_cff::xangle, protons_cff::xi, LHCInterpolatedOpticalFunctionsSet::Kinematics::y, and SimBeamSpotObjects::y().

Referenced by process().

75  {
76  const HepMC::FourVector& vtx_cms = in_trk->production_vertex()->position(); // in mm
77  const HepMC::FourVector& mom_cms = in_trk->momentum();
78 
79  // transformation to LHC/TOTEM convention
80  HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t());
81  HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t());
82 
83  // determine the LHC arm and related parameters
84  double urad = 1.e-6;
85  double beamMomentum = 0.;
86  double xangle = 0.;
87  double empiricalAperture_xi0_int, empiricalAperture_xi0_slp;
88  double empiricalAperture_a_int, empiricalAperture_a_slp;
89  unsigned int optFunctionId;
90  // get the beam position at the IP in mm and in the LHC ref. frame
91  double vtxXoffset;
92  double vtxYoffset;
94  vtxXoffset = -beamParameters_->getVtxOffsetX45() * cm_to_mm;
95  vtxYoffset = beamParameters_->getVtxOffsetY45() * cm_to_mm;
96  } else {
97  vtxXoffset = -beamspot_->x() * cm_to_mm;
98  vtxYoffset = beamspot_->y() * cm_to_mm;
99  }
100 
101  if (mom_lhc.z() < 0) // sector 45
102  {
103  optFunctionId = optFunctionId45_;
106  empiricalAperture_xi0_int = empiricalAperture45_xi0_int_;
107  empiricalAperture_xi0_slp = empiricalAperture45_xi0_slp_;
108  empiricalAperture_a_int = empiricalAperture45_a_int_;
109  empiricalAperture_a_slp = empiricalAperture45_a_slp_;
110  } else { // sector 56
111  optFunctionId = optFunctionId56_;
114  empiricalAperture_xi0_int = empiricalAperture56_xi0_int_;
115  empiricalAperture_xi0_slp = empiricalAperture56_xi0_slp_;
116  empiricalAperture_a_int = empiricalAperture56_a_int_;
117  empiricalAperture_a_slp = empiricalAperture56_a_slp_;
118  }
119  if (xangle > 1.0)
120  xangle *= urad;
121  // calculate kinematics for optics parametrisation, avoid the aproximation for small angles xangle -> tan(xangle)
122  const double p = mom_lhc.rho();
123  const double xi = 1. - p / beamMomentum;
124  const double th_x_phys = mom_lhc.x() / abs(mom_lhc.z()) - tan(xangle); //"-" in the LHC ref. frame
125  const double th_y_phys = mom_lhc.y() / abs(mom_lhc.z());
126  const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + tan(xangle)) - (vtxXoffset);
127  const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z()) - (vtxYoffset);
128 
129  if (verbosity_) {
130  LogDebug("OpticalFunctionsTransport")
131  << "simu: xi = " << xi << ", th_x_phys = " << th_x_phys << ", th_y_phys = " << th_y_phys
132  << ", vtx_lhc_eff_x = " << vtx_lhc_eff_x << ", vtx_lhc_eff_y = " << vtx_lhc_eff_y;
133  }
134 
135  // check empirical aperture
137  const auto& xangle =
139  const double xi_th = (empiricalAperture_xi0_int + xangle * empiricalAperture_xi0_slp) +
140  (empiricalAperture_a_int + xangle * empiricalAperture_a_slp) * th_x_phys;
141 
142  if (xi > xi_th) {
143  if (verbosity_) {
144  LogDebug("OpticalFunctionsTransport") << "stop because of empirical appertures";
145  }
146  return false;
147  }
148  }
149 
150  // transport the proton into pot/scoring plane
151  auto ofp = opticalFunctions_->at(optFunctionId);
152  CTPPSDetId rpId(optFunctionId);
153  const unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
154 
155  if (verbosity_)
156  LogDebug("OpticalFunctionsTransport") << " RP " << rpDecId << std::endl;
157 
158  // transport proton
160  vtx_lhc_eff_x * cm_to_mm, th_x_phys, vtx_lhc_eff_y * cm_to_mm, th_y_phys, xi}; // conversions: mm -> cm
161 
163  ofp.transport(k_in, k_out, true);
164 
165  // Original code uses mm, but CMS uses cm, so keep it in cm
166  double b_x = k_out.x * cm_to_mm, b_y = k_out.y * cm_to_mm; // conversions: cm -> mm
167  double a_x = k_out.th_x, a_y = k_out.th_y;
168 
169  // if needed, subtract beam position and angle
171  // determine beam position
172  LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_in = {0., -tan(xangle), 0., 0., 0.};
174  ofp.transport(k_be_in, k_be_out, true);
175 
176  a_x -= k_be_out.th_x;
177  a_y -= k_be_out.th_y;
178  b_x -= k_be_out.x * cm_to_mm;
179  b_y -= k_be_out.y * cm_to_mm; // conversions: cm -> mm
180  }
181 
182  const double z_scoringPlane = ofp.getScoringPlaneZ() * cm_to_mm; // conversion: cm --> mm
183 
184  if (verbosity_) {
185  LogDebug("OpticalFunctionsTransport")
186  << " proton transported: a_x = " << a_x << " rad, a_y = " << a_y << " rad, b_x = " << b_x
187  << " mm, b_y = " << b_y << " mm, z = " << z_scoringPlane << " mm";
188  }
189  //
190  // Project the track back to the starting of PPS region in mm
191  b_x -= (abs(z_scoringPlane) - ((z_scoringPlane < 0) ? fPPSRegionStart_45_ : fPPSRegionStart_56_) * 1e3) * a_x;
192  b_y -= (abs(z_scoringPlane) - ((z_scoringPlane < 0) ? fPPSRegionStart_45_ : fPPSRegionStart_56_) * 1e3) * a_y;
193 
194  unsigned int line = in_trk->barcode();
195  double px = -p * a_x;
196  double py = p * a_y;
197  double pz = std::copysign(sqrt(p * p - px * px - py * py), mom_cms.z());
198  double e = sqrt(px * px + py * py + pz * pz + ProtonMassSQ);
199  TLorentzVector p_out(px, py, pz, e);
200  m_beamPart[line] = p_out;
201  m_xAtTrPoint[line] = -b_x;
202  m_yAtTrPoint[line] = b_y;
203  return true;
204 }
double getHalfXangleX56() const
static const double urad
double getVtxOffsetX45() const
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float const crossingAngle() const
Definition: LHCInfo.cc:182
double getVtxOffsetY45() const
const LHCInterpolatedOpticalFunctionsSetCollection * opticalFunctions_
double getBeamMom45() const
const SimBeamSpotObjects * beamspot_
std::map< unsigned int, double > m_xAtTrPoint
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
std::map< unsigned int, TLorentzVector > m_beamPart
double getBeamMom56() const
const CTPPSBeamParameters * beamParameters_
double x() const
get X, Y, Z position
static const double ProtonMassSQ
std::map< unsigned int, double > m_yAtTrPoint
double getHalfXangleX45() const
static const double cm_to_mm
#define LogDebug(id)

Member Data Documentation

◆ beamParameters_

const CTPPSBeamParameters* OpticalFunctionsTransport::beamParameters_ {nullptr}
private

Definition at line 35 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

◆ beamParametersToken_

edm::ESGetToken<CTPPSBeamParameters, CTPPSBeamParametersRcd> OpticalFunctionsTransport::beamParametersToken_
private

Definition at line 30 of file OpticalFunctionsTransport.h.

Referenced by process().

◆ beamspot_

const SimBeamSpotObjects* OpticalFunctionsTransport::beamspot_ {nullptr}
private

Definition at line 37 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

◆ beamspotToken_

edm::ESGetToken<SimBeamSpotObjects, SimBeamSpotObjectsRcd> OpticalFunctionsTransport::beamspotToken_
private

Definition at line 32 of file OpticalFunctionsTransport.h.

Referenced by process().

◆ empiricalAperture45_a_int_

double OpticalFunctionsTransport::empiricalAperture45_a_int_
private

Definition at line 43 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture45_a_slp_

double OpticalFunctionsTransport::empiricalAperture45_a_slp_
private

Definition at line 43 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture45_xi0_int_

double OpticalFunctionsTransport::empiricalAperture45_xi0_int_
private

Definition at line 43 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture45_xi0_slp_

double OpticalFunctionsTransport::empiricalAperture45_xi0_slp_
private

Definition at line 43 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture56_a_int_

double OpticalFunctionsTransport::empiricalAperture56_a_int_
private

Definition at line 45 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture56_a_slp_

double OpticalFunctionsTransport::empiricalAperture56_a_slp_
private

Definition at line 45 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture56_xi0_int_

double OpticalFunctionsTransport::empiricalAperture56_xi0_int_
private

Definition at line 45 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ empiricalAperture56_xi0_slp_

double OpticalFunctionsTransport::empiricalAperture56_xi0_slp_
private

Definition at line 45 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

◆ lhcInfo_

const LHCInfo* OpticalFunctionsTransport::lhcInfo_ {nullptr}
private

Definition at line 34 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

◆ lhcInfoToken_

edm::ESGetToken<LHCInfo, LHCInfoRcd> OpticalFunctionsTransport::lhcInfoToken_
private

Definition at line 29 of file OpticalFunctionsTransport.h.

Referenced by process().

◆ optFunctionId45_

unsigned int OpticalFunctionsTransport::optFunctionId45_ {0}
private

Definition at line 39 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

◆ optFunctionId56_

unsigned int OpticalFunctionsTransport::optFunctionId56_ {0}
private

Definition at line 40 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

◆ opticalFunctions_

const LHCInterpolatedOpticalFunctionsSetCollection* OpticalFunctionsTransport::opticalFunctions_ {nullptr}
private

Definition at line 36 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

◆ opticsToken_

Definition at line 31 of file OpticalFunctionsTransport.h.

Referenced by process().

◆ useEmpiricalApertures_

bool OpticalFunctionsTransport::useEmpiricalApertures_
private

Definition at line 42 of file OpticalFunctionsTransport.h.

Referenced by transportProton().