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 
71  myobject = new HcalLongRecoParams(*p.product());
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(...)
HcalOther
Definition: HcalAssistant.h:38
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
ZdcHitReconstructor::endRun
void endRun(edm::Run const &r, edm::EventSetup const &es) final
Definition: ZdcHitReconstructor.cc:79
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
HcalCalibrations.h
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HcalLongRecoParamsRcd
Definition: HcalLongRecoParamsRcd.h:6
HcalCondObjectContainerBase::setTopo
void setTopo(const HcalTopology *topo)
Definition: HcalCondObjectContainerBase.cc:17
ESHandle.h
HcalLongRecoParam::noiseTS
std::vector< unsigned int > noiseTS() const
Definition: HcalLongRecoParam.h:27
ZdcHitReconstructor::dropZSmarkedPassed_
bool dropZSmarkedPassed_
Definition: ZdcHitReconstructor.h:64
ZdcHitReconstructor::reco_
ZdcSimpleRecAlgo reco_
Definition: ZdcHitReconstructor.h:44
HcalChannelQualityRcd
Definition: HcalChannelQualityRcd.h:8
edm::Run
Definition: Run.h:45
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HcalTopology
Definition: HcalTopology.h:26
edm::LogInfo
Definition: MessageLogger.h:254
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
AlignmentProducer_cff.calibrations
calibrations
Definition: AlignmentProducer_cff.py:59
HcalChannelQuality
Definition: HcalChannelQuality.h:17
edm::Handle
Definition: AssociativeIterator.h:50
ZdcHitReconstructor::theTopology
HcalTopology * theTopology
Definition: ZdcHitReconstructor.h:71
DetId::Calo
Definition: DetId.h:29
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
HcalDbService::getHcalShape
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:326
HcalCoderDb.h
HcalDbService::getHcalCalibrations
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:65
HcalDbService::getHcalCoder
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:319
DetId
Definition: DetId.h:17
HcalZDCDetId
Definition: HcalZDCDetId.h:16
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ZdcHitReconstructor::myobject
HcalLongRecoParams * myobject
Definition: ZdcHitReconstructor.h:70
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HcalChannelStatus
Definition: HcalChannelStatus.h:13
HcalSeverityLevelComputer
Definition: HcalSeverityLevelComputer.h:24
edm::ESHandle
Definition: DTSurvey.h:22
HcalADCSaturationFlag::setSaturationFlag
void setSaturationFlag(HBHERecHit &rechit, const HBHEDataFrame &digi)
Definition: HcalADCSaturationFlag.cc:33
HcalCalibration
Definition: HcalAssistant.h:40
HcalZDCDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
HcalDbRecord.h
HcalCalibrations
Definition: HcalCalibrations.h:9
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
HcalSeverityLevelComputer::dropChannel
bool dropChannel(const uint32_t &mystatus) const
Definition: HcalSeverityLevelComputer.cc:395
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalSeverityLevelComputerRcd.h
ZdcHitReconstructor::AuxTSvec_
std::vector< int > AuxTSvec_
Definition: ZdcHitReconstructor.h:65
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
edm::ParameterSet
Definition: ParameterSet.h:36
ZdcHitReconstructor::ZdcHitReconstructor
ZdcHitReconstructor(const edm::ParameterSet &ps)
Definition: ZdcHitReconstructor.cc:18
HcalADCSaturationFlag
Definition: HcalADCSaturationFlag.h:23
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ZdcHitReconstructor::setSaturationFlags_
bool setSaturationFlags_
Definition: ZdcHitReconstructor.h:61
ZdcHitReconstructor::beginRun
void beginRun(edm::Run const &r, edm::EventSetup const &es) final
Definition: ZdcHitReconstructor.cc:68
createfilelist.int
int
Definition: createfilelist.py:10
ZdcHitReconstructor::produce
void produce(edm::Event &e, const edm::EventSetup &c) final
Definition: ZdcHitReconstructor.cc:85
HcalLongRecoParam
Definition: HcalLongRecoParam.h:15
ZdcHitReconstructor::~ZdcHitReconstructor
~ZdcHitReconstructor() override
Definition: ZdcHitReconstructor.cc:66
edm::EventSetup
Definition: EventSetup.h:57
ZdcHitReconstructor.h
ZdcHitReconstructor::det_
DetId::Detector det_
Definition: ZdcHitReconstructor.h:52
get
#define get
ZdcHitReconstructor::subdet_
int subdet_
Definition: ZdcHitReconstructor.h:53
HcalLongRecoParam::signalTS
std::vector< unsigned int > signalTS() const
Definition: HcalLongRecoParam.h:26
HcalQIECoder
Definition: HcalQIECoder.h:20
ZdcHitReconstructor::saturationFlagSetter_
HcalADCSaturationFlag * saturationFlagSetter_
Definition: ZdcHitReconstructor.h:45
alignCSCRings.r
r
Definition: alignCSCRings.py:93
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HcalTopology.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
ZdcHitReconstructor::tok_input_castor
edm::EDGetTokenT< ZDCDigiCollection > tok_input_castor
Definition: ZdcHitReconstructor.h:56
options_cfi.eventSetup
eventSetup
Definition: options_cfi.py:12
EventSetup.h
HcalSeverityLevelComputer.h
HcalQIEShape
Definition: HcalQIEShape.h:17
HcalCoderDb
Definition: HcalCoderDb.h:15
HcalDbService.h
HcalLongRecoParams
Definition: HcalLongRecoParams.h:9
HcalDbRecord
Definition: HcalDbRecord.h:30
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
ZdcSimpleRecAlgo::reconstruct
ZDCRecHit reconstruct(const ZDCDataFrame &digi, const std::vector< unsigned int > &myNoiseTS, const std::vector< unsigned int > &mySignalTS, const HcalCoder &coder, const HcalCalibrations &calibs) const
Definition: ZdcSimpleRecAlgo.cc:265
EDCollection.h
edm::InputTag
Definition: InputTag.h:15
HcalSeverityLevelComputerRcd
Definition: HcalSeverityLevelComputerRcd.h:23
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
ZdcHitReconstructor::subdetOther_
HcalOtherSubdetector subdetOther_
Definition: ZdcHitReconstructor.h:54
ZdcHitReconstructor::tok_input_hcal
edm::EDGetTokenT< ZDCDigiCollection > tok_input_hcal
Definition: ZdcHitReconstructor.h:55
edm::SortedCollection::empty
bool empty() const
Definition: SortedCollection.h:210
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37