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/interface/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
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
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
00086 }
00094 void SiStripOfflineDQM::beginJob() {
00095
00096
00097
00098 if (createSummary_) {
00099 if (!actionExecutor_->readConfiguration()) {
00100 edm::LogInfo ("ReadConfigurationProblem") <<"SiStripOfflineDQM:: Error to read configuration file!! Summary will not be produced!!!";
00101 createSummary_ = false;
00102 }
00103 }
00104 edm::LogInfo("BeginJobDone") << "SiStripOfflineDQM::beginJob done";
00105 }
00115 void SiStripOfflineDQM::beginRun(edm::Run const& run, edm::EventSetup const& eSetup) {
00116 edm::LogInfo ("BeginRun") <<"SiStripOfflineDQM:: Begining of Run";
00117
00118 int nFEDs = 0;
00119 edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
00120 if( eSetup.find( recordKey ) != 0) {
00121
00122 edm::ESHandle<RunInfo> sumFED;
00123 eSetup.get<RunInfoRcd>().get(sumFED);
00124 if ( sumFED.isValid() ) {
00125
00126 const int siStripFedIdMin = FEDNumbering::MINSiStripFEDID;
00127 const int siStripFedIdMax = FEDNumbering::MAXSiStripFEDID;
00128
00129 std::vector<int> FedsInIds= sumFED->m_fed_in;
00130 for(unsigned int it = 0; it < FedsInIds.size(); ++it) {
00131 int fedID = FedsInIds[it];
00132
00133 if(fedID>=siStripFedIdMin && fedID<=siStripFedIdMax) ++nFEDs;
00134 }
00135 }
00136 }
00137 if (nFEDs > 0) trackerFEDsFound_ = true;
00138 else trackerFEDsFound_ = false;
00139 if (!usedWithEDMtoMEConverter_) {
00140 if (!openInputFile()) createSummary_ = false;
00141 }
00142 if (globalStatusFilling_ > 0) actionExecutor_->createStatus(dqmStore_);
00143 }
00155 void SiStripOfflineDQM::analyze(edm::Event const& e, edm::EventSetup const& eSetup){
00156 nEvents_++;
00157 }
00164 void SiStripOfflineDQM::endLuminosityBlock(edm::LuminosityBlock const& lumiSeg, edm::EventSetup const& iSetup) {
00165 edm::LogInfo( "EndLumiBlock") << "SiStripOfflineDQM::endLuminosityBlock";
00166 if (trackerFEDsFound_) {
00167 if (globalStatusFilling_ > 0) actionExecutor_->fillStatusAtLumi(dqmStore_);
00168 }
00169 }
00176 void SiStripOfflineDQM::endRun(edm::Run const& run, edm::EventSetup const& eSetup){
00177
00178 edm::LogInfo( "EndOfRun") << "SiStripOfflineDQM::endRun";
00179
00180
00181 edm::ESHandle< SiStripDetCabling > det_cabling;
00182 eSetup.get<SiStripDetCablingRcd>().get(det_cabling);
00183
00184
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 std::vector<edm::ParameterSet> tkMapOptions = configPar_.getUntrackedParameter< std::vector<edm::ParameterSet> >("TkMapOptions" );
00204 if (actionExecutor_->readTkMapConfiguration(eSetup)) {
00205
00206 for(std::vector<edm::ParameterSet>::iterator it = tkMapOptions.begin(); it != tkMapOptions.end(); ++it) {
00207 edm::ParameterSet tkMapPSet = *it;
00208 std::string map_type = it->getUntrackedParameter<std::string>("mapName","");
00209 tkMapPSet.augment(configPar_.getUntrackedParameter<edm::ParameterSet>("TkmapParameters"));
00210 edm::LogInfo("TkMapParameters") << tkMapPSet;
00211 actionExecutor_->createOfflineTkMap(tkMapPSet, dqmStore_, map_type);
00212 }
00213 }
00214 }
00215 }
00216 }
00223 void SiStripOfflineDQM::endJob() {
00224
00225 edm::LogInfo( "EndOfJob") << "SiStripOfflineDQM::endJob";
00226 if (!usedWithEDMtoMEConverter_) {
00227 if (printFaultyModuleList_) {
00228 std::ostringstream str_val;
00229 actionExecutor_->printFaultyModuleList(dqmStore_, str_val);
00230 std::cout << str_val.str() << std::endl;
00231 }
00232
00233 dqmStore_->cd();
00234 dqmStore_->save(outputFileName_, "","","");
00235 }
00236 }
00243 bool SiStripOfflineDQM::openInputFile() {
00244 if (inputFileName_.size() == 0) return false;
00245 edm::LogInfo("OpenFile") << "SiStripOfflineDQM::openInputFile: Accessing root File" << inputFileName_;
00246 dqmStore_->open(inputFileName_, false);
00247 return true;
00248 }
00249
00250 #include "FWCore/Framework/interface/MakerMacros.h"
00251 DEFINE_FWK_MODULE(SiStripOfflineDQM);