CMS 3D CMS Logo

L1TCSCTF.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TCSCTF.cc
00003  *
00004  * $Date: 2008/10/20 14:29:08 $
00005  * $Revision: 1.24 $
00006  * \author J. Berryhill
00007  *
00008  */
00009 
00010 #include "DQM/L1TMonitor/interface/L1TCSCTF.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 
00013 // KK_start: 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 // Also remember geometry classes, which are needed to SR LUTs to function
00018 #include "L1Trigger/CSCCommonTrigger/interface/CSCTriggerGeometry.h"
00019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00020 // KK_end
00021 
00022 // JAG start: grab reco info
00023 //#include "DataFormats/TrackReco/interface/Track.h"
00024 //#include "DataFormats/MuonDetId/interface/CSCDetId.h"
00025 //#include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h"
00026 //JAG end
00027 
00028 using namespace std;
00029 using namespace edm;
00030 
00031 L1TCSCTF::L1TCSCTF(const ParameterSet& ps)
00032   // KK_start: if some piece of data is absent - configure corresponding source with 'null:'
00033 //  : csctfSource_( ps.getParameter< InputTag >("csctfSource") )
00034     : gmtProducer( ps.getParameter< InputTag >("gmtProducer") ),
00035       lctProducer( ps.getParameter< InputTag >("lctProducer") ),
00036       trackProducer( ps.getParameter< InputTag >("trackProducer") ),
00037       statusProducer( ps.getParameter< InputTag >("statusProducer") )
00038   // KK_end
00039 {
00040 
00041         // verbosity switch
00042         verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00043 
00044         if(verbose_) cout << "L1TCSCTF: constructor...." << endl;
00045 
00046 
00047         dbe = NULL;
00048         if ( ps.getUntrackedParameter<bool>("DQMStore", false) )
00049         {
00050         dbe = Service<DQMStore>().operator->();
00051         dbe->setVerbose(0);
00052         }
00053 
00054         outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
00055         if ( outputFile_.size() != 0 ) 
00056         {
00057         cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
00058         }
00059 
00060         bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00061         if(disable){
00062         outputFile_="";
00063         }
00064 
00065 
00066         if ( dbe !=NULL ) 
00067         {
00068         dbe->setCurrentFolder("L1T/L1TCSCTF");
00069         }
00070 
00071         // KK_start: instantiate standard on-fly SR LUTs from CSC TF emulator package
00072         bzero(srLUTs_,sizeof(srLUTs_));
00073         int endcap=1, sector=1; // assume SR LUTs are all same for every sector in either of endcaps
00074         bool TMB07=true; // specific TMB firmware
00075         // Create a dumy pset for SR LUTs
00076         edm::ParameterSet srLUTset;
00077         srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
00078         srLUTset.addUntrackedParameter<bool>("Binary",   false);
00079         srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
00080         for(int station=1,fpga=0; station<=4 && fpga<5; station++)
00081         {
00082         if(station==1)
00083                 for(int subSector=0; subSector<2 && fpga<5; subSector++)
00084                         srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, subSector+1, station, srLUTset, TMB07);
00085         else
00086                 srLUTs_[fpga++] = new CSCSectorReceiverLUT(endcap, sector, 0, station, srLUTset, TMB07);
00087         }
00088         // KK_end
00089 }
00090 
00091 L1TCSCTF::~L1TCSCTF()
00092 {
00093 }
00094 
00095 void L1TCSCTF::beginJob(const EventSetup& c)
00096 {
00097 
00098         nev_ = 0;
00099 
00100         // get hold of back-end interface
00101         DQMStore* dbe = 0;
00102         dbe = Service<DQMStore>().operator->();
00103 
00104         if ( dbe ) {
00105         dbe->setCurrentFolder("L1T/L1TCSCTF");
00106         dbe->rmdir("L1T/L1TCSCTF");
00107         }
00108 
00109 
00110         if ( dbe )
00111         {
00112         dbe->setCurrentFolder("L1T/L1TCSCTF");
00113 
00114         //csctfetavalue[1] = dbe->book1D("CSCTF_eta_value","CSCTF eta value", 100, -2.5, 2.5 ) ;
00115         //csctfetavalue[2] = dbe->book1D("CSCTF_eta_value_+1","CSCTF eta value bx +1", 100, -2.5, 2.5 ) ;
00116         //csctfetavalue[0] = dbe->book1D("CSCTF_eta_value_-1","CSCTF eta value bx -1", 100, -2.5, 2.5 ) ;
00117         //csctfphivalue[1] = dbe->book1D("CSCTF_phi_value","CSCTF phi value", 100, 0.0, 6.2832 ) ;
00118         //csctfphivalue[2] = dbe->book1D("CSCTF_phi_value_+1","CSCTF phi value bx +1", 100, 0.0, 6.2832 ) ;
00119         //csctfphivalue[0] = dbe->book1D("CSCTF_phi_value_-1","CSCTF phi value bx -1", 100, 0.0, 6.2832 ) ;
00120         //csctfptvalue[1] = dbe->book1D("CSCTF_pt_value","CSCTF pt value", 160, -0.5, 159.5 ) ;
00121         //csctfptvalue[2] = dbe->book1D("CSCTF_pt_value_+1","CSCTF pt value bx +1", 160, -0.5, 159.5 ) ;
00122         //csctfptvalue[0] = dbe->book1D("CSCTF_pt_value_-1","CSCTF pt value bx -1", 160, -0.5, 159.5 ) ;
00123         //csctfchargevalue[1] = dbe->book1D("CSCTF_charge_value","CSCTF charge value", 3, -1.5, 1.5 ) ;
00124         //csctfchargevalue[2] = dbe->book1D("CSCTF_charge_value_+1","CSCTF charge value bx +1", 3, -1.5, 1.5 ) ;
00125         //csctfchargevalue[0] = dbe->book1D("CSCTF_charge_value_-1","CSCTF charge value bx -1", 3, -1.5, 1.5 ) ;
00126         //csctfquality[1] = dbe->book1D("CSCTF_quality","CSCTF quality", 20, -0.5, 19.5 ) ;
00127         //csctfquality[2] = dbe->book1D("CSCTF_quality_+1","CSCTF quality bx +1", 20, -0.5, 19.5 ) ;
00128         //csctfquality[0] = dbe->book1D("CSCTF_quality_-1","CSCTF quality bx -1", 20, -0.5, 19.5 ) ;
00129         //csctfntrack = dbe->book1D("CSCTF_ntrack","CSCTF ntrack", 20, -0.5, 19.5 ) ;
00130         
00131                 
00132                 // KK_start: declaration of two monitoring histograms
00133                 //  Error counting histogram:
00134                 //  1) checks TF data integrity (error rate - first bin),
00135                 //  2) monitors sychronization on input links (4 errors types: SE/SM/BX/AF; ORed for all time bins, links, and SPs),
00136                 //  3) reports FMM status (if in any SP FMM status != "Ready" - fill the last bin)
00137                 csctferrors = dbe->book1D("CSCTF_errors","CSCTF Errors",6,0,6);
00138                 csctferrors->setAxisTitle("Error type",1);
00139                 csctferrors->setAxisTitle("Number of Errors",2);
00140                 csctferrors->setBinLabel(1,"Corruptions",1);
00141                 csctferrors->setBinLabel(2,"Synch. Err.",1);
00142                 csctferrors->setBinLabel(3,"Synch. Mod.",1);
00143                 csctferrors->setBinLabel(4,"BX mismatch",1);
00144                 csctferrors->setBinLabel(5,"Time misalign.",1);
00145                 csctferrors->setBinLabel(6,"FMM != Ready",1);
00146                 //  Occupancy histogram Eta x Y, where Y:
00147                 //  1) Phi_packed of input LCTs from 1st, 2nd, 3rd, and 4th stations
00148                 //  2) Phi_packed of output tracks
00149                 //  (all 12 SPs - 360 degree coveradge)
00150                 csctfoccupancies = dbe->book2D("CSCTF_occupancies","CSCTF Occupancies",100,0.8,2.5,1229,0,1.2);
00151                 csctfoccupancies->setAxisTitle("#eta",1);
00152                 csctfoccupancies->setAxisTitle("#phi of LCTs x station x endcap & #phi of tracks",2);
00153                 csctfoccupancies->setBinLabel(64,  "ME-1",2);
00154                 csctfoccupancies->setBinLabel(192, "ME+1",2);
00155                 csctfoccupancies->setBinLabel(320, "ME-2",2);
00156                 csctfoccupancies->setBinLabel(448, "ME+2",2);
00157                 csctfoccupancies->setBinLabel(576, "ME-3",2);
00158                 csctfoccupancies->setBinLabel(704, "ME+3",2);
00159                 csctfoccupancies->setBinLabel(832, "ME-4",2);
00160                 csctfoccupancies->setBinLabel(960, "ME+4",2);
00161                 csctfoccupancies->setBinLabel(1088,"Tracks",2);
00162                 // KK_end
00163                 
00164                 //JAG
00165                 haloDelEta23 = dbe->book1D("CSCTF_Halo_Eta23","Delta station 2 to station 3 Eta for Halo Muons", 40, -0.20,0.30);
00166                 
00167                 
00168                 csctfTrackQ = dbe->book1D("CSCTF_Track_Q","CSC Track Quality", 16, -0.5, 15.5);
00169                 csctfTrackQ->setAxisTitle("Track Type", 1);
00170                 csctfTrackQ->setBinLabel(3,"ME1-2-3",1);
00171                 csctfTrackQ->setBinLabel(7,"ME1-2",1);
00172                 csctfTrackQ->setBinLabel(8,"ME1-3",1);
00173                 csctfTrackQ->setBinLabel(9,"ME2-3",1);
00174                 csctfTrackQ->setBinLabel(16,"Halo Trigger",1);
00175                 
00176         csctfChamberOccupancies = dbe->book2D("CSCTF_Chamber_Occupancies","CSCTF Chamber Occupancies", 54, -0.05, 5.35, 10, -5.5, 4.5);
00177                 csctfChamberOccupancies->setAxisTitle("Sector (Endcap), (chambers 1-9 not labeled)",1);
00178         csctfChamberOccupancies->setBinLabel(1,"ME-4",2);
00179                 csctfChamberOccupancies->setBinLabel(2,"ME-3",2);
00180                 csctfChamberOccupancies->setBinLabel(3,"ME-2",2);
00181                 csctfChamberOccupancies->setBinLabel(4,"ME-1b",2);
00182                 csctfChamberOccupancies->setBinLabel(5,"ME-1a",2);
00183                 csctfChamberOccupancies->setBinLabel(6,"ME+1a",2);
00184                 csctfChamberOccupancies->setBinLabel(7,"ME+1b",2);
00185                 csctfChamberOccupancies->setBinLabel(8,"ME+2",2);
00186                 csctfChamberOccupancies->setBinLabel(9,"ME+3",2);
00187                 csctfChamberOccupancies->setBinLabel(10,"ME+4",2);
00188                 csctfChamberOccupancies->setBinLabel(1, "1(+), 7(-)",1);
00189                 csctfChamberOccupancies->setBinLabel(10,"2(+), 8(-)",1);
00190                 csctfChamberOccupancies->setBinLabel(19,"3(+), 9(-)",1);
00191                 csctfChamberOccupancies->setBinLabel(28,"4(+), 10(-)",1);
00192                 csctfChamberOccupancies->setBinLabel(37,"5(+), 11(-)",1);
00193                 csctfChamberOccupancies->setBinLabel(46,"6(+), 12(-)",1);
00194                 
00195                 csctfTrackPhi = dbe->book1D("CSCTF_Track_Phi", "CSCTF Track Phi", 144, 0, 360);
00196                 csctfTrackPhi->setAxisTitle("Track #phi", 1);
00197                 csctfTrackEta = dbe->book1D("CSCTF_Track_Eta", "CSCTF Track Eta", 32, 0.9, 2.5);
00198                 csctfTrackEta->setAxisTitle("Track #eta", 1);
00199                 
00200                 csctfbx = dbe->bookProfile("CSCTF_bx","CSCTF bx", 36, 0.5, 36.5, 15, -5.5,9.5 ) ;
00201                 csctfbx->setAxisTitle("Sector, Endcap, MPC Link", 1);
00202                 csctfbx->setBinLabel(1,"1, +",1);
00203                 csctfbx->setBinLabel(4,"2, +",1);
00204                 csctfbx->setBinLabel(7,"3, +",1);
00205                 csctfbx->setBinLabel(10,"4, +",1);
00206                 csctfbx->setBinLabel(13,"5, +",1);
00207                 csctfbx->setBinLabel(16,"6, +",1);
00208                 csctfbx->setBinLabel(19,"1, -",1);
00209                 csctfbx->setBinLabel(22,"2, -",1);
00210                 csctfbx->setBinLabel(25,"3, -",1);
00211                 csctfbx->setBinLabel(28,"4, -",1);
00212                 csctfbx->setBinLabel(31,"5, -",1);
00213                 csctfbx->setBinLabel(34,"6, -",1);
00214                 
00215                 csctfAFerror = dbe->book2D("CSCTF_AF_Errors", "Alignment Fifo Errors",12, -0.5,11.5, 17, -0.5, 16.5);
00216                 csctfAFerror->setAxisTitle("SP Slot", 1);
00217                 csctfAFerror->setAxisTitle("SP input Fiber",2);
00218                 csctfAFerror->setBinLabel(1,"1",1);
00219                 csctfAFerror->setBinLabel(2,"2",1);
00220                 csctfAFerror->setBinLabel(3,"3",1);
00221                 csctfAFerror->setBinLabel(4,"4",1);
00222                 csctfAFerror->setBinLabel(5,"5",1);
00223                 csctfAFerror->setBinLabel(6,"6",1);
00224                 csctfAFerror->setBinLabel(7,"7",1);
00225                 csctfAFerror->setBinLabel(8,"8",1);
00226                 csctfAFerror->setBinLabel(9,"9",1);
00227                 csctfAFerror->setBinLabel(10,"10",1);
00228                 csctfAFerror->setBinLabel(11,"11",1);
00229                 csctfAFerror->setBinLabel(12,"12",1);
00230                 csctfAFerror->setBinLabel(1,"AF1a",2);
00231                 csctfAFerror->setBinLabel(2,"AF1b",2);
00232                 csctfAFerror->setBinLabel(3,"AF1c",2);
00233                 csctfAFerror->setBinLabel(4,"AF1d",2);
00234                 csctfAFerror->setBinLabel(5,"AF1e",2);
00235                 csctfAFerror->setBinLabel(6,"AF1f",2);
00236                 csctfAFerror->setBinLabel(7,"AF2a",2);
00237                 csctfAFerror->setBinLabel(8,"AF2b",2);
00238                 csctfAFerror->setBinLabel(9,"AF2c",2);
00239                 csctfAFerror->setBinLabel(10,"AF3a",2);
00240                 csctfAFerror->setBinLabel(11,"AF3b",2);
00241                 csctfAFerror->setBinLabel(12,"AF3c",2);
00242                 csctfAFerror->setBinLabel(13,"AF4a",2);
00243                 csctfAFerror->setBinLabel(14,"AF4b",2);
00244                 csctfAFerror->setBinLabel(15,"AF4c",2);
00245                 csctfAFerror->setBinLabel(16,"AFBa",2);
00246                 csctfAFerror->setBinLabel(17,"AFBb",2);
00247                 
00248                 cscTrackStubNumbers = dbe->book1D("CSCTF_TrackStubs", "Number of Stubs in CSC Tracks", 5, 0.5, 5.5);
00249                 
00250                 csctfntrack = dbe->book1D("CSCTF_ntrack","Number of CSCTracks found per event", 5, 0.5, 5.5 ) ;
00251                 //JAG
00252         }
00253 }
00254 
00255 
00256 void L1TCSCTF::endJob(void)
00257 {
00258 
00259         if(verbose_) cout << "L1TCSCTF: end job...." << endl;
00260         LogInfo("EndJob") << "analyzed " << nev_ << " events";
00261 
00262         if ( outputFile_.size() != 0  && dbe ) dbe->save(outputFile_);
00263 
00264         return;
00265 }
00266 
00267 void L1TCSCTF::analyze(const Event& e, const EventSetup& c)
00268 {
00269         int NumCSCTfTracksRep = 0;
00270         nev_++;
00271         if(verbose_) cout << "L1TCSCTF: analyze...." << endl;
00272   edm::Handle<L1MuGMTReadoutCollection> pCollection;
00273 
00274   // KK_start ///////////////////////////////////
00275         
00276   if( gmtProducer.label() != "null" )
00277         { // GMT block
00278         e.getByLabel(gmtProducer,pCollection);
00279         // KK_end   ///////////////////////////////////
00280 
00281                 if (!pCollection.isValid()) 
00282         {
00283         edm::LogInfo("DataNotFound") << "can't find L1MuGMTReadoutCollection with label ";  // << csctfSource_.label() ;
00284         return;
00285         }
00286 
00287         L1MuGMTReadoutCollection const* gmtrc = pCollection.product();
00288         vector<L1MuGMTReadoutRecord> gmt_records = gmtrc->getRecords();
00289         vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
00290 
00291         int ncsctftrack = 0;
00292                 
00293     //csctfntrack->Fill(ncsctftrack);
00294                 
00295     if (verbose_)
00296                 {
00297         cout << "\tCSCTFCand ntrack " << ncsctftrack << endl;
00298                 }
00299   
00300         // KK_start  ///////////////////////////////////
00301   } // end of GMT block
00302         // KK_end    ///////////////////////////////////
00303 
00304 
00305   // KK_start ///////////////////////////////////
00306   if( statusProducer.label() != "null" )
00307         {
00308         edm::Handle<L1CSCStatusDigiCollection> status;
00309     e.getByLabel(statusProducer.label(),statusProducer.instance(),status);
00310     bool integrity=status->first, se=false, sm=false, bx=false, af=false, fmm=false;
00311                 int Slot = 0, AF_val = 0;
00312     for(std::vector<L1CSCSPStatusDigi>::const_iterator stat=status->second.begin(); stat!=status->second.end(); stat++)
00313                 {
00314                 se |= stat->SEs()&0xFFF;
00315                 sm |= stat->SMs()&0xFFF;
00316                 bx |= stat->BXs()&0xFFF;
00317                 af |= stat->AFs()&0xFFF;
00318                 fmm|= stat->FMM()!=8;
00319                                         Slot = stat->slot();
00320                                         AF_val = stat-> AFs();
00321 
00322         }
00323      
00324                 if(integrity) csctferrors->Fill(0.5);
00325     if(se)        csctferrors->Fill(1.5);
00326     if(sm)        csctferrors->Fill(2.5);
00327     if(bx)        csctferrors->Fill(3.5);
00328     if(af)        csctferrors->Fill(4.5);
00329     if(fmm)       csctferrors->Fill(5.5);
00330                 
00331                 if(af) csctfAFerror->Fill(Slot, AF_val);
00332   }
00333 
00334 
00335         if( lctProducer.label() != "null" )
00336         {
00337         edm::ESHandle<CSCGeometry> pDD;
00338         c.get<MuonGeometryRecord>().get( pDD );
00339         CSCTriggerGeometry::setGeometry(pDD);
00340 
00341         edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
00342         e.getByLabel(lctProducer.label(),lctProducer.instance(),corrlcts);
00343 
00344         for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
00345                 {
00346                 CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
00347                 for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
00348                         {
00349                         int endcap  = (*csc).first.endcap()-1;
00350                         int station = (*csc).first.station()-1;
00351                         int sector  = (*csc).first.triggerSector()-1;
00352                         int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
00353                         int cscId   = (*csc).first.triggerCscId()-1;
00354                         int fpga    = ( subSector ? subSector-1 : station+1 );
00355                                 
00356                                 //JAG
00357                                 int endcapAssignment = 1;
00358                                 int shift = 1;
00359                                 float sectorArg = sector;
00360                                 //float sectorArg = j;
00361                                 
00362                                 if( endcap == 1 ){
00363                                         endcapAssignment = -1;
00364                                         shift = 2;
00365                                         //sectorArg = sector - 6;
00366                                 }
00367                                 
00368                                 int signedStation = (station + shift)* endcapAssignment;
00369                                 if( (station == 0) && (endcap == 0)) signedStation = subSector - 1;
00370                                 if( (station == 0) && (endcap == 1)) signedStation = (-1)*subSector;
00371                                 
00372                                 float chamberArg1 = cscId * 0.1 + sectorArg;
00373                                 //float chamberArg1 = i*0.1 + sectorArg;
00374                                 //std::cout << "First" << i << " " << sectorArg << " " << chamberArg1 << std::endl;
00375                                 
00376                                 float chamberArg11 = chamberArg1;
00377                                 if(sectorArg == 1) chamberArg1 = chamberArg11 - 0.1;
00378                                 if(sectorArg == 2) chamberArg1 = chamberArg11 - 0.2;
00379                                 if(sectorArg == 3) chamberArg1 = chamberArg11 - 0.3;
00380                                 if(sectorArg == 4) chamberArg1 = chamberArg11 - 0.4;
00381                                 if(sectorArg == 5) chamberArg1 = chamberArg11 - 0.5;
00382 
00383                                 //std::cout << "cscId, station, sector, endcap, sectorArg, chamber Arg: " << cscId << ", " << station << ", " <<sector << ", " << endcap << ", " << chamberArg1 << ", " << signedStation << std::endl;                  
00384 
00385                                 csctfChamberOccupancies->Fill(chamberArg1, signedStation); 
00386                                 int bunchX = ( (lct->getBX()) - 6 );
00387                                 
00388                                 int timingSectorArg = 3*(sector) + (lct->getMPCLink());
00389                                 if( endcap == 1) timingSectorArg = 3*(sector + 6) + (lct->getMPCLink());
00390                                 //std::cout << "Sector, MPCLink, TSA, endcap: " << sector << ", " << lct->getMPCLink() << ", " << timingSectorArg << ", " << endcap << std::endl;
00391                                 
00392                                 csctfbx->Fill(timingSectorArg, bunchX );
00393                                 
00394                                 //std::cout << "LCT'S, encap: " << endcap << ", station: " << station << ", sector: " << sector << ", subSector: " << subSector << ", cscId: " << cscId << std:: endl;
00395 
00396                                 //End JAG
00397                                 
00398                                 // Check if Det Id is within pysical range:
00399                         if( endcap<0||endcap>1 || sector<0||sector>6 || station<0||station>3 || cscId<0||cscId>8 || fpga<0||fpga>4)
00400                                 {
00401                         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);
00402                         continue;
00403                         }
00404                                 
00405                         lclphidat lclPhi;
00406                         
00407                                 try {
00408                         lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
00409                         } catch(...) { 
00410                                         bzero(&lclPhi,sizeof(lclPhi)); 
00411                                 }
00412                                 
00413                         gblphidat gblPhi;
00414                                 
00415                         try {
00416                         gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00417                         } catch(...) { 
00418                                         bzero(&gblPhi,sizeof(gblPhi)); 
00419                                 }
00420                                 
00421                         gbletadat gblEta;
00422                                 
00423                         try {
00424                         gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00425                         } catch(...) { 
00426                                         bzero(&gblEta,sizeof(gblEta)); 
00427                                 }
00428            
00429                                 // SR LUT gives packed eta and phi values -> normilize them to 1 by scale them to 'max' and shift by 'min'
00430                         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) );
00431                 }//lct != range1.scond
00432         }//csc!=corrlcts.product()->end()
00433         }// lctProducer.label() != "null"
00434 
00435         if( trackProducer.label() != "null" )
00436         {
00437                 
00438         edm::Handle<L1CSCTrackCollection> tracks;
00439         e.getByLabel(trackProducer.label(),trackProducer.instance(),tracks);
00440         for(L1CSCTrackCollection::const_iterator trk=tracks->begin(); trk<tracks->end(); trk++){
00441                 NumCSCTfTracksRep++;
00442                         
00443                         //csctfoccupancies->Fill( trk->first.eta_packed()/32. * 1.5 + 0.9, trk->first.phi_packed()*0.2/32. + 1.);
00444                         csctfoccupancies->Fill( trk->first.eta_packed()*0.0125 + 0.9, trk->first.phi_packed()*(0.2/32) + 1.);
00445                         
00446                         //JAG_START
00447                         edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
00448                 e.getByLabel(lctProducer.label(),lctProducer.instance(),corrlcts);
00449                         
00450                         long LUTAdd = trk->first.ptLUTAddress();
00451                         int trigMode = ( (LUTAdd)&0xf0000 ) >> 16;
00452                         
00453                         csctfTrackQ->Fill( trigMode );
00454                         
00455                         if( trigMode == 15 ){
00456                                 
00457                                 double haloVals[4][4];
00458                                 for( int i = 0; i < 4; i++)
00459                                 {
00460                                         haloVals[i][0] = 0;
00461                                 }
00462                                 
00463                                 edm::Handle<CSCCorrelatedLCTDigiCollection> corrlcts;
00464                         e.getByLabel(lctProducer.label(),lctProducer.instance(),corrlcts);
00465                         for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=corrlcts.product()->begin(); csc!=corrlcts.product()->end(); csc++)
00466                                 {
00467                                 CSCCorrelatedLCTDigiCollection::Range range1 = corrlcts.product()->get((*csc).first);
00468                                 for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++)
00469                                         {
00470                                                 int endcap  = (*csc).first.endcap()-1;
00471                                         int station = (*csc).first.station()-1;
00472                                         int sector  = (*csc).first.triggerSector()-1;
00473                                         int cscId   = (*csc).first.triggerCscId()-1;
00474                                         int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first);
00475                                                 int fpga    = ( subSector ? subSector-1 : station+1 );
00476                                                 
00477                                                 if( (station == 1) || (station == 2) )
00478                                                 {
00479                                                         int modEnd;
00480                                                         if( endcap == 0 ) modEnd = -1;
00481                                                         if( endcap == 1 ) modEnd = 1;
00482                                                         int indexHalo = modEnd + station;
00483                                                         if(haloVals[indexHalo][0] == 1.0) haloVals[indexHalo][3] = 1.0;
00484                                                         if(haloVals[indexHalo][0] == 0) haloVals[indexHalo][0] = 1.0;
00485                                                         haloVals[indexHalo][1] = sector*1.0;
00486                                                 
00487                                                         lclphidat lclPhi;
00488                                                 lclPhi = srLUTs_[fpga]->localPhi(lct->getStrip(), lct->getPattern(), lct->getQuality(), lct->getBend());
00489                                                 
00490                                                 gblphidat gblPhi;
00491                                                         gblPhi = srLUTs_[fpga]->globalPhiME(lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00492                         
00493                                                 gbletadat gblEta;
00494                                                         gblEta = srLUTs_[fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local, lct->getKeyWG(), cscId+1);
00495                                                         
00496                                                         haloVals[indexHalo][2] = gblEta.global_eta/127. * 1.5 + 0.9;
00497                                                 
00498                                                 } //station1 or 2
00499                                         } //lct first to second
00500                                 } //corrlcts
00501                                 
00502                                 if( (haloVals[0][0] == 1.) && (haloVals[1][0] == 1.) && (haloVals[0][3] != 1.) && (haloVals[1][3] != 1.)  ){
00503                                         if( haloVals[0][1] == haloVals[1][1] ){
00504                                                 double delEta23 = haloVals[1][2] - haloVals[0][2];
00505                                                 haloDelEta23->Fill( delEta23 );
00506                                         }
00507                                 }
00508                                 
00509                                 if( (haloVals[2][0] == 1.) && (haloVals[3][0] == 1.) && (haloVals[2][3] != 1.) && (haloVals[3][3] != 1.)  ){
00510                                         if( haloVals[2][1] == haloVals[3][1] ){
00511                                                 double delEta23 = haloVals[3][2] - haloVals[2][2];
00512                                                 haloDelEta23->Fill( delEta23 );
00513                                         }
00514                                 }
00515                                 
00516                         } //halo trigger
00517                         
00518                         csctfTrackPhi->Fill( (trk->first.phi_packed()) *2.5 + (trk->first.sector() - 1 )*61 );
00519                         csctfTrackEta->Fill( ( (trk->first.eta_packed() )*0.0125) + 0.9 );
00520                         
00521                         int cscTrackStub = 0;
00522 
00523                         CSCCorrelatedLCTDigiCollection lctsOfTracks=trk->second;
00524 
00525                 for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator trackStub=lctsOfTracks.begin(); trackStub!=lctsOfTracks.end(); trackStub++)
00526                         {
00527                         CSCCorrelatedLCTDigiCollection::Range range2 = lctsOfTracks.get((*trackStub).first);
00528                         for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range2.first; lct!=range2.second; lct++)
00529                                 {
00530                                         cscTrackStub++;
00531                                 
00532                                 }
00533                         }
00534                         
00535                         //
00536                 //edm::Handle<L1CSCTrack> tfInf;
00537                         //e.getByLabel(trackProducer.label(), tfInf);
00538                         
00539                         cscTrackStubNumbers->Fill(cscTrackStub);
00540                                 
00541                         //JAG_END
00542                 }
00543         }
00544         csctfntrack->Fill(NumCSCTfTracksRep);
00545         // KK_end    ///////////////////////////////////
00546 }

Generated on Tue Jun 9 17:33:10 2009 for CMSSW by  doxygen 1.5.4