CMS 3D CMS Logo

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