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  paramTS(0),
28  theTopology(0)
29 {
30  // Intitialize "method 3"
32  conf.getParameter<int> ("pedestalSubtractionType"),
33  conf.getParameter<double> ("pedestalUpperLimit"),
34  conf.getParameter<int> ("timeSlewParsType"),
35  conf.getParameter<std::vector<double> >("timeSlewPars"),
36  conf.getParameter<double> ("respCorrM3")
37  );
38 
39  // register for data access
40  tok_hbheUp_ = consumes<HBHEUpgradeDigiCollection>(inputLabel_);
41  tok_hfUp_ = consumes<HFUpgradeDigiCollection>(inputLabel_);
42 
43  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_);
44  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
45  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
46  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
47 
48  std::string subd=conf.getParameter<std::string>("Subdetector");
49  if(!strcasecmp(subd.c_str(),"upgradeHBHE")) {
50  upgradeHBHE_ = true;
51  produces<HBHERecHitCollection>();
52  }
53  else if (!strcasecmp(subd.c_str(),"upgradeHF")) {
54  upgradeHF_ = true;
55  produces<HFRecHitCollection>();
56  }
57  else if (!strcasecmp(subd.c_str(),"HO")) {
59  produces<HORecHitCollection>();
60  }
61  else if (!strcasecmp(subd.c_str(),"HBHE")) {
62  if( !upgradeHBHE_) {
64  produces<HBHERecHitCollection>();
65  }
66  }
67  else if (!strcasecmp(subd.c_str(),"HF")) {
68  if( !upgradeHF_) {
70  produces<HFRecHitCollection>();
71  }
72  }
73  else {
74  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
75  }
76 
77 }
78 
81  desc.setAllowAnything();
82  desc.add<int>("pedestalSubtractionType", 1);
83  desc.add<double>("pedestalUpperLimit", 2.7);
84  desc.add<int>("timeSlewParsType",3);
85  desc.add<std::vector<double>>("timeSlewPars", { 12.2999, -2.19142, 0, 12.2999, -2.19142, 0, 12.2999, -2.19142, 0 });
86  desc.add<double>("respCorrM3", 0.95);
87  descriptions.add("simpleHbhereco",desc);
88 }
89 
91  delete paramTS;
92  delete theTopology;
93 }
94 
96  if(tsFromDB_) {
98  es.get<HcalRecoParamsRcd>().get(p);
99  paramTS = new HcalRecoParams(*p.product());
100 
102  es.get<HcalRecNumberingRecord>().get(htopo);
103  theTopology=new HcalTopology(*htopo);
105 
106  }
107  reco_.beginRun(es);
108 }
109 
111  if(tsFromDB_ && paramTS) {
112  delete paramTS;
113  paramTS = 0;
114  reco_.endRun();
115  }
116 }
117 
118 
119 template<class DIGICOLL, class RECHITCOLL>
121 {
122  // get conditions
123  edm::ESHandle<HcalDbService> conditions;
124  eventSetup.get<HcalDbRecord>().get(conditions);
125 
127  e.getByToken(tok,digi);
128 
129  // create empty output
130  std::auto_ptr<RECHITCOLL> rec(new RECHITCOLL);
131  rec->reserve(digi->size());
132  // run the algorithm
133  int first = firstSample_;
134  int toadd = samplesToAdd_;
135  typename DIGICOLL::const_iterator i;
136  for (i=digi->begin(); i!=digi->end(); i++) {
137  HcalDetId cell = i->id();
138  DetId detcell=(DetId)cell;
139  // rof 27.03.09: drop ZS marked and passed digis:
141  if (i->zsMarkAndPass()) continue;
142 
143  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
144  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
145  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
146  HcalCoderDb coder (*channelCoder, *shape);
147 
148  //>>> firstSample & samplesToAdd
149  if(tsFromDB_) {
150  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
151  first = param_ts->firstSample();
152  toadd = param_ts->samplesToAdd();
153  }
154  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
155  }
156  // return result
157  e.put(rec);
158 }
159 
160 
162 {
163  // get conditions
164  edm::ESHandle<HcalDbService> conditions;
165  eventSetup.get<HcalDbRecord>().get(conditions);
166 
167  if(upgradeHBHE_){
168 
170  e.getByToken(tok_hbheUp_, digi);
171 
172  // create empty output
173  std::auto_ptr<HBHERecHitCollection> rec(new HBHERecHitCollection);
174  rec->reserve(digi->size());
175 
176  // run the algorithm
177  int first = firstSample_;
178  int toadd = samplesToAdd_;
180  for (i=digi->begin(); i!=digi->end(); i++) {
181  HcalDetId cell = i->id();
182  DetId detcell=(DetId)cell;
183  // rof 27.03.09: drop ZS marked and passed digis:
185  if (i->zsMarkAndPass()) continue;
186 
187  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
188  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
189  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
190  HcalCoderDb coder (*channelCoder, *shape);
191 
192  //>>> firstSample & samplesToAdd
193  if(tsFromDB_) {
194  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
195  first = param_ts->firstSample();
196  toadd = param_ts->samplesToAdd();
197  }
198  rec->push_back(reco_.reconstructHBHEUpgrade(*i,first,toadd,coder,calibrations));
199 
200  }
201 
202  e.put(rec); // put results
203  }// End of upgradeHBHE
204 
205  if(upgradeHF_){
206 
208  e.getByToken(tok_hfUp_, digi);
209 
210  // create empty output
211  std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
212  rec->reserve(digi->size());
213 
214  // run the algorithm
215  int first = firstSample_;
216  int toadd = samplesToAdd_;
218  for (i=digi->begin(); i!=digi->end(); i++) {
219  HcalDetId cell = i->id();
220  DetId detcell=(DetId)cell;
221  // rof 27.03.09: drop ZS marked and passed digis:
223  if (i->zsMarkAndPass()) continue;
224 
225  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
226  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
227  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
228  HcalCoderDb coder (*channelCoder, *shape);
229 
230  //>>> firstSample & samplesToAdd
231  if(tsFromDB_) {
232  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
233  first = param_ts->firstSample();
234  toadd = param_ts->samplesToAdd();
235  }
236  rec->push_back(reco_.reconstructHFUpgrade(*i,first,toadd,coder,calibrations));
237 
238  }
239  e.put(rec); // put results
240  }// End of upgradeHF
241 
242 }
243 
244 
245 
247 {
248  // HACK related to HB- corrections
249  if(e.isRealData()) reco_.setForData(e.run());
250 
251  // What to produce, better to avoid the same subdet Upgrade and regular
252  // rechits "clashes"
253  if(upgradeHBHE_ || upgradeHF_) {
254  processUpgrade(e, eventSetup);
255  } else if (det_==DetId::Hcal) {
257  process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup, tok_hbhe_);
258  } else if (subdet_==HcalForward && !upgradeHF_) {
259  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup, tok_hf_);
260  } else if (subdet_==HcalOuter) {
261  process<HODigiCollection, HORecHitCollection>(e, eventSetup, tok_ho_);
262  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
263  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup, tok_calib_);
264  }
265  }
266 }
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
HcalSimpleReconstructor(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(edm::EventSetup const &es)
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:64
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:120
HFRecHit reconstructHFUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
RunNumber_t run() const
Definition: Event.h:92
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
tuple conf
Definition: dbtoconf.py:185
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
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:121
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