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.
11 
12 #include <iostream>
13 
15  reco_(conf.getParameter<bool>("correctForTimeslew"),
16  conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
17  det_(DetId::Hcal),
18  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
19  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
20  firstSample_(conf.getParameter<int>("firstSample")),
21  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
22  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
23  upgradeHBHE_(false),
24  upgradeHF_(false),
25  paramTS(0),
26  theTopology(0)
27 {
28 
29  // register for data access
30  tok_hbheUp_ = consumes<HBHEUpgradeDigiCollection>(inputLabel_);
31  tok_hfUp_ = consumes<HFUpgradeDigiCollection>(inputLabel_);
32 
33  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_);
34  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
35  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
36  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
37 
38  std::string subd=conf.getParameter<std::string>("Subdetector");
39  if(!strcasecmp(subd.c_str(),"upgradeHBHE")) {
40  upgradeHBHE_ = true;
41  produces<HBHERecHitCollection>();
42  }
43  else if (!strcasecmp(subd.c_str(),"upgradeHF")) {
44  upgradeHF_ = true;
45  produces<HFRecHitCollection>();
46  }
47  else if (!strcasecmp(subd.c_str(),"HO")) {
49  produces<HORecHitCollection>();
50  }
51  else if (!strcasecmp(subd.c_str(),"HBHE")) {
52  if( !upgradeHBHE_) {
54  produces<HBHERecHitCollection>();
55  }
56  }
57  else if (!strcasecmp(subd.c_str(),"HF")) {
58  if( !upgradeHF_) {
60  produces<HFRecHitCollection>();
61  }
62  }
63  else {
64  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
65  }
66 
67 }
68 
70  delete paramTS;
71  delete theTopology;
72 }
73 
75  if(tsFromDB_) {
77  es.get<HcalRecoParamsRcd>().get(p);
78  paramTS = new HcalRecoParams(*p.product());
79 
81  es.get<IdealGeometryRecord>().get(htopo);
82  theTopology=new HcalTopology(*htopo);
84 
85  }
86  reco_.beginRun(es);
87 }
88 
90  if(tsFromDB_ && paramTS) {
91  delete paramTS;
92  paramTS = 0;
93  reco_.endRun();
94  }
95 }
96 
97 
98 template<class DIGICOLL, class RECHITCOLL>
100 {
101  // get conditions
102  edm::ESHandle<HcalDbService> conditions;
103  eventSetup.get<HcalDbRecord>().get(conditions);
104 
106  e.getByToken(tok,digi);
107 
108  // create empty output
109  std::auto_ptr<RECHITCOLL> rec(new RECHITCOLL);
110  rec->reserve(digi->size());
111  // run the algorithm
112  int first = firstSample_;
113  int toadd = samplesToAdd_;
114  typename DIGICOLL::const_iterator i;
115  for (i=digi->begin(); i!=digi->end(); i++) {
116  HcalDetId cell = i->id();
117  DetId detcell=(DetId)cell;
118  // rof 27.03.09: drop ZS marked and passed digis:
120  if (i->zsMarkAndPass()) continue;
121 
122  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
123  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
124  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
125  HcalCoderDb coder (*channelCoder, *shape);
126 
127  //>>> firstSample & samplesToAdd
128  if(tsFromDB_) {
129  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
130  first = param_ts->firstSample();
131  toadd = param_ts->samplesToAdd();
132  }
133  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
134  }
135  // return result
136  e.put(rec);
137 }
138 
139 
141 {
142  // get conditions
143  edm::ESHandle<HcalDbService> conditions;
144  eventSetup.get<HcalDbRecord>().get(conditions);
145 
146  if(upgradeHBHE_){
147 
149  e.getByToken(tok_hbheUp_, digi);
150 
151  // create empty output
152  std::auto_ptr<HBHERecHitCollection> rec(new HBHERecHitCollection);
153  rec->reserve(digi->size());
154 
155  // run the algorithm
156  int first = firstSample_;
157  int toadd = samplesToAdd_;
159  for (i=digi->begin(); i!=digi->end(); i++) {
160  HcalDetId cell = i->id();
161  DetId detcell=(DetId)cell;
162  // rof 27.03.09: drop ZS marked and passed digis:
164  if (i->zsMarkAndPass()) continue;
165 
166  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
167  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
168  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
169  HcalCoderDb coder (*channelCoder, *shape);
170 
171  //>>> firstSample & samplesToAdd
172  if(tsFromDB_) {
173  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
174  first = param_ts->firstSample();
175  toadd = param_ts->samplesToAdd();
176  }
177  rec->push_back(reco_.reconstructHBHEUpgrade(*i,first,toadd,coder,calibrations));
178 
179  }
180 
181  e.put(rec); // put results
182  }// End of upgradeHBHE
183 
184  if(upgradeHF_){
185 
187  e.getByToken(tok_hfUp_, digi);
188 
189  // create empty output
190  std::auto_ptr<HFRecHitCollection> rec(new HFRecHitCollection);
191  rec->reserve(digi->size());
192 
193  // run the algorithm
194  int first = firstSample_;
195  int toadd = samplesToAdd_;
197  for (i=digi->begin(); i!=digi->end(); i++) {
198  HcalDetId cell = i->id();
199  DetId detcell=(DetId)cell;
200  // rof 27.03.09: drop ZS marked and passed digis:
202  if (i->zsMarkAndPass()) continue;
203 
204  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
205  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
206  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
207  HcalCoderDb coder (*channelCoder, *shape);
208 
209  //>>> firstSample & samplesToAdd
210  if(tsFromDB_) {
211  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
212  first = param_ts->firstSample();
213  toadd = param_ts->samplesToAdd();
214  }
215  rec->push_back(reco_.reconstructHFUpgrade(*i,first,toadd,coder,calibrations));
216 
217  }
218  e.put(rec); // put results
219  }// End of upgradeHF
220 
221 }
222 
223 
224 
226 {
227  // HACK related to HB- corrections
228  if(e.isRealData()) reco_.setForData(e.run());
229 
230  // What to produce, better to avoid the same subdet Upgrade and regular
231  // rechits "clashes"
232  if(upgradeHBHE_ || upgradeHF_) {
233  processUpgrade(e, eventSetup);
234  } else if (det_==DetId::Hcal) {
236  process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup, tok_hbhe_);
237  } else if (subdet_==HcalForward && !upgradeHF_) {
238  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup, tok_hf_);
239  } else if (subdet_==HcalOuter) {
240  process<HODigiCollection, HORecHitCollection>(e, eventSetup, tok_ho_);
241  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
242  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup, tok_calib_);
243  }
244  }
245 }
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:434
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
void setTopo(const HcalTopology *topo) const
const Item * getValues(DetId fId, bool throwOnFail=true) const
edm::EDGetTokenT< HFUpgradeDigiCollection > tok_hfUp_
bool isRealData() const
Definition: EventBase.h:60
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:116
HFRecHit reconstructHFUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
RunNumber_t run() const
Definition: Event.h:88
unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:33
bool first
Definition: L1TdeRCT.cc:75
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:55
void setForData(int runnum)
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
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
volatile std::atomic< bool > shutdown_flag false
Definition: Run.h:41
virtual void endRun(edm::Run const &r, edm::EventSetup const &es) overridefinal