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
CaloRecHitsBeamHaloCleaned::it_GlobalHaloData
edm::InputTag it_GlobalHaloData
Definition: CaloRecHitsBeamHaloCleaned.cc:67
ConfigurationDescriptions.h
EcalRecHit
Definition: EcalRecHit.h:15
mps_fire.i
i
Definition: mps_fire.py:428
CaloRecHitsBeamHaloCleaned::globalhalo_token
edm::EDGetTokenT< GlobalHaloData > globalhalo_token
Definition: CaloRecHitsBeamHaloCleaned.cc:61
EcalRecHit::detid
const DetId & detid() const
Definition: EcalRecHit.h:72
reco::GlobalHaloData::GetHBHERechits
edm::RefVector< HBHERecHitCollection > & GetHBHERechits()
Definition: GlobalHaloData.h:51
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HBHERecHit
Definition: HBHERecHit.h:13
EBDetId.h
EEDetId.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
CaloRecHitsBeamHaloCleaned::~CaloRecHitsBeamHaloCleaned
~CaloRecHitsBeamHaloCleaned() override
Definition: CaloRecHitsBeamHaloCleaned.cc:94
EDProducer.h
CaloRecHitsBeamHaloCleaned::it_HBHERecHits
edm::InputTag it_HBHERecHits
Definition: CaloRecHitsBeamHaloCleaned.cc:66
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
reco::GlobalHaloData::GetEBRechits
edm::RefVector< EcalRecHitCollection > & GetEBRechits()
Definition: GlobalHaloData.h:45
edm::RefVector
Definition: EDProductfwd.h:27
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
CaloRecHit::detid
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
edm::Handle
Definition: AssociativeIterator.h:50
GlobalHaloData.h
MakerMacros.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CaloRecHitsBeamHaloCleaned::ecalebhits_token
edm::EDGetTokenT< EcalRecHitCollection > ecalebhits_token
Definition: CaloRecHitsBeamHaloCleaned.cc:58
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterSetDescription.h
CaloGeometryRecord.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
CaloRecHitsBeamHaloCleaned::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: CaloRecHitsBeamHaloCleaned.cc:183
reco::GlobalHaloData::GetEERechits
edm::RefVector< EcalRecHitCollection > & GetEERechits()
Definition: GlobalHaloData.h:48
edm::ParameterSet
Definition: ParameterSet.h:47
CaloRecHitsBeamHaloCleaned
Definition: CaloRecHitsBeamHaloCleaned.cc:48
Event.h
reco::GlobalHaloData
Definition: GlobalHaloData.h:17
iEvent
int iEvent
Definition: GenABIO.cc:224
CaloRecHitsBeamHaloCleaned::ecaleehits_token
edm::EDGetTokenT< EcalRecHitCollection > ecaleehits_token
Definition: CaloRecHitsBeamHaloCleaned.cc:59
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:58
CaloRecHitsBeamHaloCleaned::it_EERecHits
edm::InputTag it_EERecHits
Definition: CaloRecHitsBeamHaloCleaned.cc:65
CaloRecHitsBeamHaloCleaned::CaloRecHitsBeamHaloCleaned
CaloRecHitsBeamHaloCleaned(const edm::ParameterSet &)
Definition: CaloRecHitsBeamHaloCleaned.cc:75
CaloRecHitsBeamHaloCleaned::hbhehits_token
edm::EDGetTokenT< HBHERecHitCollection > hbhehits_token
Definition: CaloRecHitsBeamHaloCleaned.cc:60
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
CaloGeometry.h
Point3D.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
GlobalHaloAlgo.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Event
Definition: Event.h:73
edm::RefVector::size
size_type size() const
Size of the RefVector.
Definition: RefVector.h:102
StreamID.h
CaloRecHitsBeamHaloCleaned::it_EBRecHits
edm::InputTag it_EBRecHits
Definition: CaloRecHitsBeamHaloCleaned.cc:64
edm::InputTag
Definition: InputTag.h:15
CaloRecHitsBeamHaloCleaned::ishlt
bool ishlt
Definition: CaloRecHitsBeamHaloCleaned.cc:69
CaloRecHitsBeamHaloCleaned::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CaloRecHitsBeamHaloCleaned.cc:104