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  upgradeHBHE_(false),
26  upgradeHF_(false),
27  paramTS(0),
28  theTopology(0)
29 {
30 
31  std::string subd=conf.getParameter<std::string>("Subdetector");
32  if(!strcasecmp(subd.c_str(),"upgradeHBHE")) {
33  upgradeHBHE_ = true;
34  produces<HBHERecHitCollection>();
35  }
36  else if (!strcasecmp(subd.c_str(),"upgradeHF")) {
37  upgradeHF_ = true;
38  produces<HFRecHitCollection>();
39  }
40  else if (!strcasecmp(subd.c_str(),"HO")) {
42  produces<HORecHitCollection>();
43  }
44  else if (!strcasecmp(subd.c_str(),"HBHE")) {
45  if( !upgradeHBHE_) {
47  produces<HBHERecHitCollection>();
48  }
49  }
50  else if (!strcasecmp(subd.c_str(),"HF")) {
51  if( !upgradeHF_) {
53  produces<HFRecHitCollection>();
54  }
55  }
56  else {
57  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
58  }
59 
60 }
61 
63  delete paramTS;
64  delete theTopology;
65 }
66 
68  if(tsFromDB_) {
70  es.get<HcalRecoParamsRcd>().get(p);
71  paramTS = new HcalRecoParams(*p.product());
72 
74  es.get<IdealGeometryRecord>().get(htopo);
75  theTopology=new HcalTopology(*htopo);
77 
78  }
79  reco_.beginRun(es);
80 }
81 
83  if(tsFromDB_ && paramTS) {
84  delete paramTS;
85  paramTS = 0;
86  reco_.endRun();
87  }
88 }
89 
90 
91 template<class DIGICOLL, class RECHITCOLL>
93 {
94  // get conditions
96  eventSetup.get<HcalDbRecord>().get(conditions);
97 
99  e.getByLabel(inputLabel_,digi);
100 
101  // create empty output
102  std::auto_ptr<RECHITCOLL> rec(new RECHITCOLL);
103  rec->reserve(digi->size());
104  // run the algorithm
105  int first = firstSample_;
106  int toadd = samplesToAdd_;
107  typename DIGICOLL::const_iterator i;
108  for (i=digi->begin(); i!=digi->end(); i++) {
109  HcalDetId cell = i->id();
110  DetId detcell=(DetId)cell;
111  // rof 27.03.09: drop ZS marked and passed digis:
113  if (i->zsMarkAndPass()) continue;
114 
115  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
116  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
117  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
118  HcalCoderDb coder (*channelCoder, *shape);
119 
120  //>>> firstSample & samplesToAdd
121  if(tsFromDB_) {
122  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
123  first = param_ts->firstSample();
124  toadd = param_ts->samplesToAdd();
125  }
126  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
127  }
128  // return result
129  e.put(rec);
130 }
131 
132 
134 {
135  // get conditions
136  edm::ESHandle<HcalDbService> conditions;
137  eventSetup.get<HcalDbRecord>().get(conditions);
138 
139  if(upgradeHBHE_){
140 
142  e.getByLabel(inputLabel_, digi);
143 
144  // create empty output
145  std::auto_ptr<HBHERecHitCollection> rec(new HBHERecHitCollection);
146  rec->reserve(digi->size());
147 
148  // run the algorithm
149  int first = firstSample_;
150  int toadd = samplesToAdd_;
152  for (i=digi->begin(); i!=digi->end(); i++) {
153  HcalDetId cell = i->id();
154  DetId detcell=(DetId)cell;
155  // rof 27.03.09: drop ZS marked and passed digis:
157  if (i->zsMarkAndPass()) continue;
158 
159  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
160  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
161  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
162  HcalCoderDb coder (*channelCoder, *shape);
163 
164  //>>> firstSample & samplesToAdd
165  if(tsFromDB_) {
166  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
167  first = param_ts->firstSample();
168  toadd = param_ts->samplesToAdd();
169  }
170  rec->push_back(reco_.reconstructHBHEUpgrade(*i,first,toadd,coder,calibrations));
171 
172  }
173 
174  e.put(rec); // put results
175  }// End of upgradeHBHE
176 
177  if(upgradeHF_){
178 
180  e.getByLabel(inputLabel_, digi);
181 
182  // create empty output
183  std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
184  rec->reserve(digi->size());
185 
186  // run the algorithm
187  int first = firstSample_;
188  int toadd = samplesToAdd_;
190  for (i=digi->begin(); i!=digi->end(); i++) {
191  HcalDetId cell = i->id();
192  DetId detcell=(DetId)cell;
193  // rof 27.03.09: drop ZS marked and passed digis:
195  if (i->zsMarkAndPass()) continue;
196 
197  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
198  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
199  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
200  HcalCoderDb coder (*channelCoder, *shape);
201 
202  //>>> firstSample & samplesToAdd
203  if(tsFromDB_) {
204  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
205  first = param_ts->firstSample();
206  toadd = param_ts->samplesToAdd();
207  }
208  rec->push_back(reco_.reconstructHFUpgrade(*i,first,toadd,coder,calibrations));
209 
210  }
211  e.put(rec); // put results
212  }// End of upgradeHF
213 
214 }
215 
216 
217 
219 {
220  // HACK related to HB- corrections
221  if(e.isRealData()) reco_.setForData();
222 
223  // What to produce, better to avoid the same subdet Upgrade and regular
224  // rechits "clashes"
225  if(upgradeHBHE_ || upgradeHF_) {
226  processUpgrade(e, eventSetup);
227  } else if (det_==DetId::Hcal) {
229  process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup);
230  } else if (subdet_==HcalForward && !upgradeHF_) {
231  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup);
232  } else if (subdet_==HcalOuter) {
233  process<HODigiCollection, HORecHitCollection>(e, eventSetup);
234  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
235  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup);
236  }
237  }
238 }
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)
void beginRun(edm::EventSetup const &es)
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) overridefinal
std::vector< T >::const_iterator const_iterator
void setTopo(const HcalTopology *topo) const
const Item * getValues(DetId fId, bool throwOnFail=true) const
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:94
HFRecHit reconstructHFUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
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:361
void process(edm::Event &e, const edm::EventSetup &c)
virtual void produce(edm::Event &e, const edm::EventSetup &c) overridefinal
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
HBHERecHit reconstructHBHEUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void processUpgrade(edm::Event &e, const edm::EventSetup &c)
tuple cout
Definition: gather_cfg.py:121
Definition: Run.h:36
virtual void endRun(edm::Run const &r, edm::EventSetup const &es) overridefinal