test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  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  myobject(0),
34  theTopology(0)
35 
36 {
37  tok_input_hcal = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelhcal"));
38  tok_input_castor = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelcastor"));
39 
40  std::sort(AuxTSvec_.begin(),AuxTSvec_.end()); // sort vector in ascending TS order
41  std::string subd=conf.getParameter<std::string>("Subdetector");
42 
44  {
45  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
46  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
47  }
48  if (!strcasecmp(subd.c_str(),"ZDC")) {
51  produces<ZDCRecHitCollection>();
52  } else if (!strcasecmp(subd.c_str(),"CALIB")) {
55  produces<HcalCalibRecHitCollection>();
56  } else {
57  std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
58  }
59 
60 }
61 
63 }
65 
67  es.get<HcalLongRecoParamsRcd>().get(p);
69 
71  es.get<HcalRecNumberingRecord>().get(htopo);
72  theTopology=new HcalTopology(*htopo);
74 
75 }
76 
78  delete myobject; myobject=0;
79  delete theTopology; theTopology=0;
80 }
82 {
83  // get conditions
85  eventSetup.get<HcalDbRecord>().get(conditions);
86 
88  eventSetup.get<HcalChannelQualityRcd>().get("withTopo", p);
89  const HcalChannelQuality* myqual = p.product();
90 
92  eventSetup.get<HcalSeverityLevelComputerRcd>().get(mycomputer);
93  const HcalSeverityLevelComputer* mySeverity = mycomputer.product();
94 
95  // define vectors to pass noiseTS and signalTS
96  std::vector<unsigned int> mySignalTS;
97  std::vector<unsigned int> myNoiseTS;
98 
101  e.getByToken(tok_input_hcal,digi);
102 
103  if(digi->size() == 0) {
105  if(digi->size() == 0)
106  edm::LogInfo("ZdcHitReconstructor") << "No ZDC info found in either castorDigis or hcalDigis." << std::endl;
107  }
108 
109  // create empty output
110  std::auto_ptr<ZDCRecHitCollection> rec(new ZDCRecHitCollection);
111  rec->reserve(digi->size());
112  // run the algorithm
114  for (i=digi->begin(); i!=digi->end(); i++) {
115  HcalZDCDetId cell = i->id();
116  DetId detcell=(DetId)cell;
117  // check on cells to be ignored and dropped: (rof,20.Feb.09)
118  const HcalChannelStatus* mydigistatus=myqual->getValues(detcell.rawId());
119  if (mySeverity->dropChannel(mydigistatus->getValue() ) ) continue;
121  if (i->zsMarkAndPass()) continue;
122  const HcalCalibrations& calibrations=conditions->getHcalCalibrations(cell);
123  const HcalQIECoder* channelCoder = conditions->getHcalCoder (cell);
124  const HcalQIEShape* shape = conditions->getHcalShape (channelCoder);
125  HcalCoderDb coder (*channelCoder, *shape);
126 
127 // get db values for signalTSs and noiseTSs
128  const HcalLongRecoParam* myParams = myobject->getValues(detcell);
129  mySignalTS.clear();
130  myNoiseTS.clear();
131  mySignalTS = myParams->signalTS();
132  myNoiseTS = myParams->noiseTS();
133 
134  rec->push_back(reco_.reconstruct(*i,myNoiseTS,mySignalTS,coder,calibrations));
135  (rec->back()).setFlags(0);
137  saturationFlagSetter_->setSaturationFlag(rec->back(),*i);
138 
139  // Set auxiliary flag with subset of digi information
140  // ZDC aux flag can store non-contiguous set of values
141  int auxflag=0;
142  for (unsigned int xx=0; xx<AuxTSvec_.size() && xx<4;++xx)
143  {
144  if (AuxTSvec_[xx]<0 || AuxTSvec_[xx]>9) continue; // don't allow
145  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
146  }
147  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
148  if (AuxTSvec_.size()>0)
149  auxflag+=((i->sample(AuxTSvec_[0]).capid())<<28);
150  (rec->back()).setAux(auxflag);
151  }
152  // return result
153  e.put(rec);
154  } // else if (det_==DetId::Calo...)
155 
156 } // void HcalHitReconstructor::produce(...)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< unsigned int > signalTS() const
HcalTopology * theTopology
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< ZDCDataFrame >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
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_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
HcalOtherSubdetector subdetOther_
virtual void beginRun(edm::Run const &r, edm::EventSetup const &es) overridefinal
HcalLongRecoParams * myobject
bool dropChannel(const uint32_t &mystatus) const
void setSaturationFlag(HBHERecHit &rechit, const HBHEDataFrame &digi)
HcalADCSaturationFlag * saturationFlagSetter_
edm::EDGetTokenT< ZDCDigiCollection > tok_input_castor
Definition: DetId.h:18
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
ZdcHitReconstructor(const edm::ParameterSet &ps)
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< int > AuxTSvec_
std::vector< unsigned int > noiseTS() const
tuple cout
Definition: gather_cfg.py:145
virtual void produce(edm::Event &e, const edm::EventSetup &c) overridefinal
uint32_t getValue() const
virtual void endRun(edm::Run const &r, edm::EventSetup const &es) overridefinal
void setTopo(const HcalTopology *topo)
Definition: Run.h:43