Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:00:47

0001 #include <memory>
0002 
0003 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripRawProcessingFactory.h"
0004 #include "FWCore/Framework/interface/ConsumesCollector.h"
0005 
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripRawProcessingAlgorithms.h"
0009 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripPedestalsSubtractor.h"
0010 #include "RecoLocalTracker/SiStripZeroSuppression/interface/SiStripFedZeroSuppression.h"
0011 #include "RecoLocalTracker/SiStripZeroSuppression/interface/MedianCMNSubtractor.h"
0012 #include "RecoLocalTracker/SiStripZeroSuppression/interface/PercentileCMNSubtractor.h"
0013 #include "RecoLocalTracker/SiStripZeroSuppression/interface/IteratedMedianCMNSubtractor.h"
0014 #include "RecoLocalTracker/SiStripZeroSuppression/interface/FastLinearCMNSubtractor.h"
0015 #include "RecoLocalTracker/SiStripZeroSuppression/interface/TT6CMNSubtractor.h"
0016 
0017 std::unique_ptr<SiStripRawProcessingAlgorithms> SiStripRawProcessingFactory::create(const edm::ParameterSet& conf,
0018                                                                                     edm::ConsumesCollector iC) {
0019   return std::unique_ptr<SiStripRawProcessingAlgorithms>(
0020       new SiStripRawProcessingAlgorithms(iC,
0021                                          create_SubtractorPed(conf, iC),
0022                                          create_SubtractorCMN(conf, iC),
0023                                          create_Suppressor(conf, iC),
0024                                          create_Restorer(conf, iC),
0025                                          conf.getParameter<bool>("doAPVRestore"),
0026                                          conf.getParameter<bool>("useCMMeanMap")));
0027 }
0028 
0029 std::unique_ptr<SiStripPedestalsSubtractor> SiStripRawProcessingFactory::create_SubtractorPed(
0030     const edm::ParameterSet& conf, edm::ConsumesCollector iC) {
0031   return std::unique_ptr<SiStripPedestalsSubtractor>(
0032       new SiStripPedestalsSubtractor(conf.getParameter<bool>("PedestalSubtractionFedMode"), iC));
0033 }
0034 
0035 std::unique_ptr<SiStripCommonModeNoiseSubtractor> SiStripRawProcessingFactory::create_SubtractorCMN(
0036     const edm::ParameterSet& conf, edm::ConsumesCollector iC) {
0037   const std::string mode = conf.getParameter<std::string>("CommonModeNoiseSubtractionMode");
0038 
0039   if (mode == "Median")
0040     return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(new MedianCMNSubtractor());
0041 
0042   if (mode == "Percentile") {
0043     return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(
0044         new PercentileCMNSubtractor(conf.getParameter<double>("Percentile")));
0045   }
0046 
0047   if (mode == "IteratedMedian") {
0048     return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(new IteratedMedianCMNSubtractor(
0049         conf.getParameter<double>("CutToAvoidSignal"), conf.getParameter<int>("Iterations"), iC));
0050   }
0051 
0052   if (mode == "FastLinear")
0053     return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(new FastLinearCMNSubtractor());
0054 
0055   if (mode == "TT6") {
0056     return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(
0057         new TT6CMNSubtractor(conf.getParameter<double>("CutToAvoidSignal"), iC));
0058   }
0059 
0060   edm::LogError("SiStripRawProcessingFactory::create_SubtractorCMN")
0061       << "Unregistered Algorithm: " << mode << ". Use one of {Median, Percentile, IteratedMedian, FastLinear, TT6}";
0062   return std::unique_ptr<SiStripCommonModeNoiseSubtractor>(new MedianCMNSubtractor());
0063 }
0064 
0065 std::unique_ptr<SiStripFedZeroSuppression> SiStripRawProcessingFactory::create_Suppressor(const edm::ParameterSet& conf,
0066                                                                                           edm::ConsumesCollector iC) {
0067   const uint32_t mode = conf.getParameter<uint32_t>("SiStripFedZeroSuppressionMode");
0068   const bool trunc = conf.getParameter<bool>("TruncateInSuppressor");
0069   const bool trunc10bits = conf.getParameter<bool>("Use10bitsTruncation");
0070   switch (mode) {
0071     case 1:
0072     case 2:
0073     case 3:
0074     case 4:
0075       return std::make_unique<SiStripFedZeroSuppression>(mode, &iC, trunc, trunc10bits);
0076     default:
0077       edm::LogError("SiStripRawProcessingFactory::createSuppressor")
0078           << "Unregistered mode: " << mode << ". Use one of {1,2,3,4}.";
0079       return std::make_unique<SiStripFedZeroSuppression>(4, &iC, true, trunc10bits);
0080   }
0081 }
0082 
0083 std::unique_ptr<SiStripAPVRestorer> SiStripRawProcessingFactory::create_Restorer(const edm::ParameterSet& conf,
0084                                                                                  edm::ConsumesCollector iC) {
0085   if (!conf.exists("APVRestoreMode")) {
0086     return std::unique_ptr<SiStripAPVRestorer>(nullptr);
0087   } else {
0088     return std::unique_ptr<SiStripAPVRestorer>(new SiStripAPVRestorer(conf, iC));
0089   }
0090 }
0091 
0092 void SiStripRawProcessingFactory::fillDescriptions(edm::ParameterSetDescription& algorithms) {
0093   algorithms.add<std::string>("CommonModeNoiseSubtractionMode", "Median");
0094   algorithms.add("useCMMeanMap", false);
0095   algorithms.add("TruncateInSuppressor", true);
0096   algorithms.add("doAPVRestore", false);
0097   algorithms.add("SiStripFedZeroSuppressionMode", 4U);
0098   algorithms.add("PedestalSubtractionFedMode", true);
0099   algorithms.add("Use10bitsTruncation", false);
0100   algorithms.add("Percentile", 25.0);
0101   algorithms.add("CutToAvoidSignal", 2.0);
0102   algorithms.add("Iterations", 3);
0103   SiStripAPVRestorer::fillDescriptions(algorithms);
0104 }