Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-27 00:16:57

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 
0060 HGCalUncalibRecHitWorkerWeights::HGCalUncalibRecHitWorkerWeights(const edm::ParameterSet& ps, edm::ConsumesCollector iC)
0061     : HGCalUncalibRecHitWorkerBaseClass(ps, iC),
0062       ee_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalEESensitive"))),
0063       hef_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHESiliconSensitive"))),
0064       hfnose_geometry_token_(iC.esConsumes(edm::ESInputTag("", "HGCalHFNoseSensitive"))) {
0065   const edm::ParameterSet& ee_cfg = ps.getParameterSet("HGCEEConfig");
0066   const edm::ParameterSet& hef_cfg = ps.getParameterSet("HGCHEFConfig");
0067   const edm::ParameterSet& heb_cfg = ps.getParameterSet("HGCHEBConfig");
0068   const edm::ParameterSet& hfnose_cfg = ps.getParameterSet("HGCHFNoseConfig");
0069   configureIt(ee_cfg, uncalibMaker_ee_);
0070   configureIt(hef_cfg, uncalibMaker_hef_);
0071   configureIt(heb_cfg, uncalibMaker_heb_);
0072   configureIt(hfnose_cfg, uncalibMaker_hfnose_);
0073 }
0074 
0075 void HGCalUncalibRecHitWorkerWeights::set(const edm::EventSetup& es) {
0076   if (uncalibMaker_ee_.isSiFESim()) {
0077     uncalibMaker_ee_.setGeometry(&es.getData(ee_geometry_token_));
0078   }
0079   if (uncalibMaker_hef_.isSiFESim()) {
0080     uncalibMaker_hef_.setGeometry(&es.getData(hef_geometry_token_));
0081   }
0082   uncalibMaker_heb_.setGeometry(nullptr);
0083   if (uncalibMaker_hfnose_.isSiFESim()) {
0084     uncalibMaker_hfnose_.setGeometry(&es.getData(hfnose_geometry_token_));
0085   }
0086 }
0087 
0088 bool HGCalUncalibRecHitWorkerWeights::runHGCEE(const HGCalDigiCollection::const_iterator& itdg,
0089                                                HGCeeUncalibratedRecHitCollection& result) {
0090   result.push_back(uncalibMaker_ee_.makeRecHit(*itdg));
0091   return true;
0092 }
0093 
0094 bool HGCalUncalibRecHitWorkerWeights::runHGCHEsil(const HGCalDigiCollection::const_iterator& itdg,
0095                                                   HGChefUncalibratedRecHitCollection& result) {
0096   result.push_back(uncalibMaker_hef_.makeRecHit(*itdg));
0097   return true;
0098 }
0099 
0100 bool HGCalUncalibRecHitWorkerWeights::runHGCHEscint(const HGCalDigiCollection::const_iterator& itdg,
0101                                                     HGChebUncalibratedRecHitCollection& result) {
0102   result.push_back(uncalibMaker_heb_.makeRecHit(*itdg));
0103   return true;
0104 }
0105 
0106 bool HGCalUncalibRecHitWorkerWeights::runHGCHFNose(const HGCalDigiCollection::const_iterator& itdg,
0107                                                    HGChfnoseUncalibratedRecHitCollection& result) {
0108   result.push_back(uncalibMaker_hfnose_.makeRecHit(*itdg));
0109   return true;
0110 }
0111 
0112 #include "FWCore/Framework/interface/MakerMacros.h"
0113 #include "RecoLocalCalo/HGCalRecProducers/interface/HGCalUncalibRecHitWorkerFactory.h"
0114 DEFINE_EDM_PLUGIN(HGCalUncalibRecHitWorkerFactory, HGCalUncalibRecHitWorkerWeights, "HGCalUncalibRecHitWorkerWeights");