CMS 3D CMS Logo

PixelDigitizerAlgorithm.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 
6 
11 
12 // Geometry
15 
16 using namespace edm;
17 using namespace sipixelobjects;
18 
20  if (use_ineff_from_db_) // load gain calibration service fromdb...
21  theSiPixelGainCalibrationService_->setESObjects(es);
22 
23  if (use_deadmodule_DB_)
24  siPixelBadModule_ = &es.getData(siPixelBadModuleToken_);
25 
26  if (use_LorentzAngle_DB_) // Get Lorentz angle from DB record
27  siPixelLorentzAngle_ = &es.getData(siPixelLorentzAngleToken_);
28 
29  // gets the map and geometry from the DB (to kill ROCs)
30  fedCablingMap_ = &es.getData(fedCablingMapToken_);
31  geom_ = &es.getData(geomToken_);
32 }
33 
35  : Phase2TrackerDigitizerAlgorithm(conf.getParameter<ParameterSet>("AlgorithmCommon"),
36  conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm"),
37  iC),
38  odd_row_interchannelCoupling_next_row_(conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm")
39  .getParameter<double>("Odd_row_interchannelCoupling_next_row")),
40  even_row_interchannelCoupling_next_row_(conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm")
41  .getParameter<double>("Even_row_interchannelCoupling_next_row")),
42  odd_column_interchannelCoupling_next_column_(
43  conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm")
44  .getParameter<double>("Odd_column_interchannelCoupling_next_column")),
45  even_column_interchannelCoupling_next_column_(
46  conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm")
47  .getParameter<double>("Even_column_interchannelCoupling_next_column")),
48  apply_timewalk_(conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm").getParameter<bool>("ApplyTimewalk")),
49  timewalk_model_(
50  conf.getParameter<ParameterSet>("PixelDigitizerAlgorithm").getParameter<edm::ParameterSet>("TimewalkModel")),
51  fedCablingMapToken_(iC.esConsumes()),
52  geomToken_(iC.esConsumes()) {
57  pixelFlag_ = true;
58  LogDebug("PixelDigitizerAlgorithm") << "Algorithm constructed "
59  << "Configuration parameters:"
60  << "Threshold/Gain = "
61  << "threshold in electron Endcap = " << theThresholdInE_Endcap_
62  << "threshold in electron Barrel = " << theThresholdInE_Barrel_ << " "
64  << " The delta cut-off is set to " << tMax_ << " pix-inefficiency "
66 }
67 PixelDigitizerAlgorithm::~PixelDigitizerAlgorithm() { LogDebug("PixelDigitizerAlgorithm") << "Algorithm deleted"; }
68 //
69 // -- Select the Hit for Digitization
70 //
71 bool PixelDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, double& sigScale) const {
72  double time = hit.tof() - tCorr;
73  return (time >= theTofLowerCut_ && time < theTofUpperCut_);
74 }
75 
76 // ======================================================================
77 //
78 // Add Cross-talk contribution
79 //
80 // ======================================================================
82  if (!pixelFlag_)
83  return;
84 
85  const Phase2TrackerTopology* topol = &pixdet->specificTopology();
86 
87  // cross-talk calculation valid for the case of 25x100 pixels
88  const float pitch_first = 0.0025;
89  const float pitch_second = 0.0100;
90 
91  // 0.5 um tolerance when comparing the pitch to accommodate the small changes in different TK geometrie (temporary fix)
92  const double pitch_tolerance(0.0005);
93 
94  if (std::abs(topol->pitch().first - pitch_first) > pitch_tolerance ||
95  std::abs(topol->pitch().second - pitch_second) > pitch_tolerance)
96  return;
97 
98  uint32_t detID = pixdet->geographicalId().rawId();
99  signal_map_type& theSignal = _signal[detID];
100  signal_map_type signalNew;
101 
102  int numRows = topol->nrows();
103  int numColumns = topol->ncolumns();
104 
105  for (auto& s : theSignal) {
106  float signalInElectrons = s.second.ampl(); // signal in electrons
107 
108  auto hitChan = PixelDigi::channelToPixel(s.first);
109 
110  float signalInElectrons_odd_row_Xtalk_next_row = signalInElectrons * odd_row_interchannelCoupling_next_row_;
111  float signalInElectrons_even_row_Xtalk_next_row = signalInElectrons * even_row_interchannelCoupling_next_row_;
112  float signalInElectrons_odd_column_Xtalk_next_column =
114  float signalInElectrons_even_column_Xtalk_next_column =
116 
117  // subtract the charge which will be shared
118  s.second.set(signalInElectrons - signalInElectrons_odd_row_Xtalk_next_row -
119  signalInElectrons_even_row_Xtalk_next_row - signalInElectrons_odd_column_Xtalk_next_column -
120  signalInElectrons_even_column_Xtalk_next_column);
121 
122  if (hitChan.first != 0) {
123  auto XtalkPrev = std::make_pair(hitChan.first - 1, hitChan.second);
124  int chanXtalkPrev = pixelFlag_ ? PixelDigi::pixelToChannel(XtalkPrev.first, XtalkPrev.second)
125  : Phase2TrackerDigi::pixelToChannel(XtalkPrev.first, XtalkPrev.second);
126  if (hitChan.first % 2 == 1)
127  signalNew.emplace(chanXtalkPrev,
128  DigitizerUtility::Amplitude(signalInElectrons_even_row_Xtalk_next_row, nullptr, -1.0));
129  else
130  signalNew.emplace(chanXtalkPrev,
131  DigitizerUtility::Amplitude(signalInElectrons_odd_row_Xtalk_next_row, nullptr, -1.0));
132  }
133  if (hitChan.first < numRows - 1) {
134  auto XtalkNext = std::make_pair(hitChan.first + 1, hitChan.second);
135  int chanXtalkNext = pixelFlag_ ? PixelDigi::pixelToChannel(XtalkNext.first, XtalkNext.second)
136  : Phase2TrackerDigi::pixelToChannel(XtalkNext.first, XtalkNext.second);
137  if (hitChan.first % 2 == 1)
138  signalNew.emplace(chanXtalkNext,
139  DigitizerUtility::Amplitude(signalInElectrons_odd_row_Xtalk_next_row, nullptr, -1.0));
140  else
141  signalNew.emplace(chanXtalkNext,
142  DigitizerUtility::Amplitude(signalInElectrons_even_row_Xtalk_next_row, nullptr, -1.0));
143  }
144 
145  if (hitChan.second != 0) {
146  auto XtalkPrev = std::make_pair(hitChan.first, hitChan.second - 1);
147  int chanXtalkPrev = pixelFlag_ ? PixelDigi::pixelToChannel(XtalkPrev.first, XtalkPrev.second)
148  : Phase2TrackerDigi::pixelToChannel(XtalkPrev.first, XtalkPrev.second);
149  if (hitChan.second % 2 == 1)
150  signalNew.emplace(chanXtalkPrev,
151  DigitizerUtility::Amplitude(signalInElectrons_even_column_Xtalk_next_column, nullptr, -1.0));
152  else
153  signalNew.emplace(chanXtalkPrev,
154  DigitizerUtility::Amplitude(signalInElectrons_odd_column_Xtalk_next_column, nullptr, -1.0));
155  }
156  if (hitChan.second < numColumns - 1) {
157  auto XtalkNext = std::make_pair(hitChan.first, hitChan.second + 1);
158  int chanXtalkNext = pixelFlag_ ? PixelDigi::pixelToChannel(XtalkNext.first, XtalkNext.second)
159  : Phase2TrackerDigi::pixelToChannel(XtalkNext.first, XtalkNext.second);
160  if (hitChan.second % 2 == 1)
161  signalNew.emplace(chanXtalkNext,
162  DigitizerUtility::Amplitude(signalInElectrons_odd_column_Xtalk_next_column, nullptr, -1.0));
163  else
164  signalNew.emplace(chanXtalkNext,
165  DigitizerUtility::Amplitude(signalInElectrons_even_column_Xtalk_next_column, nullptr, -1.0));
166  }
167  }
168  for (auto const& l : signalNew) {
169  int chan = l.first;
170  auto iter = theSignal.find(chan);
171  if (iter != theSignal.end()) {
172  iter->second += l.second.ampl();
173  } else {
174  theSignal.emplace(chan, DigitizerUtility::Amplitude(l.second.ampl(), nullptr, -1.0));
175  }
176  }
177 }
178 
180  : x_(pset.getParameter<std::vector<double>>("charge")), y_(pset.getParameter<std::vector<double>>("delay")) {
181  if (x_.size() != y_.size())
182  throw cms::Exception("Configuration")
183  << "Timewalk model error: the number of charge values does not match the number of delay values!";
184 }
185 
187  auto it = std::lower_bound(x_.begin(), x_.end(), x);
188  if (it == x_.begin())
189  return y_.front();
190  if (it == x_.end())
191  return y_.back();
192  int index = std::distance(x_.begin(), it);
193  double x_high = *it;
194  double x_low = *(--it);
195  double p = (x - x_low) / (x_high - x_low);
196  return p * y_[index] + (1 - p) * y_[index - 1];
197 }
198 
200  threshold_values = pset.getParameter<std::vector<double>>("ThresholdValues");
201  const auto& curve_psetvec = pset.getParameter<std::vector<edm::ParameterSet>>("Curves");
202  if (threshold_values.size() != curve_psetvec.size())
203  throw cms::Exception("Configuration")
204  << "Timewalk model error: the number of threshold values does not match the number of curves.";
205  for (const auto& curve_pset : curve_psetvec)
206  curves.emplace_back(curve_pset);
207 }
208 
209 double PixelDigitizerAlgorithm::TimewalkModel::operator()(double q_in, double q_threshold) const {
210  auto index = find_closest_index(threshold_values, q_threshold);
211  return curves[index](q_in);
212 }
213 
214 std::size_t PixelDigitizerAlgorithm::TimewalkModel::find_closest_index(const std::vector<double>& vec,
215  double value) const {
216  auto it = std::lower_bound(vec.begin(), vec.end(), value);
217  if (it == vec.begin())
218  return 0;
219  else if (it == vec.end())
220  return vec.size() - 1;
221  else {
222  auto it_upper = it;
223  auto it_lower = --it;
224  auto closest = (value - *it_lower > *it_upper - value) ? it_upper : it_lower;
225  return std::distance(vec.begin(), closest);
226  }
227 }
228 //
229 // -- Compare Signal with Threshold
230 //
232  float charge,
233  float thr) const {
234  if (charge < thr)
235  return false;
236  if (apply_timewalk_ && hitInfo) {
237  float corrected_time = hitInfo->time();
238  double time = corrected_time + timewalk_model_(charge, thr);
239  return (time >= theTofLowerCut_ && time < theTofUpperCut_);
240  } else
241  return true;
242 }
PixelDigitizerAlgorithm::siPixelBadModuleToken_
edm::ESGetToken< SiPixelQuality, SiPixelQualityRcd > siPixelBadModuleToken_
Definition: PixelDigitizerAlgorithm.h:64
Phase2TrackerDigitizerAlgorithm::signal_map_type
std::map< int, DigitizerUtility::Amplitude, std::less< int > > signal_map_type
Definition: Phase2TrackerDigitizerAlgorithm.h:103
electrons_cff.bool
bool
Definition: electrons_cff.py:366
Phase2TrackerDigitizerAlgorithm::theThresholdInE_Barrel_
const float theThresholdInE_Barrel_
Definition: Phase2TrackerDigitizerAlgorithm.h:144
MessageLogger.h
PixelTopology.h
Phase2TrackerDigitizerAlgorithm::theTofUpperCut_
const float theTofUpperCut_
Definition: Phase2TrackerDigitizerAlgorithm.h:153
edm
HLT enums.
Definition: AlignableModifier.h:19
PixelDigitizerAlgorithm::init
void init(const edm::EventSetup &es) override
Definition: PixelDigitizerAlgorithm.cc:19
PSimHitContainer.h
PixelTopology::pitch
virtual std::pair< float, float > pitch() const =0
PixelDigitizerAlgorithm::TimewalkModel::TimewalkModel
TimewalkModel(const edm::ParameterSet &pset)
Definition: PixelDigitizerAlgorithm.cc:199
protons_cff.time
time
Definition: protons_cff.py:35
PixelDigitizerAlgorithm::odd_column_interchannelCoupling_next_column_
const double odd_column_interchannelCoupling_next_column_
Definition: PixelDigitizerAlgorithm.h:57
Phase2TrackerDigitizerAlgorithm::use_LorentzAngle_DB_
const bool use_LorentzAngle_DB_
Definition: Phase2TrackerDigitizerAlgorithm.h:116
PixelDigitizerAlgorithm::TimewalkModel::find_closest_index
std::size_t find_closest_index(const std::vector< double > &vec, double value) const
Definition: PixelDigitizerAlgorithm.cc:214
PixelDigitizerAlgorithm::odd_row_interchannelCoupling_next_row_
const double odd_row_interchannelCoupling_next_row_
Definition: PixelDigitizerAlgorithm.h:55
DDAxes::x
SiPixelGainCalibrationOfflineSimService.h
edm::ConsumesCollector::esConsumes
auto esConsumes()
Definition: ConsumesCollector.h:97
Phase2TrackerDigi::pixelToChannel
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
Definition: Phase2TrackerDigi.h:43
Phase2TrackerDigitizerAlgorithm::theTofLowerCut_
const float theTofLowerCut_
Definition: Phase2TrackerDigitizerAlgorithm.h:152
DigitizerUtility::SimHitInfo::time
float time() const
Definition: DigitizerUtility.h:23
PixelDigitizerAlgorithm::apply_timewalk_
bool apply_timewalk_
Definition: PixelDigitizerAlgorithm.h:61
alignCSCRings.s
s
Definition: alignCSCRings.py:92
PixelDigitizerAlgorithm.h
PixelDigitizerAlgorithm::even_row_interchannelCoupling_next_row_
const double even_row_interchannelCoupling_next_row_
Definition: PixelDigitizerAlgorithm.h:56
PixelDigitizerAlgorithm::isAboveThreshold
bool isAboveThreshold(const DigitizerUtility::SimHitInfo *hitInfo, float charge, float thr) const override
Definition: PixelDigitizerAlgorithm.cc:231
Phase2TrackerDigitizerAlgorithm::theAdcFullScale_
const int theAdcFullScale_
Definition: Phase2TrackerDigitizerAlgorithm.h:138
sipixelobjects
Definition: CablingPathToDetUnit.h:4
DigitizerUtility::Amplitude
Definition: DigitizerUtility.h:33
PixelGeomDetUnit
Definition: PixelGeomDetUnit.h:15
PixelTopology::ncolumns
virtual int ncolumns() const =0
PixelDigitizerAlgorithm::add_cross_talk
void add_cross_talk(const Phase2TrackerGeomDetUnit *pixdet) override
Definition: PixelDigitizerAlgorithm.cc:81
PixelDigi::pixelToChannel
static int pixelToChannel(int row, int col)
Definition: PixelDigi.h:75
PixelTopology
Definition: PixelTopology.h:10
PixelDigitizerAlgorithm::timewalk_model_
const TimewalkModel timewalk_model_
Definition: PixelDigitizerAlgorithm.h:62
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
GeomDet::geographicalId
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:64
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
PixelDigitizerAlgorithm::TimewalkCurve::y_
std::vector< double > y_
Definition: PixelDigitizerAlgorithm.h:25
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
Phase2TrackerDigitizerAlgorithm
Definition: Phase2TrackerDigitizerAlgorithm.h:54
Phase2TrackerDigitizerAlgorithm::pixelFlag_
bool pixelFlag_
Definition: Phase2TrackerDigitizerAlgorithm.h:235
Phase2TrackerDigitizerAlgorithm::tMax_
const double tMax_
Definition: Phase2TrackerDigitizerAlgorithm.h:176
PixelGeomDetUnit::specificTopology
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
Definition: PixelGeomDetUnit.cc:17
PixelDigitizerAlgorithm::TimewalkCurve::x_
std::vector< double > x_
Definition: PixelDigitizerAlgorithm.h:24
value
Definition: value.py:1
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
PixelDigitizerAlgorithm::PixelDigitizerAlgorithm
PixelDigitizerAlgorithm(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
Definition: PixelDigitizerAlgorithm.cc:34
Phase2TrackerDigitizerAlgorithm::theElectronPerADC_
const float theElectronPerADC_
Definition: Phase2TrackerDigitizerAlgorithm.h:137
edm::EventSetup
Definition: EventSetup.h:58
PixelDigitizerAlgorithm::even_column_interchannelCoupling_next_column_
const double even_column_interchannelCoupling_next_column_
Definition: PixelDigitizerAlgorithm.h:58
Phase2TrackerDigitizerAlgorithm::theThresholdInE_Endcap_
const float theThresholdInE_Endcap_
Definition: Phase2TrackerDigitizerAlgorithm.h:143
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
DigitizerUtility::SimHitInfo
Definition: DigitizerUtility.h:14
Phase2TrackerDigitizerAlgorithm::use_deadmodule_DB_
const bool use_deadmodule_DB_
Definition: Phase2TrackerDigitizerAlgorithm.h:115
PixelDigitizerAlgorithm::TimewalkCurve::TimewalkCurve
TimewalkCurve(const edm::ParameterSet &pset)
Definition: PixelDigitizerAlgorithm.cc:179
Phase2TrackerDigitizerAlgorithm::_signal
signalMaps _signal
Definition: Phase2TrackerDigitizerAlgorithm.h:109
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
PixelDigitizerAlgorithm::select_hit
bool select_hit(const PSimHit &hit, double tCorr, double &sigScale) const override
Definition: PixelDigitizerAlgorithm.cc:71
PixelDigitizerAlgorithm::siPixelLorentzAngleToken_
edm::ESGetToken< SiPixelLorentzAngle, SiPixelLorentzAngleSimRcd > siPixelLorentzAngleToken_
Definition: PixelDigitizerAlgorithm.h:65
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
relativeConstraints.value
value
Definition: relativeConstraints.py:53
PixelGeomDetUnit.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ConsumesCollector.h
cms::Exception
Definition: Exception.h:70
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
PSimHit
Definition: PSimHit.h:15
Phase2TrackerDigitizerAlgorithm::addPixelInefficiency_
const bool addPixelInefficiency_
Definition: Phase2TrackerDigitizerAlgorithm.h:163
PixelDigitizerAlgorithm::TimewalkModel::operator()
double operator()(double q_in, double q_threshold) const
Definition: PixelDigitizerAlgorithm.cc:209
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
PixelTopology::nrows
virtual int nrows() const =0
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7746
PixelDigitizerAlgorithm::~PixelDigitizerAlgorithm
~PixelDigitizerAlgorithm() override
Definition: PixelDigitizerAlgorithm.cc:67
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
hit
Definition: SiStripHitEffFromCalibTree.cc:88
PixelDigitizerAlgorithm::TimewalkCurve::operator()
double operator()(double x) const
Definition: PixelDigitizerAlgorithm.cc:186
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
PixelDigi::channelToPixel
static std::pair< int, int > channelToPixel(int ch)
Definition: PixelDigi.h:69