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 
50  {
51  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
52  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
53  }
54  if (!strcasecmp(subd.c_str(),"ZDC")) {
57  produces<ZDCRecHitCollection>();
58  } else if (!strcasecmp(subd.c_str(),"CALIB")) {
61  produces<HcalCalibRecHitCollection>();
62  } else {
63  std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
64  }
65 
66 }
67 
69 {
70  delete saturationFlagSetter_;
71 }
72 
74 
76  es.get<HcalLongRecoParamsRcd>().get(p);
78 
80  es.get<HcalRecNumberingRecord>().get(htopo);
81  theTopology=new HcalTopology(*htopo);
83 
84 }
85 
87  delete myobject; myobject=0;
88  delete theTopology; theTopology=0;
89 }
91 {
92  // get conditions
94  eventSetup.get<HcalDbRecord>().get(conditions);
95 
97  eventSetup.get<HcalChannelQualityRcd>().get("withTopo", p);
98  const HcalChannelQuality* myqual = p.product();
99 
101  eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
102  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
103 
104  // define vectors to pass noiseTS and signalTS
105  std::vector<unsigned int> mySignalTS;
106  std::vector<unsigned int> myNoiseTS;
107 
110  e.getByToken(tok_input_hcal,digi);
111 
112  if(digi->size() == 0) {
114  if(digi->size() == 0)
115  edm::LogInfo("ZdcHitReconstructor") << "No ZDC info found in either castorDigis or hcalDigis." << std::endl;
116  }
117 
118  // create empty output
119  auto rec = std::make_unique<ZDCRecHitCollection>();
120  rec->reserve(digi->size());
121  // run the algorithm
123  for (i=digi->begin(); i!=digi->end(); i++) {
124  HcalZDCDetId cell = i->id();
125  DetId detcell=(DetId)cell;
126  // check on cells to be ignored and dropped: (rof,20.Feb.09)
127  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
128  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
130  if (i->zsMarkAndPass()) continue;
131  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
132  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
133  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
134  HcalCoderDb coder (*channelCoder, *shape);
135 
136 // get db values for signalTSs and noiseTSs
137  const HcalLongRecoParam* myParams = myobject->getValues(detcell);
138  mySignalTS.clear();
139  myNoiseTS.clear();
140  mySignalTS = myParams->signalTS();
141  myNoiseTS = myParams->noiseTS();
142 
143  rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
144  (rec->back()).setFlags(0);
146  saturationFlagSetter_->setSaturationFlag(rec->back(),*i);
147 
148  // Set auxiliary flag with subset of digi information
149  // ZDC aux flag can store non-contiguous set of values
150  int auxflag=0;
151  for (unsigned int xx=0; xx<AuxTSvec_.size() && xx<4;++xx)
152  {
153  if (AuxTSvec_[xx]<0 || AuxTSvec_[xx]>9) continue; // don't allow
154  auxflag+=(i->sample(AuxTSvec_[xx]).adc())<<(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_.size()>0)
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:122
std::vector< unsigned int > signalTS() const
HcalTopology * theTopology
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
virtual void endRun(edm::Run const &r, edm::EventSetup const &es) override final
std::vector< ZDCDataFrame >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
#define nullptr
edm::EDGetTokenT< ZDCDigiCollection > tok_input_hcal
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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_
edm::EDGetTokenT< ZDCDigiCollection > tok_input_castor
const_iterator end() const
virtual void produce(edm::Event &e, const edm::EventSetup &c) override final
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
ZdcHitReconstructor(const edm::ParameterSet &ps)
const T & get() const
Definition: EventSetup.h:55
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) override final
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
std::vector< int > AuxTSvec_
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
size_type size() const
std::vector< unsigned int > noiseTS() const
uint32_t getValue() const
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)
const_iterator begin() const
Definition: Run.h:42