CMS 3D CMS Logo

ZdcHitReconstructor.cc
Go to the documentation of this file.
1 #include "ZdcHitReconstructor.h"
12 
13 #include <iostream>
14 
15 /* Zdc Hit reconstructor allows for CaloRecHits with status words */
16 
18  : reco_(conf.getParameter<bool>("correctForTimeslew"),
19  conf.getParameter<bool>("correctForPhaseContainment"),
20  conf.getParameter<double>("correctionPhaseNS"),
21  conf.getParameter<int>("recoMethod"),
22  conf.getParameter<int>("lowGainOffset"),
23  conf.getParameter<double>("lowGainFrac")),
24  saturationFlagSetter_(nullptr),
25  det_(DetId::Hcal),
26  correctTiming_(conf.getParameter<bool>("correctTiming")),
27  setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
28  setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
29  setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
30  setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
31  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
32  AuxTSvec_(conf.getParameter<std::vector<int> >("AuxTSvec")) {
33  tok_input_hcal = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelhcal"));
34  tok_input_castor = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelcastor"));
35 
36  std::sort(AuxTSvec_.begin(), AuxTSvec_.end()); // sort vector in ascending TS order
37  std::string subd = conf.getParameter<std::string>("Subdetector");
38 
39  if (setSaturationFlags_) {
40  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
41  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
42  }
43  if (!strcasecmp(subd.c_str(), "ZDC")) {
44  det_ = DetId::Calo;
46  produces<ZDCRecHitCollection>();
47  } else if (!strcasecmp(subd.c_str(), "CALIB")) {
50  produces<HcalCalibRecHitCollection>();
51  } else {
52  std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
53  }
54 
55  // ES tokens
56  htopoToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun>();
57  paramsToken_ = esConsumes<HcalLongRecoParams, HcalLongRecoParamsRcd, edm::Transition::BeginRun>();
58  conditionsToken_ = esConsumes<HcalDbService, HcalDbRecord>();
59  qualToken_ = esConsumes<HcalChannelQuality, HcalChannelQualityRcd>(edm::ESInputTag("", "withTopo"));
60  sevToken_ = esConsumes<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd>();
61 }
62 
64 
66  const HcalTopology& htopo = es.getData(htopoToken_);
68  longRecoParams_ = std::make_unique<HcalLongRecoParams>(p);
69  longRecoParams_->setTopo(&htopo);
70 }
71 
73 
75  // get conditions
77  const HcalChannelQuality* myqual = &eventSetup.getData(qualToken_);
78  const HcalSeverityLevelComputer* mySeverity = &eventSetup.getData(sevToken_);
79 
80  // define vectors to pass noiseTS and signalTS
81  std::vector<unsigned int> mySignalTS;
82  std::vector<unsigned int> myNoiseTS;
83 
86  e.getByToken(tok_input_hcal, digi);
87 
88  if (digi->empty()) {
90  e.getByToken(tok_input_castor, digi_castor);
91  if (!digi_castor.isValid() || digi_castor->empty())
92  edm::LogInfo("ZdcHitReconstructor") << "No ZDC info found in either castorDigis or hcalDigis." << std::endl;
93  if (digi_castor.isValid())
94  e.getByToken(tok_input_castor, digi);
95  }
96 
97  // create empty output
98  auto rec = std::make_unique<ZDCRecHitCollection>();
99  rec->reserve(digi->size());
100  // run the algorithm
102  for (i = digi->begin(); i != digi->end(); i++) {
103  HcalZDCDetId cell = i->id();
104  DetId detcell = (DetId)cell;
105  // check on cells to be ignored and dropped: (rof,20.Feb.09)
106  const HcalChannelStatus* mydigistatus = myqual->getValues(detcell.rawId());
107  if (mySeverity->dropChannel(mydigistatus->getValue()))
108  continue;
110  if (i->zsMarkAndPass())
111  continue;
112  const HcalCalibrations& calibrations = conditions->getHcalCalibrations(cell);
113  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
114  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
115  HcalCoderDb coder(*channelCoder, *shape);
116 
117  // get db values for signalTSs and noiseTSs
118  const HcalLongRecoParam* myParams = longRecoParams_->getValues(detcell);
119  mySignalTS.clear();
120  myNoiseTS.clear();
121  mySignalTS = myParams->signalTS();
122  myNoiseTS = myParams->noiseTS();
123 
124  rec->push_back(reco_.reconstruct(*i, myNoiseTS, mySignalTS, coder, calibrations));
125  (rec->back()).setFlags(0);
127  saturationFlagSetter_->setSaturationFlag(rec->back(), *i);
128 
129  // Set auxiliary flag with subset of digi information
130  // ZDC aux flag can store non-contiguous set of values
131  int auxflag = 0;
132  for (unsigned int xx = 0; xx < AuxTSvec_.size() && xx < 4; ++xx) {
133  if (AuxTSvec_[xx] < 0 || AuxTSvec_[xx] > 9)
134  continue; // don't allow
135  auxflag += (i->sample(AuxTSvec_[xx]).adc())
136  << (7 * xx); // store the time slices in the first 28 bits of aux, a set of 4 7-bit a dc values
137  }
138  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
139  if (!AuxTSvec_.empty())
140  auxflag += ((i->sample(AuxTSvec_[0]).capid()) << 28);
141  (rec->back()).setAux(auxflag);
142  }
143  // return result
144  e.put(std::move(rec));
145  } // else if (det_==DetId::Calo...)
146 
147 } // void HcalHitReconstructor::produce(...)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > sevToken_
void produce(edm::Event &e, const edm::EventSetup &c) final
size_type size() const
std::vector< T >::const_iterator const_iterator
edm::ESGetToken< HcalLongRecoParams, HcalLongRecoParamsRcd > paramsToken_
edm::EDGetTokenT< ZDCDigiCollection > tok_input_hcal
const Item * getValues(DetId fId, bool throwOnFail=true) const
std::unique_ptr< HcalLongRecoParams > longRecoParams_
ZdcSimpleRecAlgo reco_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualToken_
HcalOtherSubdetector subdetOther_
const_iterator begin() const
ZDCRecHit reconstruct(const ZDCDataFrame &digi, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, const HcalCoder &coder, const HcalCalibrations &calibs) const
void setSaturationFlag(HBHERecHit &rechit, const HBHEDataFrame &digi)
HcalADCSaturationFlag * saturationFlagSetter_
uint32_t getValue() const
edm::EDGetTokenT< ZDCDigiCollection > tok_input_castor
const_iterator end() const
Definition: DetId.h:17
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
ZdcHitReconstructor(const edm::ParameterSet &ps)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::ESGetToken< HcalDbService, HcalDbRecord > conditionsToken_
std::vector< unsigned int > signalTS() const
std::vector< int > AuxTSvec_
bool isValid() const
Definition: HandleBase.h:70
void endRun(edm::Run const &r, edm::EventSetup const &es) final
void beginRun(edm::Run const &r, edm::EventSetup const &es) final
std::vector< unsigned int > noiseTS() const
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
bool dropChannel(const uint32_t &mystatus) const