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 | Static Public Member Functions | Private Member Functions | Private Attributes
CTPPSDirectProtonSimulation Class Reference
Inheritance diagram for CTPPSDirectProtonSimulation:
edm::stream::EDProducer<>

Public Member Functions

 CTPPSDirectProtonSimulation (const edm::ParameterSet &)
 
 ~CTPPSDirectProtonSimulation () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void processProton (const HepMC::GenVertex *in_vtx, const HepMC::GenParticle *in_trk, const CTPPSGeometry &geometry, const LHCInfo &lhcInfo, const CTPPSBeamParameters &beamParameters, const PPSPixelTopology &ppt, const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, CLHEP::HepRandomEngine *rndEngine, std::vector< CTPPSLocalTrackLite > &out_tracks, edm::DetSetVector< TotemRPRecHit > &out_strip_hits, edm::DetSetVector< CTPPSPixelRecHit > &out_pixel_hits, edm::DetSetVector< CTPPSDiamondRecHit > &out_diamond_hits, std::map< int, edm::DetSetVector< TotemRPRecHit >> &out_strip_hits_per_particle, std::map< int, edm::DetSetVector< CTPPSPixelRecHit >> &out_pixel_hits_per_particle, std::map< int, edm::DetSetVector< CTPPSDiamondRecHit >> &out_diamond_hits_per_particle) const
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool checkIsHit_
 
edm::ESWatcher
< PPSDirectSimulationDataRcd
directSimuDataRcdWatcher_
 
std::map< unsigned int,
std::unique_ptr< TH2F > > 
efficiencyMapsPerPlane_
 
std::map< unsigned int,
std::unique_ptr< TH2F > > 
efficiencyMapsPerRP_
 
std::unique_ptr< TF2 > empiricalAperture45_
 
std::unique_ptr< TF2 > empiricalAperture56_
 
edm::EDGetTokenT
< edm::HepMCProduct
hepMCToken_
 
double insensitiveMarginStrips_
 size of insensitive margin at sensor's edge facing the beam, in mm More...
 
double pitchPixelsHor_
 
double pitchPixelsVer_
 
double pitchStrips_
 strip pitch in mm More...
 
edm::ESGetToken
< PPSPixelTopology,
PPSPixelTopologyRcd
pixelTopologyToken_
 
bool produceHitsRelativeToBeam_
 
bool produceRecHits_
 
bool produceScoringPlaneHits_
 
bool roundToPitch_
 
double stripZeroPosition_
 internal variable: v position of strip 0, in mm More...
 
std::unique_ptr< TF1 > timeResolutionDiamonds45_
 
std::unique_ptr< TF1 > timeResolutionDiamonds56_
 
edm::ESGetToken
< CTPPSBeamParameters,
CTPPSBeamParametersRcd
tokenBeamParameters_
 
edm::ESGetToken
< PPSDirectSimulationData,
PPSDirectSimulationDataRcd
tokenDirectSimuData_
 
edm::ESGetToken< CTPPSGeometry,
VeryForwardMisalignedGeometryRecord
tokenGeometry_
 
edm::ESGetToken< LHCInfo,
LHCInfoRcd
tokenLHCInfo_
 
edm::ESGetToken
< LHCInterpolatedOpticalFunctionsSetCollection,
CTPPSInterpolatedOpticsRcd
tokenOpticalFunctions_
 
bool useEmpiricalApertures_
 
bool useTimingEfficiencyPerPlane_
 
bool useTimingEfficiencyPerRP_
 
bool useTrackingEfficiencyPerPlane_
 
bool useTrackingEfficiencyPerRP_
 
unsigned int verbosity_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 66 of file CTPPSDirectProtonSimulation.cc.

Constructor & Destructor Documentation

CTPPSDirectProtonSimulation::CTPPSDirectProtonSimulation ( const edm::ParameterSet iConfig)
explicit

Definition at line 152 of file CTPPSDirectProtonSimulation.cc.

References checkIsHit_, DeDxTools::esConsumes(), Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hepMCToken_, insensitiveMarginStrips_, RPTopology::last_strip_to_border_dist_, RPTopology::no_of_strips_, RPTopology::pitch_, pitchPixelsHor_, pitchPixelsVer_, pitchStrips_, pixelTopologyToken_, produceHitsRelativeToBeam_, produceRecHits_, produceScoringPlaneHits_, roundToPitch_, AlCaHLTBitMon_QueryRunRegistry::string, stripZeroPosition_, tokenBeamParameters_, tokenDirectSimuData_, tokenGeometry_, tokenOpticalFunctions_, useEmpiricalApertures_, useTimingEfficiencyPerPlane_, useTimingEfficiencyPerRP_, useTrackingEfficiencyPerPlane_, useTrackingEfficiencyPerRP_, verbosity_, and RPTopology::y_width_.

