CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESRecHitsMerger.cc
Go to the documentation of this file.
1 
2 //#include <FWCore/Framework/interface/Handle.h>
6 
9 
11 
12 
13 using namespace edm;
14 using namespace std;
15 
16 
18 
19  debug_ = pset.getUntrackedParameter<bool>("debug");
20 
21  EgammaSourceES_ = pset.getUntrackedParameter<edm::InputTag>("EgammaSource_ES",edm::InputTag("dummyEgamma"));
22  MuonsSourceES_ = pset.getUntrackedParameter<edm::InputTag>("MuonsSource_ES",edm::InputTag("dummyMuons"));
23  TausSourceES_ = pset.getUntrackedParameter<edm::InputTag>("TausSource_ES",edm::InputTag("dummyTaus"));
24  JetsSourceES_ = pset.getUntrackedParameter<edm::InputTag>("JetsSource_ES",edm::InputTag("dummyJets"));
25  RestSourceES_ = pset.getUntrackedParameter<edm::InputTag>("RestSource_ES",edm::InputTag("dummyRest"));
26  Pi0SourceES_ = pset.getUntrackedParameter<edm::InputTag>("Pi0Source_ES",edm::InputTag("dummyPi0"));
27  EtaSourceES_ = pset.getUntrackedParameter<edm::InputTag>("EtaSource_ES",edm::InputTag("dummyEta"));
28 
29 
30  OutputLabelES_ = pset.getUntrackedParameter<std::string>("OutputLabel_ES");
31 
32  InputRecHitES_ = pset.getUntrackedParameter<std::string>("EcalRecHitCollectionES");
33 
34  produces<EcalRecHitCollection>(OutputLabelES_);
35 
36 }
37 
38 
39 
41 }
42 
43 
45 }
46 
48 }
49 
51 
52  if (debug_) std::cout << " ESRecHitMerger : Run " << e.id().run() << " Event " << e.id().event() << std::endl;
53 
54 
55  std::vector< edm::Handle<ESRecHitCollection> > EcalRecHits_done;
56  e.getManyByType(EcalRecHits_done);
57 
58  std::auto_ptr<EcalRecHitCollection> ESMergedRecHits(new EcalRecHitCollection);
59 
60 
61  unsigned int nColl = EcalRecHits_done.size();
62 
63  int nES = 0;
64 
65 
66  for (unsigned int i=0; i < nColl; i++) {
67 
68  std::string instance = EcalRecHits_done[i].provenance()->productInstanceName();
69  std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
70 
71 
72  if (debug_){
73  std::cout<<"ESrechit to be merged from "<<module_label.c_str()<<" "<<instance.c_str()<<std::endl;
74  }
75 
76  if ( module_label != EgammaSourceES_.label() &&
77  module_label != MuonsSourceES_.label() &&
78  module_label != JetsSourceES_.label() &&
79  module_label != TausSourceES_.label() &&
80  module_label != RestSourceES_.label() &&
81  module_label != Pi0SourceES_.label() &&
82  module_label != EtaSourceES_.label()) continue;
83 
84  if (instance == InputRecHitES_) {
85  nES += EcalRecHits_done[i] -> size();
86  }
87 
88  }
89 
90 
91  ESMergedRecHits -> reserve(nES);
92 
93  if (debug_) std::cout << " Number of ES Rechits to merge = " << nES << std::endl;
94 
95  for (unsigned int i=0; i < nColl; i++) {
96  std::string instance = EcalRecHits_done[i].provenance()->productInstanceName();
97 
98  std::string module_label = EcalRecHits_done[i].provenance()->moduleLabel();
99  if ( module_label != EgammaSourceES_.label() &&
100  module_label != MuonsSourceES_.label() &&
101  module_label != JetsSourceES_.label() &&
102  module_label != TausSourceES_.label() &&
103  module_label != RestSourceES_.label() &&
104  module_label != Pi0SourceES_.label() &&
105  module_label != EtaSourceES_.label() ) continue;
106 
107  if (instance == InputRecHitES_) {
108  for (EcalRecHitCollection::const_iterator it=EcalRecHits_done[i]->begin(); it !=EcalRecHits_done[i]->end(); it++) {
109  ESMergedRecHits -> push_back(*it);
110  }
111  }
112 
113  }
114 
115 
116  // std::cout << " avant le put " << std::endl;
117  e.put(ESMergedRecHits,OutputLabelES_);
118  // std::cout << " apres le put " << std::endl;
119 
120 }
121 
RunNumber_t run() const
Definition: EventID.h:42
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:408
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
static PFTauRenderPlugin instance
void beginJob(void)
std::vector< EcalRecHit >::const_iterator const_iterator
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
virtual ~ESRecHitsMerger()
void produce(edm::Event &e, const edm::EventSetup &c)
edm::EventID id() const
Definition: EventBase.h:56
#define begin
Definition: vmac.h:31
tuple cout
Definition: gather_cfg.py:121
ESRecHitsMerger(const edm::ParameterSet &pset)
tuple size
Write out results.