CMS 3D CMS Logo

CaloRecHitsBeamHaloCleaned.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoMET/METProducers
4 // Class: CaloRecHitsBeamHaloCleaned
5 //
13 //
14 // Original Author: Thomas Laurent
15 // Created: Tue, 09 Feb 2016 13:09:37 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
31 
34 #include <vector>
35 #include <iostream>
45 
46 using namespace reco;
47 
49 public:
51  ~CaloRecHitsBeamHaloCleaned() override;
52 
53  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
54 
55 private:
56  void produce(edm::Event&, const edm::EventSetup&) override;
57 
62 
63  //Input tags
68 
69  bool ishlt;
70 };
71 
72 //
73 // constructors and destructor
74 //
76  ishlt = iConfig.getParameter<bool>("IsHLT");
77 
78  produces<EcalRecHitCollection>("EcalRecHitsEB");
79  produces<EcalRecHitCollection>("EcalRecHitsEE");
80  produces<HBHERecHitCollection>();
81 
82  it_EBRecHits = iConfig.getParameter<edm::InputTag>("EBRecHitsLabel");
83  it_EERecHits = iConfig.getParameter<edm::InputTag>("EERecHitsLabel");
84  it_HBHERecHits = iConfig.getParameter<edm::InputTag>("HBHERecHitsLabel");
85  it_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
86 
87  ecalebhits_token = consumes<EcalRecHitCollection>(it_EBRecHits);
88  ecaleehits_token = consumes<EcalRecHitCollection>(it_EERecHits);
89  hbhehits_token = consumes<HBHERecHitCollection>(it_HBHERecHits);
90 
91  globalhalo_token = consumes<GlobalHaloData>(it_GlobalHaloData);
92 }
93 
95  // do anything here that needs to be done at destruction time
96  // (e.g. close files, deallocate resources etc.)
97 }
98 
99 //
100 // member functions
101 //
102 
103 // ------------ method called to produce the data ------------
105  using namespace edm;
106  using namespace reco;
107  using namespace std;
108 
109  Handle<EcalRecHitCollection> ebrhitsuncleaned;
110  iEvent.getByToken(ecalebhits_token, ebrhitsuncleaned);
111 
112  Handle<EcalRecHitCollection> eerhitsuncleaned;
113  iEvent.getByToken(ecaleehits_token, eerhitsuncleaned);
114 
115  Handle<HBHERecHitCollection> hbherhitsuncleaned;
116  iEvent.getByToken(hbhehits_token, hbherhitsuncleaned);
117 
118  // Get GlobalHaloData
119  edm::Handle<reco::GlobalHaloData> TheGlobalHaloData;
120  iEvent.getByToken(globalhalo_token, TheGlobalHaloData);
121 
122  const GlobalHaloData TheSummaryHalo = (*TheGlobalHaloData);
123 
124  //Cleaning of the various rechits collections:
125 
126  // EcalRecHit EB
127  auto ebrhitscleaned = std::make_unique<EcalRecHitCollection>();
128  for (unsigned int i = 0; i < ebrhitsuncleaned->size(); i++) {
129  const EcalRecHit& rhit = (*ebrhitsuncleaned)[i];
130  bool isclean(true);
131  const edm::RefVector<EcalRecHitCollection>& refbeamhalorechits = TheSummaryHalo.GetEBRechits();
132  for (unsigned int j = 0; j < refbeamhalorechits.size(); j++) {
133  const EcalRecHit& rhitbeamhalo = *(refbeamhalorechits)[j];
134  if (rhit.detid() == rhitbeamhalo.detid()) {
135  isclean = false;
136  break;
137  }
138  }
139  if (isclean)
140  ebrhitscleaned->push_back(rhit);
141  }
142 
143  // EcalRecHit EE
144  auto eerhitscleaned = std::make_unique<EcalRecHitCollection>();
145  for (unsigned int i = 0; i < eerhitsuncleaned->size(); i++) {
146  const EcalRecHit& rhit = (*eerhitsuncleaned)[i];
147  bool isclean(true);
148  const edm::RefVector<EcalRecHitCollection>& refbeamhalorechits = TheSummaryHalo.GetEERechits();
149  for (unsigned int j = 0; j < refbeamhalorechits.size(); j++) {
150  const EcalRecHit& rhitbeamhalo = *(refbeamhalorechits)[j];
151  if (rhit.detid() == rhitbeamhalo.detid()) {
152  isclean = false;
153  break;
154  }
155  }
156  if (isclean)
157  eerhitscleaned->push_back(rhit);
158  }
159 
160  // HBHERecHit
161  auto hbherhitscleaned = std::make_unique<HBHERecHitCollection>();
162  for (unsigned int i = 0; i < hbherhitsuncleaned->size(); i++) {
163  const HBHERecHit& rhit = (*hbherhitsuncleaned)[i];
164  bool isclean(true);
165  const edm::RefVector<HBHERecHitCollection>& refbeamhalorechits = TheSummaryHalo.GetHBHERechits();
166  for (unsigned int j = 0; j < refbeamhalorechits.size(); j++) {
167  const HBHERecHit& rhitbeamhalo = *(refbeamhalorechits)[j];
168  if (rhit.detid() == rhitbeamhalo.detid()) {
169  isclean = false;
170  break;
171  }
172  }
173  if (isclean)
174  hbherhitscleaned->push_back(rhit);
175  }
176 
177  iEvent.put(std::move(ebrhitscleaned), "EcalRecHitsEB");
178  iEvent.put(std::move(eerhitscleaned), "EcalRecHitsEE");
179  iEvent.put(std::move(hbherhitscleaned));
180 }
181 
182 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
185  desc.add<edm::InputTag>("EBRecHitsLabel", edm::InputTag("EcalRecHit", "EcalRecHitsEB"));
186  desc.add<edm::InputTag>("EERecHitsLabel", edm::InputTag("EcalRecHit", "EcalRecHitsEE"));
187  desc.add<edm::InputTag>("HBHERecHitsLabel", edm::InputTag("hbhereco"));
188  desc.add<edm::InputTag>("GlobalHaloDataLabel", edm::InputTag("GlobalHaloData"));
189  desc.add<bool>("IsHLT", false);
190  descriptions.add("caloRecHitsBeamHaloCleaned", desc);
191 }
192 
193 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
size_type size() const
CaloRecHitsBeamHaloCleaned(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
edm::RefVector< HBHERecHitCollection > & GetHBHERechits()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< GlobalHaloData > globalhalo_token
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
edm::EDGetTokenT< EcalRecHitCollection > ecalebhits_token
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void produce(edm::Event &, const edm::EventSetup &) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const DetId & detid() const
Definition: EcalRecHit.h:72
fixed size matrix
HLT enums.
edm::RefVector< EcalRecHitCollection > & GetEBRechits()
edm::EDGetTokenT< HBHERecHitCollection > hbhehits_token
edm::RefVector< EcalRecHitCollection > & GetEERechits()
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< EcalRecHitCollection > ecaleehits_token