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
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 ()
 
void setBeamEnergy (double e)
 
virtual ~BaseProtonTransport ()
 

Private Member Functions

bool transportProton (const HepMC::GenParticle *)
 

Private Attributes

const CTPPSBeamParametersbeamParameters_
 
edm::ESGetToken
< CTPPSBeamParameters,
CTPPSBeamParametersRcd
beamParametersToken_
 
const BeamSpotObjectsbeamspot_
 
edm::ESGetToken
< BeamSpotObjects,
BeamSpotObjectsRcd
beamspotToken_
 
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_
 
edm::ESGetToken< LHCInfo,
LHCInfoRcd
lhcInfoToken_
 
unsigned int optFunctionId45_
 
unsigned int optFunctionId56_
 
const
LHCInterpolatedOpticalFunctionsSetCollection
opticalFunctions_
 
edm::ESGetToken
< LHCInterpolatedOpticalFunctionsSetCollection,
CTPPSInterpolatedOpticsRcd
opticsToken_
 
bool produceHitsRelativeToBeam_
 
bool useEmpiricalApertures_
 

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

Constructor & Destructor Documentation

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

Definition at line 4 of file OpticalFunctionsTransport.cc.

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

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< BeamSpotObjects, BeamSpotObjectsRcd > beamspotToken_
OpticalFunctionsTransport::~OpticalFunctionsTransport ( )
inlineoverride

Definition at line 26 of file OpticalFunctionsTransport.h.

26 {};

Member Function Documentation

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

Implements BaseProtonTransport.

Definition at line 21 of file OpticalFunctionsTransport.cc.

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

23  {
24  this->clear();
25 
26  lhcInfo_ = &iSetup.getData(lhcInfoToken_);
27  beamParameters_ = &iSetup.getData(beamParametersToken_);
28  opticalFunctions_ = &iSetup.getData(opticsToken_);
29  beamspot_ = &iSetup.getData(beamspotToken_);
30 
31  // Choose the optical function corresponding to the first station ono each side (it is in lhc ref. frame)
32  optFunctionId45_ = 0;
33  optFunctionId56_ = 0;
34  for (const auto& ofp : (*opticalFunctions_)) {
35  if (ofp.second.getScoringPlaneZ() < 0) {
36  if (optFunctionId45_ == 0)
37  optFunctionId45_ = ofp.first;
38  if (opticalFunctions_->at(optFunctionId45_).getScoringPlaneZ() < ofp.second.getScoringPlaneZ())
39  optFunctionId45_ = ofp.first;
40  }
41  if (ofp.second.getScoringPlaneZ() > 0) {
42  if (optFunctionId56_ == 0)
43  optFunctionId56_ = ofp.first;
44  if (opticalFunctions_->at(optFunctionId56_).getScoringPlaneZ() > ofp.second.getScoringPlaneZ())
45  optFunctionId56_ = ofp.first;
46  }
47  }
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  if (gpart->pdg_id() != 2212)
63  continue; // only transport stable protons
64  if (gpart->status() != 1)
65  continue;
66  if (m_beamPart.find(line) != m_beamPart.end()) // assures this protons has not been already propagated
67  continue;
68 
69  transportProton(gpart);
70  }
71 }
edm::ESGetToken< LHCInfo, LHCInfoRcd > lhcInfoToken_
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > opticsToken_
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > beamParametersToken_
const LHCInterpolatedOpticalFunctionsSetCollection * opticalFunctions_
const BeamSpotObjects * beamspot_
CLHEP::HepRandomEngine * engine_
edm::ESGetToken< BeamSpotObjects, BeamSpotObjectsRcd > beamspotToken_
std::map< unsigned int, TLorentzVector > m_beamPart
const CTPPSBeamParameters * beamParameters_
bool transportProton(const HepMC::GenParticle *)
bool OpticalFunctionsTransport::transportProton ( const HepMC::GenParticle *  in_trk)
private

Definition at line 73 of file OpticalFunctionsTransport.cc.

References funct::abs(), CTPPSDetId::arm(), BaseProtonTransport::beamMomentum(), beamParameters_, beamspot_, cm_to_mm, LHCInfo::crossingAngle(), alignCSCRings::e, 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(), CTPPSBeamParameters::getVtxOffsetZ45(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), lhcInfo_, geometryCSVtoXML::line, LogDebug, BaseProtonTransport::m_beamPart, BaseProtonTransport::m_xAtTrPoint, BaseProtonTransport::m_yAtTrPoint, optFunctionId45_, optFunctionId56_, opticalFunctions_, AlCaHLTBitMon_ParallelJobs::p, produceHitsRelativeToBeam_, ProtonMassSQ, 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, and LHCInterpolatedOpticalFunctionsSet::Kinematics::y.

Referenced by process().

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

const CTPPSBeamParameters* OpticalFunctionsTransport::beamParameters_
private

Definition at line 39 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

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

Definition at line 34 of file OpticalFunctionsTransport.h.

Referenced by process().

const BeamSpotObjects* OpticalFunctionsTransport::beamspot_
private

Definition at line 41 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> OpticalFunctionsTransport::beamspotToken_
private

Definition at line 36 of file OpticalFunctionsTransport.h.

Referenced by process().

double OpticalFunctionsTransport::empiricalAperture45_a_int_
private

Definition at line 47 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture45_a_slp_
private

Definition at line 47 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture45_xi0_int_
private

Definition at line 47 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture45_xi0_slp_
private

Definition at line 47 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture56_a_int_
private

Definition at line 49 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture56_a_slp_
private

Definition at line 49 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture56_xi0_int_
private

Definition at line 49 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

double OpticalFunctionsTransport::empiricalAperture56_xi0_slp_
private

Definition at line 49 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

const LHCInfo* OpticalFunctionsTransport::lhcInfo_
private

Definition at line 38 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

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

Definition at line 33 of file OpticalFunctionsTransport.h.

Referenced by process().

unsigned int OpticalFunctionsTransport::optFunctionId45_
private

Definition at line 43 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

unsigned int OpticalFunctionsTransport::optFunctionId56_
private

Definition at line 44 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

const LHCInterpolatedOpticalFunctionsSetCollection* OpticalFunctionsTransport::opticalFunctions_
private

Definition at line 40 of file OpticalFunctionsTransport.h.

Referenced by process(), and transportProton().

Definition at line 35 of file OpticalFunctionsTransport.h.

Referenced by process().

bool OpticalFunctionsTransport::produceHitsRelativeToBeam_
private

Definition at line 52 of file OpticalFunctionsTransport.h.

Referenced by transportProton().

bool OpticalFunctionsTransport::useEmpiricalApertures_
private

Definition at line 46 of file OpticalFunctionsTransport.h.

Referenced by transportProton().