CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCSCTF.cc
Go to the documentation of this file.
1 /*
2  * \file L1TCSCTF.cc
3  *
4  * $Date: 2010/03/03 17:04:18 $
5  * $Revision: 1.35 $
6  * \author J. Berryhill
7  *
8  */
9 
12 
13 // KK_start: includes to fetch all reguired data products from the edm::Event
19 // KK_end
20 
21 //GP_start
24 //GP_end
25 
26 using namespace std;
27 using namespace edm;
28 
30  // KK_start: if some piece of data is absent - configure corresponding source with 'null:'
31  // : csctfSource_( ps.getParameter< InputTag >("csctfSource") )
32  : gmtProducer( ps.getParameter< InputTag >("gmtProducer") ),
33  lctProducer( ps.getParameter< InputTag >("lctProducer") ),
34  trackProducer( ps.getParameter< InputTag >("trackProducer") ),
35  statusProducer( ps.getParameter< InputTag >("statusProducer") ),
36  mbProducer( ps.getParameter< InputTag >("mbProducer") )
37  // KK_end
38 {
39 
40  // verbosity switch
41  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
42 
43  if(verbose_) edm::LogInfo("DataNotFound") << "L1TCSCTF: constructor...." << endl;
44 
45 
46  dbe = NULL;
47  if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
48  {
50  dbe->setVerbose(0);
51  }
52 
53  outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
54  if ( outputFile_.size() != 0 )
55  {
56  edm::LogInfo("DataNotFound") << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
57  }
58 
59  bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
60  if(disable){
61  outputFile_="";
62  }
63 
64 
65  if ( dbe !=NULL )
66  {
67  dbe->setCurrentFolder("L1T/L1TCSCTF");
68  }
69 
70  // KK_start: instantiate standard on-fly SR LUTs from CSC TF emulator package
71  bzero(srLUTs_,sizeof(srLUTs_));
72  int endcap=1, sector=1; // assume SR LUTs are all same for every sector in either of endcaps
73  bool TMB07=true; // specific TMB firmware
74  // Create a dumy pset for SR LUTs
75  edm::ParameterSet srLUTset;
76  srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
77  srLUTset.addUntrackedParameter<bool>("Binary", false);
78  srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
79  for(int station=1,fpga=0; station<=4 && fpga<5; station++)
80  {
81  if(station==1)
82  for(int subSector=0; subSector<2 && fpga<5; subSector++)
83  srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, subSector+1, station, srLUTset, TMB07);
84  else
85  srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, 0, station, srLUTset, TMB07);
86  }
87  // KK_end
88 }
89 
91 {
92 
93  for(int i=0; i<5; i++)
94  delete srLUTs_[i]; //free the array of pointers
95 }
96 
98 {
99 
100  nev_ = 0;
101 
102  // get hold of back-end interface
103  DQMStore* dbe = 0;
104  dbe = Service<DQMStore>().operator->();
105 
106  if( dbe )
107  {
108  dbe->setCurrentFolder("L1T/L1TCSCTF");
109  dbe->rmdir("L1T/L1TCSCTF");
110  }
111 
112 
113  if( dbe )
114  {
115  dbe->setCurrentFolder("L1T/L1TCSCTF");
116 
117  // KK_start: declaration of two monitoring histograms
118  // Error counting histogram:
119  // 1) checks TF data integrity (error rate - first bin),
120  // 2) monitors sychronization on input links (4 errors types: SE/SM/BX/AF; ORed for all time bins, links, and SPs),
121  // 3) reports FMM status (if in any SP FMM status != "Ready" - fill the last bin)
122  csctferrors = dbe->book1D("CSCTF_errors","CSCTF Errors",6,0,6);
123  csctferrors->setAxisTitle("Error type",1);
124  csctferrors->setAxisTitle("Number of Errors",2);
125  csctferrors->setBinLabel(1,"Corruptions",1);
126  csctferrors->setBinLabel(2,"Synch. Err.",1);
127  csctferrors->setBinLabel(3,"Synch. Mod.",1);
128  csctferrors->setBinLabel(4,"BX mismatch",1);
129  csctferrors->setBinLabel(5,"Time misalign.",1);
130  csctferrors->setBinLabel(6,"FMM != Ready",1);
131 
132  // Occupancy histogram Eta x Y, where Y:
133  // 1) Phi_packed of input LCTs from 1st, 2nd, 3rd, and 4th stations
134  // 2) Phi_packed of output tracks
135  // (all 12 SPs - 360 degree coveradge)
136  //csctfoccupancies = dbe->book2D("CSCTF_occupancies","CSCTF Occupancies",100,0.8,2.5,1229,0,1.2);
137 
138  //JAG MOD
139  csctfoccupancies = dbe->book2D("CSCTF_occupancies", "CSCTF Occupancies", 64,-32,31,32,0,6.2);
140  csctfoccupancies->setAxisTitle("#eta",1);
141  csctfoccupancies->setAxisTitle("#phi",2);
142  csctfoccupancies->setBinLabel(1, "-2.5", 1);
143  csctfoccupancies->setBinLabel(16,"-1.3", 1);
144  csctfoccupancies->setBinLabel(32,"-0.9", 1);
145  csctfoccupancies->setBinLabel(33,"0.9", 1);
146  csctfoccupancies->setBinLabel(45,"1.3", 1);
147  csctfoccupancies->setBinLabel(64,"2.5", 1);
148  // KK_end
149 
150  //JAG
151  haloDelEta23 = dbe->book1D("CSCTF_Halo_Eta23","Delta station 2 to station 3 Eta for Halo Muons", 40, -0.20,0.30);
152 
153 
154  csctfTrackQ = dbe->book1D("CSCTF_Track_Q","CSC Track Mode", 16, -0.5, 15.5);
155  csctfTrackQ->setAxisTitle("Track Type", 1);
156  csctfTrackQ->setBinLabel(1,"No Track",1);
157  csctfTrackQ->setBinLabel(2,"Bad Phi Road",1);
158  csctfTrackQ->setBinLabel(3,"ME1-2-3",1);
159  csctfTrackQ->setBinLabel(4,"ME1-2-4",1);
160  csctfTrackQ->setBinLabel(5,"ME1-3-4",1);
161  csctfTrackQ->setBinLabel(6,"ME2-3-4",1);
162  csctfTrackQ->setBinLabel(7,"ME1-2",1);
163  csctfTrackQ->setBinLabel(8,"ME1-3",1);
164  csctfTrackQ->setBinLabel(9,"ME2-3",1);
165  csctfTrackQ->setBinLabel(10,"ME2-4",1);
166  csctfTrackQ->setBinLabel(11,"ME3-4",1);
167  csctfTrackQ->setBinLabel(12,"Singles",1);
168  csctfTrackQ->setBinLabel(13,"ME1-2,MB1",1);
169  csctfTrackQ->setBinLabel(14,"ME1-4",1);
170  csctfTrackQ->setBinLabel(15,"ME2,MB1",1);
171  csctfTrackQ->setBinLabel(16,"Halo Trigger",1);
172 
173  csctfChamberOccupancies = dbe->book2D("CSCTF_Chamber_Occupancies","CSCTF Chamber Occupancies", 54, -0.05, 5.35, 10, -5.5, 4.5);
174  csctfChamberOccupancies->setAxisTitle("Sector (Endcap), (chambers 1-9 not labeled)",1);
178  csctfChamberOccupancies->setBinLabel(4,"ME-1b",2);
179  csctfChamberOccupancies->setBinLabel(5,"ME-1a",2);
180  csctfChamberOccupancies->setBinLabel(6,"ME+1a",2);
181  csctfChamberOccupancies->setBinLabel(7,"ME+1b",2);
184  csctfChamberOccupancies->setBinLabel(10,"ME+4",2);
185  csctfChamberOccupancies->setBinLabel(1, "1(+), 7(-)",1);
186  csctfChamberOccupancies->setBinLabel(10,"2(+), 8(-)",1);
187  csctfChamberOccupancies->setBinLabel(19,"3(+), 9(-)",1);
188  csctfChamberOccupancies->setBinLabel(28,"4(+), 10(-)",1);
189  csctfChamberOccupancies->setBinLabel(37,"5(+), 11(-)",1);
190  csctfChamberOccupancies->setBinLabel(46,"6(+), 12(-)",1);
191 
192  csctfTrackPhi = dbe->book1D("CSCTF_Track_Phi", "CSCTF Track Phi",144,0,2*M_PI);
193  //csctfTrackPhi = dbe->book1D("CSCTF_Track_Phi", "CSCTF Track Phi",32,0,32);
194  csctfTrackPhi->setAxisTitle("Track #phi", 1);
195  csctfTrackEta = dbe->book1D("CSCTF_Track_Eta", "CSCTF Track Eta",64,-32,32);
196  //csctfTrackEta = dbe->book1D("CSCTF_Track_Eta", "CSCTF TrackEta",32,0,32);
197  csctfTrackEta->setAxisTitle("Track #eta", 1);
198  csctfTrackEta->setBinLabel(1, "-2.5", 1);
199  csctfTrackEta->setBinLabel(16,"-1.3", 1);
200  csctfTrackEta->setBinLabel(32,"-0.9", 1);
201  csctfTrackEta->setBinLabel(33,"0.9", 1);
202  csctfTrackEta->setBinLabel(45,"1.3", 1);
203  csctfTrackEta->setBinLabel(64,"2.5", 1);
204 
205  csctfbx = dbe->bookProfile("CSCTF_bx","CSCTF bx", 36, 0.5, 36.5, 15, -5.5,9.5 ) ;
206  csctfbx->setAxisTitle("Sector, Endcap, MPC Link", 1);
207  csctfbx->setBinLabel(1,"1, +",1);
208  csctfbx->setBinLabel(4,"2, +",1);
209  csctfbx->setBinLabel(7,"3, +",1);
210  csctfbx->setBinLabel(10,"4, +",1);
211  csctfbx->setBinLabel(13,"5, +",1);
212  csctfbx->setBinLabel(16,"6, +",1);
213  csctfbx->setBinLabel(19,"1, -",1);
214  csctfbx->setBinLabel(22,"2, -",1);
215  csctfbx->setBinLabel(25,"3, -",1);
216  csctfbx->setBinLabel(28,"4, -",1);
217  csctfbx->setBinLabel(31,"5, -",1);
218  csctfbx->setBinLabel(34,"6, -",1);
219 
220  cscTrackStubNumbers = dbe->book1D("CSCTF_TrackStubs", "Number of Stubs in CSC Tracks", 5, 0.5, 5.5);
221 
222  csctfntrack = dbe->book1D("CSCTF_ntrack","Number of CSCTracks found per event", 5, 0.5, 5.5 ) ;
223  //JAG
224  }
225 
226  //GP_start
227  char hname [200];
228  char htitle[200];
229 
230  for(int i=0; i<12; i++) {
231 
232  sprintf(hname ,"DTstubsTimeTrackMenTimeArrival_%d",i+1);
233  sprintf(htitle,"T_{track} - T_{DT stub} sector %d",i+1);
234 
235  DTstubsTimeTrackMenTimeArrival[i] = dbe->book2D(hname,htitle, 7,-3,3, 2,1,3);
236  DTstubsTimeTrackMenTimeArrival[i]->getTH2F()->SetMinimum(0);
237 
238  // axis makeup
239  DTstubsTimeTrackMenTimeArrival[i]->setAxisTitle("bx_{CSC track} - bx_{DT stub}",1);
241 
249 
252 
253  }
254 
255  csctfHaloL1ABXN = dbe->book1D("csctfHaloL1ABXN" ,"L1A BXN (HALO)", 3564,0,3564);
256  csctfHaloL1ABXN->setAxisTitle("L1A (BX)",1);
257  csctfCoincL1ABXN = dbe->book1D("csctfCoincL1ABXN","L1A BXN (COINCIDENCE)", 3564,0,3564);
258  csctfCoincL1ABXN->setAxisTitle("L1A (BX)",1);
259  //GP_end
260 
261 
262 }
263 
264 
266 {
267 
268  if(verbose_) edm::LogInfo("DataNotFound") << "L1TCSCTF: end job...." << endl;
269  LogInfo("EndJob") << "analyzed " << nev_ << " events";
270 
271  if ( outputFile_.size() != 0 && dbe ) dbe->save(outputFile_);
272 
273  return;
274 }
275 
276 void L1TCSCTF::analyze(const Event& e, const EventSetup& c)
277 {
278  int NumCSCTfTracksRep = 0;
279  nev_++;
280  if(verbose_) edm::LogInfo("DataNotFound") << "L1TCSCTF: analyze...." << endl;
281 
283  if( gmtProducer.label() != "null" )
284  { // GMT block
285  e.getByLabel(gmtProducer,pCollection);
286  if (!pCollection.isValid())
287  {
288  edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label "; // << csctfSource_.label() ;
289  return;
290  }
291 
292  L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
293  vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
294  vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
295 
296  // GP
297  // Look if the readout window contains one (and only one CSC cands)
298  // to make it simpler I reject events with more than a CSC cand in the
299  // same readout window
300 
301  // count non-empty candidates in this bx
302  int bxWindow = 0;
303  int nCands = 0;
304 
305  for( RRItr = gmt_records.begin(); RRItr != gmt_records.end(); RRItr++ ) {
306  bxWindow++;
307 
308  // get the csc candidates
309  vector<L1MuRegionalCand> INPCands = RRItr->getCSCCands();
310 
311 
312  vector<L1MuRegionalCand>::const_iterator INPItr;
313 
314  BxInEvent_ = 0;
315  isCSCcand_ = false;
316 
317  int nCandsBx = 0;
318 
319  for( INPItr = INPCands.begin(); INPItr != INPCands.end(); ++INPItr ) {
320  if(!INPItr->empty()) {
321  nCandsBx++;
322  nCands++;
323  BxInEvent_ = RRItr->getBxInEvent();
324  if (verbose_)
325  edm::LogInfo("DataNotFound") << "cand " << nCandsBx << " -> assigned CSCTF bx: " << INPItr->bx() << endl;
326  }
327  }
328  if (verbose_)
329  if(nCandsBx)
330  edm::LogInfo("DataNotFound") << nCandsBx << " cands in bx: " << BxInEvent_ << endl;
331 
332  }
333 
334  if (nCands != 1) return;
335  else isCSCcand_ = true;
336  if (verbose_)
337  edm::LogInfo("DataNotFound") << "bxWindow: " << bxWindow << endl;
338  // GP_end
339 
340  int ncsctftrack = 0;
341  if (verbose_)
342  {
343  edm::LogInfo("DataNotFound") << "\tCSCTFCand ntrack " << ncsctftrack << endl;
344  }
345  } // end of GMT block
346 
347  L1ABXN = -999;
348  if( statusProducer.label() != "null" )
349  {
352  bool integrity=status->first, se=false, sm=false, bx=false, af=false, fmm=false;
353  int nStat = 0;
354 
355  for(std::vector<L1CSCSPStatusDigi>::const_iterator stat=status->second.begin(); stat!=status->second.end(); stat++)
356  {
357  se |= stat->SEs()&0xFFF;
358  sm |= stat->SMs()&0xFFF;
359  bx |= stat->BXs()&0xFFF;
360  af |= stat->AFs()&0xFFF;
361  fmm|= stat->FMM()!=8;
362 
363  //GP_start
364  if(stat->VPs() != 0) {
365  L1ABXN += stat->BXN();
366  nStat++;
367  }
368  //GP_end
369  }
370 
371  // GP: compute the average
372  if(nStat!=0) L1ABXN /= nStat;
373 
374  if(integrity) csctferrors->Fill(0.5);
375  if(se) csctferrors->Fill(1.5);
376  if(sm) csctferrors->Fill(2.5);
377  if(bx) csctferrors->Fill(3.5);
378  if(af) csctferrors->Fill(4.5);
379  if(fmm) csctferrors->Fill(5.5);
380  }
381 
382  if( lctProducer.label() != "null" )
383  {
385  c.get<MuonGeometryRecord>().get( pDD );
387 
390 
391  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
392  {
393  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
394  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
395  {
396  int endcap = (*csc).first.endcap()-1;
397  int station = (*csc).first.station()-1;
398  int sector = (*csc).first.triggerSector()-1;
399  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
400  int cscId = (*csc).first.triggerCscId()-1;
401  int fpga = ( subSector ? subSector-1 : station+1 );
402  //JAG
403  int endcapAssignment = 1;
404  int shift = 1;
405  float sectorArg = sector;
406  //float sectorArg = j;
407 
408  if( endcap == 1 ){
409  endcapAssignment = -1;
410  shift = 2;
411  //sectorArg = sector - 6;
412  }
413 
414  int signedStation = (station + shift)* endcapAssignment;
415  if( (station == 0) && (endcap == 0)) signedStation = subSector - 1;
416  if( (station == 0) && (endcap == 1)) signedStation = (-1)*subSector;
417 
418  float chamberArg1 = cscId * 0.1 + sectorArg;
419  //float chamberArg1 = i*0.1 + sectorArg;
420  //std::cout << "First" << i << " " << sectorArg << " " << chamberArg1 << std::endl;
421 
422  float chamberArg11 = chamberArg1;
423  if(sectorArg == 1) chamberArg1 = chamberArg11 - 0.1;
424  if(sectorArg == 2) chamberArg1 = chamberArg11 - 0.2;
425  if(sectorArg == 3) chamberArg1 = chamberArg11 - 0.3;
426  if(sectorArg == 4) chamberArg1 = chamberArg11 - 0.4;
427  if(sectorArg == 5) chamberArg1 = chamberArg11 - 0.5;
428 
429  //std::cout << "cscId, station, sector, endcap, sectorArg, chamber Arg: " << cscId << ", " << station << ", " <<sector << ", " << endcap << ", " << chamberArg1 << ", " << signedStation << std::endl;
430 
431  csctfChamberOccupancies->Fill(chamberArg1, signedStation);
432  int bunchX = ( (lct->getBX()) - 6 );
433 
434  int timingSectorArg = 3*(sector) + (lct->getMPCLink());
435  if( endcap == 1) timingSectorArg = 3*(sector + 6) + (lct->getMPCLink());
436  //std::cout << "Sector, MPCLink, TSA, endcap: " << sector << ", " << lct->getMPCLink() << ", " << timingSectorArg << ", " << endcap << std::endl;
437 
438  csctfbx->Fill(timingSectorArg, bunchX );
439 
440  //std::cout << "LCT'S, encap: " << endcap << ", station: " << station << ", sector: " << sector << ", subSector: " << subSector << ", cscId: " << cscId << std:: endl;
441 
442  //End JAG
443 
444  // Check if Det Id is within pysical range:
445  if( endcap<0||endcap>1 || sector<0||sector>6 || station<0||station>3 || cscId<0||cscId>8 || fpga<0||fpga>4)
446  {
447  edm::LogError("L1CSCTF: CSC TP are out of range: ")<<" endcap: "<<(endcap+1)<<" station: "<<(station+1) <<" sector: "<<(sector+1)<<" subSector: "<<subSector<<" fpga: "<<fpga<<" cscId: "<<(cscId+1);
448  continue;
449  }
450  lclphidat lclPhi;
451  try {
452  lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
453  } catch(...) {
454  bzero(&lclPhi,sizeof(lclPhi));
455  }
456 
457  gblphidat gblPhi;
458  try {
459  gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
460  } catch(...) {
461  bzero(&gblPhi,sizeof(gblPhi));
462  }
463 
464  gbletadat gblEta;
465  try {
466  gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
467  } catch(...) {
468  bzero(&gblEta,sizeof(gblEta));
469  }
470 
471  // SR LUT gives packed eta and phi values -> normilize them to 1 by scale them to 'max' and shift by 'min'
472  //float etaP = gblEta.global_eta/127*1.5 + 0.9;
473  //float phiP = (gblPhi.global_phi);// + ( sector )*4096 + station*4096*12) * 1./(4*4096*12);
474  //std::cout << "LCT Eta & Phi Coordinates: " << etaP << ", " << phiP << "." << std::endl;
475  //csctfoccupancies->Fill( gblEta.global_eta/127. * 1.5 + 0.9, (gblPhi.global_phi + ( sector + (endcap?0:6) )*4096 + station*4096*12) * 1./(4*4096*12) );
476  }//lct != range1.scond
477  }//csc!=corrlcts.product()->end()
478  }// lctProducer.label() != "null"
479 
480 
481 
482  if( trackProducer.label() != "null" )
483  {
484 
487  for(L1CSCTrackCollection::const_iterator trk=tracks->begin(); trk<tracks->end(); trk++)
488  {
489  //JAG_START
490  NumCSCTfTracksRep++;
491  long LUTAdd = trk->first.ptLUTAddress();
492  int trigMode = ( (LUTAdd)&0xf0000 ) >> 16;
493  float etaReal = (trk->first.eta_packed() );
494  if( trk->first.endcap() != 1)
495  {
496  float holder = etaReal;
497  etaReal = -1*holder;
498  etaReal -= 1;
499  }
500 
501  float phiReal = ((trk->first.localPhi())*(62.5/24) + (trk->first.sector() - 1)*60)*M_PI/180 ;//+ 15;
502  if( phiReal > (2*M_PI) ) phiReal -= (2*M_PI);
503 
504  csctfoccupancies->Fill( etaReal, phiReal);
505  csctfTrackPhi->Fill(phiReal);
506  csctfTrackEta->Fill( etaReal );
507  //std::cout << "Eta, phi, trigger mode, sector: " << etaReal << ", " << phiReal << ", " << trigMode << ", " << trk->first.sector() << "." << std::endl;
508 
509  csctfTrackQ->Fill( trigMode );
510 
511  if( trigMode == 15 )
512  {
513  //GP_start
515  //GP_end
516 
517  double haloVals[4][4];
518  for( int i = 0; i < 4; i++)
519  {
520  haloVals[i][0] = 0;
521  }
522 
525  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
526  {
527  CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
528  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
529  {
530  int endcap = (*csc).first.endcap()-1;
531  int station = (*csc).first.station()-1;
532  int sector = (*csc).first.triggerSector()-1;
533  int cscId = (*csc).first.triggerCscId()-1;
534  int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
535  int fpga = ( subSector ? subSector-1 : station+1 );
536 
537  if( (station == 1) || (station == 2) )
538  {
539  int modEnd = 1;
540  if( endcap == 0 ) modEnd = -1;
541  //if( endcap == 1 ) modEnd = 1;
542  int indexHalo = modEnd + station;
543  if(haloVals[indexHalo][0] == 1.0) haloVals[indexHalo][3] = 1.0;
544  if(haloVals[indexHalo][0] == 0) haloVals[indexHalo][0] = 1.0;
545  haloVals[indexHalo][1] = sector*1.0;
546 
547  lclphidat lclPhi;
548  lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
549 
550  gblphidat gblPhi;
551  gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
552 
553  gbletadat gblEta;
554  gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
555 
556  haloVals[indexHalo][2] = gblEta.global_eta/127. * 1.5 + 0.9;
557  } //station1 or 2
558  } //lct first to second
559  } //corrlcts
560 
561  if( (haloVals[0][0] == 1.) && (haloVals[1][0] == 1.) && (haloVals[0][3] != 1.) && (haloVals[1][3] != 1.) )
562  {
563  if( haloVals[0][1] == haloVals[1][1] ){
564  double delEta23 = haloVals[1][2] - haloVals[0][2];
565  haloDelEta23->Fill( delEta23 );
566  }
567  }
568 
569  if( (haloVals[2][0] == 1.) && (haloVals[3][0] == 1.) && (haloVals[2][3] != 1.) && (haloVals[3][3] != 1.) )
570  {
571  if( haloVals[2][1] == haloVals[3][1] ){
572  double delEta23 = haloVals[3][2] - haloVals[2][2];
573  haloDelEta23->Fill( delEta23 );
574  }
575  }
576  } //halo trigger
577 
578  int cscTrackStub = 0;
579 
580  CSCCorrelatedLCTDigiCollection lctsOfTracks=trk->second;
581 
582  for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator trackStub=lctsOfTracks.begin(); trackStub!=lctsOfTracks.end(); trackStub++)
583  {
584  CSCCorrelatedLCTDigiCollection::Range range2 = lctsOfTracks.get((*trackStub).first);
585  for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range2.first; lct!=range2.second; lct++)
586  {
587  cscTrackStub++;
588  }
589  }
590 
591  //
592  //edm::Handle<L1CSCTrack> tfInf;
593  //e.getByLabel(trackProducer.label(), tfInf);
594  cscTrackStubNumbers->Fill(cscTrackStub);
595 
596  //JAG_END
597 
598  //GP_start: only coincidence
599  if( trigMode > 0 && trigMode !=15 && trigMode != 11 )
601  //GP_end
602 
603 
604  }
605  }
606  csctfntrack->Fill(NumCSCTfTracksRep);
607  // KK_end ///////////////////////////////////
608 
609  // GP_Start
610  if( mbProducer.label() != "null" ) {
611 
612  // handle to needed collections
614  e.getByLabel(mbProducer.label(), mbProducer.instance(), dtStubs);
615 
618 
619  // loop on the DT stubs
620  std::vector<csctf::TrackStub> vstubs = dtStubs->get();
621  for(std::vector<csctf::TrackStub>::const_iterator stub=vstubs.begin();
622  stub!=vstubs.end(); stub++){
623 
624  if (verbose_) {
625  edm::LogInfo("DataNotFound") << "\n mbEndcap: " << stub->endcap();
626  edm::LogInfo("DataNotFound") << "\n stub->getStrip()[FLAG]: " << stub->getStrip();
627  edm::LogInfo("DataNotFound") << "\n stub->getKeyWG()[CAL]: " << stub->getKeyWG();
628  edm::LogInfo("DataNotFound") << "\n stub->BX(): " << stub->BX();
629  edm::LogInfo("DataNotFound") << "\n stub->sector(): " << stub->sector();
630  edm::LogInfo("DataNotFound") << "\n stub->subsector(): " << stub->subsector();
631  edm::LogInfo("DataNotFound") << "\n stub->station(): " << stub->station();
632  edm::LogInfo("DataNotFound") << "\n stub->phiPacked(): " << stub->phiPacked();
633  edm::LogInfo("DataNotFound") << "\n stub->getBend(): " << stub->getBend();
634  edm::LogInfo("DataNotFound") << "\n stub->getQuality(): " << stub->getQuality();
635  edm::LogInfo("DataNotFound") << "\n stub->cscid(): " << stub->cscid() << endl;
636  }
637 
638  // define the sector ID
639  int mbId = (stub->endcap()==2) ? 6 : 0;
640  mbId += stub->sector();
641 
642 
643  // *** do not fill if CalMB variable is set ***
644  // horrible! They used the same class to write up the LCT and MB info,
645  // but given the MB does not have strip and WG they replaced this two
646  // with the flag and cal bits... :S
647  if (stub->getKeyWG() == 0) {// !CAL as Janos adviced
648 
649  // if FLAG =1, muon belong to previous BX
650  int bxDT = stub->BX()-stub->getStrip(); // correct by the FLAG
651  int subDT = stub->subsector();
652 
653  // Fill the event only if CSC had or would have triggered
654  if (isCSCcand_){
655 
656  // look for tracks in the event and compare the matching DT stubs
657  int trkBX = 0;
658  for(L1CSCTrackCollection::const_iterator trk=tracks->begin();
659  trk<tracks->end(); trk++){
660 
661  trkBX = trk->first.BX();
662 
663  int trkId = (trk->first.endcap()==2) ? 6 : 0;
664  trkId += trk->first.sector();
665 
666  if (verbose_){
667  edm::LogInfo("DataNotFound") << "\n trk BX: " << trkBX
668  << " Sector: " << trkId
669  << " SubSector: " << trk->first.subsector()
670  << " Endcap: " << trk->first.endcap();
671 
672  edm::LogInfo("DataNotFound") << "\n DT BX: " << stub->BX()
673  << " Sector: " << mbId
674  << " SubSector: " << stub->subsector()
675  << " Endcap: " << stub->endcap() << endl;
676  }
677 
678  if (mbId == trkId) {
679  if (verbose_) {
680  edm::LogInfo("DataNotFound") << " --> MATCH" << endl;
681  edm::LogInfo("DataNotFound") << "Fill :" << trkBX+6-bxDT << " -- " << subDT << " -- cands" << endl;
682  }
683  // DT bx ranges from 3 to 9
684  // trk bx ranges from -3 to 3
685  DTstubsTimeTrackMenTimeArrival[mbId-1]->Fill(bxDT-trkBX-6,subDT);//subsec
686  }
687  }// loop on the tracks
688 
689  }//if (isCSCcand_){
690  }//if (stub->getKeyWG() == 0) {
691 
692  }
693  }
694  // GP_end
695 
696 }
MonitorElement * DTstubsTimeTrackMenTimeArrival[12]
Definition: L1TCSCTF.h:99
MonitorElement * csctfoccupancies
Definition: L1TCSCTF.h:82
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
DQMStore * dbe
Definition: L1TCSCTF.h:70
MonitorElement * csctfTrackPhi
Definition: L1TCSCTF.h:89
bool verbose_
Definition: L1TCSCTF.h:110
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:514
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2311
void beginJob(void)
Definition: L1TCSCTF.cc:97
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
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
MonitorElement * csctfbx
Definition: L1TCSCTF.h:78
edm::InputTag mbProducer
Definition: L1TCSCTF.h:113
gbletadat globalEtaME(int phi_bend, int phi_local, int wire_group, int cscid) const
static void setGeometry(const edm::ESHandle< CSCGeometry > &thegeom)
MonitorElement * csctfTrackEta
Definition: L1TCSCTF.h:90
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1TCSCTF.cc:276
std::string outputFile_
Definition: L1TCSCTF.h:109
void Fill(long long x)
edm::InputTag statusProducer
Definition: L1TCSCTF.h:113
MonitorElement * csctfHaloL1ABXN
Definition: L1TCSCTF.h:103
MonitorElement * cscTrackStubNumbers
Definition: L1TCSCTF.h:91
lclphidat localPhi(int strip, int pattern, int quality, int lr) const
Geometry Lookup Tables.
int L1ABXN
Definition: L1TCSCTF.h:105
int BxInEvent_
Definition: L1TCSCTF.h:100
virtual ~L1TCSCTF()
Definition: L1TCSCTF.cc:90
void endJob(void)
Definition: L1TCSCTF.cc:265
int nev_
Definition: L1TCSCTF.h:108
L1TCSCTF(const edm::ParameterSet &ps)
Definition: L1TCSCTF.cc:29
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:828
void setVerbose(unsigned level)
Definition: DQMStore.cc:196
MonitorElement * csctfChamberOccupancies
Definition: L1TCSCTF.h:88
bool isValid() const
Definition: HandleBase.h:76
edm::InputTag lctProducer
Definition: L1TCSCTF.h:113
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
std::vector< L1MuGMTReadoutRecord > getRecords() const
MonitorElement * csctfTrackQ
Definition: L1TCSCTF.h:92
CSCSectorReceiverLUT * srLUTs_[5]
Definition: L1TCSCTF.h:83
MonitorElement * haloDelEta23
Definition: L1TCSCTF.h:87
#define M_PI
Definition: BFit3D.cc:3
MonitorElement * csctferrors
Definition: L1TCSCTF.h:81
MonitorElement * csctfCoincL1ABXN
Definition: L1TCSCTF.h:104
tuple tracks
Definition: testEve_cfg.py:39
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:203
bool isCSCcand_
Definition: L1TCSCTF.h:101
class global_phi_data gblphidat
const T & get() const
Definition: EventSetup.h:55
std::vector< DigiType >::const_iterator const_iterator
class local_phi_data lclphidat
Data Types.
static int triggerSubSectorFromLabels(int station, int chamber)
T const * product() const
Definition: Handle.h:74
edm::InputTag trackProducer
Definition: L1TCSCTF.h:113
MonitorElement * csctfntrack
Definition: L1TCSCTF.h:77
std::string const & label() const
Definition: InputTag.h:25
static unsigned int const shift
std::pair< const_iterator, const_iterator > Range
tuple status
Definition: ntuplemaker.py:245
TH2F * getTH2F(void) const
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:642
class global_eta_data gbletadat
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
std::string const & instance() const
Definition: InputTag.h:26
edm::InputTag gmtProducer
Definition: L1TCSCTF.h:113
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
gblphidat globalPhiME(int phi_local, int wire_group, int cscid) const