CMS 3D CMS Logo

HitReCalibrator.cc
Go to the documentation of this file.
10 
11 namespace cms {
12 
14  tok_hbhe_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"));
15  tok_ho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"));
16  tok_hf_ = consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"));
17  allowMissingInputs_ = true;
18  tok_resp_ = esConsumes<HcalRespCorrs, HcalRespCorrsRcd>();
19 
20  //register your products
21 
22  produces<HBHERecHitCollection>("DiJetsHBHEReRecHitCollection");
23  produces<HORecHitCollection>("DiJetsHOReRecHitCollection");
24  produces<HFRecHitCollection>("DiJetsHFReRecHitCollection");
25  }
27 
29 
30  // ------------ method called to produce the data ------------
32  auto miniDiJetsHBHERecHitCollection = std::make_unique<HBHERecHitCollection>();
33  auto miniDiJetsHORecHitCollection = std::make_unique<HORecHitCollection>();
34  auto miniDiJetsHFRecHitCollection = std::make_unique<HFRecHitCollection>();
35 
36  const HcalRespCorrs* jetRecalib = &iSetup.getData(tok_resp_);
37 
38  try {
40  iEvent.getByToken(tok_hbhe_, hbhe);
41  const HBHERecHitCollection Hithbhe = *(hbhe.product());
42  for (HBHERecHitCollection::const_iterator hbheItr = Hithbhe.begin(); hbheItr != Hithbhe.end(); hbheItr++) {
43  DetId id = hbheItr->detid();
44  float recal;
45  if (jetRecalib->exists(id))
46  recal = jetRecalib->getValues(id)->getValue();
47  else
48  recal = 1.;
49  float energy = hbheItr->energy();
50  float time = hbheItr->time();
51  HBHERecHit* hbhehit = new HBHERecHit(id, recal * energy, time);
52  miniDiJetsHBHERecHitCollection->push_back(*hbhehit);
53  }
54  } catch (cms::Exception& e) { // can't find it!
55  if (!allowMissingInputs_) {
56  edm::LogError("HitCalib") << "No HBHE collection ";
57  throw e;
58  }
59  }
60 
61  try {
63  iEvent.getByToken(tok_ho_, ho);
64  const HORecHitCollection Hitho = *(ho.product());
65  for (HORecHitCollection::const_iterator hoItr = Hitho.begin(); hoItr != Hitho.end(); hoItr++) {
66  DetId id = hoItr->detid();
67  float recal;
68  if (jetRecalib->exists(id))
69  recal = jetRecalib->getValues(id)->getValue();
70  else
71  recal = 1.;
72  float energy = hoItr->energy();
73  float time = hoItr->time();
74  HORecHit* hohit = new HORecHit(id, recal * energy, time);
75  miniDiJetsHORecHitCollection->push_back(*hohit);
76  }
77  } catch (cms::Exception& e) { // can't find it!
78  if (!allowMissingInputs_) {
79  edm::LogError("HitCalib") << " No HO collection ";
80  throw e;
81  }
82  }
83 
84  try {
86  iEvent.getByToken(tok_hf_, hf);
87  const HFRecHitCollection Hithf = *(hf.product());
88  for (HFRecHitCollection::const_iterator hfItr = Hithf.begin(); hfItr != Hithf.end(); hfItr++) {
89  DetId id = hfItr->detid();
90  float recal;
91  if (jetRecalib->exists(id))
92  recal = jetRecalib->getValues(id)->getValue();
93  else
94  recal = 1.;
95  float energy = hfItr->energy();
96  float time = hfItr->time();
97  HFRecHit* hfhit = new HFRecHit(id, recal * energy, time);
98  miniDiJetsHFRecHitCollection->push_back(*hfhit);
99  }
100  } catch (cms::Exception& e) { // can't find it!
101  if (!allowMissingInputs_)
102  throw e;
103  }
104 
105  //Put selected information in the event
106 
107  iEvent.put(std::move(miniDiJetsHBHERecHitCollection), "DiJetsHBHEReRecHitCollection");
108 
109  iEvent.put(std::move(miniDiJetsHORecHitCollection), "DiJetsHOReRecHitCollection");
110 
111  iEvent.put(std::move(miniDiJetsHFRecHitCollection), "DiJetsHFReRecHitCollection");
112  }
113 } // namespace cms
114 
116 
cms::HitReCalibrator::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HitReCalibrator.cc:31
CaloJetCollection.h
HcalRespCorrs
Definition: HcalRespCorrs.h:17
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HitReCalibrator.h
MessageLogger.h
cms::HitReCalibrator::beginJob
void beginJob() override
Definition: HitReCalibrator.cc:26
HORecHit
Definition: HORecHit.h:11
HBHERecHit
Definition: HBHERecHit.h:13
protons_cff.time
time
Definition: protons_cff.py:35
edm::SortedCollection
Definition: SortedCollection.h:49
cms::HitReCalibrator::tok_hbhe_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: HitReCalibrator.h:50
cms::HitReCalibrator::tok_resp_
edm::ESGetToken< HcalRespCorrs, HcalRespCorrsRcd > tok_resp_
Definition: HitReCalibrator.h:54
TransientTrack.h
edm::Handle
Definition: AssociativeIterator.h:50
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
EcalRecHitCollections.h
DetId
Definition: DetId.h:17
cms::HitReCalibrator::HitReCalibrator
HitReCalibrator(const edm::ParameterSet &)
Definition: HitReCalibrator.cc:13
MakerMacros.h
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
HFRecHit
Definition: HFRecHit.h:11
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
TrackProducerBase.h
cms::HitReCalibrator::allowMissingInputs_
bool allowMissingInputs_
Definition: HitReCalibrator.h:48
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HcalCondObjectContainer::exists
bool exists(DetId fId) const
Definition: HcalCondObjectContainer.h:223
cms::HitReCalibrator::tok_hf_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: HitReCalibrator.h:52
HcalRespCorr::getValue
float getValue() const
Definition: HcalRespCorr.h:19
edm::ParameterSet
Definition: ParameterSet.h:47
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
iEvent
int iEvent
Definition: GenABIO.cc:224
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
CaloTowerDetId.h
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
cms::HitReCalibrator::~HitReCalibrator
~HitReCalibrator() override
Definition: HitReCalibrator.cc:28
cms::HitReCalibrator::tok_ho_
edm::EDGetTokenT< HORecHitCollection > tok_ho_
Definition: HitReCalibrator.h:51
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
cms::HitReCalibrator
Definition: HitReCalibrator.h:36
cms::Exception
Definition: Exception.h:70
edm::Event
Definition: Event.h:73
GlobalPoint.h
edm::InputTag
Definition: InputTag.h:15
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37