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  const int bx1 = (bxX - m_GMTcandidatesBx[0]);
61  for (const auto& dec : ttuDec) {
62  if (dec.second) {
63  const int bx2 = dec.first;
64  const float bxdiffPacTT = 1.0 * (bx1 - bx2);
65  m_bxDistDiffPac[k]->Fill(bxdiffPacTT);
66  }
67  }
68  }
69 
70  //.. DT
71  if (m_dtTrigger) {
72  const int bx1 = (bxX - m_DTcandidatesBx[0]);
73  for (const auto& dec : ttuDec) {
74  if (dec.second) {
75  const int bx2 = dec.first;
76  const float bxdiffDtTT = 1.0 * (bx1 - bx2);
77  m_bxDistDiffDt[k]->Fill(bxdiffDtTT);
78  }
79  }
80  }
81  ttuDec.clear();
82  }
83 
84  m_GMTcandidatesBx.clear();
85  m_DTcandidatesBx.clear();
86 
87  //..............................................................................................
88  //
89  //... For Data Emulator comparison
90 
91  const TechnicalTriggerWord gtTTWord = gtRecord->technicalTriggerWord();
92 
93  std::vector<L1GtTechnicalTrigger> ttVec = emuTTRecord->gtTechnicalTrigger();
94 
95  int k = 0;
96  //int m_BxWindow = 0;
97  bool hasDataTrigger = false;
98  bool hasEmulatorTrigger = false;
99 
100  if (ttVec.empty())
101  return;
102 
103  for (const auto& bits : m_ttBits) {
104  hasDataTrigger = gtTTWord.at(bits);
105  m_ttBitsDecisionData->Fill(bits, (int)hasDataTrigger);
106 
107  hasEmulatorTrigger = ttVec[k].gtTechnicalTriggerResult();
108  m_ttBitsDecisionEmulator->Fill(ttVec[k].gtTechnicalTriggerBitNumber(), (int)hasEmulatorTrigger);
109 
110  discriminateDecision(hasDataTrigger, hasEmulatorTrigger, k);
111 
112  ++k;
113  }
114 }
115 
118  iEvent.getByToken(m_gmtReadoutLabel, pCollection);
119 
120  if (!pCollection.isValid()) {
121  edm::LogError("discriminateGMT") << "can't find L1MuGMTReadoutCollection with label \n";
122 
123  return -1;
124  }
125 
126  int gmtDec(0);
127 
128  bool rpcBar_l1a = false;
129  bool dtBar_l1a = false;
130 
131  m_dtTrigger = false;
132  m_rpcTrigger = false;
133 
134  // get GMT readout collection
135  const L1MuGMTReadoutCollection* gmtRC = pCollection.product();
136 
137  // get record vector
138  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtRC->getRecords();
139 
140  edm::LogInfo("DiscriminateGMT") << "nRecords: " << gmt_records.size() << '\n';
141 
142  for (const auto& rr : gmt_records) {
143  const int BxInEvent = rr.getBxInEvent();
144  const int BxInEventNew = rr.getBxNr();
145 
146  // RPC barrel muon candidates
147  int nrpcB = 0;
148  int ndtB = 0;
149 
150  std::vector<L1MuRegionalCand> BrlRpcCands = rr.getBrlRPCCands();
151  std::vector<L1MuRegionalCand> BrlDtCands = rr.getDTBXCands();
152 
153  for (const auto& rc : BrlRpcCands) {
154  if (!rc.empty()) {
155  m_GMTcandidatesBx.push_back(BxInEventNew);
156 
157  nrpcB++;
158  }
159  }
160 
161  for (const auto& rc : BrlDtCands) {
162  if (!rc.empty()) {
163  m_DTcandidatesBx.push_back(BxInEventNew);
164  ndtB++;
165  }
166  }
167 
168  if (BxInEvent == 0 && nrpcB > 0)
169  rpcBar_l1a = true;
170  if (BxInEvent == 0 && ndtB > 0)
171  dtBar_l1a = true;
172  }
173 
174  if (rpcBar_l1a) {
175  gmtDec = 1;
176  m_rpcTrigger = true;
177  }
178 
179  if (dtBar_l1a) {
180  gmtDec = 2;
181  m_dtTrigger = true;
182  }
183 
184  return gmtDec;
185 }
186 
187 void RPCTTUMonitor::discriminateDecision(bool data, bool emu, int indx) {
188  if (data == 1 && emu == 1) {
189  m_dataVsemulator[indx]->Fill(1);
190  } else if (data == 1 && emu == 0) {
191  m_dataVsemulator[indx]->Fill(3);
192  } else if (data == 0 && emu == 1) {
193  m_dataVsemulator[indx]->Fill(5);
194  } else if (data == 0 && emu == 0) {
195  m_dataVsemulator[indx]->Fill(7);
196  }
197 }
198 
200  ibooker.setCurrentFolder(ttuFolder);
201  std::string hname;
202 
203  m_ttBitsDecisionData = ibooker.book1D("TechTrigger.Bits.Data", "Technical Trigger bits : Summary", 10, 23, 33);
204 
206  ibooker.book1D("TechTrigger.Bits.Emulator", "Technical Trigger bits : Summary", 10, 23, 33);
207  for (int k = 0; k < m_maxttBits; ++k) {
208  hname = fmt::format("BX.diff.PAC-TTU.bit.{}", m_ttBits[k]);
209  m_bxDistDiffPac[k] = ibooker.book1D(hname, "Timing difference between PAC and TTU", 7, -3, 3);
210 
211  hname = fmt::format("BX.diff.DT-TTU.bit.{}", m_ttBits[k]);
212  m_bxDistDiffDt[k] = ibooker.book1D(hname, "Timing difference between DT and TTU", 7, -3, 3);
213 
214  hname = fmt::format("Emu.Ttu.Compare.bit.{}", m_ttBits[k]);
215  m_dataVsemulator[k] = ibooker.book1D(hname, "Comparison between emulator and TT decisions", 10, 0, 10);
216  }
217 }
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:80
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