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