153  : tokenLHCInfo_(esConsumes(edm::ESInputTag{"", iConfig.getParameter<std::string>("lhcInfoLabel")})),
159 
160  hepMCToken_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("hepMCTag"))),
161 
162  produceScoringPlaneHits_(iConfig.getParameter<bool>("produceScoringPlaneHits")),
163  produceRecHits_(iConfig.getParameter<bool>("produceRecHits")),
164 
165  useEmpiricalApertures_(iConfig.getParameter<bool>("useEmpiricalApertures")),
166 
167  useTrackingEfficiencyPerRP_(iConfig.getParameter<bool>("useTrackingEfficiencyPerRP")),
168  useTimingEfficiencyPerRP_(iConfig.getParameter<bool>("useTimingEfficiencyPerRP")),
169  useTrackingEfficiencyPerPlane_(iConfig.getParameter<bool>("useTrackingEfficiencyPerPlane")),
170  useTimingEfficiencyPerPlane_(iConfig.getParameter<bool>("useTimingEfficiencyPerPlane")),
171 
172  produceHitsRelativeToBeam_(iConfig.getParameter<bool>("produceHitsRelativeToBeam")),
173  roundToPitch_(iConfig.getParameter<bool>("roundToPitch")),
174  checkIsHit_(iConfig.getParameter<bool>("checkIsHit")),
175 
176  pitchStrips_(iConfig.getParameter<double>("pitchStrips")),
177  insensitiveMarginStrips_(iConfig.getParameter<double>("insensitiveMarginStrips")),
178 
179  pitchPixelsHor_(iConfig.getParameter<double>("pitchPixelsHor")),
180  pitchPixelsVer_(iConfig.getParameter<double>("pitchPixelsVer")),
181 
182  verbosity_(iConfig.getUntrackedParameter<unsigned int>("verbosity", 0)) {
184  produces<std::vector<CTPPSLocalTrackLite>>();
185 
186  if (produceRecHits_) {
187  produces<edm::DetSetVector<TotemRPRecHit>>();
188  produces<edm::DetSetVector<CTPPSDiamondRecHit>>();
189  produces<edm::DetSetVector<CTPPSPixelRecHit>>();
190 
191  produces<std::map<int, edm::DetSetVector<TotemRPRecHit>>>();
192  produces<std::map<int, edm::DetSetVector<CTPPSDiamondRecHit>>>();
193  produces<std::map<int, edm::DetSetVector<CTPPSPixelRecHit>>>();
194  }
195 
196  // check user input
198  throw cms::Exception("PPS")
199  << "useTrackingEfficiencyPerRP and useTrackingEfficiencyPerPlane should not be simultaneously set true.";
200 
202  throw cms::Exception("PPS")
203  << "useTimingEfficiencyPerRP and useTimingEfficiencyPerPlane should not be simultaneously set true.";
204 
205  // v position of strip 0
208 }
edm::ESGetToken< LHCInfo, LHCInfoRcd > tokenLHCInfo_
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > tokenOpticalFunctions_
edm::ESGetToken< CTPPSGeometry, VeryForwardMisalignedGeometryRecord > tokenGeometry_
static const unsigned short no_of_strips_
Definition: RPTopology.h:53
edm::EDGetTokenT< edm::HepMCProduct > hepMCToken_
static const double y_width_
Definition: RPTopology.h:55
double insensitiveMarginStrips_
size of insensitive margin at sensor&#39;s edge facing the beam, in mm
edm::ESGetToken< PPSDirectSimulationData, PPSDirectSimulationDataRcd > tokenDirectSimuData_
static const double last_strip_to_border_dist_
Definition: RPTopology.h:57
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double stripZeroPosition_
internal variable: v position of strip 0, in mm
static const double pitch_
Definition: RPTopology.h:51
edm::ESGetToken< PPSPixelTopology, PPSPixelTopologyRcd > pixelTopologyToken_
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > tokenBeamParameters_
CTPPSDirectProtonSimulation::~CTPPSDirectProtonSimulation ( )
inlineoverride

Definition at line 69 of file CTPPSDirectProtonSimulation.cc.

69 {}

Member Function Documentation

void CTPPSDirectProtonSimulation::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 212 of file CTPPSDirectProtonSimulation.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

