CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CastorSimpleReconstructor Class Reference
Inheritance diagram for CastorSimpleReconstructor:
edm::stream::EDProducer<>

Public Member Functions

 CastorSimpleReconstructor (const edm::ParameterSet &ps)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
 ~CastorSimpleReconstructor () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

DetId::Detector det_
 
bool doSaturationCorr_
 
int firstSample_
 
int maxADCvalue_
 
CastorSimpleRecAlgo reco_
 
int samplesToAdd_
 
bool setSaturationFlag_
 
int subdet_
 
edm::ESGetToken< CastorDbService, CastorDbRecordtok_conditions_
 
edm::EDGetTokenT< CastorDigiCollectiontok_input_
 
edm::ESGetToken< CastorRecoParams, CastorRecoParamsRcdtok_recoParams_
 
edm::ESGetToken< CastorSaturationCorrs, CastorSaturationCorrsRcdtok_satCorr_
 
bool tsFromDB_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 28 of file CastorSimpleReconstructor.cc.

Constructor & Destructor Documentation

◆ CastorSimpleReconstructor()

CastorSimpleReconstructor::CastorSimpleReconstructor ( const edm::ParameterSet ps)
explicit

Definition at line 57 of file CastorSimpleReconstructor.cc.

References DetId::Calo, det_, doSaturationCorr_, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, subdet_, HcalCastorDetId::SubdetectorId, tok_conditions_, tok_input_, tok_recoParams_, tok_satCorr_, and tsFromDB_.

58  : reco_(conf.getParameter<int>("firstSample"),
59  conf.getParameter<int>("samplesToAdd"),
60  conf.getParameter<bool>("correctForTimeslew"),
61  conf.getParameter<bool>("correctForPhaseContainment"),
62  conf.getParameter<double>("correctionPhaseNS")),
64  firstSample_(conf.getParameter<int>("firstSample")),
65  samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
66  maxADCvalue_(conf.getParameter<int>("maxADCvalue")),
67  tsFromDB_(conf.getParameter<bool>("tsFromDB")),
68  setSaturationFlag_(conf.getParameter<bool>("setSaturationFlag")),
69  doSaturationCorr_(conf.getParameter<bool>("doSaturationCorr")) {
70  tok_input_ = consumes<CastorDigiCollection>(conf.getParameter<edm::InputTag>("digiLabel"));
71  tok_conditions_ = esConsumes<CastorDbService, CastorDbRecord>();
72 
73  std::string subd = conf.getParameter<std::string>("Subdetector");
74  if (!strcasecmp(subd.c_str(), "CASTOR")) {
75  det_ = DetId::Calo;
77  produces<CastorRecHitCollection>();
78  } else {
79  edm::LogWarning("CastorSimpleReconstructor")
80  << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
81  }
82  if (tsFromDB_) {
83  tok_recoParams_ = esConsumes<CastorRecoParams, CastorRecoParamsRcd>();
84  }
85  if (doSaturationCorr_) {
86  tok_satCorr_ = esConsumes<CastorSaturationCorrs, CastorSaturationCorrsRcd>();
87  }
88 }
edm::ESGetToken< CastorSaturationCorrs, CastorSaturationCorrsRcd > tok_satCorr_
edm::EDGetTokenT< CastorDigiCollection > tok_input_
static const int SubdetectorId
edm::ESGetToken< CastorRecoParams, CastorRecoParamsRcd > tok_recoParams_
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_conditions_
Log< level::Warning, false > LogWarning

◆ ~CastorSimpleReconstructor()

CastorSimpleReconstructor::~CastorSimpleReconstructor ( )
override

Definition at line 90 of file CastorSimpleReconstructor.cc.

90 {}

Member Function Documentation

◆ produce()

void CastorSimpleReconstructor::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 92 of file CastorSimpleReconstructor.cc.

References HcalCaloFlagLabels::ADCSaturationBit, edm::SortedCollection< T, SORT >::begin(), AlignmentProducer_cff::calibrations, DetId::Calo, CastorSimpleRecAlgo::checkADCSaturation(), submitPVValidationJobs::conditions, det_, doSaturationCorr_, MillePedeFileConverter_cfg::e, edm::SortedCollection< T, SORT >::end(), options_cfi::eventSetup, CastorRecoParam::firstSample(), CastorSaturationCorr::getValue(), CastorCondObjectContainer< Item >::getValues(), mps_fire::i, edm::ESHandleBase::isValid(), maxADCvalue_, eostools::move(), DetId::rawId(), reco_, CastorSimpleRecAlgo::reconstruct(), CastorSimpleRecAlgo::recoverADCSaturation(), CastorSimpleRecAlgo::resetTimeSamples(), CastorRecoParam::samplesToAdd(), setSaturationFlag_, subdet_, HcalCastorDetId::SubdetectorId, tok_conditions_, tok_input_, tok_recoParams_, tok_satCorr_, and tsFromDB_.

