File indexing completed on 2024-06-13 03:24:06
0001 #include "RecoLocalCalo/HGCalRecProducers/plugins/HGCalUncalibRecHitWorkerWeights.h"
0002
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ESProducer.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009
0010 void configureIt(const edm::ParameterSet& conf, HGCalUncalibRecHitRecWeightsAlgo<HGCalDataFrame>& maker) {
0011 constexpr char isSiFE[] = "isSiFE";
0012 constexpr char adcNbits[] = "adcNbits";
0013 constexpr char adcSaturation[] = "adcSaturation";
0014 constexpr char tdcNbits[] = "tdcNbits";
0015 constexpr char tdcSaturation[] = "tdcSaturation";
0016 constexpr char tdcOnset[] = "tdcOnset";
0017 constexpr char toaLSB_ns[] = "toaLSB_ns";
0018 constexpr char fCPerMIP[] = "fCPerMIP";
0019
0020 if (conf.exists(isSiFE)) {
0021 maker.set_isSiFESim(conf.getParameter<bool>(isSiFE));
0022 } else {
0023 maker.set_isSiFESim(false);
0024 }
0025
0026 if (conf.exists(adcNbits)) {
0027 uint32_t nBits = conf.getParameter<uint32_t>(adcNbits);
0028 double saturation = conf.getParameter<double>(adcSaturation);
0029 float adcLSB = saturation / pow(2., nBits);
0030 maker.set_ADCLSB(adcLSB);
0031 } else {
0032 maker.set_ADCLSB(-1.);
0033 }
0034
0035 if (conf.exists(tdcNbits)) {
0036 uint32_t nBits = conf.getParameter<uint32_t>(tdcNbits);
0037 double saturation = conf.getParameter<double>(tdcSaturation);
0038 double onset = conf.getParameter<double>(tdcOnset);
0039 float tdcLSB = saturation / pow(2., nBits);
0040 maker.set_TDCLSB(tdcLSB);
0041 maker.set_tdcOnsetfC(onset);
0042 } else {
0043 maker.set_TDCLSB(-1.);
0044 maker.set_tdcOnsetfC(-1.);
0045 }
0046
0047 if (conf.exists(toaLSB_ns)) {
0048 maker.set_toaLSBToNS(conf.getParameter<double>(toaLSB_ns));
0049 } else {
0050 maker.set_toaLSBToNS(-1.);
0051 }
0052
0053 if (conf.exists(fCPerMIP)) {
0054 maker.set_fCPerMIP(conf.getParameter<std::vector<double> >(fCPerMIP));
0055 } else {
0056 maker.set_fCPerMIP(std::vector<double>({1.0}));
0057 }
0058
0059 maker.set_tofDelay(conf.getParameter<double>("tofDelay"));
0060 }
0061
0062 HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet& ps,
0063 edm::ConsumesCollector iC,
0064 bool useTime)
0065 : HGCalUncalibRecHitWorkerBaseClass(ps, iC, useTime) {
0066 const edm::ParameterSet& ee_cfg = ps.getParameterSet("HGCEEConfig");
0067 const edm::ParameterSet& hef_cfg = ps.getParameterSet("HGCHEFConfig");
0068 const edm::ParameterSet& heb_cfg = ps.getParameterSet("HGCHEBConfig");
0069 const edm::ParameterSet& hfnose_cfg = ps.getParameterSet("HGCHFNoseConfig");
0070 configureIt(ee_cfg, uncalibMaker_ee_);
0071 configureIt(hef_cfg, uncalibMaker_hef_);
0072 configureIt(heb_cfg, uncalibMaker_heb_);
0073 configureIt(hfnose_cfg, uncalibMaker_hfnose_);
0074 computeLocalTime_ = useTime;
0075 }
0076
0077 bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle<HGCalGeometry>& geom,
0078 const HGCalDigiCollection& digis,
0079 HGCalUncalibRecHitRecWeightsAlgo<HGCalDataFrame>& uncalibMaker,
0080 edm::SortedCollection<HGCUncalibratedRecHit>& result) {
0081 uncalibMaker.setGeometry(geom);
0082 result.reserve(result.size() + digis.size());
0083 for (const auto& digi : digis)
0084 result.push_back(uncalibMaker.makeRecHit(digi, computeLocalTime_));
0085 return true;
0086 }
0087
0088 bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const edm::ESHandle<HGCalGeometry>& geom,
0089 const HGCalDigiCollection& digis,
0090 HGCeeUncalibratedRecHitCollection& result) {
0091 return run(geom, digis, uncalibMaker_ee_, result);
0092 }
0093
0094 bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const edm::ESHandle<HGCalGeometry>& geom,
0095 const HGCalDigiCollection& digis,
0096 HGChefUncalibratedRecHitCollection& result) {
0097 return run(geom, digis, uncalibMaker_hef_, result);
0098 }
0099
0100 bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const edm::ESHandle<HGCalGeometry>& geom,
0101 const HGCalDigiCollection& digis,
0102 HGChebUncalibratedRecHitCollection& result) {
0103 return run(geom, digis, uncalibMaker_heb_, result);
0104 }
0105
0106 bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const edm::ESHandle<HGCalGeometry>& geom,
0107 const HGCalDigiCollection& digis,
0108 HGChfnoseUncalibratedRecHitCollection& result) {
0109 return run(geom, digis, uncalibMaker_hfnose_, result);
0110 }
0111
0112 #include "FWCore/Framework/interface/MakerMacros.h"
0113 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h"
0114 DEFINE_EDM_PLUGIN(HGCalUncalibRecHitWorkerFactory, HGCalUncalibRecHitWorkerWeights, "HGCalUncalibRecHitWorkerWeights");