CMS 3D CMS Logo

RPixDummyROCSimulator.cc
Go to the documentation of this file.
2 #include <vector>
3 #include "TRandom.h"
4 #include <iostream>
5 
6 RPixDummyROCSimulator::RPixDummyROCSimulator(const edm::ParameterSet &params, uint32_t det_id) : det_id_(det_id) {
7  threshold_ = params.getParameter<double>("RPixDummyROCThreshold");
8  electron_per_adc_ = params.getParameter<double>("RPixDummyROCElectronPerADC");
9  VcaltoElectronGain_ = params.getParameter<int>("VCaltoElectronGain");
10  VcaltoElectronOffset_ = params.getParameter<int>("VCaltoElectronOffset");
11  doSingleCalibration_ = params.getParameter<bool>("doSingleCalibration");
12  dead_pixel_probability_ = params.getParameter<double>("RPixDeadPixelProbability");
13  dead_pixels_simulation_on_ = params.getParameter<bool>("RPixDeadPixelSimulationOn");
14  verbosity_ = params.getParameter<int>("RPixVerbosity");
15  links_persistence_ = params.getParameter<bool>("CTPPSPixelDigiSimHitRelationsPersistence");
16 }
17 
19  const std::map<unsigned short, double> &signals,
20  std::map<unsigned short, std::vector<std::pair<int, double> > > &theSignalProvenance,
21  std::vector<CTPPSPixelDigi> &output_digi,
22  std::vector<std::vector<std::pair<int, double> > > &output_digi_links,
23  const CTPPSPixelGainCalibrations *pcalibrations) {
24  for (std::map<unsigned short, double>::const_iterator i = signals.begin(); i != signals.end(); ++i) {
25  //one threshold per hybrid
26  unsigned short pixel_no = i->first;
27  if (verbosity_)
28  edm::LogInfo("PPS") << "RPixDummyROCSimulator "
29  << "Dummy ROC adc and threshold : " << i->second << ", " << threshold_;
30  if (i->second > threshold_ && (!dead_pixels_simulation_on_ || dead_pixels_.find(pixel_no) == dead_pixels_.end())) {
31  float gain = 0;
32  float pedestal = 0;
33  int adc = 0;
34  uint32_t col = pixel_no / 160;
35  uint32_t row = pixel_no % 160;
36 
37  const CTPPSPixelGainCalibration &DetCalibs = pcalibrations->getGainCalibration(det_id_);
38 
39  // Avoid exception due to col > 103 in case of 2x2 plane. To be removed
40  if (col >= DetCalibs.getNCols())
41  continue;
42 
44  adc = int(round(i->second / electron_per_adc_));
45  } else {
46  if (DetCalibs.getDetId() != 0) {
47  gain = DetCalibs.getGain(col, row) * highRangeCal_ / lowRangeCal_; // *highRangeCal/lowRangeCal
48  pedestal = DetCalibs.getPed(col, row);
49  adc = int(round((i->second - VcaltoElectronOffset_) / (gain * VcaltoElectronGain_) + pedestal));
50  }
51  }
53  if (adc >= maxADC_)
54  adc = maxADC_;
55  if (adc < 0)
56  adc = 0;
57  output_digi.push_back(CTPPSPixelDigi(row, col, adc));
58  if (links_persistence_) {
59  output_digi_links.push_back(theSignalProvenance[pixel_no]);
60  if (verbosity_) {
61  edm::LogInfo("PPS") << "RPixDummyROCSimulator "
62  << "digi links size=" << theSignalProvenance[pixel_no].size();
63  for (unsigned int u = 0; u < theSignalProvenance[pixel_no].size(); ++u) {
64  edm::LogInfo("PPS") << "RPixDummyROCSimulator "
65  << " digi: particle=" << theSignalProvenance[pixel_no][u].first
66  << " energy [electrons]=" << theSignalProvenance[pixel_no][u].second;
67  }
68  }
69  }
70  }
71  }
72 
73  if (verbosity_) {
74  for (unsigned int i = 0; i < output_digi.size(); ++i) {
75  edm::LogInfo("RPixDummyROCSimulator")
76  << "Dummy ROC Simulator " << det_id_ << " row= " //output_digi[i].GetDetId()<<" "
77  << output_digi[i].row() << " col= " << output_digi[i].column() << " adc= " << output_digi[i].adc();
78  }
79  }
80 }
float getPed(const int &col, const int &row) const
static constexpr int maxADC_
RPixDummyROCSimulator(const edm::ParameterSet &params, uint32_t det_id)
static constexpr double highRangeCal_
float getGain(const int &col, const int &row) const
void ConvertChargeToHits(const std::map< unsigned short, double > &signals, std::map< unsigned short, std::vector< std::pair< int, double > > > &theSignalProvenance, std::vector< CTPPSPixelDigi > &output_digi, std::vector< std::vector< std::pair< int, double > > > &output_digi_links, const CTPPSPixelGainCalibrations *pcalibration)
Log< level::Info, false > LogInfo
const CTPPSPixelGainCalibration & getGainCalibration(const uint32_t &detid) const
col
Definition: cuy.py:1009
static constexpr double lowRangeCal_
uint16_t *__restrict__ uint16_t const *__restrict__ adc