CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CastorSimpleReconstructor Class Reference

#include <CastorSimpleReconstructor.h>

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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

DetId::Detector det_
 
bool doSaturationCorr_
 
int firstSample_
 
int maxADCvalue_
 
CastorSimpleRecAlgo reco_
 
int samplesToAdd_
 
bool setSaturationFlag_
 
int subdet_
 
edm::EDGetTokenT< CastorDigiCollectiontok_input_
 
bool tsFromDB_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 14 of file CastorSimpleReconstructor.h.

Constructor & Destructor Documentation

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

Definition at line 25 of file CastorSimpleReconstructor.cc.

References DetId::Calo, det_, edm::ParameterSet::getParameter(), AlCaHLTBitMon_QueryRunRegistry::string, subdet_, HcalCastorDetId::SubdetectorId, and tok_input_.

25  :
26 reco_(conf.getParameter<int>("firstSample"),conf.getParameter<int>("samplesToAdd"),conf.getParameter<bool>("correctForTimeslew"),
27  conf.getParameter<bool>("correctForPhaseContainment"),conf.getParameter<double>("correctionPhaseNS")),
29 firstSample_(conf.getParameter<int>("firstSample")),
30 samplesToAdd_(conf.getParameter<int>("samplesToAdd")),
31 maxADCvalue_(conf.getParameter<int>("maxADCvalue")),
32 tsFromDB_(conf.getParameter<bool>("tsFromDB")),
33 setSaturationFlag_(conf.getParameter<bool>("setSaturationFlag")),
34 doSaturationCorr_(conf.getParameter<bool>("doSaturationCorr"))
35 {
36 
37  tok_input_ = consumes<CastorDigiCollection>(conf.getParameter<edm::InputTag>("digiLabel"));
38 
39  std::string subd=conf.getParameter<std::string>("Subdetector");
40  if (!strcasecmp(subd.c_str(),"CASTOR")) {
43  produces<CastorRecHitCollection>();
44  } else {
45  edm::LogWarning("CastorSimpleReconstructor") << "CastorSimpleReconstructor is not associated with CASTOR subdetector!" << std::endl;
46  }
47 
48 }
edm::EDGetTokenT< CastorDigiCollection > tok_input_
static const int SubdetectorId
CastorSimpleReconstructor::~CastorSimpleReconstructor ( )
override

Definition at line 50 of file CastorSimpleReconstructor.cc.

50  {
51 }

Member Function Documentation

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

Definition at line 53 of file CastorSimpleReconstructor.cc.

References HcalCaloFlagLabels::ADCSaturationBit, edm::SortedCollection< T, SORT >::begin(), AlignmentProducer_cff::calibrations, DetId::Calo, CastorSimpleRecAlgo::checkADCSaturation(), det_, doSaturationCorr_, edm::SortedCollection< T, SORT >::end(), CastorRecoParam::firstSample(), edm::EventSetup::get(), edm::Event::getByToken(), CastorDbService::getCastorCalibrations(), CastorDbService::getCastorCoder(), CastorDbService::getCastorShape(), CastorSaturationCorr::getValue(), CastorCondObjectContainer< Item >::getValues(), mps_fire::i, edm::ESHandleBase::isValid(), maxADCvalue_, eostools::move(), edm::Event::put(), DetId::rawId(), reco_, CastorSimpleRecAlgo::reconstruct(), CastorSimpleRecAlgo::recoverADCSaturation(), CastorSimpleRecAlgo::resetTimeSamples(), CastorRecoParam::samplesToAdd(), setSaturationFlag_, subdet_, HcalCastorDetId::SubdetectorId, tok_input_, and tsFromDB_.

