CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.size() <= 0 ) 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 
221  if ( data == 1 && emu == 1 )
222  m_dataVsemulator[indx]->Fill( 1 );
223 
224  if ( data == 1 && emu == 0 )
225  m_dataVsemulator[indx]->Fill( 3 );
226 
227  if ( data == 0 && emu == 1 )
228  m_dataVsemulator[indx]->Fill( 5 );
229 
230  if ( data == 0 && emu == 0 )
231  m_dataVsemulator[indx]->Fill( 7 );
232 
233 
234 }
235 
236 
237 
238 
240 
242 
245 
246 
248 
249 
250  m_ttBitsDecisionData = dbe->book1D("TechTrigger.Bits.Data",
251  "Technical Trigger bits : Summary",
252  10, 23, 33 );
253 
254  m_ttBitsDecisionEmulator = dbe->book1D("TechTrigger.Bits.Emulator",
255  "Technical Trigger bits : Summary",
256  10, 23, 33 );
257  for( int k=0; k < m_maxttBits; ++k) {
258 
259  std::ostringstream hname;
260 
261  hname << "BX.diff.PAC-TTU.bit." << m_ttBits[k];
262 
263  m_bxDistDiffPac[k] = dbe->book1D(hname.str().c_str(),
264  "Timing difference between PAC and TTU",
265  7, -3, 3);
266 
267  hname.str("");
268 
269  hname << "BX.diff.DT-TTU.bit." << m_ttBits[k];
270 
271  m_bxDistDiffDt[k] = dbe->book1D(hname.str().c_str(),
272  "Timing difference between DT and TTU",
273  7, -3, 3);
274 
275  hname.str("");
276 
277  hname << "Emu.Ttu.Compare.bit." << m_ttBits[k];
278 
279  m_dataVsemulator[k] = dbe->book1D(hname.str().c_str(),
280  "Comparison between emulator and TT decisions",
281  10, 0, 10 );
282 
283  hname.str("");
284 
285  }
286 
287 
288 }
289 
290 
291 void
293 
294  if(outputFile != "")
295  dbe->save(outputFile);
296 
297  dbe=0;
298 }
299 
300 
T getParameter(std::string const &) const
std::string ttuFolder
Definition: RPCTTUMonitor.h:95
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > m_DTcandidatesBx
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutLabel
int bunchCrossing() const
Definition: EventBase.h:62
edm::EDGetTokenT< L1MuGMTReadoutCollection > m_gmtReadoutLabel
std::vector< unsigned > m_ttBits
Definition: RPCTTUMonitor.h:99
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * m_dataVsemulator[8]
Definition: RPCTTUMonitor.h:92
void Fill(long long x)
MonitorElement * m_ttBitsDecisionEmulator
Definition: RPCTTUMonitor.h:89
MonitorElement * m_bxDistDiffDt[8]
Definition: RPCTTUMonitor.h:91
int iEvent
Definition: GenABIO.cc:243
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
virtual void beginRun(const edm::EventSetup &)
virtual void beginJob()
bool isValid() const
Definition: HandleBase.h:76
int k[5][pyjets_maxn]
int discriminateGMT(const edm::Event &iEvent, const edm::EventSetup &iSetup)
T const * product() const
Definition: Handle.h:81
MonitorElement * m_bxDistDiffPac[8]
Definition: RPCTTUMonitor.h:90
std::vector< int > m_GMTcandidatesBx
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
virtual void endJob()
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
RPCTTUMonitor(const edm::ParameterSet &)
Definition: RPCTTUMonitor.cc:6
std::string outputFile
Definition: RPCTTUMonitor.h:96
void showDirStructure(void) const
Definition: DQMStore.cc:2961
void discriminateDecision(bool, bool, int)
MonitorElement * m_ttBitsDecisionData
Definition: RPCTTUMonitor.h:88
edm::EDGetTokenT< L1GtTechnicalTriggerRecord > m_rpcTechTrigEmu
DQMStore * dbe
Definition: RPCTTUMonitor.h:94
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584