212  {
214  desc.addUntracked<unsigned int>("verbosity", 0);
215 
216  desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");
217  desc.add<std::string>("opticsLabel", "")->setComment("label of the optics records");
218 
219  desc.add<edm::InputTag>("hepMCTag", edm::InputTag("generator", "unsmeared"));
220 
221  desc.add<bool>("produceScoringPlaneHits", true);
222  desc.add<bool>("produceRecHits", true);
223 
224  desc.add<bool>("useEmpiricalApertures", true);
225 
226  desc.add<bool>("useTrackingEfficiencyPerRP", false);
227  desc.add<bool>("useTimingEfficiencyPerRP", false);
228  desc.add<bool>("useTrackingEfficiencyPerPlane", false);
229  desc.add<bool>("useTimingEfficiencyPerPlane", false);
230 
231  desc.add<bool>("produceHitsRelativeToBeam", true);
232  desc.add<bool>("roundToPitch", true);
233  desc.add<bool>("checkIsHit", true);
234  desc.add<double>("pitchStrips", 66.e-3); // in mm
235  desc.add<double>("insensitiveMarginStrips", 34.e-3); // in mm
236 
237  desc.add<double>("pitchPixelsHor", 100.e-3);
238  desc.add<double>("pitchPixelsVer", 150.e-3);
239 
240  descriptions.add("ctppsDirectProtonSimulation", desc);
241 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void CTPPSDirectProtonSimulation::processProton ( const HepMC::GenVertex *  in_vtx,
const HepMC::GenParticle *  in_trk,
const CTPPSGeometry geometry,
const LHCInfo lhcInfo,
const CTPPSBeamParameters beamParameters,
const PPSPixelTopology ppt,
const LHCInterpolatedOpticalFunctionsSetCollection opticalFunctions,
CLHEP::HepRandomEngine *  rndEngine,
std::vector< CTPPSLocalTrackLite > &  out_tracks,
edm::DetSetVector< TotemRPRecHit > &  out_strip_hits,
edm::DetSetVector< CTPPSPixelRecHit > &  out_pixel_hits,
edm::DetSetVector< CTPPSDiamondRecHit > &  out_diamond_hits,
std::map< int, edm::DetSetVector< TotemRPRecHit >> &  out_strip_hits_per_particle,
std::map< int, edm::DetSetVector< CTPPSPixelRecHit >> &  out_pixel_hits_per_particle,
std::map< int, edm::DetSetVector< CTPPSDiamondRecHit >> &  out_diamond_hits_per_particle 
) const
private

xi is positive for diffractive protons, thus proton momentum p = (1-xi) * p_nom horizontal component of proton momentum: p_x = th_x * (1-xi) * p_nom

Definition at line 341 of file CTPPSDirectProtonSimulation.cc.

References A, CTPPSDetId::arm(), B, checkIsHit_, LHCInfo::crossingAngle(), DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2, efficiencyMapsPerPlane_, efficiencyMapsPerRP_, empiricalAperture45_, empiricalAperture56_, edm::DetSet< T >::emplace_back(), edm::DetSetVector< T >::find_or_insert(), CTPPSBeamParameters::getBeamMom45(), CTPPSBeamParameters::getBeamMom56(), DetGeomDesc::getDiamondDimensions(), CTPPSBeamParameters::getHalfXangleX45(), CTPPSBeamParameters::getHalfXangleX56(), CTPPSGeometry::globalToLocal(), insensitiveMarginStrips_, invalid, RPTopology::IsHit(), PPSPixelTopology::isPixelHit(), CTPPSGeometry::localToGlobal(), visualization-live-secondInstance_cfg::m, AlCaHLTBitMon_ParallelJobs::p, pitchPixelsHor_, pitchPixelsVer_, pitchStrips_, CTPPSPixelDetId::plane(), produceHitsRelativeToBeam_, produceRecHits_, produceScoringPlaneHits_, edm::DetSet< T >::push_back(), alignCSCRings::r, DetId::rawId(), roundToPitch_, CTPPSDetId::rp(), CTPPSDetId::sdTimingDiamond, CTPPSDetId::sdTrackingPixel, CTPPSDetId::sdTrackingStrip, CTPPSGeometry::sensor(), CTPPSGeometry::sensorsInRP(), DetGeomDesc::sensorType(), mathSSE::sqrt(), CTPPSDetId::station(), digitizers_cfi::strip, stripZeroPosition_, DetId::subdetId(), FrontierCondition_GT_autoExpress_cfi::t0, LHCInterpolatedOpticalFunctionsSet::Kinematics::th_x, LHCInterpolatedOpticalFunctionsSet::Kinematics::th_y, timeResolutionDiamonds45_, timeResolutionDiamonds56_, compareTotals::tot, useEmpiricalApertures_, useTimingEfficiencyPerPlane_, useTimingEfficiencyPerRP_, useTrackingEfficiencyPerPlane_, useTrackingEfficiencyPerRP_, findQualityFiles::v, verbosity_, LHCInterpolatedOpticalFunctionsSet::Kinematics::x, DiamondDimensions::xHalfWidth, and LHCInterpolatedOpticalFunctionsSet::Kinematics::y.

Referenced by produce().

356  {
359 
360  std::stringstream ssLog;
361 
362  // vectors in CMS convention
363  const HepMC::FourVector &vtx_cms = in_vtx->position(); // in mm
364  const HepMC::FourVector &mom_cms = in_trk->momentum();
365 
366  // transformation to LHC/TOTEM convention
367  HepMC::FourVector vtx_lhc(-vtx_cms.x(), vtx_cms.y(), -vtx_cms.z(), vtx_cms.t());
368  HepMC::FourVector mom_lhc(-mom_cms.x(), mom_cms.y(), -mom_cms.z(), mom_cms.t());
369 
370  // determine the LHC arm and related parameters
371  unsigned int arm = 3;
372  double z_sign;
373  double beamMomentum = 0.;
374  double xangle = 0.;
375  const std::unique_ptr<TF2> *empiricalAperture;
376  if (mom_lhc.z() < 0) // sector 45
377  {
378  arm = 0;
379  z_sign = -1;
380  beamMomentum = beamParameters.getBeamMom45();
381  xangle = beamParameters.getHalfXangleX45();
382  empiricalAperture = &empiricalAperture45_;
383  } else { // sector 56
384  arm = 1;
385  z_sign = +1;
386  beamMomentum = beamParameters.getBeamMom56();
387  xangle = beamParameters.getHalfXangleX56();
388  empiricalAperture = &empiricalAperture56_;
389  }
390 
391  // calculate effective RP arrival time
392  // effective time mimics the timing calibration -> effective times are distributed about 0
393  // units:
394  // vertex: all components in mm
395  // c_light: in mm/ns
396  // time_eff: in ns
397  const double time_eff = (vtx_lhc.t() - z_sign * vtx_lhc.z()) / CLHEP::c_light;
398 
399  // calculate kinematics for optics parametrisation
400  const double p = mom_lhc.rho();
401  const double xi = 1. - p / beamMomentum;
402  const double th_x_phys = mom_lhc.x() / p;
403  const double th_y_phys = mom_lhc.y() / p;
404  const double vtx_lhc_eff_x = vtx_lhc.x() - vtx_lhc.z() * (mom_lhc.x() / mom_lhc.z() + xangle);
405  const double vtx_lhc_eff_y = vtx_lhc.y() - vtx_lhc.z() * (mom_lhc.y() / mom_lhc.z());
406 
407  if (verbosity_) {
408  ssLog << "simu: xi = " << xi << ", th_x_phys = " << th_x_phys << ", th_y_phys = " << th_y_phys
409  << ", vtx_lhc_eff_x = " << vtx_lhc_eff_x << ", vtx_lhc_eff_y = " << vtx_lhc_eff_y << std::endl;
410  }
411 
412  // check empirical aperture
414  const auto &xangle = lhcInfo.crossingAngle();
415  (*empiricalAperture)->SetParameter("xi", xi);
416  (*empiricalAperture)->SetParameter("xangle", xangle);
417  const double th_x_th = (*empiricalAperture)->EvalPar(nullptr);
418 
419  if (th_x_th > th_x_phys) {
420  if (verbosity_) {
421  ssLog << "stop because of empirical appertures";
422  edm::LogInfo("PPS") << ssLog.str();
423  }
424 
425  return;
426  }
427  }
428 
429  // transport the proton into each pot/scoring plane
430  for (const auto &ofp : opticalFunctions) {
431  CTPPSDetId rpId(ofp.first);
432  const unsigned int rpDecId = rpId.arm() * 100 + rpId.station() * 10 + rpId.rp();
433 
434  // first check the arm
435  if (rpId.arm() != arm)
436  continue;
437 
438  if (verbosity_)
439  ssLog << " RP " << rpDecId << std::endl;
440 
441  // transport proton
443  vtx_lhc_eff_x * 1E-1, th_x_phys, vtx_lhc_eff_y * 1E-1, th_y_phys, xi}; // conversions: mm -> cm
445  ofp.second.transport(k_in, k_out, true);
446 
447  double b_x = k_out.x * 1E1, b_y = k_out.y * 1E1; // conversions: cm -> mm
448  double a_x = k_out.th_x, a_y = k_out.th_y;
449 
450  // if needed, subtract beam position and angle
452  // determine beam position
453  LHCInterpolatedOpticalFunctionsSet::Kinematics k_be_in = {0., 0., 0., 0., 0.};
455  ofp.second.transport(k_be_in, k_be_out, true);
456 
457  a_x -= k_be_out.th_x;
458  a_y -= k_be_out.th_y;
459  b_x -= k_be_out.x * 1E1;
460  b_y -= k_be_out.y * 1E1; // conversions: cm -> mm
461  }
462 
463  const double z_scoringPlane = ofp.second.getScoringPlaneZ() * 1E1; // conversion: cm --> mm
464 
465  if (verbosity_) {
466  ssLog << " proton transported: a_x = " << a_x << " rad, a_y = " << a_y << " rad, b_x = " << b_x
467  << " mm, b_y = " << b_y << " mm, z = " << z_scoringPlane << " mm" << std::endl;
468  }
469 
470  // RP type
471  const bool isTrackingRP =
472  (rpId.subdetId() == CTPPSDetId::sdTrackingStrip || rpId.subdetId() == CTPPSDetId::sdTrackingPixel);
473  const bool isTimingRP = (rpId.subdetId() == CTPPSDetId::sdTimingDiamond);
474 
475  // apply per-RP efficiency
476  if ((useTimingEfficiencyPerRP_ && isTimingRP) || (useTrackingEfficiencyPerRP_ && isTrackingRP)) {
477  const auto it = efficiencyMapsPerRP_.find(rpId);
478 
479  if (it != efficiencyMapsPerRP_.end()) {
480  const double r = CLHEP::RandFlat::shoot(rndEngine, 0., 1.);
481  auto *effMap = it->second.get();
482  const double eff = effMap->GetBinContent(effMap->FindBin(b_x, b_y));
483  if (r > eff) {
484  if (verbosity_)
485  ssLog << " stop due to per-RP efficiency" << std::endl;
486  continue;
487  }
488  }
489  }
490 
491  // save scoring plane hit
493  out_tracks.emplace_back(
494  rpId.rawId(), b_x, 0., b_y, 0., 0., 0., 0., 0., 0., CTPPSpixelLocalTrackReconstructionInfo::invalid, 0, 0., 0.);
495 
496  // stop if rec hits are not to be produced
497  if (!produceRecHits_)
498  continue;
499 
500  // loop over all sensors in the RP
501  for (const auto &detIdInt : geometry.sensorsInRP(rpId)) {
502  CTPPSDetId detId(detIdInt);
503 
504  // determine the track impact point (in global coordinates)
505  // !! this assumes that local axes (1, 0, 0) and (0, 1, 0) describe the sensor surface
506  const auto &gl_o = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 0, 0));
507  const auto &gl_a1 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(1, 0, 0)) - gl_o;
508  const auto &gl_a2 = geometry.localToGlobal(detId, CTPPSGeometry::Vector(0, 1, 0)) - gl_o;
509 
510  const double gl_o_z = gl_o.z();
511 
512  TMatrixD A(3, 3);
513  TVectorD B(3);
514  A(0, 0) = a_x;
515  A(0, 1) = -gl_a1.x();
516  A(0, 2) = -gl_a2.x();
517  B(0) = gl_o.x() - b_x;
518  A(1, 0) = a_y;
519  A(1, 1) = -gl_a1.y();
520  A(1, 2) = -gl_a2.y();
521  B(1) = gl_o.y() - b_y;
522  A(2, 0) = z_sign;
523  A(2, 1) = -gl_a1.z();
524  A(2, 2) = -gl_a2.z();
525  B(2) = gl_o_z - z_scoringPlane;
526  TMatrixD Ai(3, 3);
527  Ai = A.Invert();
528  TVectorD P(3);
529  P = Ai * B;
530 
531  double ze = P(0);
532  const CTPPSGeometry::Vector h_glo(a_x * ze + b_x, a_y * ze + b_y, z_sign * ze + z_scoringPlane);
533 
534  // hit in local coordinates
535  auto h_loc = geometry.globalToLocal(detId, h_glo);
536 
537  if (verbosity_) {
538  ssLog << std::endl
539  << " de z = " << P(0) << " mm, p1 = " << P(1) << " mm, p2 = " << P(2) << " mm" << std::endl
540  << " h_glo: x = " << h_glo.x() << " mm, y = " << h_glo.y() << " mm, z = " << h_glo.z() << " mm"
541  << std::endl
542  << " h_loc: c1 = " << h_loc.x() << " mm, c2 = " << h_loc.y() << " mm, c3 = " << h_loc.z() << " mm"
543  << std::endl;
544  }
545 
546  // apply per-plane efficiency
547  if ((useTimingEfficiencyPerPlane_ && isTimingRP) || (useTrackingEfficiencyPerPlane_ && isTrackingRP)) {
548  const auto it = efficiencyMapsPerPlane_.find(detId);
549 
550  if (it != efficiencyMapsPerPlane_.end()) {
551  const double r = CLHEP::RandFlat::shoot(rndEngine, 0., 1.);
552  auto *effMap = it->second.get();
553  const double eff = effMap->GetBinContent(effMap->FindBin(h_glo.x(), h_glo.y()));
554  if (r > eff) {
555  if (verbosity_)
556  ssLog << " stop due to per-plane efficiency" << std::endl;
557  continue;
558  }
559  }
560  }
561 
562  // strips
563  if (detId.subdetId() == CTPPSDetId::sdTrackingStrip) {
564  double u = h_loc.x();
565  double v = h_loc.y();
566 
567  if (verbosity_ > 5)
568  ssLog << " u=" << u << ", v=" << v;
569 
570  // is it within detector?
572  if (verbosity_ > 5)
573  ssLog << " | no hit" << std::endl;
574  continue;
575  }
576 
577  // round the measurement
578  if (roundToPitch_) {
579  double m = stripZeroPosition_ - v;
580  signed int strip = (int)floor(m / pitchStrips_ + 0.5);
581 
583 
584  if (verbosity_ > 5)
585  ssLog << " | strip=" << strip;
586  }
587 
588  double sigma = pitchStrips_ / sqrt(12.);
589 
590  if (verbosity_ > 5)
591  ssLog << " | m=" << v << ", sigma=" << sigma << std::endl;
592 
593  edm::DetSet<TotemRPRecHit> &hits = out_strip_hits.find_or_insert(detId);
594  hits.emplace_back(v, sigma);
595 
596  edm::DetSet<TotemRPRecHit> &hits_per_particle =
597  out_strip_hits_per_particle[in_trk->barcode()].find_or_insert(detId);
598  hits_per_particle.emplace_back(v, sigma);
599  }
600 
601  // diamonds
602  if (detId.subdetId() == CTPPSDetId::sdTimingDiamond) {
603  CTPPSDiamondDetId diamondDetId(detIdInt);
604 
605  // check acceptance
606  const auto *dg = geometry.sensor(detIdInt);
607  const auto &diamondDimensions = dg->getDiamondDimensions();
608  const auto x_half_width = diamondDimensions.xHalfWidth;
609  const auto y_half_width = diamondDimensions.yHalfWidth;
610  const auto z_half_width = diamondDimensions.zHalfWidth;
611 
612  if (h_loc.x() < -x_half_width || h_loc.x() > +x_half_width || h_loc.y() < -y_half_width ||
613  h_loc.y() > +y_half_width)
614  continue;
615 
616  // timing information
617  const double time_resolution = (diamondDetId.arm() == 0) ? timeResolutionDiamonds45_->Eval(h_glo.x())
618  : timeResolutionDiamonds56_->Eval(h_glo.x());
619 
620  const double t0 = time_eff + CLHEP::RandGauss::shoot(rndEngine, 0., time_resolution);
621  const double tot = 1.23456;
622  const double ch_t_precis = time_resolution;
623  const int time_slice = 0;
624 
625  // build rec hit
626  const bool multiHit = false;
627 
628  CTPPSDiamondRecHit rc(gl_o.x(),
629  2. * x_half_width,
630  gl_o.y(),
631  2. * y_half_width,
632  gl_o_z,
633  2. * z_half_width,
634  t0,
635  tot,
636  ch_t_precis,
637  time_slice,
638  HPTDCErrorFlags(),
639  multiHit);
640 
641  edm::DetSet<CTPPSDiamondRecHit> &hits = out_diamond_hits.find_or_insert(detId);
642  hits.push_back(rc);
643 
644  edm::DetSet<CTPPSDiamondRecHit> &hits_per_particle =
645  out_diamond_hits_per_particle[in_trk->barcode()].find_or_insert(detId);
646  hits_per_particle.push_back(rc);
647  }
648 
649  // pixels
650  if (detId.subdetId() == CTPPSDetId::sdTrackingPixel) {
651  if (verbosity_) {
652  CTPPSPixelDetId pixelDetId(detIdInt);
653  ssLog << " pixel plane " << pixelDetId.plane() << ": local hit x = " << h_loc.x()
654  << " mm, y = " << h_loc.y() << " mm, z = " << h_loc.z() << " mm" << std::endl;
655  }
656 
657  bool module3By2 = (geometry.sensor(detIdInt)->sensorType() != DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2);
658  if (checkIsHit_ && !ppt.isPixelHit(h_loc.x(), h_loc.y(), module3By2))
659  continue;
660 
661  if (roundToPitch_) {
662  h_loc.SetX(pitchPixelsHor_ * floor(h_loc.x() / pitchPixelsHor_ + 0.5));
663  h_loc.SetY(pitchPixelsVer_ * floor(h_loc.y() / pitchPixelsVer_ + 0.5));
664  }
665 
666  if (verbosity_ > 5)
667  ssLog << " hit accepted: m1 = " << h_loc.x() << " mm, m2 = " << h_loc.y() << " mm" << std::endl;
668 
669  const double sigmaHor = pitchPixelsHor_ / sqrt(12.);
670  const double sigmaVer = pitchPixelsVer_ / sqrt(12.);
671 
672  const LocalPoint lp(h_loc.x(), h_loc.y(), h_loc.z());
673  const LocalError le(sigmaHor, 0., sigmaVer);
674 
675  edm::DetSet<CTPPSPixelRecHit> &hits = out_pixel_hits.find_or_insert(detId);
676  hits.emplace_back(lp, le);
677 
678  edm::DetSet<CTPPSPixelRecHit> &hits_per_particle =
679  out_pixel_hits_per_particle[in_trk->barcode()].find_or_insert(detId);
680  hits_per_particle.emplace_back(lp, le);
681  }
682  }
683  }
684 
685  if (verbosity_)
686  edm::LogInfo("PPS") << ssLog.str();
687 }
bool isPixelHit(float xLocalCoordinate, float yLocalCoordinate, bool is3x2) const
void push_back(const T &t)
Definition: DetSet.h:66
Definition: APVGainStruct.h:7
std::map< unsigned int, std::unique_ptr< TH2F > > efficiencyMapsPerPlane_
const std::string & sensorType() const
Definition: DetGeomDesc.h:99
Reconstructed hit in diamond detectors.
const DiamondDimensions & getDiamondDimensions() const
Definition: DetGeomDesc.h:90
static bool IsHit(double u, double v, double insensitiveMargin=0)
Definition: RPTopology.cc:29
const std::string DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2
Definition: CTPPSDDDNames.h:17
DetGeomDesc::Translation Vector
Definition: CTPPSGeometry.h:36
Vector localToGlobal(const DetGeomDesc *, const Vector &) const
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:234
float const crossingAngle() const
Definition: LHCInfo.cc:182
Vector globalToLocal(const DetGeomDesc *, const Vector &) const
std::unique_ptr< TF1 > timeResolutionDiamonds45_
decltype(auto) emplace_back(Args &&...args)
Definition: DetSet.h:68
T sqrt(T t)
Definition: SSEVec.h:19
double getBeamMom56() const
double insensitiveMarginStrips_
size of insensitive margin at sensor&#39;s edge facing the beam, in mm
double getHalfXangleX56() const
std::map< unsigned int, std::unique_ptr< TH2F > > efficiencyMapsPerRP_
Log< level::Info, false > LogInfo
const std::set< unsigned int > & sensorsInRP(unsigned int) const
after checks returns set of sensor ids corresponding to the given RP id
const DetGeomDesc * sensor(unsigned int id) const
returns geometry of a detector performs necessary checks, returns NULL if fails
std::unique_ptr< TF1 > timeResolutionDiamonds56_
std::pair< OmniClusterRef, TrackingParticleRef > P
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
double stripZeroPosition_
internal variable: v position of strip 0, in mm
double getBeamMom45() const
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
Definition: APVGainStruct.h:7
double getHalfXangleX45() const
void CTPPSDirectProtonSimulation::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 245 of file CTPPSDirectProtonSimulation.cc.

