Go to the documentation of this file.00001 #include <iostream>
00002
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "FWCore/Framework/interface/MakerMacros.h"
00006 #include "FWCore/Framework/interface/Frameworkfwd.h"
00007
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010
00011 #include <DataFormats/EcalDetId/interface/ESDetId.h>
00012
00013 #include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
00014 #include "CondFormats/RunInfo/interface/RunSummary.h"
00015 #include "CondFormats/RunInfo/interface/RunInfo.h"
00016
00017 #include "DQMServices/Core/interface/MonitorElement.h"
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019
00020 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00021
00022 #include "Geometry/EcalMapping/interface/ESElectronicsMapper.h"
00023
00024 #include "DQM/EcalPreshowerMonitorModule/interface/ESDaqInfoTask.h"
00025
00026 using namespace cms;
00027 using namespace edm;
00028 using namespace std;
00029
00030 ESDaqInfoTask::ESDaqInfoTask(const ParameterSet& ps) {
00031
00032 dqmStore_ = Service<DQMStore>().operator->();
00033
00034 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00035
00036 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00037
00038 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00039
00040 ESFedRangeMin_ = ps.getUntrackedParameter<int>("ESFedRangeMin", 520);
00041 ESFedRangeMax_ = ps.getUntrackedParameter<int>("ESFedRangeMax", 575);
00042
00043 meESDaqFraction_ = 0;
00044 meESDaqActiveMap_ = 0;
00045 meESDaqError_ = 0;
00046
00047 for (int i = 0; i < 56; i++) {
00048 meESDaqActive_[i] = 0;
00049 }
00050
00051 if (ps.exists("esMapping")){
00052 edm::ParameterSet esMap=ps.getParameter<edm::ParameterSet>("esMapping");
00053 es_mapping_ = new ESElectronicsMapper(esMap);
00054 }else{
00055 edm::LogError("ESDaqInfoTask")<<"preshower mapping pointer not initialized. Temporary.";
00056 es_mapping_=0;
00057 }
00058
00059
00060
00061 }
00062
00063 ESDaqInfoTask::~ESDaqInfoTask() {
00064 delete es_mapping_;
00065 }
00066
00067 void ESDaqInfoTask::beginJob(void) {
00068
00069 char histo[200];
00070
00071 if ( dqmStore_ ) {
00072
00073 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
00074
00075 sprintf(histo, "DAQSummary");
00076 meESDaqFraction_ = dqmStore_->bookFloat(histo);
00077 meESDaqFraction_->Fill(0.0);
00078
00079 sprintf(histo, "DAQSummaryMap");
00080 meESDaqActiveMap_ = dqmStore_->book2D(histo,histo, 80, 0.5, 80.5, 80, 0.5, 80.5);
00081 meESDaqActiveMap_->setAxisTitle("Si X", 1);
00082 meESDaqActiveMap_->setAxisTitle("Si Y", 2);
00083
00084 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
00085
00086 for (int i = 0; i < 56; i++) {
00087 sprintf(histo, "EcalPreshower_%d", ESFedRangeMin_+i);
00088 meESDaqActive_[i] = dqmStore_->bookFloat(histo);
00089 meESDaqActive_[i]->Fill(0.0);
00090
00091 ESOnFed_[i] = false;
00092 for ( int x = 0; x < 80; x++ ) {
00093 for ( int y = 0; y < 80; y++ ) {
00094 if(getFEDNumber(x, y) == ESFedRangeMin_+i){
00095 ESOnFed_[i] = true;
00096 break;
00097 }
00098 }
00099 if(ESOnFed_[i] == true) break;
00100 }
00101 }
00102
00103 dqmStore_->setCurrentFolder(prefixME_ + "/ESIntegrityTask");
00104 sprintf(histo, "DAQError");
00105 meESDaqError_ = dqmStore_->book1D(histo, histo, 56, ESFedRangeMin_-0.5, ESFedRangeMax_+0.5);
00106 meESDaqError_->setAxisTitle("FedID", 1);
00107
00108 }
00109
00110 }
00111
00112 void ESDaqInfoTask::endJob(void) {
00113
00114 if ( enableCleanup_ ) this->cleanup();
00115
00116 }
00117
00118 void ESDaqInfoTask::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup){
00119
00120 this->reset();
00121
00122 for (int x = 0; x < 80; ++x) {
00123 for (int y = 0; y < 80; ++y) {
00124 if( getFEDNumber(x, y) > 0 ) meESDaqActiveMap_->setBinContent( x+1, y+1, 0.0 );
00125 else meESDaqActiveMap_->setBinContent( x+1, y+1, -1.0 );
00126 }
00127 }
00128
00129 for (int i = 0; i < 56; i++) {
00130 if ( meESDaqError_ ) meESDaqError_->setBinContent(i, 0.0);
00131 }
00132
00133 edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
00134
00135 if( iSetup.find( recordKey ) ) {
00136
00137 edm::ESHandle<RunInfo> sumFED;
00138 iSetup.get<RunInfoRcd>().get(sumFED);
00139
00140 std::vector<int> FedsInIds= sumFED->m_fed_in;
00141
00142 float ESFedCount = 0.;
00143
00144 for( unsigned int fedItr=0; fedItr<FedsInIds.size(); ++fedItr ) {
00145
00146 int fedID=FedsInIds[fedItr];
00147
00148 if ( fedID >= ESFedRangeMin_ && fedID <= ESFedRangeMax_ ) {
00149
00150 if( ESOnFed_[fedID - ESFedRangeMin_] ) ESFedCount++;
00151
00152 if ( meESDaqActive_[fedID-ESFedRangeMin_] ) meESDaqActive_[fedID-ESFedRangeMin_]->Fill(1.0);
00153
00154 if( meESDaqActiveMap_ ) {
00155
00156 for (int x = 0; x < 80; x++) {
00157 for (int y = 0; y < 80; y++) {
00158 if (fedID == getFEDNumber(x, y))
00159 meESDaqActiveMap_->setBinContent( x+1, y+1, 1.0 );
00160 }
00161 }
00162
00163 }
00164
00165 if( meESDaqFraction_ ) meESDaqFraction_->Fill( ESFedCount/40. );
00166
00167 if( meESDaqError_ ){
00168 for( int i = 0; i < 56; i++){
00169 if( ESOnFed_[fedID-ESFedRangeMin_] ) meESDaqError_->setBinContent(i+1, 1.0);
00170 else meESDaqError_->setBinContent(i+1, 2.0);
00171 }
00172 }
00173
00174 }
00175
00176 }
00177
00178 } else {
00179
00180 LogWarning("ESDaqInfoTask") << "Cannot find any RunInfoRcd" << endl;
00181
00182 }
00183
00184 }
00185
00186 void ESDaqInfoTask::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) {
00187
00188 }
00189
00190 void ESDaqInfoTask::reset(void) {
00191
00192 if ( meESDaqFraction_ ) meESDaqFraction_->Reset();
00193
00194 for (int i = 0; i < 56; i++) {
00195 if ( meESDaqActive_[i] ) meESDaqActive_[i]->Reset();
00196 }
00197
00198 if ( meESDaqActiveMap_ ) meESDaqActiveMap_->Reset();
00199
00200 if ( meESDaqError_ ) meESDaqError_->Reset();
00201
00202 }
00203
00204
00205 void ESDaqInfoTask::cleanup(void){
00206
00207 if ( dqmStore_ ) {
00208
00209 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
00210
00211 if ( meESDaqFraction_ ) dqmStore_->removeElement( meESDaqFraction_->getName() );
00212
00213 if ( meESDaqActiveMap_ ) dqmStore_->removeElement( meESDaqActiveMap_->getName() );
00214
00215 if ( meESDaqError_ ) dqmStore_->removeElement( meESDaqError_->getName() );
00216
00217 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
00218
00219 for (int i = 0; i < 56; i++) {
00220 if ( meESDaqActive_[i] ) dqmStore_->removeElement( meESDaqActive_[i]->getName() );
00221 }
00222
00223 }
00224
00225 }
00226
00227 void ESDaqInfoTask::analyze(const Event& e, const EventSetup& c){
00228
00229 }
00230
00231 DEFINE_FWK_MODULE(ESDaqInfoTask);