CMS 3D CMS Logo

GEMSignalModel.cc
Go to the documentation of this file.
7 #include "CLHEP/Random/RandFlat.h"
8 #include "CLHEP/Random/RandPoissonQ.h"
9 #include "CLHEP/Random/RandGaussQ.h"
10 #include "CLHEP/Units/GlobalPhysicalConstants.h"
12 #include <cmath>
13 #include <utility>
14 #include <map>
15 
18  averageEfficiency_(config.getParameter<double>("averageEfficiency")),
19  averageShapingTime_(config.getParameter<double>("averageShapingTime")),
20  timeResolution_(config.getParameter<double>("timeResolution")),
21  timeJitter_(config.getParameter<double>("timeJitter")),
22  signalPropagationSpeed_(config.getParameter<double>("signalPropagationSpeed")),
23  digitizeOnlyMuons_(config.getParameter<bool>("digitizeOnlyMuons")),
24  resolutionX_(config.getParameter<double>("resolutionX")),
25  muonPdgId(13),
26  cspeed(geant_units::operators::convertMmToCm(CLHEP::c_light)),
27  momConvFact(1000.),
28  elecMomCut1(1.96e-03),
29  elecMomCut2(10.e-03),
30  elecEffLowCoeff(1.7e-05),
31  elecEffLowParam0(2.1),
32  elecEffMidCoeff(1.34),
33  elecEffMidParam0(-5.75e-01),
34  elecEffMidParam1(7.96e-01) {}
35 
37 
40  CLHEP::HepRandomEngine* engine,
41  Strips& strips_,
42  DetectorHitMap& detectorHitMap_) {
43  bool digiMuon = false;
44  bool digiElec = false;
45  const GEMStripTopology* top(dynamic_cast<const GEMStripTopology*>(&(roll->topology())));
46  for (const auto& hit : simHits) {
47  if (std::abs(hit.particleType()) != muonPdgId && digitizeOnlyMuons_)
48  continue;
49  double elecEff = 0.;
50  double partMom = hit.pabs();
51  double checkMuonEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
52  double checkElecEff = CLHEP::RandFlat::shoot(engine, 0., 1.);
53  if (std::abs(hit.particleType()) == muonPdgId && checkMuonEff < averageEfficiency_)
54  digiMuon = true;
55  if (std::abs(hit.particleType()) != muonPdgId) //consider all non muon particles with gem efficiency to electrons
56  {
57  if (partMom <= elecMomCut1)
58  elecEff = elecEffLowCoeff * std::exp(elecEffLowParam0 * partMom * momConvFact);
59  if (partMom > elecMomCut1 && partMom < elecMomCut2)
62  if (partMom > elecMomCut2)
63  elecEff = 1.;
64  if (checkElecEff < elecEff)
65  digiElec = true;
66  }
67  if (!(digiMuon || digiElec))
68  continue;
69  const int bx(getSimHitBx(&hit, engine));
70  const std::vector<std::pair<int, int> >& cluster(simulateClustering(top, &hit, bx, engine));
71  for (const auto& digi : cluster) {
72  detectorHitMap_.emplace(digi, &hit);
73  strips_.emplace(digi);
74  }
75  }
76 }
77 
78 int GEMSignalModel::getSimHitBx(const PSimHit* simhit, CLHEP::HepRandomEngine* engine) {
79  int bx = -999;
80  const LocalPoint simHitPos(simhit->localPosition());
81  const float tof(simhit->timeOfFlight());
82  // random Gaussian time correction due to electronics jitter
83  float randomJitterTime = CLHEP::RandGaussQ::shoot(engine, 0., timeJitter_);
84  const GEMDetId id(simhit->detUnitId());
85  const GEMEtaPartition* roll(geometry_->etaPartition(id));
86  if (!roll) {
87  throw cms::Exception("Geometry") << "GEMSignalModel::getSimHitBx() - GEM simhit id does not match any GEM roll id: "
88  << id << "\n";
89  return 999;
90  }
91  if (roll->id().region() == 0) {
92  throw cms::Exception("Geometry")
93  << "GEMSignalModel::getSimHitBx() - this GEM id is from barrel, which cannot happen: " << roll->id() << "\n";
94  }
95  const int nstrips = roll->nstrips();
96  float middleStrip = nstrips / 2.;
97  const LocalPoint& middleOfRoll = roll->centreOfStrip(middleStrip);
98  const GlobalPoint& globMiddleRol = roll->toGlobal(middleOfRoll);
99  double muRadius = sqrt(globMiddleRol.x() * globMiddleRol.x() + globMiddleRol.y() * globMiddleRol.y() +
100  globMiddleRol.z() * globMiddleRol.z());
101  double timeCalibrationOffset_ = muRadius / cspeed; //[ns]
102 
103  const GEMStripTopology* top(dynamic_cast<const GEMStripTopology*>(&(roll->topology())));
104  const float halfStripLength(0.5 * top->stripLength());
105  const float distanceFromEdge(halfStripLength - simHitPos.y());
106 
107  // signal propagation speed in material in [cm/ns]
108  double signalPropagationSpeedTrue = signalPropagationSpeed_ * cspeed;
109 
110  // average time for the signal to propagate from the SimHit to the top of a strip
111  const float averagePropagationTime(distanceFromEdge / signalPropagationSpeedTrue);
112  // random Gaussian time correction due to the finite timing resolution of the detector
113  float randomResolutionTime = CLHEP::RandGaussQ::shoot(engine, 0., timeResolution_);
114  const float simhitTime(tof + averageShapingTime_ + randomResolutionTime + averagePropagationTime + randomJitterTime);
115  float referenceTime = 0.;
116  referenceTime = timeCalibrationOffset_ + halfStripLength / signalPropagationSpeedTrue + averageShapingTime_;
117  const float timeDifference(simhitTime - referenceTime);
118  // assign the bunch crossing
119  bx = static_cast<int>(std::round((timeDifference) / 25.));
120 
121  // check time
122  LogDebug("GEMDigiProducer") << "checktime "
123  << "bx = " << bx << "\tdeltaT = " << timeDifference << "\tsimT = " << simhitTime
124  << "\trefT = " << referenceTime << "\ttof = " << tof
125  << "\tavePropT = " << averagePropagationTime
126  << "\taveRefPropT = " << halfStripLength / signalPropagationSpeedTrue << "\n";
127  return bx;
128 }
129 
130 std::vector<std::pair<int, int> > GEMSignalModel::simulateClustering(const GEMStripTopology* top,
131  const PSimHit* simHit,
132  const int bx,
133  CLHEP::HepRandomEngine* engine) {
134  const LocalPoint& hit_entry(simHit->entryPoint());
135  const LocalPoint& hit_exit(simHit->exitPoint());
136 
137  LocalPoint start_point, end_point;
138  if (hit_entry.x() < hit_exit.x()) {
139  start_point = hit_entry;
140  end_point = hit_exit;
141  } else {
142  start_point = hit_exit;
143  end_point = hit_entry;
144  }
145 
146  // Add Gaussian noise to the points towards outside.
147  float smeared_start_x = start_point.x() - std::abs(CLHEP::RandGaussQ::shoot(engine, 0, resolutionX_));
148  float smeared_end_x = end_point.x() + std::abs(CLHEP::RandGaussQ::shoot(engine, 0, resolutionX_));
149 
150  LocalPoint smeared_start_point(smeared_start_x, start_point.y(), start_point.z());
151  LocalPoint smeared_end_point(smeared_end_x, end_point.y(), end_point.z());
152 
153  int cluster_start = top->channel(smeared_start_point);
154  int cluster_end = top->channel(smeared_end_point);
155 
156  std::vector<std::pair<int, int> > cluster;
157  for (int strip = cluster_start; strip <= cluster_end; strip++) {
158  cluster.emplace_back(strip, bx);
159  }
160 
161  return cluster;
162 }
PSimHit::timeOfFlight
float timeOfFlight() const
Definition: PSimHit.h:73
electrons_cff.bool
bool
Definition: electrons_cff.py:366
GEMSignalModel::resolutionX_
double resolutionX_
Definition: GEMSignalModel.h:47
GEMSignalModel::elecEffMidParam0
const double elecEffMidParam0
Definition: GEMSignalModel.h:57
MessageLogger.h
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
GEMSignalModel::digitizeOnlyMuons_
bool digitizeOnlyMuons_
Definition: GEMSignalModel.h:46
GEMStripTopology.h
GEMEtaPartition
Definition: GEMEtaPartition.h:12
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
FastTrackerRecHitCombiner_cfi.simHits
simHits
Definition: FastTrackerRecHitCombiner_cfi.py:5
GEMDigiModel
Definition: GEMDigiModel.h:37
GEMStripTopology
Definition: GEMStripTopology.h:11
GEMSignalModel::muonPdgId
const int muonPdgId
Definition: GEMSignalModel.h:49
GEMStripTopology::channel
int channel(const LocalPoint &) const override
Definition: GEMStripTopology.cc:107
GEMSignalModel::simulateClustering
std::vector< std::pair< int, int > > simulateClustering(const GEMStripTopology *, const PSimHit *, const int, CLHEP::HepRandomEngine *)
Definition: GEMSignalModel.cc:130
GEMSignalModel::cspeed
const double cspeed
Definition: GEMSignalModel.h:50
PSimHit::detUnitId
unsigned int detUnitId() const
Definition: PSimHit.h:97
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
config
Definition: config.py:1
GEMSignalModel::elecEffLowParam0
const double elecEffLowParam0
Definition: GEMSignalModel.h:55
GEMSignalModel::GEMSignalModel
GEMSignalModel(const edm::ParameterSet &)
Definition: GEMSignalModel.cc:16
GEMSignalModel::elecMomCut1
const double elecMomCut1
Definition: GEMSignalModel.h:52
rpcPointValidation_cfi.simHit
simHit
Definition: rpcPointValidation_cfi.py:24
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
PSimHit::localPosition
Local3DPoint localPosition() const
Definition: PSimHit.h:52
GEMSignalModel::averageShapingTime_
double averageShapingTime_
Definition: GEMSignalModel.h:42
Point3DBase< float, LocalTag >
Strips
std::set< std::pair< int, int > > Strips
Definition: GEMDigiModel.h:31
DetectorHitMap
std::multimap< std::pair< unsigned int, int >, const PSimHit *, std::less< std::pair< unsigned int, int > > > DetectorHitMap
Definition: GEMDigiModel.h:35
CLHEP
Definition: CocoaGlobals.h:27
GEMSignalModel::momConvFact
const double momConvFact
Definition: GEMSignalModel.h:51
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
GEMEtaPartitionSpecs.h
edm::ParameterSet
Definition: ParameterSet.h:47
GeantUnits.h
GEMSignalModel.h
GEMDetId
Definition: GEMDetId.h:18
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
GEMEtaPartition::topology
const Topology & topology() const override
Definition: GEMEtaPartition.cc:14
GEMSignalModel::getSimHitBx
int getSimHitBx(const PSimHit *, CLHEP::HepRandomEngine *)
Definition: GEMSignalModel.cc:78
GEMSignalModel::elecEffLowCoeff
const double elecEffLowCoeff
Definition: GEMSignalModel.h:54
GEMSignalModel::elecEffMidParam1
const double elecEffMidParam1
Definition: GEMSignalModel.h:58
GEMSignalModel::elecEffMidCoeff
const double elecEffMidCoeff
Definition: GEMSignalModel.h:56
GEMSignalModel::simulate
void simulate(const GEMEtaPartition *, const edm::PSimHitContainer &, CLHEP::HepRandomEngine *, Strips &, DetectorHitMap &) override
Definition: GEMSignalModel.cc:38
GEMSignalModel::signalPropagationSpeed_
double signalPropagationSpeed_
Definition: GEMSignalModel.h:45
GEMSignalModel::averageEfficiency_
double averageEfficiency_
Definition: GEMSignalModel.h:41
GEMGeometry.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
GEMSignalModel::timeJitter_
double timeJitter_
Definition: GEMSignalModel.h:44
Exception
Definition: hltDiff.cc:245
GEMSignalModel::elecMomCut2
const double elecMomCut2
Definition: GEMSignalModel.h:53
GEMSignalModel::timeResolution_
double timeResolution_
Definition: GEMSignalModel.h:43
Exception.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
GEMDigiModel::geometry_
const GEMGeometry * geometry_
Definition: GEMDigiModel.h:47
geant_units::operators::convertMmToCm
constexpr NumType convertMmToCm(NumType millimeters)
Definition: GeantUnits.h:63
geant_units
Definition: GeantUnits.h:11
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
PSimHit
Definition: PSimHit.h:15
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
GEMSignalModel::~GEMSignalModel
~GEMSignalModel() override
Definition: GEMSignalModel.cc:36
hit
Definition: SiStripHitEffFromCalibTree.cc:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
GEMGeometry::etaPartition
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:77