42 mixProdStep2_(ps_mix.getParameter<bool>(
"mixProdStep2")),
43 mixProdStep1_(ps_mix.getParameter<bool>(
"mixProdStep1")),
47 if (
mixProdStep1_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
48 if (
mixProdStep2_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
51 if (ps_mix.
exists(
"useCurrentProcessOnly")) {
56 if (ps_mix.
exists(
"LabelPlayback")) {
59 if (labelPlayback.empty()) {
69 for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) {
71 if (!pset.
exists(
"type"))
continue;
73 std::vector<InputTag>
tags=pset.
getParameter<std::vector<InputTag> >(
"input");
80 if (
object==
"SimTrack") {
82 if (tags.size()>0) tag=tags[0];
88 if(makeCrossingFrame) {
90 produces<CrossingFrame<SimTrack> >(
label);
91 consumes<std::vector<SimTrack> >(
tag);
94 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
97 }
else if (
object==
"RecoTrack") {
99 if (tags.size()>0) tag=tags[0];
107 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
110 }
else if (
object==
"SimVertex") {
112 if (tags.size()>0) tag=tags[0];
118 if(makeCrossingFrame) {
120 produces<CrossingFrame<SimVertex> >(
label);
121 consumes<std::vector<SimVertex> >(
tag);
124 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag "<<tag.
encode()<<
", label will be "<<
label;
127 }
else if (
object==
"HepMCProduct") {
129 if (tags.size()>0) tag=tags[0];
134 if(makeCrossingFrame) {
136 produces<CrossingFrame<HepMCProduct> >(
label);
138 consumes<HepMCProduct>(
tag);
140 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
143 }
else if (
object==
"PCaloHit") {
145 std::vector<std::string> crossingFrames=pset.
getUntrackedParameter<std::vector<std::string> >(
"crossingFrames", std::vector<std::string>());
147 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
149 if (tags.size()==1) tag=tags[0];
150 else if(tags.size()>1) tag=tags[
ii];
157 produces<CrossingFrame<PCaloHit> >(
label);
158 consumes<std::vector<PCaloHit> >(
tag);
161 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
166 }
else if (
object==
"PSimHit") {
168 std::vector<std::string> crossingFrames=pset.
getUntrackedParameter<std::vector<std::string> >(
"crossingFrames", std::vector<std::string>());
170 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
172 if (tags.size()==1) tag=tags[0];
173 else if(tags.size()>1) tag=tags[
ii];
180 produces<CrossingFrame<PSimHit> >(
label);
181 consumes<std::vector<PSimHit> >(
tag);
184 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
188 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!";
198 produces<PileupMixingContent>();
200 produces<CrossingFramePlaybackInfoExtended>();
211 for(
auto const& digiName : digiNames) {
215 if(accumulator.get() != 0) {
251 if (adjuster->checkSignal(e)){
258 if (worker->checkSignal(e)){
285 delete digiAccumulator;
291 LogDebug(
"MixingModule")<<
"===============> adding signals for "<<e.
id();
302 int bunchCrossing,
int eventId,
313 adjuster->doOffset(
bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
318 for (
auto const& worker :
workers_) {
319 LogDebug(
"MixingModule") <<
" merging Event: id " << eventPrincipal.
id();
322 worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
327 using namespace std::placeholders;
330 std::vector<edm::EventID> recordEventID;
336 "CrossingFramePlaybackInfoExtended on the input file, but playback "
337 "option set!!!!! Please change the input file if you really want "
338 "playback!!!!!!" << std::endl;
344 std::vector<int> PileupList;
350 if((source0 && source0->doPileUp(0) ) && !
playback_) {
363 int KeepTrackOfPileup = 0;
364 std::vector<edm::EventID> eventInfoList;
367 for (
size_t setBcrIdx=0; setBcrIdx<
workers_.size(); ++setBcrIdx) {
368 workers_[setBcrIdx]->setBcrOffset();
371 (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
374 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; ++readSrcIdx) {
379 for (
size_t setSrcIdx=0; setSrcIdx<
workers_.size(); ++setSrcIdx) {
380 workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
383 if (!source || !source->doPileUp(bunchIdx))
continue;
385 int NumPU_Events = 0;
388 NumPU_Events = PileupList[bunchIdx -
minBunch_];
394 int vertexOffset = 0;
400 _2, vertexOffset, std::ref(setup), e.
streamID()), NumPU_Events, e.
streamID()
403 const std::vector<edm::EventID>& playEventID =
405 for (
unsigned int pu=0; pu<playEventID.size(); pu++ ) { eventInfoList.push_back(playEventID[pu]); }
407 KeepTrackOfPileup+=NumPU_Events;
409 const std::vector<edm::EventID>& playEventID =
410 playbackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
411 if(readSrcIdx == 0) {
412 PileupList.push_back(playEventID.size());
418 _2, vertexOffset, std::ref(setup), e.
streamID())
420 for (
unsigned int pu=0; pu<playEventID.size(); pu++ ) eventInfoList.push_back(playEventID[pu]);
424 (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
430 std::auto_ptr<PileupMixingContent> PileupMixing_;
432 std::vector<int> numInteractionList;
433 std::vector<int> bunchCrossingList;
434 std::vector<float> TrueInteractionList;
438 bunchCrossingList.push_back(bunchCrossing);
440 numInteractionList.push_back(0);
441 TrueInteractionList.push_back(0);
444 numInteractionList.push_back(PileupList[bunchCrossing-
minBunch_]);
450 (*accItr)->StorePileupInformation( bunchCrossingList,
458 PileupMixing_ = std::auto_ptr<PileupMixingContent>(
new PileupMixingContent(bunchCrossingList,
464 e.
put(PileupMixing_);
476 std::auto_ptr<CrossingFramePlaybackInfoExtended> pOut(
playbackInfo_);
483 (*accItr)->beginRun(run, setup);
490 (*accItr)->endRun(run, setup);
497 (*accItr)->beginLuminosityBlock(lumi, setup);
504 (*accItr)->endLuminosityBlock(lumi, setup);
512 (*accItr)->initializeEvent(event, setup);
519 (*accItr)->accumulate(event, setup);
526 (*accItr)->accumulate(event, setup, streamID);
533 (*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[]
std::vector< edm::EventID > getStartEventId(const unsigned int s, const int bcr) const
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
std::vector< std::string > wantedBranches_
std::vector< AdjusterBase * > adjustersObjects_
InputTag inputTagPlayback_
void accumulateEvent(Event const &event, EventSetup const &setup)
std::vector< std::shared_ptr< PileUp > > inputSources_
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