CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQM/L1TMonitor/src/L1TFED.cc

Go to the documentation of this file.
00001 /*
00002  * \file L1TFED.cc
00003  *
00004  * $Date: 2010/04/06 01:14:46 $
00005  * $Revision: 1.15 $
00006  * \author J. Berryhill
00007  *
00008  */
00009 
00010 #include "DQM/L1TMonitor/interface/L1TFED.h"
00011 #include "DQMServices/Core/interface/DQMStore.h"
00012 #include "DQMServices/Core/interface/MonitorElement.h"
00013 #include "DataFormats/FEDRawData/interface/FEDHeader.h"
00014 #include "DataFormats/FEDRawData/interface/FEDTrailer.h"
00015 
00016 using namespace std;
00017 using namespace edm;
00018 
00019 L1TFED::L1TFED(const ParameterSet& ps)
00020 {
00021 
00022   // verbosity switch
00023   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00024   rawl_  = ps.getParameter< InputTag >("rawTag");
00025   if(verbose_) cout << "L1TFED: constructor...." << endl;
00026 
00027 
00028   dbe = NULL;
00029   if ( ps.getUntrackedParameter<bool>("DQMStore", false) ) 
00030   {
00031     dbe = Service<DQMStore>().operator->();
00032     dbe->setVerbose(0);
00033   }
00034 
00035   outputFile_ = ps.getUntrackedParameter<string>("outputFile", "");
00036   if ( outputFile_.size() != 0 ) {
00037     cout << "L1T Monitoring histograms will be saved to " << outputFile_.c_str() << endl;
00038   }
00039 
00040   bool disable = ps.getUntrackedParameter<bool>("disableROOToutput", false);
00041   if(disable){
00042     outputFile_="";
00043   }
00044   
00045   l1feds_ = ps.getParameter<std::vector<int> >("L1FEDS");
00046 
00047   directory_ = ps.getUntrackedParameter<std::string>("FEDDirName","L1T/FEDIntegrity");
00048 
00049 
00050   if ( dbe !=NULL ) {
00051     dbe->setCurrentFolder(directory_);
00052   }
00053 
00054   stableROConfig_ = ps.getUntrackedParameter<bool>("stableROConfig", true);
00055 }
00056 
00057 L1TFED::~L1TFED()
00058 {
00059 }
00060 
00061 void L1TFED::beginJob(void)
00062 {
00063 
00064   nev_ = 0;
00065 
00066   // get hold of back-end interface
00067   DQMStore* dbe = 0;
00068   dbe = Service<DQMStore>().operator->();
00069 
00070   if ( dbe ) {
00071     dbe->setCurrentFolder(directory_);
00072     dbe->rmdir(directory_);
00073   }
00074 
00075 
00076   if ( dbe ) 
00077   {
00078     dbe->setCurrentFolder(directory_);
00079     
00080     fedentries = dbe->book1D("FEDEntries", "Fed ID occupancy", l1feds_.size(), 0.,l1feds_.size() );       
00081     fedfatal = dbe->book1D("FEDFatal", "Fed ID non present ", l1feds_.size(), 0., l1feds_.size());        
00082     fednonfatal = dbe->book1D("FEDNonFatal", "Fed corrupted data ", l1feds_.size(), 0.,l1feds_.size() );
00083     hfedprof = dbe->bookProfile("fedprofile","FED Size by ID", l1feds_.size(), 0., l1feds_.size(),0,0.,5000.);
00084     for(unsigned int i=0;i<l1feds_.size();i++){
00085        ostringstream sfed;
00086        sfed << l1feds_[i];
00087        fedentries->setBinLabel(i+1,"FED "+ sfed.str());
00088        fedfatal->setBinLabel(i+1,"FED "+ sfed.str());
00089        fednonfatal->setBinLabel(i+1,"FED "+ sfed.str());
00090 //       hfedprof->getTProfile()->GetXaxis()->SetBinLabel(i+1,"FED "+ sfed.str());
00091 
00092     }
00093           
00094     hfedsize = dbe->book1D("fedsize","FED Size Distribution",100,0.,10000.);
00095 
00096    }
00097 }
00098 
00099 
00100 void L1TFED::endJob(void)
00101 {
00102  
00103   if(verbose_) std::cout << "L1T FED Integrity: end job...." << std::endl;
00104   LogInfo("EndJob") << "analyzed " << nev_ << " events"; 
00105 
00106  if ( outputFile_.size() != 0  && dbe ) dbe->save(outputFile_);
00107 
00108  return;
00109 }
00110 
00111 void L1TFED::analyze(const Event& e, const EventSetup& c)
00112 {
00113   nev_++; 
00114   if(verbose_) cout << "L1T FED Integrity: analyze...." << endl;
00115 
00116   edm::Handle<FEDRawDataCollection> rawdata;
00117   bool t = e.getByLabel(rawl_,rawdata);
00118   
00119   if ( ! t ) {
00120     if(verbose_) cout << "can't find FEDRawDataCollection "<< endl;
00121   }
00122   
00123   else {
00124 
00125      if(verbose_) cout << "fedlist size = " << l1feds_.size() << endl;
00126 
00127      for (unsigned int i = 0; i<l1feds_.size(); i++){
00128         int fedId = l1feds_[i];
00129         if(verbose_) cout << "fedId = " << fedId << endl;
00130        
00131         const FEDRawData & data = rawdata->FEDData(fedId);
00132         
00133         if(size_t size=data.size()){
00134                
00135             fedentries->Fill(i);
00136             hfedsize->Fill(float(size));
00137             hfedprof->Fill(float(i),float(size));
00138             if(verbose_) cout << "header check = " << FEDHeader(data.data()).check() << endl;
00139             if(verbose_) cout << "trailer check = " << FEDTrailer(data.data()).check() << endl;
00140 
00141             if(!FEDHeader(data.data()).check()) fedfatal->Fill(i);
00142 
00143 //            if(!FEDHeader(data.data()).check() || !FEDTrailer(data.data()).check()) fedfatal->Fill(i);
00144 // fedtrailer check seems to be always 0.
00145 
00146 //          for fedId dedicated integrity checks.
00147 /*          switch(fedId){
00148          
00149                case 813:
00150                std::cout << "do something for GT 813 data corruption..." << std::endl; continue;
00151                fednonfatal->Fill(fedId);
00152             
00153                case 814:
00154                std::cout << "do something for GT 814 data corruption..." << std::endl; continue;
00155                fednonfatal->Fill(fedId);
00156             }
00157 */       
00158         } else {
00159         
00160          if(verbose_) cout << "empty fed " << i << endl;
00161          if(stableROConfig_) fedfatal->Fill(i);
00162         
00163         }
00164    }
00165   
00166  }
00167 
00168 }
00169 
00170