CMS 3D CMS Logo

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  paramTS(0),
26  theTopology(0)
27 {
28  // Intitialize "method 3"
30  conf.getParameter<bool> ("applyTimeSlewM3"),
31  conf.getParameter<double> ("pedestalUpperLimit"),
32  conf.getParameter<int> ("timeSlewParsType"),
33  conf.getParameter<std::vector<double> >("timeSlewPars"),
34  conf.getParameter<double> ("respCorrM3")
35  );
36 
37  // register for data access
38  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_);
39  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
40  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
41  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
42 
43  std::string subd=conf.getParameter<std::string>("Subdetector");
44  if (!strcasecmp(subd.c_str(),"HO")) {
46  produces<HORecHitCollection>();
47  }
48  else if (!strcasecmp(subd.c_str(),"HBHE")) {
50  produces<HBHERecHitCollection>();
51  }
52  else if (!strcasecmp(subd.c_str(),"HF")) {
54  produces<HFRecHitCollection>();
55  }
56  else {
57  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
58  }
59 
60 }
61 
64  desc.setAllowAnything();
65  desc.add<bool>("applyTimeSlewM3", true);
66  desc.add<double>("pedestalUpperLimit", 2.7);
67  desc.add<int>("timeSlewParsType",3);
68  desc.add<std::vector<double>>("timeSlewPars", { 12.2999, -2.19142, 0, 12.2999, -2.19142, 0, 12.2999, -2.19142, 0 });
69  desc.add<double>("respCorrM3", 1.0);
70  descriptions.add("simpleHbhereco",desc);
71 }
72 
74  delete paramTS;
75  delete theTopology;
76 }
77 
79  if(tsFromDB_) {
81  es.get<HcalRecoParamsRcd>().get(p);
82  paramTS = new HcalRecoParams(*p.product());
83 
85  es.get<HcalRecNumberingRecord>().get(htopo);
86  theTopology=new HcalTopology(*htopo);
88 
89  }
90  reco_.beginRun(es);
91 }
92 
94  if(tsFromDB_ && paramTS) {
95  delete paramTS;
96  paramTS = 0;
97  reco_.endRun();
98  }
99 }
100 
101 
102 template<class DIGICOLL, class RECHITCOLL>
104 {
105  // get conditions
106  edm::ESHandle<HcalDbService> conditions;
107  eventSetup.get<HcalDbRecord>().get(conditions);
108 
110  e.getByToken(tok,digi);
111 
112  // create empty output
113  auto rec = std::make_unique<RECHITCOLL>();
114  rec->reserve(digi->size());
115  // run the algorithm
116  int first = firstSample_;
117  int toadd = samplesToAdd_;
118  typename DIGICOLL::const_iterator i;
119  for (i=digi->begin(); i!=digi->end(); i++) {
120  HcalDetId cell = i->id();
121  DetId detcell=(DetId)cell;
122  // rof 27.03.09: drop ZS marked and passed digis:
124  if (i->zsMarkAndPass()) continue;
125 
126  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
127  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
128  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
129  HcalCoderDb coder (*channelCoder, *shape);
130 
131  //>>> firstSample & samplesToAdd
132  if(tsFromDB_) {
133  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
134  first = param_ts->firstSample();
135  toadd = param_ts->samplesToAdd();
136  }
137  rec->push_back(reco_.reconstruct(*i,first,toadd,coder,calibrations));
138  }
139  // return result
140  e.put(std::move(rec));
141 }
142 
144 {
145  // HACK related to HB- corrections
146  if(e.isRealData()) reco_.setForData(e.run());
147 
148  if (det_==DetId::Hcal) {
149  if ((subdet_==HcalBarrel || subdet_==HcalEndcap)) {
150  process<HBHEDigiCollection, HBHERecHitCollection>(e, eventSetup, tok_hbhe_);
151  } else if (subdet_==HcalForward) {
152  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup, tok_hf_);
153  } else if (subdet_==HcalOuter) {
154  process<HODigiCollection, HORecHitCollection>(e, eventSetup, tok_ho_);
155  } else if (subdet_==HcalOther && subdetOther_==HcalCalibration) {
156  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup, tok_calib_);
157  }
158  }
159 }
unsigned int firstSample() const
Definition: HcalRecoParam.h:32
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
HBHERecHit reconstruct(const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void setMeth3Params(bool iApplyTimeSlew, float iPedSubThreshold, int iTimeSlewParsType, std::vector< double > iTimeSlewPars, double irespCorrM3)
HcalSimpleReconstructor(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
void setAllowAnything()
allow any parameter label/value pairs
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(edm::EventSetup const &es)
void process(edm::Event &e, const edm::EventSetup &c, const edm::EDGetTokenT< DIGICOLL > &tok)
const Item * getValues(DetId fId, bool throwOnFail=true) const
virtual void produce(edm::Event &e, const edm::EventSetup &c) override final
bool isRealData() const
Definition: EventBase.h:62
virtual void endRun(edm::Run const &r, edm::EventSetup const &es) override final
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
HcalOtherSubdetector subdetOther_
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_
RunNumber_t run() const
Definition: Event.h:94
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_
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:56
void setForData(int runnum)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
HLT enums.
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) override final
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
void setTopo(const HcalTopology *topo)
Definition: Run.h:42