CMS 3D CMS Logo

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