forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable phase2 tracker in phase2 premixing
- Loading branch information
Showing
11 changed files
with
236 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<use name="SimTracker/SiPhase2Digitizer"/> | ||
<library file="Phase2TrackerDigitizer.cc PSPDigitizerAlgorithm.cc Phase2TrackerDigitizerAlgorithm.cc PixelDigitizerAlgorithm.cc PSSDigitizerAlgorithm.cc SSDigitizerAlgorithm.cc" name="SimTrackerSiPhase2DigitizerPlugins"> | ||
<library file="*.cc" name="SimTrackerSiPhase2DigitizerPlugins"> | ||
<use name="SimGeneral/PreMixingModule"/> | ||
<flags EDM_PLUGIN="1"/> | ||
</library> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
SimTracker/SiPhase2Digitizer/plugins/PreMixingPhase2TrackerWorker.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/ProducerBase.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "DataFormats/Common/interface/Handle.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/ConsumesCollector.h" | ||
#include "FWCore/Utilities/interface/RandomNumberGenerator.h" | ||
#include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h" | ||
|
||
#include "DataFormats/Common/interface/DetSetVector.h" | ||
#include "DataFormats/Common/interface/DetSet.h" | ||
|
||
#include "SimGeneral/PreMixingModule/interface/PreMixingWorker.h" | ||
#include "SimGeneral/PreMixingModule/interface/PreMixingWorkerFactory.h" | ||
|
||
#include "Phase2TrackerDigitizer.h" | ||
#include "Phase2TrackerDigitizerAlgorithm.h" | ||
|
||
class PreMixingPhase2TrackerWorker: public PreMixingWorker { | ||
public: | ||
PreMixingPhase2TrackerWorker(const edm::ParameterSet& ps, edm::ProducerBase& producer, edm::ConsumesCollector&& iC); | ||
~PreMixingPhase2TrackerWorker() override = default; | ||
|
||
void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) override; | ||
|
||
void initializeEvent(edm::Event const& e, edm::EventSetup const& es) override; | ||
void addSignals(edm::Event const& e, edm::EventSetup const& es) override; | ||
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; | ||
|
||
private: | ||
void accumulate(const edm::DetSetVector<PixelDigi>& digis); | ||
|
||
cms::Phase2TrackerDigitizer digitizer_; | ||
|
||
edm::EDGetTokenT<edm::DetSetVector<PixelDigi> > pixelSignalToken_; | ||
edm::EDGetTokenT<edm::DetSetVector<PixelDigi> > trackerSignalToken_; | ||
edm::InputTag pixelPileupLabel_; | ||
edm::InputTag trackerPileupLabel_; | ||
float electronPerAdc_; | ||
|
||
// Maybe map of maps is not that bad for this add once, update once, | ||
// read once workflow? | ||
using SignalMap = std::map<unsigned int, std::map<int, float>>; // (channel, charge) | ||
SignalMap accumulator_; | ||
}; | ||
|
||
|
||
PreMixingPhase2TrackerWorker::PreMixingPhase2TrackerWorker(const edm::ParameterSet& ps, edm::ProducerBase& producer, edm::ConsumesCollector&& iC): | ||
digitizer_(ps, producer, iC), | ||
pixelSignalToken_(iC.consumes<edm::DetSetVector<PixelDigi> >(ps.getParameter<edm::InputTag>("pixelLabelSig"))), | ||
trackerSignalToken_(iC.consumes<edm::DetSetVector<PixelDigi> >(ps.getParameter<edm::InputTag>("trackerLabelSig"))), | ||
pixelPileupLabel_(ps.getParameter<edm::InputTag>("pixelPileInputTag")), | ||
trackerPileupLabel_(ps.getParameter<edm::InputTag>("trackerPileInputTag")), | ||
electronPerAdc_(ps.getParameter<double>("premixStage1ElectronPerAdc")) | ||
{} | ||
|
||
void PreMixingPhase2TrackerWorker::beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& es) { | ||
digitizer_.beginLuminosityBlock(lumi, es); | ||
} | ||
|
||
void PreMixingPhase2TrackerWorker::initializeEvent(edm::Event const& e, edm::EventSetup const& es) { | ||
digitizer_.initializeEvent(e, es); | ||
} | ||
|
||
void PreMixingPhase2TrackerWorker::addSignals(edm::Event const& e, edm::EventSetup const& es) { | ||
edm::Handle<edm::DetSetVector<PixelDigi> > hdigis; | ||
e.getByToken(pixelSignalToken_, hdigis); | ||
accumulate(*hdigis); | ||
|
||
e.getByToken(trackerSignalToken_, hdigis); | ||
accumulate(*hdigis); | ||
} | ||
|
||
void PreMixingPhase2TrackerWorker::addPileups(PileUpEventPrincipal const& pep, edm::EventSetup const& es) { | ||
edm::Handle<edm::DetSetVector<PixelDigi> > hdigis; | ||
pep.getByLabel(pixelPileupLabel_, hdigis); | ||
accumulate(*hdigis); | ||
|
||
pep.getByLabel(trackerPileupLabel_, hdigis); | ||
accumulate(*hdigis); | ||
} | ||
|
||
void PreMixingPhase2TrackerWorker::accumulate(const edm::DetSetVector<PixelDigi>& digis) { | ||
for(const auto& detset: digis) { | ||
auto& accDet = accumulator_[detset.detId()]; | ||
for(const auto& digi: detset) { | ||
// note: according to C++ standard operator[] does | ||
// value-initializiation, which for float means initial value of 0 | ||
auto& acc = accDet[digi.channel()]; | ||
acc += digi.adc()*electronPerAdc_; | ||
} | ||
} | ||
} | ||
|
||
void PreMixingPhase2TrackerWorker::put(edm::Event &e, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bs) { | ||
digitizer_.loadAccumulator(accumulator_); | ||
digitizer_.finalizeEvent(e, iSetup); | ||
decltype(accumulator_){}.swap(accumulator_); // release memory | ||
} | ||
|
||
DEFINE_EDM_PLUGIN(PreMixingWorkerFactory, PreMixingPhase2TrackerWorker, "PreMixingPhase2TrackerWorker"); |
Oops, something went wrong.