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 }
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
RPCTTUMonitor::m_gtReadoutLabel
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutLabel
Definition: RPCTTUMonitor.h:55
edm::Run
Definition: Run.h:45
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
RPCTTUMonitor::m_DTcandidatesBx
std::vector< int > m_DTcandidatesBx
Definition: RPCTTUMonitor.h:50
RPCTTUMonitor::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: RPCTTUMonitor.cc:20
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
RPCTTUMonitor::m_ttBits
std::vector< unsigned > m_ttBits
Definition: RPCTTUMonitor.h:44
RPCTTUMonitor::m_ttBitsDecisionData
MonitorElement * m_ttBitsDecisionData
Definition: RPCTTUMonitor.h:34
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPCTTUMonitor::discriminateDecision
void discriminateDecision(bool, bool, int)
Definition: RPCTTUMonitor.cc:191
edm::Handle
Definition: AssociativeIterator.h:50
RPCTTUMonitor::m_GMTcandidatesBx
std::vector< int > m_GMTcandidatesBx
Definition: RPCTTUMonitor.h:49
RPCTTUMonitor::outputFile
std::string outputFile
Definition: RPCTTUMonitor.h:41
L1GtTechnicalTriggerRecord::gtTechnicalTrigger
const std::vector< L1GtTechnicalTrigger > & gtTechnicalTrigger() const
get / set the vector of technical triggers
Definition: L1GtTechnicalTriggerRecord.h:45
dqm-mbProfile.format
format
Definition: dqm-mbProfile.py:16
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
dqmdumpme.k
k
Definition: dqmdumpme.py:60
RPCTTUMonitor::m_ttBitsDecisionEmulator
MonitorElement * m_ttBitsDecisionEmulator
Definition: RPCTTUMonitor.h:35
RPCTTUMonitor::m_rpcTechTrigEmu
edm::EDGetTokenT< L1GtTechnicalTriggerRecord > m_rpcTechTrigEmu
Definition: RPCTTUMonitor.h:57
RPCTTUMonitor::m_bxDistDiffDt
MonitorElement * m_bxDistDiffDt[8]
Definition: RPCTTUMonitor.h:37
edm::ParameterSet
Definition: ParameterSet.h:47
RPCTTUMonitor.h
RPCTTUMonitor::m_rpcTrigger
bool m_rpcTrigger
Definition: RPCTTUMonitor.h:47
L1MuGMTReadoutCollection::getRecords
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
Definition: L1MuGMTReadoutCollection.h:52
RPCTTUMonitor::m_maxttBits
int m_maxttBits
Definition: RPCTTUMonitor.h:43
iEvent
int iEvent
Definition: GenABIO.cc:224
RPCTTUMonitor::m_dataVsemulator
MonitorElement * m_dataVsemulator[8]
Definition: RPCTTUMonitor.h:38
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RPCTTUMonitor::m_bxDistDiffPac
MonitorElement * m_bxDistDiffPac[8]
Definition: RPCTTUMonitor.h:36
alignCSCRings.r
r
Definition: alignCSCRings.py:93
L1MuGMTReadoutCollection
Definition: L1MuGMTReadoutCollection.h:39
RPCTTUMonitor::discriminateGMT
int discriminateGMT(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: RPCTTUMonitor.cc:120
RPCTTUMonitor::ttuFolder
std::string ttuFolder
Definition: RPCTTUMonitor.h:40
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
dqm::implementation::IBooker
Definition: DQMStore.h:43
RPCTTUMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: RPCTTUMonitor.cc:203
RPCTTUMonitor::m_dtTrigger
bool m_dtTrigger
Definition: RPCTTUMonitor.h:46
L1GlobalTriggerReadoutRecord::technicalTriggerWord
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
Definition: L1GlobalTriggerReadoutRecord.cc:212
TechnicalTriggerWord
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
Definition: L1GlobalTriggerReadoutSetupFwd.h:41
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
RPCTTUMonitor::RPCTTUMonitor
RPCTTUMonitor(const edm::ParameterSet &)
Definition: RPCTTUMonitor.cc:7
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
edm::InputTag
Definition: InputTag.h:15
RPCTTUMonitor::m_gmtReadoutLabel
edm::EDGetTokenT< L1MuGMTReadoutCollection > m_gmtReadoutLabel
Definition: RPCTTUMonitor.h:56
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98