CMS 3D CMS Logo

PreMixingPhase2TrackerWorker.cc
Go to the documentation of this file.
11 
14 
17 
18 #include "Phase2TrackerDigitizer.h"
20 
22 public:
24  ~PreMixingPhase2TrackerWorker() override = default;
25 
26  void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) override;
27 
28  void initializeEvent(edm::Event const& e, edm::EventSetup const& es) override;
29  void addSignals(edm::Event const& e, edm::EventSetup const& es) override;
30  void addPileups(PileUpEventPrincipal const& pep, edm::EventSetup const& es) override;
31  void put(edm::Event &e, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bs) override;
32 
33 private:
34  void accumulate(const edm::DetSetVector<PixelDigi>& digis);
35 
37 
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<unsigned int, std::map<int, float>>; // (channel, charge)
48 };
49 
50 
52  digitizer_(ps, producer, iC),
53  pixelSignalToken_(iC.consumes<edm::DetSetVector<PixelDigi> >(ps.getParameter<edm::InputTag>("pixelLabelSig"))),
54  trackerSignalToken_(iC.consumes<edm::DetSetVector<PixelDigi> >(ps.getParameter<edm::InputTag>("trackerLabelSig"))),
55  pixelPileupLabel_(ps.getParameter<edm::InputTag>("pixelPileInputTag")),
56  trackerPileupLabel_(ps.getParameter<edm::InputTag>("trackerPileInputTag")),
57  electronPerAdc_(ps.getParameter<double>("premixStage1ElectronPerAdc"))
58 {}
59 
62 }
63 
66 }
67 
70  e.getByToken(pixelSignalToken_, hdigis);
71  accumulate(*hdigis);
72 
74  accumulate(*hdigis);
75 }
76 
79  pep.getByLabel(pixelPileupLabel_, hdigis);
80  accumulate(*hdigis);
81 
82  pep.getByLabel(trackerPileupLabel_, hdigis);
83  accumulate(*hdigis);
84 }
85 
87  for(const auto& detset: digis) {
88  auto& accDet = accumulator_[detset.detId()];
89  for(const auto& digi: detset) {
90  // note: according to C++ standard operator[] does
91  // value-initializiation, which for float means initial value of 0
92  auto& acc = accDet[digi.channel()];
93  acc += digi.adc()*electronPerAdc_;
94  }
95  }
96 }
97 
98 void PreMixingPhase2TrackerWorker::put(edm::Event &e, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bs) {
100  digitizer_.finalizeEvent(e, iSetup);
101  decltype(accumulator_){}.swap(accumulator_); // release memory
102 }
103 
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 accumulate(const edm::DetSetVector< PixelDigi > &digis)
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
void initializeEvent(edm::Event const &e, edm::EventSetup const &es) override
void loadAccumulator(const std::map< unsigned int, std::map< int, float > > &accumulator)
std::map< unsigned int, std::map< int, float >> SignalMap
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &iSetup) override
cms::Phase2TrackerDigitizer digitizer_
HLT enums.
~PreMixingPhase2TrackerWorker() override=default
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
PreMixingPhase2TrackerWorker(const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
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