44 mixProdStep2_(ps_mix.getParameter<bool>(
"mixProdStep2")),
45 mixProdStep1_(ps_mix.getParameter<bool>(
"mixProdStep1")),
49 if (
mixProdStep1_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
50 if (
mixProdStep2_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
53 if (ps_mix.
exists(
"useCurrentProcessOnly")) {
58 if (ps_mix.
exists(
"LabelPlayback")) {
61 if (labelPlayback.empty()) {
71 for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) {
73 if (!pset.
exists(
"type"))
continue;
75 std::vector<InputTag>
tags=pset.
getParameter<std::vector<InputTag> >(
"input");
82 if (
object==
"SimTrack") {
84 if (tags.size()>0) tag=tags[0];
90 if(makeCrossingFrame) {
92 produces<CrossingFrame<SimTrack> >(
label);
94 consumes<std::vector<SimTrack> >(
tag);
96 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
99 }
else if (
object==
"RecoTrack") {
101 if (tags.size()>0) tag=tags[0];
110 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
113 }
else if (
object==
"SimVertex") {
115 if (tags.size()>0) tag=tags[0];
121 if(makeCrossingFrame) {
123 produces<CrossingFrame<SimVertex> >(
label);
125 consumes<std::vector<SimVertex> >(
tag);
127 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag "<<tag.
encode()<<
", label will be "<<
label;
130 }
else if (
object==
"HepMCProduct") {
132 if (tags.size()>0) tag=tags[0];
137 if(makeCrossingFrame) {
139 produces<CrossingFrame<HepMCProduct> >(
label);
141 consumes<HepMCProduct>(
tag);
143 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
145 for(
size_t i = 1;
i < tags.size(); ++
i) {
149 mayConsume<HepMCProduct>(fallbackTag);
152 }
else if (
object==
"PCaloHit") {
154 std::vector<std::string> crossingFrames=pset.
getUntrackedParameter<std::vector<std::string> >(
"crossingFrames", std::vector<std::string>());
156 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
158 if (tags.size()==1) tag=tags[0];
159 else if(tags.size()>1) tag=tags[
ii];
166 produces<CrossingFrame<PCaloHit> >(
label);
167 consumes<std::vector<PCaloHit> >(
tag);
170 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
175 }
else if (
object==
"PSimHit") {
177 std::vector<std::string> crossingFrames=pset.
getUntrackedParameter<std::vector<std::string> >(
"crossingFrames", std::vector<std::string>());
179 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
181 if (tags.size()==1) tag=tags[0];
182 else if(tags.size()>1) tag=tags[
ii];
189 produces<CrossingFrame<PSimHit> >(
label);
190 consumes<std::vector<PSimHit> >(
tag);
193 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
197 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!";
207 produces<PileupMixingContent>();
209 produces<CrossingFramePlaybackInfoNew>();
220 for(
auto const& digiName : digiNames) {
224 if(accumulator.get() != 0) {
260 if (adjuster->checkSignal(e)){
267 if (worker->checkSignal(e)){
294 delete digiAccumulator;
300 LogDebug(
"MixingModule")<<
"===============> adding signals for "<<e.
id();
311 int bunchCrossing,
int eventId,
323 adjuster->doOffset(
bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
329 for (
auto const& worker :
workers_) {
330 LogDebug(
"MixingModule") <<
" merging Event: id " << eventPrincipal.
id();
333 worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
338 using namespace std::placeholders;
341 std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
342 std::vector<size_t> sizes;
344 size_t playbackCounter = 0U;
347 bool oldFormatPlayback =
false;
354 "CrossingFramePlaybackInfoNew on the input file, but playback "
355 "option set!!!!! Please change the input file if you really want "
356 "playback!!!!!!" << std::endl;
358 oldFormatPlayback =
true;
364 std::vector<int> PileupList;
370 if((source0 && source0->doPileUp(0) ) && !
playback_) {
382 std::vector<int> numInteractionList;
383 std::vector<int> bunchCrossingList;
384 std::vector<float> TrueInteractionList;
385 std::vector<edm::EventID> eventInfoList;
391 bunchCrossingList.push_back(bunchCrossing);
393 numInteractionList.push_back(0);
394 TrueInteractionList.push_back(0);
397 numInteractionList.push_back(PileupList[bunchCrossing-
minBunch_]);
405 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; ++readSrcIdx) {
407 if(oldFormatPlayback) {
408 std::vector<edm::EventID>
const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
409 size_t numberOfEvents = playEventID.size();
410 if(readSrcIdx == 0) {
411 PileupList.push_back(numberOfEvents);
415 size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
416 if(readSrcIdx == 0) {
417 PileupList.push_back(numberOfEvents);
426 (*accItr)->StorePileupInformation( bunchCrossingList,
439 for (
size_t setBcrIdx=0; setBcrIdx<
workers_.size(); ++setBcrIdx) {
440 workers_[setBcrIdx]->setBcrOffset();
443 (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
446 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; ++readSrcIdx) {
451 for (
size_t setSrcIdx=0; setSrcIdx<
workers_.size(); ++setSrcIdx) {
452 workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
455 if (!source || !source->doPileUp(bunchIdx)) {
458 playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
464 int vertexOffset = 0;
469 int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx -
minBunch_] : 1);
470 sizes.push_back(numberOfEvents);
473 _2, vertexOffset, std::ref(setup), e.
streamID()), numberOfEvents, e.
streamID());
474 }
else if(oldFormatPlayback) {
475 std::vector<edm::EventID>
const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
476 size_t numberOfEvents = playEventID.size();
477 if(readSrcIdx == 0) {
478 PileupList.push_back(numberOfEvents);
481 sizes.push_back(numberOfEvents);
482 std::vector<EventID>::const_iterator
begin = playEventID.begin();
483 std::vector<EventID>::const_iterator
end = playEventID.end();
485 begin, end, recordEventID,
487 _2, vertexOffset, std::ref(setup), e.
streamID()));
489 size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
490 if(readSrcIdx == 0) {
491 PileupList.push_back(numberOfEvents);
494 sizes.push_back(numberOfEvents);
495 std::vector<SecondaryEventIDAndFileInfo>::const_iterator
begin = playbackInfo_H->getEventId(playbackCounter);
496 playbackCounter += numberOfEvents;
497 std::vector<SecondaryEventIDAndFileInfo>::const_iterator
end = playbackInfo_H->getEventId(playbackCounter);
499 begin, end, recordEventID,
501 _2, vertexOffset, std::ref(setup), e.
streamID()));
505 (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
510 for (
auto const item : recordEventID) {
511 eventInfoList.emplace_back(item.eventID());
519 std::unique_ptr<PileupMixingContent> PileupMixing_;
521 PileupMixing_ = std::auto_ptr<PileupMixingContent>(
new PileupMixingContent(bunchCrossingList,
539 std::auto_ptr<CrossingFramePlaybackInfoNew> pOut(
playbackInfo_);
546 (*accItr)->beginRun(run, setup);
553 (*accItr)->endRun(run, setup);
560 (*accItr)->beginLuminosityBlock(lumi, setup);
567 (*accItr)->endLuminosityBlock(lumi, setup);
575 (*accItr)->initializeEvent(event, setup);
582 (*accItr)->accumulate(event, setup);
589 (*accItr)->accumulate(event, setup, streamID);
596 (*accItr)->finalizeEvent(event, setup);
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
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
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
virtual void endRun(const edm::Run &r, const edm::EventSetup &setup) override
virtual void put(edm::Event &e, const edm::EventSetup &es)
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.
MixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
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
CrossingFramePlaybackInfoNew * playbackInfo_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
ModuleDescription const & moduleDescription() 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
std::auto_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, stream::EDProducerBase &, ConsumesCollector &) const
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)
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