References edm::ESWatcher< T >::check(), directSimuDataRcdWatcher_, efficiencyMapsPerPlane_, efficiencyMapsPerRP_, empiricalAperture45_, empiricalAperture56_, relativeConstraints::geometry, edm::Event::getByToken(), edm::EventSetup::getData(), edm::RandomNumberGenerator::getEngine(), hepMCToken_, eostools::move(), pixelTopologyToken_, processProton(), produceRecHits_, produceScoringPlaneHits_, edm::Event::put(), edm::Event::streamID(), timeResolutionDiamonds45_, timeResolutionDiamonds56_, tokenBeamParameters_, tokenDirectSimuData_, tokenGeometry_, tokenLHCInfo_, tokenOpticalFunctions_, useTimingEfficiencyPerPlane_, useTimingEfficiencyPerRP_, useTrackingEfficiencyPerPlane_, and useTrackingEfficiencyPerRP_.

245  {
246  // get input
248  iEvent.getByToken(hepMCToken_, hepmc_prod);
249 
250  // get conditions
251  auto const &lhcInfo = iSetup.getData(tokenLHCInfo_);
252  auto const &beamParameters = iSetup.getData(tokenBeamParameters_);
253  auto const &ppt = iSetup.getData(pixelTopologyToken_);
254  auto const &opticalFunctions = iSetup.getData(tokenOpticalFunctions_);
255  auto const &geometry = iSetup.getData(tokenGeometry_);
256  auto const &directSimuData = iSetup.getData(tokenDirectSimuData_);
257 
258  if (directSimuDataRcdWatcher_.check(iSetup)) {
260  std::make_unique<TF1>(TF1("timeResolutionDiamonds45", directSimuData.getTimeResolutionDiamonds45().c_str()));
262  std::make_unique<TF1>(TF1("timeResolutionDiamonds56", directSimuData.getTimeResolutionDiamonds56().c_str()));
263 
265  std::make_unique<TF2>(TF2("empiricalAperture45", directSimuData.getEmpiricalAperture45().c_str()));
267  std::make_unique<TF2>(TF2("empiricalAperture56", directSimuData.getEmpiricalAperture56().c_str()));
268 
269  // load the efficiency maps
271  efficiencyMapsPerRP_ = directSimuData.loadEffeciencyHistogramsPerRP();
273  efficiencyMapsPerPlane_ = directSimuData.loadEffeciencyHistogramsPerPlane();
274  }
275 
276  // prepare outputs
277  std::unique_ptr<edm::DetSetVector<TotemRPRecHit>> pStripRecHits(new edm::DetSetVector<TotemRPRecHit>());
278  std::unique_ptr<edm::DetSetVector<CTPPSDiamondRecHit>> pDiamondRecHits(new edm::DetSetVector<CTPPSDiamondRecHit>());
279  std::unique_ptr<edm::DetSetVector<CTPPSPixelRecHit>> pPixelRecHits(new edm::DetSetVector<CTPPSPixelRecHit>());
280 
281  auto pStripRecHitsPerParticle = std::make_unique<std::map<int, edm::DetSetVector<TotemRPRecHit>>>();
282  auto pDiamondRecHitsPerParticle = std::make_unique<std::map<int, edm::DetSetVector<CTPPSDiamondRecHit>>>();
283  auto pPixelRecHitsPerParticle = std::make_unique<std::map<int, edm::DetSetVector<CTPPSPixelRecHit>>>();
284 
285  std::unique_ptr<std::vector<CTPPSLocalTrackLite>> pTracks(new std::vector<CTPPSLocalTrackLite>());
286 
287  // get random engine
289  CLHEP::HepRandomEngine *engine = &rng->getEngine(iEvent.streamID());
290 
291  // loop over event vertices
292  auto evt = hepmc_prod->GetEvent();
293  for (auto it_vtx = evt->vertices_begin(); it_vtx != evt->vertices_end(); ++it_vtx) {
294  auto vtx = *(it_vtx);
295 
296  // loop over outgoing particles
297  for (auto it_part = vtx->particles_out_const_begin(); it_part != vtx->particles_out_const_end(); ++it_part) {
298  auto part = *(it_part);
299 
300  // accept only stable protons
301  if (part->pdg_id() != 2212)
302  continue;
303 
304  if (part->status() != 1 && part->status() < 83)
305  continue;
306 
307  processProton(vtx,
308  part,
309  geometry,
310  lhcInfo,
311  beamParameters,
312  ppt,
313  opticalFunctions,
314  engine,
315  *pTracks,
316  *pStripRecHits,
317  *pPixelRecHits,
318  *pDiamondRecHits,
319  *pStripRecHitsPerParticle,
320  *pPixelRecHitsPerParticle,
321  *pDiamondRecHitsPerParticle);
322  }
323  }
324 
326  iEvent.put(std::move(pTracks));
327 
328  if (produceRecHits_) {
329  iEvent.put(std::move(pStripRecHits));
330  iEvent.put(std::move(pPixelRecHits));
331  iEvent.put(std::move(pDiamondRecHits));
332 
333  iEvent.put(std::move(pStripRecHitsPerParticle));
334  iEvent.put(std::move(pPixelRecHitsPerParticle));
335  iEvent.put(std::move(pDiamondRecHitsPerParticle));
336  }
337 }
edm::ESGetToken< LHCInfo, LHCInfoRcd > tokenLHCInfo_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void processProton(const HepMC::GenVertex *in_vtx, const HepMC::GenParticle *in_trk, const CTPPSGeometry &geometry, const LHCInfo &lhcInfo, const CTPPSBeamParameters &beamParameters, const PPSPixelTopology &ppt, const LHCInterpolatedOpticalFunctionsSetCollection &opticalFunctions, CLHEP::HepRandomEngine *rndEngine, std::vector< CTPPSLocalTrackLite > &out_tracks, edm::DetSetVector< TotemRPRecHit > &out_strip_hits, edm::DetSetVector< CTPPSPixelRecHit > &out_pixel_hits, edm::DetSetVector< CTPPSDiamondRecHit > &out_diamond_hits, std::map< int, edm::DetSetVector< TotemRPRecHit >> &out_strip_hits_per_particle, std::map< int, edm::DetSetVector< CTPPSPixelRecHit >> &out_pixel_hits_per_particle, std::map< int, edm::DetSetVector< CTPPSDiamondRecHit >> &out_diamond_hits_per_particle) const
std::map< unsigned int, std::unique_ptr< TH2F > > efficiencyMapsPerPlane_
edm::ESGetToken< LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd > tokenOpticalFunctions_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::ESGetToken< CTPPSGeometry, VeryForwardMisalignedGeometryRecord > tokenGeometry_
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::ESWatcher< PPSDirectSimulationDataRcd > directSimuDataRcdWatcher_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::EDGetTokenT< edm::HepMCProduct > hepMCToken_
std::unique_ptr< TF1 > timeResolutionDiamonds45_
def move
Definition: eostools.py:511
std::map< unsigned int, std::unique_ptr< TH2F > > efficiencyMapsPerRP_
edm::ESGetToken< PPSDirectSimulationData, PPSDirectSimulationDataRcd > tokenDirectSimuData_
part
Definition: HCALResponse.h:20
std::unique_ptr< TF1 > timeResolutionDiamonds56_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
StreamID streamID() const
Definition: Event.h:98
edm::ESGetToken< PPSPixelTopology, PPSPixelTopologyRcd > pixelTopologyToken_
edm::ESGetToken< CTPPSBeamParameters, CTPPSBeamParametersRcd > tokenBeamParameters_

