Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00021
00022
00023 #include "FWCore/Framework/interface/LuminosityBlock.h"
00024 #include "FWCore/ServiceRegistry/interface/Service.h"
00025 #include "FWCore/ParameterSet/interface/FileInPath.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027
00028 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00029
00030 #include "DQMServices/Core/interface/DQMStore.h"
00031
00032 #include "DQM/SiStripCommon/interface/SiStripFolderOrganizer.h"
00033 #include "DQM/SiStripMonitorClient/interface/SiStripActionExecutor.h"
00034
00035 #include "DQM/SiStripMonitorClient/plugins/SiStripOfflineDQM.h"
00036
00037
00038 #include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
00039 #include "CondFormats/RunInfo/interface/RunSummary.h"
00040 #include "CondFormats/RunInfo/interface/RunInfo.h"
00041
00042 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00043 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00044
00045 #include <iostream>
00046 #include <iomanip>
00047 #include <stdio.h>
00048 #include <string>
00049 #include <sstream>
00050 #include <math.h>
00051
00052
00060 SiStripOfflineDQM::SiStripOfflineDQM(edm::ParameterSet const& pSet) : configPar_(pSet) {
00061
00062 edm::LogInfo( "SiStripOfflineDQM") << "SiStripOfflineDQM::Deleting SiStripOfflineDQM ";
00063
00064
00065 actionExecutor_ = new SiStripActionExecutor(pSet);
00066
00067
00068 dqmStore_ = edm::Service<DQMStore>().operator->();
00069
00070 usedWithEDMtoMEConverter_= configPar_.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter",false);
00071 createSummary_ = configPar_.getUntrackedParameter<bool>("CreateSummary",false);
00072 inputFileName_ = configPar_.getUntrackedParameter<std::string>("InputFileName","");
00073 outputFileName_ = configPar_.getUntrackedParameter<std::string>("OutputFileName","");
00074 globalStatusFilling_ = configPar_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
00075 printFaultyModuleList_ = configPar_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);
00076
00077 nEvents_ = 0;
00078 }
00084 SiStripOfflineDQM::~SiStripOfflineDQM() {
00085 edm::LogInfo("SiStripOfflineDQM") << "SiStripOfflineDQM::Deleting SiStripOfflineDQM ";
00086
00087 }
00095 void SiStripOfflineDQM::beginJob() {
00096
00097
00098
00099 if (createSummary_) {
00100 if (!actionExecutor_->readConfiguration()) {
00101 edm::LogInfo ("SiStripOfflineDQM") <<"SiStripOfflineDQM:: Error to read configuration file!! Summary will not be produced!!!";
00102 createSummary_ = false;
00103 }
00104 }
00105 edm::LogInfo("SiStripOfflineDQM") << "SiStripOfflineDQM::beginJob done";
00106 }
00116 void SiStripOfflineDQM::beginRun(edm::Run const& run, edm::EventSetup const& eSetup) {
00117 edm::LogInfo ("SiStripOfflineDQM") <<"SiStripOfflineDQM:: Begining of Run";
00118
00119 int nFEDs = 0;
00120 edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
00121 if( eSetup.find( recordKey ) != 0) {
00122
00123 edm::ESHandle<RunInfo> sumFED;
00124 eSetup.get<RunInfoRcd>().get(sumFED);
00125 if ( sumFED.isValid() ) {
00126
00127 const FEDNumbering numbering;
00128 const int siStripFedIdMin = numbering.MINSiStripFEDID;
00129 const int siStripFedIdMax = numbering.MAXSiStripFEDID;
00130
00131 std::vector<int> FedsInIds= sumFED->m_fed_in;
00132 for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
00133 int fedID = FedsInIds[it];
00134
00135 if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDs;
00136 }
00137 }
00138 }
00139 if (nFEDs > 0) trackerFEDsFound_ = true;
00140 else trackerFEDsFound_ = false;
00141 if (!usedWithEDMtoMEConverter_) {
00142 if (!openInputFile()) createSummary_ = false;
00143 }
00144 if (globalStatusFilling_ > 0) actionExecutor_->createStatus(dqmStore_);
00145 }
00157 void SiStripOfflineDQM::analyze(edm::Event const& e, edm::EventSetup const& eSetup){
00158 nEvents_++;
00159 }
00166 void SiStripOfflineDQM::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {
00167 edm::LogInfo( "SiStripOfflineDQM") << "SiStripOfflineDQM::endLuminosityBlock";
00168 if (trackerFEDsFound_) {
00169 if (globalStatusFilling_ > 0) actionExecutor_->fillStatusAtLumi(dqmStore_);
00170 }
00171 }
00178 void SiStripOfflineDQM::endRun(edm::Run const& run, edm::EventSetup const& eSetup){
00179
00180 edm::LogInfo( "SiStripOfflineDQM") << "SiStripOfflineDQM::endRun";
00181
00182
00183 edm::ESHandle< SiStripDetCabling > det_cabling;
00184 eSetup.get<SiStripDetCablingRcd>().get(det_cabling);
00185 if (globalStatusFilling_ > 0) actionExecutor_->createStatus(dqmStore_);
00186
00187 if (!trackerFEDsFound_) {
00188 if (globalStatusFilling_ > 0) actionExecutor_->fillDummyStatus();
00189 return;
00190 }
00191
00192
00193 if (globalStatusFilling_ > 0) actionExecutor_->fillStatus(dqmStore_, det_cabling);
00194
00195 if (!usedWithEDMtoMEConverter_) {
00196
00197
00198 if (createSummary_) actionExecutor_->createSummaryOffline(dqmStore_);
00199
00200
00201 bool create_tkmap = configPar_.getUntrackedParameter<bool>("CreateTkMap",false);
00202 if (create_tkmap) {
00203 edm::ParameterSet tkMapPSet = configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters");
00204 std::vector<std::string> tkMapOptions = configPar_.getUntrackedParameter< std::vector<std::string> >("TkMapOptions" );
00205 if (actionExecutor_->readTkMapConfiguration()) {
00206
00207 for(std::vector<std::string>::iterator it = tkMapOptions.begin(); it != tkMapOptions.end(); ++it) {
00208 std::string map_type = (*it);
00209 actionExecutor_->createOfflineTkMap(tkMapPSet, dqmStore_, map_type);
00210 }
00211 }
00212 }
00213 }
00214 }
00221 void SiStripOfflineDQM::endJob() {
00222
00223 edm::LogInfo( "SiStripOfflineDQM") << "SiStripOfflineDQM::endJob";
00224 if (!usedWithEDMtoMEConverter_) {
00225 if (printFaultyModuleList_) {
00226 std::ostringstream str_val;
00227 actionExecutor_->printFaultyModuleList(dqmStore_, str_val);
00228 std::cout << str_val.str() << std::endl;
00229 }
00230
00231 dqmStore_->cd();
00232 dqmStore_->save(outputFileName_, "","","");
00233 }
00234 }
00241 bool SiStripOfflineDQM::openInputFile() {
00242 if (inputFileName_.size() == 0) return false;
00243 edm::LogInfo("SiStripOfflineDQM") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
00244 dqmStore_->open(inputFileName_, false);
00245 return true;
00246 }
00247
00248 #include "FWCore/Framework/interface/MakerMacros.h"
00249 DEFINE_FWK_MODULE(SiStripOfflineDQM);