92  {
93  // get conditions
95  const CastorQIEShape* shape = conditions->getCastorShape(); // this one is generic
96 
98 
99  // try to get the TS windows from the db
101  if (tsFromDB_) {
102  recoparams = eventSetup.getHandle(tok_recoParams_);
103  if (!recoparams.isValid()) {
104  tsFromDB_ = false;
105  edm::LogWarning("CastorSimpleReconstructor")
106  << "Could not handle the CastorRecoParamsRcd correctly, using parameters from cfg file from this event "
107  "onwards... These parameters could be wrong for this run... please check"
108  << std::endl;
109  }
110  }
111 
112  // try to get the saturation correction constants from the db
114  if (doSaturationCorr_) {
115  satcorr = eventSetup.getHandle(tok_satCorr_);
116  if (!satcorr.isValid()) {
117  doSaturationCorr_ = false;
118  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorSaturationCorrsRcd correctly. We'll "
119  "not try the saturation correction from this event onwards..."
120  << std::endl;
121  }
122  }
123 
126  e.getByToken(tok_input_, digi);
127 
128  // create empty output
129  auto rec = std::make_unique<CastorRecHitCollection>();
130  // run the algorithm
132  for (i = digi->begin(); i != digi->end(); i++) {
133  HcalCastorDetId cell = i->id();
134  DetId detcell = (DetId)cell;
135  const CastorCalibrations& calibrations = conditions->getCastorCalibrations(cell);
136 
137  if (tsFromDB_) {
138  const CastorRecoParam* param_ts = recoparams->getValues(detcell.rawId());
139  reco_.resetTimeSamples(param_ts->firstSample(), param_ts->samplesToAdd());
140  }
141  const CastorQIECoder* channelCoder = conditions->getCastorCoder(cell);
142  CastorCoderDb coder(*channelCoder, *shape);
143 
144  // reconstruct the rechit
145  rec->push_back(reco_.reconstruct(*i, coder, calibrations));
146 
147  // set the saturation flag if needed
148  if (setSaturationFlag_) {
149  reco_.checkADCSaturation(rec->back(), *i, maxADCvalue_);
150 
151  //++++ Saturation Correction +++++
152  if (doSaturationCorr_ && rec->back().flagField(HcalCaloFlagLabels::ADCSaturationBit)) {
153  // get saturation correction value
154  const CastorSaturationCorr* saturationCorr = satcorr->getValues(detcell.rawId());
155  double satCorrConst = 1.;
156  satCorrConst = saturationCorr->getValue();
157  reco_.recoverADCSaturation(rec->back(), coder, calibrations, *i, maxADCvalue_, satCorrConst);
158  }
159  }
160  }
161  // return result
162  e.put(std::move(rec));
163  }
164 }
void resetTimeSamples(int f, int t)
const Item * getValues(DetId fId, bool throwOnFail=true) const
void recoverADCSaturation(CastorRecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const CastorDataFrame &digi, const int &maxADCvalue, const double &satCorrConst) const
std::vector< T >::const_iterator const_iterator
edm::ESGetToken< CastorSaturationCorrs, CastorSaturationCorrsRcd > tok_satCorr_
unsigned int samplesToAdd() const
unsigned int firstSample() const
edm::EDGetTokenT< CastorDigiCollection > tok_input_
const_iterator begin() const
static const int SubdetectorId
bool isValid() const
Definition: ESHandle.h:44
const_iterator end() const
edm::ESGetToken< CastorRecoParams, CastorRecoParamsRcd > tok_recoParams_
Definition: DetId.h:17
edm::ESGetToken< CastorDbService, CastorDbRecord > tok_conditions_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void checkADCSaturation(CastorRecHit &rechit, const CastorDataFrame &digi, const int &maxADCvalue) const
CastorRecHit reconstruct(const CastorDataFrame &digi, const CastorCoder &coder, const CastorCalibrations &calibs) const
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ det_

DetId::Detector CastorSimpleReconstructor::det_
private

Definition at line 36 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ doSaturationCorr_

bool CastorSimpleReconstructor::doSaturationCorr_
private

Definition at line 49 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ firstSample_

int CastorSimpleReconstructor::firstSample_
private

Definition at line 44 of file CastorSimpleReconstructor.cc.

◆ maxADCvalue_

int CastorSimpleReconstructor::maxADCvalue_
private

Definition at line 46 of file CastorSimpleReconstructor.cc.

Referenced by produce().

◆ reco_

CastorSimpleRecAlgo CastorSimpleReconstructor::reco_
private

Definition at line 35 of file CastorSimpleReconstructor.cc.

Referenced by produce().

◆ samplesToAdd_

int CastorSimpleReconstructor::samplesToAdd_
private

Definition at line 45 of file CastorSimpleReconstructor.cc.

◆ setSaturationFlag_

bool CastorSimpleReconstructor::setSaturationFlag_
private

Definition at line 48 of file CastorSimpleReconstructor.cc.

Referenced by produce().

◆ subdet_

int CastorSimpleReconstructor::subdet_
private

Definition at line 37 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ tok_conditions_

edm::ESGetToken<CastorDbService, CastorDbRecord> CastorSimpleReconstructor::tok_conditions_
private

Definition at line 40 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ tok_input_

edm::EDGetTokenT<CastorDigiCollection> CastorSimpleReconstructor::tok_input_
private

Definition at line 39 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ tok_recoParams_

edm::ESGetToken<CastorRecoParams, CastorRecoParamsRcd> CastorSimpleReconstructor::tok_recoParams_
private

Definition at line 41 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ tok_satCorr_

edm::ESGetToken<CastorSaturationCorrs, CastorSaturationCorrsRcd> CastorSimpleReconstructor::tok_satCorr_
private

Definition at line 42 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().

◆ tsFromDB_

bool CastorSimpleReconstructor::tsFromDB_
private

Definition at line 47 of file CastorSimpleReconstructor.cc.

Referenced by CastorSimpleReconstructor(), and produce().