00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <memory>
00012 #include <iostream>
00013 #include <fstream>
00014 #include <iomanip>
00015
00016 #include "FWCore/ServiceRegistry/interface/Service.h"
00017
00018 #include "DQMServices/Core/interface/DQMStore.h"
00019
00020 #include "DQM/EcalCommon/interface/UtilsClient.h"
00021 #include "DQM/EcalCommon/interface/Numbers.h"
00022
00023 #include "DQM/EcalEndcapMonitorClient/interface/EETriggerTowerClient.h"
00024
00025 EETriggerTowerClient::EETriggerTowerClient(const edm::ParameterSet& ps) {
00026
00027
00028 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00029
00030
00031 verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00032
00033
00034 debug_ = ps.getUntrackedParameter<bool>("debug", false);
00035
00036
00037 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00038
00039
00040 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00041
00042
00043 superModules_.reserve(18);
00044 for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
00045 superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
00046
00047 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00048
00049 int ism = superModules_[i];
00050
00051 l01_[ism-1] = 0;
00052 o01_[ism-1] = 0;
00053
00054 mel01_[ism-1] = 0;
00055 meo01_[ism-1] = 0;
00056
00057 }
00058
00059 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00060
00061 int ism = superModules_[i];
00062
00063 me_o01_[ism-1] = 0;
00064 me_o02_[ism-1] = 0;
00065
00066 }
00067
00068 }
00069
00070 EETriggerTowerClient::~EETriggerTowerClient() {
00071
00072 }
00073
00074 void EETriggerTowerClient::beginJob(void) {
00075
00076 dqmStore_ = edm::Service<DQMStore>().operator->();
00077
00078 if ( debug_ ) std::cout << "EETriggerTowerClient: beginJob" << std::endl;
00079
00080 ievt_ = 0;
00081 jevt_ = 0;
00082
00083 }
00084
00085 void EETriggerTowerClient::beginRun(void) {
00086
00087 if ( debug_ ) std::cout << "EETriggerTowerClient: beginRun" << std::endl;
00088
00089 jevt_ = 0;
00090
00091 this->setup();
00092
00093 }
00094
00095 void EETriggerTowerClient::endJob(void) {
00096
00097 if ( debug_ ) std::cout << "EETriggerTowerClient: endJob, ievt = " << ievt_ << std::endl;
00098
00099 this->cleanup();
00100
00101 }
00102
00103 void EETriggerTowerClient::endRun(void) {
00104
00105 if ( debug_ ) std::cout << "EETriggerTowerClient: endRun, jevt = " << jevt_ << std::endl;
00106
00107 this->cleanup();
00108
00109 }
00110
00111 void EETriggerTowerClient::setup(void) {
00112
00113 char histo[200];
00114
00115 dqmStore_->setCurrentFolder( prefixME_ + "/EETriggerTowerClient" );
00116
00117 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00118
00119 int ism = superModules_[i];
00120
00121 if ( me_o01_[ism-1] ) dqmStore_->removeElement( me_o01_[ism-1]->getName() );
00122 sprintf(histo, "EETTT Trigger Primitives Timing %s", Numbers::sEE(ism).c_str());
00123 me_o01_[ism-1] = dqmStore_->book2D(histo, histo, 50, Numbers::ix0EE(ism)+0., Numbers::ix0EE(ism)+50., 50, Numbers::iy0EE(ism)+0., Numbers::iy0EE(ism)+50.);
00124 me_o01_[ism-1]->setAxisTitle("ix", 1);
00125 if ( ism >= 1 && ism <= 9 ) me_o01_[ism-1]->setAxisTitle("101-ix", 1);
00126 me_o01_[ism-1]->setAxisTitle("iy", 2);
00127
00128 if ( me_o02_[ism-1] ) dqmStore_->removeElement( me_o02_[ism-1]->getName() );
00129 sprintf(histo, "EETTT Non Single Timing %s", Numbers::sEE(ism).c_str());
00130 me_o02_[ism-1] = dqmStore_->book2D(histo, histo, 50, Numbers::ix0EE(ism)+0., Numbers::ix0EE(ism)+50., 50, Numbers::iy0EE(ism)+0., Numbers::iy0EE(ism)+50.);
00131 me_o02_[ism-1]->setAxisTitle("ix", 1);
00132 if ( ism >= 1 && ism <= 9 ) me_o02_[ism-1]->setAxisTitle("101-ix", 1);
00133 me_o02_[ism-1]->setAxisTitle("iy", 2);
00134 me_o02_[ism-1]->setAxisTitle("fraction", 3);
00135
00136 }
00137
00138 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00139
00140 int ism = superModules_[i];
00141
00142 if ( me_o01_[ism-1] ) me_o01_[ism-1]->Reset();
00143 if ( me_o02_[ism-1] ) me_o02_[ism-1]->Reset();
00144
00145 }
00146
00147 }
00148
00149 void EETriggerTowerClient::cleanup(void) {
00150
00151 if ( ! enableCleanup_ ) return;
00152
00153 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00154
00155 int ism = superModules_[i];
00156
00157 if ( cloneME_ ) {
00158 if ( l01_[ism-1] ) delete l01_[ism-1];
00159 if ( o01_[ism-1] ) delete o01_[ism-1];
00160 }
00161
00162 l01_[ism-1] = 0;
00163 o01_[ism-1] = 0;
00164
00165 mel01_[ism-1] = 0;
00166 meo01_[ism-1] = 0;
00167
00168 }
00169
00170 dqmStore_->setCurrentFolder( prefixME_ + "/EETriggerTowerClient" );
00171
00172 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00173
00174 int ism = superModules_[i];
00175
00176 if ( me_o01_[ism-1] ) dqmStore_->removeElement( me_o01_[ism-1]->getName() );
00177 me_o01_[ism-1] = 0;
00178 if ( me_o02_[ism-1] ) dqmStore_->removeElement( me_o02_[ism-1]->getName() );
00179 me_o02_[ism-1] = 0;
00180
00181 }
00182
00183 }
00184
00185 #ifdef WITH_ECAL_COND_DB
00186 bool EETriggerTowerClient::writeDb(EcalCondDBInterface* econn, RunIOV* runiov, MonRunIOV* moniov, bool& status) {
00187
00188 status = true;
00189
00190 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00191
00192 int ism = superModules_[i];
00193
00194 if ( verbose_ ) {
00195 std::cout << " " << Numbers::sEE(ism) << " (ism=" << ism << ")" << std::endl;
00196 std::cout << std::endl;
00197 UtilsClient::printBadChannels(mel01_[ism-1], UtilsClient::getHisto<TH2F*>(mel01_[ism-1]), true);
00198 }
00199
00200 }
00201
00202 return true;
00203
00204 }
00205 #endif
00206
00207 void EETriggerTowerClient::analyze(void) {
00208
00209 ievt_++;
00210 jevt_++;
00211 if ( ievt_ % 10 == 0 ) {
00212 if ( debug_ ) std::cout << "EETriggerTowerClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
00213 }
00214
00215 char histo[200];
00216
00217 MonitorElement* me;
00218
00219 for ( unsigned int i=0; i<superModules_.size(); i++ ) {
00220
00221 int ism = superModules_[i];
00222
00223 sprintf(histo, (prefixME_ + "/EETriggerTowerTask/EETTT EmulError %s").c_str(), Numbers::sEE(ism).c_str());
00224 me = dqmStore_->get(histo);
00225 l01_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, l01_[ism-1] );
00226 mel01_[ism-1] = me;
00227
00228 sprintf(histo, (prefixME_ + "/EETriggerTowerTask/EETTT EmulFineGrainVetoError %s").c_str(), Numbers::sEE(ism).c_str());
00229 me = dqmStore_->get(histo);
00230 l02_[ism-1] = UtilsClient::getHisto<TH2F*>( me, cloneME_, l02_[ism-1] );
00231 mel02_[ism-1] = me;
00232
00233 sprintf(histo, (prefixME_ + "/EETriggerTowerTask/EETTT EmulMatch %s").c_str(), Numbers::sEE(ism).c_str());
00234 me = dqmStore_->get(histo);
00235 o01_[ism-1] = UtilsClient::getHisto<TH3F*>( me, cloneME_, o01_[ism-1] );
00236 meo01_[ism-1] = me;
00237
00238 if ( me_o01_[ism-1] ) me_o01_[ism-1]->Reset();
00239 if ( me_o02_[ism-1] ) me_o02_[ism-1]->Reset();
00240
00241 for (int ix = 1; ix <= 50; ix++) {
00242 for (int iy = 1; iy <= 50; iy++) {
00243
00244 if ( o01_[ism-1] ) {
00245
00246 float index=-1;
00247 double max=0;
00248 double total=0;
00249 for (int j=0; j<6; j++) {
00250 double sampleEntries = o01_[ism-1]->GetBinContent(ix, iy, j+1);
00251 if(sampleEntries > max) {
00252 index=j;
00253 max = sampleEntries;
00254 }
00255 total += sampleEntries;
00256 }
00257 if ( max > 0 ) {
00258 if ( index == 0 ) {
00259 me_o01_[ism-1]->setBinContent(ix, iy, -1);
00260 } else {
00261 me_o01_[ism-1]->setBinContent(ix, iy, index );
00262 }
00263 }
00264 double fraction = (total > 0) ? 1.0 - max/total : 0.;
00265 if ( me_o02_[ism-1] ) me_o02_[ism-1]->setBinContent(ix, iy, fraction);
00266 }
00267
00268 }
00269 }
00270
00271 }
00272
00273 }
00274