test
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  HFQIE10_(false),
28  paramTS(0),
29  theTopology(0)
30 {
31  // Intitialize "method 3"
33  conf.getParameter<int> ("pedestalSubtractionType"),
34  conf.getParameter<double> ("pedestalUpperLimit"),
35  conf.getParameter<int> ("timeSlewParsType"),
36  conf.getParameter<std::vector<double> >("timeSlewPars"),
37  conf.getParameter<double> ("respCorrM3")
38  );
39 
40  // register for data access
41  tok_hbheUp_ = consumes<HBHEUpgradeDigiCollection>(inputLabel_);
42  tok_hfUp_ = consumes<HFUpgradeDigiCollection>(inputLabel_);
43  tok_hfQIE10_ = consumes<QIE10DigiCollection>(inputLabel_);
44 
45  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_);
46  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
47  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
48  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
49 
50  std::string subd=conf.getParameter<std::string>("Subdetector");
51  if(!strcasecmp(subd.c_str(),"upgradeHBHE")) {
52  upgradeHBHE_ = true;
53  produces<HBHERecHitCollection>();
54  }
55  else if (!strcasecmp(subd.c_str(),"upgradeHF")) {
56  upgradeHF_ = true;
57  produces<HFRecHitCollection>();
58  }
59  else if (!strcasecmp(subd.c_str(),"HFQIE10")) {
60  HFQIE10_ = true;
61  produces<HFRecHitCollection>();
62  }
63  else if (!strcasecmp(subd.c_str(),"HO")) {
65  produces<HORecHitCollection>();
66  }
67  else if (!strcasecmp(subd.c_str(),"HBHE")) {
68  if( !upgradeHBHE_) {
70  produces<HBHERecHitCollection>();
71  }
72  }
73  else if (!strcasecmp(subd.c_str(),"HF")) {
74  if( !upgradeHF_) {
76  produces<HFRecHitCollection>();
77  }
78  }
79  else {
80  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
81  }
82 
83 }
84 
87  desc.setAllowAnything();
88  desc.add<int>("pedestalSubtractionType", 1);
89  desc.add<double>("pedestalUpperLimit", 2.7);
90  desc.add<int>("timeSlewParsType",3);
91  desc.add<std::vector<double>>("timeSlewPars", { 12.2999, -2.19142, 0, 12.2999, -2.19142, 0, 12.2999, -2.19142, 0 });
92  desc.add<double>("respCorrM3", 0.95);
93  descriptions.add("simpleHbhereco",desc);
94 }
95 
97  delete paramTS;
98  delete theTopology;
99 }
100 
102  if(tsFromDB_) {
104  es.get<HcalRecoParamsRcd>().get(p);
105  paramTS = new HcalRecoParams(*p.product());
106 
108  es.get<HcalRecNumberingRecord>().get(htopo);
109  theTopology=new HcalTopology(*htopo);
111 
112  }
113  reco_.beginRun(es);
114 }
115 
117  if(tsFromDB_ && paramTS) {
118  delete paramTS;
119  paramTS = 0;
120  reco_.endRun();
121  }
122 }
123 
124 
125 template<class DIGICOLL, class RECHITCOLL>
127 {
128  // get conditions
129  edm::ESHandle<HcalDbService> conditions;
130  eventSetup.get<HcalDbRecord>().get(conditions);
131 
133  e.getByToken(tok,digi);
134 
135  // create empty output
136  std::auto_ptr<RECHITCOLL> rec(new RECHITCOLL);
137  rec->reserve(digi->size());
138  // run the algorithm
139  int first = firstSample_;
140  int toadd = samplesToAdd_;
141  typename DIGICOLL::const_iterator i;
142  for (i=digi->begin(); i!=digi->end(); i++) {
143  HcalDetId cell = i->id();
144  DetId detcell=(DetId)cell;
145  // rof 27.03.09: drop ZS marked and passed digis:
147  if (i->zsMarkAndPass()) continue;
148 
149  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
150  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
151  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
152  HcalCoderDb coder (*channelCoder, *shape);
153 
154  //>>> firstSample & samplesToAdd
155  if(tsFromDB_) {
156  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
157  first = param_ts->firstSample();
158  toadd = param_ts->samplesToAdd();
159  }
160  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
161  }
162  // return result
163  e.put(rec);
164 }
165 
166 
168 {
169  // get conditions
170  edm::ESHandle<HcalDbService> conditions;
171  eventSetup.get<HcalDbRecord>().get(conditions);
172 
173  if(upgradeHBHE_){
174 
176  e.getByToken(tok_hbheUp_, digi);
177 
178  // create empty output
179  std::auto_ptr<HBHERecHitCollection> rec(new HBHERecHitCollection);
180  rec->reserve(digi->size());
181 
182  // run the algorithm
183  int first = firstSample_;
184  int toadd = samplesToAdd_;
186  for (i=digi->begin(); i!=digi->end(); i++) {
187  HcalDetId cell = i->id();
188  DetId detcell=(DetId)cell;
189  // rof 27.03.09: drop ZS marked and passed digis:
191  if (i->zsMarkAndPass()) continue;
192 
193  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
194  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
195  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
196  HcalCoderDb coder (*channelCoder, *shape);
197 
198  //>>> firstSample & samplesToAdd
199  if(tsFromDB_) {
200  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
201  first = param_ts->firstSample();
202  toadd = param_ts->samplesToAdd();
203  }
204  rec->push_back(reco_.reconstructHBHEUpgrade(*i,first,toadd,coder,calibrations));
205 
206  }
207 
208  e.put(rec); // put results
209  }// End of upgradeHBHE
210 
211  if(upgradeHF_){
212 
214  e.getByToken(tok_hfUp_, digi);
215 
216  // create empty output
217  std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
218  rec->reserve(digi->size());
219 
220  // run the algorithm
221  int first = firstSample_;
222  int toadd = samplesToAdd_;
224  for (i=digi->begin(); i!=digi->end(); i++) {
225  HcalDetId cell = i->id();
226  DetId detcell=(DetId)cell;
227  // rof 27.03.09: drop ZS marked and passed digis:
229  if (i->zsMarkAndPass()) continue;
230 
231  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
232  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
233  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
234  HcalCoderDb coder (*channelCoder, *shape);
235 
236  //>>> firstSample & samplesToAdd
237  if(tsFromDB_) {
238  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
239  first = param_ts->firstSample();
240  toadd = param_ts->samplesToAdd();
241  }
242  rec->push_back(reco_.reconstructHFUpgrade(*i,first,toadd,coder,calibrations));
243 
244  }
245  e.put(rec); // put results
246  }// End of upgradeHF
247 
248  if(HFQIE10_){
249 
251  e.getByToken(tok_hfQIE10_, digi);
252 
253  // create empty output
254  std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
255  rec->reserve(digi->size());
256 
257  // run the algorithm
258  int first = firstSample_;
259  int toadd = samplesToAdd_;
260  for (QIE10DigiCollection::const_iterator i=digi->begin(); i!=digi->end(); i++) {
261  HcalDetId cell = i->id();
262  DetId detcell=(DetId)cell;
263 
264  //make dataframe
265  QIE10DataFrame frame(*i);
266 
267  // rof 27.03.09: drop ZS marked and passed digis:
268  if (dropZSmarkedPassed_){
269  if (frame.zsMarkAndPass()) continue;
270  }
271 
272  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
273  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
274  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
275  HcalCoderDb coder (*channelCoder, *shape);
276 
277  //>>> firstSample & samplesToAdd
278  if(tsFromDB_) {
279  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
280  first = param_ts->firstSample();
281  toadd = param_ts->samplesToAdd();
282  }
283  rec->push_back(reco_.reconstructQIE10(frame,first,toadd,coder,calibrations));
284 
285  }
286  e.put(rec); // put results
287  }// End of upgradeHF
288 
289 }
290 
291 
292 
294 {
295  // HACK related to HB- corrections
296  if(e.isRealData()) reco_.setForData(e.run());
297 
298  // What to produce, better to avoid the same subdet Upgrade and regular
299  // rechits "clashes"
300  if(upgradeHBHE_ || upgradeHF_ || HFQIE10_) {
301  processUpgrade(e, eventSetup);
302  } else if (det_==DetId::Hcal) {
304  process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup, tok_hbhe_);
305  } else if (subdet_==HcalForward && !upgradeHF_) {
306  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup, tok_hf_);
307  } else if (subdet_==HcalOuter) {
308  process<HODigiCollection, HORecHitCollection>(e, eventSetup, tok_ho_);
309  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
310  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup, tok_calib_);
311  }
312  }
313 }
void setMeth3Params(int iPedSubMethod, float iPedSubThreshold, int iTimeSlewParsType, std::vector< double > iTimeSlewPars, double irespCorrM3)
unsigned int firstSample() const
Definition: HcalRecoParam.h:32
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< HBHEUpgradeDigiCollection > tok_hbheUp_
HBHERecHit reconstruct(const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
HcalSimpleReconstructor(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(edm::EventSetup const &es)
edm::EDGetTokenT< QIE10DigiCollection > tok_hfQIE10_
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) overridefinal
void process(edm::Event &e, const edm::EventSetup &c, const edm::EDGetTokenT< DIGICOLL > &tok)
std::vector< HcalUpgradeDataFrame >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
edm::EDGetTokenT< HFUpgradeDigiCollection > tok_hfUp_
bool isRealData() const
Definition: EventBase.h:63
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
HcalOtherSubdetector subdetOther_
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
HFRecHit reconstructHFUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
bool zsMarkAndPass() const
RunNumber_t run() const
Definition: Event.h:93
ParameterDescriptionBase * add(U const &iLabel, T const &value)
unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:33
edm::EDGetTokenT< HFDigiCollection > tok_hf_
edm::EDGetTokenT< HODigiCollection > tok_ho_
virtual void produce(edm::Event &e, const edm::EventSetup &c) overridefinal
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
HFRecHit reconstructQIE10(const QIE10DataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void setForData(int runnum)
T const * product() const
Definition: ESHandle.h:86
HBHERecHit reconstructHBHEUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void processUpgrade(edm::Event &e, const edm::EventSetup &c)
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
volatile std::atomic< bool > shutdown_flag false
void setTopo(const HcalTopology *topo)
Definition: Run.h:43
virtual void endRun(edm::Run const &r, edm::EventSetup const &es) overridefinal