CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/DQM/EcalCommon/src/DQWorkerClient.cc

Go to the documentation of this file.
00001 #include "DQM/EcalCommon/interface/DQWorkerClient.h"
00002 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00003 
00004 #include "DQM/EcalCommon/interface/MESetChannel.h"
00005 
00006 #include "FWCore/Utilities/interface/Exception.h"
00007 
00008 namespace ecaldqm {
00009 
00010   EcalDQMChannelStatus const* DQWorkerClient::channelStatus(0);
00011   EcalDQMTowerStatus const* DQWorkerClient::towerStatus(0);
00012 
00013   DQWorkerClient::DQWorkerClient(const edm::ParameterSet &_params, const edm::ParameterSet& _paths, std::string const& _name) :
00014     DQWorker(_params, _paths, _name),
00015     sources_(0)
00016   {
00017   }
00018 
00019   void
00020   DQWorkerClient::endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
00021   {
00022     for(std::vector<MESet const*>::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr){
00023       MESetChannel const* meset(dynamic_cast<MESetChannel const*>(*sItr));
00024       if(meset) meset->checkDirectory();
00025     }
00026   }
00027 
00028   void
00029   DQWorkerClient::reset()
00030   {
00031     DQWorker::reset();
00032     for(std::vector<MESet const*>::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
00033       (*sItr)->clear();
00034   }
00035 
00036   void
00037   DQWorkerClient::initialize()
00038   {
00039     initialized_ = true;
00040     for(std::vector<MESet const*>::iterator sItr(sources_.begin()); sItr != sources_.end(); ++sItr)
00041       initialized_ &= (*sItr)->retrieve();
00042   }
00043 
00044   void
00045   DQWorkerClient::source_(unsigned _iS, std::string const& _worker, unsigned _iW, edm::ParameterSet const& _sources)
00046   {
00047     if(_iS >= sources_.size()) sources_.resize(_iS + 1, 0);
00048 
00049     std::map<std::string, std::vector<MEData> >::const_iterator dataItr(meData.find(_worker));
00050     if(dataItr == meData.end())
00051       throw cms::Exception("InvalidCall") << "DQWorker " << _worker << " is not defined";
00052 
00053     MEData const& data(dataItr->second.at(_iW));
00054 
00055     edm::ParameterSet const& workerPaths(_sources.getUntrackedParameterSet(_worker));
00056 
00057     std::string fullpath(workerPaths.getUntrackedParameter<std::string>(data.pathName));
00058 
00059     sources_.at(_iS) = createMESet_(fullpath, data, true);
00060   }
00061 
00062   void
00063   DQWorkerClient::fillQuality_(unsigned _iME, DetId const& _id, uint32_t _mask, float _quality)
00064   {
00065     using namespace std;
00066 
00067     bool doMask(false);
00068 
00069     // turn off masking for good channel for the time being
00070     // update the RP then enable again
00071     if(_quality != 1. && channelStatus && towerStatus){
00072       BinService::BinningType btype(MEs_[_iME]->getBinType());
00073       bool searchTower(btype == BinService::kTriggerTower || btype == BinService::kSuperCrystal);
00074 
00075       switch(_id.subdetId()){
00076       case EcalBarrel:
00077         if(searchTower){
00078           EcalTrigTowerDetId ttid(EBDetId(_id).tower());
00079           int tccid(getElectronicsMap()->TCCid(ttid));
00080           int itt(getElectronicsMap()->iTT(ttid));
00081           vector<DetId> ids(getElectronicsMap()->ttConstituents(tccid, itt));
00082           for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
00083             if(doMask) break;
00084             EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(idItr->rawId()));
00085             if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
00086           }
00087         }
00088         else{
00089           EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(_id.rawId()));
00090           if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
00091         }
00092 
00093         if(!doMask){
00094           EcalDQMTowerStatus::const_iterator tItr(towerStatus->find(EBDetId(_id).tower().rawId()));
00095           if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
00096         }
00097 
00098         break;
00099 
00100       case EcalEndcap:
00101         if(isEcalScDetId(_id)){
00102           EcalScDetId scid(_id);
00103           for(int ix(1); ix <= 5; ix++){
00104             for(int iy(1); iy <= 5; iy++){
00105               if(doMask) break;
00106               int iix((scid.ix() - 1) * 5 + ix);
00107               int iiy((scid.iy() - 1) * 5 + iy);
00108               if(!EEDetId::validDetId(iix, iiy, scid.zside())) continue;
00109               EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(EEDetId(iix, iiy, scid.zside()).rawId()));
00110               if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
00111             }
00112           }
00113 
00114           if(!doMask){
00115             EcalDQMTowerStatus::const_iterator tItr(towerStatus->find(_id.rawId()));
00116             if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
00117           }
00118         }
00119         else{
00120           if(searchTower){
00121             EcalScDetId scid(EEDetId(_id).sc());
00122             for(int ix(1); ix <= 5; ix++){
00123               for(int iy(1); iy <= 5; iy++){
00124                 if(doMask) break;
00125                 int iix((scid.ix() - 1) * 5 + ix);
00126                 int iiy((scid.iy() - 1) * 5 + iy);
00127                 if(!EEDetId::validDetId(iix, iiy, scid.zside())) continue;
00128                 EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(EEDetId(iix, iiy, scid.zside()).rawId()));
00129                 if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
00130               }
00131             }
00132           }
00133           else{
00134             EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(_id.rawId()));
00135             if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
00136           }
00137 
00138           if(!doMask){
00139             EcalDQMTowerStatus::const_iterator tItr(towerStatus->find(EEDetId(_id).sc().rawId()));
00140             if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
00141           }
00142         }
00143 
00144         break;
00145 
00146       case EcalTriggerTower:
00147         {
00148           EcalTrigTowerDetId ttid(_id);
00149           vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
00150           for(vector<DetId>::iterator idItr(ids.begin()); idItr != ids.end(); ++idItr){
00151             if(doMask) break;
00152             EcalDQMChannelStatus::const_iterator cItr(channelStatus->find(idItr->rawId()));
00153             if(cItr != channelStatus->end()) doMask |= cItr->getStatusCode() & _mask;
00154 
00155             if(doMask) break;
00156             if(idItr->subdetId() == EcalBarrel){
00157               if(idItr != ids.begin()) continue;
00158               EcalDQMTowerStatus::const_iterator tItr(towerStatus->find(EBDetId(*idItr).tower().rawId()));
00159               if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
00160             }
00161             else{
00162               EcalDQMTowerStatus::const_iterator tItr(towerStatus->find(EEDetId(*idItr).sc().rawId()));
00163               if(tItr != towerStatus->end()) doMask |= tItr->getStatusCode() & _mask;
00164             }
00165           }
00166         }
00167 
00168         break;
00169 
00170       default:
00171         break;
00172       }
00173     }
00174 
00175     float quality(doMask ? _quality + 3. : _quality);
00176 
00177     MEs_[_iME]->setBinContent(_id, quality);
00178   }
00179 
00180 }