CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ESDaqInfoTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 
7 
10 
12 
16 
18 
20 
22 
24 
25 using namespace cms;
26 using namespace edm;
27 using namespace std;
28 
30  dqmStore_ = Service<DQMStore>().operator->();
31  runInfoToken_ = esConsumes<edm::Transition::BeginLuminosityBlock>();
32  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
33 
34  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
35 
36  ESFedRangeMin_ = ps.getUntrackedParameter<int>("ESFedRangeMin", 520);
37  ESFedRangeMax_ = ps.getUntrackedParameter<int>("ESFedRangeMax", 575);
38 
39  meESDaqFraction_ = nullptr;
40  meESDaqActiveMap_ = nullptr;
41  meESDaqError_ = nullptr;
42 
43  for (int i = 0; i < 56; i++) {
44  meESDaqActive_[i] = nullptr;
45  }
46 
47  if (ps.exists("esMapping")) {
48  edm::ParameterSet esMap = ps.getParameter<edm::ParameterSet>("esMapping");
49  es_mapping_ = new ESElectronicsMapper(esMap);
50  } else {
51  edm::LogError("ESDaqInfoTask") << "preshower mapping pointer not initialized. Temporary.";
52  es_mapping_ = nullptr;
53  }
54 }
55 
56 ESDaqInfoTask::~ESDaqInfoTask() { delete es_mapping_; }
57 
59  char histo[200];
60 
61  if (dqmStore_) {
62  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
63 
64  sprintf(histo, "DAQSummary");
65  meESDaqFraction_ = dqmStore_->bookFloat(histo);
66  meESDaqFraction_->Fill(0.0);
67 
68  sprintf(histo, "DAQSummaryMap");
69  meESDaqActiveMap_ = dqmStore_->book2D(histo, histo, 80, 0.5, 80.5, 80, 0.5, 80.5);
70  meESDaqActiveMap_->setAxisTitle("Si X", 1);
71  meESDaqActiveMap_->setAxisTitle("Si Y", 2);
72 
73  dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
74 
75  for (int i = 0; i < 56; i++) {
76  sprintf(histo, "EcalPreshower_%d", ESFedRangeMin_ + i);
77  meESDaqActive_[i] = dqmStore_->bookFloat(histo);
78  meESDaqActive_[i]->Fill(0.0);
79 
80  ESOnFed_[i] = false;
81  for (int x = 0; x < 80; x++) {
82  for (int y = 0; y < 80; y++) {
83  if (getFEDNumber(x, y) == ESFedRangeMin_ + i) {
84  ESOnFed_[i] = true;
85  break;
86  }
87  }
88  if (ESOnFed_[i] == true)
89  break;
90  }
91  }
92 
93  dqmStore_->setCurrentFolder(prefixME_ + "/ESIntegrityTask");
94  sprintf(histo, "DAQError");
95  meESDaqError_ = dqmStore_->book1D(histo, histo, 56, ESFedRangeMin_ - 0.5, ESFedRangeMax_ + 0.5);
96  meESDaqError_->setAxisTitle("FedID", 1);
97  }
98 }
99 
101 
103  this->reset();
104 
105  for (int x = 0; x < 80; ++x) {
106  for (int y = 0; y < 80; ++y) {
107  if (getFEDNumber(x, y) > 0)
108  meESDaqActiveMap_->setBinContent(x + 1, y + 1, 0.0);
109  else
110  meESDaqActiveMap_->setBinContent(x + 1, y + 1, -1.0);
111  }
112  }
113 
114  for (int i = 0; i < 56; i++) {
115  if (meESDaqError_)
116  meESDaqError_->setBinContent(i, 0.0);
117  }
118 
119  if (auto runInfoRec = iSetup.tryToGet<RunInfoRcd>()) {
120  const auto& sumFED = runInfoRec->getHandle(runInfoToken_);
121 
122  std::vector<int> FedsInIds = sumFED->m_fed_in;
123 
124  float ESFedCount = 0.;
125 
126  for (unsigned int fedItr = 0; fedItr < FedsInIds.size(); ++fedItr) {
127  int fedID = FedsInIds[fedItr];
128 
129  if (fedID >= ESFedRangeMin_ && fedID <= ESFedRangeMax_) {
130  if (ESOnFed_[fedID - ESFedRangeMin_])
131  ESFedCount++;
132 
133  if (meESDaqActive_[fedID - ESFedRangeMin_])
134  meESDaqActive_[fedID - ESFedRangeMin_]->Fill(1.0);
135 
136  if (meESDaqActiveMap_) {
137  for (int x = 0; x < 80; x++) {
138  for (int y = 0; y < 80; y++) {
139  if (fedID == getFEDNumber(x, y))
140  meESDaqActiveMap_->setBinContent(x + 1, y + 1, 1.0);
141  }
142  }
143  }
144 
145  if (meESDaqFraction_)
146  meESDaqFraction_->Fill(ESFedCount / 40.);
147 
148  if (meESDaqError_) {
149  for (int i = 0; i < 56; i++) {
150  if (ESOnFed_[fedID - ESFedRangeMin_])
151  meESDaqError_->setBinContent(i + 1, 1.0);
152  else
153  meESDaqError_->setBinContent(i + 1, 2.0);
154  }
155  }
156  }
157  }
158 
159  } else {
160  LogWarning("ESDaqInfoTask") << "Cannot find any RunInfoRcd" << endl;
161  }
162 }
163 
165  if (meESDaqFraction_)
166  meESDaqFraction_->Reset();
167 
168  for (int i = 0; i < 56; i++) {
169  if (meESDaqActive_[i])
170  meESDaqActive_[i]->Reset();
171  }
172 
173  if (meESDaqActiveMap_)
174  meESDaqActiveMap_->Reset();
175 
176  if (meESDaqError_)
177  meESDaqError_->Reset();
178 }
179 
180 void ESDaqInfoTask::analyze(const Event& e, const EventSetup& c) {}
181 
void endJob(void) override
EndJob.
T getUntrackedParameter(std::string const &, T const &) const
std::optional< T > tryToGet() const
Definition: EventSetup.h:103
const edm::EventSetup & c
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool exists(std::string const &parameterName) const
checks if a parameter exists
void beginJob(void) override
BeginJob.
Log< level::Error, false > LogError
~ESDaqInfoTask() override
Destructor.
void reset(void)
Reset.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
void beginLuminosityBlock(const edm::LuminosityBlock &lumiBlock, const edm::EventSetup &iSetup) override
BeginLuminosityBlock.
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Log< level::Warning, false > LogWarning
void reset(double vett[256])
Definition: TPedValues.cc:11
ESDaqInfoTask(const edm::ParameterSet &ps)
Constructor.