Member Data Documentation

bool CTPPSDirectProtonSimulation::checkIsHit_
private

Definition at line 132 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

edm::ESWatcher<PPSDirectSimulationDataRcd> CTPPSDirectProtonSimulation::directSimuDataRcdWatcher_
private

Definition at line 105 of file CTPPSDirectProtonSimulation.cc.

Referenced by produce().

std::map<unsigned int, std::unique_ptr<TH2F> > CTPPSDirectProtonSimulation::efficiencyMapsPerPlane_
private

Definition at line 127 of file CTPPSDirectProtonSimulation.cc.

Referenced by processProton(), and produce().

std::map<unsigned int, std::unique_ptr<TH2F> > CTPPSDirectProtonSimulation::efficiencyMapsPerRP_
private

Definition at line 126 of file CTPPSDirectProtonSimulation.cc.

Referenced by processProton(), and produce().

std::unique_ptr<TF2> CTPPSDirectProtonSimulation::empiricalAperture45_
private

Definition at line 116 of file CTPPSDirectProtonSimulation.cc.

Referenced by processProton(), and produce().

std::unique_ptr<TF2> CTPPSDirectProtonSimulation::empiricalAperture56_
private

Definition at line 117 of file CTPPSDirectProtonSimulation.cc.

Referenced by processProton(), and produce().

