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()) {
69 if (ps_mix.
exists(
"WrapLongTimes")) {
70 wrapLongTimes_ = ps_mix.
getParameter<
bool>(
"WrapLongTimes");
75 std::vector<std::string>
names = ps.getParameterNames();
76 for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) {
78 if (!pset.
exists(
"type"))
continue;
80 std::vector<InputTag> tags=pset.
getParameter<std::vector<InputTag> >(
"input");
87 if (
object==
"SimTrack") {
89 if (!tags.empty()) tag=tags[0];
95 if(makeCrossingFrame) {
97 produces<CrossingFrame<SimTrack> >(
label);
99 consumes<std::vector<SimTrack> >(
tag);
101 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
104 }
else if (
object==
"RecoTrack") {
106 if (!tags.empty()) tag=tags[0];
115 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
118 }
else if (
object==
"SimVertex") {
120 if (!tags.empty()) tag=tags[0];
126 if(makeCrossingFrame) {
128 produces<CrossingFrame<SimVertex> >(
label);
130 consumes<std::vector<SimVertex> >(
tag);
132 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag "<<tag.
encode()<<
", label will be "<<
label;
135 }
else if (
object==
"HepMCProduct") {
137 if (!tags.empty()) tag=tags[0];
142 if(makeCrossingFrame) {
144 produces<CrossingFrame<HepMCProduct> >(
label);
146 consumes<HepMCProduct>(
tag);
148 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
150 for(
size_t i = 1;
i < tags.size(); ++
i) {
154 mayConsume<HepMCProduct>(fallbackTag);
157 }
else if (
object==
"PCaloHit") {
161 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
163 if (tags.size()==1) tag=tags[0];
164 else if(tags.size()>1) tag=tags[
ii];
171 produces<CrossingFrame<PCaloHit> >(
label);
172 consumes<std::vector<PCaloHit> >(
tag);
175 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
180 }
else if (
object==
"PSimHit") {
186 for (
unsigned int ii=0;
ii<subdets.size();++
ii) {
188 if (tags.size()==1) tag=tags[0];
189 else if(tags.size()>1) tag=tags[
ii];
197 produces<CrossingFrame<PSimHit> >(
label);
198 if(makePCrossingFrame) {
199 produces<PCrossingFrame<PSimHit> >(
label);
201 consumes<std::vector<PSimHit> >(
tag);
204 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
208 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!";
218 produces<PileupMixingContent>();
220 produces<CrossingFramePlaybackInfoNew>();
231 for(
auto const& digiName : digiNames) {
238 if(accumulator.get() !=
nullptr) {
274 if (adjuster->checkSignal(e)){
281 if (worker->checkSignal(e)){
308 delete digiAccumulator;
314 LogDebug(
"MixingModule")<<
"===============> adding signals for "<<e.
id();
325 int bunchCrossing,
int eventId,
337 adjuster->doOffset(
bunchSpace_, bunchCrossing, eventPrincipal, &moduleCallingContext, eventId, vertexOffset);
343 for (
auto const& worker :
workers_) {
344 LogDebug(
"MixingModule") <<
" merging Event: id " << eventPrincipal.
id();
347 worker->addPileups(eventPrincipal, &moduleCallingContext, eventId);
355 std::vector<edm::SecondaryEventIDAndFileInfo> recordEventID;
356 std::vector<size_t> sizes;
358 size_t playbackCounter = 0
U;
361 bool oldFormatPlayback =
false;
368 "CrossingFramePlaybackInfoNew on the input file, but playback " 369 "option set!!!!! Please change the input file if you really want " 370 "playback!!!!!!" << std::endl;
372 oldFormatPlayback =
true;
378 std::vector<int> PileupList;
384 if((source0 && source0->doPileUp(0) ) && !
playback_) {
396 std::vector<int> numInteractionList;
398 std::vector<float> TrueInteractionList;
399 std::vector<edm::EventID> eventInfoList;
405 bunchCrossingList.push_back(bunchCrossing);
407 numInteractionList.push_back(0);
408 TrueInteractionList.push_back(0);
411 numInteractionList.push_back(PileupList[bunchCrossing-
minBunch_]);
418 bunchCrossingList.push_back(bunchIdx);
419 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; ++readSrcIdx) {
421 if(oldFormatPlayback) {
422 std::vector<edm::EventID>
const& playEventID = oldFormatPlaybackInfo_H->
getStartEventId(readSrcIdx, bunchIdx);
423 size_t numberOfEvents = playEventID.size();
424 if(readSrcIdx == 0) {
425 PileupList.push_back(numberOfEvents);
427 numInteractionList.push_back(numberOfEvents);
428 TrueInteractionList.push_back(numberOfEvents);
432 if(readSrcIdx == 0) {
433 PileupList.push_back(numberOfEvents);
435 numInteractionList.push_back(numberOfEvents);
436 TrueInteractionList.push_back(numberOfEvents);
444 (*accItr)->StorePileupInformation( bunchCrossingList,
457 for (
size_t setBcrIdx=0; setBcrIdx<
workers_.size(); ++setBcrIdx) {
458 workers_[setBcrIdx]->setBcrOffset();
461 (*accItr)->initializeBunchCrossing(e, setup, bunchIdx);
464 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; ++readSrcIdx) {
469 for (
size_t setSrcIdx=0; setSrcIdx<
workers_.size(); ++setSrcIdx) {
470 workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
473 if (!source || !source->doPileUp(bunchIdx)) {
482 int vertexOffset = 0;
487 int numberOfEvents = (readSrcIdx == 0 ? PileupList[bunchIdx -
minBunch_] : 1);
488 sizes.push_back(numberOfEvents);
491 _2, vertexOffset, std::ref(setup), e.
streamID()), numberOfEvents, e.
streamID());
492 }
else if(oldFormatPlayback) {
493 std::vector<edm::EventID>
const& playEventID = oldFormatPlaybackInfo_H->
getStartEventId(readSrcIdx, bunchIdx);
494 size_t numberOfEvents = playEventID.size();
495 if(readSrcIdx == 0) {
496 PileupList.push_back(numberOfEvents);
499 sizes.push_back(numberOfEvents);
500 std::vector<EventID>::const_iterator
begin = playEventID.begin();
501 std::vector<EventID>::const_iterator
end = playEventID.end();
503 begin, end, recordEventID,
505 _2, vertexOffset, std::ref(setup), e.
streamID()));
508 if(readSrcIdx == 0) {
509 PileupList.push_back(numberOfEvents);
512 sizes.push_back(numberOfEvents);
513 std::vector<SecondaryEventIDAndFileInfo>::const_iterator
begin = playbackInfo_H->
getEventId(playbackCounter);
514 playbackCounter += numberOfEvents;
515 std::vector<SecondaryEventIDAndFileInfo>::const_iterator
end = playbackInfo_H->
getEventId(playbackCounter);
517 begin, end, recordEventID,
519 _2, vertexOffset, std::ref(setup), e.
streamID()));
523 (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx);
528 for (
auto const item : recordEventID) {
529 eventInfoList.emplace_back(item.eventID());
538 std::unique_ptr<PileupMixingContent> PileupMixing_;
540 PileupMixing_ = std::unique_ptr<PileupMixingContent>(
new PileupMixingContent(bunchCrossingList,
558 std::unique_ptr<CrossingFramePlaybackInfoNew> pOut(
playbackInfo_);
565 (*accItr)->beginRun(run, setup);
572 (*accItr)->endRun(run, setup);
579 (*accItr)->beginLuminosityBlock(lumi, setup);
586 (*accItr)->endLuminosityBlock(lumi, setup);
594 (*accItr)->initializeEvent(event, setup);
601 (*accItr)->accumulate(event, setup);
608 (*accItr)->accumulate(event, setup, streamID);
615 (*accItr)->finalizeEvent(event, setup);
void setInfo(std::vector< edm::SecondaryEventIDAndFileInfo > &eventInfo, std::vector< size_t > &sizes)
std::vector< edm::SecondaryEventIDAndFileInfo >::const_iterator getEventId(size_t offset) const
T getParameter(std::string const &) const
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
const int & bunchSpace() const
static std::string const source("source")
static const HistoName names[]
std::vector< edm::EventID > getStartEventId(const unsigned int s, const int bcr) const
void createDigiAccumulators(const edm::ParameterSet &mixingPSet, edm::ConsumesCollector &iC)
std::vector< float > TrueNumInteractions_
EventID const & id() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
void addSignals(const edm::Event &e, const edm::EventSetup &es) override
void endRun(const edm::Run &r, const edm::EventSetup &setup) override
void put(edm::Event &e, const edm::EventSetup &es) override
const int & maxBunch() 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::vector< MixingWorkerBase * > workers_
Accumulators digiAccumulators_
void initializeEvent(Event const &event, EventSetup const &setup) override
MixingModule(const edm::ParameterSet &ps, MixingCache::Config const *globalConf)
std::vector< AdjusterBase * > adjusters_
size_t getNumberOfEvents(int bunchIdx, size_t sourceNumber) const
static const unsigned int maxNbSources_
std::vector< MixingWorkerBase * > workersObjects_
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
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
bool useCurrentProcessOnly_
virtual void branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label)
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)
void createnewEDProduct() override
std::vector< std::shared_ptr< PileUp > > inputSources_
std::unique_ptr< DigiAccumulatorMixMod > makeDigiAccumulator(ParameterSet const &, ProducerBase &, ConsumesCollector &) const
StreamID streamID() const
const int & minBunch() 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
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 pileAllWorkers(EventPrincipal const &ep, ModuleCallingContext const *, int bcr, int id, int &offset, const edm::EventSetup &setup, edm::StreamID const &)
void endRun(Run const &r1, EventSetup const &c) override