CMS 3D CMS Logo

L1TGT.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TGT.cc
00003  *
00004  * $Date: 2008/04/25 14:57:19 $
00005  * $Revision: 1.18 $
00006  * \author J. Berryhill, I. Mikulec
00007  *
00008  */
00009 
00010 #include "DQM/L1TMonitor/interface/L1TGT.h"
00011 
00012 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00013 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00014 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
00015 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00016 
00017 using namespace std;
00018 using namespace edm;
00019 
00020 L1TGT::L1TGT(const ParameterSet& ps)
00021   : gtSource_( ps.getParameter< InputTag >("gtSource") ),
00022     gtEvmSource_( ps.getParameter< InputTag >("gtEvmSource") )
00023 {
00024 
00025   // verbosity switch
00026   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00027 
00028   if(verbose_) cout << "L1TGT: constructor...." << endl;
00029 
00030   dbe = NULL;
00031   if ( ps.getUntrackedParameter<bool>("DQMStore", false) ) 
00032   {
00033     dbe = Service<DQMStore>().operator->();
00034     dbe->setVerbose(0);
00035   }
00036 
00037   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
00038   if ( outputFile_.size() != 0 ) {
00039     cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
00040   }
00041 
00042   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00043   if(disable){
00044     outputFile_="";
00045   }
00046 
00047 
00048   if ( dbe !=NULL ) {
00049     dbe->setCurrentFolder("L1T/L1TGT");
00050   }
00051 
00052 
00053 }
00054 
00055 L1TGT::~L1TGT()
00056 {
00057 }
00058 
00059 void L1TGT::beginJob(const EventSetup& c)
00060 {
00061 
00062   nev_ = 0;
00063 
00064   // get hold of back-end interface
00065   DQMStore* dbe = 0;
00066   dbe = Service<DQMStore>().operator->();
00067 
00068   if ( dbe ) {
00069     dbe->setCurrentFolder("L1T/L1TGT");
00070     dbe->rmdir("L1T/L1TGT");
00071   }
00072 
00073 
00074   if ( dbe ) {
00075     dbe->setCurrentFolder("L1T/L1TGT");
00076     
00077     algo_bits = dbe->book1D("algo_bits", "GT algo bits", 128, -0.5, 127.5 );
00078     algo_bits->setAxisTitle("algorithm bits",1);
00079     algo_bits_corr = dbe->book2D("algo_bits_corr","GT algo bit correlation", 
00080         128, -0.5, 127.5, 128, -0.5, 127.5 );
00081     algo_bits_corr->setAxisTitle("algorithm bits",1);
00082     algo_bits_corr->setAxisTitle("algorithm bits",2);
00083     
00084     tt_bits = dbe->book1D("tt_bits", "GT technical trigger bits", 64, -0.5, 63.5 );
00085     tt_bits->setAxisTitle("technical trigger bits",1);
00086     tt_bits_corr = dbe->book2D("tt_bits_corr","GT tech. trig. bit correlation", 
00087         64, -0.5, 63.5, 64, -0.5, 63.5 );
00088     tt_bits_corr->setAxisTitle("technical trigger bits",1);
00089     tt_bits_corr->setAxisTitle("technical trigger bits",2);
00090 
00091     algo_tt_bits_corr = dbe->book2D("algo_tt_bits_corr","GT algo tech. trig. bit correlation", 
00092         128, -0.5, 127.5, 64, -0.5, 63.5 );
00093     algo_tt_bits_corr->setAxisTitle("algorithm bits",1);
00094     algo_tt_bits_corr->setAxisTitle("technical trigger bits",2);
00095     
00096     algo_bits_lumi = dbe->book2D("algo_bits_lumi", "GT algo bit rate per lumi segment", 
00097         250, 0., 250., 128, -0.5, 127.5);
00098     algo_bits_lumi->setAxisTitle("luminosity segment",1);
00099     algo_bits_lumi->setAxisTitle("algorithm bits",2);
00100     tt_bits_lumi = dbe->book2D("tt_bits_lumi", "GT tech. trig. bit rate per lumi segment", 
00101         250, 0., 250., 64, -0.5, 63.5);
00102     tt_bits_lumi->setAxisTitle("luminosity segment",1);
00103     tt_bits_lumi->setAxisTitle("technical trigger bits",2);
00104     
00105     event_type = dbe->book1D("event_type","GT event type", 10, -0.5, 9.5);
00106     event_type->setAxisTitle("event type",1);
00107     event_type->setBinLabel(2,"Physics",1);
00108     event_type->setBinLabel(3,"Calibration",1);
00109     event_type->setBinLabel(4,"Random",1);
00110     event_type->setBinLabel(6,"Traced",1);
00111     event_type->setBinLabel(7,"Test",1);
00112     event_type->setBinLabel(8,"Error",1);
00113 
00114     event_number = dbe->book1D("event_number", "GT Event number (from last resync)", 100, 0., 50000.);
00115     event_number->setAxisTitle("event number",1);
00116     event_lumi = dbe->bookProfile("event_lumi","GT Event number (from last resync) vs lumi section",
00117         250, 0., 250., 100, -0.1, 1.e15, "s");
00118     event_lumi->setAxisTitle("luminosity segment",1);
00119     event_lumi->setAxisTitle("event number",2);
00120     trigger_number = dbe->book1D("trigger_number", "GT Trigger number (from start run)", 100, 0., 50000.);
00121     trigger_number->setAxisTitle("trigger number",1);
00122     trigger_lumi = dbe->bookProfile("trigger_lumi","GT Trigger number (from start run) vs lumi section",
00123         250, 0., 250., 100, -0.1, 1.e15, "s");
00124     trigger_lumi->setAxisTitle("luminosity segment",1);
00125     trigger_lumi->setAxisTitle("trigger number",2);
00126     
00127     evnum_trignum_lumi = dbe->bookProfile("evnum_trignum_lumi","GT Event/Trigger number ratio vs lumi section",
00128         250, 0., 250., 100, -0.1, 2., "s");
00129     evnum_trignum_lumi->setAxisTitle("luminosity segment",1);
00130     evnum_trignum_lumi->setAxisTitle("event/trigger number ratio",2);
00131     orbit_lumi = dbe->bookProfile("orbit_lumi","GT orbit number vs lumi section",
00132         250, 0., 250., 100, -0.1, 1.e15, "s");
00133     orbit_lumi->setAxisTitle("luminosity segment",1);
00134     orbit_lumi->setAxisTitle("orbit number",2);
00135     setupversion_lumi = dbe->bookProfile("setupversion_lumi","GT setup version vs lumi section",
00136         250, 0., 250., 100, -0.1, 1.e10, "i");
00137     setupversion_lumi->setAxisTitle("luminosity segment",1);
00138     setupversion_lumi->setAxisTitle("prescale stup version",2);
00139     
00140     gtfe_bx = dbe->book1D("gtfe_bx","GTFE Bx number",3600, 0., 3600.);
00141     gtfe_bx->setAxisTitle("GTFE BX number",1);
00142     dbx_module = dbe->bookProfile("dbx_module", "delta Bx of GT modules wrt. GTFE",
00143         20,0.,20.,100,-4000.,4000.,"i");
00144     dbx_module->setAxisTitle("GT crate module",1);
00145     dbx_module->setAxisTitle("Module Bx - GTFE Bx",2);
00146     dbx_module->setBinLabel(1,"GTFEevm",1);
00147     dbx_module->setBinLabel(2,"TCS",1);
00148     dbx_module->setBinLabel(3,"FDL",1);
00149     dbx_module->setBinLabel(4,"FDLloc",1);
00150     dbx_module->setBinLabel(5,"PSB9",1);
00151     dbx_module->setBinLabel(6,"PSB9loc",1);
00152     dbx_module->setBinLabel(7,"PSB13",1);
00153     dbx_module->setBinLabel(8,"PSB13loc",1);
00154     dbx_module->setBinLabel(9,"PSB14",1);
00155     dbx_module->setBinLabel(10,"PSB14loc",1);
00156     dbx_module->setBinLabel(11,"PSB15",1);
00157     dbx_module->setBinLabel(12,"PSB15loc",1);
00158     dbx_module->setBinLabel(13,"PSB19",1);
00159     dbx_module->setBinLabel(14,"PSB19loc",1);
00160     dbx_module->setBinLabel(15,"PSB20",1);
00161     dbx_module->setBinLabel(16,"PSB20loc",1);
00162     dbx_module->setBinLabel(17,"PSB21",1);
00163     dbx_module->setBinLabel(18,"PSB21loc",1);
00164     dbx_module->setBinLabel(19,"GMT",1);
00165   }  
00166 }
00167 
00168 
00169 void L1TGT::endJob(void)
00170 {
00171   if(verbose_) cout << "L1TGT: end job...." << endl;
00172   LogInfo("EndJob") << "analyzed " << nev_ << " events"; 
00173 
00174   if ( outputFile_.size() != 0  && dbe ) dbe->save(outputFile_);
00175 
00176   return;
00177 }
00178 
00179 void L1TGT::analyze(const Event& e, const EventSetup& c)
00180 {
00181   nev_++; 
00182   if(verbose_) cout << "L1TGT: analyze...." << endl;
00183 
00184   // open main GT (DAQ) readout record - exit if failed
00185   Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
00186   e.getByLabel(gtSource_,gtReadoutRecord);
00187      
00188   if (!gtReadoutRecord.isValid()) {
00189     edm::LogInfo("DataNotFound") << "can't find L1GlobalTriggerReadoutRecord with label "
00190                                << gtSource_.label() ;
00191     return;
00192   }
00193   
00194   // initialize bx's to invalid value
00195   int gtfeBx = -1;
00196   int tcsBx = -1;
00197   int gtfeEvmBx = -1;
00198   int fdlBx[2] = { -1, -1};
00199   int psbBx[2][7] = { 
00200       {-1, -1, -1, -1, -1, -1, -1},
00201       {-1, -1, -1, -1, -1, -1, -1}};
00202   int gmtBx = -1;
00203   
00204   // get info from GTFE DAQ record
00205   L1GtfeWord gtfeWord = gtReadoutRecord->gtfeWord();
00206   gtfeBx = gtfeWord.bxNr();
00207   gtfe_bx->Fill(gtfeBx);
00208   setupversion_lumi->Fill(e.luminosityBlock(),gtfeWord.setupVersion());
00209   int gtfeActiveBoards = gtfeWord.activeBoards();
00210   
00211   
00212   // open EVM readout record if available
00213   Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
00214   e.getByLabel(gtEvmSource_,gtEvmReadoutRecord);
00215      
00216   if (!gtEvmReadoutRecord.isValid()) {
00217     edm::LogInfo("DataNotFound") << "can't find L1GlobalTriggerEvmReadoutRecord with label "
00218                    << gtSource_.label() ;
00219   } else {
00220     // get all info from the EVM record if available
00221     
00222     L1GtfeWord gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
00223     gtfeEvmBx = gtfeEvmWord.bxNr();
00224     int gtfeEvmActiveBoards = gtfeEvmWord.activeBoards();
00225     
00226     if( isActive(gtfeEvmActiveBoards,TCS) ) { // if TCS present in the record
00227       
00228       L1TcsWord tcsWord = gtEvmReadoutRecord->tcsWord();
00229       tcsBx = tcsWord.bxNr();
00230 
00231       event_type->Fill(tcsWord.triggerType());
00232       orbit_lumi->Fill(e.luminosityBlock(),tcsWord.orbitNr());
00233 
00234       trigger_number->Fill(tcsWord.partTrigNr());
00235       event_number->Fill(tcsWord.eventNr());
00236       
00237       trigger_lumi->Fill(e.luminosityBlock(),tcsWord.partTrigNr());
00238       event_lumi->Fill(e.luminosityBlock(),tcsWord.eventNr());
00239       evnum_trignum_lumi->Fill(e.luminosityBlock(),double(tcsWord.eventNr())/double(tcsWord.partTrigNr()));
00240     }
00241   }
00242   
00243   // look for GMT readout collection from the same source if GMT active
00244   if( isActive(gtfeActiveBoards,GMT) ) {
00245     edm::Handle<L1MuGMTReadoutCollection> gmtReadoutCollection;
00246     e.getByLabel(gtSource_,gmtReadoutCollection);
00247 
00248     if (gmtReadoutCollection.isValid()) {
00249       gmtBx = gmtReadoutCollection->getRecord().getBxNr();
00250     }
00251   }
00252 
00253   // get info from FDL if active (including decision word)
00254   if( isActive(gtfeActiveBoards,FDL) ) {
00255     L1GtFdlWord fdlWord = gtReadoutRecord->gtFdlWord();
00256     fdlBx[0] = fdlWord.bxNr();
00257     fdlBx[1] = fdlWord.localBxNr();
00258     
00260     DecisionWord gtDecisionWord = gtReadoutRecord->decisionWord();
00261     TechnicalTriggerWord gtTTWord = gtReadoutRecord->technicalTriggerWord();
00262 
00263     int dbitNumber = 0;
00264     DecisionWord::const_iterator GTdbitItr;
00265     algo_bits->Fill(-1.); // fill underflow to normalize
00266     for(GTdbitItr = gtDecisionWord.begin(); GTdbitItr != gtDecisionWord.end(); GTdbitItr++) {
00267       if (*GTdbitItr) {
00268         algo_bits->Fill(dbitNumber);
00269         algo_bits_lumi->Fill(e.luminosityBlock(),dbitNumber);
00270         int dbitNumber1 = 0;
00271         DecisionWord::const_iterator GTdbitItr1;
00272         for(GTdbitItr1 = gtDecisionWord.begin(); GTdbitItr1 != gtDecisionWord.end(); GTdbitItr1++) {
00273           if (*GTdbitItr1) algo_bits_corr->Fill(dbitNumber,dbitNumber1);
00274           dbitNumber1++; 
00275         }
00276         int tbitNumber1 = 0;
00277         TechnicalTriggerWord::const_iterator GTtbitItr1;
00278         for(GTtbitItr1 = gtTTWord.begin(); GTtbitItr1 != gtTTWord.end(); GTtbitItr1++) {
00279           if (*GTtbitItr1) tt_bits_corr->Fill(dbitNumber,tbitNumber1);
00280           tbitNumber1++; 
00281         }
00282       }
00283       dbitNumber++; 
00284     }
00285 
00286     int tbitNumber = 0;
00287     TechnicalTriggerWord::const_iterator GTtbitItr;
00288     tt_bits->Fill(-1.); // fill underflow to normalize
00289     for(GTtbitItr = gtTTWord.begin(); GTtbitItr != gtTTWord.end(); GTtbitItr++) {
00290       if (*GTtbitItr) {
00291         tt_bits->Fill(tbitNumber);
00292         tt_bits_lumi->Fill(e.luminosityBlock(),tbitNumber);
00293         int tbitNumber1 = 0;
00294         TechnicalTriggerWord::const_iterator GTtbitItr1;
00295         for(GTtbitItr1 = gtTTWord.begin(); GTtbitItr1 != gtTTWord.end(); GTtbitItr1++) {
00296           if (*GTtbitItr1) tt_bits_corr->Fill(tbitNumber,tbitNumber1);
00297           tbitNumber1++; 
00298         }
00299       }
00300       tbitNumber++; 
00301     }
00302   }
00303   
00304   // get info from active PSB's
00305   int ibit = PSB9; // first psb
00306   // for now hardcode psb id's - TODO - get them from Vasile's board maps...
00307   int psbID[7] = { 0xbb09, 0xbb0d, 0xbb0e,  0xbb0f,  0xbb13,  0xbb14,  0xbb15 };
00308   for(int i=0; i<7; i++) {
00309     if( isActive(gtfeActiveBoards,ibit) ) {
00310       L1GtPsbWord psbWord = gtReadoutRecord->gtPsbWord(psbID[i]);
00311       psbBx[0][i] = psbWord.bxNr();
00312       psbBx[1][i] = psbWord.localBxNr();
00313     }  
00314     ibit++;
00315   }
00316   
00317   //fill the dbx histo
00318   if(gtfeEvmBx>-1) dbx_module->Fill(0.,gtfeEvmBx-gtfeBx);
00319   if(tcsBx>-1) dbx_module->Fill(1., tcsBx-gtfeBx);
00320   for(int i=0; i<2; i++) {
00321     if(fdlBx[i]>-1) dbx_module->Fill(2.+i, fdlBx[i]-gtfeBx);
00322   }
00323   for(int j=0; j<7; j++) {
00324     for(int i=0; i<2; i++) {
00325       if(psbBx[i][j]>-1) dbx_module->Fill(4.+i+2*j, psbBx[i][j]-gtfeBx);
00326     }
00327   }
00328   if(gmtBx>-1) dbx_module->Fill(18., gmtBx-gtfeBx);
00329 }
00330 
00332 bool L1TGT::isActive(int word, int bit) {
00333   if( word & (1<<bit) ) return true;
00334   return false;
00335 }

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