Go to the documentation of this file.00001 #include "../interface/TowerStatusTask.h"
00002
00003 #include "FWCore/Framework/interface/ESHandle.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "CondFormats/EcalObjects/interface/EcalDAQTowerStatus.h"
00008 #include "CondFormats/DataRecord/interface/EcalDAQTowerStatusRcd.h"
00009 #include "CondFormats/EcalObjects/interface/EcalDCSTowerStatus.h"
00010 #include "CondFormats/DataRecord/interface/EcalDCSTowerStatusRcd.h"
00011
00012 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00013 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00014 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00015 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00016
00017 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00018
00019 namespace ecaldqm {
00020
00021 TowerStatusTask::TowerStatusTask(const edm::ParameterSet& _params, const edm::ParameterSet& _paths) :
00022 DQWorkerTask(_params, _paths, "TowerStatusTask"),
00023 daqLumiStatus_(),
00024 daqRunStatus_(),
00025 dcsLumiStatus_(),
00026 dcsRunStatus_(),
00027 doDAQInfo_(false),
00028 doDCSInfo_(false)
00029 {
00030 collectionMask_ =
00031 (0x1 << kRun) |
00032 (0x1 << kLumiSection);
00033
00034 edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
00035
00036 doDAQInfo_ = taskParams.getUntrackedParameter<bool>("doDAQInfo");
00037 doDCSInfo_ = taskParams.getUntrackedParameter<bool>("doDCSInfo");
00038
00039 if(!doDAQInfo_ && !doDCSInfo_)
00040 throw cms::Exception("InvalidConfiguration") << "Nonthing to do in TowerStatusTask";
00041 }
00042
00043 TowerStatusTask::~TowerStatusTask()
00044 {
00045 }
00046
00047 void
00048 TowerStatusTask::bookMEs()
00049 {
00050 }
00051
00052 void
00053 TowerStatusTask::beginRun(const edm::Run &, const edm::EventSetup &)
00054 {
00055 if(doDAQInfo_){
00056 MEs_[kDAQSummary]->book();
00057 MEs_[kDAQSummaryMap]->book();
00058 MEs_[kDAQContents]->book();
00059
00060 MEs_[kDAQSummaryMap]->resetAll(-1.);
00061 }
00062 if(doDCSInfo_){
00063 MEs_[kDCSSummary]->book();
00064 MEs_[kDCSSummaryMap]->book();
00065 MEs_[kDCSContents]->book();
00066
00067 MEs_[kDCSSummaryMap]->resetAll(-1.);
00068 }
00069
00070 daqLumiStatus_.clear();
00071 daqRunStatus_.clear();
00072 dcsLumiStatus_.clear();
00073 dcsRunStatus_.clear();
00074
00075 for(unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++){
00076 EcalTrigTowerDetId ttid(EcalTrigTowerDetId::detIdFromDenseIndex(id));
00077 if(doDAQInfo_){
00078 daqLumiStatus_[ttid.rawId()] = true;
00079 daqRunStatus_[ttid.rawId()] = true;
00080 }
00081 if(doDCSInfo_){
00082 dcsLumiStatus_[ttid.rawId()] = true;
00083 dcsRunStatus_[ttid.rawId()] = true;
00084 }
00085 }
00086
00087 for(unsigned id(0); id < EcalScDetId::kSizeForDenseIndexing; id++){
00088 EcalScDetId scid(EcalScDetId::unhashIndex(id));
00089 if(doDAQInfo_){
00090 daqLumiStatus_[scid.rawId()] = true;
00091 daqRunStatus_[scid.rawId()] = true;
00092 }
00093 if(doDCSInfo_){
00094 dcsLumiStatus_[scid.rawId()] = true;
00095 dcsRunStatus_[scid.rawId()] = true;
00096 }
00097 }
00098 }
00099
00100 void
00101 TowerStatusTask::endRun(const edm::Run &, const edm::EventSetup &)
00102 {
00103 if(doDAQInfo_) runOnTowerStatus(daqRunStatus_, 0);
00104 if(doDCSInfo_) runOnTowerStatus(dcsRunStatus_, 1);
00105 }
00106
00107 void
00108 TowerStatusTask::beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &_es)
00109 {
00110 edm::ESHandle<EcalDAQTowerStatus> daqHndl;
00111 if(doDAQInfo_){
00112 _es.get<EcalDAQTowerStatusRcd>().get(daqHndl);
00113 if (!daqHndl.isValid()){
00114 edm::LogWarning("EventSetup") << "EcalDAQTowerStatus record not valid";
00115 return;
00116 }
00117 }
00118
00119 edm::ESHandle<EcalDCSTowerStatus> dcsHndl;
00120 if(doDCSInfo_){
00121 _es.get<EcalDCSTowerStatusRcd>().get(dcsHndl);
00122 if (!dcsHndl.isValid()){
00123 edm::LogWarning("EventSetup") << "EcalDCSTowerStatus record not valid";
00124 return;
00125 }
00126 }
00127
00128 for(unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++){
00129 EcalTrigTowerDetId ttid(EcalTrigTowerDetId::detIdFromDenseIndex(id));
00130 if(doDAQInfo_){
00131 uint16_t status(daqHndl->barrel(id).getStatusCode());
00132 if(status != 0){
00133 daqLumiStatus_[ttid.rawId()] = false;
00134 daqRunStatus_[ttid.rawId()] = false;
00135 }
00136 }
00137 if(doDCSInfo_){
00138 uint16_t status(dcsHndl->barrel(id).getStatusCode());
00139 if(status != 0){
00140 dcsLumiStatus_[ttid.rawId()] = false;
00141 dcsRunStatus_[ttid.rawId()] = false;
00142 }
00143 }
00144 }
00145
00146 for(unsigned id(0); id < EcalScDetId::kSizeForDenseIndexing; id++){
00147 EcalScDetId scid(EcalScDetId::unhashIndex(id));
00148 if(doDAQInfo_){
00149 uint16_t status(daqHndl->endcap(id).getStatusCode());
00150 if(status != 0){
00151 daqLumiStatus_[scid.rawId()] = false;
00152 daqRunStatus_[scid.rawId()] = false;
00153 }
00154 }
00155 if(doDCSInfo_){
00156 uint16_t status(dcsHndl->endcap(id).getStatusCode());
00157 if(status != 0){
00158 dcsLumiStatus_[scid.rawId()] = false;
00159 dcsRunStatus_[scid.rawId()] = false;
00160 }
00161 }
00162 }
00163 }
00164
00165 void
00166 TowerStatusTask::endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
00167 {
00168 if(doDAQInfo_) runOnTowerStatus(daqLumiStatus_, 0);
00169 if(doDCSInfo_) runOnTowerStatus(dcsLumiStatus_, 1);
00170 }
00171
00172 void
00173 TowerStatusTask::runOnTowerStatus(const std::map<uint32_t, bool>& _status, int _type)
00174 {
00175 if(!initialized_) return;
00176
00177 std::vector<int> activeChannels(54, 0);
00178
00179 unsigned summary, summaryMap, contents;
00180 if(_type == 0){
00181 summary = kDAQSummary;
00182 summaryMap = kDAQSummaryMap;
00183 contents = kDAQContents;
00184 }
00185 else{
00186 summary = kDCSSummary;
00187 summaryMap = kDCSSummaryMap;
00188 contents = kDCSContents;
00189 }
00190
00191 MEs_[summaryMap]->reset();
00192
00193 for(std::map<uint32_t, bool>::const_iterator stItr(_status.begin()); stItr != _status.end(); ++stItr){
00194 DetId id(stItr->first);
00195 bool status(stItr->second);
00196
00197 std::cout.flush();
00198 MEs_[summaryMap]->setBinContent(id, status ? 1. : 0.);
00199
00200 if(status){
00201 if(id.subdetId() == EcalTriggerTower)
00202 activeChannels[dccId(id) - 1] += 25;
00203 else{
00204 int dccid(dccId(id));
00205 int towerid(towerId(id));
00206 activeChannels[dccId(id) - 1] += getElectronicsMap()->dccTowerConstituents(dccid, towerid).size();
00207 }
00208 }
00209 }
00210
00211 int totalActive(0);
00212 for(unsigned iDCC(0); iDCC < 54; iDCC++){
00213 float fraction(float(activeChannels[iDCC]) / float(getElectronicsMap()->dccConstituents(iDCC + 1).size()));
00214 MEs_[contents]->fill(iDCC + 1, fraction);
00215 totalActive += activeChannels[iDCC];
00216 }
00217
00218 MEs_[summary]->fill(float(totalActive) / float(EBDetId::kSizeForDenseIndexing + EEDetId::kSizeForDenseIndexing));
00219 }
00220
00221
00222 void
00223 TowerStatusTask::setMEData(std::vector<MEData>& _data)
00224 {
00225 _data[kDAQSummary] = MEData("DAQSummary", BinService::kEcal, BinService::kReport, MonitorElement::DQM_KIND_REAL);
00226 _data[kDAQSummaryMap] = MEData("DAQSummaryMap", BinService::kEcal, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F);
00227 _data[kDAQContents] = MEData("DAQContents", BinService::kSM, BinService::kReport, MonitorElement::DQM_KIND_REAL);
00228 _data[kDCSSummary] = MEData("DCSSummary", BinService::kEcal, BinService::kReport, MonitorElement::DQM_KIND_REAL);
00229 _data[kDCSSummaryMap] = MEData("DCSSummaryMap", BinService::kEcal, BinService::kSuperCrystal, MonitorElement::DQM_KIND_TH2F);
00230 _data[kDCSContents] = MEData("DCSContents", BinService::kSM, BinService::kReport, MonitorElement::DQM_KIND_REAL);
00231 }
00232
00233 DEFINE_ECALDQM_WORKER(TowerStatusTask);
00234 }
00235
00236