edm::EDGetTokenT<edm::HepMCProduct> CTPPSDirectProtonSimulation::hepMCToken_
private

Definition at line 108 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and produce().

double CTPPSDirectProtonSimulation::insensitiveMarginStrips_
private

size of insensitive margin at sensor's edge facing the beam, in mm

Definition at line 135 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

double CTPPSDirectProtonSimulation::pitchPixelsHor_
private

Definition at line 137 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

double CTPPSDirectProtonSimulation::pitchPixelsVer_
private

Definition at line 138 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

double CTPPSDirectProtonSimulation::pitchStrips_
private

strip pitch in mm

Definition at line 134 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

edm::ESGetToken<PPSPixelTopology, PPSPixelTopologyRcd> CTPPSDirectProtonSimulation::pixelTopologyToken_
private

Definition at line 100 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and produce().

bool CTPPSDirectProtonSimulation::produceHitsRelativeToBeam_
private

Definition at line 130 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

bool CTPPSDirectProtonSimulation::produceRecHits_
private
bool CTPPSDirectProtonSimulation::produceScoringPlaneHits_
private
bool CTPPSDirectProtonSimulation::roundToPitch_
private

Definition at line 131 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

double CTPPSDirectProtonSimulation::stripZeroPosition_
private

internal variable: v position of strip 0, in mm

