CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HitReCalibrator.cc
Go to the documentation of this file.
13 
14 
15 using namespace edm;
16 using namespace std;
17 using namespace reco;
18 
19 namespace cms
20 {
21 
22 HitReCalibrator::HitReCalibrator(const edm::ParameterSet& iConfig)
23 {
24  hbheInput_ = iConfig.getParameter<edm::InputTag>("hbheInput");
25  hoInput_ = iConfig.getParameter<edm::InputTag>("hoInput");
26  hfInput_ = iConfig.getParameter<edm::InputTag>("hfInput");
27  allowMissingInputs_ = true;
28 //register your products
29 
30  produces<HBHERecHitCollection>("DiJetsHBHEReRecHitCollection");
31  produces<HORecHitCollection>("DiJetsHOReRecHitCollection");
32  produces<HFRecHitCollection>("DiJetsHFReRecHitCollection");
33 
34 }
36 {
37 }
38 
39 HitReCalibrator::~HitReCalibrator()
40 {
41 
42 }
43 
44 
45 // ------------ method called to produce the data ------------
46 void
47 HitReCalibrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
48 {
49 
50  std::auto_ptr<HBHERecHitCollection> miniDiJetsHBHERecHitCollection(new HBHERecHitCollection);
51  std::auto_ptr<HORecHitCollection> miniDiJetsHORecHitCollection(new HORecHitCollection);
52  std::auto_ptr<HFRecHitCollection> miniDiJetsHFRecHitCollection(new HFRecHitCollection);
53 
54 
55  edm::ESHandle <HcalRespCorrs> recalibCorrs;
56  iSetup.get<HcalRespCorrsRcd>().get("recalibrate",recalibCorrs);
57  const HcalRespCorrs* jetRecalib = recalibCorrs.product();
58 
59 
60  try {
62  iEvent.getByLabel(hbheInput_,hbhe);
63  const HBHERecHitCollection Hithbhe = *(hbhe.product());
64  for(HBHERecHitCollection::const_iterator hbheItr=Hithbhe.begin(); hbheItr!=Hithbhe.end(); hbheItr++)
65  {
66  DetId id = hbheItr->detid();
67  float recal;
68  if (jetRecalib->exists(id))
69  recal = jetRecalib->getValues(id)->getValue();
70  else recal = 1.;
71  float energy = hbheItr->energy();
72  float time = hbheItr->time();
73  HBHERecHit* hbhehit = new HBHERecHit(id,recal*energy,time);
74  miniDiJetsHBHERecHitCollection->push_back(*hbhehit);
75  }
76  } catch (cms::Exception& e) { // can't find it!
77  if (!allowMissingInputs_) {cout<<"No HBHE collection "<<endl; throw e;}
78  }
79 
80  try{
82  iEvent.getByLabel(hoInput_,ho);
83  const HORecHitCollection Hitho = *(ho.product());
84  for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++)
85  {
86  DetId id = hoItr->detid();
87  float recal;
88  if (jetRecalib->exists(id))
89  recal = jetRecalib->getValues(id)->getValue();
90  else recal = 1.;
91  float energy = hoItr->energy();
92  float time = hoItr->time();
93  HORecHit* hohit = new HORecHit(id,recal*energy,time);
94  miniDiJetsHORecHitCollection->push_back(*hohit);
95  }
96  } catch (cms::Exception& e) { // can't find it!
97  if (!allowMissingInputs_) {cout<<" No HO collection "<<endl; throw e;}
98  }
99 
100  try {
102  iEvent.getByLabel(hfInput_,hf);
103  const HFRecHitCollection Hithf = *(hf.product());
104  for(HFRecHitCollection::const_iterator hfItr=Hithf.begin(); hfItr!=Hithf.end(); hfItr++)
105  {
106  DetId id = hfItr->detid();
107  float recal;
108  if (jetRecalib->exists(id))
109  recal = jetRecalib->getValues(id)->getValue();
110  else recal = 1.;
111  float energy = hfItr->energy();
112  float time = hfItr->time();
113  HFRecHit* hfhit = new HFRecHit(id,recal*energy,time);
114  miniDiJetsHFRecHitCollection->push_back(*hfhit);
115  }
116  } catch (cms::Exception& e) { // can't find it!
117  if (!allowMissingInputs_) throw e;
118  }
119 
120  //Put selected information in the event
121 
122  iEvent.put( miniDiJetsHBHERecHitCollection, "DiJetsHBHEReRecHitCollection");
123 
124  iEvent.put( miniDiJetsHORecHitCollection, "DiJetsHOReRecHitCollection");
125 
126  iEvent.put( miniDiJetsHFRecHitCollection, "DiJetsHFReRecHitCollection");
127 
128 }
129 }
T getParameter(std::string const &) const
std::vector< T >::const_iterator const_iterator
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
const bool exists(DetId fId) const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
const_iterator end() const
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
float getValue() const
Definition: HcalRespCorr.h:18
tuple cout
Definition: gather_cfg.py:121
const Item * getValues(DetId fId) const
const_iterator begin() const