File indexing completed on 2021-02-14 14:30:27
0001 #include <vector>
0002 #include <iostream>
0003
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "SimPPS/RPDigiProducer/plugins/RPDetDigitizer.h"
0006 #include "Geometry/VeryForwardRPTopology/interface/RPTopology.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008
0009 RPDetDigitizer::RPDetDigitizer(const edm::ParameterSet ¶ms,
0010 CLHEP::HepRandomEngine &eng,
0011 RPDetId det_id,
0012 const edm::EventSetup &iSetup)
0013 : det_id_(det_id) {
0014 verbosity_ = params.getParameter<int>("RPVerbosity");
0015 numStrips_ = RPTopology().DetStripNo();
0016 theNoiseInElectrons = params.getParameter<double>("RPEquivalentNoiseCharge300um");
0017 theStripThresholdInE = params.getParameter<double>("RPVFATThreshold");
0018 noNoise_ = params.getParameter<bool>("RPNoNoise");
0019 misalignment_simulation_on_ = params.getParameter<bool>("RPDisplacementOn");
0020 links_persistence_ = params.getParameter<bool>("RPDigiSimHitRelationsPresistence");
0021
0022 theRPGaussianTailNoiseAdder = std::make_unique<RPGaussianTailNoiseAdder>(
0023 numStrips_, theNoiseInElectrons, theStripThresholdInE, eng, verbosity_);
0024 theRPPileUpSignals = std::make_unique<RPPileUpSignals>(params, det_id_);
0025 theRPVFATSimulator = std::make_unique<RPVFATSimulator>(params, det_id_);
0026 theRPHitChargeConverter = std::make_unique<RPHitChargeConverter>(params, eng, det_id_);
0027 theRPDisplacementGenerator = std::make_unique<RPDisplacementGenerator>(params, det_id_, iSetup);
0028 }
0029
0030 void RPDetDigitizer::run(const std::vector<PSimHit> &input,
0031 const std::vector<int> &input_links,
0032 std::vector<TotemRPDigi> &output_digi,
0033 simromanpot::DigiPrimaryMapType &output_digi_links) {
0034 if (verbosity_)
0035 LogDebug("RPDetDigitizer ") << det_id_ << " received input.size()=" << input.size() << "\n";
0036 theRPPileUpSignals->reset();
0037
0038 bool links_persistence_checked = links_persistence_ && input_links.size() == input.size();
0039
0040 int input_size = input.size();
0041 for (int i = 0; i < input_size; ++i) {
0042 simromanpot::strip_charge_map the_strip_charge_map;
0043 if (misalignment_simulation_on_)
0044 the_strip_charge_map = theRPHitChargeConverter->processHit(theRPDisplacementGenerator->displace(input[i]));
0045 else
0046 the_strip_charge_map = theRPHitChargeConverter->processHit(input[i]);
0047
0048 if (verbosity_)
0049 LogDebug("RPHitChargeConverter ") << det_id_ << " returned hits=" << the_strip_charge_map.size() << "\n";
0050 if (links_persistence_checked)
0051 theRPPileUpSignals->add(the_strip_charge_map, input_links[i]);
0052 else
0053 theRPPileUpSignals->add(the_strip_charge_map, 0);
0054 }
0055
0056 const simromanpot::strip_charge_map &theSignal = theRPPileUpSignals->dumpSignal();
0057 simromanpot::strip_charge_map_links_type &theSignalProvenance = theRPPileUpSignals->dumpLinks();
0058 simromanpot::strip_charge_map afterNoise;
0059 if (noNoise_)
0060 afterNoise = theSignal;
0061 else
0062 afterNoise = theRPGaussianTailNoiseAdder->addNoise(theSignal);
0063
0064 theRPVFATSimulator->ConvertChargeToHits(afterNoise, theSignalProvenance, output_digi, output_digi_links);
0065 }