Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011
00012 #include "FWCore/ServiceRegistry/interface/Service.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016
00017 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00018
00019 #include "CondFormats/EcalObjects/interface/EcalDCSTowerStatus.h"
00020 #include "CondFormats/DataRecord/interface/EcalDCSTowerStatusRcd.h"
00021
00022 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00023
00024 #include "DQMServices/Core/interface/MonitorElement.h"
00025 #include "DQMServices/Core/interface/DQMStore.h"
00026
00027 #include "DQM/EcalCommon/interface/Numbers.h"
00028
00029 #include "DQM/EcalEndcapMonitorTasks/interface/EEDcsInfoTask.h"
00030
00031 EEDcsInfoTask::EEDcsInfoTask(const edm::ParameterSet& ps) {
00032
00033 dqmStore_ = edm::Service<DQMStore>().operator->();
00034
00035 prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
00036
00037 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00038
00039 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00040
00041 meEEDcsFraction_ = 0;
00042 meEEDcsActiveMap_ = 0;
00043 for (int i = 0; i < 18; i++) {
00044 meEEDcsActive_[i] = 0;
00045 }
00046
00047 }
00048
00049 EEDcsInfoTask::~EEDcsInfoTask() {
00050
00051 }
00052
00053 void EEDcsInfoTask::beginJob(void){
00054
00055 char histo[200];
00056
00057 if ( dqmStore_ ) {
00058
00059 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
00060
00061 sprintf(histo, "DCSSummary");
00062 meEEDcsFraction_ = dqmStore_->bookFloat(histo);
00063 meEEDcsFraction_->Fill(0.0);
00064
00065 sprintf(histo, "DCSSummaryMap");
00066 meEEDcsActiveMap_ = dqmStore_->book2D(histo,histo, 40, 0., 200., 20, 0., 100.);
00067 meEEDcsActiveMap_->setAxisTitle("ix / ix+100", 1);
00068 meEEDcsActiveMap_->setAxisTitle("iy", 2);
00069
00070 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
00071
00072 for (int i = 0; i < 18; i++) {
00073 sprintf(histo, "EcalEndcap_%s", Numbers::sEE(i+1).c_str());
00074 meEEDcsActive_[i] = dqmStore_->bookFloat(histo);
00075 meEEDcsActive_[i]->Fill(-1.0);
00076 }
00077
00078 }
00079
00080 }
00081
00082 void EEDcsInfoTask::endJob(void) {
00083
00084 if ( enableCleanup_ ) this->cleanup();
00085
00086 }
00087
00088 void EEDcsInfoTask::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup){
00089
00090
00091 for ( int itx = 0; itx < 40; itx++ ) {
00092 for ( int ity = 0; ity < 20; ity++ ) {
00093 readyLumi[itx][ity] = 1;
00094 }
00095 }
00096
00097 if ( !iSetup.find( edm::eventsetup::EventSetupRecordKey::makeKey<EcalDCSTowerStatusRcd>() ) ) {
00098 edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not found";
00099 return;
00100 }
00101
00102 edm::ESHandle<EcalDCSTowerStatus> pDCSStatus;
00103 iSetup.get<EcalDCSTowerStatusRcd>().get(pDCSStatus);
00104 if ( !pDCSStatus.isValid() ) {
00105 edm::LogWarning("EEDcsInfoTask") << "EcalDCSTowerStatus record not valid";
00106 return;
00107 }
00108 const EcalDCSTowerStatus* dcsStatus = pDCSStatus.product();
00109
00110 edm::ESHandle< EcalElectronicsMapping > pElecMapping;
00111 iSetup.get< EcalMappingRcd >().get(pElecMapping);
00112 if( !pElecMapping.isValid() ) {
00113 edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
00114 return;
00115 }
00116 const EcalElectronicsMapping *map = pElecMapping.product();
00117
00118 std::vector<DetId> crystals;
00119 std::vector<EcalScDetId> scs;
00120
00121 for(unsigned i=0 ; i<sizeof(DccId_)/sizeof(int) ; i++){
00122 for(int t=1 ; t<=nTowerMax_ ; t++){
00123
00124 crystals = map->dccTowerConstituents(DccId_[i], t);
00125 if(!crystals.size()) continue;
00126
00127 scs = map->getEcalScDetId(DccId_[i], t, false);
00128
00129 for(unsigned u=0 ; u<scs.size() ; u++){
00130
00131 uint16_t dbStatus = 0;
00132 EcalDCSTowerStatus::const_iterator dcsStatusIt = dcsStatus->find( scs[u].rawId() );
00133 if ( dcsStatusIt != dcsStatus->end() ) dbStatus = dcsStatusIt->getStatusCode();
00134
00135 if ( dbStatus > 0 ) {
00136 int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
00137 int jy = scs[u].iy() - 1;
00138 readyRun[jx][jy] = 0;
00139 readyLumi[jx][jy] = 0;
00140 }
00141 }
00142 }
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 }
00168
00169 void EEDcsInfoTask::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) {
00170
00171 edm::ESHandle< EcalElectronicsMapping > handle;
00172 iSetup.get< EcalMappingRcd >().get(handle);
00173 const EcalElectronicsMapping *map = handle.product();
00174 if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
00175 else this->fillMonitorElements(readyLumi, map);
00176
00177 }
00178
00179 void EEDcsInfoTask::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00180
00181 if ( ! mergeRuns_ ) this->reset();
00182
00183 for ( int itx = 0; itx < 40; itx++ ) {
00184 for ( int ity = 0; ity < 20; ity++ ) {
00185 readyRun[itx][ity] = 1;
00186 }
00187 }
00188
00189 }
00190
00191 void EEDcsInfoTask::endRun(const edm::Run& r, const edm::EventSetup& c) {
00192
00193 edm::ESHandle< EcalElectronicsMapping > handle;
00194 c.get< EcalMappingRcd >().get(handle);
00195 const EcalElectronicsMapping *map = handle.product();
00196 if( ! map ) edm::LogWarning("EEDaqInfoTask") << "EcalElectronicsMapping not available";
00197 else this->fillMonitorElements(readyRun, map);
00198
00199 }
00200
00201 void EEDcsInfoTask::reset(void) {
00202
00203 if ( meEEDcsFraction_ ) meEEDcsFraction_->Reset();
00204
00205 for (int i = 0; i < 18; i++) {
00206 if ( meEEDcsActive_[i] ) meEEDcsActive_[i]->Reset();
00207 }
00208
00209 if ( meEEDcsActiveMap_ ) meEEDcsActiveMap_->Reset();
00210
00211 }
00212
00213
00214 void EEDcsInfoTask::cleanup(void){
00215
00216 if ( dqmStore_ ) {
00217
00218 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
00219
00220 if ( meEEDcsFraction_ ) dqmStore_->removeElement( meEEDcsFraction_->getName() );
00221
00222 if ( meEEDcsActiveMap_ ) dqmStore_->removeElement( meEEDcsActiveMap_->getName() );
00223
00224 dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DCSContents");
00225
00226 for (int i = 0; i < 18; i++) {
00227 if ( meEEDcsActive_[i] ) dqmStore_->removeElement( meEEDcsActive_[i]->getName() );
00228 }
00229
00230 }
00231
00232 }
00233
00234 void EEDcsInfoTask::fillMonitorElements(int ready[40][20], const EcalElectronicsMapping *map) {
00235
00236 float readySum[18];
00237 int nValidChannels[18];
00238 for ( int ism = 0; ism < 18; ism++ ) {
00239 readySum[ism] = 0;
00240 nValidChannels[ism] = 0;
00241 }
00242 float readySumTot = 0.;
00243 int nValidChannelsTot = 0;
00244
00245 if(meEEDcsActiveMap_){
00246 for(int ix=1 ; ix<=meEEDcsActiveMap_->getNbinsX() ; ix++){
00247 for(int iy=1 ; iy<=meEEDcsActiveMap_->getNbinsY() ; iy++){
00248 meEEDcsActiveMap_->setBinContent( ix, iy, -1.0 );
00249 }
00250 }
00251 }
00252
00253 std::vector<DetId> crystals;
00254 std::vector<EcalScDetId> scs;
00255
00256 for ( unsigned iDcc = 0; iDcc < sizeof(DccId_)/sizeof(int); iDcc++) {
00257 for ( int t = 1; t<=nTowerMax_; t++ ) {
00258
00259 crystals = map->dccTowerConstituents(DccId_[iDcc], t);
00260 if(!crystals.size()) continue;
00261
00262 scs = map->getEcalScDetId(DccId_[iDcc], t, false);
00263
00264 for(unsigned u=0 ; u<scs.size() ; u++){
00265
00266 int jx = scs[u].ix() - 1 + (scs[u].zside()<0 ? 0 : 20);
00267 int jy = scs[u].iy() - 1;
00268
00269 if(meEEDcsActiveMap_) meEEDcsActiveMap_->setBinContent( jx+1, jy+1, ready[jx][jy] );
00270
00271 int ncrystals = 0;
00272
00273 for(std::vector<DetId>::const_iterator it=crystals.begin() ; it!=crystals.end() ; ++it){
00274 EEDetId id(*it);
00275 if( id.zside() == scs[u].zside() && (id.ix()-1)/5+1 == scs[u].ix() && (id.iy()-1)/5+1 == scs[u].iy() ) ncrystals++;
00276 }
00277
00278 if(ready[jx][jy]) {
00279 readySum[iDcc] += ncrystals;
00280 readySumTot += ncrystals;
00281 }
00282
00283 nValidChannels[iDcc] += ncrystals;
00284 nValidChannelsTot += ncrystals;
00285 }
00286 }
00287
00288 if( meEEDcsActive_[iDcc] ) meEEDcsActive_[iDcc]->Fill( readySum[iDcc]/float(nValidChannels[iDcc]) );
00289 }
00290
00291 if( meEEDcsFraction_ ) meEEDcsFraction_->Fill( readySumTot/float(nValidChannelsTot) );
00292
00293 }
00294
00295 void EEDcsInfoTask::analyze(const edm::Event& e, const edm::EventSetup& c){
00296
00297 }