File indexing completed on 2024-04-06 12:30:52
0001 #include "SimPPS/PPSPixelDigiProducer/interface/RPixDetDigitizer.h"
0002
0003 RPixDetDigitizer::RPixDetDigitizer(const edm::ParameterSet ¶ms,
0004 CLHEP::HepRandomEngine &eng,
0005 uint32_t det_id,
0006 const PPSPixelTopology &ppt)
0007 : det_id_(det_id) {
0008 verbosity_ = params.getParameter<int>("RPixVerbosity");
0009 theNoiseInElectrons = params.getParameter<double>("RPixEquivalentNoiseCharge");
0010 thePixelThresholdInE = params.getParameter<double>("RPixDummyROCThreshold");
0011 noNoise = params.getParameter<bool>("RPixNoNoise");
0012
0013 links_persistence_ = params.getParameter<bool>("CTPPSPixelDigiSimHitRelationsPersistence");
0014
0015 theRPixPileUpSignals = std::make_unique<RPixPileUpSignals>(params, det_id_);
0016 theRPixDummyROCSimulator = std::make_unique<RPixDummyROCSimulator>(params, det_id_);
0017 theRPixHitChargeConverter = std::make_unique<RPixHitChargeConverter>(params, eng, det_id_, ppt);
0018 }
0019
0020 RPixDetDigitizer::~RPixDetDigitizer() {}
0021
0022 void RPixDetDigitizer::run(const std::vector<PSimHit> &input,
0023 const std::vector<int> &input_links,
0024 std::vector<CTPPSPixelDigi> &output_digi,
0025 std::vector<std::vector<std::pair<int, double> > > &output_digi_links,
0026 const CTPPSPixelGainCalibrations *pcalibrations,
0027 const PPSPixelTopology *pixelTopology) {
0028 if (verbosity_)
0029 edm::LogInfo("PPS") << "RPixDetDigitizer " << det_id_ << " received input.size()=" << input.size();
0030 theRPixPileUpSignals->reset();
0031 bool links_persistence_checked = links_persistence_ && input_links.size() == input.size();
0032 int input_size = input.size();
0033 for (int i = 0; i < input_size; ++i) {
0034 std::map<unsigned short, double> the_pixel_charge_map;
0035 the_pixel_charge_map = theRPixHitChargeConverter->processHit(input[i], *pixelTopology);
0036
0037 if (verbosity_)
0038 edm::LogInfo("PPS") << "RPixDetDigitizer " << det_id_ << " returned hits=" << the_pixel_charge_map.size();
0039 if (links_persistence_checked)
0040 theRPixPileUpSignals->add(the_pixel_charge_map, input_links[i]);
0041 else
0042 theRPixPileUpSignals->add(the_pixel_charge_map, 0);
0043 }
0044 const std::map<unsigned short, double> &theSignal = theRPixPileUpSignals->dumpSignal();
0045 std::map<unsigned short, std::vector<std::pair<int, double> > > &theSignalProvenance =
0046 theRPixPileUpSignals->dumpLinks();
0047 std::map<unsigned short, double> afterNoise;
0048 afterNoise = theSignal;
0049 theRPixDummyROCSimulator->ConvertChargeToHits(
0050 afterNoise, theSignalProvenance, output_digi, output_digi_links, pcalibrations);
0051 }