CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/EcalCommon/src/EcalDQMStatusReader.cc

Go to the documentation of this file.
00001 /*
00002  * \file EcalDQMStatusReader.cc
00003  *
00004  * $Date: 2010/08/09 17:47:32 $
00005  * $Revision: 1.11 $
00006  * \author G. Della Ricca
00007  *
00008 */
00009 
00010 #include <fstream>
00011 #include <iostream>
00012 #include <string>
00013 #include <cstring>
00014 #include <time.h>
00015 #include <unistd.h>
00016 
00017 #include "FWCore/Framework/interface/ESHandle.h"
00018 #include "CondFormats/DataRecord/interface/EcalDQMChannelStatusRcd.h"
00019 #include "CondFormats/DataRecord/interface/EcalDQMTowerStatusRcd.h"
00020 
00021 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00022 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00023 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00024 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00025 
00026 #include "DQM/EcalCommon/interface/Numbers.h"
00027 
00028 #include "DQM/EcalCommon/interface/EcalDQMStatusDictionary.h"
00029 
00030 #include "DQM/EcalCommon/interface/EcalDQMStatusReader.h"
00031 
00032 EcalDQMStatusReader::EcalDQMStatusReader(const edm::ParameterSet& ps) {
00033 
00034   verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
00035 
00036 }
00037 
00038 void EcalDQMStatusReader::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00039 
00040   Numbers::initGeometry(c, verbose_);
00041 
00042   std::vector<EcalDQMStatusDictionary::codeDef> dictionary;
00043   EcalDQMStatusDictionary::getDictionary( dictionary );
00044 
00045   const EcalDQMChannelStatus* channelStatus = 0;
00046   if ( c.find( edm::eventsetup::EventSetupRecordKey::makeKey< EcalDQMChannelStatusRcd >() ) ) {
00047     edm::ESHandle< EcalDQMChannelStatus > handle;
00048     c.get< EcalDQMChannelStatusRcd >().get(handle);
00049     if ( handle.isValid() ) channelStatus = handle.product();
00050   }
00051 
00052   const EcalDQMTowerStatus* towerStatus = 0;
00053   if ( c.find( edm::eventsetup::EventSetupRecordKey::makeKey< EcalDQMTowerStatusRcd >() ) ) {
00054     edm::ESHandle< EcalDQMTowerStatus > handle;
00055     c.get< EcalDQMTowerStatusRcd >().get(handle);
00056     if ( handle.isValid() ) towerStatus = handle.product();
00057   }
00058 
00059   // barrel
00060   for ( int ism=1; ism<=36; ism++ ) {
00061     for ( int ic=1; ic<=1700; ic++ ) {
00062       int jsm = Numbers::iSM(ism, EcalBarrel);
00063       EBDetId id(jsm, ic, EBDetId::SMCRYSTALMODE);
00064       if ( channelStatus ) {
00065         EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
00066         if ( it != channelStatus->end() ) {
00067           if ( it->getStatusCode() != 0 ) {
00068             if ( verbose_ ) std::cout << "# EB:channel, ic=" << ic << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
00069             std::vector<EcalDQMStatusDictionary::codeDef> codes;
00070             EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00071             for ( unsigned int i=0; i<codes.size(); i++ ) {
00072               std::cout << "Crystal " << Numbers::sEB(ism) << " " << ic << " " << codes[i].desc << std::endl;
00073             }
00074           }
00075         }
00076       }
00077     }
00078   }
00079 
00080   for ( int ix=1; ix<=17; ix++ ) {
00081     for ( int iy=1; iy<=72; iy++ ) {
00082       if ( EcalTrigTowerDetId::validDetId(+1, EcalBarrel, ix, iy) ) {
00083         EcalTrigTowerDetId id(+1, EcalBarrel, ix, iy);
00084         if ( towerStatus ) {
00085           EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
00086           if ( it != towerStatus->end() ) {
00087             if ( it->getStatusCode() != 0 ) {
00088               if ( verbose_ ) std::cout << "# EB:tower, tt=" << Numbers::iTT(id) << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
00089               std::vector<EcalDQMStatusDictionary::codeDef> codes;
00090               EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00091               for ( unsigned int i=0; i<codes.size(); i++ ) {
00092                 std::cout << "TT " << Numbers::sEB(Numbers::iSM(id)) << " " << Numbers::iTT(id) << " " << codes[i].desc << std::endl;
00093               }
00094             }
00095           }
00096         }
00097       }
00098       if ( EcalTrigTowerDetId::validDetId(-1, EcalBarrel, ix, iy) ) {
00099         EcalTrigTowerDetId id(-1, EcalBarrel, ix, iy);
00100         if ( towerStatus ) {
00101           EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
00102           if ( it != towerStatus->end() ) {
00103             if ( it->getStatusCode() != 0 ) {
00104               if ( verbose_ ) std::cout << "# EB:tower, tt=" << Numbers::iTT(id) << " hi=" << id.hashedIndex() << " status=" << it->getStatusCode() << std::endl;
00105               std::vector<EcalDQMStatusDictionary::codeDef> codes;
00106               EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00107               for ( unsigned int i=0; i<codes.size(); i++ ) {
00108                 std::cout << "TT " << Numbers::sEB(Numbers::iSM(id)) << " " << Numbers::iTT(id) << " " << codes[i].desc << std::endl;
00109               }
00110             }
00111           }
00112         }
00113       }
00114     }
00115   }
00116 
00117   // endcap
00118   for ( int ix=1; ix<=100; ix++ ) {
00119     for ( int iy=1; iy<=100; iy++ ) {
00120       if ( EEDetId::validDetId(ix, iy, +1) ) {
00121         EEDetId id(ix, iy, +1);
00122         if ( channelStatus ) {
00123           EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
00124           if ( it != channelStatus->end() ) {
00125             if ( it->getStatusCode() != 0 ) {
00126               if ( verbose_ ) std::cout << "# EE:channel, " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
00127               std::vector<EcalDQMStatusDictionary::codeDef> codes;
00128               EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00129               for ( unsigned int i=0; i<codes.size(); i++ ) {
00130                 std::cout << "Crystal " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " " << codes[i].desc << std::endl;
00131               }
00132             }
00133           }
00134         }
00135       }
00136       if ( EEDetId::validDetId(ix, iy, -1) ) {
00137         EEDetId id(ix, iy, -1);
00138         if ( channelStatus ) {
00139           EcalDQMChannelStatus::const_iterator it = channelStatus->find( id.rawId() );
00140           if ( it != channelStatus->end() ) {
00141             if ( it->getStatusCode() != 0 ) {
00142               if ( verbose_ ) std::cout << "# EE:channel, " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
00143               std::vector<EcalDQMStatusDictionary::codeDef> codes;
00144               EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00145               for ( unsigned int i=0; i<codes.size(); i++ ) {
00146                 std::cout << "Crystal " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::indexEE(Numbers::iSM(id), ix, iy) << " " << codes[i].desc << std::endl;
00147               }
00148             }
00149           }
00150         }
00151       }
00152     }
00153   }
00154 
00155   for ( int ix=1; ix<=20; ix++ ) {
00156     for ( int iy=1; iy<=20; iy++ ) {
00157       if ( EcalScDetId::validDetId(ix, iy, +1) ) {
00158         EcalScDetId id(ix, iy, +1);
00159         if ( towerStatus ) {
00160           EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
00161           if ( it != towerStatus->end() ) {
00162             if ( it->getStatusCode() != 0 ) {
00163               if ( verbose_ ) std::cout << "# EE:tower, " << Numbers::iSC(id) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
00164               std::vector<EcalDQMStatusDictionary::codeDef> codes;
00165               EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00166               for ( unsigned int i=0; i<codes.size(); i++ ) {
00167                 std::cout << "TT " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::iSC(id) << " " << codes[i].desc << std::endl;
00168               }
00169             }
00170           }
00171         }
00172       }
00173       if ( EcalScDetId::validDetId(ix, iy, -1) ) {
00174         EcalScDetId id(ix, iy, -1);
00175         if ( towerStatus ) {
00176           EcalDQMTowerStatus::const_iterator it = towerStatus->find( id.rawId() );
00177           if ( it != towerStatus->end() ) {
00178             if ( it->getStatusCode() != 0 ) {
00179               if ( verbose_ ) std::cout << "# EE:tower, " << Numbers::iSC(id) << " hi=" << id.hashedIndex() << " " << it->getStatusCode() << std::endl;
00180               std::vector<EcalDQMStatusDictionary::codeDef> codes;
00181               EcalDQMStatusDictionary::getCodes( codes, it->getStatusCode() );
00182               for ( unsigned int i=0; i<codes.size(); i++ ) {
00183                 std::cout << "TT " << Numbers::sEE(Numbers::iSM(id)) << " " << Numbers::iSC(id) << " " << codes[i].desc << std::endl;
00184               }
00185             }
00186           }
00187         }
00188       }
00189     }
00190   }
00191 
00192 }
00193