CMS 3D CMS Logo

RPCTTUMonitor.cc
Go to the documentation of this file.
3 
4 #include <fmt/format.h>
5 
6 //
8  ttuFolder = iConfig.getUntrackedParameter<std::string>("TTUFolder", "RPC/TTU");
9  outputFile = iConfig.getUntrackedParameter<std::string>("OutPutFile", "");
10 
11  m_gtReadoutLabel = consumes<L1GlobalTriggerReadoutRecord>(iConfig.getParameter<edm::InputTag>("GTReadoutRcd"));
12  m_gmtReadoutLabel = consumes<L1MuGMTReadoutCollection>(iConfig.getParameter<edm::InputTag>("GMTReadoutRcd"));
13  m_rpcTechTrigEmu = consumes<L1GtTechnicalTriggerRecord>(iConfig.getParameter<edm::InputTag>("L1TTEmuBitsLabel"));
14 
15  m_ttBits = iConfig.getParameter<std::vector<unsigned> >("BitNumbers");
16  m_maxttBits = m_ttBits.size();
17 }
18 
19 // ------------ method called to for each event ------------
21  //..............................................................................................
22  // Data .
24  iEvent.getByToken(m_gtReadoutLabel, gtRecord);
25 
26  if (!gtRecord.isValid()) {
27  edm::LogError("RPCTTUMonitor") << "can nout find L1GlobalTriggerRecord \n";
28  return;
29  }
30 
31  // Emulator .
33  iEvent.getByToken(m_rpcTechTrigEmu, emuTTRecord);
34 
35  if (!emuTTRecord.isValid()) {
36  edm::LogError("RPCTTUMonitor") << "can not find L1GtTechnicalTriggerRecord (emulator) \n";
37  return;
38  }
39 
40  //..............................................................................................
41  //
42  //Timing difference between RPC-PAT and DT
43 
44  const int dGMT = discriminateGMT(iEvent, iSetup);
45  if (dGMT < 0)
46  return;
47 
48  std::map<int, bool> ttuDec;
49 
50  const int bxX = iEvent.bunchCrossing(); // ... 1 to 3564
51 
52  for (int k = 0; k < m_maxttBits; ++k) {
53  for (int iebx = 0; iebx <= 2; iebx++) {
54  const TechnicalTriggerWord gtTTWord = gtRecord->technicalTriggerWord(iebx - 1);
55  ttuDec[iebx - 1] = gtTTWord[24 + k];
56  }
57 
58  //. RPC
59  if (m_rpcTrigger) {
60  int ndec(0);
61  const int bx1 = (bxX - m_GMTcandidatesBx[0]);
62  for (const auto& dec : ttuDec) {
63  if (dec.second) {
64  const int bx2 = dec.first;
65  const float bxdiffPacTT = 1.0 * (bx1 - bx2);
66  m_bxDistDiffPac[k]->Fill(bxdiffPacTT);
67  ++ndec;
68  }
69  }
70  }
71 
72  //.. DT
73  if (m_dtTrigger) {
74  int ndec(0);
75  const int bx1 = (bxX - m_DTcandidatesBx[0]);
76  for (const auto& dec : ttuDec) {
77  if (dec.second) {
78  const int bx2 = dec.first;
79  const float bxdiffDtTT = 1.0 * (bx1 - bx2);
80  m_bxDistDiffDt[k]->Fill(bxdiffDtTT);
81  ++ndec;
82  }
83  }
84  }
85  ttuDec.clear();
86  }
87 
88  m_GMTcandidatesBx.clear();
89  m_DTcandidatesBx.clear();
90 
91  //..............................................................................................
92  //
93  //... For Data Emulator comparison
94 
95  const TechnicalTriggerWord gtTTWord = gtRecord->technicalTriggerWord();
96 
97  std::vector<L1GtTechnicalTrigger> ttVec = emuTTRecord->gtTechnicalTrigger();
98 
99  int k = 0;
100  //int m_BxWindow = 0;
101  bool hasDataTrigger = false;
102  bool hasEmulatorTrigger = false;
103 
104  if (ttVec.empty())
105  return;
106 
107  for (const auto& bits : m_ttBits) {
108  hasDataTrigger = gtTTWord.at(bits);
109  m_ttBitsDecisionData->Fill(bits, (int)hasDataTrigger);
110 
111  hasEmulatorTrigger = ttVec[k].gtTechnicalTriggerResult();
112  m_ttBitsDecisionEmulator->Fill(ttVec[k].gtTechnicalTriggerBitNumber(), (int)hasEmulatorTrigger);
113 
114  discriminateDecision(hasDataTrigger, hasEmulatorTrigger, k);
115 
116  ++k;
117  }
118 }
119 
122  iEvent.getByToken(m_gmtReadoutLabel, pCollection);
123 
124  if (!pCollection.isValid()) {
125  edm::LogError("discriminateGMT") << "can't find L1MuGMTReadoutCollection with label \n";
126 
127  return -1;
128  }
129 
130  int gmtDec(0);
131 
132  bool rpcBar_l1a = false;
133  bool dtBar_l1a = false;
134 
135  m_dtTrigger = false;
136  m_rpcTrigger = false;
137 
138  // get GMT readout collection
139  const L1MuGMTReadoutCollection* gmtRC = pCollection.product();
140 
141  // get record vector
142  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtRC->getRecords();
143 
144  edm::LogInfo("DiscriminateGMT") << "nRecords: " << gmt_records.size() << '\n';
145 
146  for (const auto& rr : gmt_records) {
147  const int BxInEvent = rr.getBxInEvent();
148  const int BxInEventNew = rr.getBxNr();
149 
150  // RPC barrel muon candidates
151  int nrpcB = 0;
152  int ndtB = 0;
153 
154  std::vector<L1MuRegionalCand> BrlRpcCands = rr.getBrlRPCCands();
155  std::vector<L1MuRegionalCand> BrlDtCands = rr.getDTBXCands();
156 
157  for (const auto& rc : BrlRpcCands) {
158  if (!rc.empty()) {
159  m_GMTcandidatesBx.push_back(BxInEventNew);
160 
161  nrpcB++;
162  }
163  }
164 
165  for (const auto& rc : BrlDtCands) {
166  if (!rc.empty()) {
167  m_DTcandidatesBx.push_back(BxInEventNew);
168  ndtB++;
169  }
170  }
171 
172  if (BxInEvent == 0 && nrpcB > 0)
173  rpcBar_l1a = true;
174  if (BxInEvent == 0 && ndtB > 0)
175  dtBar_l1a = true;
176  }
177 
178  if (rpcBar_l1a) {
179  gmtDec = 1;
180  m_rpcTrigger = true;
181  }
182 
183  if (dtBar_l1a) {
184  gmtDec = 2;
185  m_dtTrigger = true;
186  }
187 
188  return gmtDec;
189 }
190 
191 void RPCTTUMonitor::discriminateDecision(bool data, bool emu, int indx) {
192  if (data == 1 && emu == 1) {
193  m_dataVsemulator[indx]->Fill(1);
194  } else if (data == 1 && emu == 0) {
195  m_dataVsemulator[indx]->Fill(3);
196  } else if (data == 0 && emu == 1) {
197  m_dataVsemulator[indx]->Fill(5);
198  } else if (data == 0 && emu == 0) {
199  m_dataVsemulator[indx]->Fill(7);
200  }
201 }
202 
204  ibooker.setCurrentFolder(ttuFolder);
205  std::string hname;
206 
207  m_ttBitsDecisionData = ibooker.book1D("TechTrigger.Bits.Data", "Technical Trigger bits : Summary", 10, 23, 33);
208 
210  ibooker.book1D("TechTrigger.Bits.Emulator", "Technical Trigger bits : Summary", 10, 23, 33);
211  for (int k = 0; k < m_maxttBits; ++k) {
212  hname = fmt::format("BX.diff.PAC-TTU.bit.{}", m_ttBits[k]);
213  m_bxDistDiffPac[k] = ibooker.book1D(hname, "Timing difference between PAC and TTU", 7, -3, 3);
214 
215  hname = fmt::format("BX.diff.DT-TTU.bit.{}", m_ttBits[k]);
216  m_bxDistDiffDt[k] = ibooker.book1D(hname, "Timing difference between DT and TTU", 7, -3, 3);
217 
218  hname = fmt::format("Emu.Ttu.Compare.bit.{}", m_ttBits[k]);
219  m_dataVsemulator[k] = ibooker.book1D(hname, "Comparison between emulator and TT decisions", 10, 0, 10);
220  }
221 }
std::string ttuFolder
Definition: RPCTTUMonitor.h:40
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< int > m_DTcandidatesBx
Definition: RPCTTUMonitor.h:50
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutLabel
Definition: RPCTTUMonitor.h:55
T const * product() const
Definition: Handle.h:70
constexpr uint32_t bits
Definition: gpuClustering.h:25
edm::EDGetTokenT< L1MuGMTReadoutCollection > m_gmtReadoutLabel
Definition: RPCTTUMonitor.h:56
Log< level::Error, false > LogError
std::vector< unsigned > m_ttBits
Definition: RPCTTUMonitor.h:44
MonitorElement * m_dataVsemulator[8]
Definition: RPCTTUMonitor.h:38
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
MonitorElement * m_ttBitsDecisionEmulator
Definition: RPCTTUMonitor.h:35
MonitorElement * m_bxDistDiffDt[8]
Definition: RPCTTUMonitor.h:37
int iEvent
Definition: GenABIO.cc:224
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
const std::vector< L1GtTechnicalTrigger > & gtTechnicalTrigger() const
get / set the vector of technical triggers
Log< level::Info, false > LogInfo
int discriminateGMT(const edm::Event &iEvent, const edm::EventSetup &iSetup)
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
bool isValid() const
Definition: HandleBase.h:70
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * m_bxDistDiffPac[8]
Definition: RPCTTUMonitor.h:36
std::vector< int > m_GMTcandidatesBx
Definition: RPCTTUMonitor.h:49
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RPCTTUMonitor(const edm::ParameterSet &)
Definition: RPCTTUMonitor.cc:7
std::string outputFile
Definition: RPCTTUMonitor.h:41
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void discriminateDecision(bool, bool, int)
MonitorElement * m_ttBitsDecisionData
Definition: RPCTTUMonitor.h:34
edm::EDGetTokenT< L1GtTechnicalTriggerRecord > m_rpcTechTrigEmu
Definition: RPCTTUMonitor.h:57
Definition: Run.h:45