CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
StubWindowSuggest.cc
Go to the documentation of this file.
5 
8 
9 #include <sstream>
10 #include <mutex>
11 
12 using namespace std;
13 
14 namespace tmtt {
15 
16  //=== Get FE window size arrays (via copy) used with stub producer, but set to zero.
17 
18  void StubWindowSuggest::setFEWindows(const StubFEWindows* sw) {
19  static std::mutex myMutex;
20  std::lock_guard<std::mutex> myGuard(myMutex); // Allow only one thread.
21  // Only need to create FE windows once.
22  if (not sw_) {
23  sw_ = std::make_unique<StubFEWindows>(*sw); // Copy
24  sw_->setZero();
25  }
26  }
27 
28  //=== Analyse stub window required for this stub.
29 
30  void StubWindowSuggest::process(const TrackerTopology* trackerTopo, const Stub* stub) {
31  static std::mutex myMutex;
32  std::lock_guard<std::mutex> myGuard(myMutex); // Allow only one thread.
33 
34  // Half-size of FE chip bend window corresponding to Pt range in which tracks are to be found.
35  const double invPtMax = 1 / ptMin_;
36  double bendHalfWind = invPtMax / std::abs(stub->qOverPtOverBend());
37  // Increase half-indow size to allow for resolution in bend.
38  bendHalfWind += stub->bendCutInFrontend();
39  // Stub bend is measured here in half-integer values.
40  bendHalfWind = int(2 * bendHalfWind) / 2.;
41 
42  // Compare with half-size of FE bend window stored in arrays.
43  this->updateStoredWindow(trackerTopo, stub, bendHalfWind);
44  }
45 
46  //=== Update stored stub window size with this stub.
47 
48  void StubWindowSuggest::updateStoredWindow(const TrackerTopology* trackerTopo,
49  const Stub* stub,
50  double bendHalfWind) {
51  // Code accessing geometry inspired by L1Trigger/TrackTrigger/src/TTStubAlgorithm_official.cc
52 
53  DetId stDetId(stub->trackerModule()->detId());
54 
55  double* storedHalfWindow = sw_->storedWindowSize(trackerTopo, stDetId);
56 
57  if (*storedHalfWindow < bendHalfWind)
58  *storedHalfWindow = bendHalfWind;
59  }
60 
61  //=== Print results (should be done in endJob();
62 
63  void StubWindowSuggest::printResults() const {
64  PrintL1trk(1) << "==============================================================================";
65  PrintL1trk(1) << " Stub window sizes that TMTT suggests putting inside ";
66  PrintL1trk(1) << " /L1Trigger/TrackTrigger/python/TTStubAlgorithmRegister_cfi.py";
67  PrintL1trk(1) << " (These should give good efficiency, but tighter windows may be needed to";
68  PrintL1trk(1) << " limit the data rate from the FE tracker electronics).";
69  PrintL1trk(1) << "==============================================================================";
70 
71  std::stringstream text;
72  string div;
73 
74  text << "BarrelCut = cms.vdouble( ";
75  div = "";
76  for (const auto& cut : sw_->windowSizeBarrelLayers()) {
77  text << div << cut;
78  div = ", ";
79  }
80  text << "),";
81  PrintL1trk(1) << text.str();
82 
83  PrintL1trk(1) << "TiltedBarrelCutSet = cms.VPSET( ";
84  for (const auto& cutVec : sw_->windowSizeTiltedLayersRings()) {
85  text.str("");
86  text << " cms.PSet( TiltedCut = cms.vdouble(";
87  if (cutVec.empty())
88  text << "0";
89  div = "";
90  for (const auto& cut : cutVec) {
91  text << div << cut;
92  div = ", ";
93  }
94  text << "), ),";
95  PrintL1trk(1) << text.str();
96  }
97  PrintL1trk(1) << "),";
98 
99  PrintL1trk(1) << "EndcapCutSet = cms.VPSET( ";
100  for (const auto& cutVec : sw_->windowSizeEndcapDisksRings()) {
101  text.str("");
102  text << " cms.PSet( EndcapCut = cms.vdouble(";
103  if (cutVec.empty())
104  text << "0";
105  div = "";
106  for (const auto& cut : cutVec) {
107  text << div << cut;
108  div = ", ";
109  }
110  text << "), ),";
111  PrintL1trk(1) << text.str();
112  }
113  PrintL1trk(1) << ")";
114 
115  PrintL1trk(1) << "==============================================================================";
116  }
117 
118 } // namespace tmtt
float bendCutInFrontend() const
Definition: Stub.h:124
static std::mutex mutex
Definition: Proxy.cc:8
const TrackerModule * trackerModule() const
Definition: Stub.h:78
ptMin_(conf.getParameter< double >("ptMin"))
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
tuple text
Definition: runonSM.py:43
const DetId & detId() const
Definition: TrackerModule.h:44
Definition: DetId.h:17
float qOverPtOverBend() const
Definition: Stub.h:148
tuple process
Definition: LaserDQM_cfg.py:3