44 mixProdStep2_(ps_mix.getParameter<bool>(
"mixProdStep2")),
45 mixProdStep1_(ps_mix.getParameter<bool>(
"mixProdStep1")),
48 LogInfo(
"MixingModule") <<
" The MixingModule was run in the Standard mode.";
50 LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
52 LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
55 if (ps_mix.
exists(
"useCurrentProcessOnly")) {
60 if (ps_mix.
exists(
"LabelPlayback")) {
63 if (labelPlayback.empty()) {
71 if (ps_mix.
exists(
"WrapLongTimes")) {
76 if (ps_mix.
exists(
"skipSignal")) {
82 for (std::vector<std::string>::iterator it = names.begin(); it != names.end(); ++it) {
87 std::vector<InputTag>
tags = pset.
getParameter<std::vector<InputTag> >(
"input");
94 if (
object ==
"SimTrack") {
103 if (makeCrossingFrame) {
106 produces<CrossingFrame<SimTrack> >(
label);
108 consumes<std::vector<SimTrack> >(
tag);
110 LogInfo(
"MixingModule") <<
"Will mix " <<
object <<
"s with InputTag= " << tag.
encode() <<
", label will be "
114 }
else if (
object ==
"RecoTrack") {
122 TypeID(
typeid(std::vector<reco::TrackExtra>)).friendlyClassName(),
std::string(
""), tag, label);
132 LogInfo(
"MixingModule") <<
"Will mix " <<
object <<
"s with InputTag= " << tag.
encode() <<
", label will be "
136 }
else if (
object ==
"SimVertex") {
145 if (makeCrossingFrame) {
148 produces<CrossingFrame<SimVertex> >(
label);
150 consumes<std::vector<SimVertex> >(
tag);
152 LogInfo(
"MixingModule") <<
"Will mix " <<
object <<
"s with InputTag " << tag.
encode() <<
", label will be "
156 }
else if (
object ==
"HepMCProduct") {
164 if (makeCrossingFrame) {
167 produces<CrossingFrame<HepMCProduct> >(
label);
169 consumes<HepMCProduct>(
tag);
171 LogInfo(
"MixingModule") <<
"Will mix " <<
object <<
"s with InputTag= " << tag.
encode() <<
", label will be "
174 for (
size_t i = 1;
i < tags.size(); ++
i) {
179 mayConsume<HepMCProduct>(fallbackTag);
182 }
else if (
object ==
"PCaloHit") {
183 std::vector<std::string>
subdets = pset.
getParameter<std::vector<std::string> >(
"subdets");
184 std::vector<std::string> crossingFrames =
187 for (
unsigned int ii = 0;
ii < subdets.size(); ++
ii) {
189 if (tags.size() == 1)
191 else if (tags.size() > 1)
200 produces<CrossingFrame<PCaloHit> >(
label);
201 consumes<std::vector<PCaloHit> >(
tag);
204 LogInfo(
"MixingModule") <<
"Will mix " <<
object <<
"s with InputTag= " << tag.
encode() <<
", label will be "
209 }
else if (
object ==
"PSimHit") {
210 std::vector<std::string>
subdets = pset.
getParameter<std::vector<std::string> >(
"subdets");
211 std::vector<std::string> crossingFrames =
215 pset.
getUntrackedParameter<std::vector<std::string> >(
"pcrossingFrames", std::vector<std::string>());
217 for (
unsigned int ii = 0;
ii < subdets.size(); ++
ii) {
219 if (tags.size() == 1)
221 else if (tags.size() > 1)
238 makePCrossingFrame));
239 produces<CrossingFrame<PSimHit> >(
label);
240 if (makePCrossingFrame) {
241 produces<PCrossingFrame<PSimHit> >(
label);
243 consumes<std::vector<PSimHit> >(
tag);
246 LogInfo(
"MixingModule") <<
"Will mix " <<
object <<
"s with InputTag= " << tag.
encode() <<
", label will be "
252 <<
"You have asked to mix an unknown type of object(" <<
object
253 <<
").\n If you want to include it in mixing, please contact the authors of the MixingModule!";
259 for (
unsigned int branch = 0; branch <
wantedBranches_.size(); ++branch)
264 produces<PileupMixingContent>();
266 produces<CrossingFramePlaybackInfoNew>();
270 configToken_ = esConsumes<edm::Transition::BeginLuminosityBlock>();
279 for (
auto const& digiName : digiNames) {
284 std::unique_ptr<DigiAccumulatorMixMod> accumulator = std::unique_ptr<DigiAccumulatorMixMod>(
287 if (accumulator.get() !=
nullptr) {
356 delete digiAccumulator;
365 LogDebug(
"MixingModule") <<
"===============> adding signals for " << e.
id();
387 adjuster->doOffset(
bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
393 for (
auto const& worker :
workers_) {
394 LogDebug(
"MixingModule") <<
" merging Event: id " << eventPrincipal.
id();
397 worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
404 using namespace std::placeholders;
407 std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
408 std::vector<size_t> sizes;
410 size_t playbackCounter = 0U;
413 bool oldFormatPlayback =
false;
421 "CrossingFramePlaybackInfoNew on the input file, but playback "
422 "option set!!!!! Please change the input file if you really want "
426 oldFormatPlayback =
true;
432 std::vector<int> PileupList;
438 if ((source0 && source0->doPileUp(0)) && !
playback_) {
449 std::vector<int> numInteractionList;
450 std::vector<int> bunchCrossingList;
451 std::vector<float> TrueInteractionList;
452 std::vector<edm::EventID> eventInfoList;
457 bunchCrossingList.push_back(bunchCrossing);
459 numInteractionList.push_back(0);
460 TrueInteractionList.push_back(0);
462 numInteractionList.push_back(PileupList[bunchCrossing -
minBunch_]);
468 bunchCrossingList.push_back(bunchIdx);
469 for (
size_t readSrcIdx = 0; readSrcIdx <
maxNbSources_; ++readSrcIdx) {
470 if (oldFormatPlayback) {
471 std::vector<edm::EventID>
const& playEventID =
472 oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
473 size_t numberOfEvents = playEventID.size();
474 if (readSrcIdx == 0) {
475 PileupList.push_back(numberOfEvents);
477 numInteractionList.push_back(numberOfEvents);
478 TrueInteractionList.push_back(numberOfEvents);
481 size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
482 if (readSrcIdx == 0) {
483 PileupList.push_back(numberOfEvents);
485 numInteractionList.push_back(numberOfEvents);
486 TrueInteractionList.push_back(numberOfEvents);
496 (*accItr)->StorePileupInformation(
497 bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList,
bunchSpace_);
505 for (
size_t setBcrIdx = 0; setBcrIdx <
workers_.size(); ++setBcrIdx) {
506 workers_[setBcrIdx]->setBcrOffset();
511 (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
514 for (
size_t readSrcIdx = 0; readSrcIdx <
maxNbSources_; ++readSrcIdx) {
519 for (
size_t setSrcIdx = 0; setSrcIdx <
workers_.size(); ++setSrcIdx) {
520 workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
523 if (!source || !source->doPileUp(bunchIdx)) {
526 playbackCounter += playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
532 int vertexOffset = 0;
537 int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx -
minBunch_] : 1);
538 sizes.push_back(numberOfEvents);
552 }
else if (oldFormatPlayback) {
553 std::vector<edm::EventID>
const& playEventID = oldFormatPlaybackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
554 size_t numberOfEvents = playEventID.size();
555 if (readSrcIdx == 0) {
556 PileupList.push_back(numberOfEvents);
559 sizes.push_back(numberOfEvents);
560 std::vector<EventID>::const_iterator
begin = playEventID.begin();
561 std::vector<EventID>::const_iterator
end = playEventID.end();
575 size_t numberOfEvents = playbackInfo_H->getNumberOfEvents(bunchIdx, readSrcIdx);
576 if (readSrcIdx == 0) {
577 PileupList.push_back(numberOfEvents);
580 sizes.push_back(numberOfEvents);
581 std::vector<SecondaryEventIDAndFileInfo>::const_iterator
begin = playbackInfo_H->getEventId(playbackCounter);
582 playbackCounter += numberOfEvents;
583 std::vector<SecondaryEventIDAndFileInfo>::const_iterator
end = playbackInfo_H->getEventId(playbackCounter);
601 (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
606 for (
auto const item : recordEventID) {
607 eventInfoList.emplace_back(
item.eventID());
615 std::unique_ptr<PileupMixingContent> PileupMixing_;
617 PileupMixing_ = std::make_unique<PileupMixingContent>(
618 bunchCrossingList, numInteractionList, TrueInteractionList, eventInfoList,
bunchSpace_);
631 std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(
playbackInfo_);
640 (*accItr)->beginRun(run, setup);
649 (*accItr)->endRun(run, setup);
658 (*accItr)->beginLuminosityBlock(lumi, setup);
667 (*accItr)->endLuminosityBlock(lumi, setup);
676 (*accItr)->initializeEvent(event, setup);
684 (*accItr)->accumulate(event, setup);
694 (*accItr)->accumulate(event, setup, streamID);
702 (*accItr)->finalizeEvent(event, setup);
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(const edm::Run &r, const edm::EventSetup &setup) override
void beginLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
static std::string const source("source")
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
edm::ESGetToken< MixingModuleConfig, MixingRcd > configToken_
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
EventID const & id() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void addSignals(const edm::Event &e, const edm::EventSetup &es) override
std::vector< AdjusterBase * > adjustersObjects_
std::vector< AdjusterBase * > adjusters_
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
void put(edm::Event &e, const edm::EventSetup &es) override
std::vector< MixingWorkerBase * > workers_
bool getData(T &iHolder) const
ModuleCallingContext const * moduleCallingContext() const
void reload(const edm::EventSetup &) override
std::string friendlyName(std::string const &iFullName)
void endLuminosityBlock(LuminosityBlock const &l1, EventSetup const &c) override
void checkSignal(const edm::Event &e) override
std::unique_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, ProducesCollector, ConsumesCollector &) const
Accumulators digiAccumulators_
void initializeEvent(Event const &event, EventSetup const &setup) override
MixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
static const unsigned int maxNbSources_
std::vector< std::string > names
std::vector< float > TrueNumInteractions_
void beginRun(Run const &r1, EventSetup const &c) override
std::vector< std::string > getParameterNames() const
CrossingFramePlaybackInfoNew * playbackInfo_
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)
Log< level::Info, false > LogInfo
bool pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
ParameterSet const & getParameterSet(std::string const &) const
T getParameter(std::string const &) const
std::vector< std::string > wantedBranches_
InputTag inputTagPlayback_
tuple config
parse the configuration file
void accumulateEvent(Event const &event, EventSetup const &setup)
void createnewEDProduct() override
std::vector< std::shared_ptr< PileUp > > inputSources_
std::vector< MixingWorkerBase * > workersObjects_
StreamID streamID() const
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
void finalizeEvent(Event &event, EventSetup const &setup) override
Log< level::Warning, false > LogWarning
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
static DigiAccumulatorMixModFactory const * get()
static const std::string subdets[7]
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &setup) override
void doPileUp(edm::Event &e, const edm::EventSetup &es) override
void endRun(Run const &r1, EventSetup const &c) override