CMS 3D CMS Logo

ZdcHitReconstructor.cc
Go to the documentation of this file.
1 #include "ZdcHitReconstructor.h"
12 
13 #include <iostream>
14 
15 /* Zdc Hit reconstructor allows for CaloRecHits with status words */
16 
18  : reco_(conf.getParameter<bool>("correctForTimeslew"),
19  conf.getParameter<bool>("correctForPhaseContainment"),
20  conf.getParameter<double>("correctionPhaseNS"),
21  conf.getParameter<int>("recoMethod"),
22  conf.getParameter<int>("lowGainOffset"),
23  conf.getParameter<double>("lowGainFrac")),
24  saturationFlagSetter_(nullptr),
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  tok_input_hcal = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelhcal"));
34  tok_input_castor = consumes<ZDCDigiCollection>(conf.getParameter<edm::InputTag>("digiLabelcastor"));
35 
36  std::sort(AuxTSvec_.begin(), AuxTSvec_.end()); // sort vector in ascending TS order
37  std::string subd = conf.getParameter<std::string>("Subdetector");
38 
39  if (setSaturationFlags_) {
40  const edm::ParameterSet& pssat = conf.getParameter<edm::ParameterSet>("saturationParameters");
41  saturationFlagSetter_ = new HcalADCSaturationFlag(pssat.getParameter<int>("maxADCvalue"));
42  }
43  if (!strcasecmp(subd.c_str(), "ZDC")) {
44  det_ = DetId::Calo;
46  produces<ZDCRecHitCollection>();
47  } else if (!strcasecmp(subd.c_str(), "CALIB")) {
50  produces<HcalCalibRecHitCollection>();
51  } else {
52  std::cout << "ZdcHitReconstructor is not associated with a specific subdetector!" << std::endl;
53  }
54 
55  // ES tokens
56  htopoToken_ = esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun>();
57  paramsToken_ = esConsumes<HcalLongRecoParams, HcalLongRecoParamsRcd, edm::Transition::BeginRun>();
58  conditionsToken_ = esConsumes<HcalDbService, HcalDbRecord>();
59  qualToken_ = esConsumes<HcalChannelQuality, HcalChannelQualityRcd>(edm::ESInputTag("", "withTopo"));
60  sevToken_ = esConsumes<HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd>();
61 }
62 
64 
66  const HcalTopology& htopo = es.getData(htopoToken_);
68  longRecoParams_ = std::make_unique<HcalLongRecoParams>(p);
69  longRecoParams_->setTopo(&htopo);
70 }
71 
73 
75  // get conditions
76  const HcalDbService* conditions = &eventSetup.getData(conditionsToken_);
77  const HcalChannelQuality* myqual = &eventSetup.getData(qualToken_);
78  const HcalSeverityLevelComputer* mySeverity = &eventSetup.getData(sevToken_);
79 
80  // define vectors to pass noiseTS and signalTS
81  std::vector<unsigned int> mySignalTS;
82  std::vector<unsigned int> myNoiseTS;
83 
86  e.getByToken(tok_input_hcal, digi);
87 
88  if (digi->empty()) {
90  e.getByToken(tok_input_castor, digi_castor);
91  if (!digi_castor.isValid() || digi_castor->empty())
92  edm::LogInfo("ZdcHitReconstructor") << "No ZDC info found in either castorDigis or hcalDigis." << std::endl;
93  if (digi_castor.isValid())
94  e.getByToken(tok_input_castor, digi);
95  }
96 
97  // create empty output
98  auto rec = std::make_unique<ZDCRecHitCollection>();
99  rec->reserve(digi->size());
100  // run the algorithm
102  for (i = digi->begin(); i != digi->end(); i++) {
103  HcalZDCDetId cell = i->id();
104  DetId detcell = (DetId)cell;
105  // check on cells to be ignored and dropped: (rof,20.Feb.09)
106  const HcalChannelStatus* mydigistatus = myqual->getValues(detcell.rawId());
107  if (mySeverity->dropChannel(mydigistatus->getValue()))
108  continue;
110  if (i->zsMarkAndPass())
111  continue;
112  const HcalCalibrations& calibrations = conditions->getHcalCalibrations(cell);
113  const HcalQIECoder* channelCoder = conditions->getHcalCoder(cell);
114  const HcalQIEShape* shape = conditions->getHcalShape(channelCoder);
115  HcalCoderDb coder(*channelCoder, *shape);
116 
117  // get db values for signalTSs and noiseTSs
118  const HcalLongRecoParam* myParams = longRecoParams_->getValues(detcell);
119  mySignalTS.clear();
120  myNoiseTS.clear();
121  mySignalTS = myParams->signalTS();
122  myNoiseTS = myParams->noiseTS();
123 
124  rec->push_back(reco_.reconstruct(*i, myNoiseTS, mySignalTS, coder, calibrations));
125  (rec->back()).setFlags(0);
127  saturationFlagSetter_->setSaturationFlag(rec->back(), *i);
128 
129  // Set auxiliary flag with subset of digi information
130  // ZDC aux flag can store non-contiguous set of values
131  int auxflag = 0;
132  for (unsigned int xx = 0; xx < AuxTSvec_.size() && xx < 4; ++xx) {
133  if (AuxTSvec_[xx] < 0 || AuxTSvec_[xx] > 9)
134  continue; // don't allow
135  auxflag += (i->sample(AuxTSvec_[xx]).adc())
136  << (7 * xx); // store the time slices in the first 28 bits of aux, a set of 4 7-bit a dc values
137  }
138  // bits 28 and 29 are reserved for capid of the first time slice saved in aux
139  if (!AuxTSvec_.empty())
140  auxflag += ((i->sample(AuxTSvec_[0]).capid()) << 28);
141  (rec->back()).setAux(auxflag);
142  }
143  // return result
144  e.put(std::move(rec));
145  } // else if (det_==DetId::Calo...)
146 
147 } // void HcalHitReconstructor::produce(...)
HcalOther
Definition: HcalAssistant.h:38
ZdcHitReconstructor::htopoToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
Definition: ZdcHitReconstructor.h:80
ZdcHitReconstructor::endRun
void endRun(edm::Run const &r, edm::EventSetup const &es) final
Definition: ZdcHitReconstructor.cc:72
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
HcalCalibrations.h
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
ZdcHitReconstructor::longRecoParams_
std::unique_ptr< HcalLongRecoParams > longRecoParams_
Definition: ZdcHitReconstructor.h:77
HcalLongRecoParam::noiseTS
std::vector< unsigned int > noiseTS() const
Definition: HcalLongRecoParam.h:27
ZdcHitReconstructor::dropZSmarkedPassed_
bool dropZSmarkedPassed_
Definition: ZdcHitReconstructor.h:70
ZdcHitReconstructor::reco_
ZdcSimpleRecAlgo reco_
Definition: ZdcHitReconstructor.h:55
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::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
DetId::Calo
Definition: DetId.h:29
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
HcalCoderDb.h
ZdcHitReconstructor::paramsToken_
edm::ESGetToken< HcalLongRecoParams, HcalLongRecoParamsRcd > paramsToken_
Definition: ZdcHitReconstructor.h:81
ZdcHitReconstructor::sevToken_
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > sevToken_
Definition: ZdcHitReconstructor.h:84
DetId
Definition: DetId.h:17
HcalZDCDetId
Definition: HcalZDCDetId.h:16
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HcalChannelStatus
Definition: HcalChannelStatus.h:13
HcalSeverityLevelComputer
Definition: HcalSeverityLevelComputer.h:24
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
ZdcHitReconstructor::conditionsToken_
edm::ESGetToken< HcalDbService, HcalDbRecord > conditionsToken_
Definition: ZdcHitReconstructor.h:82
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:71
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
edm::ParameterSet
Definition: ParameterSet.h:47
ZdcHitReconstructor::ZdcHitReconstructor
ZdcHitReconstructor(const edm::ParameterSet &ps)
Definition: ZdcHitReconstructor.cc:17
HcalADCSaturationFlag
Definition: HcalADCSaturationFlag.h:23
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ZdcHitReconstructor::setSaturationFlags_
bool setSaturationFlags_
Definition: ZdcHitReconstructor.h:67
ZdcHitReconstructor::qualToken_
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualToken_
Definition: ZdcHitReconstructor.h:83
ZdcHitReconstructor::beginRun
void beginRun(edm::Run const &r, edm::EventSetup const &es) final
Definition: ZdcHitReconstructor.cc:65
createfilelist.int
int
Definition: createfilelist.py:10
ZdcHitReconstructor::produce
void produce(edm::Event &e, const edm::EventSetup &c) final
Definition: ZdcHitReconstructor.cc:74
HcalLongRecoParam
Definition: HcalLongRecoParam.h:15
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
ZdcHitReconstructor::~ZdcHitReconstructor
~ZdcHitReconstructor() override
Definition: ZdcHitReconstructor.cc:63
edm::EventSetup
Definition: EventSetup.h:57
ZdcHitReconstructor.h
ZdcHitReconstructor::det_
DetId::Detector det_
Definition: ZdcHitReconstructor.h:58
ZdcHitReconstructor::subdet_
int subdet_
Definition: ZdcHitReconstructor.h:59
HcalLongRecoParam::signalTS
std::vector< unsigned int > signalTS() const
Definition: HcalLongRecoParam.h:26
HcalQIECoder
Definition: HcalQIECoder.h:20
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
ZdcHitReconstructor::saturationFlagSetter_
HcalADCSaturationFlag * saturationFlagSetter_
Definition: ZdcHitReconstructor.h:56
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HcalTopology.h
HcalDbService
Definition: HcalDbService.h:26
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
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:62
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalSeverityLevelComputer.h
HcalQIEShape
Definition: HcalQIEShape.h:17
HcalCoderDb
Definition: HcalCoderDb.h:15
HcalDbService.h
HcalLongRecoParams
Definition: HcalLongRecoParams.h:9
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
edm::Log
Definition: MessageLogger.h:70
EDCollection.h
edm::InputTag
Definition: InputTag.h:15
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
ZdcHitReconstructor::subdetOther_
HcalOtherSubdetector subdetOther_
Definition: ZdcHitReconstructor.h:60
ZdcHitReconstructor::tok_input_hcal
edm::EDGetTokenT< ZDCDigiCollection > tok_input_hcal
Definition: ZdcHitReconstructor.h:61
edm::SortedCollection::empty
bool empty() const
Definition: SortedCollection.h:210
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37