CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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"),
19  conf.getParameter<double>("correctionPhaseNS"),
20  consumesCollector()),
21  det_(DetId::Hcal),
22  inputLabel_(conf.getParameter<edm::InputTag>("digiLabel")),
23  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
24  firstSample_(conf.getParameter<int>("firstSample")),
25  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
26  tsFromDB_(conf.getParameter<bool>("tsFromDB")) {
27  // register for data access
28  tok_hf_ = consumes<HFDigiCollection>(inputLabel_);
29  tok_ho_ = consumes<HODigiCollection>(inputLabel_);
30  tok_calib_ = consumes<HcalCalibDigiCollection>(inputLabel_);
31 
32  std::string subd = conf.getParameter<std::string>("Subdetector");
33  if (!strcasecmp(subd.c_str(), "HO")) {
35  produces<HORecHitCollection>();
36  } else if (!strcasecmp(subd.c_str(), "HF")) {
38  produces<HFRecHitCollection>();
39  } else {
40  std::cout << "HcalSimpleReconstructor is not associated with a specific subdetector!" << std::endl;
41  }
42 
43  // ES tokens
44  if (tsFromDB_) {
45  htopoToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun>();
46  paramsToken_ = esConsumes<HcalRecoParams, HcalRecoParamsRcd, edm::Transition::BeginRun>();
47  }
48  conditionsToken_ = esConsumes<HcalDbService, HcalDbRecord>();
49 }
50 
52 
54  if (tsFromDB_) {
55  const HcalTopology& htopo = es.getData(htopoToken_);
56  const HcalRecoParams& p = es.getData(paramsToken_);
57  paramTS_ = std::make_unique<HcalRecoParams>(p);
58  paramTS_->setTopo(&htopo);
59  }
60  reco_.beginRun(es);
61 }
62 
64 
65 template <class DIGICOLL, class RECHITCOLL>
67  const edm::EventSetup& eventSetup,
68  const edm::EDGetTokenT<DIGICOLL>& tok) {
69  // get conditions
70  const HcalDbService* conditions = &eventSetup.getData(conditionsToken_);
71 
73  e.getByToken(tok, digi);
74 
75  // create empty output
76  auto rec = std::make_unique<RECHITCOLL>();
77  rec->reserve(digi->size());
78  // run the algorithm
79  int first = firstSample_;
80  int toadd = samplesToAdd_;
81  typename DIGICOLL::const_iterator i;
82  for (i = digi->begin(); i != digi->end(); i++) {
83  HcalDetId cell = i->id();
84  DetId detcell = (DetId)cell;
85  // rof 27.03.09: drop ZS marked and passed digis:
87  if (i->zsMarkAndPass())
88  continue;
89 
90  const HcalCalibrations& calibrations = conditions->getHcalCalibrations(cell);
91  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
92  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
93  HcalCoderDb coder(*channelCoder, *shape);
94 
95  //>>> firstSample & samplesToAdd
96  if (tsFromDB_) {
97  const HcalRecoParam* param_ts = paramTS_->getValues(detcell.rawId());
98  first = param_ts->firstSample();
99  toadd = param_ts->samplesToAdd();
100  }
101  rec->push_back(reco_.reconstruct(*i, first, toadd, coder, calibrations));
102  }
103  // return result
104  e.put(std::move(rec));
105 }
106 
108  if (det_ == DetId::Hcal) {
109  if (subdet_ == HcalForward) {
110  process<HFDigiCollection, HFRecHitCollection>(e, eventSetup, tok_hf_);
111  } else if (subdet_ == HcalOuter) {
112  process<HODigiCollection, HORecHitCollection>(e, eventSetup, tok_ho_);
113  } else if (subdet_ == HcalOther && subdetOther_ == HcalCalibration) {
114  process<HcalCalibDigiCollection, HcalCalibRecHitCollection>(e, eventSetup, tok_calib_);
115  }
116  }
117 }
118 
120  // horeco
122  descHO.add<double>("correctionPhaseNS", 13.0);
123  descHO.add<edm::InputTag>("digiLabel", edm::InputTag("hcalDigis"));
124  descHO.add<bool>("tsFromDB", true);
125  descHO.add<int>("samplesToAdd", 4);
126  descHO.add<std::string>("Subdetector", "HO");
127  descHO.add<bool>("correctForTimeslew", true);
128  descHO.add<bool>("dropZSmarkedPassed", true);
129  descHO.add<bool>("correctForPhaseContainment", true);
130  descHO.add<int>("firstSample", 4);
131  descriptions.add("hosimplereco", descHO);
132 
133  // hfreco
135  descHF.add<double>("correctionPhaseNS", 0.0);
136  descHF.add<edm::InputTag>("digiLabel", edm::InputTag("hcalDigis"));
137  descHF.add<bool>("tsFromDB", true);
138  descHF.add<int>("samplesToAdd", 2);
139  descHF.add<std::string>("Subdetector", "HF");
140  descHF.add<bool>("correctForTimeslew", false);
141  descHF.add<bool>("dropZSmarkedPassed", true);
142  descHF.add<bool>("correctForPhaseContainment", false);
143  descHF.add<int>("firstSample", 4);
144  descriptions.add("hfsimplereco", descHF);
145 }
constexpr unsigned int samplesToAdd() const
Definition: HcalRecoParam.h:32
std::unique_ptr< HcalRecoParams > paramTS_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::ESGetToken< HcalRecoParams, HcalRecoParamsRcd > paramsToken_
HcalSimpleReconstructor(const edm::ParameterSet &ps)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginRun(edm::EventSetup const &es)
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)
bool getData(T &iHolder) const
Definition: EventSetup.h:128
HcalOtherSubdetector subdetOther_
void produce(edm::Event &e, const edm::EventSetup &c) final
void beginRun(edm::Run const &r, edm::EventSetup const &es) final
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
def move
Definition: eostools.py:511
HFRecHit reconstruct(const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
edm::ESGetToken< HcalDbService, HcalDbRecord > conditionsToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< HFDigiCollection > tok_hf_
edm::EDGetTokenT< HODigiCollection > tok_ho_
Definition: DetId.h:17
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
tuple cout
Definition: gather_cfg.py:144
edm::EDGetTokenT< HcalCalibDigiCollection > tok_calib_
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void endRun(edm::Run const &r, edm::EventSetup const &es) final
constexpr unsigned int firstSample() const
Definition: HcalRecoParam.h:31
Definition: Run.h:45