Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:52

0001 #include "L1Trigger/TrackFindingTMTT/interface/Settings.h"
0002 #include "FWCore/Utilities/interface/Exception.h"
0003 #include <set>
0004 #include <cmath>
0005 
0006 using namespace std;
0007 
0008 namespace tmtt {
0009 
0010   ///=== Hybrid Tracking
0011   ///=== Set config params for HYBRID TRACKING via hard-wired consts to allow use outside CMSSW.
0012 
0013   Settings::Settings()
0014       :  //--------------------------------------------------------------------------------------------------
0015         // TMTT related configuration parameters, including Kalman Filter.
0016         // Meaning of these parameters explained in TrackFindingTMTT/python/TMTrackProducer_Defaults_cfi.py
0017         //--------------------------------------------------------------------------------------------------
0018 
0019         // General cfg params
0020         enableDigitize_(false),
0021         useApproxB_(true),
0022         bApprox_gradient_(0.886454),
0023         bApprox_intercept_(0.504148),
0024         numPhiNonants_(9),
0025         numPhiSectors_(9),
0026         chosenRofPhi_(55.),  // Hourglass radius in r-phi (tracklet)
0027         etaRegions_(
0028             {-2.4, -2.08, -1.68, -1.26, -0.90, -0.62, -0.41, -0.20, 0.0, 0.20, 0.41, 0.62, 0.90, 1.26, 1.68, 2.08, 2.4}),
0029         chosenRofZ_(50.0),  // Hourglass radius in r-z (this must be tmtt)
0030         houghMinPt_(2.0),   // L1 track pt cut
0031         minStubLayers_(4),
0032         minPtToReduceLayers_(99999.),
0033         reduceLayerID_(true),
0034         minFracMatchStubsOnReco_(-99),
0035         minFracMatchStubsOnTP_(-99),
0036         minNumMatchLayers_(4),
0037         minNumMatchPSLayers_(0),
0038         stubMatchStrict_(false),
0039 
0040         // Kalman filter track fit cfg
0041         kalmanDebugLevel_(0),
0042         //kalmanDebugLevel_(2), // Good for debugging
0043         kalmanMinNumStubs_(4),
0044         kalmanMaxNumStubs_(6),
0045         kalmanAddBeamConstr_(false),  // Apply post-fit beam-spot constraint to 5-param fit
0046         kalmanRemove2PScut_(true),
0047         kalmanMaxSkipLayersHard_(1),  // On "hard" input tracks
0048         kalmanMaxSkipLayersEasy_(2),  // On "easy" input tracks
0049         kalmanMaxStubsEasy_(10),      // Max. #stubs an input track can have to be defined "easy"
0050         kfUseMaybeLayers_(true),
0051         kfLayerVsPtToler_({999., 999., 0.1, 0.1, 0.05, 0.05, 0.05}),
0052         kfLayerVsD0Cut5_({999., 999., 999., 10., 10., 10., 10.}),
0053         kfLayerVsZ0Cut5_({999., 999., 25.5, 25.5, 25.5, 25.5, 25.5}),
0054         kfLayerVsZ0Cut4_({999., 999., 15., 15., 15., 15., 15.}),
0055         kfLayerVsChiSq5_({999., 999., 10., 30., 80., 120., 160.}),
0056         kfLayerVsChiSq4_({999., 999., 10., 30., 80., 120., 160.}),
0057         kalmanMaxStubsPerLayer_(4),  // To save resources, consider at most this many stubs per layer per track.
0058         kalmanMultiScattTerm_(0.00075),
0059         kalmanChi2RphiScale_(8),
0060         kalmanHOtilted_(true),
0061         kalmanHOhelixExp_(true),
0062         kalmanHOalpha_(1),
0063         kalmanHOprojZcorr_(1),
0064         kalmanHOfw_(false) {
0065     hybrid_ = true;
0066     magneticField_ = 0.;  // Value set later
0067     killScenario_ = 0;    // Emulation of dead modules
0068     killRecover_ = false;
0069 
0070     if (hybrid_) {
0071       if (not useApproxB_) {
0072         throw cms::Exception("BadConfig")
0073             << "TMTT Settings Error: module tilt angle unknown, so must set useApproxB = true";
0074       }
0075     }
0076   }
0077 
0078   ///=== TMTT tracking.
0079   ///=== Get configuration parameters from python cfg for TMTT tracking.
0080 
0081   Settings::Settings(const edm::ParameterSet& iConfig)
0082       :
0083 
0084         // See either Analyze_Defaults_cfi.py or Settings.h for description of these parameters.
0085 
0086         //=== Tags for Input ES & ED data.
0087         magneticFieldInputTag_(iConfig.getParameter<edm::ESInputTag>("magneticFieldInputTag")),
0088         trackerGeometryInputTag_(iConfig.getParameter<edm::ESInputTag>("trackerGeometryInputTag")),
0089         trackerTopologyInputTag_(iConfig.getParameter<edm::ESInputTag>("trackerTopologyInputTag")),
0090         ttStubAlgoInputTag_(iConfig.getParameter<edm::ESInputTag>("ttStubAlgoInputTag")),
0091 
0092         stubInputTag_(iConfig.getParameter<edm::InputTag>("stubInputTag")),
0093         tpInputTag_(iConfig.getParameter<edm::InputTag>("tpInputTag")),
0094         stubTruthInputTag_(iConfig.getParameter<edm::InputTag>("stubTruthInputTag")),
0095         clusterTruthInputTag_(iConfig.getParameter<edm::InputTag>("clusterTruthInputTag")),
0096         genJetInputTag_(iConfig.getParameter<edm::InputTag>("genJetInputTag")),
0097 
0098         //=== Parameter sets for differents types of configuration parameter.
0099         genCuts_(iConfig.getParameter<edm::ParameterSet>("GenCuts")),
0100         stubCuts_(iConfig.getParameter<edm::ParameterSet>("StubCuts")),
0101         stubDigitize_(iConfig.getParameter<edm::ParameterSet>("StubDigitize")),
0102         trackerModuleType_(iConfig.getParameter<edm::ParameterSet>("TrackerModuleType")),
0103         geometricProc_(iConfig.getParameter<edm::ParameterSet>("GeometricProc")),
0104         phiSectors_(iConfig.getParameter<edm::ParameterSet>("PhiSectors")),
0105         etaSectors_(iConfig.getParameter<edm::ParameterSet>("EtaSectors")),
0106         htArraySpecRphi_(iConfig.getParameter<edm::ParameterSet>("HTArraySpecRphi")),
0107         htFillingRphi_(iConfig.getParameter<edm::ParameterSet>("HTFillingRphi")),
0108         rzFilterOpts_(iConfig.getParameter<edm::ParameterSet>("RZfilterOpts")),
0109         l1TrackDef_(iConfig.getParameter<edm::ParameterSet>("L1TrackDef")),
0110         dupTrkRemoval_(iConfig.getParameter<edm::ParameterSet>("DupTrkRemoval")),
0111         trackMatchDef_(iConfig.getParameter<edm::ParameterSet>("TrackMatchDef")),
0112         trackFitSettings_(iConfig.getParameter<edm::ParameterSet>("TrackFitSettings")),
0113         deadModuleOpts_(iConfig.getParameter<edm::ParameterSet>("DeadModuleOpts")),
0114         trackDigi_(iConfig.getParameter<edm::ParameterSet>("TrackDigi")),
0115 
0116         //=== General settings
0117 
0118         enableMCtruth_(iConfig.getParameter<bool>("EnableMCtruth")),
0119         enableHistos_(iConfig.getParameter<bool>("EnableHistos")),
0120         enableOutputIntermediateTTTracks_(iConfig.getParameter<bool>("EnableOutputIntermediateTTTracks")),
0121 
0122         //=== Cuts on MC truth tracks used for tracking efficiency measurements.
0123 
0124         genMinPt_(genCuts_.getParameter<double>("GenMinPt")),
0125         genMaxAbsEta_(genCuts_.getParameter<double>("GenMaxAbsEta")),
0126         genMaxVertR_(genCuts_.getParameter<double>("GenMaxVertR")),
0127         genMaxVertZ_(genCuts_.getParameter<double>("GenMaxVertZ")),
0128         genMaxD0_(genCuts_.getParameter<double>("GenMaxD0")),
0129         genMaxZ0_(genCuts_.getParameter<double>("GenMaxZ0")),
0130         genMinStubLayers_(genCuts_.getParameter<unsigned int>("GenMinStubLayers")),
0131 
0132         //=== Cuts applied to stubs before arriving in L1 track finding board.
0133 
0134         degradeBendRes_(stubCuts_.getParameter<unsigned int>("DegradeBendRes")),
0135         maxStubEta_(stubCuts_.getParameter<double>("MaxStubEta")),
0136         killLowPtStubs_(stubCuts_.getParameter<bool>("KillLowPtStubs")),
0137         printStubWindows_(stubCuts_.getParameter<bool>("PrintStubWindows")),
0138         bendCut_(stubCuts_.getParameter<double>("BendCut")),
0139         bendCutExtra_(stubCuts_.getParameter<double>("BendCutExtra")),
0140         orderStubsByBend_(stubCuts_.getParameter<bool>("OrderStubsByBend")),
0141 
0142         //=== Optional stub digitization.
0143 
0144         enableDigitize_(stubDigitize_.getParameter<bool>("EnableDigitize")),
0145 
0146         //--- Parameters available in MP board.
0147         phiSectorBits_(stubDigitize_.getParameter<unsigned int>("PhiSectorBits")),
0148         phiSBits_(stubDigitize_.getParameter<unsigned int>("PhiSBits")),
0149         phiSRange_(stubDigitize_.getParameter<double>("PhiSRange")),
0150         rtBits_(stubDigitize_.getParameter<unsigned int>("RtBits")),
0151         rtRange_(stubDigitize_.getParameter<double>("RtRange")),
0152         zBits_(stubDigitize_.getParameter<unsigned int>("ZBits")),
0153         zRange_(stubDigitize_.getParameter<double>("ZRange")),
0154         //--- Parameters available in GP board (excluding any in common with MP specified above).
0155         phiNBits_(stubDigitize_.getParameter<unsigned int>("PhiNBits")),
0156         phiNRange_(stubDigitize_.getParameter<double>("PhiNRange")),
0157         bendBits_(stubDigitize_.getParameter<unsigned int>("BendBits")),
0158 
0159         //=== Tracker Module Type for FW.
0160         pitchVsType_(trackerModuleType_.getParameter<vector<double>>("PitchVsType")),
0161         spaceVsType_(trackerModuleType_.getParameter<vector<double>>("SpaceVsType")),
0162         barrelVsTypeTmp_(trackerModuleType_.getParameter<vector<unsigned int>>("BarrelVsType")),
0163         psVsTypeTmp_(trackerModuleType_.getParameter<vector<unsigned int>>("PSVsType")),
0164         tiltedVsTypeTmp_(trackerModuleType_.getParameter<vector<unsigned int>>("TiltedVsType")),
0165 
0166         //=== Configuration of Geometric Processor.
0167         useApproxB_(geometricProc_.getParameter<bool>("UseApproxB")),
0168         bApprox_gradient_(geometricProc_.getParameter<double>("BApprox_gradient")),
0169         bApprox_intercept_(geometricProc_.getParameter<double>("BApprox_intercept")),
0170 
0171         //=== Division of Tracker into phi sectors.
0172         numPhiNonants_(phiSectors_.getParameter<unsigned int>("NumPhiNonants")),
0173         numPhiSectors_(phiSectors_.getParameter<unsigned int>("NumPhiSectors")),
0174         chosenRofPhi_(phiSectors_.getParameter<double>("ChosenRofPhi")),
0175         useStubPhi_(phiSectors_.getParameter<bool>("UseStubPhi")),
0176         useStubPhiTrk_(phiSectors_.getParameter<bool>("UseStubPhiTrk")),
0177         assumedPhiTrkRes_(phiSectors_.getParameter<double>("AssumedPhiTrkRes")),
0178         calcPhiTrkRes_(phiSectors_.getParameter<bool>("CalcPhiTrkRes")),
0179 
0180         //=== Division of Tracker into eta sectors.
0181         etaRegions_(etaSectors_.getParameter<vector<double>>("EtaRegions")),
0182         chosenRofZ_(etaSectors_.getParameter<double>("ChosenRofZ")),
0183         beamWindowZ_(etaSectors_.getParameter<double>("BeamWindowZ")),
0184         allowOver2EtaSecs_(etaSectors_.getParameter<bool>("AllowOver2EtaSecs")),
0185 
0186         //=== r-phi Hough transform array specifications.
0187         houghMinPt_(htArraySpecRphi_.getParameter<double>("HoughMinPt")),
0188         houghNbinsPt_(htArraySpecRphi_.getParameter<unsigned int>("HoughNbinsPt")),
0189         houghNbinsPhi_(htArraySpecRphi_.getParameter<unsigned int>("HoughNbinsPhi")),
0190         enableMerge2x2_(htArraySpecRphi_.getParameter<bool>("EnableMerge2x2")),
0191         maxPtToMerge2x2_(htArraySpecRphi_.getParameter<double>("MaxPtToMerge2x2")),
0192         numSubSecsEta_(htArraySpecRphi_.getParameter<unsigned int>("NumSubSecsEta")),
0193         shape_(htArraySpecRphi_.getParameter<unsigned int>("Shape")),
0194         miniHTstage_(htArraySpecRphi_.getParameter<bool>("MiniHTstage")),
0195         miniHoughNbinsPt_(htArraySpecRphi_.getParameter<unsigned int>("MiniHoughNbinsPt")),
0196         miniHoughNbinsPhi_(htArraySpecRphi_.getParameter<unsigned int>("MiniHoughNbinsPhi")),
0197         miniHoughMinPt_(htArraySpecRphi_.getParameter<double>("MiniHoughMinPt")),
0198         miniHoughDontKill_(htArraySpecRphi_.getParameter<bool>("MiniHoughDontKill")),
0199         miniHoughDontKillMinPt_(htArraySpecRphi_.getParameter<double>("MiniHoughDontKillMinPt")),
0200         miniHoughLoadBalance_(htArraySpecRphi_.getParameter<unsigned int>("MiniHoughLoadBalance")),
0201 
0202         //=== Rules governing how stubs are filled into the r-phi Hough Transform array.
0203         killSomeHTCellsRphi_(htFillingRphi_.getParameter<unsigned int>("KillSomeHTCellsRphi")),
0204         useBendFilter_(htFillingRphi_.getParameter<bool>("UseBendFilter")),
0205         maxStubsInCell_(htFillingRphi_.getParameter<unsigned int>("MaxStubsInCell")),
0206         maxStubsInCellMiniHough_(htFillingRphi_.getParameter<unsigned int>("MaxStubsInCellMiniHough")),
0207         busySectorKill_(htFillingRphi_.getParameter<bool>("BusySectorKill")),
0208         busySectorNumStubs_(htFillingRphi_.getParameter<unsigned int>("BusySectorNumStubs")),
0209         busySectorMbinRanges_(htFillingRphi_.getParameter<vector<unsigned int>>("BusySectorMbinRanges")),
0210         busySectorMbinOrder_(htFillingRphi_.getParameter<vector<unsigned int>>("BusySectorMbinOrder")),
0211         busyInputSectorKill_(htFillingRphi_.getParameter<bool>("BusyInputSectorKill")),
0212         busyInputSectorNumStubs_(htFillingRphi_.getParameter<unsigned int>("BusyInputSectorNumStubs")),
0213         muxOutputsHT_(htFillingRphi_.getParameter<unsigned int>("MuxOutputsHT")),
0214         etaRegWhitelist_(htFillingRphi_.getParameter<vector<unsigned int>>("EtaRegWhitelist")),
0215 
0216         //=== Options controlling r-z track filters (or any other track filters run after the Hough transform, as opposed to inside it).
0217 
0218         rzFilterName_(rzFilterOpts_.getParameter<string>("RZFilterName")),
0219         seedResCut_(rzFilterOpts_.getParameter<double>("SeedResCut")),
0220         keepAllSeed_(rzFilterOpts_.getParameter<bool>("KeepAllSeed")),
0221         maxSeedCombinations_(rzFilterOpts_.getParameter<unsigned int>("MaxSeedCombinations")),
0222         maxGoodSeedCombinations_(rzFilterOpts_.getParameter<unsigned int>("MaxGoodSeedCombinations")),
0223         maxSeedsPerStub_(rzFilterOpts_.getParameter<unsigned int>("MaxSeedsPerStub")),
0224         zTrkSectorCheck_(rzFilterOpts_.getParameter<bool>("zTrkSectorCheck")),
0225         minFilterLayers_(rzFilterOpts_.getParameter<unsigned int>("MinFilterLayers")),
0226 
0227         //=== Rules for deciding when the track finding has found an L1 track candidate
0228 
0229         minStubLayers_(l1TrackDef_.getParameter<unsigned int>("MinStubLayers")),
0230         minPtToReduceLayers_(l1TrackDef_.getParameter<double>("MinPtToReduceLayers")),
0231         etaSecsReduceLayers_(l1TrackDef_.getParameter<vector<unsigned int>>("EtaSecsReduceLayers")),
0232         reduceLayerID_(l1TrackDef_.getParameter<bool>("ReducedLayerID")),
0233 
0234         //=== Specification of algorithm to eliminate duplicate tracks.
0235 
0236         dupTrkAlgFit_(dupTrkRemoval_.getParameter<unsigned int>("DupTrkAlgFit")),
0237 
0238         //=== Rules for deciding when a reconstructed L1 track matches a MC truth particle (i.e. tracking particle).
0239 
0240         minFracMatchStubsOnReco_(trackMatchDef_.getParameter<double>("MinFracMatchStubsOnReco")),
0241         minFracMatchStubsOnTP_(trackMatchDef_.getParameter<double>("MinFracMatchStubsOnTP")),
0242         minNumMatchLayers_(trackMatchDef_.getParameter<unsigned int>("MinNumMatchLayers")),
0243         minNumMatchPSLayers_(trackMatchDef_.getParameter<unsigned int>("MinNumMatchPSLayers")),
0244         stubMatchStrict_(trackMatchDef_.getParameter<bool>("StubMatchStrict")),
0245 
0246         //=== Track Fitting Settings
0247 
0248         trackFitters_(trackFitSettings_.getParameter<vector<std::string>>("TrackFitters")),
0249         useRZfilter_(trackFitSettings_.getParameter<vector<std::string>>("UseRZfilter")),
0250         detailedFitOutput_(trackFitSettings_.getParameter<bool>("DetailedFitOutput")),
0251         trackFitCheat_(trackFitSettings_.getParameter<bool>("TrackFitCheat")),
0252         //
0253         numTrackFitIterations_(trackFitSettings_.getParameter<unsigned int>("NumTrackFitIterations")),
0254         killTrackFitWorstHit_(trackFitSettings_.getParameter<bool>("KillTrackFitWorstHit")),
0255         generalResidualCut_(trackFitSettings_.getParameter<double>("GeneralResidualCut")),
0256         killingResidualCut_(trackFitSettings_.getParameter<double>("KillingResidualCut")),
0257         //
0258         digitizeSLR_(trackFitSettings_.getParameter<bool>("DigitizeSLR")),
0259         dividerBitsHelix_(trackFitSettings_.getParameter<unsigned int>("DividerBitsHelix")),
0260         dividerBitsHelixZ_(trackFitSettings_.getParameter<unsigned int>("DividerBitsHelixZ")),
0261         ShiftingBitsDenRPhi_(trackFitSettings_.getParameter<unsigned int>("ShiftingBitsDenRPhi")),
0262         ShiftingBitsDenRZ_(trackFitSettings_.getParameter<unsigned int>("ShiftingBitsDenRZ")),
0263         ShiftingBitsPt_(trackFitSettings_.getParameter<unsigned int>("ShiftingBitsPt")),
0264         ShiftingBitsPhi_(trackFitSettings_.getParameter<unsigned int>("ShiftingBitsPhi")),
0265 
0266         ShiftingBitsLambda_(trackFitSettings_.getParameter<unsigned int>("ShiftingBitsLambda")),
0267         ShiftingBitsZ0_(trackFitSettings_.getParameter<unsigned int>("ShiftingBitsZ0")),
0268         slr_chi2cut_(trackFitSettings_.getParameter<double>("SLR_chi2cut")),
0269         residualCut_(trackFitSettings_.getParameter<double>("ResidualCut")),
0270         //
0271         kalmanDebugLevel_(trackFitSettings_.getParameter<unsigned int>("KalmanDebugLevel")),
0272         kalmanMinNumStubs_(trackFitSettings_.getParameter<unsigned int>("KalmanMinNumStubs")),
0273         kalmanMaxNumStubs_(trackFitSettings_.getParameter<unsigned int>("KalmanMaxNumStubs")),
0274         kalmanAddBeamConstr_(trackFitSettings_.getParameter<bool>("KalmanAddBeamConstr")),
0275         kalmanRemove2PScut_(trackFitSettings_.getParameter<bool>("KalmanRemove2PScut")),
0276         kalmanMaxSkipLayersHard_(trackFitSettings_.getParameter<unsigned>("KalmanMaxSkipLayersHard")),
0277         kalmanMaxSkipLayersEasy_(trackFitSettings_.getParameter<unsigned>("KalmanMaxSkipLayersEasy")),
0278         kalmanMaxStubsEasy_(trackFitSettings_.getParameter<unsigned>("KalmanMaxStubsEasy")),
0279         kfUseMaybeLayers_(trackFitSettings_.getParameter<bool>("KFUseMaybeLayers")),
0280 
0281         kfLayerVsPtToler_(trackFitSettings_.getParameter<vector<double>>("KFLayerVsPtToler")),
0282         kfLayerVsD0Cut5_(trackFitSettings_.getParameter<vector<double>>("KFLayerVsD0Cut5")),
0283         kfLayerVsZ0Cut5_(trackFitSettings_.getParameter<vector<double>>("KFLayerVsZ0Cut5")),
0284         kfLayerVsZ0Cut4_(trackFitSettings_.getParameter<vector<double>>("KFLayerVsZ0Cut4")),
0285         kfLayerVsChiSq5_(trackFitSettings_.getParameter<vector<double>>("KFLayerVsChiSq5")),
0286         kfLayerVsChiSq4_(trackFitSettings_.getParameter<vector<double>>("KFLayerVsChiSq4")),
0287 
0288         kalmanMaxStubsPerLayer_(trackFitSettings_.getParameter<unsigned>("KalmanMaxStubsPerLayer")),
0289         kalmanMultiScattTerm_(trackFitSettings_.getParameter<double>("KalmanMultiScattTerm")),
0290         kalmanChi2RphiScale_(trackFitSettings_.getParameter<unsigned>("KalmanChi2RphiScale")),
0291         kalmanHOtilted_(trackFitSettings_.getParameter<bool>("KalmanHOtilted")),
0292         kalmanHOhelixExp_(trackFitSettings_.getParameter<bool>("KalmanHOhelixExp")),
0293         kalmanHOalpha_(trackFitSettings_.getParameter<unsigned int>("KalmanHOalpha")),
0294         kalmanHOprojZcorr_(trackFitSettings_.getParameter<unsigned int>("KalmanHOprojZcorr")),
0295         kalmanHOfw_(trackFitSettings_.getParameter<bool>("KalmanHOfw")),
0296 
0297         //=== Treatment of dead modules.
0298 
0299         killScenario_(deadModuleOpts_.getParameter<unsigned int>("KillScenario")),
0300         killRecover_(deadModuleOpts_.getParameter<bool>("KillRecover")),
0301 
0302         //=== Track digitisation configuration for various track fitters
0303 
0304         slr_skipTrackDigi_(trackDigi_.getParameter<bool>("SLR_skipTrackDigi")),
0305         slr_oneOver2rBits_(trackDigi_.getParameter<unsigned int>("SLR_oneOver2rBits")),
0306         slr_oneOver2rRange_(trackDigi_.getParameter<double>("SLR_oneOver2rRange")),
0307         slr_d0Bits_(trackDigi_.getParameter<unsigned int>("SLR_d0Bits")),
0308         slr_d0Range_(trackDigi_.getParameter<double>("SLR_d0Range")),
0309         slr_phi0Bits_(trackDigi_.getParameter<unsigned int>("SLR_phi0Bits")),
0310         slr_phi0Range_(trackDigi_.getParameter<double>("SLR_phi0Range")),
0311         slr_z0Bits_(trackDigi_.getParameter<unsigned int>("SLR_z0Bits")),
0312         slr_z0Range_(trackDigi_.getParameter<double>("SLR_z0Range")),
0313         slr_tanlambdaBits_(trackDigi_.getParameter<unsigned int>("SLR_tanlambdaBits")),
0314         slr_tanlambdaRange_(trackDigi_.getParameter<double>("SLR_tanlambdaRange")),
0315         slr_chisquaredBits_(trackDigi_.getParameter<unsigned int>("SLR_chisquaredBits")),
0316         slr_chisquaredRange_(trackDigi_.getParameter<double>("SLR_chisquaredRange")),
0317         //
0318         kf_skipTrackDigi_(trackDigi_.getParameter<bool>("KF_skipTrackDigi")),
0319         kf_oneOver2rBits_(trackDigi_.getParameter<unsigned int>("KF_oneOver2rBits")),
0320         kf_oneOver2rRange_(trackDigi_.getParameter<double>("KF_oneOver2rRange")),
0321         kf_d0Bits_(trackDigi_.getParameter<unsigned int>("KF_d0Bits")),
0322         kf_d0Range_(trackDigi_.getParameter<double>("KF_d0Range")),
0323         kf_phi0Bits_(trackDigi_.getParameter<unsigned int>("KF_phi0Bits")),
0324         kf_phi0Range_(trackDigi_.getParameter<double>("KF_phi0Range")),
0325         kf_z0Bits_(trackDigi_.getParameter<unsigned int>("KF_z0Bits")),
0326         kf_z0Range_(trackDigi_.getParameter<double>("KF_z0Range")),
0327         kf_tanlambdaBits_(trackDigi_.getParameter<unsigned int>("KF_tanlambdaBits")),
0328         kf_tanlambdaRange_(trackDigi_.getParameter<double>("KF_tanlambdaRange")),
0329         kf_chisquaredBits_(trackDigi_.getParameter<unsigned int>("KF_chisquaredBits")),
0330         kf_chisquaredRange_(trackDigi_.getParameter<double>("KF_chisquaredRange")),
0331         kf_chisquaredBinEdges_(trackDigi_.getParameter<vector<double>>("KF_chisquaredBinEdges")),
0332         //
0333         other_skipTrackDigi_(trackDigi_.getParameter<bool>("Other_skipTrackDigi")),
0334 
0335         // Plot options
0336         resPlotOpt_(iConfig.getParameter<bool>("ResPlotOpt")),
0337 
0338         // Name of output EDM file if any.
0339         // N.B. This parameter does not appear inside TMTrackProducer_Defaults_cfi.py . It is created inside
0340         // tmtt_tf_analysis_cfg.py .
0341         writeOutEdmFile_(iConfig.getUntrackedParameter<bool>("WriteOutEdmFile", true)),
0342 
0343         // Bfield in Tesla. (Unknown at job initiation. Set to true value for each event
0344         magneticField_(0.),
0345 
0346         // Hybrid tracking
0347         hybrid_(iConfig.getParameter<bool>("Hybrid")) {
0348     // If user didn't specify any PDG codes, use e,mu,pi,K,p, to avoid picking up unstable particles like Xi-.
0349     vector<unsigned int> genPdgIdsUnsigned(genCuts_.getParameter<vector<unsigned int>>("GenPdgIds"));
0350     if (genPdgIdsUnsigned.empty()) {
0351       genPdgIdsUnsigned = {11, 13, 211, 321, 2212};
0352     }
0353 
0354     // For simplicity, user need not distinguish particles from antiparticles in configuration file.
0355     // But here we must store both explicitely in Settings, since TrackingParticleSelector expects them.
0356     for (unsigned int i = 0; i < genPdgIdsUnsigned.size(); i++) {
0357       genPdgIds_.push_back(genPdgIdsUnsigned[i]);
0358       genPdgIds_.push_back(-genPdgIdsUnsigned[i]);
0359     }
0360 
0361     // Clean up list of fitters that require the r-z track filter to be run before them,
0362     // by removing those fitters that are not to be run.
0363     vector<string> useRZfilterTmp;
0364     for (const string& name : useRZfilter_) {
0365       if (std::count(trackFitters_.begin(), trackFitters_.end(), name) > 0)
0366         useRZfilterTmp.push_back(name);
0367     }
0368     useRZfilter_ = useRZfilterTmp;
0369 
0370     // As python cfg doesn't know type "vbool", fix it here.
0371     for (unsigned int i = 0; i < barrelVsTypeTmp_.size(); i++) {
0372       barrelVsType_.push_back(bool(barrelVsTypeTmp_[i]));
0373       psVsType_.push_back(bool(psVsTypeTmp_[i]));
0374       tiltedVsType_.push_back(bool(tiltedVsTypeTmp_[i]));
0375     }
0376 
0377     //--- Sanity checks
0378 
0379     if (!(useStubPhi_ || useStubPhiTrk_))
0380       throw cms::Exception("BadConfig")
0381           << "Settings: Invalid cfg parameters - You cant set both UseStubPhi & useStubPhiTrk to false.";
0382 
0383     if (minNumMatchLayers_ > minStubLayers_)
0384       throw cms::Exception("BadConfig")
0385           << "Settings: Invalid cfg parameters - You are setting the minimum number of layers incorrectly : type A.";
0386     if (genMinStubLayers_ > minStubLayers_)
0387       throw cms::Exception("BadConfig")
0388           << "Settings: Invalid cfg parameters - You are setting the minimum number of layers incorrectly : type B.";
0389     if (minNumMatchLayers_ > genMinStubLayers_)
0390       throw cms::Exception("BadConfig")
0391           << "Settings: Invalid cfg parameters - You are setting the minimum number of layers incorrectly : type C.";
0392 
0393     // If reducing number of required layers for high Pt tracks, then above checks must be redone.
0394     bool doReduceLayers = (minPtToReduceLayers_ < 10000. || not etaSecsReduceLayers_.empty());
0395     if (doReduceLayers && minStubLayers_ > 4) {
0396       if (minNumMatchLayers_ > minStubLayers_ - 1)
0397         throw cms::Exception("BadConfig")
0398             << "Settings: Invalid cfg parameters - You are setting the minimum number of layers incorrectly : type D.";
0399       if (genMinStubLayers_ > minStubLayers_ - 1)
0400         throw cms::Exception("BadConfig")
0401             << "Settings: Invalid cfg parameters - You are setting the minimum number of layers incorrectly : type E.";
0402     }
0403 
0404     constexpr float verySmall = 0.1;
0405     if (houghMinPt_ < verySmall)
0406       throw cms::Exception("BadConfig") << "Settings: Invalid cfg parameters -- HoughMinPt must be positive.";
0407     miniHoughMinPt_ = std::max(miniHoughMinPt_, houghMinPt_);
0408 
0409     for (const unsigned int& iEtaReg : etaSecsReduceLayers_) {
0410       if (iEtaReg >= etaRegions_.size())
0411         throw cms::Exception("BadConfig") << "Settings: You specified an eta sector number in EtaSecsReduceLayers "
0412                                              "which exceeds the total number of eta sectors! "
0413                                           << iEtaReg << " " << etaRegions_.size();
0414     }
0415 
0416     // Chains of m bin ranges for output of HT.
0417     if (!busySectorMbinOrder_.empty()) {
0418       // User has specified an order in which the m bins should be chained together. Check if it makes sense.
0419       if (busySectorMbinOrder_.size() != houghNbinsPt_)
0420         throw cms::Exception("BadConfig")
0421             << "Settings: Invalid cfg parameters - BusySectorMbinOrder used by HT MUX contains wrong number of "
0422                "elements. Unless you are optimising the MUX, suggest you configure it to an empty vector.";
0423       set<unsigned int> mOrderCheck;
0424       for (const unsigned int& m : busySectorMbinOrder_) {
0425         mOrderCheck.insert(m);
0426       }
0427       if (mOrderCheck.size() != houghNbinsPt_)
0428         throw cms::Exception("BadConfig")
0429             << "Settings: Invalid cfg parameters - BusySectorMbinOrder used by HT MUX contains duplicate elements.";
0430       unsigned int sum_nr = 0;
0431       for (unsigned int nr : busySectorMbinRanges_) {
0432         sum_nr += nr;
0433       }
0434       if (sum_nr != houghNbinsPt_)
0435         throw cms::Exception("BadConfig")
0436             << "Settings: Invalid cfg parameters - Sum of entries in BusySectorMbinRanges is incorrect.";
0437     }
0438 
0439     if (miniHTstage_) {
0440       if (enableMerge2x2_)
0441         throw cms::Exception("BadConfig")
0442             << "Settings: it is not allowed to enable both MiniHTstage & EnableMerge2x2 options.";
0443       // Options for 2nd stage mini HT
0444       if (shape_ != 0)
0445         throw cms::Exception("BadConfig")
0446             << "Settings: Invalid cfg parameters - 2nd stage mini HT only allowed for square-shaped cells.";
0447       if (miniHoughNbinsPt_ != 2 || miniHoughNbinsPhi_ != 2)
0448         throw cms::Exception("BadConfig") << "Settings: 2nd mini HT has so dar only been implemented in C++ for 2x2.";
0449     }
0450 
0451     if (enableMerge2x2_) {
0452       if (miniHTstage_)
0453         throw cms::Exception("BadConfig")
0454             << "Settings: it is not allowed to enable both MiniHTstage & EnableMerge2x2 options.";
0455       // Merging of HT cells has not yet been implemented for diamond or hexagonal HT cell shape.
0456       if (enableMerge2x2_ && shape_ != 0)
0457         throw cms::Exception("BadConfig")
0458             << "Settings: Invalid cfg parameters - merging only allowed for square-shaped cells.";
0459     }
0460 
0461     // Check Kalman fit params.
0462     if (kalmanMaxNumStubs_ < kalmanMinNumStubs_)
0463       throw cms::Exception("BadConfig")
0464           << "Settings: Invalid cfg parameters - KalmanMaxNumStubs is less than KalmanMaxNumStubs.";
0465   }
0466 
0467   bool Settings::isHTRPhiEtaRegWhitelisted(unsigned const iEtaReg) const {
0468     bool whitelisted = true;
0469 
0470     bool const whitelist_enabled = (!etaRegWhitelist_.empty());
0471     if (whitelist_enabled) {
0472       whitelisted = (std::count(etaRegWhitelist_.begin(), etaRegWhitelist_.end(), iEtaReg) > 0);
0473     }
0474 
0475     return whitelisted;
0476   }
0477 
0478 }  // namespace tmtt