CMS 3D CMS Logo

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