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