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 }
RPixDummyROCSimulator::RPixDummyROCSimulator
RPixDummyROCSimulator(const edm::ParameterSet &params, uint32_t det_id)
Definition: RPixDummyROCSimulator.cc:6
mps_fire.i
i
Definition: mps_fire.py:428
CTPPSPixelGainCalibration::getNCols
uint32_t getNCols() const
Definition: CTPPSPixelGainCalibration.h:77
RPixDummyROCSimulator.h
RPixDummyROCSimulator::dead_pixels_
dead_pixel_set dead_pixels_
Definition: RPixDummyROCSimulator.h:32
CTPPSPixelGainCalibration::getDetId
uint32_t getDetId() const
Definition: CTPPSPixelGainCalibration.h:76
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
gpuClustering::adc
uint16_t *__restrict__ uint16_t const *__restrict__ adc
Definition: gpuClusterChargeCut.h:20
cuy.col
col
Definition: cuy.py:1009
RPixDummyROCSimulator::highRangeCal_
static constexpr double highRangeCal_
Definition: RPixDummyROCSimulator.h:25
RPixDummyROCSimulator::VcaltoElectronOffset_
int VcaltoElectronOffset_
Definition: RPixDummyROCSimulator.h:37
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPixDummyROCSimulator::maxADC_
static constexpr int maxADC_
Definition: RPixDummyROCSimulator.h:27
CTPPSPixelGainCalibration
Definition: CTPPSPixelGainCalibration.h:27
CTPPSPixelGainCalibration::getGain
float getGain(const int &col, const int &row) const
Definition: CTPPSPixelGainCalibration.cc:136
RPixDummyROCSimulator::doSingleCalibration_
bool doSingleCalibration_
Definition: RPixDummyROCSimulator.h:38
RPixDummyROCSimulator::links_persistence_
bool links_persistence_
Definition: RPixDummyROCSimulator.h:39
RPixDummyROCSimulator::VcaltoElectronGain_
int VcaltoElectronGain_
Definition: RPixDummyROCSimulator.h:36
RPixDummyROCSimulator::det_id_
uint32_t det_id_
Definition: RPixDummyROCSimulator.h:29
RPixDummyROCSimulator::verbosity_
int verbosity_
Definition: RPixDummyROCSimulator.h:33
CTPPSPixelDigi
Definition: CTPPSPixelDigi.h:10
CTPPSPixelGainCalibrations::getGainCalibration
const CTPPSPixelGainCalibration & getGainCalibration(const uint32_t &detid) const
Definition: CTPPSPixelGainCalibrations.cc:52
edm::ParameterSet
Definition: ParameterSet.h:47
CTPPSPixelGainCalibration::getPed
float getPed(const int &col, const int &row) const
Definition: CTPPSPixelGainCalibration.cc:122
RPixDummyROCSimulator::electron_per_adc_
double electron_per_adc_
Definition: RPixDummyROCSimulator.h:35
CTPPSPixelGainCalibrations
Definition: CTPPSPixelGainCalibrations.h:8
createfilelist.int
int
Definition: createfilelist.py:10
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
RPixDummyROCSimulator::dead_pixels_simulation_on_
bool dead_pixels_simulation_on_
Definition: RPixDummyROCSimulator.h:31
RPixDummyROCSimulator::lowRangeCal_
static constexpr double lowRangeCal_
Definition: RPixDummyROCSimulator.h:26
RPixDummyROCSimulator::dead_pixel_probability_
double dead_pixel_probability_
Definition: RPixDummyROCSimulator.h:30
RPixDummyROCSimulator::threshold_
double threshold_
Definition: RPixDummyROCSimulator.h:34
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
RPixDummyROCSimulator::ConvertChargeToHits
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)
Definition: RPixDummyROCSimulator.cc:18
genParticles_cff.map
map
Definition: genParticles_cff.py:11