Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/TrackFindingTMTT/interface/StubWindowSuggest.h"
0002 #include "L1Trigger/TrackFindingTMTT/interface/Stub.h"
0003 #include "L1Trigger/TrackFindingTMTT/interface/TrackerModule.h"
0004 #include "L1Trigger/TrackFindingTMTT/interface/PrintL1trk.h"
0005 
0006 #include "DataFormats/DetId/interface/DetId.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 
0009 #include <sstream>
0010 #include <mutex>
0011 
0012 using namespace std;
0013 
0014 namespace tmtt {
0015 
0016   //=== Get FE window size arrays (via copy) used with stub producer, but set to zero.
0017 
0018   void StubWindowSuggest::setFEWindows(const StubFEWindows* sw) {
0019     static std::mutex myMutex;
0020     std::lock_guard<std::mutex> myGuard(myMutex);  // Allow only one thread.
0021     // Only need to create FE windows once.
0022     if (not sw_) {
0023       sw_ = std::make_unique<StubFEWindows>(*sw);  // Copy
0024       sw_->setZero();
0025     }
0026   }
0027 
0028   //=== Analyse stub window required for this stub.
0029 
0030   void StubWindowSuggest::process(const TrackerTopology* trackerTopo, const Stub* stub) {
0031     static std::mutex myMutex;
0032     std::lock_guard<std::mutex> myGuard(myMutex);  // Allow only one thread.
0033 
0034     // Half-size of FE chip bend window corresponding to Pt range in which tracks are to be found.
0035     const double invPtMax = 1 / ptMin_;
0036     double bendHalfWind = invPtMax / std::abs(stub->qOverPtOverBend());
0037     // Increase half-indow size to allow for resolution in bend.
0038     bendHalfWind += stub->bendCutInFrontend();
0039     // Stub bend is measured here in half-integer values.
0040     bendHalfWind = int(2 * bendHalfWind) / 2.;
0041 
0042     // Compare with half-size of FE bend window stored in arrays.
0043     this->updateStoredWindow(trackerTopo, stub, bendHalfWind);
0044   }
0045 
0046   //===  Update stored stub window size with this stub.
0047 
0048   void StubWindowSuggest::updateStoredWindow(const TrackerTopology* trackerTopo,
0049                                              const Stub* stub,
0050                                              double bendHalfWind) {
0051     // Code accessing geometry inspired by L1Trigger/TrackTrigger/src/TTStubAlgorithm_official.cc
0052 
0053     DetId stDetId(stub->trackerModule()->detId());
0054 
0055     double* storedHalfWindow = sw_->storedWindowSize(trackerTopo, stDetId);
0056 
0057     if (*storedHalfWindow < bendHalfWind)
0058       *storedHalfWindow = bendHalfWind;
0059   }
0060 
0061   //=== Print results (should be done in endJob();
0062 
0063   void StubWindowSuggest::printResults() const {
0064     PrintL1trk(1) << "==============================================================================";
0065     PrintL1trk(1) << " Stub window sizes that TMTT suggests putting inside ";
0066     PrintL1trk(1) << "   /L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py";
0067     PrintL1trk(1) << " (These should give good efficiency, but tighter windows may be needed to";
0068     PrintL1trk(1) << "  limit the data rate from the FE tracker electronics).";
0069     PrintL1trk(1) << "==============================================================================";
0070 
0071     std::stringstream text;
0072     string div;
0073 
0074     text << "BarrelCut = cms.vdouble( ";
0075     div = "";
0076     for (const auto& cut : sw_->windowSizeBarrelLayers()) {
0077       text << div << cut;
0078       div = ", ";
0079     }
0080     text << "),";
0081     PrintL1trk(1) << text.str();
0082 
0083     PrintL1trk(1) << "TiltedBarrelCutSet = cms.VPSET( ";
0084     for (const auto& cutVec : sw_->windowSizeTiltedLayersRings()) {
0085       text.str("");
0086       text << "     cms.PSet( TiltedCut = cms.vdouble(";
0087       if (cutVec.empty())
0088         text << "0";
0089       div = "";
0090       for (const auto& cut : cutVec) {
0091         text << div << cut;
0092         div = ", ";
0093       }
0094       text << "), ),";
0095       PrintL1trk(1) << text.str();
0096     }
0097     PrintL1trk(1) << "),";
0098 
0099     PrintL1trk(1) << "EndcapCutSet = cms.VPSET( ";
0100     for (const auto& cutVec : sw_->windowSizeEndcapDisksRings()) {
0101       text.str("");
0102       text << "     cms.PSet( EndcapCut = cms.vdouble(";
0103       if (cutVec.empty())
0104         text << "0";
0105       div = "";
0106       for (const auto& cut : cutVec) {
0107         text << div << cut;
0108         div = ", ";
0109       }
0110       text << "), ),";
0111       PrintL1trk(1) << text.str();
0112     }
0113     PrintL1trk(1) << ")";
0114 
0115     PrintL1trk(1) << "==============================================================================";
0116   }
0117 
0118 }  // namespace tmtt