CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/DTMonitorClient/src/DTDataIntegrityTest.cc

Go to the documentation of this file.
00001 
00002 /*
00003  * \file DTDataIntegrityTest.cc
00004  * 
00005  * $Date: 2010/09/07 09:15:14 $
00006  * $Revision: 1.37 $
00007  * \author S. Bolognesi - CERN
00008  *
00009  */
00010 
00011 #include <DQM/DTMonitorClient/src/DTDataIntegrityTest.h>
00012 
00013 //Framework
00014 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00015 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
00016 #include "CondFormats/DataRecord/interface/DTReadOutMappingRcd.h"
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019 #include "FWCore/ServiceRegistry/interface/Service.h"
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021 
00022 #include <iostream>
00023 #include <string>
00024 
00025 
00026 using namespace std;
00027 using namespace edm;
00028 
00029 
00030 DTDataIntegrityTest::DTDataIntegrityTest(const ParameterSet& ps) : nevents(0) {
00031   
00032   LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: Constructor";
00033 
00034   // prescale on the # of LS to update the test
00035   prescaleFactor = ps.getUntrackedParameter<int>("diagnosticPrescale", 1);
00036 
00037 
00038 }
00039 
00040 
00041 DTDataIntegrityTest::~DTDataIntegrityTest(){
00042 
00043   LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "DataIntegrityTest: analyzed " << nupdates << " updates";
00044 
00045 }
00046 
00047 
00048 void DTDataIntegrityTest::beginJob(){
00049 
00050   LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") << "[DTDataIntegrityTest]: BeginJob";
00051 
00052   //nSTAEvents = 0;
00053   nupdates = 0;
00054   run=0;
00055 
00056   dbe = Service<DQMStore>().operator->();
00057   
00058   // book the summary histogram
00059   dbe->setCurrentFolder("DT/00-DataIntegrity");
00060   summaryHisto = dbe->book2D("DataIntegritySummary","Summary Data Integrity",12,1,13,5,-2,3);
00061   summaryHisto->setAxisTitle("Sector",1);
00062   summaryHisto->setAxisTitle("Wheel",2);
00063 
00064   dbe->setCurrentFolder("DT/00-DataIntegrity");
00065   summaryTDCHisto = dbe->book2D("DataIntegrityTDCSummary","TDC Summary Data Integrity",12,1,13,5,-2,3);
00066   summaryTDCHisto->setAxisTitle("Sector",1);
00067   summaryTDCHisto->setAxisTitle("Wheel",2);
00068 
00069   dbe->setCurrentFolder("DT/00-DataIntegrity");
00070   glbSummaryHisto = dbe->book2D("DataIntegrityGlbSummary","Summary Data Integrity",12,1,13,5,-2,3);
00071   glbSummaryHisto->setAxisTitle("Sector",1);
00072   glbSummaryHisto->setAxisTitle("Wheel",2);
00073 
00074 }
00075 
00076 void DTDataIntegrityTest::beginRun(const Run& run, const EventSetup& context){
00077 
00078   context.get<DTReadOutMappingRcd>().get(mapping);
00079 
00080 }
00081 
00082 
00083 
00084 void DTDataIntegrityTest::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00085 
00086   LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest]: Begin of LS transition";
00087 
00088   // Get the run number
00089   run = lumiSeg.run();
00090 
00091 }
00092 
00093 
00094 
00095 void DTDataIntegrityTest::analyze(const Event& e, const EventSetup& context){
00096   // count the analyzed events
00097   nevents++;
00098   if(nevents%1000 == 0)
00099     LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
00100       << "[DTDataIntegrityTest]: "<<nevents<<" events";
00101 }
00102 
00103 
00104 
00105 void DTDataIntegrityTest::endLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00106 
00107   // counts number of lumiSegs 
00108   nLumiSegs = lumiSeg.id().luminosityBlock();
00109   stringstream nLumiSegs_s; nLumiSegs_s << nLumiSegs;
00110   
00111   // prescale factor
00112   if (nLumiSegs%prescaleFactor != 0) return;
00113   
00114   LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
00115     <<"[DTDataIntegrityTest]: End of LS " << nLumiSegs << ", performing client operations";
00116 
00117 
00118   // counts number of updats 
00119   nupdates++;
00120 
00121   
00122   //Counter for x bin in the timing histos
00123   counter++;
00124 
00125   //Loop on FED id
00126   for (int dduId=FEDNumbering::MINDTFEDID; dduId<=FEDNumbering::MAXDTFEDID; ++dduId){
00127     LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest")
00128       <<"[DTDataIntegrityTest]:FED Id: "<<dduId;
00129  
00130     //Each nTimeBin onUpdate remove timing histos and book a new bunch of them
00131     stringstream dduId_s; dduId_s << dduId;
00132     
00133     string histoType;
00134     
00135     //Check if the list of ROS is compatible with the channels enabled
00136     string rosStatusName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "/FED" + dduId_s.str() + "_ROSStatus";
00137     MonitorElement * FED_ROSStatus = dbe->get(rosStatusName);
00138      
00139     // Fill the summary histo   
00140     // Get the error summary histo
00141     string wheelSummaryName = "DT/00-DataIntegrity/FED" + dduId_s.str() + "_ROSSummary";
00142     MonitorElement * FED_ROSSummary = dbe->get(wheelSummaryName);
00143 
00144     // Get the histos for FED integrity
00145     string fedIntegrityFolder = "DT/FEDIntegrity_DT/";
00146     MonitorElement * hFEDEntry = dbe->get(fedIntegrityFolder+"FEDEntries");
00147     MonitorElement * hFEDFatal = dbe->get(fedIntegrityFolder+"FEDFatal");
00148     MonitorElement * hFEDNonFatal = dbe->get(fedIntegrityFolder+"FEDNonFatal");
00149 
00150     if(hFEDEntry && hFEDFatal && hFEDNonFatal) {
00151 
00152       if(FED_ROSSummary && FED_ROSStatus) {
00153         TH2F * histoFEDSummary = FED_ROSSummary->getTH2F();
00154         TH2F * histoROSStatus  = FED_ROSStatus->getTH2F();
00155         // Check that the FED is in the ReadOut using the FEDIntegrity histos
00156         bool fedNotReadout = (hFEDEntry->getBinContent(dduId-769) == 0 &&
00157                               hFEDFatal->getBinContent(dduId-769) == 0 &&
00158                               hFEDNonFatal->getBinContent(dduId-769) == 0); 
00159         for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) { // loop on the ROS
00160           int wheelNumber, sectorNumber;
00161           if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
00162             int result = -2;
00163             float nErrors  = histoFEDSummary->Integral(1,14,rosNumber,rosNumber);
00164             nErrors += histoROSStatus->Integral(2,8,rosNumber,rosNumber);
00165             //nErrors += histoROSStatus->Integral(10,12,rosNumber,rosNumber); Ev Id Mismatch triggers to many minor errors
00166             if(nErrors == 0) { // no errors
00167               result = 0;
00168             } else { // there are errors
00169               result = 2;
00170             }
00171             summaryHisto->setBinContent(sectorNumber,wheelNumber+3,result);
00172             int tdcResult = -2;
00173             float nTDCErrors = histoFEDSummary->Integral(15,15,rosNumber,rosNumber); 
00174             if(nTDCErrors == 0) { // no errors
00175               tdcResult = 0;
00176             } else { // there are errors
00177               tdcResult = 2;
00178             }
00179             summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,tdcResult);
00180             // FIXME: different errors should have different weights
00181             float sectPerc = max((float)0., ((float)nevents-nErrors)/(float)nevents);
00182             glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,sectPerc);
00183            
00184             if(fedNotReadout) {
00185               // no data in this FED: it is off
00186               summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00187               summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00188               glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
00189             }
00190           }
00191         }
00192       
00193       } else { // no data in this FED: it is off
00194         for(int rosNumber = 1; rosNumber <= 12; ++rosNumber) {
00195           int wheelNumber, sectorNumber;
00196           if (!readOutToGeometry(dduId,rosNumber,wheelNumber,sectorNumber)) {
00197             summaryHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00198             summaryTDCHisto->setBinContent(sectorNumber,wheelNumber+3,1);
00199             glbSummaryHisto->setBinContent(sectorNumber,wheelNumber+3,0);
00200           } 
00201         }
00202       }
00203 
00204     }
00205     
00206   }
00207   
00208 }
00209 
00210 
00211 
00212 void DTDataIntegrityTest::endJob(){
00213 
00214   LogTrace ("DTDQM|DTRawToDigi|DTMonitorClient|DTDataIntegrityTest") <<"[DTDataIntegrityTest] endjob called!";
00215 
00216 //   dbe->rmdir("DT/DTDataIntegrity");
00217 }
00218 
00219 
00220 
00221 string DTDataIntegrityTest::getMEName(string histoType, int FEDId){
00222   //Use the DDU name to find the ME
00223   stringstream dduID_s; dduID_s << FEDId;
00224 
00225   string folderName = "DT/00-DataIntegrity/FED" + dduID_s.str(); 
00226 
00227   string histoName = folderName + "/FED" + dduID_s.str() + "_" + histoType;
00228   return histoName;
00229 }
00230 
00231 
00232 
00233 void DTDataIntegrityTest::bookHistos(string histoType, int dduId){
00234   stringstream dduId_s; dduId_s << dduId;
00235   dbe->setCurrentFolder("DT/00-DataIntegrity/FED" + dduId_s.str());
00236   string histoName;
00237 
00238 }
00239 
00240 
00241 int DTDataIntegrityTest::readOutToGeometry(int dduId, int ros, int& wheel, int& sector){
00242 
00243   int dummy;
00244   return mapping->readOutToGeometry(dduId,ros,2,2,2,wheel,dummy,sector,dummy,dummy,dummy);
00245 
00246 }
00247