CMS 3D CMS Logo

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  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
36  if ( outputFile_.size() != 0 ) {
37  cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
38  }
39 
40  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
41  if(disable){
42  outputFile_="";
43  }
44 }
45 
46 
47 
49 {
50 }
51 
53 {
54 
55  nev_ = 0;
56  nevRPC_ = 0;
57 
58  ostringstream oDir; oDir<< output_dir_ << "/CrateSynchroHistograms/";
59  ibooker.setCurrentFolder(oDir.str());
60  for( unsigned int i = 0; i < 12; i++) {
61 
62  ostringstream o; o<<"RPCTF_crate_"<<i<<"_synchro";
63  rpctfcratesynchro[i] = ibooker.book2D(o.str(), o.str(), 5, -2.5, 2.5, 33, -16.5, 16.5);
64  for (int bx = -2; bx < 3; ++bx){
65  ostringstream b; b<<"BX="<<bx;
66  rpctfcratesynchro[i]->setBinLabel(bx+3, b.str(),1);
67  }
68  rpctfcratesynchro[i]->setAxisTitle("Tower",2);
69 
70  }
71  ibooker.setCurrentFolder(output_dir_);
72 
73  rpctfetavalue[1] = ibooker.book1D("RPCTF_eta_value_bx0",
74  "RPCTF eta value bx=0", 33, -16.5, 16.5 ) ;
75  rpctfetavalue[2] = ibooker.book1D("RPCTF_eta_value_bx+",
76  "RPCTF eta value bx>0", 33, -16.5, 16.5 ) ;
77  rpctfetavalue[0] = ibooker.book1D("RPCTF_eta_value_bx-",
78  "RPCTF eta value bx<0", 33, -16.5, 16.5 ) ;
79 
80  rpctfphivalue[1] = ibooker.book1D("RPCTF_phi_value_bx0",
81  "RPCTF phi value bx=0", 144, -0.5, 143.5) ;
82  rpctfphivalue[2] = ibooker.book1D("RPCTF_phi_value_bx+",
83  "RPCTF phi value bx>0", 144, -0.5, 143.5 ) ;
84  rpctfphivalue[0] = ibooker.book1D("RPCTF_phi_value_bx-",
85  "RPCTF phi value bx<0", 144, -0.5, 143.5 ) ;
86 
87 
88 
89  rpctfptvalue[1] = ibooker.book1D("RPCTF_pt_value_bx0",
90  "RPCTF pt value bx=0", 160, -0.5, 159.5 );
91  rpctfptvalue[2] = ibooker.book1D("RPCTF_pt_value_bx+",
92  "RPCTF pt value bx>0", 160, -0.5, 159.5 );
93  rpctfptvalue[0] = ibooker.book1D("RPCTF_pt_value_bx-",
94  "RPCTF pt value bx<0", 160, -0.5, 159.5 );
95 
96 
97  rpctfchargevalue[1] = ibooker.book1D("RPCTF_charge_value_bx0",
98  "RPCTF charge value bx=0", 3, -1.5, 1.5 ) ;
99  rpctfchargevalue[2] = ibooker.book1D("RPCTF_charge_value_bx+",
100  "RPCTF charge value bx>0", 3, -1.5, 1.5 ) ;
101  rpctfchargevalue[0] = ibooker.book1D("RPCTF_charge_value_bx-",
102  "RPCTF charge value bx<01", 3, -1.5, 1.5 ) ;
103 
104  rpctfquality[1] = ibooker.book1D("RPCTF_quality",
105  "RPCTF quality bx=0", 6, -0.5, 5.5 ) ;
106  rpctfquality[2] = ibooker.book1D("RPCTF_quality_bx+",
107  "RPCTF quality bx>0", 6, -0.5, 5.5 ) ;
108  rpctfquality[0] = ibooker.book1D("RPCTF_quality_bx-",
109  "RPCTF quality bx<0", 6, -0.5, 5.5 ) ;
110 
111  rpctfntrack_b[1] = ibooker.book1D("RPCTF_ntrack_brl_bx0",
112  "RPCTF number of tracks - barrel, bx=0", 5, -0.5, 4.5 ) ;
113  rpctfntrack_b[2] = ibooker.book1D("RPCTF_ntrack_brl_bx+",
114  "RPCTF number of tracks - barrel, bx>0", 5, -0.5, 4.5 ) ;
115  rpctfntrack_b[0] = ibooker.book1D("RPCTF_ntrack_brl_bx-",
116  "RPCTF number of tracks - barrel, bx<0", 5, -0.5, 4.5 ) ;
117 
118 
119 
120  rpctfntrack_e[1] = ibooker.book1D("RPCTF_ntrack_fwd_bx0",
121  "RPCTF number of tracks - endcap, bx=0", 5, -0.5, 4.5 ) ;
122  rpctfntrack_e[2] = ibooker.book1D("RPCTF_ntrack_fwd_bx+",
123  "RPCTF number of tracks - endcap, bx>0", 5, -0.5, 4.5 ) ;
124  rpctfntrack_e[0] = ibooker.book1D("RPCTF_ntrack_fwd_bx-",
125  "RPCTF number of tracks - endcap, bx<0", 5, -0.5, 4.5 ) ;
126 
127 
128 
129 
130 
131  m_qualVsEta[1] = ibooker.book2D("RPCTF_quality_vs_eta_bx0",
132  "RPCTF quality vs eta, bx=0",
133  33, -16.5, 16.5,
134  6, -0.5, 5.5); // Currently only 0...3 quals are possible
135  m_qualVsEta[2] = ibooker.book2D("RPCTF_quality_vs_eta_bx+",
136  "RPCTF quality vs eta, bx>0",
137  33, -16.5, 16.5,
138  6, -0.5, 5.5); // Currently only 0...3 quals are possible
139  m_qualVsEta[0] = ibooker.book2D("RPCTF_quality_vs_eta_bx-",
140  "RPCTF quality vs eta, bx<0",
141  33, -16.5, 16.5,
142  6, -0.5, 5.5); // Currently only 0...3 quals are possible
143 
144 
145 
146  m_muonsEtaPhi[1] = ibooker.book2D("RPCTF_muons_eta_phi_bx0",
147  "RPCTF occupancy(eta,phi), bx=0",
148  33, -16.5, 16.5,
149  144, -0.5, 143.5);
150  m_muonsEtaPhi[2] = ibooker.book2D("RPCTF_muons_eta_phi_bx+",
151  "RPCTF occupancy(eta,phi), bx>0",
152  33, -16.5, 16.5,
153  144, -0.5, 143.5);
154  m_muonsEtaPhi[0] = ibooker.book2D("RPCTF_muons_eta_phi_bx-",
155  "RPCTF occupancy(eta,phi), bx<0",
156  33, -16.5, 16.5,
157  144, -0.5, 143.5);
158 
159  rpctfbx = ibooker.book1D("RPCTF_bx",
160  "RPCTF bx distribiution", 7, -3.5, 3.5 );
161 
162  //axis labels
163  for (int l = 0; l<3; ++l){
164  m_muonsEtaPhi[l]->setAxisTitle("tower",1);
165  m_qualVsEta[l]->setAxisTitle("tower");
166  rpctfetavalue[l]->setAxisTitle("tower");
167 
168  m_muonsEtaPhi[l]->setAxisTitle("phi",2);
169  rpctfphivalue[l]->setAxisTitle("phi");
170  }
171 
172  // set phi bin labels
173  for (int i = 0; i < 12 ; ++i ){
174  //float lPhi = (30./360)*i*2*3.14;
175  int lPhi = 30*i;
176  int lBin = int((30./360)*i*144)+1;
177  std::stringstream ss;
178  ss << "phi=" <<lPhi;
179  for (int l = 0; l<3; ++l){
180  rpctfphivalue[l]->setBinLabel(lBin,ss.str());
181  m_muonsEtaPhi[l]->setBinLabel(lBin,ss.str(), 2);
182  }
183  }
184 
185  /*
186  // set TC numbers on phi axis
187  for (int tc = 0; tc < 12 ; ++tc ){
188  int lBin = (tc*12+3+1)%144;
189  std::stringstream ss;
190  ss << "TC" <<tc;
191  for (int l = 0; l<3; ++l){
192  rpctfphivalue[l]->setBinLabel(lBin,ss.str());
193  m_muonsEtaPhi[l]->setBinLabel(lBin,ss.str(), 2);
194  }
195  }*/
196 
197 
198  // set eta bin labels
199  for (int i = -16; i < 17 ; ++i ){
200  std::stringstream ss;
201  ss << i;
202  for (int l = 0; l<3; ++l){
203  rpctfetavalue[l]->setBinLabel(i+17, ss.str());
204  m_muonsEtaPhi[l]->setBinLabel(i+17, ss.str(), 1);
205  m_qualVsEta[l]->setBinLabel(i+17, ss.str());
206  }
207  }
208 
209 
210 
211  m_bxDiff = ibooker.book1D("RPCTF_bx_diff",
212  "RPCTrigger - bx difference", 12000, -.5, 11999.5);
213 
214 }
215 
216 void L1TRPCTF::analyze(const Event& e, const EventSetup& c)
217 {
218  nev_++;
219  if(verbose_) cout << "L1TRPCTF: analyze...." << endl;
220 
222  e.getByToken(rpctfSource_,pCollection);
223 
224  if (!pCollection.isValid()) {
225  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection";
226  return;
227  }
228 
229 
230  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
231  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
232  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
233 
234  std::vector<int> nrpctftrack_b(3,0);
235  std::vector<int> nrpctftrack_e(3,0);
236 
237  vector<L1TRPCTF::BxDelays> all_bxdelays;
238 
239 
240  for( RRItr = gmt_records.begin() ;
241  RRItr != gmt_records.end() ;
242  RRItr++ )
243  {
244 
245  if (verbose_) cout << "Readout Record " << RRItr->getBxInEvent() << endl;
246 
247  vector<vector<L1MuRegionalCand> > brlAndFwdCands;
248  brlAndFwdCands.push_back(RRItr->getBrlRPCCands());
249  brlAndFwdCands.push_back(RRItr->getFwdRPCCands());
250 
251  int beIndex = 0;
252  vector<vector<L1MuRegionalCand> >::iterator RPCTFCands = brlAndFwdCands.begin();
253  for(; RPCTFCands!= brlAndFwdCands.end(); ++RPCTFCands)
254  {
255 
256  for( vector<L1MuRegionalCand>::const_iterator
257  ECItr = RPCTFCands->begin() ;
258  ECItr != RPCTFCands->end() ;
259  ++ECItr )
260  {
261 
262  int bxindex = 1 ; // bx == 0
263  if (ECItr->bx() > 0) bxindex = 2;
264  if (ECItr->bx() < 0) bxindex = 0;
265 
266  if (!ECItr->empty()) {
267 
268 
269  if (beIndex == 0) ++nrpctftrack_b[bxindex];
270  if (beIndex == 1) ++nrpctftrack_e[bxindex];
271 
272  if (verbose_) cout << "RPCTFCand bx " << ECItr->bx() << endl;
273 
274  int tower = ECItr->eta_packed();
275  if (tower > 16) {
276  tower = - ( (~tower & 63) + 1);
277  }
278 
279  rpctfbx->Fill(ECItr->bx());
280 
281  rpctfetavalue[bxindex]->Fill(tower);
282  if (verbose_) cout << "\tRPCTFCand eta value " << ECItr->etaValue() << endl;
283 
284  rpctfphivalue[bxindex]->Fill(ECItr->phi_packed());
285  if (verbose_) cout << "\tRPCTFCand phi value " << ECItr->phiValue() << endl;
286 
287  rpctfptvalue[bxindex]->Fill(ECItr->ptValue());
288  if (verbose_) cout << "\tRPCTFCand pt value " << ECItr->ptValue()<< endl;
289 
290  rpctfchargevalue[bxindex]->Fill(ECItr->chargeValue());
291  if (verbose_) cout << "\tRPCTFCand charge value " << ECItr->chargeValue() << endl;
292 
293  rpctfquality[bxindex]->Fill(ECItr->quality());
294  if (verbose_) cout << "\tRPCTFCand quality " << ECItr->quality() << endl;
295 
296 
297  m_qualVsEta[bxindex]->Fill(tower, ECItr->quality());
298  m_muonsEtaPhi[bxindex]->Fill(tower, ECItr->phi_packed());
299 
300  BxDelays bx_del;
301  bx_del.bx = ECItr->bx();
302  bx_del.eta_t = tower;
303  bx_del.phi_p = ECItr->phi_packed();
304  all_bxdelays.push_back(bx_del);
305 
306  } // if !empty
307  } // end candidates iteration
308  ++beIndex;
309  } // end brl/endcap iteration
310  } // end GMT records iteration
311 
312  for (int bxI = 0; bxI < 3; ++bxI){
313  rpctfntrack_b[bxI]->Fill(nrpctftrack_b[bxI]);
314  rpctfntrack_e[bxI]->Fill(nrpctftrack_e[bxI]);
315  }
316 
317 
318  for(unsigned int i = 0; i < all_bxdelays.size(); i++) {
319 
320  int sector= ((all_bxdelays[i].phi_p+ 142)%144)/12;
321  if (sector>11 || sector < 0) continue;
322  int eta_tower = all_bxdelays[i].eta_t;
323  for(unsigned int j = 0; j < all_bxdelays.size(); j++) {
324  if(i == j) continue;
325  int sector2= ((all_bxdelays[j].phi_p + 142)%144)/12;
326 
327  int distance_cut = 1;
328  int distance = ((sector+12)-sector2)%12;
329  distance = min(distance, 11-distance);
330  if(distance<distance_cut) continue;
331 
332  int bxDiff = all_bxdelays[i].bx-all_bxdelays[j].bx;
333  rpctfcratesynchro[sector]->Fill(bxDiff,eta_tower);
334  }
335 
336  }
337 
338  while (m_globBX.begin() != m_globBX.end() ) {
339  long long int diff = *m_globBX.begin()-m_lastUsedBxInBxdiff; // first entry will go to overflow bin, ignore
340  m_bxDiff->Fill(diff);
341  m_lastUsedBxInBxdiff = *m_globBX.begin();
342  m_globBX.erase(m_globBX.begin());
343  }
344 
345  if(verbose_) cout << "L1TRPCTF: end job...." << endl;
346  LogInfo("EndJob") << "analyzed " << nev_ << " events";
347 
348 }
349 
351  const edm::EventSetup& c){
352 // m_rpcDigiWithBX0=0;
353 // m_rpcDigiWithBXnon0=0;
354 // m_bxs.clear();
355 // m_useRpcDigi = true;
356 
357 
358 }
359 
360 
362  const edm::EventSetup& c){
363 
364 }
365 
367 
368 }
std::set< unsigned long long int > m_globBX
Definition: L1TRPCTF.h:86
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c) override
Definition: L1TRPCTF.cc:361
MonitorElement * rpctfcratesynchro[12]
Definition: L1TRPCTF.h:83
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * rpctfchargevalue[3]
Definition: L1TRPCTF.h:73
MonitorElement * rpctfetavalue[3]
Definition: L1TRPCTF.h:70
MonitorElement * rpctfptvalue[3]
Definition: L1TRPCTF.h:72
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
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)
virtual void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: L1TRPCTF.cc:366
virtual void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
Definition: L1TRPCTF.cc:52
virtual ~L1TRPCTF()
Definition: L1TRPCTF.cc:48
void Fill(long long x)
std::string outputFile_
Definition: L1TRPCTF.h:92
MonitorElement * rpctfquality[3]
Definition: L1TRPCTF.h:74
MonitorElement * rpctfphivalue[3]
Definition: L1TRPCTF.h:71
int nev_
Definition: L1TRPCTF.h:90
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
T min(T a, T b)
Definition: MathUtil.h:58
MonitorElement * m_bxDiff
Definition: L1TRPCTF.h:82
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * m_muonsEtaPhi[3]
Definition: L1TRPCTF.h:79
MonitorElement * m_qualVsEta[3]
Definition: L1TRPCTF.h:78
std::string output_dir_
Definition: L1TRPCTF.h:99
L1TRPCTF(const edm::ParameterSet &ps)
Definition: L1TRPCTF.cc:18
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
long long int m_lastUsedBxInBxdiff
Definition: L1TRPCTF.h:98
double b
Definition: hdecay.h:120
MonitorElement * rpctfntrack_e[3]
Definition: L1TRPCTF.h:76
HLT enums.
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
MonitorElement * rpctfbx
Definition: L1TRPCTF.h:77
MonitorElement * rpctfntrack_b[3]
Definition: L1TRPCTF.h:75
virtual void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c) override
Definition: L1TRPCTF.cc:350
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Definition: L1TRPCTF.cc:216
int nevRPC_
Definition: L1TRPCTF.h:91
bool verbose_
Definition: L1TRPCTF.h:93
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: Run.h:42
edm::EDGetTokenT< L1MuGMTReadoutCollection > rpctfSource_
Definition: L1TRPCTF.h:88