CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/DQM/DTMonitorModule/src/DTDCSByLumiTask.cc

Go to the documentation of this file.
00001 /*
00002  * \file DTDCSByLumiTask.cc
00003  * 
00004  * $Date: 2011/03/02 13:58:32 $
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 
00013 #include <DQM/DTMonitorModule/src/DTDCSByLumiTask.h>
00014 
00015 // Framework
00016 #include <FWCore/Framework/interface/EventSetup.h>
00017 
00018 // Geometry
00019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00020 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00021 #include "Geometry/DTGeometry/interface/DTLayer.h"
00022 #include "Geometry/DTGeometry/interface/DTTopology.h"
00023 
00024 #include "CondFormats/DataRecord/interface/DTHVStatusRcd.h"
00025 #include "CondFormats/DTObjects/interface/DTHVStatus.h"
00026 
00027 #include "DQMServices/Core/interface/DQMStore.h"
00028 #include "DQMServices/Core/interface/MonitorElement.h"
00029 #include "FWCore/ServiceRegistry/interface/Service.h"
00030 #include <FWCore/Framework/interface/EventSetupRecord.h>
00031 #include <FWCore/Framework/interface/EventSetupRecordKey.h>
00032 #include <iostream>
00033 
00034 
00035 using namespace edm;
00036 using namespace std;
00037 
00038 
00039 DTDCSByLumiTask::DTDCSByLumiTask(const edm::ParameterSet& ps) : theEvents(0) , theLumis(0) {
00040 
00041   theDQMStore = Service<DQMStore>().operator->();
00042   LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00043     << "[DTDCSByLumiTask]: Constructor" << endl;
00044 
00045   // If needed put getParameter here
00046   // dtDCSByLumiLabel = ps.getParameter<InputTag>("dtDCSByLumiLabel");
00047 
00048 }
00049 
00050 
00051 DTDCSByLumiTask::~DTDCSByLumiTask(){
00052 
00053   LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00054     << "DTDCSByLumiTask: processed " << theEvents << 
00055     " events in " << theLumis << " lumi sections" << endl;
00056 
00057 }
00058 
00059 
00060 void DTDCSByLumiTask::endJob(){
00061 
00062   LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00063     <<"[DTDCSByLumiTask] endjob called!"<<endl;
00064 
00065 }
00066 
00067 
00068 void DTDCSByLumiTask::beginJob(){
00069 
00070   LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00071     <<"[DTDCSByLumiTask]: BeginJob"<<endl;
00072 
00073 }
00074 
00075 void DTDCSByLumiTask::beginRun(const edm::Run& run, const edm::EventSetup& context) {
00076 
00077   LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00078     << "[DTDCSByLumiTask]: begin run" << endl;
00079 
00080   bookHistos();
00081 
00082   context.get<MuonGeometryRecord>().get(theDTGeom);
00083 
00084   DTHVRecordFound=true;
00085 
00086   eventsetup::EventSetupRecordKey recordKey(eventsetup::EventSetupRecordKey::TypeTag::findType("DTHVStatusRcd"));
00087 
00088   std::vector<eventsetup::EventSetupRecordKey> recordKeys;
00089   context.fillAvailableRecordKeys(recordKeys);
00090   vector<eventsetup::EventSetupRecordKey>::iterator it = find(recordKeys.begin(),recordKeys.end(),recordKey);
00091 
00092   if( it == recordKeys.end() ) {
00093     //record not found
00094     LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")<<"Record DTHVStatusRcd does not exist "<<std::endl;
00095 
00096     DTHVRecordFound=false;
00097   }
00098 
00099 }
00100 
00101 
00102 void DTDCSByLumiTask::beginLuminosityBlock(LuminosityBlock const& lumiSeg, EventSetup const& context) {
00103 
00104   theLumis++;
00105 
00106   LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00107     << "[DTDCSByLumiTask]: Begin of processed lumi # " << lumiSeg.id().luminosityBlock() 
00108     << " " << theLumis << " lumi processed by this job" <<  endl;
00109 
00110   for(int wheel=0; wheel <5; wheel++) {
00111     hActiveUnits[wheel]->Reset(); // Cb by lumi histo need to be resetted in between lumi boundaries
00112   } 
00113 
00114 }
00115 
00116 
00117 void DTDCSByLumiTask::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context) {
00118 
00119 
00120   if(DTHVRecordFound) context.get<DTHVStatusRcd>().get(hvStatus);
00121 
00122   vector<DTLayer*>::const_iterator layersIt  = theDTGeom->layers().begin();
00123   vector<DTLayer*>::const_iterator layersEnd = theDTGeom->layers().end();
00124 
00125   for(; layersIt!=layersEnd; ++layersIt) {
00126 
00127     int wheel = (*layersIt)->id().wheel();
00128 
00129     int nWiresLayer = (*layersIt)->specificTopology().channels();
00130 
00131     hActiveUnits[wheel+2]->Fill(1,nWiresLayer); // CB first bin is # of layers
00132     int nActiveWires = nWiresLayer;
00133 
00134     int flagA = -100;
00135     int flagC = -100;
00136     int flagS = -100;
00137     int first = -100;
00138     int last  = -100;
00139 
00140     // CB info is not stored if HV is ON -> in this case get returns 1
00141     // process all other cases and removed wires with "BAD HV" from active
00142     // wires list
00143 
00144     if( DTHVRecordFound ) {
00145       if ( !hvStatus->get((*layersIt)->id(),0,first,last,flagA,flagC,flagS) 
00146           && (flagA || flagC || flagS) ) {
00147         nActiveWires -= (last - first + 1);
00148       }    
00149 
00150       if ( !hvStatus->get((*layersIt)->id(),1,first,last,flagA,flagC,flagS) 
00151           && (flagA || flagC || flagS) ) {
00152         nActiveWires -= (last - first + 1);
00153       }
00154     } else {
00155       nActiveWires=-1.;
00156     }
00157 
00158     hActiveUnits[wheel+2]->Fill(2,nActiveWires); // CB 2nd bin is the list of wires wit HV ON
00159 
00160   }
00161 
00162   /* LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") 
00163      << "[DTDCSByLumiTask]: processed lumi # : " << lumiSeg.id().luminosityBlock()  
00164      << "\t# of wires " << hActiveUnits->getBinContent(1) 
00165      << "\t# of Active wires (anodes && cathodes && strips ON) : " 
00166      << hActiveUnits->getBinContent(2) << endl; 
00167    */
00168 }
00169 
00170 
00171 void DTDCSByLumiTask::bookHistos() {
00172 
00173   // Book bylumi histo (# of bins as reduced as possible)
00174   theDQMStore->setCurrentFolder(topFolder());
00175 
00176   for(int wheel=-2; wheel <=2; wheel++) {
00177 
00178     stringstream wheel_str; wheel_str << wheel; 
00179 
00180     MonitorElement* ME = theDQMStore->book1D("hActiveUnits"+wheel_str.str(),"Active Untis x LS Wh"+wheel_str.str(),2,0.5,2.5);
00181     ME->setLumiFlag();// Set LumiFlag in order to save histo every LS
00182 
00183     hActiveUnits.push_back(ME);
00184   }
00185 
00186 }
00187 
00188 void DTDCSByLumiTask::analyze(const edm::Event& event, const edm::EventSetup& c) {
00189 
00190   theEvents++;
00191 
00192 }
00193 
00194 
00195 string DTDCSByLumiTask::topFolder() const {
00196 
00197   return string("DT/EventInfo/DCSContents");
00198 
00199 }