Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:22:29

0001 #ifndef RecoTracker_MkFitCore_interface_Config_h
0002 #define RecoTracker_MkFitCore_interface_Config_h
0003 
0004 namespace mkfit {
0005 
0006   enum PropagationFlagsEnum {
0007     PF_none = 0,
0008     PF_use_param_b_field = 0x1,
0009     PF_apply_material = 0x2,
0010     PF_copy_input_state_on_fail = 0x4
0011   };
0012 
0013   struct PropagationFlags {
0014     bool use_param_b_field : 1;
0015     bool apply_material : 1;
0016     bool copy_input_state_on_fail : 1;
0017     // Could add: bool use_trig_approx       -- now Config::useTrigApprox = true
0018     // Could add: int  n_prop_to_r_iters : 8 -- now Config::Niter = 5
0019 
0020     PropagationFlags() : use_param_b_field(false), apply_material(false), copy_input_state_on_fail(false) {}
0021 
0022     PropagationFlags(int pfe)
0023         : use_param_b_field(pfe & PF_use_param_b_field),
0024           apply_material(pfe & PF_apply_material),
0025           copy_input_state_on_fail(pfe & PF_copy_input_state_on_fail) {}
0026   };
0027 
0028   class PropagationConfig {
0029   public:
0030     bool backward_fit_to_pca;
0031     bool finding_requires_propagation_to_hit_pos;
0032     PropagationFlags finding_inter_layer_pflags;
0033     PropagationFlags finding_intra_layer_pflags;
0034     PropagationFlags backward_fit_pflags;
0035     PropagationFlags forward_fit_pflags;
0036     PropagationFlags seed_fit_pflags;
0037     PropagationFlags pca_prop_pflags;
0038 
0039     void set_as_default(bool force = false);
0040 
0041     static const PropagationConfig& get_default() { return *s_default; }
0042 
0043   private:
0044     static const PropagationConfig* s_default;
0045   };
0046 
0047   //------------------------------------------------------------------------------
0048 
0049   namespace Const {
0050     constexpr float PI = 3.14159265358979323846;
0051     constexpr float TwoPI = 6.28318530717958647692;
0052     constexpr float PIOver2 = Const::PI / 2.0f;
0053     constexpr float PIOver4 = Const::PI / 4.0f;
0054     constexpr float PI3Over4 = 3.0f * Const::PI / 4.0f;
0055     constexpr float InvPI = 1.0f / Const::PI;
0056     constexpr float sol = 0.299792458;  // speed of light in nm/s
0057 
0058     // NAN and silly track parameter tracking options
0059     constexpr bool nan_etc_sigs_enable = false;
0060 
0061     constexpr bool nan_n_silly_check_seeds = true;
0062     constexpr bool nan_n_silly_print_bad_seeds = false;
0063     constexpr bool nan_n_silly_fixup_bad_seeds = false;
0064     constexpr bool nan_n_silly_remove_bad_seeds = true;
0065 
0066     constexpr bool nan_n_silly_check_cands_every_layer = false;
0067     constexpr bool nan_n_silly_print_bad_cands_every_layer = false;
0068     constexpr bool nan_n_silly_fixup_bad_cands_every_layer = false;
0069 
0070     constexpr bool nan_n_silly_check_cands_pre_bkfit = true;
0071     constexpr bool nan_n_silly_check_cands_post_bkfit = true;
0072     constexpr bool nan_n_silly_print_bad_cands_bkfit = false;
0073   }  // namespace Const
0074 
0075   inline float cdist(float a) { return a > Const::PI ? Const::TwoPI - a : a; }
0076 
0077   //------------------------------------------------------------------------------
0078 
0079   namespace Config {
0080     // config for fitting
0081     constexpr int nLayers = 10;  // default/toy: 10; cms-like: 18 (barrel), 27 (endcap)
0082 
0083     // Layer constants for common barrel / endcap.
0084     // TrackerInfo more or less has all this information.
0085     constexpr int nMaxTrkHits = 64;  // Used for array sizes in MkFitter/Finder, max hits in toy MC
0086     constexpr int nAvgSimHits = 32;  // Used for reserve() calls for sim hits/states
0087 
0088     // This will become layer dependent (in bits). To be consistent with min_dphi.
0089     static constexpr int m_nphi = 256;
0090 
0091     // Config for propagation - could/should enter into PropagationFlags?!
0092     constexpr int Niter = 5;
0093     constexpr bool useTrigApprox = true;
0094 
0095     // Config for Bfield. Note: for now the same for CMS-phase1 and CylCowWLids.
0096     constexpr float Bfield = 3.8112;
0097     constexpr float mag_c1 = 3.8114;
0098     constexpr float mag_b0 = -3.94991e-06;
0099     constexpr float mag_b1 = 7.53701e-06;
0100     constexpr float mag_a = 2.43878e-11;
0101 
0102     // Config for SelectHitIndices
0103     // Use extra arrays to store phi and q of hits.
0104     // MT: This would in principle allow fast selection of good hits, if
0105     // we had good error estimates and reasonable *minimal* phi and q windows.
0106     // Speed-wise, those arrays (filling AND access, about half each) cost 1.5%
0107     // and could help us reduce the number of hits we need to process with bigger
0108     // potential gains.
0109 #ifdef CONFIG_PhiQArrays
0110     extern bool usePhiQArrays;
0111 #else
0112     constexpr bool usePhiQArrays = true;
0113 #endif
0114 
0115     // sorting config (bonus,penalty)
0116     constexpr float validHitBonus_ = 4;
0117     constexpr float validHitSlope_ = 0.2;
0118     constexpr float overlapHitBonus_ = 0;  // set to negative for penalty
0119     constexpr float missingHitPenalty_ = 8;
0120     constexpr float tailMissingHitPenalty_ = 3;
0121 
0122     // Threading
0123 #if defined(MKFIT_STANDALONE)
0124     extern int numThreadsFinder;
0125     extern int numThreadsEvents;
0126     extern int numSeedsPerTask;
0127 #else
0128     constexpr int numThreadsFinder = 1;
0129     constexpr int numThreadsEvents = 1;
0130     constexpr int numSeedsPerTask = 32;
0131 #endif
0132 
0133     // config on seed cleaning
0134     constexpr float track1GeVradius = 87.6;  // = 1/(c*B)
0135     constexpr float c_etamax_brl = 0.9;
0136     constexpr float c_dpt_common = 0.25;
0137     constexpr float c_dzmax_brl = 0.005;
0138     constexpr float c_drmax_brl = 0.010;
0139     constexpr float c_ptmin_hpt = 2.0;
0140     constexpr float c_dzmax_hpt = 0.010;
0141     constexpr float c_drmax_hpt = 0.010;
0142     constexpr float c_dzmax_els = 0.015;
0143     constexpr float c_drmax_els = 0.015;
0144 
0145     // config on duplicate removal
0146 #if defined(MKFIT_STANDALONE)
0147     extern bool useHitsForDuplicates;
0148     extern bool removeDuplicates;
0149 #else
0150     const bool useHitsForDuplicates = true;
0151 #endif
0152     extern const float maxdPhi;
0153     extern const float maxdPt;
0154     extern const float maxdEta;
0155     extern const float minFracHitsShared;
0156     extern const float maxdR;
0157 
0158     // duplicate removal: tighter version
0159     extern const float maxd1pt;
0160     extern const float maxdphi;
0161     extern const float maxdcth;
0162     extern const float maxcth_ob;
0163     extern const float maxcth_fw;
0164 
0165     // ================================================================
0166 
0167     inline float bFieldFromZR(const float z, const float r) {
0168       return (Config::mag_b0 * z * z + Config::mag_b1 * z + Config::mag_c1) * (Config::mag_a * r * r + 1.f);
0169     }
0170 
0171   };  // namespace Config
0172 
0173   //------------------------------------------------------------------------------
0174 
0175 }  // end namespace mkfit
0176 #endif