CMS 3D CMS Logo

ESRecHitsMerger.cc
Go to the documentation of this file.
1 
2 //#include <FWCore/Framework/interface/Handle.h>
6 
9 
13 
14 
15 using namespace edm;
16 using namespace std;
17 
18 
20 
21  debug_ = pset.getUntrackedParameter<bool>("debug");
22 
23  EgammaSourceES_ = pset.getUntrackedParameter<edm::InputTag>("EgammaSource_ES",edm::InputTag("dummyEgamma"));
24  MuonsSourceES_ = pset.getUntrackedParameter<edm::InputTag>("MuonsSource_ES",edm::InputTag("dummyMuons"));
25  TausSourceES_ = pset.getUntrackedParameter<edm::InputTag>("TausSource_ES",edm::InputTag("dummyTaus"));
26  JetsSourceES_ = pset.getUntrackedParameter<edm::InputTag>("JetsSource_ES",edm::InputTag("dummyJets"));
27  RestSourceES_ = pset.getUntrackedParameter<edm::InputTag>("RestSource_ES",edm::InputTag("dummyRest"));
28  Pi0SourceES_ = pset.getUntrackedParameter<edm::InputTag>("Pi0Source_ES",edm::InputTag("dummyPi0"));
29  EtaSourceES_ = pset.getUntrackedParameter<edm::InputTag>("EtaSource_ES",edm::InputTag("dummyEta"));
30 
31  OutputLabelES_ = pset.getUntrackedParameter<std::string>("OutputLabel_ES");
32  InputRecHitES_ = pset.getUntrackedParameter<std::string>("EcalRecHitCollectionES");
33 
34  consumesMany<ESRecHitCollection>();
35  produces<EcalRecHitCollection>(OutputLabelES_);
36 
37 }
38 
40 
42  desc.add<bool>("debug", false);
43  desc.add<edm::InputTag>("EgammaSource_ES", edm::InputTag("dummyEgamma"));
44  desc.add<edm::InputTag>("MuonsSource_ES",edm::InputTag("dummyMuons"));
45  desc.add<edm::InputTag>("TausSource_ES",edm::InputTag("dummyTaus"));
46  desc.add<edm::InputTag>("JetsSource_ES",edm::InputTag("dummyJets"));
47  desc.add<edm::InputTag>("RestSource_ES",edm::InputTag("dummyRest"));
48  desc.add<edm::InputTag>("Pi0Source_ES",edm::InputTag("dummyPi0"));
49  desc.add<edm::InputTag>("EtaSource_ES",edm::InputTag("dummyEta"));
50  desc.add<std::string>("OutputLabel_ES", "EcalRecHitsES");
51  desc.add<std::string>("EcalRecHitCollectionES", "EcalRecHitsES");
52  descriptions.add("hltESRecHitsMerger", desc);
53 }
54 
55 
56 
58 }
59 
60 
62 }
63 
65 }
66 
68 
69  if (debug_) std::cout << " ESRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl;
70 
71 
72  std::vector< edm::Handle<ESRecHitCollection> > EcalRecHits_done;
73  e.getManyByType(EcalRecHits_done);
74 
75  auto ESMergedRecHits = std::make_unique<EcalRecHitCollection>();
76 
77 
78  unsigned int nColl = EcalRecHits_done.size();
79 
80  int nES = 0;
81 
82 
83  for (unsigned int i=0; i < nColl; i++) {
84 
85  std::string instance = EcalRecHits_done[i].provenance()->productInstanceName();
86  std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
87 
88 
89  if (debug_){
90  std::cout<<"ESrechit to be merged from "<<module_label.c_str()<<" "<<instance.c_str()<<std::endl;
91  }
92 
93  if ( module_label != EgammaSourceES_.label() &&
94  module_label != MuonsSourceES_.label() &&
95  module_label != JetsSourceES_.label() &&
96  module_label != TausSourceES_.label() &&
97  module_label != RestSourceES_.label() &&
98  module_label != Pi0SourceES_.label() &&
99  module_label != EtaSourceES_.label()) continue;
100 
101  if (instance == InputRecHitES_) {
102  nES += EcalRecHits_done[i] -> size();
103  }
104 
105  }
106 
107 
108  ESMergedRecHits -> reserve(nES);
109 
110  if (debug_) std::cout << " Number of ES Rechits to merge = " << nES << std::endl;
111 
112  for (unsigned int i=0; i < nColl; i++) {
113  std::string instance = EcalRecHits_done[i].provenance()->productInstanceName();
114 
115  std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
116  if ( module_label != EgammaSourceES_.label() &&
117  module_label != MuonsSourceES_.label() &&
118  module_label != JetsSourceES_.label() &&
119  module_label != TausSourceES_.label() &&
120  module_label != RestSourceES_.label() &&
121  module_label != Pi0SourceES_.label() &&
122  module_label != EtaSourceES_.label() ) continue;
123 
124  if (instance == InputRecHitES_) {
125  for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) {
126  ESMergedRecHits -> push_back(*it);
127  }
128  }
129 
130  }
131 
132 
133  // std::cout << " avant le put " << std::endl;
134  e.put(std::move(ESMergedRecHits),OutputLabelES_);
135  // std::cout << " apres le put " << std::endl;
136 
137 }
138 
RunNumber_t run() const
Definition: EventID.h:39
size
Write out results.
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:569
EventNumber_t event() const
Definition: EventID.h:41
T getUntrackedParameter(std::string const &, T const &) const
void produce(edm::Event &e, const edm::EventSetup &c) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
~ESRecHitsMerger() override
static PFTauRenderPlugin instance
std::vector< EcalRecHit >::const_iterator const_iterator
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void endJob(void) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EventID id() const
Definition: EventBase.h:60
#define begin
Definition: vmac.h:32
HLT enums.
void beginJob(void) override
ESRecHitsMerger(const edm::ParameterSet &pset)
def move(src, dest)
Definition: eostools.py:510