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=nullptr;
88  delete theTopology; theTopology=nullptr;
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->empty()) {
113  edm::Handle<ZDCDigiCollection> digi_castor;
114  e.getByToken(tok_input_castor,digi_castor);
115  if(!digi_castor.isValid() || digi_castor->empty())
116  edm::LogInfo("ZdcHitReconstructor") << "No ZDC info found in either castorDigis or hcalDigis." << std::endl;
117  if(digi_castor.isValid())
119  }
120 
121  // create empty output
122  auto rec = std::make_unique<ZDCRecHitCollection>();
123  rec->reserve(digi->size());
124  // run the algorithm
126  for (i=digi->begin(); i!=digi->end(); i++) {
127  HcalZDCDetId cell = i->id();
128  DetId detcell=(DetId)cell;
129  // check on cells to be ignored and dropped: (rof,20.Feb.09)
130  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
131  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
133  if (i->zsMarkAndPass()) continue;
134  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
135  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
136  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
137  HcalCoderDb coder (*channelCoder, *shape);
138 
139 // get db values for signalTSs and noiseTSs
140  const HcalLongRecoParam* myParams = myobject->getValues(detcell);
141  mySignalTS.clear();
142  myNoiseTS.clear();
143  mySignalTS = myParams->signalTS();
144  myNoiseTS = myParams->noiseTS();
145 
146  rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
147  (rec->back()).setFlags(0);
149  saturationFlagSetter_->setSaturationFlag(rec->back(),*i);
150 
151  // Set auxiliary flag with subset of digi information
152  // ZDC aux flag can store non-contiguous set of values
153  int auxflag=0;
154  for (unsigned int xx=0; xx<AuxTSvec_.size() && xx<4;++xx)
155  {
156  if (AuxTSvec_[xx]<0 || AuxTSvec_[xx]>9) continue; // don't allow
157  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
158  }
159  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
160  if (!AuxTSvec_.empty())
161  auxflag+=((i->sample(AuxTSvec_[0]).capid())<<28);
162  (rec->back()).setAux(auxflag);
163  }
164  // return result
165  e.put(std::move(rec));
166  } // else if (det_==DetId::Calo...)
167 
168 } // void HcalHitReconstructor::produce(...)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
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:519
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:44
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:74
edm::EDGetTokenT< ZDCDigiCollection > tok_input_castor
const_iterator end() const
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
ZdcHitReconstructor(const edm::ParameterSet &ps)
const T & get() const
Definition: EventSetup.h:59
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
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:510
void setTopo(const HcalTopology *topo)
const_iterator begin() const
Definition: Run.h:43