CMS 3D CMS Logo

PreMixingPhase2TrackerWorker.cc
Go to the documentation of this file.
10 
13 
16 
17 #include "Phase2TrackerDigitizer.h"
19 
21 public:
23  ~PreMixingPhase2TrackerWorker() override = default;
24 
25  void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) override;
26 
27  void initializeEvent(edm::Event const& e, edm::EventSetup const& es) override;
28  void addSignals(edm::Event const& e, edm::EventSetup const& es) override;
29  void addPileups(PileUpEventPrincipal const& pep, edm::EventSetup const& es) override;
30  void put(edm::Event& e, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bs) override;
31 
32 private:
33  void accumulate(const edm::DetSetVector<PixelDigi>& digis, const float electronsPerADC);
34 
36 
43 
44  // Maybe map of maps is not that bad for this add once, update once,
45  // read once workflow?
46  using SignalMap = std::map<uint32_t, std::map<int, float>>; // (channel, charge)
48 };
49 
51  edm::ProducesCollector producesCollector,
53  : digitizer_(ps, producesCollector, iC),
54  pixelSignalToken_(iC.consumes<edm::DetSetVector<PixelDigi>>(ps.getParameter<edm::InputTag>("pixelLabelSig"))),
55  trackerSignalToken_(iC.consumes<edm::DetSetVector<PixelDigi>>(ps.getParameter<edm::InputTag>("trackerLabelSig"))),
56  pixelPileupLabel_(ps.getParameter<edm::InputTag>("pixelPileInputTag")),
57  trackerPileupLabel_(ps.getParameter<edm::InputTag>("trackerPileInputTag")),
58  pixelElectronPerAdc_(ps.getParameter<double>("pixelPmxStage1ElectronPerAdc")),
59  trackerElectronPerAdc_(ps.getParameter<double>("trackerPmxStage1ElectronPerAdc")) {}
60 
63 }
64 
67 }
68 
71  e.getByToken(pixelSignalToken_, hdigis);
73 
74  e.getByToken(trackerSignalToken_, hdigis);
76 }
77 
80  pep.getByLabel(pixelPileupLabel_, hdigis);
82 
83  pep.getByLabel(trackerPileupLabel_, hdigis);
85 }
86 
87 void PreMixingPhase2TrackerWorker::accumulate(const edm::DetSetVector<PixelDigi>& digis, const float electronPerADC) {
88  for (const auto& detset : digis) {
89  auto& accDet = accumulator_[detset.detId()];
90  for (const auto& digi : detset) {
91  // note: according to C++ standard operator[] does
92  // value-initializiation, which for float means initial value of 0
93  auto& acc = accDet[digi.channel()];
94  acc += digi.adc() * electronPerADC;
95  }
96  }
97 }
98 
100  edm::EventSetup const& iSetup,
101  std::vector<PileupSummaryInfo> const& ps,
102  int bs) {
104  digitizer_.finalizeEvent(e, iSetup);
105  decltype(accumulator_){}.swap(accumulator_); // release memory
106 }
107 
PreMixingPhase2TrackerWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &es) override
void put(edm::Event &e, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bs) override
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
void accumulate(const edm::DetSetVector< PixelDigi > &digis, const float electronsPerADC)
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
virtual void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup)
void initializeEvent(edm::Event const &e, edm::EventSetup const &es) override
void loadAccumulator(const std::map< uint32_t, std::map< int, float > > &accumulator)
cms::Phase2TrackerDigitizer digitizer_
std::map< uint32_t, std::map< int, float > > SignalMap
HLT enums.
~PreMixingPhase2TrackerWorker() override=default
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > pixelSignalToken_
edm::EDGetTokenT< edm::DetSetVector< PixelDigi > > trackerSignalToken_
void addSignals(edm::Event const &e, edm::EventSetup const &es) override
#define DEFINE_PREMIXING_WORKER(TYPE)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &es) override
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const