CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSimpleReconstructor.cc
Go to the documentation of this file.
13 
14 #include <iostream>
15 
17  reco_(conf.getParameter<bool>("correctForTimeslew"),
18  conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
19  det_(DetId::Hcal),
20  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
21  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
22  firstSample_(conf.getParameter<int>("firstSample")),
23  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
24  tsFromDB_(conf.getParameter<bool>("tsFromDB"))
25 {
26 
27  std::string subd=conf.getParameter<std::string>("Subdetector");
28  if (!strcasecmp(subd.c_str(),"HBHE")) {
30  produces<HBHERecHitCollection>();
31  } else if (!strcasecmp(subd.c_str(),"HO")) {
33  produces<HORecHitCollection>();
34  } else if (!strcasecmp(subd.c_str(),"HF")) {
36  produces<HFRecHitCollection>();
37  } else {
38  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
39  }
40 
41 }
42 
44 
46  if(tsFromDB_) {
48  es.get<HcalRecoParamsRcd>().get(p);
49  paramTS = new HcalRecoParams(*p.product());
50  }
51  reco_.beginRun(es);
52 }
53 
55  if(tsFromDB_ && paramTS) {
56  delete paramTS;
57  paramTS = 0;
58  reco_.endRun();
59  }
60 }
61 
62 
63 template<class DIGICOLL, class RECHITCOLL>
65 {
66  // get conditions
68  eventSetup.get<HcalDbRecord>().get(conditions);
69  const HcalQIEShape* shape = conditions->getHcalShape (); // this one is generic
70 
71  // HACK related to HB- corrections
72  if(e.isRealData()) reco_.setForData();
73 
75 
76  e.getByLabel(inputLabel_,digi);
77 
78  // create empty output
79  std::auto_ptr<RECHITCOLL> rec(new RECHITCOLL);
80  rec->reserve(digi->size());
81  // run the algorithm
82  int first = firstSample_;
83  int toadd = samplesToAdd_;
84  typename DIGICOLL::const_iterator i;
85  for (i=digi->begin(); i!=digi->end(); i++) {
86  HcalDetId cell = i->id();
87  DetId detcell=(DetId)cell;
88  // rof 27.03.09: drop ZS marked and passed digis:
90  if (i->zsMarkAndPass()) continue;
91 
92  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
93  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
94  HcalCoderDb coder (*channelCoder, *shape);
95 
96  //>>> firstSample & samplesToAdd
97  if(tsFromDB_) {
98  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
99  first = param_ts->firstSample();
100  toadd = param_ts->samplesToAdd();
101  }
102  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
103 
104  }
105  // return result
106  e.put(rec);
107 }
108 
109 
111 {
112  // HACK related to HB- corrections
113  if(e.isRealData()) reco_.setForData();
114 
115 
116  if (det_==DetId::Hcal) {
118  process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup);
119  } else if (subdet_==HcalForward) {
120  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup);
121  } else if (subdet_==HcalOuter) {
122  process<HODigiCollection, HORecHitCollection>(e, eventSetup);
123  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
124  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup);
125  }
126  }
127 }
unsigned int firstSample() const
Definition: HcalRecoParam.h:30
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
HBHERecHit reconstruct(const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
HcalSimpleReconstructor(const edm::ParameterSet &ps)
virtual void endRun(edm::Run &r, edm::EventSetup const &es)
void beginRun(edm::EventSetup const &es)
bool isRealData() const
Definition: EventBase.h:60
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
HcalOtherSubdetector subdetOther_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:31
bool first
Definition: L1TdeRCT.cc:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void process(edm::Event &e, const edm::EventSetup &c)
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:20
virtual void beginRun(edm::Run &r, edm::EventSetup const &es)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
tuple cout
Definition: gather_cfg.py:121
const Item * getValues(DetId fId) const
virtual void produce(edm::Event &e, const edm::EventSetup &c)
Definition: Run.h:33