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