Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-22 00:47:28

0001 #include "RecoTracker/MkFitCore/interface/cms_common_macros.h"
0002 #include "RecoTracker/MkFitCore/interface/Track.h"
0003 #include "RecoTracker/MkFitCore/interface/TrackerInfo.h"
0004 #include "RecoTracker/MkFitCore/interface/HitStructures.h"
0005 #include "RecoTracker/MkFitCore/interface/IterationConfig.h"
0006 
0007 namespace {
0008   using namespace mkfit;
0009 
0010   [[maybe_unused]] void partitionSeeds0(const TrackerInfo &trk_info,
0011                                         const TrackVec &in_seeds,
0012                                         const EventOfHits &eoh,
0013                                         IterationSeedPartition &part) {
0014     const size_t size = in_seeds.size();
0015 
0016     for (size_t i = 0; i < size; ++i) {
0017       const Track &S = in_seeds[i];
0018 
0019       const bool z_dir_pos = S.pz() > 0;
0020 
0021       const auto &hot = S.getLastHitOnTrack();
0022       const float eta = eoh[hot.layer].refHit(hot.index).eta();
0023 
0024       // Region to be defined by propagation / intersection tests
0025       TrackerInfo::EtaRegion reg;
0026 
0027       const LayerInfo &outer_brl = trk_info.outer_barrel_layer();
0028 
0029       // Define first (mkFit) layer IDs for each strip subdetector.
0030       constexpr int tib1_id = 4;
0031       constexpr int tob1_id = 10;
0032       constexpr int tecp1_id = 27;
0033       constexpr int tecn1_id = 54;
0034 
0035       const LayerInfo &tib1 = trk_info.layer(tib1_id);
0036       const LayerInfo &tob1 = trk_info.layer(tob1_id);
0037 
0038       const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
0039       const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
0040 
0041       const LayerInfo &tec_first = z_dir_pos ? tecp1 : tecn1;
0042 
0043       const float maxR = S.maxReachRadius();
0044       float z_at_maxr;
0045 
0046       bool can_reach_outer_brl = S.canReachRadius(outer_brl.rout());
0047       float z_at_outer_brl;
0048       bool misses_first_tec;
0049       if (can_reach_outer_brl) {
0050         z_at_outer_brl = S.zAtR(outer_brl.rout());
0051         if (z_dir_pos)
0052           misses_first_tec = z_at_outer_brl < tec_first.zmin();
0053         else
0054           misses_first_tec = z_at_outer_brl > tec_first.zmax();
0055       } else {
0056         z_at_maxr = S.zAtR(maxR);
0057         if (z_dir_pos)
0058           misses_first_tec = z_at_maxr < tec_first.zmin();
0059         else
0060           misses_first_tec = z_at_maxr > tec_first.zmax();
0061       }
0062 
0063       if (misses_first_tec) {
0064         reg = TrackerInfo::Reg_Barrel;
0065       } else {
0066         if ((S.canReachRadius(tib1.rin()) && tib1.is_within_z_limits(S.zAtR(tib1.rin()))) ||
0067             (S.canReachRadius(tob1.rin()) && tob1.is_within_z_limits(S.zAtR(tob1.rin())))) {
0068           reg = z_dir_pos ? TrackerInfo::Reg_Transition_Pos : TrackerInfo::Reg_Transition_Neg;
0069         } else {
0070           reg = z_dir_pos ? TrackerInfo::Reg_Endcap_Pos : TrackerInfo::Reg_Endcap_Neg;
0071         }
0072       }
0073 
0074       part.m_region[i] = reg;
0075       if (part.m_phi_eta_foo)
0076         part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
0077     }
0078   }
0079 
0080   [[maybe_unused]] void partitionSeeds1(const TrackerInfo &trk_info,
0081                                         const TrackVec &in_seeds,
0082                                         const EventOfHits &eoh,
0083                                         IterationSeedPartition &part) {
0084     // Define first (mkFit) layer IDs for each strip subdetector.
0085     constexpr int tib1_id = 4;
0086     constexpr int tob1_id = 10;
0087     constexpr int tidp1_id = 21;
0088     constexpr int tidn1_id = 48;
0089     constexpr int tecp1_id = 27;
0090     constexpr int tecn1_id = 54;
0091 
0092     const LayerInfo &tib1 = trk_info.layer(tib1_id);
0093     const LayerInfo &tob1 = trk_info.layer(tob1_id);
0094 
0095     const LayerInfo &tidp1 = trk_info.layer(tidp1_id);
0096     const LayerInfo &tidn1 = trk_info.layer(tidn1_id);
0097 
0098     const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
0099     const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
0100 
0101     // Merge first two layers to account for mono/stereo coverage.
0102     // TrackerInfo could hold joint limits for sub-detectors.
0103     const auto &L = trk_info;
0104     const float tidp_rin = std::min(L[tidp1_id].rin(), L[tidp1_id + 1].rin());
0105     const float tidp_rout = std::max(L[tidp1_id].rout(), L[tidp1_id + 1].rout());
0106     const float tecp_rin = std::min(L[tecp1_id].rin(), L[tecp1_id + 1].rin());
0107     const float tecp_rout = std::max(L[tecp1_id].rout(), L[tecp1_id + 1].rout());
0108     const float tidn_rin = std::min(L[tidn1_id].rin(), L[tidn1_id + 1].rin());
0109     const float tidn_rout = std::max(L[tidn1_id].rout(), L[tidn1_id + 1].rout());
0110     const float tecn_rin = std::min(L[tecn1_id].rin(), L[tecn1_id + 1].rin());
0111     const float tecn_rout = std::max(L[tecn1_id].rout(), L[tecn1_id + 1].rout());
0112 
0113     // Bias towards more aggressive transition-region assignemnts.
0114     // With current tunning it seems to make things a bit worse.
0115     const float tid_z_extra = 0.0f;  // 5.0f;
0116     const float tec_z_extra = 0.0f;  // 10.0f;
0117 
0118     const size_t size = in_seeds.size();
0119 
0120     auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax) -> bool {
0121       bool inside = maxR > rin && S.zAtR(rin) < zmax;
0122       return inside;
0123     };
0124 
0125     auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin) -> bool {
0126       bool inside = maxR > rin && S.zAtR(rin) > zmin;
0127       return inside;
0128     };
0129 
0130     auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin) -> bool {
0131       bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
0132       return inside;
0133     };
0134 
0135     auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax) -> bool {
0136       bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
0137       return inside;
0138     };
0139 
0140     for (size_t i = 0; i < size; ++i) {
0141       const Track &S = in_seeds[i];
0142 
0143       const auto &hot = S.getLastHitOnTrack();
0144       const float eta = eoh[hot.layer].refHit(hot.index).eta();
0145 
0146       // Region to be defined by propagation / intersection tests
0147       TrackerInfo::EtaRegion reg;
0148 
0149       const bool z_dir_pos = S.pz() > 0;
0150       const float maxR = S.maxReachRadius();
0151 
0152       if (z_dir_pos) {
0153         const bool in_tib = barrel_pos_check(S, maxR, tib1.rin(), tib1.zmax());
0154         const bool in_tob = barrel_pos_check(S, maxR, tob1.rin(), tob1.zmax());
0155 
0156         if (!in_tib && !in_tob) {
0157           reg = TrackerInfo::Reg_Endcap_Pos;
0158         } else {
0159           const bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.zmin() - tid_z_extra);
0160           const bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.zmin() - tec_z_extra);
0161 
0162           if (!in_tid && !in_tec) {
0163             reg = TrackerInfo::Reg_Barrel;
0164           } else {
0165             reg = TrackerInfo::Reg_Transition_Pos;
0166           }
0167         }
0168       } else {
0169         const bool in_tib = barrel_neg_check(S, maxR, tib1.rin(), tib1.zmin());
0170         const bool in_tob = barrel_neg_check(S, maxR, tob1.rin(), tob1.zmin());
0171 
0172         if (!in_tib && !in_tob) {
0173           reg = TrackerInfo::Reg_Endcap_Neg;
0174         } else {
0175           const bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.zmax() + tid_z_extra);
0176           const bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.zmax() + tec_z_extra);
0177 
0178           if (!in_tid && !in_tec) {
0179             reg = TrackerInfo::Reg_Barrel;
0180           } else {
0181             reg = TrackerInfo::Reg_Transition_Neg;
0182           }
0183         }
0184       }
0185 
0186       part.m_region[i] = reg;
0187       if (part.m_phi_eta_foo)
0188         part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
0189     }
0190   }
0191 
0192   [[maybe_unused]] void partitionSeeds1debug(const TrackerInfo &trk_info,
0193                                              const TrackVec &in_seeds,
0194                                              const EventOfHits &eoh,
0195                                              IterationSeedPartition &part) {
0196     // Define first (mkFit) layer IDs for each strip subdetector.
0197     constexpr int tib1_id = 4;
0198     constexpr int tob1_id = 10;
0199     constexpr int tidp1_id = 21;
0200     constexpr int tidn1_id = 48;
0201     constexpr int tecp1_id = 27;
0202     constexpr int tecn1_id = 54;
0203 
0204     const LayerInfo &tib1 = trk_info.layer(tib1_id);
0205     const LayerInfo &tob1 = trk_info.layer(tob1_id);
0206 
0207     const LayerInfo &tidp1 = trk_info.layer(tidp1_id);
0208     const LayerInfo &tidn1 = trk_info.layer(tidn1_id);
0209 
0210     const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
0211     const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
0212 
0213     // Merge first two layers to account for mono/stereo coverage.
0214     // TrackerInfo could hold joint limits for sub-detectors.
0215     const auto &L = trk_info;
0216     const float tidp_rin = std::min(L[tidp1_id].rin(), L[tidp1_id + 1].rin());
0217     const float tidp_rout = std::max(L[tidp1_id].rout(), L[tidp1_id + 1].rout());
0218     const float tecp_rin = std::min(L[tecp1_id].rin(), L[tecp1_id + 1].rin());
0219     const float tecp_rout = std::max(L[tecp1_id].rout(), L[tecp1_id + 1].rout());
0220     const float tidn_rin = std::min(L[tidn1_id].rin(), L[tidn1_id + 1].rin());
0221     const float tidn_rout = std::max(L[tidn1_id].rout(), L[tidn1_id + 1].rout());
0222     const float tecn_rin = std::min(L[tecn1_id].rin(), L[tecn1_id + 1].rin());
0223     const float tecn_rout = std::max(L[tecn1_id].rout(), L[tecn1_id + 1].rout());
0224 
0225     // Bias towards more aggressive transition-region assignemnts.
0226     // With current tunning it seems to make things a bit worse.
0227     const float tid_z_extra = 0.0f;  //  5.0f;
0228     const float tec_z_extra = 0.0f;  // 10.0f;
0229 
0230     const int size = in_seeds.size();
0231 
0232     auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax, const char *det) -> bool {
0233       bool inside = maxR > rin && S.zAtR(rin) < zmax;
0234 
0235       printf("  in_%s=%d  maxR=%7.3f, rin=%7.3f -- ", det, inside, maxR, rin);
0236       if (maxR > rin) {
0237         printf("maxR > rin:   S.zAtR(rin) < zmax  -- %.3f <? %.3f\n", S.zAtR(rin), zmax);
0238       } else {
0239         printf("maxR < rin: no pie.\n");
0240       }
0241 
0242       return inside;
0243     };
0244 
0245     auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin, const char *det) -> bool {
0246       bool inside = maxR > rin && S.zAtR(rin) > zmin;
0247 
0248       printf("  in_%s=%d  maxR=%7.3f, rin=%7.3f -- ", det, inside, maxR, rin);
0249       if (maxR > rin) {
0250         printf("maxR > rin:   S.zAtR(rin) > zmin  -- %.3f >? %.3f\n", S.zAtR(rin), zmin);
0251       } else {
0252         printf("maxR < rin: no pie.\n");
0253       }
0254 
0255       return inside;
0256     };
0257 
0258     auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin, const char *det) -> bool {
0259       bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
0260 
0261       printf("  in_%s=%d  maxR=%7.3f, rout=%7.3f, rin=%7.3f -- ", det, inside, maxR, rout, rin);
0262       if (maxR > rout) {
0263         printf("maxR > rout:  S.zAtR(rout) > zmin  -- %.3f >? %.3f\n", S.zAtR(rout), zmin);
0264       } else if (maxR > rin) {
0265         printf("maxR > rin:   S.zAtR(maxR) > zmin) -- %.3f >? %.3f\n", S.zAtR(maxR), zmin);
0266       } else {
0267         printf("maxR < rin: no pie.\n");
0268       }
0269 
0270       return inside;
0271     };
0272 
0273     auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax, const char *det) -> bool {
0274       bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
0275 
0276       printf("  in_%s=%d  maxR=%7.3f, rout=%7.3f, rin=%7.3f -- ", det, inside, maxR, rout, rin);
0277       if (maxR > rout) {
0278         printf("maxR > rout:  S.zAtR(rout) < zmax  -- %.3f <? %.3f\n", S.zAtR(rout), zmax);
0279       } else if (maxR > rin) {
0280         printf("maxR > rin:   S.zAtR(maxR) < zmax  -- %.3f <? %.3f\n", S.zAtR(maxR), zmax);
0281       } else {
0282         printf("maxR < rin: no pie.\n");
0283       }
0284 
0285       return inside;
0286     };
0287 
0288     for (int i = 0; i < size; ++i) {
0289       const Track &S = in_seeds[i];
0290 
0291       HitOnTrack hot = S.getLastHitOnTrack();
0292       float eta = eoh[hot.layer].refHit(hot.index).eta();
0293       // float  eta = S.momEta();
0294 
0295       // Region to be defined by propagation / intersection tests
0296       TrackerInfo::EtaRegion reg;
0297 
0298       const bool z_dir_pos = S.pz() > 0;
0299       const float maxR = S.maxReachRadius();
0300 
0301       printf("partitionSeeds1debug seed index %d, z_dir_pos=%d (pz=%.3f), maxR=%.3f\n", i, z_dir_pos, S.pz(), maxR);
0302 
0303       if (z_dir_pos) {
0304         bool in_tib = barrel_pos_check(S, maxR, tib1.rin(), tib1.zmax(), "TIBp");
0305         bool in_tob = barrel_pos_check(S, maxR, tob1.rin(), tob1.zmax(), "TOBp");
0306 
0307         if (!in_tib && !in_tob) {
0308           reg = TrackerInfo::Reg_Endcap_Pos;
0309           printf("  --> region = %d, endcap pos\n", reg);
0310         } else {
0311           bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.zmin() - tid_z_extra, "TIDp");
0312           bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.zmin() - tec_z_extra, "TECp");
0313 
0314           if (!in_tid && !in_tec) {
0315             reg = TrackerInfo::Reg_Barrel;
0316             printf("  --> region = %d, barrel\n", reg);
0317           } else {
0318             reg = TrackerInfo::Reg_Transition_Pos;
0319             printf("  --> region = %d, transition pos\n", reg);
0320           }
0321         }
0322       } else {
0323         bool in_tib = barrel_neg_check(S, maxR, tib1.rin(), tib1.zmin(), "TIBn");
0324         bool in_tob = barrel_neg_check(S, maxR, tob1.rin(), tob1.zmin(), "TOBn");
0325 
0326         if (!in_tib && !in_tob) {
0327           reg = TrackerInfo::Reg_Endcap_Neg;
0328           printf("  --> region = %d, endcap neg\n", reg);
0329         } else {
0330           bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.zmax() + tid_z_extra, "TIDn");
0331           bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.zmax() + tec_z_extra, "TECn");
0332 
0333           if (!in_tid && !in_tec) {
0334             reg = TrackerInfo::Reg_Barrel;
0335             printf("  --> region = %d, barrel\n", reg);
0336           } else {
0337             reg = TrackerInfo::Reg_Transition_Neg;
0338             printf("  --> region = %d, transition neg\n", reg);
0339           }
0340         }
0341       }
0342 
0343       part.m_region[i] = reg;
0344       if (part.m_phi_eta_foo)
0345         part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
0346     }
0347   }
0348 
0349   CMS_SA_ALLOW struct register_seed_partitioners {
0350     register_seed_partitioners() {
0351       IterationConfig::register_seed_partitioner("phase1:0", partitionSeeds0);
0352       IterationConfig::register_seed_partitioner("phase1:1", partitionSeeds1);
0353       IterationConfig::register_seed_partitioner("phase1:1:debug", partitionSeeds1debug);
0354     }
0355   } rsp_instance;
0356 }  // namespace