#include <MixingModule.h>
Public Types | |
typedef std::vector < DigiAccumulatorMixMod * > | Accumulators |
Public Member Functions | |
void | accumulateEvent (Event const &event, EventSetup const &setup) |
void | accumulateEvent (PileUpEventPrincipal const &event, EventSetup const &setup) |
virtual void | beginJob () |
virtual void | beginLuminosityBlock (LuminosityBlock const &l1, EventSetup const &c) override |
virtual void | beginRun (Run const &r1, EventSetup const &c) override |
virtual void | endLuminosityBlock (LuminosityBlock const &l1, EventSetup const &c) override |
virtual void | endRun (Run const &r1, EventSetup const &c) override |
void | finalizeEvent (Event &event, EventSetup const &setup) |
void | initializeEvent (Event const &event, EventSetup const &setup) |
MixingModule (const edm::ParameterSet &ps) | |
virtual void | reload (const edm::EventSetup &) |
virtual | ~MixingModule () |
Private Member Functions | |
virtual void | addSignals (const edm::Event &e, const edm::EventSetup &es) |
virtual void | branchesActivate (const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label) |
virtual void | checkSignal (const edm::Event &e) |
void | createDigiAccumulators (const edm::ParameterSet &mixingPSet) |
virtual void | createnewEDProduct () |
virtual void | doPileUp (edm::Event &e, const edm::EventSetup &es) |
void | pileAllWorkers (EventPrincipal const &ep, int bcr, int id, int &offset, const edm::EventSetup &setup) |
virtual void | put (edm::Event &e, const edm::EventSetup &es) |
Private Attributes | |
std::vector< AdjusterBase * > | adjusters_ |
std::vector< AdjusterBase * > | adjustersObjects_ |
Accumulators | digiAccumulators_ |
InputTag | inputTagPlayback_ |
bool | mixProdStep1_ |
bool | mixProdStep2_ |
CrossingFramePlaybackInfoExtended * | playbackInfo_ |
bool | useCurrentProcessOnly_ |
std::vector< std::string > | wantedBranches_ |
std::vector< MixingWorkerBase * > | workers_ |
std::vector< MixingWorkerBase * > | workersObjects_ |
Definition at line 46 of file MixingModule.h.
typedef std::vector<DigiAccumulatorMixMod*> edm::MixingModule::Accumulators |
Definition at line 48 of file MixingModule.h.
afs cern ch work a aaltunda public www CMSSW_6_2_5 src SimGeneral MixingModule plugins MixingModule cc afs cern ch work a aaltunda public www CMSSW_6_2_5 src SimGeneral MixingModule plugins MixingModule cc MixingModule::MixingModule | ( | const edm::ParameterSet & | ps | ) | [explicit] |
standard constructor
Definition at line 33 of file MixingModule.cc.
References edm::binary_search_all(), edm::InputTag::encode(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), edm::ParameterSet::getUntrackedParameter(), cuy::ii, edm::InputTag::instance(), diffTwoXMLs::label, LogDebug, cscdqm::h::names, edm::sort_all(), AlCaHLTBitMon_QueryRunRegistry::string, subdets, GlobalPosition_Frontier_DevDB_cff::tag, and o2o::tags.
{ if (!mixProdStep1_ && !mixProdStep2_) LogInfo("MixingModule") << " The MixingModule was run in the Standard mode."; if (mixProdStep1_) LogInfo("MixingModule") << " The MixingModule was run in the Step1 mode. It produces a mixed secondary source."; if (mixProdStep2_) LogInfo("MixingModule") << " The MixingModule was run in the Step2 mode. It uses a mixed secondary source."; useCurrentProcessOnly_=false; if (ps_mix.exists("useCurrentProcessOnly")) { useCurrentProcessOnly_=ps_mix.getParameter<bool>("useCurrentProcessOnly"); LogInfo("MixingModule") <<" using given Parameter 'useCurrentProcessOnly' ="<<useCurrentProcessOnly_; } std::string labelPlayback; if (ps_mix.exists("LabelPlayback")) { labelPlayback = ps_mix.getParameter<std::string>("LabelPlayback"); } if (labelPlayback.empty()) { labelPlayback = ps_mix.getParameter<std::string>("@module_label"); } inputTagPlayback_ = InputTag(labelPlayback, ""); ParameterSet ps=ps_mix.getParameter<ParameterSet>("mixObjects"); std::vector<std::string> names = ps.getParameterNames(); for(std::vector<std::string>::iterator it=names.begin();it!= names.end();++it) { ParameterSet pset=ps.getParameter<ParameterSet>((*it)); if (!pset.exists("type")) continue; //to allow replacement by empty pset std::string object = pset.getParameter<std::string>("type"); std::vector<InputTag> tags=pset.getParameter<std::vector<InputTag> >("input"); //if (!mixProdStep2_) { InputTag tagCF = InputTag(); std::string labelCF = " "; if (object=="SimTrack") { InputTag tag; if (tags.size()>0) tag=tags[0]; std::string label; branchesActivate(TypeID(typeid(std::vector<SimTrack>)).friendlyClassName(),std::string(""),tag,label); adjustersObjects_.push_back(new Adjuster<SimTrack>(tag)); bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false); if(makeCrossingFrame) { workersObjects_.push_back(new MixingWorker<SimTrack>(minBunch_,maxBunch_,bunchSpace_,std::string(""),label,labelCF,maxNbSources_,tag,tagCF)); produces<CrossingFrame<SimTrack> >(label); } LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label; // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl; } else if (object=="RecoTrack") { InputTag tag; if (tags.size()>0) tag=tags[0]; std::string label; branchesActivate(TypeID(typeid(std::vector<reco::Track>)).friendlyClassName(),std::string(""),tag,label); // note: no crossing frame is foreseen to be used for this object type LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label; //std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl; } else if (object=="SimVertex") { InputTag tag; if (tags.size()>0) tag=tags[0]; std::string label; branchesActivate(TypeID(typeid(std::vector<SimVertex>)).friendlyClassName(),std::string(""),tag,label); adjustersObjects_.push_back(new Adjuster<SimVertex>(tag)); bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false); if(makeCrossingFrame) { workersObjects_.push_back(new MixingWorker<SimVertex>(minBunch_,maxBunch_,bunchSpace_,std::string(""),label,labelCF,maxNbSources_,tag,tagCF)); produces<CrossingFrame<SimVertex> >(label); } LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label; // std::cout <<"Will mix "<<object<<"s with InputTag "<<tag.encode()<<", label will be "<<label<<std::endl; } else if (object=="HepMCProduct") { InputTag tag; if (tags.size()>0) tag=tags[0]; std::string label; branchesActivate(TypeID(typeid(HepMCProduct)).friendlyClassName(),std::string(""),tag,label); bool makeCrossingFrame = pset.getUntrackedParameter<bool>("makeCrossingFrame", false); if(makeCrossingFrame) { workersObjects_.push_back(new MixingWorker<HepMCProduct>(minBunch_,maxBunch_,bunchSpace_,std::string(""),label,labelCF,maxNbSources_,tag,tagCF)); produces<CrossingFrame<HepMCProduct> >(label); } LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label; // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl; } else if (object=="PCaloHit") { std::vector<std::string> subdets=pset.getParameter<std::vector<std::string> >("subdets"); std::vector<std::string> crossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>()); sort_all(crossingFrames); for (unsigned int ii=0;ii<subdets.size();++ii) { InputTag tag; if (tags.size()==1) tag=tags[0]; else if(tags.size()>1) tag=tags[ii]; std::string label; branchesActivate(TypeID(typeid(std::vector<PCaloHit>)).friendlyClassName(),subdets[ii],tag,label); adjustersObjects_.push_back(new Adjuster<PCaloHit>(tag)); if(binary_search_all(crossingFrames, tag.instance())) { workersObjects_.push_back(new MixingWorker<PCaloHit>(minBunch_,maxBunch_,bunchSpace_,subdets[ii],label,labelCF,maxNbSources_,tag,tagCF)); produces<CrossingFrame<PCaloHit> >(label); } LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label; // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl; } } else if (object=="PSimHit") { std::vector<std::string> subdets=pset.getParameter<std::vector<std::string> >("subdets"); std::vector<std::string> crossingFrames=pset.getUntrackedParameter<std::vector<std::string> >("crossingFrames", std::vector<std::string>()); sort_all(crossingFrames); for (unsigned int ii=0;ii<subdets.size();++ii) { InputTag tag; if (tags.size()==1) tag=tags[0]; else if(tags.size()>1) tag=tags[ii]; std::string label; branchesActivate(TypeID(typeid(std::vector<PSimHit>)).friendlyClassName(),subdets[ii],tag,label); adjustersObjects_.push_back(new Adjuster<PSimHit>(tag)); if(binary_search_all(crossingFrames, tag.instance())) { workersObjects_.push_back(new MixingWorker<PSimHit>(minBunch_,maxBunch_,bunchSpace_,subdets[ii],label,labelCF,maxNbSources_,tag,tagCF)); produces<CrossingFrame<PSimHit> >(label); } LogInfo("MixingModule") <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label; // std::cout <<"Will mix "<<object<<"s with InputTag= "<<tag.encode()<<", label will be "<<label<<std::endl; } } else { 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!"; } //} //if for mixProdStep2 }//while over the mixObjects parameters sort_all(wantedBranches_); for (unsigned int branch=0;branch<wantedBranches_.size();++branch) LogDebug("MixingModule")<<"Will keep branch "<<wantedBranches_[branch]<<" for mixing "; dropUnwantedBranches(wantedBranches_); produces<PileupMixingContent>(); produces<CrossingFramePlaybackInfoExtended>(); // Create and configure digitizers createDigiAccumulators(ps_mix); }
MixingModule::~MixingModule | ( | ) | [virtual] |
Default destructor
Definition at line 258 of file MixingModule.cc.
: adjustersObjects_) { delete adjuster; } for (auto& digiAccumulator : digiAccumulators_) { delete digiAccumulator; } } void MixingModule::addSignals(const edm::Event &e, const edm::EventSetup& setup) {
void MixingModule::accumulateEvent | ( | edm::Event const & | event, |
edm::EventSetup const & | setup | ||
) |
Definition at line 470 of file MixingModule.cc.
Referenced by pileAllWorkers().
void MixingModule::accumulateEvent | ( | PileUpEventPrincipal const & | event, |
edm::EventSetup const & | setup | ||
) |
Definition at line 477 of file MixingModule.cc.
void MixingModule::addSignals | ( | const edm::Event & | e, |
const edm::EventSetup & | es | ||
) | [private, virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 272 of file MixingModule.cc.
{ workers_[ii]->addSignals(e); } } void MixingModule::pileAllWorkers(EventPrincipal const& eventPrincipal,
virtual void edm::MixingModule::beginJob | ( | void | ) | [inline, virtual] |
void MixingModule::beginLuminosityBlock | ( | edm::LuminosityBlock const & | lumi, |
edm::EventSetup const & | setup | ||
) | [override, virtual] |
void MixingModule::beginRun | ( | edm::Run const & | run, |
edm::EventSetup const & | setup | ||
) | [override, virtual] |
void MixingModule::branchesActivate | ( | const std::string & | friendlyName, |
const std::string & | subdet, | ||
InputTag & | tag, | ||
std::string & | label | ||
) | [private, virtual] |
Definition at line 216 of file MixingModule.cc.
References EgammaHLTValidationUtils::getProcessName(), and AlCaHLTBitMon_QueryRunRegistry::string.
{ const std::string processName = edm::Service<edm::service::TriggerNamesService>()->getProcessName(); tag = InputTag(tag.label(),tag.instance(),processName); } } void MixingModule::checkSignal(const edm::Event &e){
void MixingModule::checkSignal | ( | const edm::Event & | e | ) | [private, virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 230 of file MixingModule.cc.
References adjusters_.
: adjustersObjects_) { if (adjuster->checkSignal(e)){ adjusters_.push_back(adjuster); } } } if (workers_.empty()){ for (auto const& worker : workersObjects_) { if (worker->checkSignal(e)){ workers_.push_back(worker); } } } } void MixingModule::createnewEDProduct() {
void MixingModule::createDigiAccumulators | ( | const edm::ParameterSet & | mixingPSet | ) | [private] |
Definition at line 190 of file MixingModule.cc.
References digiAccumulators_, reco::get(), and edm::ParameterSet::getParameterSet().
: digiNames) { ParameterSet const& pset = digiPSet.getParameterSet(digiName); std::auto_ptr<DigiAccumulatorMixMod> accumulator = std::auto_ptr<DigiAccumulatorMixMod>(DigiAccumulatorMixModFactory::get()->makeDigiAccumulator(pset, *this)); // Create appropriate DigiAccumulator if(accumulator.get() != 0) { digiAccumulators_.push_back(accumulator.release()); } } } void MixingModule::reload(const edm::EventSetup & setup){
void MixingModule::createnewEDProduct | ( | ) | [private, virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 248 of file MixingModule.cc.
void MixingModule::doPileUp | ( | edm::Event & | e, |
const edm::EventSetup & | es | ||
) | [private, virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 301 of file MixingModule.cc.
References Exception, edm::Event::getByLabel(), and inputTagPlayback_.
{ bool got = e.getByLabel(inputTagPlayback_, playbackInfo_H); if (!got) { throw cms::Exception("MixingProductNotFound") << " No " "CrossingFramePlaybackInfoExtended on the input file, but playback " "option set!!!!! Please change the input file if you really want " "playback!!!!!!" << std::endl; } } // source[0] is "real" pileup. Check to see that this is what we are doing. std::vector<int> PileupList; PileupList.clear(); TrueNumInteractions_.clear(); boost::shared_ptr<PileUp> source0 = inputSources_[0]; if((source0 && source0->doPileUp() ) && !playback_) { // if((!inputSources_[0] || !inputSources_[0]->doPileUp()) && !playback_ ) // Pre-calculate all pileup distributions before we go fishing for events source0->CalculatePileup(minBunch_, maxBunch_, PileupList, TrueNumInteractions_); } // for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) { // std::cout << " bunch ID, Pileup, True " << bunchIdx << " " << PileupList[bunchIdx-minBunch_] << " " << TrueNumInteractions_[bunchIdx-minBunch_] << std::endl; //} int KeepTrackOfPileup = 0; for (int bunchIdx = minBunch_; bunchIdx <= maxBunch_; ++bunchIdx) { for (size_t setBcrIdx=0; setBcrIdx<workers_.size(); ++setBcrIdx) { workers_[setBcrIdx]->setBcrOffset(); } for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) { (*accItr)->initializeBunchCrossing(e, setup, bunchIdx); } for (size_t readSrcIdx=0; readSrcIdx<maxNbSources_; ++readSrcIdx) { boost::shared_ptr<PileUp> source = inputSources_[readSrcIdx]; // this looks like we create // new PileUp objects for each // source for each event? // Why? for (size_t setSrcIdx=0; setSrcIdx<workers_.size(); ++setSrcIdx) { workers_[setSrcIdx]->setSourceOffset(readSrcIdx); } if (!source || !source->doPileUp()) continue; int NumPU_Events = 0; if(readSrcIdx ==0 && !playback_) { NumPU_Events = PileupList[bunchIdx - minBunch_]; } else { NumPU_Events = 1; } // non-minbias pileup only gets one event for now. Fix later if desired. // int eventId = 0; int vertexOffset = 0; if (!playback_) { inputSources_[readSrcIdx]->readPileUp(e.id(), recordEventID, boost::bind(&MixingModule::pileAllWorkers, boost::ref(*this), _1, bunchIdx, _2, vertexOffset, boost::ref(setup)), NumPU_Events ); playbackInfo_->setStartEventId(recordEventID, readSrcIdx, bunchIdx, KeepTrackOfPileup); KeepTrackOfPileup+=NumPU_Events; } else { int dummyId = 0; const std::vector<edm::EventID>& playEventID = playbackInfo_H->getStartEventId(readSrcIdx, bunchIdx); if(readSrcIdx == 0) { PileupList.push_back(playEventID.size()); TrueNumInteractions_.push_back(playEventID.size()); } inputSources_[readSrcIdx]->playPileUp( playEventID, boost::bind(&MixingModule::pileAllWorkers, boost::ref(*this), _1, bunchIdx, dummyId, vertexOffset, boost::ref(setup)) ); } } for(Accumulators::const_iterator accItr = digiAccumulators_.begin(), accEnd = digiAccumulators_.end(); accItr != accEnd; ++accItr) { (*accItr)->finalizeBunchCrossing(e, setup, bunchIdx); } } // Keep track of pileup accounting... std::auto_ptr<PileupMixingContent> PileupMixing_; std::vector<int> numInteractionList; std::vector<int> bunchCrossingList; std::vector<float> TrueInteractionList; //Makin' a list: Basically, we don't care about the "other" sources at this point. for (int bunchCrossing=minBunch_;bunchCrossing<=maxBunch_;++bunchCrossing) { bunchCrossingList.push_back(bunchCrossing); if(!inputSources_[0] || !inputSources_[0]->doPileUp()) { numInteractionList.push_back(0); TrueInteractionList.push_back(0); } else { numInteractionList.push_back(PileupList[bunchCrossing-minBunch_]); TrueInteractionList.push_back((TrueNumInteractions_)[bunchCrossing-minBunch_]); } } PileupMixing_ = std::auto_ptr<PileupMixingContent>(new PileupMixingContent(bunchCrossingList, numInteractionList, TrueInteractionList)); e.put(PileupMixing_); // we have to do the ToF transformation for PSimHits once all pileup has been added for (unsigned int ii=0;ii<workers_.size();++ii) { workers_[ii]->setTof(); workers_[ii]->put(e); } } void MixingModule::put(edm::Event &e, const edm::EventSetup& setup) {
void MixingModule::endLuminosityBlock | ( | edm::LuminosityBlock const & | lumi, |
edm::EventSetup const & | setup | ||
) | [override, virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 456 of file MixingModule.cc.
void MixingModule::endRun | ( | edm::Run const & | run, |
edm::EventSetup const & | setup | ||
) | [override, virtual] |
void MixingModule::finalizeEvent | ( | edm::Event & | event, |
edm::EventSetup const & | setup | ||
) | [virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 484 of file MixingModule.cc.
void MixingModule::initializeEvent | ( | edm::Event const & | event, |
edm::EventSetup const & | setup | ||
) | [virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 463 of file MixingModule.cc.
void MixingModule::pileAllWorkers | ( | EventPrincipal const & | ep, |
int | bcr, | ||
int | id, | ||
int & | offset, | ||
const edm::EventSetup & | setup | ||
) | [private] |
Definition at line 283 of file MixingModule.cc.
References accumulateEvent(), adjusters_, edm::BMixingModule::bunchSpace_, LogDebug, and workers_.
{ for (auto const& adjuster : adjusters_) { adjuster->doOffset(bunchSpace_, bunchCrossing, eventPrincipal, eventId, vertexOffset); } PileUpEventPrincipal pep(eventPrincipal, bunchCrossing); accumulateEvent(pep, setup); for (auto const& worker : workers_) { LogDebug("MixingModule") <<" merging Event: id " << eventPrincipal.id(); // std::cout <<"PILEALLWORKERS merging Event: id " << eventPrincipal.id() << std::endl; worker->addPileups(eventPrincipal, eventId); } } void MixingModule::doPileUp(edm::Event &e, const edm::EventSetup& setup) {
void MixingModule::put | ( | edm::Event & | e, |
const edm::EventSetup & | es | ||
) | [private, virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 430 of file MixingModule.cc.
References playbackInfo_, and edm::Event::put().
{ std::auto_ptr<CrossingFramePlaybackInfoExtended> pOut(playbackInfo_); e.put(pOut); } } void MixingModule::beginRun(edm::Run const& run, edm::EventSetup const& setup) {
void MixingModule::reload | ( | const edm::EventSetup & | setup | ) | [virtual] |
Reimplemented from edm::BMixingModule.
Definition at line 203 of file MixingModule.cc.
{ workersObjects_[ii]->reload(setup); } } void MixingModule::branchesActivate(const std::string &friendlyName, const std::string &subdet, InputTag &tag, std::string &label) {
std::vector<AdjusterBase *> edm::MixingModule::adjusters_ [private] |
Definition at line 92 of file MixingModule.h.
Referenced by checkSignal(), and pileAllWorkers().
std::vector<AdjusterBase *> edm::MixingModule::adjustersObjects_ [private] |
Definition at line 93 of file MixingModule.h.
Definition at line 100 of file MixingModule.h.
Referenced by createDigiAccumulators().
InputTag edm::MixingModule::inputTagPlayback_ [private] |
Definition at line 87 of file MixingModule.h.
Referenced by doPileUp().
bool edm::MixingModule::mixProdStep1_ [private] |
Reimplemented from edm::BMixingModule.
Definition at line 89 of file MixingModule.h.
bool edm::MixingModule::mixProdStep2_ [private] |
Reimplemented from edm::BMixingModule.
Definition at line 88 of file MixingModule.h.
Definition at line 90 of file MixingModule.h.
Referenced by put().
bool edm::MixingModule::useCurrentProcessOnly_ [private] |
Definition at line 97 of file MixingModule.h.
std::vector<std::string> edm::MixingModule::wantedBranches_ [private] |
Definition at line 96 of file MixingModule.h.
std::vector<MixingWorkerBase *> edm::MixingModule::workers_ [private] |
Definition at line 94 of file MixingModule.h.
Referenced by pileAllWorkers().
std::vector<MixingWorkerBase *> edm::MixingModule::workersObjects_ [private] |
Definition at line 95 of file MixingModule.h.