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