CMS 3D CMS Logo

ZdcHitReconstructor.cc
Go to the documentation of this file.
1 #include "ZdcHitReconstructor.h"
13 
14 #include <iostream>
15 
16 /* Zdc Hit reconstructor allows for CaloRecHits with status words */
17 
19  : reco_(conf.getParameter<bool>("correctForTimeslew"),
20  conf.getParameter<bool>("correctForPhaseContainment"),
21  conf.getParameter<double>("correctionPhaseNS"),
22  conf.getParameter<int>("recoMethod"),
23  conf.getParameter<int>("lowGainOffset"),
24  conf.getParameter<double>("lowGainFrac")),
25  saturationFlagSetter_(nullptr),
26  HFTimingTrustFlagSetter_(nullptr),
27  hbheHSCPFlagSetter_(nullptr),
28  hbheTimingShapedFlagSetter_(nullptr),
29  hfrechitbit_(nullptr),
30  hfdigibit_(nullptr),
31  det_(DetId::Hcal),
32  correctTiming_(conf.getParameter<bool>("correctTiming")),
33  setNoiseFlags_(conf.getParameter<bool>("setNoiseFlags")),
34  setHSCPFlags_(conf.getParameter<bool>("setHSCPFlags")),
35  setSaturationFlags_(conf.getParameter<bool>("setSaturationFlags")),
36  setTimingTrustFlags_(conf.getParameter<bool>("setTimingTrustFlags")),
37  dropZSmarkedPassed_(conf.getParameter<bool>("dropZSmarkedPassed")),
38  AuxTSvec_(conf.getParameter<std::vector<int> >("AuxTSvec")),
39  myobject(nullptr),
40  theTopology(nullptr)
41 
42 {
43  tok_input_hcal = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelhcal"));
44  tok_input_castor = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelcastor"));
45 
46  std::sort(AuxTSvec_.begin(), AuxTSvec_.end()); // sort vector in ascending TS order
47  std::string subd = conf.getParameter<std::string>("Subdetector");
48 
49  if (setSaturationFlags_) {
50  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
51  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
52  }
53  if (!strcasecmp(subd.c_str(), "ZDC")) {
54  det_ = DetId::Calo;
56  produces<ZDCRecHitCollection>();
57  } else if (!strcasecmp(subd.c_str(), "CALIB")) {
60  produces<HcalCalibRecHitCollection>();
61  } else {
62  std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
63  }
64 }
65 
67 
70  es.get<HcalLongRecoParamsRcd>().get(p);
72 
74  es.get<HcalRecNumberingRecord>().get(htopo);
75  theTopology = new HcalTopology(*htopo);
77 }
78 
80  delete myobject;
81  myobject = nullptr;
82  delete theTopology;
83  theTopology = nullptr;
84 }
86  // get conditions
88  eventSetup.get<HcalDbRecord>().get(conditions);
89 
91  eventSetup.get<HcalChannelQualityRcd>().get("withTopo", p);
92  const HcalChannelQuality* myqual = p.product();
93 
95  eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
96  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
97 
98  // define vectors to pass noiseTS and signalTS
99  std::vector<unsigned int> mySignalTS;
100  std::vector<unsigned int> myNoiseTS;
101 
104  e.getByToken(tok_input_hcal, digi);
105 
106  if (digi->empty()) {
107  edm::Handle<ZDCDigiCollection> digi_castor;
108  e.getByToken(tok_input_castor, digi_castor);
109  if (!digi_castor.isValid() || digi_castor->empty())
110  edm::LogInfo("ZdcHitReconstructor") << "No ZDC info found in either castorDigis or hcalDigis." << std::endl;
111  if (digi_castor.isValid())
112  e.getByToken(tok_input_castor, digi);
113  }
114 
115  // create empty output
116  auto rec = std::make_unique<ZDCRecHitCollection>();
117  rec->reserve(digi->size());
118  // run the algorithm
120  for (i = digi->begin(); i != digi->end(); i++) {
121  HcalZDCDetId cell = i->id();
122  DetId detcell = (DetId)cell;
123  // check on cells to be ignored and dropped: (rof,20.Feb.09)
124  const HcalChannelStatus* mydigistatus = myqual->getValues(detcell.rawId());
125  if (mySeverity->dropChannel(mydigistatus->getValue()))
126  continue;
128  if (i->zsMarkAndPass())
129  continue;
130  const HcalCalibrations& calibrations = conditions->getHcalCalibrations(cell);
131  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
132  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
133  HcalCoderDb coder(*channelCoder, *shape);
134 
135  // get db values for signalTSs and noiseTSs
136  const HcalLongRecoParam* myParams = myobject->getValues(detcell);
137  mySignalTS.clear();
138  myNoiseTS.clear();
139  mySignalTS = myParams->signalTS();
140  myNoiseTS = myParams->noiseTS();
141 
142  rec->push_back(reco_.reconstruct(*i, myNoiseTS, mySignalTS, coder, calibrations));
143  (rec->back()).setFlags(0);
145  saturationFlagSetter_->setSaturationFlag(rec->back(), *i);
146 
147  // Set auxiliary flag with subset of digi information
148  // ZDC aux flag can store non-contiguous set of values
149  int auxflag = 0;
150  for (unsigned int xx = 0; xx < AuxTSvec_.size() && xx < 4; ++xx) {
151  if (AuxTSvec_[xx] < 0 || AuxTSvec_[xx] > 9)
152  continue; // don't allow
153  auxflag += (i->sample(AuxTSvec_[xx]).adc())
154  << (7 * xx); // store the time slices in the first 28 bits of aux, a set of 4 7-bit a dc values
155  }
156  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
157  if (!AuxTSvec_.empty())
158  auxflag += ((i->sample(AuxTSvec_[0]).capid()) << 28);
159  (rec->back()).setAux(auxflag);
160  }
161  // return result
162  e.put(std::move(rec));
163  } // else if (det_==DetId::Calo...)
164 
165 } // void HcalHitReconstructor::produce(...)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
std::vector< unsigned int > signalTS() const
void produce(edm::Event &e, const edm::EventSetup &c) final
HcalTopology * theTopology
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
#define nullptr
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::vector< T >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
edm::EDGetTokenT< ZDCDigiCollection > tok_input_hcal
ZDCRecHit reconstruct(const ZDCDataFrame &digi, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, const HcalCoder &coder, const HcalCalibrations &calibs) const
ZdcSimpleRecAlgo reco_
HcalOtherSubdetector subdetOther_
HcalLongRecoParams * myobject
bool dropChannel(const uint32_t &mystatus) const
void setSaturationFlag(HBHERecHit &rechit, const HBHEDataFrame &digi)
HcalADCSaturationFlag * saturationFlagSetter_
bool isValid() const
Definition: HandleBase.h:70
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)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
std::vector< int > AuxTSvec_
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
void endRun(edm::Run const &r, edm::EventSetup const &es) final
size_type size() const
T get() const
Definition: EventSetup.h:73
std::vector< unsigned int > noiseTS() const
uint32_t getValue() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void beginRun(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)
const_iterator begin() const
Definition: Run.h:45