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   // named constants for useful layers (l/u for lower/upper)
0011   constexpr int tecp1l_id = 28;
0012   constexpr int tecp1u_id = 29;
0013   constexpr int tecp2l_id = 30;
0014   constexpr int tecp2u_id = 31;
0015   constexpr int tecn1l_id = 50;
0016   constexpr int tecn1u_id = 51;
0017   constexpr int tecn2l_id = 52;
0018   constexpr int tecntu_id = 53;
0019 
0020   [[maybe_unused]] void partitionSeeds1(const TrackerInfo &trk_info,
0021                                         const TrackVec &in_seeds,
0022                                         const EventOfHits &eoh,
0023                                         IterationSeedPartition &part) {
0024     // Seeds are placed into eta regions and sorted on region + eta.
0025 
0026     // Merge mono and stereo limits for relevant layers / parameters.
0027     // TrackerInfo could hold joint limits for sub-detectors.
0028     const auto &L = trk_info;
0029     const float tecp1_rin = std::min(L[tecp1l_id].rin(), L[tecp1u_id].rin());
0030     const float tecp1_rout = std::max(L[tecp1l_id].rout(), L[tecp1u_id].rout());
0031     const float tecp1_zmin = std::min(L[tecp1l_id].zmin(), L[tecp1u_id].zmin());
0032 
0033     const float tecp2_rin = std::min(L[tecp2l_id].rin(), L[tecp2u_id].rin());
0034     const float tecp2_zmax = std::max(L[tecp2l_id].zmax(), L[tecp2u_id].zmax());
0035 
0036     const float tecn1_rin = std::min(L[tecn1l_id].rin(), L[tecn1u_id].rin());
0037     const float tecn1_rout = std::max(L[tecn1l_id].rout(), L[tecn1u_id].rout());
0038     const float tecn1_zmax = std::max(L[tecn1l_id].zmax(), L[tecn1u_id].zmax());
0039 
0040     const float tecn2_rin = std::min(L[tecn2l_id].rin(), L[tecntu_id].rin());
0041     const float tecn2_zmin = std::min(L[tecn2l_id].zmin(), L[tecntu_id].zmin());
0042 
0043     const float tec_z_extra = 0.0f;  // 10.0f;
0044 
0045     const int size = in_seeds.size();
0046 
0047     auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax) -> bool {
0048       bool inside = maxR > rin && S.zAtR(rin) < zmax;
0049       return inside;
0050     };
0051 
0052     auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin) -> bool {
0053       bool inside = maxR > rin && S.zAtR(rin) > zmin;
0054       return inside;
0055     };
0056 
0057     auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin) -> bool {
0058       bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
0059       return inside;
0060     };
0061 
0062     auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax) -> bool {
0063       bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
0064       return inside;
0065     };
0066 
0067     for (int i = 0; i < size; ++i) {
0068       const Track &S = in_seeds[i];
0069 
0070       HitOnTrack hot = S.getLastHitOnTrack();
0071       float eta = eoh[hot.layer].refHit(hot.index).eta();
0072 
0073       // Region to be defined by propagation / intersection tests
0074       TrackerInfo::EtaRegion reg;
0075 
0076       const bool z_dir_pos = S.pz() > 0;
0077       const float maxR = S.maxReachRadius();
0078 
0079       if (z_dir_pos) {
0080         bool in_tec_as_brl = barrel_pos_check(S, maxR, tecp2_rin, tecp2_zmax);
0081 
0082         if (!in_tec_as_brl) {
0083           reg = TrackerInfo::Reg_Endcap_Pos;
0084         } else {
0085           bool in_tec = endcap_pos_check(S, maxR, tecp1_rout, tecp1_rin, tecp1_zmin - tec_z_extra);
0086 
0087           if (!in_tec) {
0088             reg = TrackerInfo::Reg_Barrel;
0089           } else {
0090             reg = TrackerInfo::Reg_Transition_Pos;
0091           }
0092         }
0093       } else {
0094         bool in_tec_as_brl = barrel_neg_check(S, maxR, tecn2_rin, tecn2_zmin);
0095 
0096         if (!in_tec_as_brl) {
0097           reg = TrackerInfo::Reg_Endcap_Neg;
0098         } else {
0099           bool in_tec = endcap_neg_check(S, maxR, tecn1_rout, tecn1_rin, tecn1_zmax + tec_z_extra);
0100 
0101           if (!in_tec) {
0102             reg = TrackerInfo::Reg_Barrel;
0103           } else {
0104             reg = TrackerInfo::Reg_Transition_Neg;
0105           }
0106         }
0107       }
0108 
0109       part.m_region[i] = reg;
0110       if (part.m_phi_eta_foo)
0111         part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
0112     }
0113   }
0114 
0115   [[maybe_unused]] void partitionSeeds1debug(const TrackerInfo &trk_info,
0116                                              const TrackVec &in_seeds,
0117                                              const EventOfHits &eoh,
0118                                              IterationSeedPartition &part) {
0119     // Seeds are placed into eta regions and sorted on region + eta.
0120 
0121     // Merge mono and stereo limits for relevant layers / parameters.
0122     // TrackerInfo could hold joint limits for sub-detectors.
0123     const auto &L = trk_info;
0124     const float tecp1_rin = std::min(L[tecp1l_id].rin(), L[tecp1u_id].rin());
0125     const float tecp1_rout = std::max(L[tecp1l_id].rout(), L[tecp1u_id].rout());
0126     const float tecp1_zmin = std::min(L[tecp1l_id].zmin(), L[tecp1u_id].zmin());
0127 
0128     const float tecp2_rin = std::min(L[tecp2l_id].rin(), L[tecp2u_id].rin());
0129     const float tecp2_zmax = std::max(L[tecp2l_id].zmax(), L[tecp2u_id].zmax());
0130 
0131     const float tecn1_rin = std::min(L[tecn1l_id].rin(), L[tecn1u_id].rin());
0132     const float tecn1_rout = std::max(L[tecn1l_id].rout(), L[tecn1u_id].rout());
0133     const float tecn1_zmax = std::max(L[tecn1l_id].zmax(), L[tecn1u_id].zmax());
0134 
0135     const float tecn2_rin = std::min(L[tecn2l_id].rin(), L[tecntu_id].rin());
0136     const float tecn2_zmin = std::min(L[tecn2l_id].zmin(), L[tecntu_id].zmin());
0137 
0138     const float tec_z_extra = 0.0f;  // 10.0f;
0139 
0140     const int size = in_seeds.size();
0141 
0142     auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax, const char *det) -> bool {
0143       bool inside = maxR > rin && S.zAtR(rin) < zmax;
0144 
0145       printf("  in_%s=%d  maxR=%7.3f, rin=%7.3f -- ", det, inside, maxR, rin);
0146       if (maxR > rin) {
0147         printf("maxR > rin:   S.zAtR(rin) < zmax  -- %.3f <? %.3f\n", S.zAtR(rin), zmax);
0148       } else {
0149         printf("maxR < rin: no pie.\n");
0150       }
0151 
0152       return inside;
0153     };
0154 
0155     auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin, const char *det) -> bool {
0156       bool inside = maxR > rin && S.zAtR(rin) > zmin;
0157 
0158       printf("  in_%s=%d  maxR=%7.3f, rin=%7.3f -- ", det, inside, maxR, rin);
0159       if (maxR > rin) {
0160         printf("maxR > rin:   S.zAtR(rin) > zmin  -- %.3f >? %.3f\n", S.zAtR(rin), zmin);
0161       } else {
0162         printf("maxR < rin: no pie.\n");
0163       }
0164 
0165       return inside;
0166     };
0167 
0168     auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin, const char *det) -> bool {
0169       bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
0170 
0171       printf("  in_%s=%d  maxR=%7.3f, rout=%7.3f, rin=%7.3f -- ", det, inside, maxR, rout, rin);
0172       if (maxR > rout) {
0173         printf("maxR > rout:  S.zAtR(rout) > zmin  -- %.3f >? %.3f\n", S.zAtR(rout), zmin);
0174       } else if (maxR > rin) {
0175         printf("maxR > rin:   S.zAtR(maxR) > zmin) -- %.3f >? %.3f\n", S.zAtR(maxR), zmin);
0176       } else {
0177         printf("maxR < rin: no pie.\n");
0178       }
0179 
0180       return inside;
0181     };
0182 
0183     auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax, const char *det) -> bool {
0184       bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
0185 
0186       printf("  in_%s=%d  maxR=%7.3f, rout=%7.3f, rin=%7.3f -- ", det, inside, maxR, rout, rin);
0187       if (maxR > rout) {
0188         printf("maxR > rout:  S.zAtR(rout) < zmax  -- %.3f <? %.3f\n", S.zAtR(rout), zmax);
0189       } else if (maxR > rin) {
0190         printf("maxR > rin:   S.zAtR(maxR) < zmax  -- %.3f <? %.3f\n", S.zAtR(maxR), zmax);
0191       } else {
0192         printf("maxR < rin: no pie.\n");
0193       }
0194 
0195       return inside;
0196     };
0197 
0198     for (int i = 0; i < size; ++i) {
0199       const Track &S = in_seeds[i];
0200 
0201       HitOnTrack hot = S.getLastHitOnTrack();
0202       float eta = eoh[hot.layer].refHit(hot.index).eta();
0203       // float  eta = S.momEta();
0204 
0205       // Region to be defined by propagation / intersection tests
0206       TrackerInfo::EtaRegion reg;
0207 
0208       const bool z_dir_pos = S.pz() > 0;
0209       const float maxR = S.maxReachRadius();
0210 
0211       printf("partitionSeeds1debug seed index %d, z_dir_pos=%d (pz=%.3f), maxR=%.3f\n", i, z_dir_pos, S.pz(), maxR);
0212 
0213       if (z_dir_pos) {
0214         bool in_tec_as_brl = barrel_pos_check(S, maxR, tecp2_rin, tecp2_zmax, "TECasBarrelp");
0215 
0216         if (!in_tec_as_brl) {
0217           reg = TrackerInfo::Reg_Endcap_Pos;
0218           printf("  --> region = %d, endcap pos\n", reg);
0219         } else {
0220           bool in_tec = endcap_pos_check(S, maxR, tecp1_rout, tecp1_rin, tecp1_zmin - tec_z_extra, "TECp");
0221 
0222           if (!in_tec) {
0223             reg = TrackerInfo::Reg_Barrel;
0224             printf("  --> region = %d, barrel\n", reg);
0225           } else {
0226             reg = TrackerInfo::Reg_Transition_Pos;
0227             printf("  --> region = %d, transition pos\n", reg);
0228           }
0229         }
0230       } else {
0231         bool in_tec_as_brl = barrel_neg_check(S, maxR, tecn2_rin, tecn2_zmin, "TECasBarreln");
0232 
0233         if (!in_tec_as_brl) {
0234           reg = TrackerInfo::Reg_Endcap_Neg;
0235           printf("  --> region = %d, endcap neg\n", reg);
0236         } else {
0237           bool in_tec = endcap_neg_check(S, maxR, tecn1_rout, tecn1_rin, tecn1_zmax + tec_z_extra, "TECn");
0238 
0239           if (!in_tec) {
0240             reg = TrackerInfo::Reg_Barrel;
0241             printf("  --> region = %d, barrel\n", reg);
0242           } else {
0243             reg = TrackerInfo::Reg_Transition_Neg;
0244             printf("  --> region = %d, transition neg\n", reg);
0245           }
0246         }
0247       }
0248 
0249       part.m_region[i] = reg;
0250       if (part.m_phi_eta_foo)
0251         part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
0252     }
0253   }
0254 
0255   CMS_SA_ALLOW struct register_seed_partitioners {
0256     register_seed_partitioners() {
0257       IterationConfig::register_seed_partitioner("phase2:1", partitionSeeds1);
0258       IterationConfig::register_seed_partitioner("phase2:1:debug", partitionSeeds1debug);
0259     }
0260   } rsp_instance;
0261 }  // namespace