29 labelPlayback_(ps_mix.getParameter<std::string>(
"LabelPlayback")),
30 mixProdStep2_(ps_mix.getParameter<bool>(
"mixProdStep2")),
31 mixProdStep1_(ps_mix.getParameter<bool>(
"mixProdStep1"))
34 if (
mixProdStep1_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step1 mode. It produces a mixed secondary source.";
35 if (
mixProdStep2_)
LogInfo(
"MixingModule") <<
" The MixingModule was run in the Step2 mode. It uses a mixed secondary source.";
38 if (ps_mix.
exists(
"useCurrentProcessOnly")) {
51 for (std::vector<string>::iterator it=names.begin();it!= names.end();++it)
54 if (!pset.
exists(
"type"))
continue;
55 std::string
object = pset.
getParameter<std::string>(
"type");
56 std::vector<InputTag>
tags=pset.
getParameter<std::vector<InputTag> >(
"input");
60 if (
object==
"SimTrackPCrossingFrame") {
62 if (tags.size()>0) tag=tags[0];
66 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
71 if (
find(names.begin(), names.end(),
"mixTracks") != names.end())
74 if (!psin.
exists(
"type"))
continue;
75 std::string
object = psin.
getParameter<std::string>(
"type");
76 std::vector<InputTag> tags=psin.
getParameter<std::vector<InputTag> >(
"input");
79 if (tags.size()>0) tagCF=tags[0];
85 produces<CrossingFrame<SimTrack> >(labelCF);
89 }
else if (
object==
"SimVertexPCrossingFrame") {
91 if (tags.size()>0) tag=tags[0];
95 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag "<<tag.
encode()<<
", label will be "<<
label;
100 if (
find(names.begin(), names.end(),
"mixVertices") != names.end())
103 if (!psin.
exists(
"type"))
continue;
104 std::string
object = psin.
getParameter<std::string>(
"type");
105 std::vector<InputTag> tags=psin.
getParameter<std::vector<InputTag> >(
"input");
108 if (tags.size()>0) tagCF=tags[0];
111 branchesActivate(
TypeID(
typeid(std::vector<SimVertex>)).friendlyClassName(),std::string(
""),tagCF,labelCF);
114 produces<CrossingFrame<SimVertex> >(labelCF);
119 else if (
object==
"HepMCProductPCrossingFrame") {
121 if (tags.size()>0) tag=tags[0];
125 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
130 if (
find(names.begin(), names.end(),
"mixHepMC") != names.end())
133 if (!psin.
exists(
"type"))
continue;
134 std::string
object = psin.
getParameter<std::string>(
"type");
135 std::vector<InputTag> tags=psin.
getParameter<std::vector<InputTag> >(
"input");
138 if (tags.size()>0) tagCF=tags[0];
144 produces<CrossingFrame<HepMCProduct> >(labelCF);
147 }
else if (
object==
"PCaloHitPCrossingFrame") {
149 for (
unsigned int ii=0;ii<subdets.size();ii++) {
151 if (tags.size()==1) tag=tags[0];
152 else if(tags.size()>1) tag=tags[ii];
156 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
161 if (
find(names.begin(), names.end(),
"mixCH") != names.end())
164 if (!psin.
exists(
"type"))
continue;
165 std::string
object = psin.
getParameter<std::string>(
"type");
166 std::vector<InputTag> tags=psin.
getParameter<std::vector<InputTag> >(
"input");
169 if (tags.size()==1) tagCF=tags[0];
170 else if(tags.size()>1) tagCF=tags[ii];
176 produces<CrossingFrame<PCaloHit> > (labelCF);
181 }
else if (
object==
"PSimHitPCrossingFrame") {
183 for (
unsigned int ii=0;ii<subdets.size();ii++) {
185 if (tags.size()==1) tag=tags[0];
186 else if(tags.size()>1) tag=tags[ii];
190 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
196 if (
find(names.begin(), names.end(),
"mixSH") != names.end())
199 if (!psin.
exists(
"type"))
continue;
200 std::string
object = psin.
getParameter<std::string>(
"type");
201 std::vector<InputTag> tags=psin.
getParameter<std::vector<InputTag> >(
"input");
204 if (tags.size()==1) tagCF=tags[0];
205 else if(tags.size()>1) tagCF=tags[ii];
210 produces<CrossingFrame<PSimHit> > (labelCF);
222 std::string labelCF =
" ";
225 if (
object==
"SimTrack") {
227 if (tags.size()>0) tag=tags[0];
233 produces<CrossingFrame<SimTrack> >(
label);
234 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
238 }
else if (
object==
"SimVertex") {
240 if (tags.size()>0) tag=tags[0];
246 produces<CrossingFrame<SimVertex> >(
label);
247 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag "<<tag.
encode()<<
", label will be "<<
label;
250 }
else if (
object==
"HepMCProduct") {
252 if (tags.size()>0) tag=tags[0];
258 produces<CrossingFrame<HepMCProduct> >(
label);
259 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
263 }
else if (
object==
"PCaloHit") {
265 for (
unsigned int ii=0;ii<subdets.size();ii++) {
267 if (tags.size()==1) tag=tags[0];
268 else if(tags.size()>1) tag=tags[ii];
274 produces<CrossingFrame<PCaloHit> > (
label);
275 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
280 }
else if (
object==
"PSimHit") {
282 for (
unsigned int ii=0;ii<subdets.size();ii++) {
284 if (tags.size()==1) tag=tags[0];
285 else if(tags.size()>1) tag=tags[ii];
291 produces<CrossingFrame<PSimHit> > (
label);
292 LogInfo(
"MixingModule") <<
"Will mix "<<
object<<
"s with InputTag= "<<tag.
encode()<<
", label will be "<<
label;
296 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!";
305 produces<PileupMixingContent>();
307 produces<CrossingFramePlaybackInfoExtended>();
356 for (
unsigned int ii=0;ii<
workers_.size();ii++){
372 LogDebug(
"MixingModule")<<
"===============> adding signals for "<<e.
id();
373 for (
unsigned int ii=0;ii<
workers_.size();ii++){
381 int bunchCrossing,
int eventId,
384 for (
unsigned int ii=0;ii<
workers_.size();ii++) {
385 LogDebug(
"MixingModule") <<
" merging Event: id " << eventPrincipal.
id();
388 workers_[ii]->addPileups(bunchCrossing,eventPrincipal,
398 std::vector<edm::EventID> recordEventID;
401 bool got=e.
get((*
sel_), playbackInfo_H);
404 "CrossingFramePlaybackInfoExtended on the input file, but playback "
405 "option set!!!!! Please change the input file if you really want "
406 "playback!!!!!!" << endl;
412 std::vector<int> PileupList;
418 if( (source0 && source0->doPileUp() ) && !
playback_ ) {
431 int KeepTrackOfPileup = 0;
434 for (
size_t setBcrIdx=0; setBcrIdx<
workers_.size(); setBcrIdx++) {
435 workers_[setBcrIdx]->setBcrOffset();
438 for (
size_t readSrcIdx=0; readSrcIdx<
maxNbSources_; readSrcIdx++ ) {
444 for (
size_t setSrcIdx=0; setSrcIdx<
workers_.size(); setSrcIdx++) {
445 workers_[setSrcIdx]->setSourceOffset(readSrcIdx);
447 if (!source || !source->doPileUp())
continue;
449 int NumPU_Events = 0;
452 else { NumPU_Events = 1;}
455 int vertexOffset = 0;
460 _2, vertexOffset), NumPU_Events
463 KeepTrackOfPileup+=NumPU_Events;
466 const std::vector<edm::EventID>& playEventID =
467 playbackInfo_H->getStartEventId(readSrcIdx, bunchIdx);
468 if(readSrcIdx == 0) {
469 PileupList.push_back(playEventID.size());
475 dummyId, vertexOffset)
483 std::auto_ptr< PileupMixingContent > PileupMixing_;
485 std::vector<int> numInteractionList;
486 std::vector<int> bunchCrossingList;
487 std::vector<float> TrueInteractionList;
491 bunchCrossingList.push_back(bunchCrossing);
493 numInteractionList.push_back(0);
494 TrueInteractionList.push_back(0);
497 numInteractionList.push_back(PileupList[bunchCrossing-
minBunch_]);
503 PileupMixing_ = std::auto_ptr< PileupMixingContent >(
new PileupMixingContent( bunchCrossingList,
505 TrueInteractionList));
507 e.
put(PileupMixing_);
511 for (
unsigned int ii=0;ii<
workers_.size();ii++) {
524 std::auto_ptr<CrossingFramePlaybackInfoExtended> pOut(
playbackInfo_);
T getParameter(std::string const &) const
void pileAllWorkers(EventPrincipal const &ep, int bcr, int id, int &offset)
virtual void reload(const edm::EventSetup &)
virtual void createnewEDProduct()
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
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::string labelPlayback_
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)
virtual void checkSignal(const edm::Event &e)
std::string friendlyName(std::string const &iFullName)
static std::string subdets[11]
std::vector< MixingWorkerBase * > workers_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool get(ProductID const &oid, Handle< PROD > &result) const
static const unsigned int maxNbSources_
std::vector< MixingWorkerBase * > workersObjects_
std::vector< std::string > getParameterNames() const
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
std::vector< std::string > wantedBranches_
std::vector< boost::shared_ptr< PileUp > > inputSources_
CrossingFramePlaybackInfoExtended * playbackInfo_
void dropUnwantedBranches(std::vector< std::string > const &wantedBranches)
static const HistoName names[]
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual void doPileUp(edm::Event &e, const edm::EventSetup &es)