CMS 3D CMS Logo

SSDigitizerAlgorithm.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 
5 
9 
10 // Geometry
13 
14 using namespace edm;
15 
16 namespace {
17  double nFactorial(int n);
18  double aScalingConstant(int N, int i);
19 } // namespace
20 namespace {
21  double nFactorial(int n) { return std::tgamma(n + 1); }
22  double aScalingConstant(int N, int i) {
23  return std::pow(-1, (double)i) * nFactorial(N) * nFactorial(N + 2) /
24  (nFactorial(N - i) * nFactorial(N + 2 - i) * nFactorial(i));
25  }
26 } // namespace
27 
29  if (use_LorentzAngle_DB_) { // Get Lorentz angle from DB record
30  siPhase2OTLorentzAngle_ = &es.getData(siPhase2OTLorentzAngleToken_);
31  }
32 
33  geom_ = &es.getData(geomToken_);
34 }
35 
37  : Phase2TrackerDigitizerAlgorithm(conf.getParameter<ParameterSet>("AlgorithmCommon"),
38  conf.getParameter<ParameterSet>("SSDigitizerAlgorithm"),
39  iC),
40  hitDetectionMode_(conf.getParameter<ParameterSet>("SSDigitizerAlgorithm").getParameter<int>("HitDetectionMode")),
41  pulseShapeParameters_(conf.getParameter<ParameterSet>("SSDigitizerAlgorithm")
42  .getParameter<std::vector<double> >("PulseShapeParameters")),
43  deadTime_(conf.getParameter<ParameterSet>("SSDigitizerAlgorithm").getParameter<double>("CBCDeadTime")),
44  geomToken_(iC.esConsumes()) {
47  pixelFlag_ = false;
48  LogDebug("SSDigitizerAlgorithm ") << "SSDigitizerAlgorithm constructed "
49  << "Configuration parameters:"
50  << "Threshold/Gain = "
51  << "threshold in electron Endcap = " << theThresholdInE_Endcap_
52  << "threshold in electron Barrel = " << theThresholdInE_Barrel_ << " "
53  << theElectronPerADC_ << " " << theAdcFullScale_ << " The delta cut-off is set to "
54  << tMax_ << " pix-inefficiency " << addPixelInefficiency_;
56 }
57 SSDigitizerAlgorithm::~SSDigitizerAlgorithm() { LogDebug("SSDigitizerAlgorithm") << "SSDigitizerAlgorithm deleted"; }
58 //
59 // -- Select the Hit for Digitization
60 //
61 bool SSDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const {
62  bool result = false;
64  result = select_hit_sampledMode(hit, tCorr, sigScale);
66  result = select_hit_latchedMode(hit, tCorr, sigScale);
67  else {
68  double toa = hit.tof() - tCorr;
69  result = (toa > theTofLowerCut_ && toa < theTofUpperCut_);
70  }
71  return result;
72 }
73 //
74 // -- Select Hits in Sampled Mode
75 //
76 bool SSDigitizerAlgorithm::select_hit_sampledMode(const PSimHit& hit, double tCorr, double& sigScale) const {
77  double toa = hit.tof() - tCorr;
78  double sampling_time = bx_time;
79 
80  DetId det_id = DetId(hit.detUnitId());
81  float theThresholdInE =
83 
84  sigScale = getSignalScale(sampling_time - toa);
85  return (sigScale * hit.energyLoss() / GeVperElectron_ > theThresholdInE);
86 }
87 //
88 // -- Select Hits in Hit Detection Mode
89 //
90 bool SSDigitizerAlgorithm::select_hit_latchedMode(const PSimHit& hit, double tCorr, double& sigScale) const {
91  float toa = hit.tof() - tCorr;
92  toa -= hit.eventId().bunchCrossing() * bx_time;
93 
94  float sampling_time = (-1) * (hit.eventId().bunchCrossing() + 1) * bx_time;
95 
96  DetId det_id = DetId(hit.detUnitId());
97  float theThresholdInE =
99 
100  bool lastPulse = true;
101  bool aboveThr = false;
102  for (float i = deadTime_; i <= bx_time; i++) {
103  sigScale = getSignalScale(sampling_time - toa + i);
104 
105  aboveThr = (sigScale * hit.energyLoss() / GeVperElectron_ > theThresholdInE);
106  if (!lastPulse && aboveThr)
107  return true;
108 
109  lastPulse = aboveThr;
110  }
111  return false;
112 }
114  constexpr size_t max_par = 6;
115  if (pulseShapeParameters_.size() < max_par)
116  return -1;
117  double xOffset = pulseShapeParameters_[0];
118  double tau = pulseShapeParameters_[1];
119  double r = pulseShapeParameters_[2];
120  double theta = pulseShapeParameters_[3];
121  int nTerms = static_cast<int>(pulseShapeParameters_[4]);
122 
123  double fN = 0;
124  double xx = x - xOffset;
125  if (xx < 0)
126  return 0;
127 
128  for (int i = 0; i < nTerms; i++) {
129  double angularTerm = 0;
130  double temporalTerm = 0;
131  double rTerm = std::pow(r, i) / (std::pow(tau, 2. * i) * ::nFactorial(i + 2));
132  for (int j = 0; j <= i; j++) {
133  angularTerm += std::pow(std::cos(theta), (double)(i - j)) * std::pow(std::sin(theta), (double)j);
134  temporalTerm += ::aScalingConstant(i, j) * std::pow(xx, (double)(i - j)) * std::pow(tau, (double)j);
135  }
136  double fi = rTerm * angularTerm * temporalTerm;
137 
138  fN += fi;
139  }
140  return fN;
141 }
142 double SSDigitizerAlgorithm::signalShape(double x) const {
143  double xOffset = pulseShapeParameters_[0];
144  double tau = pulseShapeParameters_[1];
145  double maxCharge = pulseShapeParameters_[5];
146 
147  double xx = x - xOffset;
148  return maxCharge * (std::exp(-xx / tau) * std::pow(xx / tau, 2.) * cbc3PulsePolarExpansion(x));
149 }
151  for (size_t i = 0; i < interpolationPoints; i++) {
152  float val = i / interpolationStep;
153 
154  pulseShapeVec_.push_back(signalShape(val));
155  }
156 }
157 double SSDigitizerAlgorithm::getSignalScale(double xval) const {
158  double res = 0.0;
159  int len = pulseShapeVec_.size();
160 
161  if (xval < 0.0 || xval * interpolationStep >= len)
162  return res;
163 
164  unsigned int lower = std::floor(xval) * interpolationStep;
165  unsigned int upper = std::ceil(xval) * interpolationStep;
166  for (size_t i = lower + 1; i < upper * interpolationStep; i++) {
167  float val = i * 0.1;
168  if (val > xval) {
169  res = pulseShapeVec_[i - 1];
170  break;
171  }
172  }
173  return res;
174 }
175 //
176 // -- Compare Signal with Threshold
177 //
179  float charge,
180  float thr) const {
181  return (charge >= thr);
182 }
SSDigitizerAlgorithm::storeSignalShape
void storeSignalShape()
Definition: SSDigitizerAlgorithm.cc:150
Phase2TrackerDigitizerAlgorithm::theThresholdInE_Barrel_
const float theThresholdInE_Barrel_
Definition: Phase2TrackerDigitizerAlgorithm.h:144
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
SSDigitizerAlgorithm::SSDigitizerAlgorithm
SSDigitizerAlgorithm(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
Definition: SSDigitizerAlgorithm.cc:36
Phase2TrackerDigitizerAlgorithm::theTofUpperCut_
const float theTofUpperCut_
Definition: Phase2TrackerDigitizerAlgorithm.h:153
metsig::tau
Definition: SignAlgoResolutions.h:49
SSDigitizerAlgorithm::interpolationStep
static constexpr int interpolationStep
Definition: SSDigitizerAlgorithm.h:37
SSDigitizerAlgorithm::pulseShapeVec_
std::vector< double > pulseShapeVec_
Definition: SSDigitizerAlgorithm.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
SSDigitizerAlgorithm::isAboveThreshold
bool isAboveThreshold(const DigitizerUtility::SimHitInfo *hitInfo, float charge, float thr) const override
Definition: SSDigitizerAlgorithm.cc:178
SSDigitizerAlgorithm::interpolationPoints
static constexpr size_t interpolationPoints
Definition: SSDigitizerAlgorithm.h:36
SSDigitizerAlgorithm::bx_time
static constexpr float bx_time
Definition: SSDigitizerAlgorithm.h:35
Phase2TrackerDigitizerAlgorithm::use_LorentzAngle_DB_
const bool use_LorentzAngle_DB_
Definition: Phase2TrackerDigitizerAlgorithm.h:116
SSDigitizerAlgorithm::~SSDigitizerAlgorithm
~SSDigitizerAlgorithm() override
Definition: SSDigitizerAlgorithm.cc:57
DDAxes::x
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
SSDigitizerAlgorithm::siPhase2OTLorentzAngleToken_
edm::ESGetToken< SiPhase2OuterTrackerLorentzAngle, SiPhase2OuterTrackerLorentzAngleSimRcd > siPhase2OTLorentzAngleToken_
Definition: SSDigitizerAlgorithm.h:33
Phase2TrackerDigitizerAlgorithm::theTofLowerCut_
const float theTofLowerCut_
Definition: Phase2TrackerDigitizerAlgorithm.h:152
DetId
Definition: DetId.h:17
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
reco::ceil
constexpr int32_t ceil(float num)
Definition: constexpr_cmath.h:7
Phase2TrackerDigitizerAlgorithm::theAdcFullScale_
const int theAdcFullScale_
Definition: Phase2TrackerDigitizerAlgorithm.h:138
SSDigitizerAlgorithm::signalShape
double signalShape(double x) const
Definition: SSDigitizerAlgorithm.cc:142
SSDigitizerAlgorithm::pulseShapeParameters_
std::vector< double > pulseShapeParameters_
Definition: SSDigitizerAlgorithm.h:31
N
#define N
Definition: blowfish.cc:9
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
hcaldqm::quantity::fN
Definition: ValueQuantity.h:11
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
SSDigitizerAlgorithm::cbc3PulsePolarExpansion
double cbc3PulsePolarExpansion(double x) const
Definition: SSDigitizerAlgorithm.cc:113
SSDigitizerAlgorithm::select_hit_sampledMode
bool select_hit_sampledMode(const PSimHit &hit, double tCorr, double &sigScale) const
Definition: SSDigitizerAlgorithm.cc:76
SSDigitizerAlgorithm.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
Phase2TrackerDigitizerAlgorithm
Definition: Phase2TrackerDigitizerAlgorithm.h:54
Phase2TrackerDigitizerAlgorithm::pixelFlag_
bool pixelFlag_
Definition: Phase2TrackerDigitizerAlgorithm.h:235
Phase2TrackerDigitizerAlgorithm::tMax_
const double tMax_
Definition: Phase2TrackerDigitizerAlgorithm.h:176
SSDigitizerAlgorithm::LatchedMode
Definition: SSDigitizerAlgorithm.h:21
createfilelist.int
int
Definition: createfilelist.py:10
phase1PixelTopology::xOffset
constexpr int16_t xOffset
Definition: phase1PixelTopology.h:19
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
SSDigitizerAlgorithm::deadTime_
float deadTime_
Definition: SSDigitizerAlgorithm.h:32
SSDigitizerAlgorithm::select_hit
bool select_hit(const PSimHit &hit, double tCorr, double &sigScale) const override
Definition: SSDigitizerAlgorithm.cc:61
Phase2TrackerDigitizerAlgorithm::theElectronPerADC_
const float theElectronPerADC_
Definition: Phase2TrackerDigitizerAlgorithm.h:137
edm::EventSetup
Definition: EventSetup.h:58
Phase2TrackerDigitizerAlgorithm::GeVperElectron_
const float GeVperElectron_
Definition: Phase2TrackerDigitizerAlgorithm.h:123
res
Definition: Electron.h:6
Phase2TrackerDigitizerAlgorithm::theThresholdInE_Endcap_
const float theThresholdInE_Endcap_
Definition: Phase2TrackerDigitizerAlgorithm.h:143
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
alignCSCRings.r
r
Definition: alignCSCRings.py:93
SSDigitizerAlgorithm::select_hit_latchedMode
bool select_hit_latchedMode(const PSimHit &hit, double tCorr, double &sigScale) const
Definition: SSDigitizerAlgorithm.cc:90
DigitizerUtility::SimHitInfo
Definition: DigitizerUtility.h:14
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
SSDigitizerAlgorithm::SampledMode
Definition: SSDigitizerAlgorithm.h:21
SSDigitizerAlgorithm::init
void init(const edm::EventSetup &es) override
Definition: SSDigitizerAlgorithm.cc:28
SSDigitizerAlgorithm::hitDetectionMode_
int hitDetectionMode_
Definition: SSDigitizerAlgorithm.h:29
genVertex_cff.x
x
Definition: genVertex_cff.py:13
PixelGeomDetUnit.h
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
pileupCalc.upper
upper
Definition: pileupCalc.py:213
SSDigitizerAlgorithm::getSignalScale
double getSignalScale(double xval) const
Definition: SSDigitizerAlgorithm.cc:157
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
ParameterSet.h
PSimHit
Definition: PSimHit.h:15
Phase2TrackerDigitizerAlgorithm::addPixelInefficiency_
const bool addPixelInefficiency_
Definition: Phase2TrackerDigitizerAlgorithm.h:163
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
StripSubdetector.h
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
hit
Definition: SiStripHitEffFromCalibTree.cc:88