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 #include "CondFormats/SiStripObjects/interface/SiStripFedCabling.h"
00045
00046 #include <iostream>
00047 #include <iomanip>
00048 #include <stdio.h>
00049 #include <string>
00050 #include <sstream>
00051 #include <math.h>
00052
00053
00061 SiStripOfflineDQM::SiStripOfflineDQM(edm::ParameterSet const& pSet) : configPar_(pSet) {
00062
00063 edm::LogInfo( "SiStripOfflineDQM") << "SiStripOfflineDQM::Deleting SiStripOfflineDQM ";
00064
00065
00066 actionExecutor_ = new SiStripActionExecutor(pSet);
00067
00068
00069 dqmStore_ = edm::Service<DQMStore>().operator->();
00070
00071 usedWithEDMtoMEConverter_= configPar_.getUntrackedParameter<bool>("UsedWithEDMtoMEConverter",false);
00072 createSummary_ = configPar_.getUntrackedParameter<bool>("CreateSummary",false);
00073 inputFileName_ = configPar_.getUntrackedParameter<std::string>("InputFileName","");
00074 outputFileName_ = configPar_.getUntrackedParameter<std::string>("OutputFileName","");
00075 globalStatusFilling_ = configPar_.getUntrackedParameter<int>("GlobalStatusFilling", 1);
00076 printFaultyModuleList_ = configPar_.getUntrackedParameter<bool>("PrintFaultyModuleList", false);
00077
00078 nEvents_ = 0;
00079 }
00085 SiStripOfflineDQM::~SiStripOfflineDQM() {
00086 edm::LogInfo("SiStripOfflineDQM") << "SiStripOfflineDQM::Deleting SiStripOfflineDQM ";
00087
00088 }
00096 void SiStripOfflineDQM::beginJob() {
00097
00098
00099
00100 if (createSummary_) {
00101 if (!actionExecutor_->readConfiguration()) {
00102 edm::LogInfo ("SiStripOfflineDQM") <<"SiStripOfflineDQM:: Error to read configuration file!! Summary will not be produced!!!";
00103 createSummary_ = false;
00104 }
00105 }
00106 edm::LogInfo("SiStripOfflineDQM") << "SiStripOfflineDQM::beginJob done";
00107 }
00117 void SiStripOfflineDQM::beginRun(edm::Run const& run, edm::EventSetup const& eSetup) {
00118 edm::LogInfo ("SiStripOfflineDQM") <<"SiStripOfflineDQM:: Begining of Run";
00119
00120 int nFEDs = 0;
00121 edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
00122 if( eSetup.find( recordKey ) != 0) {
00123
00124 edm::ESHandle<RunInfo> sumFED;
00125 eSetup.get<RunInfoRcd>().get(sumFED);
00126 if ( sumFED.isValid() ) {
00127
00128 const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
00129 const int siStripFedIdMax = FEDNumbering::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 edm::ESHandle< SiStripFedCabling > fed_cabling;
00186 eSetup.get<SiStripFedCablingRcd>().get(fed_cabling);
00187 if (globalStatusFilling_ > 0) actionExecutor_->createStatus(dqmStore_);
00188
00189 if (!trackerFEDsFound_) {
00190 if (globalStatusFilling_ > 0) actionExecutor_->fillDummyStatus();
00191 return;
00192 }
00193
00194
00195 if (globalStatusFilling_ > 0) actionExecutor_->fillStatus(dqmStore_, det_cabling);
00196
00197 if (!usedWithEDMtoMEConverter_) {
00198
00199
00200 if (createSummary_) actionExecutor_->createSummaryOffline(dqmStore_);
00201
00202
00203 bool create_tkmap = configPar_.getUntrackedParameter<bool>("CreateTkMap",false);
00204 if (create_tkmap) {
00205 std::vector<edm::ParameterSet> tkMapOptions = configPar_.getUntrackedParameter< std::vector<edm::ParameterSet> >("TkMapOptions" );
00206 if (actionExecutor_->readTkMapConfiguration()) {
00207
00208 for(std::vector<edm::ParameterSet>::iterator it = tkMapOptions.begin(); it != tkMapOptions.end(); ++it) {
00209 edm::ParameterSet tkMapPSet = *it;
00210 std::string map_type = it->getUntrackedParameter<std::string>("mapName","");
00211 tkMapPSet.augment(configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
00212 std::cout << tkMapPSet << std::endl;
00213 actionExecutor_->createOfflineTkMap(tkMapPSet, fed_cabling, dqmStore_, map_type);
00214 }
00215 }
00216 }
00217 }
00218 }
00225 void SiStripOfflineDQM::endJob() {
00226
00227 edm::LogInfo( "SiStripOfflineDQM") << "SiStripOfflineDQM::endJob";
00228 if (!usedWithEDMtoMEConverter_) {
00229 if (printFaultyModuleList_) {
00230 std::ostringstream str_val;
00231 actionExecutor_->printFaultyModuleList(dqmStore_, str_val);
00232 std::cout << str_val.str() << std::endl;
00233 }
00234
00235 dqmStore_->cd();
00236 dqmStore_->save(outputFileName_, "","","");
00237 }
00238 }
00245 bool SiStripOfflineDQM::openInputFile() {
00246 if (inputFileName_.size() == 0) return false;
00247 edm::LogInfo("SiStripOfflineDQM") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
00248 dqmStore_->open(inputFileName_, false);
00249 return true;
00250 }
00251
00252 #include "FWCore/Framework/interface/MakerMacros.h"
00253 DEFINE_FWK_MODULE(SiStripOfflineDQM);