Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-27 04:18:05

0001 #include "L1Trigger/L1TMuonEndCap/interface/SectorProcessor.h"
0002 
0003 SectorProcessor::SectorProcessor() {}
0004 
0005 SectorProcessor::~SectorProcessor() {}
0006 
0007 void SectorProcessor::configure(const EMTFSetup* setup, int verbose, int endcap, int sector) {
0008   emtf_assert(setup != nullptr);
0009   emtf_assert(emtf::MIN_ENDCAP <= endcap && endcap <= emtf::MAX_ENDCAP);
0010   emtf_assert(emtf::MIN_TRIGSECTOR <= sector && sector <= emtf::MAX_TRIGSECTOR);
0011 
0012   setup_ = setup;
0013   verbose_ = verbose;
0014   endcap_ = endcap;
0015   sector_ = sector;
0016 }
0017 
0018 void SectorProcessor::process(const edm::EventID& event_id,
0019                               const TriggerPrimitiveCollection& muon_primitives,
0020                               EMTFHitCollection& out_hits,
0021                               EMTFTrackCollection& out_tracks) const {
0022   auto cfg = setup_->getVersionControl();
0023 
0024   // List of converted hits, extended from previous BXs
0025   // deque (double-ended queue) is similar to a vector, but allows insertion or deletion of elements at both beginning and end
0026   std::deque<EMTFHitCollection> extended_conv_hits;
0027 
0028   // List of best track candidates, extended from previous BXs
0029   std::deque<EMTFTrackCollection> extended_best_track_cands;
0030 
0031   // Map of pattern detector --> lifetime, tracked across BXs
0032   std::map<pattern_ref_t, int> patt_lifetime_map;
0033 
0034   // ___________________________________________________________________________
0035   // Run each sector processor for every BX, taking into account the BX window
0036 
0037   int delayBX = cfg.bxWindow_ - 1;
0038 
0039   for (int bx = cfg.minBX_; bx <= cfg.maxBX_ + delayBX; ++bx) {
0040     if (verbose_ > 0) {  // debug
0041       std::cout << "Event: " << event_id << " Endcap: " << endcap_ << " Sector: " << sector_ << " BX: " << bx
0042                 << std::endl;
0043     }
0044 
0045     process_single_bx(
0046         bx, muon_primitives, out_hits, out_tracks, extended_conv_hits, extended_best_track_cands, patt_lifetime_map);
0047 
0048     // Drop earliest BX outside of BX window
0049     if (bx >= cfg.minBX_ + delayBX) {
0050       extended_conv_hits.pop_front();
0051 
0052       int n = emtf::zone_array<int>().size();
0053       extended_best_track_cands.erase(extended_best_track_cands.end() - n,
0054                                       extended_best_track_cands.end());  // pop_back
0055     }
0056   }  // end loop over bx
0057 
0058   return;
0059 }
0060 
0061 void SectorProcessor::process_single_bx(int bx,
0062                                         const TriggerPrimitiveCollection& muon_primitives,
0063                                         EMTFHitCollection& out_hits,
0064                                         EMTFTrackCollection& out_tracks,
0065                                         std::deque<EMTFHitCollection>& extended_conv_hits,
0066                                         std::deque<EMTFTrackCollection>& extended_best_track_cands,
0067                                         std::map<pattern_ref_t, int>& patt_lifetime_map) const {
0068   auto cfg = setup_->getVersionControl();
0069 
0070   auto tp_geom_ = &(setup_->getGeometryTranslator());
0071   auto pc_lut_ = &(setup_->getSectorProcessorLUT());
0072   auto pt_assign_engine_ = setup_->getPtAssignmentEngine();
0073   auto pt_assign_engine_dxy_ = setup_->getPtAssignmentEngineDxy();
0074 
0075   // ___________________________________________________________________________
0076   // Configure
0077 
0078   PrimitiveSelection prim_sel;
0079   prim_sel.configure(verbose_,
0080                      endcap_,
0081                      sector_,
0082                      bx,
0083                      cfg.bxShiftCSC_,
0084                      cfg.bxShiftRPC_,
0085                      cfg.bxShiftGEM_,
0086                      cfg.bxShiftME0_,
0087                      cfg.includeNeighbor_,
0088                      cfg.duplicateTheta_,
0089                      cfg.bugME11Dupes_);
0090 
0091   PrimitiveConversion prim_conv;
0092   prim_conv.configure(tp_geom_,
0093                       pc_lut_,
0094                       verbose_,
0095                       endcap_,
0096                       sector_,
0097                       bx,
0098                       cfg.bxShiftCSC_,
0099                       cfg.bxShiftRPC_,
0100                       cfg.bxShiftGEM_,
0101                       cfg.bxShiftME0_,
0102                       cfg.zoneBoundaries_,
0103                       cfg.zoneOverlap_,
0104                       cfg.duplicateTheta_,
0105                       cfg.fixZonePhi_,
0106                       cfg.useNewZones_,
0107                       cfg.fixME11Edges_,
0108                       cfg.bugME11Dupes_,
0109                       cfg.useRun3CCLUT_OTMB_,
0110                       cfg.useRun3CCLUT_TMB_);
0111 
0112   PatternRecognition patt_recog;
0113   patt_recog.configure(verbose_,
0114                        endcap_,
0115                        sector_,
0116                        bx,
0117                        cfg.bxWindow_,
0118                        cfg.pattDefinitions_,
0119                        cfg.symPattDefinitions_,
0120                        cfg.useSymPatterns_,
0121                        cfg.maxRoadsPerZone_,
0122                        cfg.useSecondEarliest_);
0123 
0124   PrimitiveMatching prim_match;
0125   prim_match.configure(
0126       verbose_, endcap_, sector_, bx, cfg.fixZonePhi_, cfg.useNewZones_, cfg.bugSt2PhDiff_, cfg.bugME11Dupes_);
0127 
0128   AngleCalculation angle_calc;
0129   angle_calc.configure(verbose_,
0130                        endcap_,
0131                        sector_,
0132                        bx,
0133                        cfg.bxWindow_,
0134                        cfg.thetaWindow_,
0135                        cfg.thetaWindowZone0_,
0136                        cfg.bugME11Dupes_,
0137                        cfg.bugAmbigThetaWin_,
0138                        cfg.twoStationSameBX_);
0139 
0140   BestTrackSelection btrack_sel;
0141   btrack_sel.configure(verbose_,
0142                        endcap_,
0143                        sector_,
0144                        bx,
0145                        cfg.bxWindow_,
0146                        cfg.maxRoadsPerZone_,
0147                        cfg.maxTracks_,
0148                        cfg.useSecondEarliest_,
0149                        cfg.bugSameSectorPt0_);
0150 
0151   SingleHitTrack single_hit;
0152   single_hit.configure(verbose_, endcap_, sector_, bx, cfg.maxTracks_, cfg.useSingleHits_);
0153 
0154   PtAssignment pt_assign;
0155   pt_assign.configure(pt_assign_engine_,
0156                       pt_assign_engine_dxy_,
0157                       verbose_,
0158                       endcap_,
0159                       sector_,
0160                       bx,
0161                       cfg.readPtLUTFile_,
0162                       cfg.fixMode15HighPt_,
0163                       cfg.bug9BitDPhi_,
0164                       cfg.bugMode7CLCT_,
0165                       cfg.bugNegPt_,
0166                       cfg.bugGMTPhi_,
0167                       cfg.promoteMode7_,
0168                       cfg.modeQualVer_,
0169                       cfg.pbFileName_);
0170 
0171   std::map<int, TriggerPrimitiveCollection> selected_dt_map;
0172   std::map<int, TriggerPrimitiveCollection> selected_csc_map;
0173   std::map<int, TriggerPrimitiveCollection> selected_rpc_map;
0174   std::map<int, TriggerPrimitiveCollection> selected_gem_map;
0175   std::map<int, TriggerPrimitiveCollection> selected_me0_map;
0176   std::map<int, TriggerPrimitiveCollection> selected_prim_map;
0177   std::map<int, TriggerPrimitiveCollection> inclusive_selected_prim_map;
0178 
0179   EMTFHitCollection conv_hits;  // "converted" hits converted by primitive converter
0180   EMTFHitCollection inclusive_conv_hits;
0181 
0182   emtf::zone_array<EMTFRoadCollection> zone_roads;  // each zone has its road collection
0183 
0184   emtf::zone_array<EMTFTrackCollection> zone_tracks;  // each zone has its track collection
0185 
0186   EMTFTrackCollection best_tracks;  // "best" tracks selected from all the zones
0187 
0188   // ___________________________________________________________________________
0189   // Process
0190 
0191   // Select muon primitives that belong to this sector and this BX.
0192   // Put them into maps with an index that roughly corresponds to
0193   // each input link.
0194   // From src/PrimitiveSelection.cc
0195   prim_sel.process(emtf::DTTag(), muon_primitives, selected_dt_map);
0196   prim_sel.process(emtf::CSCTag(), muon_primitives, selected_csc_map);
0197   prim_sel.process(emtf::RPCTag(), muon_primitives, selected_rpc_map);
0198   prim_sel.process(emtf::GEMTag(), muon_primitives, selected_gem_map);
0199   prim_sel.process(emtf::ME0Tag(), muon_primitives, selected_me0_map);
0200   prim_sel.merge(
0201       selected_dt_map, selected_csc_map, selected_rpc_map, selected_gem_map, selected_me0_map, selected_prim_map);
0202 
0203   // Convert trigger primitives into "converted" hits
0204   // A converted hit consists of integer representations of phi, theta, and zones
0205   // From src/PrimitiveConversion.cc
0206   prim_conv.process(selected_prim_map, conv_hits);
0207   extended_conv_hits.push_back(conv_hits);
0208 
0209   {
0210     // Keep all the converted hits for the use of data-emulator comparisons.
0211     // They include the extra ones that are not used in track building and the subsequent steps.
0212     prim_sel.merge_no_truncate(selected_dt_map,
0213                                selected_csc_map,
0214                                selected_rpc_map,
0215                                selected_gem_map,
0216                                selected_me0_map,
0217                                inclusive_selected_prim_map);
0218     prim_conv.process(inclusive_selected_prim_map, inclusive_conv_hits);
0219 
0220     // Clear the input maps to save memory
0221     selected_dt_map.clear();
0222     selected_csc_map.clear();
0223     selected_rpc_map.clear();
0224     selected_gem_map.clear();
0225     selected_me0_map.clear();
0226   }
0227 
0228   // Detect patterns in all zones, find 3 best roads in each zone
0229   // From src/PatternRecognition.cc
0230   patt_recog.process(extended_conv_hits, patt_lifetime_map, zone_roads);
0231 
0232   // Match the trigger primitives to the roads, create tracks
0233   // From src/PrimitiveMatching.cc
0234   prim_match.process(extended_conv_hits, zone_roads, zone_tracks);
0235 
0236   // Calculate deflection angles for each track and fill track variables
0237   // From src/AngleCalculation.cc
0238   angle_calc.process(zone_tracks);
0239   extended_best_track_cands.insert(
0240       extended_best_track_cands.begin(), zone_tracks.begin(), zone_tracks.end());  // push_front
0241 
0242   // Select 3 "best" tracks from all the zones
0243   // From src/BestTrackSelection.cc
0244   btrack_sel.process(extended_best_track_cands, best_tracks);
0245 
0246   // Insert single LCTs from station 1 as tracks
0247   // From src/SingleHitTracks.cc
0248   single_hit.process(conv_hits, best_tracks);
0249 
0250   // Construct pT address, assign pT, calculate other GMT quantities
0251   // From src/PtAssignment.cc
0252   pt_assign.process(best_tracks);
0253 
0254   // ___________________________________________________________________________
0255   // Output
0256 
0257   out_hits.insert(out_hits.end(), inclusive_conv_hits.begin(), inclusive_conv_hits.end());
0258   out_tracks.insert(out_tracks.end(), best_tracks.begin(), best_tracks.end());
0259 
0260   return;
0261 }