CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DQM/DTMonitorClient/src/DTDCSByLumiSummary.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2011/03/02 14:00:29 $
00005  *  $Revision: 1.1 $
00006  *  \author C. Battilana - CIEMAT
00007  *  \author P. Bellan - INFN PD
00008  *  \author A. Branca = INFN PD
00009  */
00010 
00011 
00012 #include "DQM/DTMonitorClient/src/DTDCSByLumiSummary.h"
00013 #include "DQM/DTMonitorModule/interface/DTTimeEvolutionHisto.h"
00014 
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "FWCore/Framework/interface/EventSetup.h"
00019 
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 #include "DQMServices/Core/interface/MonitorElement.h"
00022 
00023 #include<string>
00024 
00025 
00026 using namespace std;
00027 using namespace edm;
00028 
00029 
00030 DTDCSByLumiSummary::DTDCSByLumiSummary(const ParameterSet& pset) {}
00031 
00032 
00033 DTDCSByLumiSummary::~DTDCSByLumiSummary() {}
00034 
00035 
00036 void DTDCSByLumiSummary::beginJob(){
00037 
00038   theDQMStore = Service<DQMStore>().operator->();
00039 
00040   // book the ME
00041   theDQMStore->setCurrentFolder("DT/EventInfo/DCSContents");
00042 
00043   totalDCSFraction = theDQMStore->bookFloat("DTDCSSummary");  
00044   totalDCSFraction->setLumiFlag(); // set LumiFlag to DCS content value (save it by lumi)
00045 
00046   globalHVSummary = theDQMStore->book2D("HVGlbSummary","HV Status Summary",1,1,13,5,-2,3);
00047   globalHVSummary->setAxisTitle("Sectors",1);
00048   globalHVSummary->setAxisTitle("Wheel",2);
00049 
00050   for(int wh=-2;wh<=2;wh++){
00051 
00052     stringstream wheel_str; wheel_str << wh;
00053 
00054     MonitorElement* FractionWh = theDQMStore->bookFloat("DT_Wheel"+wheel_str.str());  
00055     FractionWh->setLumiFlag(); // set LumiFlag to DCS content value (save it by lumi)
00056 
00057     totalDCSFractionWh.push_back(FractionWh);
00058   }
00059 
00060   globalHVSummary->Reset();
00061 
00062 }
00063 
00064 
00065 void DTDCSByLumiSummary::beginLuminosityBlock(const LuminosityBlock& lumi, const  EventSetup& setup) {
00066 
00067   // CB LumiFlag marked products are reset on LS boundaries
00068   totalDCSFraction->Reset(); 
00069 
00070   for(int wh=-2;wh<=2;wh++){
00071     totalDCSFractionWh[wh+2]->Reset();
00072   }
00073 
00074 }
00075 
00076 
00077 void DTDCSByLumiSummary::endLuminosityBlock(const LuminosityBlock&  lumi, const  EventSetup& setup){
00078 
00079   // Get the by lumi product plot from the task
00080   int lumiNumber = lumi.id().luminosityBlock();
00081 
00082   bool null_pointer_histo(0);
00083 
00084   std::vector<float> wh_activeFrac;
00085 
00086   for(int wh=-2;wh<=2;wh++){
00087 
00088     stringstream wheel_str; wheel_str << wh;    
00089 
00090     string hActiveUnitsPath = "DT/EventInfo/DCSContents/hActiveUnits"+wheel_str.str();
00091     MonitorElement *hActiveUnits = theDQMStore->get(hActiveUnitsPath);
00092 
00093     if (hActiveUnits) {
00094       float activeFrac = static_cast<float>(hActiveUnits->getBinContent(2)) /  // CB 2nd bin is # of active channels
00095         hActiveUnits->getBinContent(1);    // first bin is overall number of channels
00096 
00097       if(activeFrac < 0.) activeFrac=-1;
00098 
00099       wh_activeFrac.push_back(activeFrac);
00100 
00101       // Fill by lumi Certification ME
00102       totalDCSFraction->Fill(activeFrac); 
00103       totalDCSFractionWh[wh+2]->Fill(activeFrac);
00104 
00105     } else {
00106       LogTrace("DTDQM|DTMonitorClient|DTDCSByLumiSummary")
00107         << "[DTDCSByLumiSummary]: got null pointer retrieving histo at :" 
00108         << hActiveUnitsPath << " for lumi # " << lumiNumber
00109         << "client operation not performed." << endl;
00110 
00111       null_pointer_histo=true;
00112     }    
00113 
00114   } // end loop on wheels
00115 
00116   if(!null_pointer_histo) dcsFracPerLumi[lumiNumber] = wh_activeFrac; // Fill map to be used to compute trend plots
00117 
00118 }
00119 
00120 
00121 void DTDCSByLumiSummary::endRun(const edm::Run& run, const edm::EventSetup& setup) {
00122 
00123 
00124   // Book trend plots ME & loop on map to fill it with by lumi info
00125   map<int,std::vector<float> >::const_iterator fracPerLumiIt  = dcsFracPerLumi.begin();
00126   map<int,std::vector<float> >::const_iterator fracPerLumiEnd = dcsFracPerLumi.end();
00127 
00128   int fLumi = dcsFracPerLumi.begin()->first;
00129   int lLumi = dcsFracPerLumi.rbegin()->first;
00130   theDQMStore->setCurrentFolder("DT/EventInfo/DCSContents");
00131 
00132   int nLumis = lLumi-fLumi + 1.;
00133 
00134   // trend plots
00135   for(int wh=-2; wh<=2; wh++) {
00136 
00137     stringstream wheel_str; wheel_str << wh;    
00138 
00139     DTTimeEvolutionHisto* trend;
00140 
00141     trend = new DTTimeEvolutionHisto(theDQMStore, "hDCSFracTrendWh" + wheel_str.str(), "Fraction of DT-HV ON Wh" + wheel_str.str(),
00142         nLumis, fLumi, 1, false, 2);
00143 
00144     hDCSFracTrend.push_back(trend);
00145 
00146   }
00147 
00148   float goodLSperWh[5] = {0,0,0,0,0}; 
00149   float badLSperWh[5] = {0,0,0,0,0};
00150 
00151   // fill trend plots and save infos for summaryPlot
00152   for(;fracPerLumiIt!=fracPerLumiEnd;++fracPerLumiIt) {
00153 
00154     for(int wh=-2; wh<=2; wh++) {
00155 
00156       std::vector<float> activeFracPerWh;
00157       activeFracPerWh =  fracPerLumiIt->second;
00158 
00159       hDCSFracTrend[wh+2]->setTimeSlotValue(activeFracPerWh[wh+2],fracPerLumiIt->first);
00160 
00161       if( activeFracPerWh[wh+2] > 0 ) { // we do not count the lumi were the DTs are off (no real problem), 
00162         // even if this can happen in the middle of a run (real problem: to be fixed)
00163         if( activeFracPerWh[wh+2] > 0.9 ) goodLSperWh[wh+2]++;
00164         else { 
00165           badLSperWh[wh+2]++;
00166         }
00167       } else {  // there is no HV value OR all channels OFF
00168         if( activeFracPerWh[wh+2] < 0 ) badLSperWh[wh+2]=-1;       // if there were no HV values, activeFrac returning -1
00169       }
00170 
00171     }
00172 
00173   }
00174 
00175   // fill summaryPlot
00176   for(int wh=-2; wh<=2; wh++) {
00177 
00178     if( goodLSperWh[wh+2] != 0 || badLSperWh[wh+2] == -1 ) {
00179 
00180       float r = badLSperWh[wh+2]/fabs(goodLSperWh[wh+2] + badLSperWh[wh+2]);
00181       if( r > 0.5 ) globalHVSummary->Fill(1,wh,0);
00182       else globalHVSummary->Fill(1,wh,1); 
00183       if( r == -1 ) globalHVSummary->Fill(1,wh,-1);    
00184 
00185     } else {
00186 
00187       globalHVSummary->Fill(1,wh,0);
00188 
00189     }
00190 
00191   }
00192 
00193 }
00194 
00195 
00196 void DTDCSByLumiSummary::endJob() {  
00197 
00198 }
00199 
00200 
00201 void DTDCSByLumiSummary::analyze(const Event& event, const EventSetup& setup){ 
00202 
00203 }
00204