CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TRPCTF.cc
Go to the documentation of this file.
1 /*
2  * \file L1TRPCTF.cc
3  *
4  * \author J. Berryhill
5  *
6  */
9 
13 
14 #include <sstream>
15 using namespace std;
16 using namespace edm;
17 
19 : rpctfSource_(consumes<L1MuGMTReadoutCollection>( ps.getParameter< InputTag >("rpctfSource") )),
20 // digiSource_( ps.getParameter< InputTag >("rpctfRPCDigiSource") ),
21 // m_rpcDigiFine(false),
22 // m_useRpcDigi(true),
23  m_lastUsedBxInBxdiff(0),
24  output_dir_ (ps.getUntrackedParameter<string>("output_dir") )
25 // m_rpcDigiWithBX0(0),
26 // m_rpcDigiWithBXnon0(0)
27 
28  {
29 
30  // verbosity switch
31  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
32 
33  if(verbose_) cout << "L1TRPCTF: constructor...." << endl;
34 
35 
36  m_dbe = NULL;
37  if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
38  {
40  m_dbe->setVerbose(0);
41  }
42 
43  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
44  if ( outputFile_.size() != 0 ) {
45  cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
46  }
47 
48  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
49  if(disable){
50  outputFile_="";
51  }
52 
53 
54  if ( m_dbe !=NULL ) {
56  }
57 
58 
59 
60 }
61 
63 {
64 }
65 
67 {
68 
69  nev_ = 0;
70  nevRPC_ = 0;
71 
72  // get hold of back-end interface
74 
75  if ( m_dbe ) {
78  }
79 
80 
81  if ( m_dbe )
82  {
83 
84 
85  ostringstream oDir; oDir<< output_dir_ << "/CrateSynchroHistograms/";
86  m_dbe->setCurrentFolder(oDir.str());
87  for( unsigned int i = 0; i < 12; i++) {
88 
89  ostringstream o; o<<"RPCTF_crate_"<<i<<"_synchro";
90  rpctfcratesynchro[i] = m_dbe->book2D(o.str(), o.str(), 5, -2.5, 2.5, 33, -16.5, 16.5);
91  for (int bx = -2; bx < 3; ++bx){
92  ostringstream b; b<<"BX="<<bx;
93  rpctfcratesynchro[i]->setBinLabel(bx+3, b.str(),1);
94  }
95  rpctfcratesynchro[i]->setAxisTitle("Tower",2);
96 
97  }
98  m_dbe->setCurrentFolder(output_dir_);
99 
100  rpctfetavalue[1] = m_dbe->book1D("RPCTF_eta_value_bx0",
101  "RPCTF eta value bx=0", 33, -16.5, 16.5 ) ;
102  rpctfetavalue[2] = m_dbe->book1D("RPCTF_eta_value_bx+",
103  "RPCTF eta value bx>0", 33, -16.5, 16.5 ) ;
104  rpctfetavalue[0] = m_dbe->book1D("RPCTF_eta_value_bx-",
105  "RPCTF eta value bx<0", 33, -16.5, 16.5 ) ;
106 
107  rpctfphivalue[1] = m_dbe->book1D("RPCTF_phi_value_bx0",
108  "RPCTF phi value bx=0", 144, -0.5, 143.5) ;
109  rpctfphivalue[2] = m_dbe->book1D("RPCTF_phi_value_bx+",
110  "RPCTF phi value bx>0", 144, -0.5, 143.5 ) ;
111  rpctfphivalue[0] = m_dbe->book1D("RPCTF_phi_value_bx-",
112  "RPCTF phi value bx<0", 144, -0.5, 143.5 ) ;
113 
114 
115 
116  rpctfptvalue[1] = m_dbe->book1D("RPCTF_pt_value_bx0",
117  "RPCTF pt value bx=0", 160, -0.5, 159.5 );
118  rpctfptvalue[2] = m_dbe->book1D("RPCTF_pt_value_bx+",
119  "RPCTF pt value bx>0", 160, -0.5, 159.5 );
120  rpctfptvalue[0] = m_dbe->book1D("RPCTF_pt_value_bx-",
121  "RPCTF pt value bx<0", 160, -0.5, 159.5 );
122 
123 
124  rpctfchargevalue[1] = m_dbe->book1D("RPCTF_charge_value_bx0",
125  "RPCTF charge value bx=0", 3, -1.5, 1.5 ) ;
126  rpctfchargevalue[2] = m_dbe->book1D("RPCTF_charge_value_bx+",
127  "RPCTF charge value bx>0", 3, -1.5, 1.5 ) ;
128  rpctfchargevalue[0] = m_dbe->book1D("RPCTF_charge_value_bx-",
129  "RPCTF charge value bx<01", 3, -1.5, 1.5 ) ;
130 
131  rpctfquality[1] = m_dbe->book1D("RPCTF_quality",
132  "RPCTF quality bx=0", 6, -0.5, 5.5 ) ;
133  rpctfquality[2] = m_dbe->book1D("RPCTF_quality_bx+",
134  "RPCTF quality bx>0", 6, -0.5, 5.5 ) ;
135  rpctfquality[0] = m_dbe->book1D("RPCTF_quality_bx-",
136  "RPCTF quality bx<0", 6, -0.5, 5.5 ) ;
137 
138  rpctfntrack_b[1] = m_dbe->book1D("RPCTF_ntrack_brl_bx0",
139  "RPCTF number of tracks - barrel, bx=0", 5, -0.5, 4.5 ) ;
140  rpctfntrack_b[2] = m_dbe->book1D("RPCTF_ntrack_brl_bx+",
141  "RPCTF number of tracks - barrel, bx>0", 5, -0.5, 4.5 ) ;
142  rpctfntrack_b[0] = m_dbe->book1D("RPCTF_ntrack_brl_bx-",
143  "RPCTF number of tracks - barrel, bx<0", 5, -0.5, 4.5 ) ;
144 
145 
146 
147  rpctfntrack_e[1] = m_dbe->book1D("RPCTF_ntrack_fwd_bx0",
148  "RPCTF number of tracks - endcap, bx=0", 5, -0.5, 4.5 ) ;
149  rpctfntrack_e[2] = m_dbe->book1D("RPCTF_ntrack_fwd_bx+",
150  "RPCTF number of tracks - endcap, bx>0", 5, -0.5, 4.5 ) ;
151  rpctfntrack_e[0] = m_dbe->book1D("RPCTF_ntrack_fwd_bx-",
152  "RPCTF number of tracks - endcap, bx<0", 5, -0.5, 4.5 ) ;
153 
154 
155 
156 
157 
158  m_qualVsEta[1] = m_dbe->book2D("RPCTF_quality_vs_eta_bx0",
159  "RPCTF quality vs eta, bx=0",
160  33, -16.5, 16.5,
161  6, -0.5, 5.5); // Currently only 0...3 quals are possible
162  m_qualVsEta[2] = m_dbe->book2D("RPCTF_quality_vs_eta_bx+",
163  "RPCTF quality vs eta, bx>0",
164  33, -16.5, 16.5,
165  6, -0.5, 5.5); // Currently only 0...3 quals are possible
166  m_qualVsEta[0] = m_dbe->book2D("RPCTF_quality_vs_eta_bx-",
167  "RPCTF quality vs eta, bx<0",
168  33, -16.5, 16.5,
169  6, -0.5, 5.5); // Currently only 0...3 quals are possible
170 
171 
172 
173  m_muonsEtaPhi[1] = m_dbe->book2D("RPCTF_muons_eta_phi_bx0",
174  "RPCTF occupancy(eta,phi), bx=0",
175  33, -16.5, 16.5,
176  144, -0.5, 143.5);
177  m_muonsEtaPhi[2] = m_dbe->book2D("RPCTF_muons_eta_phi_bx+",
178  "RPCTF occupancy(eta,phi), bx>0",
179  33, -16.5, 16.5,
180  144, -0.5, 143.5);
181  m_muonsEtaPhi[0] = m_dbe->book2D("RPCTF_muons_eta_phi_bx-",
182  "RPCTF occupancy(eta,phi), bx<0",
183  33, -16.5, 16.5,
184  144, -0.5, 143.5);
185 
186  rpctfbx = m_dbe->book1D("RPCTF_bx",
187  "RPCTF bx distribiution", 7, -3.5, 3.5 );
188 
189  //axis labels
190  for (int l = 0; l<3; ++l){
191  m_muonsEtaPhi[l]->setAxisTitle("tower",1);
192  m_qualVsEta[l]->setAxisTitle("tower");
193  rpctfetavalue[l]->setAxisTitle("tower");
194 
195  m_muonsEtaPhi[l]->setAxisTitle("phi",2);
196  rpctfphivalue[l]->setAxisTitle("phi");
197  }
198 
199  // set phi bin labels
200  for (int i = 0; i < 12 ; ++i ){
201  //float lPhi = (30./360)*i*2*3.14;
202  int lPhi = 30*i;
203  int lBin = int((30./360)*i*144)+1;
204  std::stringstream ss;
205  ss << "phi=" <<lPhi;
206  for (int l = 0; l<3; ++l){
207  rpctfphivalue[l]->setBinLabel(lBin,ss.str());
208  m_muonsEtaPhi[l]->setBinLabel(lBin,ss.str(), 2);
209  }
210  }
211 
212  /*
213  // set TC numbers on phi axis
214  for (int tc = 0; tc < 12 ; ++tc ){
215  int lBin = (tc*12+3+1)%144;
216  std::stringstream ss;
217  ss << "TC" <<tc;
218  for (int l = 0; l<3; ++l){
219  rpctfphivalue[l]->setBinLabel(lBin,ss.str());
220  m_muonsEtaPhi[l]->setBinLabel(lBin,ss.str(), 2);
221  }
222  }*/
223 
224 
225  // set eta bin labels
226  for (int i = -16; i < 17 ; ++i ){
227  std::stringstream ss;
228  ss << i;
229  for (int l = 0; l<3; ++l){
230  rpctfetavalue[l]->setBinLabel(i+17, ss.str());
231  m_muonsEtaPhi[l]->setBinLabel(i+17, ss.str(), 1);
232  m_qualVsEta[l]->setBinLabel(i+17, ss.str());
233  }
234  }
235 
236 
237 
238  m_bxDiff = m_dbe->book1D("RPCTF_bx_diff",
239  "RPCTrigger - bx difference", 12000, -.5, 11999.5);
240 
241 
242 
243  } // if (m_dbe)
244 }
245 
246 void L1TRPCTF::endRun(const edm::Run & r, const edm::EventSetup & c){
247 
248 
249 
250  // fixme, norm iteration would be better
251  while (m_globBX.begin() != m_globBX.end() ) {
252  long long int diff = *m_globBX.begin()-m_lastUsedBxInBxdiff; // first entry will go to overflow bin, ignore
253  m_bxDiff->Fill(diff);
254  m_lastUsedBxInBxdiff = *m_globBX.begin();
255  m_globBX.erase(m_globBX.begin());
256 
257  }
258 
259 
260 }
261 
262 
264 {
265 
266  if(verbose_) cout << "L1TRPCTF: end job...." << endl;
267  LogInfo("EndJob") << "analyzed " << nev_ << " events";
268 
269  if ( outputFile_.size() != 0 && m_dbe ) m_dbe->save(outputFile_);
270 
271  return;
272 
273 }
274 
275 void L1TRPCTF::analyze(const Event& e, const EventSetup& c)
276 {
277  nev_++;
278  if(verbose_) cout << "L1TRPCTF: analyze...." << endl;
279 
281  e.getByToken(rpctfSource_,pCollection);
282 
283  if (!pCollection.isValid()) {
284  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection";
285  return;
286  }
287 
288 
289  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
290  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
291  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
292 
293  std::vector<int> nrpctftrack_b(3,0);
294  std::vector<int> nrpctftrack_e(3,0);
295 
296  vector<L1TRPCTF::BxDelays> all_bxdelays;
297 
298 
299  for( RRItr = gmt_records.begin() ;
300  RRItr != gmt_records.end() ;
301  RRItr++ )
302  {
303 
304  if (verbose_) cout << "Readout Record " << RRItr->getBxInEvent() << endl;
305 
306  vector<vector<L1MuRegionalCand> > brlAndFwdCands;
307  brlAndFwdCands.push_back(RRItr->getBrlRPCCands());
308  brlAndFwdCands.push_back(RRItr->getFwdRPCCands());
309 
310  int beIndex = 0;
311  vector<vector<L1MuRegionalCand> >::iterator RPCTFCands = brlAndFwdCands.begin();
312  for(; RPCTFCands!= brlAndFwdCands.end(); ++RPCTFCands)
313  {
314 
315  for( vector<L1MuRegionalCand>::const_iterator
316  ECItr = RPCTFCands->begin() ;
317  ECItr != RPCTFCands->end() ;
318  ++ECItr )
319  {
320 
321  int bxindex = 1 ; // bx == 0
322  if (ECItr->bx() > 0) bxindex = 2;
323  if (ECItr->bx() < 0) bxindex = 0;
324 
325  if (!ECItr->empty()) {
326 
327 
328  if (beIndex == 0) ++nrpctftrack_b[bxindex];
329  if (beIndex == 1) ++nrpctftrack_e[bxindex];
330 
331  if (verbose_) cout << "RPCTFCand bx " << ECItr->bx() << endl;
332 
333  int tower = ECItr->eta_packed();
334  if (tower > 16) {
335  tower = - ( (~tower & 63) + 1);
336  }
337 
338  rpctfbx->Fill(ECItr->bx());
339 
340  rpctfetavalue[bxindex]->Fill(tower);
341  if (verbose_) cout << "\tRPCTFCand eta value " << ECItr->etaValue() << endl;
342 
343  rpctfphivalue[bxindex]->Fill(ECItr->phi_packed());
344  if (verbose_) cout << "\tRPCTFCand phi value " << ECItr->phiValue() << endl;
345 
346  rpctfptvalue[bxindex]->Fill(ECItr->ptValue());
347  if (verbose_) cout << "\tRPCTFCand pt value " << ECItr->ptValue()<< endl;
348 
349  rpctfchargevalue[bxindex]->Fill(ECItr->chargeValue());
350  if (verbose_) cout << "\tRPCTFCand charge value " << ECItr->chargeValue() << endl;
351 
352  rpctfquality[bxindex]->Fill(ECItr->quality());
353  if (verbose_) cout << "\tRPCTFCand quality " << ECItr->quality() << endl;
354 
355 
356  m_qualVsEta[bxindex]->Fill(tower, ECItr->quality());
357  m_muonsEtaPhi[bxindex]->Fill(tower, ECItr->phi_packed());
358 
359  BxDelays bx_del;
360  bx_del.bx = ECItr->bx();
361  bx_del.eta_t = tower;
362  bx_del.phi_p = ECItr->phi_packed();
363  all_bxdelays.push_back(bx_del);
364 
365  } // if !empty
366  } // end candidates iteration
367  ++beIndex;
368  } // end brl/endcap iteration
369  } // end GMT records iteration
370 
371  for (int bxI = 0; bxI < 3; ++bxI){
372  rpctfntrack_b[bxI]->Fill(nrpctftrack_b[bxI]);
373  rpctfntrack_e[bxI]->Fill(nrpctftrack_e[bxI]);
374  }
375 
376 
377  for(unsigned int i = 0; i < all_bxdelays.size(); i++) {
378 
379  int sector= ((all_bxdelays[i].phi_p+ 142)%144)/12;
380  if (sector>11 || sector < 0) continue;
381  int eta_tower = all_bxdelays[i].eta_t;
382  for(unsigned int j = 0; j < all_bxdelays.size(); j++) {
383  if(i == j) continue;
384  int sector2= ((all_bxdelays[j].phi_p + 142)%144)/12;
385 
386  int distance_cut = 1;
387  int distance = ((sector+12)-sector2)%12;
388  distance = min(distance, 11-distance);
389  if(distance<distance_cut) continue;
390 
391  int bxDiff = all_bxdelays[i].bx-all_bxdelays[j].bx;
392  rpctfcratesynchro[sector]->Fill(bxDiff,eta_tower);
393  }
394 
395  }
396 
397 
398 
399 }
400 
402  const edm::EventSetup& context)
403 {
404 // m_rpcDigiWithBX0=0;
405 // m_rpcDigiWithBXnon0=0;
406 // m_bxs.clear();
407 // m_useRpcDigi = true;
408 
409 
410 }
411 
412 
414  const edm::EventSetup& c)
415 {
416 
417 }
418 
std::set< unsigned long long int > m_globBX
Definition: L1TRPCTF.h:90
MonitorElement * rpctfcratesynchro[12]
Definition: L1TRPCTF.h:89
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * rpctfchargevalue[3]
Definition: L1TRPCTF.h:79
MonitorElement * rpctfetavalue[3]
Definition: L1TRPCTF.h:76
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2730
MonitorElement * rpctfptvalue[3]
Definition: L1TRPCTF.h:78
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void endJob(void)
Definition: L1TRPCTF.cc:263
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
#define NULL
Definition: scimark2.h:8
virtual ~L1TRPCTF()
Definition: L1TRPCTF.cc:62
void Fill(long long x)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1TRPCTF.cc:275
std::string outputFile_
Definition: L1TRPCTF.h:99
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
Definition: L1TRPCTF.cc:401
MonitorElement * rpctfquality[3]
Definition: L1TRPCTF.h:80
MonitorElement * rpctfphivalue[3]
Definition: L1TRPCTF.h:77
int nev_
Definition: L1TRPCTF.h:97
int j
Definition: DBlmapReader.cc:9
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
void endRun(const edm::Run &r, const edm::EventSetup &c)
Definition: L1TRPCTF.cc:246
void setVerbose(unsigned level)
Definition: DQMStore.cc:548
MonitorElement * m_bxDiff
Definition: L1TRPCTF.h:88
bool isValid() const
Definition: HandleBase.h:76
MonitorElement * m_muonsEtaPhi[3]
Definition: L1TRPCTF.h:85
MonitorElement * m_qualVsEta[3]
Definition: L1TRPCTF.h:84
std::string output_dir_
Definition: L1TRPCTF.h:106
L1TRPCTF(const edm::ParameterSet &ps)
Definition: L1TRPCTF.cc:18
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
Definition: L1TRPCTF.cc:413
long long int m_lastUsedBxInBxdiff
Definition: L1TRPCTF.h:105
double b
Definition: hdecay.h:120
T const * product() const
Definition: Handle.h:81
MonitorElement * rpctfntrack_e[3]
Definition: L1TRPCTF.h:82
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
MonitorElement * rpctfbx
Definition: L1TRPCTF.h:83
MonitorElement * rpctfntrack_b[3]
Definition: L1TRPCTF.h:81
int nevRPC_
Definition: L1TRPCTF.h:98
bool verbose_
Definition: L1TRPCTF.h:100
tuple cout
Definition: gather_cfg.py:121
void beginJob(void)
Definition: L1TRPCTF.cc:66
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1000
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41
edm::EDGetTokenT< L1MuGMTReadoutCollection > rpctfSource_
Definition: L1TRPCTF.h:95
DQMStore * m_dbe
Definition: L1TRPCTF.h:74