Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:49

0001 #include "L1Trigger/TrackFindingTMTT/interface/DegradeBend.h"
0002 #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h"
0003 
0004 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0005 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 #include <map>
0009 #include <set>
0010 #include <utility>
0011 #include <cmath>
0012 #include <algorithm>
0013 #include <iostream>
0014 
0015 using namespace std;
0016 
0017 namespace tmtt {
0018 
0019   //--- Given the original bend, flag indicating if this is a PS or 2S module, & detector identifier,
0020   //--- this returns the degraded stub bend, a boolean indicatng if stub bend was outside the assumed window
0021   //--- size programmed below, and an integer indicating how many values of the original bend
0022   //--- were grouped together into this single value of the degraded bend.
0023 
0024   void DegradeBend::degrade(float bend,
0025                             bool psModule,
0026                             const DetId& stDetId,
0027                             float windowFEnew,
0028                             float& degradedBend,
0029                             unsigned int& numInGroup) const {
0030     // Get degraded bend value.
0031     unsigned int windowHalfStrips;
0032     this->work(bend, psModule, stDetId, windowFEnew, degradedBend, numInGroup, windowHalfStrips);
0033   }
0034 
0035   //--- Does the actual work of degrading the bend.
0036 
0037   void DegradeBend::work(float bend,
0038                          bool psModule,
0039                          const DetId& stDetId,
0040                          float windowFEnew,
0041                          float& degradedBend,
0042                          unsigned int& numInGroup,
0043                          unsigned int& windowHalfStrips) const {
0044     // Calculate stub window size in half-strip units used to produce stubs.
0045     // Code accessing geometry inspired by L1Trigger/TrackTrigger/src/TTStubAlgorithm_official.cc
0046 
0047     const double* storedHalfWindow = sw_->storedWindowSize(theTrackerTopo_, stDetId);
0048 
0049     // Compare this with the possibly tighter window provided by the user, converting to half-strip units.
0050     const double window = std::min(*storedHalfWindow, double(windowFEnew));
0051     windowHalfStrips = (unsigned int)(2 * window);
0052 
0053     // Bend is measured with granularity of 0.5 strips.
0054     // Convert it to integer measured in half-strip units for this calculation!
0055     int b = std::round(2 * bend);
0056 
0057     if ((unsigned int)(std::abs(b)) <= windowHalfStrips) {
0058       // Call the official CMS bend encoding algorithm.
0059       degradedBend = stubAlgo_->degradeBend(psModule, windowHalfStrips, b);
0060     } else {
0061       // This should only happen for stubs subsequently rejected by the FE.
0062       numInGroup = 0;
0063       constexpr float rejectedStubBend = 99999.;
0064       degradedBend = rejectedStubBend;
0065     }
0066   }
0067 }  // namespace tmtt