CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TowerStatusTask.cc
Go to the documentation of this file.
1 #include "../interface/TowerStatusTask.h"
2 
6 
11 
16 
18 
19 namespace ecaldqm {
20 
22  DQWorkerTask(_params, _paths, "TowerStatusTask"),
23  daqLumiStatus_(),
24  daqRunStatus_(),
25  dcsLumiStatus_(),
26  dcsRunStatus_(),
27  doDAQInfo_(false),
28  doDCSInfo_(false)
29  {
31  (0x1 << kRun) |
32  (0x1 << kLumiSection);
33 
34  edm::ParameterSet const& taskParams(_params.getUntrackedParameterSet(name_));
35 
36  doDAQInfo_ = taskParams.getUntrackedParameter<bool>("doDAQInfo");
37  doDCSInfo_ = taskParams.getUntrackedParameter<bool>("doDCSInfo");
38 
39  if(!doDAQInfo_ && !doDCSInfo_)
40  throw cms::Exception("InvalidConfiguration") << "Nonthing to do in TowerStatusTask";
41  }
42 
44  {
45  }
46 
47  void
49  {
50  }
51 
52  void
54  {
55  if(doDAQInfo_){
56  MEs_[kDAQSummary]->book();
57  MEs_[kDAQSummaryMap]->book();
58  MEs_[kDAQContents]->book();
59 
60  MEs_[kDAQSummaryMap]->resetAll(-1.);
61  }
62  if(doDCSInfo_){
63  MEs_[kDCSSummary]->book();
64  MEs_[kDCSSummaryMap]->book();
65  MEs_[kDCSContents]->book();
66 
67  MEs_[kDCSSummaryMap]->resetAll(-1.);
68  }
69 
70  daqLumiStatus_.clear();
71  daqRunStatus_.clear();
72  dcsLumiStatus_.clear();
73  dcsRunStatus_.clear();
74 
75  for(unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++){
77  if(doDAQInfo_){
78  daqLumiStatus_[ttid.rawId()] = true;
79  daqRunStatus_[ttid.rawId()] = true;
80  }
81  if(doDCSInfo_){
82  dcsLumiStatus_[ttid.rawId()] = true;
83  dcsRunStatus_[ttid.rawId()] = true;
84  }
85  }
86 
87  for(unsigned id(0); id < EcalScDetId::kSizeForDenseIndexing; id++){
89  if(doDAQInfo_){
90  daqLumiStatus_[scid.rawId()] = true;
91  daqRunStatus_[scid.rawId()] = true;
92  }
93  if(doDCSInfo_){
94  dcsLumiStatus_[scid.rawId()] = true;
95  dcsRunStatus_[scid.rawId()] = true;
96  }
97  }
98  }
99 
100  void
102  {
105  }
106 
107  void
109  {
111  if(doDAQInfo_){
112  _es.get<EcalDAQTowerStatusRcd>().get(daqHndl);
113  if (!daqHndl.isValid()){
114  edm::LogWarning("EventSetup") << "EcalDAQTowerStatus record not valid";
115  return;
116  }
117  }
118 
120  if(doDCSInfo_){
121  _es.get<EcalDCSTowerStatusRcd>().get(dcsHndl);
122  if (!dcsHndl.isValid()){
123  edm::LogWarning("EventSetup") << "EcalDCSTowerStatus record not valid";
124  return;
125  }
126  }
127 
128  for(unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++){
130  if(doDAQInfo_){
131  uint16_t status(daqHndl->barrel(id).getStatusCode());
132  if(status != 0){
133  daqLumiStatus_[ttid.rawId()] = false;
134  daqRunStatus_[ttid.rawId()] = false;
135  }
136  }
137  if(doDCSInfo_){
138  uint16_t status(dcsHndl->barrel(id).getStatusCode());
139  if(status != 0){
140  dcsLumiStatus_[ttid.rawId()] = false;
141  dcsRunStatus_[ttid.rawId()] = false;
142  }
143  }
144  }
145 
146  for(unsigned id(0); id < EcalScDetId::kSizeForDenseIndexing; id++){
148  if(doDAQInfo_){
149  uint16_t status(daqHndl->endcap(id).getStatusCode());
150  if(status != 0){
151  daqLumiStatus_[scid.rawId()] = false;
152  daqRunStatus_[scid.rawId()] = false;
153  }
154  }
155  if(doDCSInfo_){
156  uint16_t status(dcsHndl->endcap(id).getStatusCode());
157  if(status != 0){
158  dcsLumiStatus_[scid.rawId()] = false;
159  dcsRunStatus_[scid.rawId()] = false;
160  }
161  }
162  }
163  }
164 
165  void
167  {
170  }
171 
172  void
173  TowerStatusTask::runOnTowerStatus(const std::map<uint32_t, bool>& _status, int _type)
174  {
175  if(!initialized_) return;
176 
177  std::vector<int> activeChannels(54, 0);
178 
179  unsigned summary, summaryMap, contents;
180  if(_type == 0){
181  summary = kDAQSummary;
182  summaryMap = kDAQSummaryMap;
183  contents = kDAQContents;
184  }
185  else{
186  summary = kDCSSummary;
187  summaryMap = kDCSSummaryMap;
188  contents = kDCSContents;
189  }
190 
191  MEs_[summaryMap]->reset();
192 
193  for(std::map<uint32_t, bool>::const_iterator stItr(_status.begin()); stItr != _status.end(); ++stItr){
194  DetId id(stItr->first);
195  bool status(stItr->second);
196 
197  std::cout.flush();
198  MEs_[summaryMap]->setBinContent(id, status ? 1. : 0.);
199 
200  if(status){
201  if(id.subdetId() == EcalTriggerTower)
202  activeChannels[dccId(id) - 1] += 25;
203  else{
204  int dccid(dccId(id));
205  int towerid(towerId(id));
206  activeChannels[dccId(id) - 1] += getElectronicsMap()->dccTowerConstituents(dccid, towerid).size();
207  }
208  }
209  }
210 
211  int totalActive(0);
212  for(unsigned iDCC(0); iDCC < 54; iDCC++){
213  float fraction(float(activeChannels[iDCC]) / float(getElectronicsMap()->dccConstituents(iDCC + 1).size()));
214  MEs_[contents]->fill(iDCC + 1, fraction);
215  totalActive += activeChannels[iDCC];
216  }
217 
218  MEs_[summary]->fill(float(totalActive) / float(EBDetId::kSizeForDenseIndexing + EEDetId::kSizeForDenseIndexing));
219  }
220 
221  /*static*/
222  void
223  TowerStatusTask::setMEData(std::vector<MEData>& _data)
224  {
231  }
232 
234 }
235 
236 
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
static void setMEData(std::vector< MEData > &)
const EcalElectronicsMapping * getElectronicsMap()
TowerStatusTask(const edm::ParameterSet &, const edm::ParameterSet &)
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:118
unsigned dccId(const DetId &)
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
void endRun(const edm::Run &, const edm::EventSetup &) override
std::map< uint32_t, bool > daqLumiStatus_
std::map< uint32_t, bool > dcsRunStatus_
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
unsigned towerId(const DetId &)
std::map< uint32_t, bool > daqRunStatus_
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition: DetId.h:18
std::vector< MESet * > MEs_
Definition: DQWorker.h:56
void runOnTowerStatus(const std::map< uint32_t, bool > &, int)
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121
std::map< uint32_t, bool > dcsLumiStatus_
DEFINE_ECALDQM_WORKER(CertificationClient)
volatile std::atomic< bool > shutdown_flag false
tuple status
Definition: ntuplemaker.py:245
bool isValid() const
Definition: ESHandle.h:37
tuple size
Write out results.
std::string name_
Definition: DQWorker.h:55
Definition: Run.h:41
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
std::vector< DetId > dccTowerConstituents(int dccId, int tower) const
Get the constituent detids for this dccId.