Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:59

0001 #include "L1Trigger/L1TMuonEndCap/interface/SingleHitTrack.h"
0002 
0003 void SingleHitTrack::configure(int verbose, int endcap, int sector, int bx, int maxTracks, bool useSingleHits) {
0004   verbose_ = verbose;
0005   endcap_ = endcap;
0006   sector_ = sector;
0007   bx_ = bx;
0008 
0009   maxTracks_ = maxTracks;
0010 
0011   useSingleHits_ = useSingleHits;
0012 }
0013 
0014 void SingleHitTrack::process(const EMTFHitCollection& conv_hits, EMTFTrackCollection& best_tracks) const {
0015   if (conv_hits.empty())
0016     return;
0017 
0018   if (!useSingleHits_)
0019     return;
0020 
0021   if (int(best_tracks.size()) >= maxTracks_)
0022     return;
0023 
0024   // New collection to contain single-hit tracks
0025   EMTFTrackCollection one_hit_trks;
0026 
0027   // Loop over [subsector, CSC ID] pairs in order: [2,3], [2,2], [2,1], [1,3], [1,2], [1,1]
0028   for (int sub_ID = 5; sub_ID >= 0; sub_ID--) {
0029     int subsector = 1 + (sub_ID / 3);
0030     int CSC_ID = 1 + (sub_ID % 3);
0031 
0032     // Loop over all the hits in a given BX
0033     for (const auto& conv_hits_it : conv_hits) {
0034       // Require subsector and CSC ID to match
0035       if (conv_hits_it.Subsector() != subsector || conv_hits_it.CSC_ID() != CSC_ID)
0036         continue;
0037 
0038       // Only consider CSC LCTs
0039       if (conv_hits_it.Is_CSC() != 1)
0040         continue;
0041 
0042       // Only consider hits in station 1, ring 1
0043       if (conv_hits_it.Station() != 1 || (conv_hits_it.Ring() % 3) != 1)
0044         continue;
0045 
0046       // Only consider hits in the same sector (not neighbor hits)
0047       if ((conv_hits_it.Endcap() == 1) != (endcap_ == 1) || conv_hits_it.Sector() != sector_)
0048         continue;
0049 
0050       // Check if a hit has already been used in a track
0051       bool already_used = false;
0052 
0053       // Loop over existing multi-hit tracks
0054       for (const auto& best_tracks_it : best_tracks) {
0055         // Only consider tracks with a hit in station 1
0056         if (best_tracks_it.Mode() < 8)
0057           continue;
0058 
0059         // Check if hit in track is identical
0060         // "Duplicate" hits (with same strip but different wire) are considered identical
0061         // const EMTFHit& conv_hit_i = *conv_hits_it;
0062         auto conv_hit_j = best_tracks_it.Hits().front();
0063 
0064         if ((conv_hits_it.Subsystem() == conv_hit_j.Subsystem()) &&
0065             (conv_hits_it.PC_station() == conv_hit_j.PC_station()) &&
0066             (conv_hits_it.PC_chamber() == conv_hit_j.PC_chamber()) &&
0067             ((conv_hits_it.Ring() % 3) == (conv_hit_j.Ring() % 3)) &&  // because of ME1/1
0068             (conv_hits_it.Strip() == conv_hit_j.Strip()) &&
0069             // (conv_hits_it.Wire()       == conv_hit_j.Wire()) &&
0070             (conv_hits_it.BX() == conv_hit_j.BX()) && true) {
0071           already_used = true;
0072           break;
0073         }
0074       }  // End loop: for (const auto & best_tracks_it : best_tracks)
0075 
0076       // Only use hits that have not been used in a track
0077       if (already_used)
0078         continue;
0079 
0080       int zone = -1;
0081       int zone_code = conv_hits_it.Zone_code();
0082       if (zone_code & 0b1000)
0083         zone = 4;
0084       else if (zone_code & 0b0100)
0085         zone = 3;
0086       else if (zone_code & 0b0010)
0087         zone = 2;
0088       else if (zone_code & 0b0001)
0089         zone = 1;
0090       else {
0091         emtf_assert(false && "Incorrect zone_code");
0092       }
0093 
0094       EMTFTrack new_trk;
0095       new_trk.push_Hit(conv_hits_it);
0096 
0097       EMTFPtLUT empty_LUT = {};
0098       new_trk.set_PtLUT(empty_LUT);
0099 
0100       new_trk.set_endcap(conv_hits_it.Endcap());
0101       new_trk.set_sector(conv_hits_it.Sector());
0102       new_trk.set_sector_idx(conv_hits_it.Sector_idx());
0103       new_trk.set_mode(1);  // Set "mode" to 1
0104       new_trk.set_mode_inv(0);
0105       new_trk.set_rank(0b0100000);         // Station 1 hit, straightness 0 (see "rank" in AngleCalculation.cc)
0106       new_trk.set_winner(maxTracks_ - 1);  // Always set to the last / lowest track
0107       new_trk.set_bx(bx_);
0108       new_trk.set_first_bx(bx_);
0109       new_trk.set_second_bx(bx_);
0110       new_trk.set_zone(zone);
0111       new_trk.set_ph_num(conv_hits_it.Zone_hit());
0112       new_trk.set_ph_q(0b010000);  // Original "quality_code" from PatternRecognition.cc
0113       new_trk.set_theta_fp(conv_hits_it.Theta_fp());
0114       new_trk.set_theta(conv_hits_it.Theta());
0115       new_trk.set_eta(conv_hits_it.Eta());
0116       new_trk.set_phi_fp(conv_hits_it.Phi_fp());
0117       new_trk.set_phi_loc(conv_hits_it.Phi_loc());
0118       new_trk.set_phi_glob(conv_hits_it.Phi_glob());
0119       new_trk.set_track_num(maxTracks_ - 1);
0120 
0121       one_hit_trks.push_back(new_trk);
0122 
0123       if (int(best_tracks.size()) + int(one_hit_trks.size()) >= maxTracks_)
0124         break;
0125 
0126       // Firmware only sends one single-hit track per sector
0127       if (!one_hit_trks.empty())
0128         break;
0129 
0130     }  // End loop:  for (const auto & conv_hits_it : conv_hits)
0131 
0132     if (!one_hit_trks.empty())
0133       break;
0134 
0135   }  // End loop: for (int sub_ID = 5; sub_ID > 0; sub_ID--) {
0136 
0137   best_tracks.insert(best_tracks.end(), one_hit_trks.begin(), one_hit_trks.end());
0138 }