CMS 3D CMS Logo

CastorSimpleReconstructor.cc
Go to the documentation of this file.
19 
21 #include <iostream>
22 
23 using namespace std;
24 
26  : reco_(conf.getParameter<int>("firstSample"),
27  conf.getParameter<int>("samplesToAdd"),
28  conf.getParameter<bool>("correctForTimeslew"),
29  conf.getParameter<bool>("correctForPhaseContainment"),
30  conf.getParameter<double>("correctionPhaseNS")),
31  det_(DetId::Hcal),
32  firstSample_(conf.getParameter<int>("firstSample")),
33  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
34  maxADCvalue_(conf.getParameter<int>("maxADCvalue")),
35  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
36  setSaturationFlag_(conf.getParameter<bool>("setSaturationFlag")),
37  doSaturationCorr_(conf.getParameter<bool>("doSaturationCorr")) {
38  tok_input_ = consumes<CastorDigiCollection>(conf.getParameter<edm::InputTag>("digiLabel"));
39 
40  std::string subd = conf.getParameter<std::string>("Subdetector");
41  if (!strcasecmp(subd.c_str(), "CASTOR")) {
42  det_ = DetId::Calo;
44  produces<CastorRecHitCollection>();
45  } else {
46  edm::LogWarning("CastorSimpleReconstructor")
47  << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
48  }
49 }
50 
52 
54  // get conditions
56  eventSetup.get<CastorDbRecord>().get(conditions);
57  const CastorQIEShape* shape = conditions->getCastorShape(); // this one is generic
58 
60 
61  // try to get the TS windows from the db
63  if (tsFromDB_) {
64  eventSetup.get<CastorRecoParamsRcd>().get(recoparams);
65  if (!recoparams.isValid()) {
66  tsFromDB_ = false;
67  edm::LogWarning("CastorSimpleReconstructor")
68  << "Could not handle the CastorRecoParamsRcd correctly, using parameters from cfg file from this event "
69  "onwards... These parameters could be wrong for this run... please check"
70  << std::endl;
71  }
72  }
73 
74  // try to get the saturation correction constants from the db
76  if (doSaturationCorr_) {
77  eventSetup.get<CastorSaturationCorrsRcd>().get(satcorr);
78  if (!satcorr.isValid()) {
79  doSaturationCorr_ = false;
80  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorSaturationCorrsRcd correctly. We'll "
81  "not try the saturation correction from this event onwards..."
82  << std::endl;
83  }
84  }
85 
88  e.getByToken(tok_input_, digi);
89 
90  // create empty output
91  auto rec = std::make_unique<CastorRecHitCollection>();
92  // run the algorithm
94  for (i = digi->begin(); i != digi->end(); i++) {
95  HcalCastorDetId cell = i->id();
96  DetId detcell = (DetId)cell;
97  const CastorCalibrations& calibrations = conditions->getCastorCalibrations(cell);
98 
99  if (tsFromDB_) {
100  const CastorRecoParam* param_ts = recoparams->getValues(detcell.rawId());
101  reco_.resetTimeSamples(param_ts->firstSample(), param_ts->samplesToAdd());
102  }
103  const CastorQIECoder* channelCoder = conditions->getCastorCoder(cell);
104  CastorCoderDb coder(*channelCoder, *shape);
105 
106  // reconstruct the rechit
107  rec->push_back(reco_.reconstruct(*i, coder, calibrations));
108 
109  // set the saturation flag if needed
110  if (setSaturationFlag_) {
111  reco_.checkADCSaturation(rec->back(), *i, maxADCvalue_);
112 
113  //++++ Saturation Correction +++++
114  if (doSaturationCorr_ && rec->back().flagField(HcalCaloFlagLabels::ADCSaturationBit)) {
115  // get saturation correction value
116  const CastorSaturationCorr* saturationCorr = satcorr->getValues(detcell.rawId());
117  double satCorrConst = 1.;
118  satCorrConst = saturationCorr->getValue();
119  reco_.recoverADCSaturation(rec->back(), coder, calibrations, *i, maxADCvalue_, satCorrConst);
120  }
121  }
122  }
123  // return result
124  e.put(std::move(rec));
125  }
126 }
CastorChannelQualityRcd.h
Handle.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
CastorCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: CastorCondObjectContainer.h:65
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
ESHandle.h
CastorSaturationCorr::getValue
float getValue() const
Definition: CastorSaturationCorr.h:21
CastorSaturationCorrsRcd
Definition: CastorSaturationCorrsRcd.h:4
CastorDbService::getCastorCalibrations
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
Definition: CastorDbService.h:32
CastorSimpleRecAlgo::reconstruct
CastorRecHit reconstruct(const CastorDataFrame &digi, const CastorCoder &coder, const CastorCalibrations &calibs) const
Definition: CastorSimpleRecAlgo.cc:163
CastorDbService::getCastorCoder
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:169
AlignmentProducer_cff.calibrations
calibrations
Definition: AlignmentProducer_cff.py:59
HcalCastorDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalCastorDetId.h:28
CastorCoderDb
Definition: CastorCoderDb.h:16
edm::Handle
Definition: AssociativeIterator.h:50
DetId::Calo
Definition: DetId.h:29
CastorRecoParam
Definition: CastorRecoParam.h:13
HcalCaloFlagLabels::ADCSaturationBit
Definition: HcalCaloFlagLabels.h:53
DetId
Definition: DetId.h:17
CastorCalibrations
Definition: CastorCalibrations.h:9
CastorRecoParams.h
CastorSimpleReconstructor::produce
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: CastorSimpleReconstructor.cc:53
CastorChannelStatus.h
CastorCalibrations.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
CastorSimpleReconstructor::~CastorSimpleReconstructor
~CastorSimpleReconstructor() override
Definition: CastorSimpleReconstructor.cc:51
CastorSimpleReconstructor::CastorSimpleReconstructor
CastorSimpleReconstructor(const edm::ParameterSet &ps)
Definition: CastorSimpleReconstructor.cc:25
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
edm::ESHandle
Definition: DTSurvey.h:22
CastorSimpleReconstructor::tok_input_
edm::EDGetTokenT< CastorDigiCollection > tok_input_
Definition: CastorSimpleReconstructor.h:25
CastorRecoParamsRcd
Definition: CastorRecoParamsRcd.h:4
CastorSimpleReconstructor::maxADCvalue_
int maxADCvalue_
Definition: CastorSimpleReconstructor.h:29
CastorSimpleRecAlgo::recoverADCSaturation
void recoverADCSaturation(CastorRecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const CastorDataFrame &digi, const int &maxADCvalue, const double &satCorrConst) const
Definition: CastorSimpleRecAlgo.cc:178
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalCastorDetId
Definition: HcalCastorDetId.h:23
CastorSimpleReconstructor.h
edm::LogWarning
Definition: MessageLogger.h:141
CastorDbService::getCastorShape
const CastorQIEShape * getCastorShape() const
Definition: CastorDbService.cc:176
CastorSimpleReconstructor::setSaturationFlag_
bool setSaturationFlag_
Definition: CastorSimpleReconstructor.h:31
edm::ParameterSet
Definition: ParameterSet.h:36
HcalCaloFlagLabels.h
CastorRecoParamsRcd.h
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
CastorSaturationCorrs.h
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:57
CastorSimpleReconstructor::doSaturationCorr_
bool doSaturationCorr_
Definition: CastorSimpleReconstructor.h:32
get
#define get
CastorSimpleReconstructor::tsFromDB_
bool tsFromDB_
Definition: CastorSimpleReconstructor.h:30
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
CastorSimpleReconstructor::reco_
CastorSimpleRecAlgo reco_
Definition: CastorSimpleReconstructor.h:21
CastorSimpleRecAlgo::resetTimeSamples
void resetTimeSamples(int f, int t)
Definition: CastorSimpleRecAlgo.h:46
CastorDbRecord
Definition: CastorDbRecord.h:29
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
CastorCoderDb.h
CastorSaturationCorr
Definition: CastorSaturationCorr.h:13
EventSetup.h
HcalRecHitCollections.h
CastorDbService.h
CastorQIECoder
Definition: CastorQIECoder.h:21
CastorChannelQuality.h
CastorRecoParam::firstSample
unsigned int firstSample() const
Definition: CastorRecoParam.h:22
CastorSimpleRecAlgo::checkADCSaturation
void checkADCSaturation(CastorRecHit &rechit, const CastorDataFrame &digi, const int &maxADCvalue) const
Definition: CastorSimpleRecAlgo.cc:170
edm::Event
Definition: Event.h:73
CastorSimpleReconstructor::subdet_
int subdet_
Definition: CastorSimpleReconstructor.h:23
EDCollection.h
CastorDbRecord.h
edm::InputTag
Definition: InputTag.h:15
CastorQIEShape
Definition: CastorQIEShape.h:14
CastorSimpleReconstructor::det_
DetId::Detector det_
Definition: CastorSimpleReconstructor.h:22
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
CastorRecoParam::samplesToAdd
unsigned int samplesToAdd() const
Definition: CastorRecoParam.h:23
CastorSaturationCorrsRcd.h