CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DQM/L1TMonitor/src/L1TCSCTF.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TCSCTF.cc
00003  *
00004  * $Date: 2012/04/05 14:57:59 $
00005  * $Revision: 1.40 $
00006  * \author J. Berryhill
00007  *
00008  */
00009 
00010 #include "DQM/L1TMonitor/interface/L1TCSCTF.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 
00013 // includes to fetch all reguired data products from the edm::Event
00014 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
00015 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h"
00016 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCStatusDigiCollection.h"
00017 #include "L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h"
00018 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00019 
00020 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
00021 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"
00022 
00023 
00024 using namespace std;
00025 using namespace edm;
00026 
00027 L1TCSCTF::L1TCSCTF(const ParameterSet& ps)
00028 // if some piece of data is absent - configure corresponding source with 'null:'
00029 //  : csctfSource_( ps.getParameter< InputTag >("csctfSource") )
00030   : gmtProducer( ps.getParameter< InputTag >("gmtProducer") ),
00031     lctProducer( ps.getParameter< InputTag >("lctProducer") ),
00032     trackProducer( ps.getParameter< InputTag >("trackProducer") ),
00033     statusProducer( ps.getParameter< InputTag >("statusProducer") ),
00034     mbProducer( ps.getParameter< InputTag >("mbProducer") )
00035 {
00036 
00037   // verbosity switch
00038   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00039 
00040   if(verbose_) edm::LogInfo("DataNotFound") << "L1TCSCTF: constructor...." << endl;
00041 
00042 
00043   dbe = NULL;
00044   if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
00045     {
00046       dbe = Service<DQMStore>().operator->();
00047       dbe->setVerbose(0);
00048     }
00049 
00050   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
00051   if ( outputFile_.size() != 0 ) 
00052     {
00053       edm::LogInfo("DataNotFound") << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
00054     }
00055 
00056   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00057   if(disable){
00058     outputFile_="";
00059   }
00060 
00061 
00062   if ( dbe !=NULL ) 
00063     {
00064       dbe->setCurrentFolder("L1T/L1TCSCTF");
00065     }
00066 
00067   // instantiate standard on-fly SR LUTs from CSC TF emulator package
00068   bzero(srLUTs_,sizeof(srLUTs_));
00069   int endcap=1, sector=1; // assume SR LUTs are all same for every sector in either of endcaps
00070   bool TMB07=true; // specific TMB firmware
00071   // Create a dummy pset for SR LUTs
00072   edm::ParameterSet srLUTset;
00073   srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
00074   srLUTset.addUntrackedParameter<bool>("Binary",   false);
00075   srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
00076   for(int station=1,fpga=0; station<=4 && fpga<5; station++)
00077     {
00078       if(station==1)
00079         for(int subSector=0; subSector<2 && fpga<5; subSector++)
00080           srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, subSector+1, station, srLUTset, TMB07);
00081       else
00082         srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, 0, station, srLUTset, TMB07);
00083     }
00084 
00085 }
00086 
00087 L1TCSCTF::~L1TCSCTF()
00088 {
00089 
00090   for(int i=0; i<5; i++) 
00091     delete srLUTs_[i]; //free the array of pointers
00092 }
00093 
00094 void L1TCSCTF::beginJob(void)
00095 {
00096   m_scalesCacheID  = -999;
00097   m_ptScaleCacheID = -999;
00098 
00099   nev_ = 0;
00100 
00101   // get hold of back-end interface
00102   DQMStore* dbe = 0;
00103   dbe = Service<DQMStore>().operator->();
00104 
00105   if( dbe )
00106     {
00107       dbe->setCurrentFolder("L1T/L1TCSCTF");
00108       dbe->rmdir("L1T/L1TCSCTF");
00109     }
00110 
00111 
00112   if( dbe )
00113     {
00114       dbe->setCurrentFolder("L1T/L1TCSCTF");
00115                 
00116       //  Error counting histogram:
00117       //  1) checks TF data integrity (error rate - first bin),
00118       //  2) monitors sychronization on input links (4 errors types: SE/SM/BX/AF; ORed for all time bins, links, and SPs),
00119       //  3) reports FMM status (if in any SP FMM status != "Ready" - fill the last bin)
00120       csctferrors = dbe->book1D("CSCTF_errors","CSCTF Errors",6,0,6);   
00121       csctferrors->setAxisTitle("Error type",1);
00122       csctferrors->setAxisTitle("Number of Errors",2);
00123       csctferrors->setBinLabel(1,"Corruptions",1);
00124       csctferrors->setBinLabel(2,"Synch. Err.",1);
00125       csctferrors->setBinLabel(3,"Synch. Mod.",1);
00126       csctferrors->setBinLabel(4,"BX mismatch",1);
00127       csctferrors->setBinLabel(5,"Time misalign.",1);
00128       csctferrors->setBinLabel(6,"FMM != Ready",1);
00129         
00130       //  Occupancy histogram Eta x Y, where Y:
00131       //  1) Phi_packed of input LCTs from 1st, 2nd, 3rd, and 4th stations
00132       //  2) Phi_packed of output tracks
00133       //  (all 12 SPs - 360 degree coveradge)
00134       csctfoccupancies = dbe->book2D("CSCTF_occupancies", "CSCTF Occupancies", 64,-32,31,32,0,6.2);
00135       csctfoccupancies->setAxisTitle("#eta",1);
00136       csctfoccupancies->setAxisTitle("#phi",2);
00137       csctfoccupancies->setBinLabel( 1,"-2.5", 1);
00138       csctfoccupancies->setBinLabel( 8,"-2.1", 1);
00139       csctfoccupancies->setBinLabel(18,"-1.6", 1);
00140       csctfoccupancies->setBinLabel(26,"-1.2", 1);
00141       csctfoccupancies->setBinLabel(32,"-0.9", 1);
00142       csctfoccupancies->setBinLabel(33, "0.9", 1);
00143       csctfoccupancies->setBinLabel(39, "1.2", 1);
00144       csctfoccupancies->setBinLabel(47, "1.6", 1);
00145       csctfoccupancies->setBinLabel(57, "2.1", 1);
00146       csctfoccupancies->setBinLabel(64, "2.5", 1);
00147 
00148       // ... and for halo muons only
00149       csctfoccupancies_H = dbe->book2D("CSCTF_occupancies_H", "CSCTF Halo Occupancies", 64,-32,31,32,0,6.2);
00150       csctfoccupancies_H->setAxisTitle("#eta",1);
00151       csctfoccupancies_H->setAxisTitle("#phi",2);
00152       csctfoccupancies_H->setBinLabel( 1,"-2.5", 1);
00153       csctfoccupancies_H->setBinLabel( 8,"-2.1", 1);
00154       csctfoccupancies_H->setBinLabel(18,"-1.6", 1);
00155       csctfoccupancies_H->setBinLabel(26,"-1.2", 1);
00156       csctfoccupancies_H->setBinLabel(32,"-0.9", 1);
00157       csctfoccupancies_H->setBinLabel(33, "0.9", 1);
00158       csctfoccupancies_H->setBinLabel(39, "1.2", 1);
00159       csctfoccupancies_H->setBinLabel(47, "1.6", 1);
00160       csctfoccupancies_H->setBinLabel(57, "2.1", 1);
00161       csctfoccupancies_H->setBinLabel(64, "2.5", 1);
00162 
00163       //haloDelEta12  = dbe->book1D("CSCTF_Halo_Eta12", "#Delta #eta_{12} for Halo Muons", 40, -0.20,0.30);
00164       //haloDelEta112 = dbe->book1D("CSCTF_Halo_Eta112","#Delta #eta_{112} for Halo Muons", 40, -0.20,0.30);
00165       //haloDelEta13  = dbe->book1D("CSCTF_Halo_Eta13", "#Delta #eta_{13} for Halo Muons", 40, -0.20,0.30);
00166       //haloDelEta113 = dbe->book1D("CSCTF_Halo_Eta113","#Delta #eta_{113} for Halo Muons", 40, -0.20,0.30);
00167         
00168       // Quality VS Mode
00169       trackModeVsQ = dbe->book2D("CSCTF_Track_ModeVsQual","CSC Track Mode Vs Quality", 19, -0.5, 18.5, 4, 0, 4);
00170       trackModeVsQ->setAxisTitle("Track Type", 1);
00171       trackModeVsQ->setBinLabel(1,"No Track",1);
00172       trackModeVsQ->setBinLabel(2,"Bad Phi/Single",1);
00173       trackModeVsQ->setBinLabel(3,"ME1-2-3",1);
00174       trackModeVsQ->setBinLabel(4,"ME1-2-4",1);
00175       trackModeVsQ->setBinLabel(5,"ME1-3-4",1);
00176       trackModeVsQ->setBinLabel(6,"ME2-3-4",1);
00177       trackModeVsQ->setBinLabel(7,"ME1-2",1);
00178       trackModeVsQ->setBinLabel(8,"ME1-3",1);
00179       trackModeVsQ->setBinLabel(9,"ME2-3",1);
00180       trackModeVsQ->setBinLabel(10,"ME2-4",1);
00181       trackModeVsQ->setBinLabel(11,"ME3-4",1);
00182       trackModeVsQ->setBinLabel(12,"MB1-ME3",1);
00183       trackModeVsQ->setBinLabel(13,"MB1-ME2",1);
00184       trackModeVsQ->setBinLabel(14,"ME1-4",1);
00185       trackModeVsQ->setBinLabel(15,"MB1-ME1",1);
00186       trackModeVsQ->setBinLabel(16,"Halo Trigger",1);
00187       trackModeVsQ->setBinLabel(17,"MB1-ME1-2",1);
00188       trackModeVsQ->setBinLabel(18,"MB1-ME1-3",1);
00189       trackModeVsQ->setBinLabel(19,"MB1-ME2-3",1);
00190 
00191       trackModeVsQ->setAxisTitle("Quality",2);
00192       trackModeVsQ->setBinLabel(1,"0",2);
00193       trackModeVsQ->setBinLabel(2,"1",2);
00194       trackModeVsQ->setBinLabel(3,"2",2);
00195       trackModeVsQ->setBinLabel(4,"3",2);
00196 
00197       // Mode
00198       csctfTrackM = dbe->book1D("CSCTF_Track_Mode","CSC Track Mode", 19, -0.5, 18.5);
00199       csctfTrackM->setAxisTitle("Track Type", 1);
00200       csctfTrackM->setBinLabel(1,"No Track",1);
00201       csctfTrackM->setBinLabel(2,"Bad Phi/Single",1);
00202       csctfTrackM->setBinLabel(3,"ME1-2-3",1);
00203       csctfTrackM->setBinLabel(4,"ME1-2-4",1);
00204       csctfTrackM->setBinLabel(5,"ME1-3-4",1);
00205       csctfTrackM->setBinLabel(6,"ME2-3-4",1);
00206       csctfTrackM->setBinLabel(7,"ME1-2",1);
00207       csctfTrackM->setBinLabel(8,"ME1-3",1);
00208       csctfTrackM->setBinLabel(9,"ME2-3",1);
00209       csctfTrackM->setBinLabel(10,"ME2-4",1);
00210       csctfTrackM->setBinLabel(11,"ME3-4",1);
00211       csctfTrackM->setBinLabel(12,"MB1-ME3",1);
00212       csctfTrackM->setBinLabel(13,"MB1-ME2",1);
00213       csctfTrackM->setBinLabel(14,"ME1-4",1);
00214       csctfTrackM->setBinLabel(15,"MB1-ME1",1);
00215       csctfTrackM->setBinLabel(16,"Halo Trigger",1);
00216       csctfTrackM->setBinLabel(17,"MB1-ME1-2",1);
00217       csctfTrackM->setBinLabel(18,"MB1-ME1-3",1);
00218       csctfTrackM->setBinLabel(19,"MB1-ME2-3",1);
00219                 
00220       // Chamber Occupancy
00221       csctfChamberOccupancies = dbe->book2D("CSCTF_Chamber_Occupancies","CSCTF Chamber Occupancies", 54, -0.05, 5.35, 10, -5.5, 4.5);
00222       csctfChamberOccupancies->setAxisTitle("Sector, (chambers 1-9 not labeled)",1);
00223       csctfChamberOccupancies->setBinLabel(1,"ME-4",2);
00224       csctfChamberOccupancies->setBinLabel(2,"ME-3",2);
00225       csctfChamberOccupancies->setBinLabel(3,"ME-2",2);
00226       csctfChamberOccupancies->setBinLabel(4,"ME-1b",2);
00227       csctfChamberOccupancies->setBinLabel(5,"ME-1a",2);
00228       csctfChamberOccupancies->setBinLabel(6,"ME+1a",2);
00229       csctfChamberOccupancies->setBinLabel(7,"ME+1b",2);
00230       csctfChamberOccupancies->setBinLabel(8,"ME+2",2);
00231       csctfChamberOccupancies->setBinLabel(9,"ME+3",2);
00232       csctfChamberOccupancies->setBinLabel(10,"ME+4",2);
00233       csctfChamberOccupancies->setBinLabel(1, "1",1);
00234       csctfChamberOccupancies->setBinLabel(10,"2",1);
00235       csctfChamberOccupancies->setBinLabel(19,"3",1);
00236       csctfChamberOccupancies->setBinLabel(28,"4",1);
00237       csctfChamberOccupancies->setBinLabel(37,"5",1);
00238       csctfChamberOccupancies->setBinLabel(46,"6",1);
00239                 
00240       // Track Phi
00241       csctfTrackPhi = dbe->book1D("CSCTF_Track_Phi", "CSCTF Track #phi",144,0,2*M_PI);
00242       csctfTrackPhi->setAxisTitle("Track #phi", 1);
00243 
00244       // Track Eta
00245       csctfTrackEta = dbe->book1D("CSCTF_Track_Eta", "CSCTF Track #eta",64,-32,32);
00246       csctfTrackEta->setAxisTitle("Track #eta", 1);
00247       csctfTrackEta->setBinLabel( 1,"-2.5", 1);
00248       csctfTrackEta->setBinLabel( 8,"-2.1", 1);
00249       csctfTrackEta->setBinLabel(18,"-1.6", 1);
00250       csctfTrackEta->setBinLabel(26,"-1.2", 1);
00251       csctfTrackEta->setBinLabel(32,"-0.9", 1);
00252       csctfTrackEta->setBinLabel(33, "0.9", 1);
00253       csctfTrackEta->setBinLabel(39, "1.2", 1);
00254       csctfTrackEta->setBinLabel(47, "1.6", 1);
00255       csctfTrackEta->setBinLabel(57, "2.1", 1);
00256       csctfTrackEta->setBinLabel(64, "2.5", 1);
00257 
00258       // Track Eta Low Quality
00259       csctfTrackEtaLowQ = dbe->book1D("CSCTF_Track_Eta_LowQ", "CSCTF Track #eta LQ",64,-32,32);
00260       csctfTrackEtaLowQ->setAxisTitle("Track #eta", 1);
00261       csctfTrackEtaLowQ->setBinLabel( 1,"-2.5", 1);
00262       csctfTrackEtaLowQ->setBinLabel( 8,"-2.1", 1);
00263       csctfTrackEtaLowQ->setBinLabel(18,"-1.6", 1);
00264       csctfTrackEtaLowQ->setBinLabel(26,"-1.2", 1);
00265       csctfTrackEtaLowQ->setBinLabel(32,"-0.9", 1);
00266       csctfTrackEtaLowQ->setBinLabel(33, "0.9", 1);
00267       csctfTrackEtaLowQ->setBinLabel(39, "1.2", 1);
00268       csctfTrackEtaLowQ->setBinLabel(47, "1.6", 1);
00269       csctfTrackEtaLowQ->setBinLabel(57, "2.1", 1);
00270       csctfTrackEtaLowQ->setBinLabel(64, "2.5", 1);
00271 
00272 
00273       // Track Eta High Quality
00274       csctfTrackEtaHighQ = dbe->book1D("CSCTF_Track_Eta_HighQ", "CSCTF Track #eta HQ",64,-32,32);
00275       csctfTrackEtaHighQ->setAxisTitle("Track #eta", 1);
00276       csctfTrackEtaHighQ->setBinLabel( 1,"-2.5", 1);
00277       csctfTrackEtaHighQ->setBinLabel( 8,"-2.1", 1);
00278       csctfTrackEtaHighQ->setBinLabel(18,"-1.6", 1);
00279       csctfTrackEtaHighQ->setBinLabel(26,"-1.2", 1);
00280       csctfTrackEtaHighQ->setBinLabel(32,"-0.9", 1);
00281       csctfTrackEtaHighQ->setBinLabel(33, "0.9", 1);
00282       csctfTrackEtaHighQ->setBinLabel(39, "1.2", 1);
00283       csctfTrackEtaHighQ->setBinLabel(47, "1.6", 1);
00284       csctfTrackEtaHighQ->setBinLabel(57, "2.1", 1);
00285       csctfTrackEtaHighQ->setBinLabel(64, "2.5", 1);
00286 
00287 
00288       // Halo Phi 
00289       csctfTrackPhi_H = dbe->book1D("CSCTF_Track_Phi_H", "CSCTF Halo #phi",144,0,2*M_PI);
00290       csctfTrackPhi_H->setAxisTitle("Track #phi", 1);
00291 
00292       // Halo Eta 
00293       csctfTrackEta_H = dbe->book1D("CSCTF_Track_Eta_H", "CSCTF Halo #eta",64,-32,32);
00294       csctfTrackEta_H->setAxisTitle("Track #eta", 1);
00295       csctfTrackEta_H->setBinLabel( 1,"-2.5", 1);
00296       csctfTrackEta_H->setBinLabel( 8,"-2.1", 1);
00297       csctfTrackEta_H->setBinLabel(18,"-1.6", 1);
00298       csctfTrackEta_H->setBinLabel(26,"-1.2", 1);
00299       csctfTrackEta_H->setBinLabel(32,"-0.9", 1);
00300       csctfTrackEta_H->setBinLabel(33, "0.9", 1);
00301       csctfTrackEta_H->setBinLabel(39, "1.2", 1);
00302       csctfTrackEta_H->setBinLabel(47, "1.6", 1);
00303       csctfTrackEta_H->setBinLabel(57, "2.1", 1);
00304       csctfTrackEta_H->setBinLabel(64, "2.5", 1);
00305                 
00306       // Track Timing
00307       csctfbx = dbe->book2D("CSCTF_bx","CSCTF BX", 12,1,13, 7,-3,3) ;
00308       csctfbx->setAxisTitle("Sector (Endcap)", 1);
00309       csctfbx->setBinLabel( 1," 1 (+)",1);
00310       csctfbx->setBinLabel( 2," 2 (+)",1);
00311       csctfbx->setBinLabel( 3," 3 (+)",1);
00312       csctfbx->setBinLabel( 4," 4 (+)",1);
00313       csctfbx->setBinLabel( 5," 5 (+)",1);
00314       csctfbx->setBinLabel( 6," 6 (+)",1);
00315       csctfbx->setBinLabel( 7," 7 (-)",1);
00316       csctfbx->setBinLabel( 8," 8 (-)",1);
00317       csctfbx->setBinLabel( 9," 9 (-)",1);
00318       csctfbx->setBinLabel(10,"10 (-)",1);
00319       csctfbx->setBinLabel(11,"11 (-)",1);
00320       csctfbx->setBinLabel(12,"12 (-)",1);
00321                 
00322       csctfbx->setAxisTitle("CSCTF BX", 2);
00323       csctfbx->setBinLabel( 1, "-3", 2);
00324       csctfbx->setBinLabel( 2, "-2", 2);
00325       csctfbx->setBinLabel( 3, "-1", 2);
00326       csctfbx->setBinLabel( 4, "-0", 2);
00327       csctfbx->setBinLabel( 5, " 1", 2);
00328       csctfbx->setBinLabel( 6, " 2", 2);
00329       csctfbx->setBinLabel( 7, " 3", 2);
00330 
00331       // Halo Timing
00332       csctfbx_H = dbe->book2D("CSCTF_bx_H","CSCTF HALO BX", 12,1,13, 7,-3,3) ;
00333       csctfbx_H->setAxisTitle("Sector (Endcap)", 1);
00334       csctfbx_H->setBinLabel( 1," 1 (+)",1);
00335       csctfbx_H->setBinLabel( 2," 2 (+)",1);
00336       csctfbx_H->setBinLabel( 3," 3 (+)",1);
00337       csctfbx_H->setBinLabel( 4," 4 (+)",1);
00338       csctfbx_H->setBinLabel( 5," 5 (+)",1);
00339       csctfbx_H->setBinLabel( 6," 6 (+)",1);
00340       csctfbx_H->setBinLabel( 7," 7 (-)",1);
00341       csctfbx_H->setBinLabel( 8," 8 (-)",1);
00342       csctfbx_H->setBinLabel( 9," 9 (-)",1);
00343       csctfbx_H->setBinLabel(10,"10 (-)",1);
00344       csctfbx_H->setBinLabel(11,"11 (-)",1);
00345       csctfbx_H->setBinLabel(12,"12 (-)",1);
00346                 
00347       csctfbx_H->setAxisTitle("CSCTF BX", 2);
00348       csctfbx_H->setBinLabel( 1, "-3", 2);
00349       csctfbx_H->setBinLabel( 2, "-2", 2);
00350       csctfbx_H->setBinLabel( 3, "-1", 2);
00351       csctfbx_H->setBinLabel( 4, "-0", 2);
00352       csctfbx_H->setBinLabel( 5, " 1", 2);
00353       csctfbx_H->setBinLabel( 6, " 2", 2);
00354       csctfbx_H->setBinLabel( 7, " 3", 2);
00355 
00356       // Number of Tracks Stubs
00357       cscTrackStubNumbers = dbe->book1D("CSCTF_TrackStubs", "Number of Stubs in CSCTF Tracks", 5, 0, 5);
00358       cscTrackStubNumbers->setBinLabel( 1, "0", 1);
00359       cscTrackStubNumbers->setBinLabel( 2, "1", 1);
00360       cscTrackStubNumbers->setBinLabel( 3, "2", 1);
00361       cscTrackStubNumbers->setBinLabel( 4, "3", 1);
00362       cscTrackStubNumbers->setBinLabel( 5, "4", 1);
00363 
00364       // Number of Tracks       
00365       csctfntrack = dbe->book1D("CSCTF_ntrack","Number of CSCTracks found per event", 5, 0, 5 ) ;
00366       csctfntrack->setBinLabel( 1, "0", 1);
00367       csctfntrack->setBinLabel( 2, "1", 1);
00368       csctfntrack->setBinLabel( 3, "2", 1);
00369       csctfntrack->setBinLabel( 4, "3", 1);
00370       csctfntrack->setBinLabel( 5, "4", 1);
00371     }
00372  
00373   char hname [200];
00374   char htitle[200];
00375 
00376   for(int i=0; i<12; i++) {
00377     
00378     sprintf(hname ,"DTstubsTimeTrackMenTimeArrival_%d",i+1);
00379     sprintf(htitle,"T_{track} - T_{DT stub} sector %d",i+1);
00380  
00381     DTstubsTimeTrackMenTimeArrival[i] = dbe->book2D(hname,htitle, 7,-3,3, 2,1,3);
00382     DTstubsTimeTrackMenTimeArrival[i]->getTH2F()->SetMinimum(0);
00383     
00384     // axis makeup
00385     DTstubsTimeTrackMenTimeArrival[i]->setAxisTitle("bx_{CSC track} - bx_{DT stub}",1);
00386     DTstubsTimeTrackMenTimeArrival[i]->setAxisTitle("subsector",2);
00387 
00388     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(1,"-3",1);
00389     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(2,"-2",1);
00390     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(3,"-1",1);
00391     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(4, "0",1);
00392     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(5,"+1",1);
00393     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(6,"+2",1);
00394     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(7,"+3",1);
00395 
00396     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(1,"sub1",2);
00397     DTstubsTimeTrackMenTimeArrival[i]->setBinLabel(2,"sub2",2);
00398 
00399   } 
00400 
00401 }
00402 
00403 
00404 void L1TCSCTF::endJob(void)
00405 {
00406 
00407   if(verbose_) edm::LogInfo("DataNotFound") << "L1TCSCTF: end job...." << endl;
00408   LogInfo("EndJob") << "analyzed " << nev_ << " events";
00409 
00410   if ( outputFile_.size() != 0  && dbe ) dbe->save(outputFile_);
00411 
00412   return;
00413 }
00414 
00415 void L1TCSCTF::analyze(const Event& e, const EventSetup& c)
00416 {
00417 
00418   if( c.get< L1MuTriggerScalesRcd > ().cacheIdentifier() != m_scalesCacheID ||
00419       c.get< L1MuTriggerPtScaleRcd >().cacheIdentifier() != m_ptScaleCacheID ){
00420       
00421     ESHandle< L1MuTriggerScales > scales;
00422     c.get< L1MuTriggerScalesRcd >().get(scales);
00423     ts = scales.product();
00424     ESHandle< L1MuTriggerPtScale > ptscales;
00425     c.get< L1MuTriggerPtScaleRcd >().get(ptscales);
00426     tpts = ptscales.product();
00427     m_scalesCacheID  = c.get< L1MuTriggerScalesRcd  >().cacheIdentifier();
00428     m_ptScaleCacheID = c.get< L1MuTriggerPtScaleRcd >().cacheIdentifier();
00429     
00430     edm::LogInfo("L1TCSCTF")  << "Changing triggerscales and triggerptscales...";
00431   }    
00432 
00433   int NumCSCTfTracksRep = 0;
00434   nev_++;
00435   if(verbose_) edm::LogInfo("DataNotFound") << "L1TCSCTF: analyze...." << endl;
00436 
00437   edm::Handle<L1MuGMTReadoutCollection> pCollection;
00438   if( gmtProducer.label() != "null" )
00439     { // GMT block
00440       e.getByLabel(gmtProducer,pCollection);
00441       if (!pCollection.isValid()) 
00442         {
00443           edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label ";  // << csctfSource_.label() ;
00444           return;
00445         }
00446 
00447       L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
00448       vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
00449       vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
00450       
00451       // Look if the readout window contains one (and only one CSC cands)
00452       // to make it simpler I reject events with more than a CSC cand in the
00453       // same readout window 
00454 
00455       // count non-empty candidates in this bx
00456       int bxWindow = 0;
00457       int nCands   = 0;
00458     
00459       for( RRItr = gmt_records.begin(); RRItr != gmt_records.end(); RRItr++ ) {
00460         bxWindow++;
00461 
00462         // get the csc candidates
00463         vector<L1MuRegionalCand> INPCands = RRItr->getCSCCands();
00464         vector<L1MuRegionalCand>::const_iterator INPItr;
00465 
00466         BxInEvent_ = 0;
00467         isCSCcand_ = false;
00468         int  nCandsBx  = 0;
00469         
00470         for( INPItr = INPCands.begin(); INPItr != INPCands.end(); ++INPItr ) {
00471           if(!INPItr->empty()) 
00472             {
00473               nCandsBx++;
00474               nCands++;
00475               BxInEvent_ = RRItr->getBxInEvent();
00476               if (verbose_) edm::LogInfo("DataNotFound") << "cand " << nCandsBx << " -> assigned CSCTF bx: " << INPItr->bx() << endl;
00477             }
00478         }
00479         if (verbose_)
00480           if(nCandsBx) edm::LogInfo("DataNotFound") << nCandsBx << " cands in bx: " << BxInEvent_ << endl;
00481       }
00482 
00483       if (nCands != 1) return;
00484       else isCSCcand_ = true;
00485       if (verbose_) edm::LogInfo("DataNotFound") << "bxWindow: " << bxWindow << endl;
00486       
00487       int ncsctftrack = 0;
00488       if (verbose_)
00489         {
00490           edm::LogInfo("DataNotFound") << "\tCSCTFCand ntrack " << ncsctftrack << endl;
00491         }
00492     } // end of GMT block
00493 
00494   L1ABXN = -999;
00495   if( statusProducer.label() != "null" )
00496     {
00497       edm::Handle<L1CSCStatusDigiCollection> status;
00498       e.getByLabel(statusProducer.label(),statusProducer.instance(),status);
00499       bool integrity=status->first, se=false, sm=false, bx=false, af=false, fmm=false;
00500       int nStat = 0;
00501  
00502       for(std::vector<L1CSCSPStatusDigi>::const_iterator stat=status->second.begin(); stat!=status->second.end(); stat++)
00503         {
00504           se |= stat->SEs()&0xFFF;
00505           sm |= stat->SMs()&0xFFF;
00506           bx |= stat->BXs()&0xFFF;
00507           af |= stat->AFs()&0xFFF;
00508           fmm|= stat->FMM()!=8;
00509 
00510           if(stat->VPs() != 0) 
00511             {
00512               L1ABXN += stat->BXN();
00513               nStat++;
00514             }
00515         }
00516       // compute the average
00517       if(nStat!=0) L1ABXN /= nStat;
00518       if(integrity) csctferrors->Fill(0.5);
00519       if(se)        csctferrors->Fill(1.5);
00520       if(sm)        csctferrors->Fill(2.5);
00521       if(bx)        csctferrors->Fill(3.5);
00522       if(af)        csctferrors->Fill(4.5);
00523       if(fmm)       csctferrors->Fill(5.5);
00524     }
00525 
00526   if( lctProducer.label() != "null" )
00527     {
00528       edm::ESHandle<CSCGeometry> pDD;
00529       c.get<MuonGeometryRecord>().get( pDD );
00530       CSCTriggerGeometry::setGeometry(pDD);
00531 
00532       edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
00533       e.getByLabel(lctProducer.label(),lctProducer.instance(),corrlcts);
00534 
00535       for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
00536         {
00537           CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
00538           for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
00539             {
00540               int endcap  = (*csc).first.endcap()-1;
00541               int station = (*csc).first.station()-1;
00542               int sector  = (*csc).first.triggerSector()-1;
00543               int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
00544               int cscId   = (*csc).first.triggerCscId()-1;
00545               int fpga    = ( subSector ? subSector-1 : station+1 );
00546 
00547               int endcapAssignment = 1;
00548               int shift = 1;
00549               float sectorArg = sector;
00550               //float sectorArg = j;
00551                                 
00552               if( endcap == 1 ){
00553                 endcapAssignment = -1;
00554                 shift = 2;
00555                 //sectorArg = sector - 6;
00556               }
00557                                 
00558               int signedStation = (station + shift)* endcapAssignment;
00559               if( (station == 0) && (endcap == 0)) signedStation = subSector - 1;
00560               if( (station == 0) && (endcap == 1)) signedStation = (-1)*subSector;
00561                                 
00562               float chamberArg1 = cscId * 0.1 + sectorArg;
00563               //float chamberArg1 = i*0.1 + sectorArg;
00564               //std::cout << "First" << i << " " << sectorArg << " " << chamberArg1 << std::endl;
00565                                 
00566               float chamberArg11 = chamberArg1;
00567               if(sectorArg == 1) chamberArg1 = chamberArg11 - 0.1;
00568               if(sectorArg == 2) chamberArg1 = chamberArg11 - 0.2;
00569               if(sectorArg == 3) chamberArg1 = chamberArg11 - 0.3;
00570               if(sectorArg == 4) chamberArg1 = chamberArg11 - 0.4;
00571               if(sectorArg == 5) chamberArg1 = chamberArg11 - 0.5;
00572 
00573               //std::cout << "cscId, station, sector, endcap, sectorArg, chamber Arg: " << cscId << ", " << station << ", " <<sector << ", " << endcap << ", " << chamberArg1 << ", " << signedStation << std::endl;                    
00574 
00575               csctfChamberOccupancies->Fill(chamberArg1, signedStation); 
00576               //int bunchX = ( (lct->getBX()) - 6 );
00577                                 
00578               //int timingSectorArg = 3*(sector) + (lct->getMPCLink());
00579               //if( endcap == 1) timingSectorArg = 3*(sector + 6) + (lct->getMPCLink());
00580               //std::cout << "Sector, MPCLink, TSA, endcap: " << sector << ", " << lct->getMPCLink() << ", " << timingSectorArg << ", " << endcap << std::endl;
00581                                 
00582               //csctfbx->Fill(timingSectorArg, bunchX );
00583               //std::cout << "LCT'S, encap: " << endcap << ", station: " << station << ", sector: " << sector << ", subSector: " << subSector << ", cscId: " << cscId << std:: endl;
00584               //End JAG
00585                                 
00586               // Check if Det Id is within pysical range:
00587               if( endcap<0||endcap>1 || sector<0||sector>6 || station<0||station>3 || cscId<0||cscId>8 || fpga<0||fpga>4)
00588                 {
00589                   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);
00590                   continue;
00591                 }
00592               lclphidat lclPhi;                 
00593               try {
00594                 lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
00595               } catch(...) { 
00596                 bzero(&lclPhi,sizeof(lclPhi)); 
00597               }
00598                                 
00599               gblphidat gblPhi;
00600               try {
00601                 gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00602               } catch(...) { 
00603                 bzero(&gblPhi,sizeof(gblPhi)); 
00604               }
00605                                 
00606               gbletadat gblEta;
00607               try {
00608                 gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00609               } catch(...) { 
00610                 bzero(&gblEta,sizeof(gblEta)); 
00611               }
00612            
00613               // SR LUT gives packed eta and phi values -> normilize them to 1 by scale them to 'max' and shift by 'min'
00614               //float etaP = gblEta.global_eta/127*1.5 + 0.9;
00615               //float phiP =  (gblPhi.global_phi);// + ( sector )*4096 + station*4096*12) * 1./(4*4096*12);
00616               //std::cout << "LCT Eta & Phi Coordinates: " << etaP << ", " << phiP << "." << std::endl;
00617               //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) );
00618             }//lct != range1.scond
00619         }//csc!=corrlcts.product()->end()
00620     }// lctProducer.label() != "null"
00621 
00622 
00623 
00624   if( trackProducer.label() != "null" )
00625     {
00626       edm::Handle<L1CSCTrackCollection> tracks;
00627       e.getByLabel(trackProducer.label(),trackProducer.instance(),tracks);
00628       for(L1CSCTrackCollection::const_iterator trk=tracks->begin(); trk<tracks->end(); trk++)
00629         {
00630 
00631           NumCSCTfTracksRep++;
00632           long LUTAdd = trk->first.ptLUTAddress();
00633           int trigMode = ( (LUTAdd)&0xf0000 ) >> 16;
00634           int trEta = (trk->first.eta_packed() );
00635 
00636           
00637           // trk->first.endcap() = 2 for - endcap
00638           //                     = 1 for + endcap
00639           //int trEndcap = (trk->first.endcap()==2 ? trk->first.endcap()-3 : trk->first.endcap());
00640           if( trk->first.endcap() != 1) 
00641             {
00642               int holder = trEta;
00643               trEta = -1*holder;
00644               trEta -= 1;
00645             }
00646                                 
00647           int trSector = 6*(trk->first.endcap()-1)+trk->first.sector();
00648           int trBX     = trk->first.BX();
00649 
00650           //Here is what is done with output phi value:
00651           //output_phi = (phi / 32) * 3 /16
00652           //where:
00653           //phi is 12-bit phi, 4096 bins covering 62 degrees
00654           //output_phi is 5-bit value
00655 
00656           //Easy to see that output_phi can have values from 0 to 23, or 24 total combinations.
00657           //This gives per-bin phi value of 62/24 = 2.583333 degrees.
00658 
00659           // Sector 1 nominally starts at 15 degrees but there 1 degree overlap between sectors so 14 degrees effectively 
00660           //double trPhi = trk->first.localPhi() * 62. / 24.;
00661           double trPhi     = ts->getPhiScale()->getLowEdge(trk->first.localPhi());
00662           double trPhi02PI = fmod(trPhi + 
00663                                   ((trSector-1)*M_PI/3) + 
00664                                   (M_PI*14/180.), 2*M_PI);
00665       
00666           if (trigMode == 15) {
00667             csctfTrackPhi_H    -> Fill( trPhi02PI );
00668             csctfTrackEta_H    -> Fill( trEta );
00669             csctfoccupancies_H -> Fill( trEta, trPhi02PI );
00670             csctfbx_H          -> Fill( trSector, trBX );
00671           }
00672           else{
00673             csctfTrackPhi    -> Fill( trPhi02PI );
00674             csctfTrackEta    -> Fill( trEta );
00675             csctfoccupancies -> Fill( trEta, trPhi02PI );
00676             csctfbx          -> Fill( trSector, trBX );
00677 
00678             // Low Quality / High Quality Eta Distributions
00679             //|eta| < 2.1
00680             if (abs(trEta) < 24) {
00681               if (trigMode ==  2 || 
00682                   trigMode ==  3 || 
00683                   trigMode ==  4 || 
00684                   trigMode ==  5 || 
00685                   trigMode ==  6 || 
00686                   trigMode ==  7 || 
00687                   trigMode == 11 || 
00688                   trigMode == 12 || 
00689                   trigMode == 13 || 
00690                   trigMode == 14  )  csctfTrackEtaHighQ -> Fill (trEta);
00691               
00692               if (trigMode ==  8 || 
00693                   trigMode ==  9 || 
00694                   trigMode == 10  )  csctfTrackEtaLowQ  -> Fill (trEta);
00695             }
00696             else {//|eta| > 2.1
00697               if (trigMode ==  2 || 
00698                   trigMode ==  3 || 
00699                   trigMode ==  4 || 
00700                   trigMode ==  5  )  csctfTrackEtaHighQ -> Fill (trEta);
00701               else
00702                                      csctfTrackEtaLowQ  -> Fill (trEta);
00703             }
00704           }
00705           
00706           csctfTrackM->Fill( trk->first.modeExtended() );
00707           
00708           // we monitor the track quality only on the first link
00709           // so let's make sure to fill the plot if there is something that 
00710           // is read from the hardware
00711           int trRank   = trk->first.rank();    
00712           if (trRank) {
00713             int trQuality = ((trRank>>5)&0x3);
00714             trackModeVsQ->Fill( trk->first.modeExtended(), trQuality );
00715           }
00716 
00717           /* 
00718              OLD METHOD FOR FILLING HALO PLOTS, IMPROVED METHOD USING ASSOCIATED TRACK STUBS
00719              BELOW ~LINE 605
00720              if( trigMode == 15 )
00721              {
00722 
00723              double haloVals[4][4];
00724              for( int i = 0; i < 4; i++)
00725              {
00726              haloVals[i][0] = 0;
00727              }
00728                                 
00729              edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
00730              e.getByLabel(lctProducer.label(),lctProducer.instance(),corrlcts);
00731              for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
00732              {
00733              CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
00734              for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
00735              {
00736              int endcap  = (*csc).first.endcap()-1;
00737              int station = (*csc).first.station()-1;
00738              int sector  = (*csc).first.triggerSector()-1;
00739              int cscId   = (*csc).first.triggerCscId()-1;
00740              int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
00741              int fpga    = ( subSector ? subSector-1 : station+1 );
00742                                                 
00743              if(station != 4)
00744              {
00745              int modEnd = 1;
00746              if( endcap == 0 ) modEnd = -1;
00747              int indexHalo = modEnd + station;
00748              if(haloVals[indexHalo][0] == 1.0) haloVals[indexHalo][3] = 1.0;
00749              if(haloVals[indexHalo][0] == 0) haloVals[indexHalo][0] = 1.0;
00750              haloVals[indexHalo][1] = sector*1.0;
00751                                                 
00752              lclphidat lclPhi;
00753              lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
00754              gblphidat gblPhi;
00755              gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00756              gbletadat gblEta;
00757              gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00758                                                         
00759              haloVals[indexHalo][2] = gblEta.global_eta/127. * 1.5 + 0.9;
00760              } //station1 or 2
00761              } //lct first to second
00762              } //corrlcts
00763 
00764              if( (haloVals[0][0] == 1.) && (haloVals[1][0] == 1.) && (haloVals[0][3] != 1.) && (haloVals[1][3] != 1.)  )
00765              {
00766              if( haloVals[0][1] == haloVals[1][1] ){
00767              double delEta23 = haloVals[1][2] - haloVals[0][2];
00768              haloDelEta23->Fill( delEta23 );
00769              }
00770              }
00771                                 
00772              if( (haloVals[2][0] == 1.) && (haloVals[3][0] == 1.) && (haloVals[2][3] != 1.) && (haloVals[3][3] != 1.)  )
00773              {
00774              if( haloVals[2][1] == haloVals[3][1] ){
00775              double delEta23 = haloVals[3][2] - haloVals[2][2];
00776              haloDelEta23->Fill( delEta23 );
00777              }
00778              }  
00779              } //halo trigger
00780           */
00781                         
00782           int cscTrackStub = 0;
00783           //float haloEta[3];
00784           //for(int i=0; i<3; i++) haloEta[i]=-1.0;
00785           //bool haloME11 = false;
00786           CSCCorrelatedLCTDigiCollection lctsOfTracks=trk->second;
00787           for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator trackStub=lctsOfTracks.begin(); trackStub!=lctsOfTracks.end(); trackStub++)
00788             {
00789               CSCCorrelatedLCTDigiCollection::Range range2 = lctsOfTracks.get((*trackStub).first);
00790               for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range2.first; lct!=range2.second; lct++)
00791                 {
00792 //                   int station = (*trackStub).first.station()-1;
00793 //                   if(station != 4)
00794 //                     {
00795 //                       // int endcap  = (*trackStub).first.endcap()-1;
00796 //                       // int sector  = (*trackStub).first.triggerSector()-1;
00797 //                       int cscId   = (*trackStub).first.triggerCscId()-1;
00798 //                       int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*trackStub).first);
00799 //                       int fpga    = ( subSector ? subSector-1 : station+1 );
00800                                                 
00801 //                       lclphidat lclPhi;
00802 //                       lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
00803 //                       gblphidat gblPhi;
00804 //                       gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00805 //                       gbletadat gblEta;
00806 //                       gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00807 //                       haloEta[station-1] = gblEta.global_eta/127. * 1.5 + 0.9;
00808 //                       if(station==1 && cscId<2) haloME11 = true;
00809 //                    }
00810                   cscTrackStub++;                       
00811                 }
00812             }
00813           cscTrackStubNumbers->Fill(cscTrackStub);
00814           
00815 //           if(trigMode == 15)
00816 //             {
00817 //               float dEta13 = haloEta[2]-haloEta[0];
00818 //               float dEta12 = haloEta[1]-haloEta[0];
00819 //               if(haloME11)
00820 //                 {
00821 //                   if(haloEta[1]!=-1.0) haloDelEta112->Fill(dEta12);
00822 //                   if(haloEta[2]!=-1.0) haloDelEta113->Fill(dEta13);
00823 //                 } else {
00824 //                 if(haloEta[1]!=-1.0) haloDelEta12->Fill(dEta12);
00825 //                 if(haloEta[2]!=-1.0) haloDelEta13->Fill(dEta13);
00826 //               }
00827 //             }
00828           //
00829 
00830 
00831                                 
00832         }
00833     }
00834   csctfntrack->Fill(NumCSCTfTracksRep);
00835 
00836 
00837   if( mbProducer.label() != "null" ) 
00838     {
00839       // handle to needed collections
00840       edm::Handle<CSCTriggerContainer<csctf::TrackStub> > dtStubs;
00841       e.getByLabel(mbProducer.label(),  mbProducer.instance(),  dtStubs);
00842       edm::Handle<L1CSCTrackCollection> tracks;
00843       e.getByLabel(trackProducer.label(),trackProducer.instance(),tracks);
00844                   
00845       // loop on the DT stubs
00846       std::vector<csctf::TrackStub> vstubs = dtStubs->get();
00847       for(std::vector<csctf::TrackStub>::const_iterator stub=vstubs.begin(); 
00848           stub!=vstubs.end(); stub++)
00849         {
00850           if (verbose_) 
00851             {
00852               edm::LogInfo("DataNotFound") << "\n mbEndcap: "               << stub->endcap();
00853               edm::LogInfo("DataNotFound") << "\n stub->getStrip()[FLAG]: " << stub->getStrip(); 
00854               edm::LogInfo("DataNotFound") << "\n stub->getKeyWG()[CAL]: "  << stub->getKeyWG(); 
00855               edm::LogInfo("DataNotFound") << "\n stub->BX(): "             << stub->BX();
00856               edm::LogInfo("DataNotFound") << "\n stub->sector(): "         << stub->sector();
00857               edm::LogInfo("DataNotFound") << "\n stub->subsector(): "      << stub->subsector();
00858               edm::LogInfo("DataNotFound") << "\n stub->station(): "        << stub->station();
00859               edm::LogInfo("DataNotFound") << "\n stub->phiPacked(): "      << stub->phiPacked();
00860               edm::LogInfo("DataNotFound") << "\n stub->getBend(): "        << stub->getBend();
00861               edm::LogInfo("DataNotFound") << "\n stub->getQuality(): "     << stub->getQuality();
00862               edm::LogInfo("DataNotFound") << "\n stub->cscid(): "          << stub->cscid() << endl;      
00863             }       
00864           // define the sector ID
00865           int mbId = (stub->endcap()==2) ? 6 : 0;
00866           mbId += stub->sector();
00867           // *** do not fill if CalMB variable is set ***
00868           // horrible! They used the same class to write up the LCT and MB info,
00869           // but given the MB does not have strip and WG they replaced this two
00870           // with the flag and cal bits... :S
00871           if (stub->getKeyWG() == 0) 
00872             {
00873               // if FLAG =1, muon belong to previous BX
00874               int bxDT     = stub->BX()-stub->getStrip(); // correct by the FLAG
00875               int subDT    = stub->subsector();
00876           
00877               // Fill the event only if CSC had or would have triggered
00878               if (isCSCcand_)
00879                 {
00880                   //look for tracks in the event and compare the matching DT stubs 
00881                   int trkBX = 0;
00882                   for(L1CSCTrackCollection::const_iterator trk=tracks->begin(); trk<tracks->end(); trk++)
00883                     {
00884                       trkBX = trk->first.BX();
00885                       int trkId = (trk->first.endcap()==2) ? 6 : 0;
00886                       trkId += trk->first.sector();
00887                       if (verbose_){ 
00888                         edm::LogInfo("DataNotFound") << "\n trk BX: "  << trkBX
00889                                                      << " Sector: "    << trkId
00890                                                      << " SubSector: " << trk->first.subsector()
00891                                                      << " Endcap: "    << trk->first.endcap();
00892 
00893                         edm::LogInfo("DataNotFound") << "\n DT  BX: "    << stub->BX()
00894                                                      << " Sector: "      << mbId
00895                                                      << " SubSector: "   << stub->subsector()
00896                                                      << " Endcap: "      << stub->endcap() << endl;
00897                       }
00898 
00899                       if (mbId == trkId) 
00900                         {
00901                           if (verbose_) {
00902                             edm::LogInfo("DataNotFound") << " --> MATCH" << endl;
00903                             edm::LogInfo("DataNotFound") << "Fill :" << trkBX+6-bxDT << " -- " << subDT << " -- cands" << endl;
00904                           }
00905                           // DT bx ranges from 3 to 9
00906                           // trk bx ranges from -3 to 3
00907                           DTstubsTimeTrackMenTimeArrival[mbId-1]->Fill(bxDT-trkBX-6,subDT);//subsec
00908                         }
00909                     }// loop on the tracks
00910                 }//if (isCSCcand_){
00911             }//if (stub->getKeyWG() == 0) {
00912         }
00913     }
00914 }