54 {
55  // get conditions
57  eventSetup.get<CastorDbRecord>().get(conditions);
58  const CastorQIEShape* shape = conditions->getCastorShape (); // this one is generic
59 
61 
62  // try to get the TS windows from the db
64  if (tsFromDB_) {
65  eventSetup.get<CastorRecoParamsRcd>().get(recoparams);
66  if (!recoparams.isValid()) {
67  tsFromDB_ = false;
68  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorRecoParamsRcd correctly, using parameters from cfg file from this event onwards... These parameters could be wrong for this run... please check" << std::endl;
69  }
70  }
71 
72  // try to get the saturation correction constants from the db
74  if (doSaturationCorr_) {
75  eventSetup.get<CastorSaturationCorrsRcd>().get(satcorr);
76  if (!satcorr.isValid()) {
77  doSaturationCorr_ = false;
78  edm::LogWarning("CastorSimpleReconstructor") << "Could not handle the CastorSaturationCorrsRcd correctly. We'll not try the saturation correction from this event onwards..." << std::endl;
79  }
80  }
81 
82 
85  e.getByToken(tok_input_,digi);
86 
87  // create empty output
88  auto rec = std::make_unique<CastorRecHitCollection>();
89  // run the algorithm
91  for (i=digi->begin(); i!=digi->end(); i++) {
92  HcalCastorDetId cell = i->id();
93  DetId detcell=(DetId)cell;
94  const CastorCalibrations& calibrations=conditions->getCastorCalibrations(cell);
95 
96  if (tsFromDB_) {
97  const CastorRecoParam* param_ts = recoparams->getValues(detcell.rawId());
98  reco_.resetTimeSamples(param_ts->firstSample(),param_ts->samplesToAdd());
99  }
100  const CastorQIECoder* channelCoder = conditions->getCastorCoder (cell);
101  CastorCoderDb coder (*channelCoder, *shape);
102 
103  // reconstruct the rechit
104  rec->push_back(reco_.reconstruct(*i,coder,calibrations));
105 
106  // set the saturation flag if needed
107  if (setSaturationFlag_) {
108  reco_.checkADCSaturation(rec->back(),*i,maxADCvalue_);
109 
110  //++++ Saturation Correction +++++
111  if (doSaturationCorr_ && rec->back().flagField(HcalCaloFlagLabels::ADCSaturationBit)) {
112  // get saturation correction value
113  const CastorSaturationCorr* saturationCorr = satcorr->getValues(detcell.rawId());
114  double satCorrConst = 1.;
115  satCorrConst = saturationCorr->getValue();
116  reco_.recoverADCSaturation(rec->back(),coder,calibrations,*i,maxADCvalue_,satCorrConst);
117  }
118  }
119  }
120  // return result
121  e.put(std::move(rec));
122  }
123 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void resetTimeSamples(int f, int t)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
std::vector< T >::const_iterator const_iterator
const CastorCalibrations & getCastorCalibrations(const HcalGenericDetId &fId) const
const Item * getValues(DetId fId, bool throwOnFail=true) const
CastorRecHit reconstruct(const CastorDataFrame &digi, const CastorCoder &coder, const CastorCalibrations &calibs) const
unsigned int samplesToAdd() const
const CastorQIEShape * getCastorShape() const
edm::EDGetTokenT< CastorDigiCollection > tok_input_
static const int SubdetectorId
const_iterator end() const
Definition: DetId.h:18
unsigned int firstSample() const
void recoverADCSaturation(CastorRecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const CastorDataFrame &digi, const int &maxADCvalue, const double &satCorrConst) const
void checkADCSaturation(CastorRecHit &rechit, const CastorDataFrame &digi, const int &maxADCvalue) const
bool isValid() const
Definition: ESHandle.h:44
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const

Member Data Documentation

DetId::Detector CastorSimpleReconstructor::det_
private

Definition at line 21 of file CastorSimpleReconstructor.h.

Referenced by CastorSimpleReconstructor(), and produce().

bool CastorSimpleReconstructor::doSaturationCorr_
private

Definition at line 31 of file CastorSimpleReconstructor.h.

Referenced by produce().

int CastorSimpleReconstructor::firstSample_
private

Definition at line 26 of file CastorSimpleReconstructor.h.

int CastorSimpleReconstructor::maxADCvalue_
private

Definition at line 28 of file CastorSimpleReconstructor.h.

Referenced by produce().

CastorSimpleRecAlgo CastorSimpleReconstructor::reco_
private

Definition at line 20 of file CastorSimpleReconstructor.h.

Referenced by produce().

int CastorSimpleReconstructor::samplesToAdd_
private

Definition at line 27 of file CastorSimpleReconstructor.h.

bool CastorSimpleReconstructor::setSaturationFlag_
private

Definition at line 30 of file CastorSimpleReconstructor.h.

Referenced by produce().

int CastorSimpleReconstructor::subdet_
private

Definition at line 22 of file CastorSimpleReconstructor.h.

Referenced by CastorSimpleReconstructor(), and produce().

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

Definition at line 24 of file CastorSimpleReconstructor.h.

Referenced by CastorSimpleReconstructor(), and produce().

bool CastorSimpleReconstructor::tsFromDB_
private

Definition at line 29 of file CastorSimpleReconstructor.h.

Referenced by produce().