CMS 3D CMS Logo

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