CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HitReCalibrator.cc
Go to the documentation of this file.
12 
13 using namespace edm;
14 using namespace std;
15 using namespace reco;
16 
17 namespace cms {
18 
19  HitReCalibrator::HitReCalibrator(const edm::ParameterSet& iConfig) {
20  tok_hbhe_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"));
21  tok_ho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"));
22  tok_hf_ = consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"));
23  allowMissingInputs_ = true;
24  //register your products
25 
26  produces<HBHERecHitCollection>("DiJetsHBHEReRecHitCollection");
27  produces<HORecHitCollection>("DiJetsHOReRecHitCollection");
28  produces<HFRecHitCollection>("DiJetsHFReRecHitCollection");
29  }
31 
32  HitReCalibrator::~HitReCalibrator() {}
33 
34  // ------------ method called to produce the data ------------
35  void HitReCalibrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
36  auto miniDiJetsHBHERecHitCollection = std::make_unique<HBHERecHitCollection>();
37  auto miniDiJetsHORecHitCollection = std::make_unique<HORecHitCollection>();
38  auto miniDiJetsHFRecHitCollection = std::make_unique<HFRecHitCollection>();
39 
40  edm::ESHandle<HcalRespCorrs> recalibCorrs;
41  iSetup.get<HcalRespCorrsRcd>().get("recalibrate", recalibCorrs);
42  const HcalRespCorrs* jetRecalib = recalibCorrs.product();
43 
44  try {
46  iEvent.getByToken(tok_hbhe_, hbhe);
47  const HBHERecHitCollection Hithbhe = *(hbhe.product());
48  for (HBHERecHitCollection::const_iterator hbheItr = Hithbhe.begin(); hbheItr != Hithbhe.end(); hbheItr++) {
49  DetId id = hbheItr->detid();
50  float recal;
51  if (jetRecalib->exists(id))
52  recal = jetRecalib->getValues(id)->getValue();
53  else
54  recal = 1.;
55  float energy = hbheItr->energy();
56  float time = hbheItr->time();
57  HBHERecHit* hbhehit = new HBHERecHit(id, recal * energy, time);
58  miniDiJetsHBHERecHitCollection->push_back(*hbhehit);
59  }
60  } catch (cms::Exception& e) { // can't find it!
61  if (!allowMissingInputs_) {
62  cout << "No HBHE collection " << endl;
63  throw e;
64  }
65  }
66 
67  try {
69  iEvent.getByToken(tok_ho_, ho);
70  const HORecHitCollection Hitho = *(ho.product());
71  for (HORecHitCollection::const_iterator hoItr = Hitho.begin(); hoItr != Hitho.end(); hoItr++) {
72  DetId id = hoItr->detid();
73  float recal;
74  if (jetRecalib->exists(id))
75  recal = jetRecalib->getValues(id)->getValue();
76  else
77  recal = 1.;
78  float energy = hoItr->energy();
79  float time = hoItr->time();
80  HORecHit* hohit = new HORecHit(id, recal * energy, time);
81  miniDiJetsHORecHitCollection->push_back(*hohit);
82  }
83  } catch (cms::Exception& e) { // can't find it!
84  if (!allowMissingInputs_) {
85  cout << " No HO collection " << endl;
86  throw e;
87  }
88  }
89 
90  try {
92  iEvent.getByToken(tok_hf_, hf);
93  const HFRecHitCollection Hithf = *(hf.product());
94  for (HFRecHitCollection::const_iterator hfItr = Hithf.begin(); hfItr != Hithf.end(); hfItr++) {
95  DetId id = hfItr->detid();
96  float recal;
97  if (jetRecalib->exists(id))
98  recal = jetRecalib->getValues(id)->getValue();
99  else
100  recal = 1.;
101  float energy = hfItr->energy();
102  float time = hfItr->time();
103  HFRecHit* hfhit = new HFRecHit(id, recal * energy, time);
104  miniDiJetsHFRecHitCollection->push_back(*hfhit);
105  }
106  } catch (cms::Exception& e) { // can't find it!
107  if (!allowMissingInputs_)
108  throw e;
109  }
110 
111  //Put selected information in the event
112 
113  iEvent.put(std::move(miniDiJetsHBHERecHitCollection), "DiJetsHBHEReRecHitCollection");
114 
115  iEvent.put(std::move(miniDiJetsHORecHitCollection), "DiJetsHOReRecHitCollection");
116 
117  iEvent.put(std::move(miniDiJetsHFRecHitCollection), "DiJetsHFReRecHitCollection");
118  }
119 } // namespace cms
120 
122 
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
CaloJetCollection.h
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
HcalRespCorrsRcd.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
HORecHit
Definition: HORecHit.h:11
edm
HLT enums.
Definition: AlignableModifier.h:19
HBHERecHit
Definition: HBHERecHit.h:13
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::SortedCollection
Definition: SortedCollection.h:49
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
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
MakerMacros.h
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
HFRecHit
Definition: HFRecHit.h:11
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
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
edm::ESHandle
Definition: DTSurvey.h:22
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HcalCondObjectContainer::exists
bool exists(DetId fId) const
Definition: HcalCondObjectContainer.h:223
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
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:671
iEvent
int iEvent
Definition: GenABIO.cc:224
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
CaloTowerDetId.h
edm::EventSetup
Definition: EventSetup.h:57
HcalRespCorrs.h
HcalRespCorrsRcd
Definition: HcalRespCorrsRcd.h:27
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
cms::HitReCalibrator
Definition: HitReCalibrator.h:37
cms::Exception
Definition: Exception.h:70
ntuplemaker.time
time
Definition: ntuplemaker.py:310
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