Definition at line 147 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

std::unique_ptr<TF1> CTPPSDirectProtonSimulation::timeResolutionDiamonds45_
private

Definition at line 142 of file CTPPSDirectProtonSimulation.cc.

Referenced by processProton(), and produce().

std::unique_ptr<TF1> CTPPSDirectProtonSimulation::timeResolutionDiamonds56_
private

Definition at line 142 of file CTPPSDirectProtonSimulation.cc.

Referenced by processProton(), and produce().

edm::ESGetToken<CTPPSBeamParameters, CTPPSBeamParametersRcd> CTPPSDirectProtonSimulation::tokenBeamParameters_
private

Definition at line 99 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and produce().

edm::ESGetToken<PPSDirectSimulationData, PPSDirectSimulationDataRcd> CTPPSDirectProtonSimulation::tokenDirectSimuData_
private

Definition at line 103 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and produce().

edm::ESGetToken<CTPPSGeometry, VeryForwardMisalignedGeometryRecord> CTPPSDirectProtonSimulation::tokenGeometry_
private

Definition at line 102 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and produce().

edm::ESGetToken<LHCInfo, LHCInfoRcd> CTPPSDirectProtonSimulation::tokenLHCInfo_
private

Definition at line 98 of file CTPPSDirectProtonSimulation.cc.

Referenced by produce().

edm::ESGetToken<LHCInterpolatedOpticalFunctionsSetCollection, CTPPSInterpolatedOpticsRcd> CTPPSDirectProtonSimulation::tokenOpticalFunctions_
private

Definition at line 101 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and produce().

bool CTPPSDirectProtonSimulation::useEmpiricalApertures_
private

Definition at line 115 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().

bool CTPPSDirectProtonSimulation::useTimingEfficiencyPerPlane_
private
bool CTPPSDirectProtonSimulation::useTimingEfficiencyPerRP_
private
bool CTPPSDirectProtonSimulation::useTrackingEfficiencyPerPlane_
private
bool CTPPSDirectProtonSimulation::useTrackingEfficiencyPerRP_
private
unsigned int CTPPSDirectProtonSimulation::verbosity_
private

Definition at line 140 of file CTPPSDirectProtonSimulation.cc.

Referenced by CTPPSDirectProtonSimulation(), and processProton().