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"),
19  conf.getParameter<double>("correctionPhaseNS")),
20  det_(DetId::Hcal),
21  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
22  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
23  firstSample_(conf.getParameter<int>("firstSample")),
24  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
25  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
26  paramTS(nullptr),
27  theTopology(nullptr) {
28  // register for data access
29  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
30  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
31  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
32 
33  std::string subd = conf.getParameter<std::string>("Subdetector");
34  if (!strcasecmp(subd.c_str(), "HO")) {
36  produces<HORecHitCollection>();
37  } else if (!strcasecmp(subd.c_str(), "HF")) {
39  produces<HFRecHitCollection>();
40  } else {
41  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
42  }
43 }
44 
46  delete paramTS;
47  delete theTopology;
48 }
49 
51  if (tsFromDB_) {
53  es.get<HcalRecoParamsRcd>().get(p);
54  paramTS = new HcalRecoParams(*p.product());
55 
57  es.get<HcalRecNumberingRecord>().get(htopo);
58  theTopology = new HcalTopology(*htopo);
60  }
61  reco_.beginRun(es);
62 }
63 
65  if (tsFromDB_ && paramTS) {
66  delete paramTS;
67  paramTS = nullptr;
68  reco_.endRun();
69  }
70 }
71 
72 template <class DIGICOLL, class RECHITCOLL>
74  const edm::EventSetup& eventSetup,
75  const edm::EDGetTokenT<DIGICOLL>& tok) {
76  // get conditions
78  eventSetup.get<HcalDbRecord>().get(conditions);
79 
81  e.getByToken(tok, digi);
82 
83  // create empty output
84  auto rec = std::make_unique<RECHITCOLL>();
85  rec->reserve(digi->size());
86  // run the algorithm
87  int first = firstSample_;
88  int toadd = samplesToAdd_;
89  typename DIGICOLL::const_iterator i;
90  for (i = digi->begin(); i != digi->end(); i++) {
91  HcalDetId cell = i->id();
92  DetId detcell = (DetId)cell;
93  // rof 27.03.09: drop ZS marked and passed digis:
95  if (i->zsMarkAndPass())
96  continue;
97 
98  const HcalCalibrations& calibrations = conditions->getHcalCalibrations(cell);
99  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
100  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
101  HcalCoderDb coder(*channelCoder, *shape);
102 
103  //>>> firstSample & samplesToAdd
104  if (tsFromDB_) {
105  const HcalRecoParam* param_ts = paramTS->getValues(detcell.rawId());
106  first = param_ts->firstSample();
107  toadd = param_ts->samplesToAdd();
108  }
109  rec->push_back(reco_.reconstruct(*i, first, toadd, coder, calibrations));
110  }
111  // return result
112  e.put(std::move(rec));
113 }
114 
116  if (det_ == DetId::Hcal) {
117  if (subdet_ == HcalForward) {
118  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup, tok_hf_);
119  } else if (subdet_ == HcalOuter) {
120  process<HODigiCollection, HORecHitCollection>(e, eventSetup, tok_ho_);
121  } else if (subdet_ == HcalOther && subdetOther_ == HcalCalibration) {
122  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup, tok_calib_);
123  }
124  }
125 }
126 
128  // horeco
130  descHO.add<double>("correctionPhaseNS", 13.0);
131  descHO.add<edm::InputTag>("digiLabel", edm::InputTag("hcalDigis"));
132  descHO.add<bool>("tsFromDB", true);
133  descHO.add<int>("samplesToAdd", 4);
134  descHO.add<std::string>("Subdetector", "HO");
135  descHO.add<bool>("correctForTimeslew", true);
136  descHO.add<bool>("dropZSmarkedPassed", true);
137  descHO.add<bool>("correctForPhaseContainment", true);
138  descHO.add<int>("firstSample", 4);
139  descriptions.add("hosimplereco", descHO);
140 
141  // hfreco
143  descHF.add<double>("correctionPhaseNS", 0.0);
144  descHF.add<edm::InputTag>("digiLabel", edm::InputTag("hcalDigis"));
145  descHF.add<bool>("tsFromDB", true);
146  descHF.add<int>("samplesToAdd", 2);
147  descHF.add<std::string>("Subdetector", "HF");
148  descHF.add<bool>("correctForTimeslew", false);
149  descHF.add<bool>("dropZSmarkedPassed", true);
150  descHF.add<bool>("correctForPhaseContainment", false);
151  descHF.add<int>("firstSample", 4);
152  descriptions.add("hfsimplereco", descHF);
153 }
T getParameter(std::string const &) const
constexpr unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:32
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
HcalSimpleReconstructor(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(edm::EventSetup const &es)
#define nullptr
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void process(edm::Event &e, const edm::EventSetup &c, const edm::EDGetTokenT< DIGICOLL > &tok)
const Item * getValues(DetId fId, bool throwOnFail=true) const
HcalOtherSubdetector subdetOther_
void produce(edm::Event &e, const edm::EventSetup &c) final
void beginRun(edm::Run const &r, edm::EventSetup const &es) final
HFRecHit reconstruct(const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< HFDigiCollection > tok_hf_
edm::EDGetTokenT< HODigiCollection > tok_ho_
Definition: DetId.h:17
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.
T get() const
Definition: EventSetup.h:73
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void endRun(edm::Run const &r, edm::EventSetup const &es) final
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
void setTopo(const HcalTopology *topo)
constexpr unsigned int firstSample() const
Definition: HcalRecoParam.h:31
Definition: Run.h:45