Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:19:01

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);  // in fC
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, edm::ConsumesCollector iC)
0063     : HGCalUncalibRecHitWorkerBaseClass(ps, iC) {
0064   const edm::ParameterSet& ee_cfg = ps.getParameterSet("HGCEEConfig");
0065   const edm::ParameterSet& hef_cfg = ps.getParameterSet("HGCHEFConfig");
0066   const edm::ParameterSet& heb_cfg = ps.getParameterSet("HGCHEBConfig");
0067   const edm::ParameterSet& hfnose_cfg = ps.getParameterSet("HGCHFNoseConfig");
0068   configureIt(ee_cfg, uncalibMaker_ee_);
0069   configureIt(hef_cfg, uncalibMaker_hef_);
0070   configureIt(heb_cfg, uncalibMaker_heb_);
0071   configureIt(hfnose_cfg, uncalibMaker_hfnose_);
0072 }
0073 
0074 bool HGCalUncalibRecHitWorkerWeights::run(const edm::ESHandle<HGCalGeometry>& geom,
0075                                           const HGCalDigiCollection& digis,
0076                                           HGCalUncalibRecHitRecWeightsAlgo<HGCalDataFrame>& uncalibMaker,
0077                                           edm::SortedCollection<HGCUncalibratedRecHit>& result) {
0078   uncalibMaker.setGeometry(geom);
0079   result.reserve(result.size() + digis.size());
0080   for (const auto& digi : digis)
0081     result.push_back(uncalibMaker.makeRecHit(digi));
0082   return true;
0083 }
0084 
0085 bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const edm::ESHandle<HGCalGeometry>& geom,
0086                                                const HGCalDigiCollection& digis,
0087                                                HGCeeUncalibratedRecHitCollection& result) {
0088   return run(geom, digis, uncalibMaker_ee_, result);
0089 }
0090 
0091 bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const edm::ESHandle<HGCalGeometry>& geom,
0092                                                   const HGCalDigiCollection& digis,
0093                                                   HGChefUncalibratedRecHitCollection& result) {
0094   return run(geom, digis, uncalibMaker_hef_, result);
0095 }
0096 
0097 bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const edm::ESHandle<HGCalGeometry>& geom,
0098                                                     const HGCalDigiCollection& digis,
0099                                                     HGChebUncalibratedRecHitCollection& result) {
0100   return run(geom, digis, uncalibMaker_heb_, result);
0101 }
0102 
0103 bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const edm::ESHandle<HGCalGeometry>& geom,
0104                                                    const HGCalDigiCollection& digis,
0105                                                    HGChfnoseUncalibratedRecHitCollection& result) {
0106   return run(geom, digis, uncalibMaker_hfnose_, result);
0107 }
0108 
0109 #include "FWCore/Framework/interface/MakerMacros.h"
0110 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h"
0111 DEFINE_EDM_PLUGIN(HGCalUncalibRecHitWorkerFactory, HGCalUncalibRecHitWorkerWeights, "HGCalUncalibRecHitWorkerWeights");