00001 #include <memory>
00002 #include <iostream>
00003 #include <fstream>
00004 #include <iomanip>
00005
00006 #include "DQMServices/Core/interface/MonitorElement.h"
00007 #include "DQMServices/Core/interface/DQMStore.h"
00008
00009 #include "DQM/EcalPreshowerMonitorClient/interface/ESSummaryClient.h"
00010
00011 using namespace edm;
00012 using namespace std;
00013
00014 ESSummaryClient::ESSummaryClient(const ParameterSet& ps) {
00015
00016 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00017 verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00018 debug_ = ps.getUntrackedParameter<bool>("debug", false);
00019 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00020 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00021
00022 }
00023
00024 ESSummaryClient::~ESSummaryClient() {
00025 }
00026
00027 void ESSummaryClient::beginJob(DQMStore* dqmStore) {
00028
00029 dqmStore_ = dqmStore;
00030
00031 if ( debug_ ) cout << "ESSummaryClient: beginJob" << endl;
00032
00033 ievt_ = 0;
00034 jevt_ = 0;
00035
00036 char histo[200];
00037
00038 MonitorElement* me;
00039
00040 dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo" );
00041
00042 sprintf(histo, "reportSummary");
00043 me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo);
00044 if ( me ) {
00045 dqmStore_->removeElement(me->getName());
00046 }
00047 me = dqmStore_->bookFloat(histo);
00048 me->Fill(-1.0);
00049
00050 dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo/reportSummaryContents" );
00051
00052 for (int i=0 ; i<2; ++i){
00053 for (int j=0 ; j<2; ++j){
00054 int iz = (i==0)? 1:-1;
00055 sprintf(histo, "EcalPreshower Z %d P %d", iz, j+1);
00056 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/" + histo);
00057 if(me){
00058 dqmStore_->removeElement(me->getName());
00059 }
00060 me = dqmStore_->bookFloat(histo);
00061 me->Fill(-1.0);
00062 }
00063 }
00064
00065 dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo" );
00066
00067 sprintf(histo, "reportSummaryMap");
00068 me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo);
00069 if ( me ) {
00070 dqmStore_->removeElement(me->getName());
00071 }
00072 me = dqmStore_->book2D(histo, histo, 80, 0.5, 80.5, 80, 0.5, 80.5);
00073 me->setAxisTitle("Si X", 1);
00074 me->setAxisTitle("Si Y", 2);
00075
00076 for ( int i = 0; i < 80; i++ ) {
00077 for ( int j = 0; j < 80; j++ ) {
00078 me->setBinContent( i+1, j+1, -1. );
00079 }
00080 }
00081
00082 }
00083
00084 void ESSummaryClient::beginRun(void) {
00085
00086 if ( debug_ ) cout << "ESSummaryClient: beginRun" << endl;
00087
00088 jevt_ = 0;
00089
00090 this->setup();
00091
00092 }
00093
00094 void ESSummaryClient::endJob(void) {
00095
00096 if ( debug_ ) cout << "ESSummaryClient: endJob, ievt = " << ievt_ << endl;
00097
00098 this->cleanup();
00099
00100 }
00101
00102 void ESSummaryClient::endRun(void) {
00103
00104 if ( debug_ ) cout << "ESSummaryClient: endRun, jevt = " << jevt_ << endl;
00105
00106 this->cleanup();
00107
00108 }
00109
00110 void ESSummaryClient::setup(void) {
00111
00112 }
00113
00114 void ESSummaryClient::cleanup(void) {
00115
00116 if ( ! enableCleanup_ ) return;
00117
00118 }
00119
00120 void ESSummaryClient::analyze(void) {
00121
00122 char histo[200];
00123
00124 float nDI_FedErr[80][80];
00125 float DCC[80][80];
00126 float eCount;
00127
00128 MonitorElement* me;
00129
00130 for (int i=0; i<80; ++i)
00131 for (int j=0; j<80; ++j) {
00132 nDI_FedErr[i][j] = -1;
00133 DCC[i][j]=0;
00134 }
00135
00136 for (int i=0; i<2; ++i) {
00137 for (int j=0; j<2; ++j) {
00138
00139 int iz = (i==0)? 1:-1;
00140
00141 sprintf(histo, "ES Integrity Errors Z %d P %d", iz, j+1);
00142 me = dqmStore_->get(prefixME_ + "/ESIntegrityTask/" + histo);
00143 if (me)
00144 for (int x=0; x<40; ++x)
00145 for (int y=0; y<40; ++y)
00146 nDI_FedErr[i*40+x][(1-j)*40+y] = me->getBinContent(x+1, y+1);
00147
00148 sprintf(histo, "ES Integrity Summary 1 Z %d P %d", iz, j+1);
00149 me = dqmStore_->get(prefixME_ + "/ESIntegrityClient/" + histo);
00150 if (me)
00151 for (int x=0; x<40; ++x)
00152 for (int y=0; y<40; ++y)
00153 DCC[i*40+x][(1-j)*40+y] = me->getBinContent(x+1, y+1);
00154
00155 sprintf(histo, "ES RecHit 2D Occupancy Z %d P %d", iz, j+1);
00156 me = dqmStore_->get(prefixME_ + "/ESOccupancyTask/" + histo);
00157 if (me)
00158 eCount = me->getBinContent(40,40);
00159 else
00160 eCount = 1.;
00161
00162 }
00163 }
00164
00165
00166
00167
00168
00169 float nValidChannels=0;
00170 float nGlobalErrors=0;
00171 float nValidChannelsES[2][2]={};
00172 float nGlobalErrorsES[2][2]={};
00173
00174 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
00175 if (me) {
00176 for (int x=0; x<80; ++x) {
00177 if (eCount < 1) break;
00178 for (int y=0; y<80; ++y) {
00179
00180 int z = (x<40) ? 0:1;
00181 int p = (y>=40) ? 0:1;
00182
00183 if (DCC[x][y]==0.) {
00184 me->setBinContent(x+1, y+1, -1.);
00185 } else {
00186 if (nDI_FedErr[x][y] >= 0) {
00187 me->setBinContent(x+1, y+1, 1-(nDI_FedErr[x][y]/eCount));
00188
00189 nValidChannels++;
00190 nGlobalErrors += nDI_FedErr[x][y]/eCount;
00191
00192 nValidChannelsES[z][p]++;
00193 nGlobalErrorsES[z][p] += nDI_FedErr[x][y]/eCount;
00194 }
00195 else {
00196 me->setBinContent(x+1, y+1, -1.);
00197 }
00198 }
00199
00200 }
00201 }
00202 }
00203
00204 for (int i=0; i<2; ++i) {
00205 for (int j=0; j<2; ++j) {
00206 int iz = (i==0)? 1:-1;
00207 float reportSummaryES = -1.;
00208 if (nValidChannelsES[i][j] != 0)
00209 reportSummaryES = 1.0 - nGlobalErrorsES[i][j]/nValidChannelsES[i][j];
00210 sprintf(histo, "EcalPreshower Z %d P %d", iz, j+1);
00211 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/" + histo);
00212 if ( me ) me->Fill(reportSummaryES);
00213 }
00214 }
00215
00216
00217 float reportSummary = -1.0;
00218 if ( nValidChannels != 0 )
00219 reportSummary = 1.0 - nGlobalErrors/nValidChannels;
00220 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummary");
00221 if ( me ) me->Fill(reportSummary);
00222
00223 }
00224
00225 void ESSummaryClient::softReset(bool flag) {
00226 }
00227
00228 void ESSummaryClient::endLumiAnalyze() {
00229
00230 char histo[200];
00231 MonitorElement* me = 0;
00232 MonitorElement* me_report = 0;
00233 sprintf(histo, "ES Good Channel Fraction");
00234 me = dqmStore_->get(prefixME_+"/ESIntegrityTask/"+histo);
00235 if (!me) return;
00236 for (int i=0; i<2; ++i) {
00237 for (int j=0; j<2; ++j) {
00238 int iz = (i==0)? 1:-1;
00239 sprintf(histo, "EcalPreshower Z %d P %d", iz, j+1);
00240 me_report = dqmStore_->get(prefixME_+"/EventInfo/reportSummaryContents/" + histo);
00241 if (me_report) {
00242 me_report->Fill(me->getBinContent(i+1, j+1));
00243 }
00244 }
00245 }
00246 me_report = dqmStore_->get(prefixME_ + "/EventInfo/reportSummary");
00247 if ( me_report ) me_report->Fill(me->getBinContent(3,3));
00248
00249 }