11 #include "boost/bind.hpp"
41 mixProdStep2_(ps_mix.getParameter<bool>(
"mixProdStep2")),
42 mixProdStep1_(ps_mix.getParameter<bool>(
"mixProdStep1")),
46 if (
mixProdStep1_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
47 if (
mixProdStep2_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
50 if (ps_mix.
exists(
"useCurrentProcessOnly")) {
55 if (ps_mix.
exists(
"LabelPlayback")) {
58 if (labelPlayback.empty()) {
68 for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) {
70 if (!pset.
exists(
"type"))
continue;
72 std::vector<InputTag>
tags=pset.
getParameter<std::vector<InputTag> >(
"input");
79 if (
object==
"SimTrack") {
81 if (tags.size()>0) tag=tags[0];
87 if(makeCrossingFrame) {
89 produces<CrossingFrame<SimTrack> >(
label);
90 consumes<std::vector<SimTrack> >(
tag);
93 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
96 }
else if (
object==
"RecoTrack") {
98 if (tags.size()>0) tag=tags[0];
104 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
107 }
else if (
object==
"SimVertex") {
109 if (tags.size()>0) tag=tags[0];
115 if(makeCrossingFrame) {
117 produces<CrossingFrame<SimVertex> >(
label);
118 consumes<std::vector<SimVertex> >(
tag);
121 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag "<<tag.
encode()<<
", label will be "<<
label;
124 }
else if (
object==
"HepMCProduct") {
126 if (tags.size()>0) tag=tags[0];
131 if(makeCrossingFrame) {
133 produces<CrossingFrame<HepMCProduct> >(
label);
135 consumes<HepMCProduct>(
tag);
137 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
140 }
else if (
object==
"PCaloHit") {
142 std::vector<std::string> crossingFrames=pset.
getUntrackedParameter<std::vector<std::string> >(
"crossingFrames", std::vector<std::string>());
144 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
146 if (tags.size()==1) tag=tags[0];
147 else if(tags.size()>1) tag=tags[
ii];
154 produces<CrossingFrame<PCaloHit> >(
label);
155 consumes<std::vector<PCaloHit> >(
tag);
158 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
163 }
else if (
object==
"PSimHit") {
165 std::vector<std::string> crossingFrames=pset.
getUntrackedParameter<std::vector<std::string> >(
"crossingFrames", std::vector<std::string>());
167 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
169 if (tags.size()==1) tag=tags[0];
170 else if(tags.size()>1) tag=tags[
ii];
177 produces<CrossingFrame<PSimHit> >(
label);
178 consumes<std::vector<PSimHit> >(
tag);
181 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
185 LogWarning(
"MixingModule") <<
"You have asked to mix an unknown type of object("<<
object<<
").\n If you want to include it in mixing, please contact the authors of the MixingModule!";
195 produces<PileupMixingContent>();
197 produces<CrossingFramePlaybackInfoExtended>();
208 for(
auto const& digiName : digiNames) {
212 if(accumulator.get() != 0) {
248 if (adjuster->checkSignal(e)){
255 if (worker->checkSignal(e)){
282 delete digiAccumulator;
288 LogDebug(
"MixingModule")<<
"===============> adding signals for "<<e.
id();
299 int bunchCrossing,
int eventId,
310 adjuster->doOffset(
bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
315 for (
auto const& worker :
workers_) {
316 LogDebug(
"MixingModule") <<
" merging Event: id " << eventPrincipal.
id();
319 worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
325 std::vector<edm::EventID> recordEventID;
331 "CrossingFramePlaybackInfoExtended on the input file, but playback "
332 "option set!!!!! Please change the input file if you really want "
333 "playback!!!!!!" << std::endl;
339 std::vector<int> PileupList;
345 if((source0 && source0->doPileUp() ) && !
playback_) {
358 int KeepTrackOfPileup = 0;
361 for (
size_t setBcrIdx=0; setBcrIdx<
workers_.size(); ++setBcrIdx) {
362 workers_[setBcrIdx]->setBcrOffset();
365 (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
368 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; ++readSrcIdx) {
373 for (
size_t setSrcIdx=0; setSrcIdx<
workers_.size(); ++setSrcIdx) {
374 workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
377 if (!source || !source->doPileUp())
continue;
379 int NumPU_Events = 0;
382 NumPU_Events = PileupList[bunchIdx -
minBunch_];
388 int vertexOffset = 0;
394 _2, vertexOffset, boost::ref(setup), boost::cref(e.
streamID())), NumPU_Events, e.
streamID()
397 KeepTrackOfPileup+=NumPU_Events;
399 const std::vector<edm::EventID>& playEventID =
400 playbackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
401 if(readSrcIdx == 0) {
402 PileupList.push_back(playEventID.size());
408 _2, vertexOffset, boost::ref(setup), boost::cref(e.
streamID()))
413 (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
419 std::auto_ptr<PileupMixingContent> PileupMixing_;
421 std::vector<int> numInteractionList;
422 std::vector<int> bunchCrossingList;
423 std::vector<float> TrueInteractionList;
427 bunchCrossingList.push_back(bunchCrossing);
429 numInteractionList.push_back(0);
430 TrueInteractionList.push_back(0);
433 numInteractionList.push_back(PileupList[bunchCrossing-
minBunch_]);
439 (*accItr)->StorePileupInformation( bunchCrossingList,
441 TrueInteractionList);
445 PileupMixing_ = std::auto_ptr<PileupMixingContent>(
new PileupMixingContent(bunchCrossingList,
447 TrueInteractionList));
449 e.
put(PileupMixing_);
461 std::auto_ptr<CrossingFramePlaybackInfoExtended> pOut(
playbackInfo_);
468 (*accItr)->beginRun(run, setup);
475 (*accItr)->endRun(run, setup);
482 (*accItr)->beginLuminosityBlock(lumi, setup);
489 (*accItr)->endLuminosityBlock(lumi, setup);
497 (*accItr)->initializeEvent(event, setup);
504 (*accItr)->accumulate(event, setup);
511 (*accItr)->accumulate(event, setup, streamID);
518 (*accItr)->finalizeEvent(event, setup);
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void reload(const edm::EventSetup &)
virtual void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
MixingModule(const edm::ParameterSet &ps)
virtual void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
static std::string const source("source")
static const HistoName names[]
virtual void createnewEDProduct()
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
std::vector< float > TrueNumInteractions_
virtual void addSignals(const edm::Event &e, const edm::EventSetup &es)
EventID const & id() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::auto_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, one::EDProducerBase &, ConsumesCollector &) const
ModuleDescription const & moduleDescription() const
virtual void endRun(const edm::Run &r, const edm::EventSetup &setup) override
virtual void put(edm::Event &e, const edm::EventSetup &es)
void setStartEventId(const std::vector< edm::EventID > &id, const unsigned int s, const int bcr, const int start)
ModuleCallingContext const * moduleCallingContext() const
virtual void checkSignal(const edm::Event &e)
std::string friendlyName(std::string const &iFullName)
virtual void endLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
std::vector< MixingWorkerBase * > workers_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Accumulators digiAccumulators_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< AdjusterBase * > adjusters_
static const unsigned int maxNbSources_
std::vector< MixingWorkerBase * > workersObjects_
virtual void beginRun(Run const &r1, EventSetup const &c) override
std::vector< std::string > getParameterNames() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool useCurrentProcessOnly_
virtual void branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
void finalizeEvent(Event &event, EventSetup const &setup)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
ParameterSet const & getParameterSet(std::string const &) const
constexpr char const * subdets[11]
std::vector< std::string > wantedBranches_
std::vector< AdjusterBase * > adjustersObjects_
InputTag inputTagPlayback_
std::vector< boost::shared_ptr< PileUp > > inputSources_
void accumulateEvent(Event const &event, EventSetup const &setup)
StreamID streamID() const
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
CrossingFramePlaybackInfoExtended * playbackInfo_
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
virtual void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
static DigiAccumulatorMixModFactory const * get()
void initializeEvent(Event const &event, EventSetup const &setup)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
virtual void doPileUp(edm::Event &e, const edm::EventSetup &es) override
void pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
virtual void endRun(Run const &r1, EventSetup const &c) override