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 
7 
12 
17 
19 
20 namespace ecaldqm {
21 
23  DQWorkerTask(),
24  doDAQInfo_(false),
25  doDCSInfo_(false)
26  {
27  }
28 
29  void
31  {
32  doDAQInfo_ = _params.getUntrackedParameter<bool>("doDAQInfo");
33  doDCSInfo_ = _params.getUntrackedParameter<bool>("doDCSInfo");
34 
35  if(doDAQInfo_ && doDCSInfo_) return;
36  if(doDAQInfo_){
37  MEs_.erase(std::string("DCSSummary"));
38  MEs_.erase(std::string("DCSSummaryMap"));
39  MEs_.erase(std::string("DCSContents"));
40  }
41  else if(doDCSInfo_){
42  MEs_.erase(std::string("DAQSummary"));
43  MEs_.erase(std::string("DAQSummaryMap"));
44  MEs_.erase(std::string("DAQContents"));
45  }
46  else
47  throw cms::Exception("InvalidConfiguration") << "Nothing to do in TowerStatusTask";
48  }
49 
50  void
52  {
53  if(doDAQInfo_){
54  float status[nDCC];
55  std::fill_n(status, nDCC, 1.);
56 
58  _es.get<EcalDAQTowerStatusRcd>().get(daqHndl);
59  if(daqHndl.isValid()){
60  for(unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++){
61  if(daqHndl->barrel(id).getStatusCode() != 0){
63  status[dccId(ttid) - 1] -= 25. / 1700.;
64  }
65  }
66  for(unsigned id(0); id < EcalScDetId::kSizeForDenseIndexing; id++){
67  if(daqHndl->endcap(id).getStatusCode() != 0){
69  unsigned dccid(dccId(scid));
70  status[dccid - 1] -= double(scConstituents(scid).size()) / nCrystals(dccid);
71  }
72  }
73 
74  runOnTowerStatus(status, DAQInfo);
75  }
76  else
77  edm::LogWarning("EventSetup") << "EcalDAQTowerStatus record not valid";
78  }
79 
80  if(doDCSInfo_){
81  float status[nDCC];
82  std::fill_n(status, nDCC, 1.);
83 
85  _es.get<EcalDCSTowerStatusRcd>().get(dcsHndl);
86  if(dcsHndl.isValid()){
87  for(unsigned id(0); id < EcalTrigTowerDetId::kEBTotalTowers; id++){
88  if(dcsHndl->barrel(id).getStatusCode() != 0){
90  status[dccId(ttid) - 1] -= 25. / 1700.;
91  }
92  }
93  for(unsigned id(0); id < EcalScDetId::kSizeForDenseIndexing; id++){
94  if(dcsHndl->endcap(id).getStatusCode() != 0){
96  unsigned dccid(dccId(scid));
97  status[dccid - 1] -= double(scConstituents(scid).size()) / nCrystals(dccid);
98  }
99  }
100 
101  runOnTowerStatus(status, DCSInfo);
102  }
103  else
104  edm::LogWarning("EventSetup") << "EcalDCSTowerStatus record not valid";
105  }
106  }
107 
108  void
109  TowerStatusTask::runOnTowerStatus(float const* _status, InfoType _type)
110  {
111  MESet* meSummary(0);
112  MESet* meSummaryMap(0);
113  MESet* meContents(0);
114  if(_type == DAQInfo){
115  meSummary = &MEs_.at("DAQSummary");
116  meSummaryMap = &MEs_.at("DAQSummaryMap");
117  meContents = &MEs_.at("DAQContents");
118  }
119  else{
120  meSummary = &MEs_.at("DCSSummary");
121  meSummaryMap = &MEs_.at("DCSSummaryMap");
122  meContents = &MEs_.at("DCSContents");
123  }
124 
125  meSummary->reset(-1.);
126  meSummaryMap->resetAll(-1.);
127  meSummaryMap->reset();
128  meContents->reset(-1.);
129 
130  float totalFraction(0.);
131  for(int iDCC(0); iDCC < nDCC; iDCC++){
132  meSummaryMap->setBinContent(iDCC + 1, _status[iDCC]);
133  meContents->fill(iDCC + 1, _status[iDCC]);
134  totalFraction += _status[iDCC] / nCrystals(iDCC + 1);
135  }
136 
137  meSummary->fill(totalFraction);
138  }
139 
141 }
142 
143 
T getUntrackedParameter(std::string const &, T const &) const
static EcalTrigTowerDetId detIdFromDenseIndex(uint32_t di)
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
static EcalScDetId unhashIndex(int hi)
Definition: EcalScDetId.h:118
virtual void setBinContent(DetId const &, double)
Definition: MESet.h:52
DEFINE_ECALDQM_WORKER(CalibrationSummaryClient)
void setParams(edm::ParameterSet const &) override
unsigned nCrystals(unsigned)
virtual void reset(double=0., double=0., double=0.)
Definition: MESet.cc:110
void runOnTowerStatus(float const *, InfoType)
const T & get() const
Definition: EventSetup.h:55
virtual void fill(DetId const &, double=1., double=1., double=1.)
Definition: MESet.h:47
MESetCollection MEs_
Definition: DQWorker.h:76
virtual void resetAll(double=0., double=0., double=0.)
Definition: MESet.cc:118
std::vector< DetId > scConstituents(EcalScDetId const &)
volatile std::atomic< bool > shutdown_flag false
tuple status
Definition: ntuplemaker.py:245
bool isValid() const
Definition: ESHandle.h:37
unsigned dccId(DetId const &)
tuple size
Write out results.