CMS 3D CMS Logo

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