1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
#include <iostream>
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include <DataFormats/EcalDetId/interface/ESDetId.h>
#include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
#include "CondFormats/RunInfo/interface/RunSummary.h"
#include "CondFormats/RunInfo/interface/RunInfo.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
#include "Geometry/EcalMapping/interface/ESElectronicsMapper.h"
#include "DQM/EcalPreshowerMonitorModule/interface/ESDaqInfoTask.h"
using namespace cms;
using namespace edm;
using namespace std;
ESDaqInfoTask::ESDaqInfoTask(const ParameterSet& ps) {
usesResource("DQMStore");
dqmStore_ = Service<DQMStore>().operator->();
runInfoToken_ = esConsumes<edm::Transition::BeginLuminosityBlock>();
prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
ESFedRangeMin_ = ps.getUntrackedParameter<int>("ESFedRangeMin", 520);
ESFedRangeMax_ = ps.getUntrackedParameter<int>("ESFedRangeMax", 575);
meESDaqFraction_ = nullptr;
meESDaqActiveMap_ = nullptr;
meESDaqError_ = nullptr;
for (int i = 0; i < 56; i++) {
meESDaqActive_[i] = nullptr;
}
if (ps.exists("esMapping")) {
edm::ParameterSet esMap = ps.getParameter<edm::ParameterSet>("esMapping");
es_mapping_ = new ESElectronicsMapper(esMap);
} else {
edm::LogError("ESDaqInfoTask") << "preshower mapping pointer not initialized. Temporary.";
es_mapping_ = nullptr;
}
}
ESDaqInfoTask::~ESDaqInfoTask() { delete es_mapping_; }
void ESDaqInfoTask::beginJob(void) {
char histo[200];
if (dqmStore_) {
dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo");
sprintf(histo, "DAQSummary");
meESDaqFraction_ = dqmStore_->bookFloat(histo);
meESDaqFraction_->Fill(0.0);
sprintf(histo, "DAQSummaryMap");
meESDaqActiveMap_ = dqmStore_->book2D(histo, histo, 80, 0.5, 80.5, 80, 0.5, 80.5);
meESDaqActiveMap_->setAxisTitle("Si X", 1);
meESDaqActiveMap_->setAxisTitle("Si Y", 2);
dqmStore_->setCurrentFolder(prefixME_ + "/EventInfo/DAQContents");
for (int i = 0; i < 56; i++) {
sprintf(histo, "EcalPreshower_%d", ESFedRangeMin_ + i);
meESDaqActive_[i] = dqmStore_->bookFloat(histo);
meESDaqActive_[i]->Fill(0.0);
ESOnFed_[i] = false;
for (int x = 0; x < 80; x++) {
for (int y = 0; y < 80; y++) {
if (getFEDNumber(x, y) == ESFedRangeMin_ + i) {
ESOnFed_[i] = true;
break;
}
}
if (ESOnFed_[i] == true)
break;
}
}
dqmStore_->setCurrentFolder(prefixME_ + "/ESIntegrityTask");
sprintf(histo, "DAQError");
meESDaqError_ = dqmStore_->book1D(histo, histo, 56, ESFedRangeMin_ - 0.5, ESFedRangeMax_ + 0.5);
meESDaqError_->setAxisTitle("FedID", 1);
}
}
void ESDaqInfoTask::endJob(void) {}
void ESDaqInfoTask::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& iSetup) {
this->reset();
for (int x = 0; x < 80; ++x) {
for (int y = 0; y < 80; ++y) {
if (getFEDNumber(x, y) > 0)
meESDaqActiveMap_->setBinContent(x + 1, y + 1, 0.0);
else
meESDaqActiveMap_->setBinContent(x + 1, y + 1, -1.0);
}
}
for (int i = 0; i < 56; i++) {
if (meESDaqError_)
meESDaqError_->setBinContent(i, 0.0);
}
if (auto runInfoRec = iSetup.tryToGet<RunInfoRcd>()) {
const auto& sumFED = runInfoRec->getHandle(runInfoToken_);
std::vector<int> FedsInIds = sumFED->m_fed_in;
float ESFedCount = 0.;
for (unsigned int fedItr = 0; fedItr < FedsInIds.size(); ++fedItr) {
int fedID = FedsInIds[fedItr];
if (fedID >= ESFedRangeMin_ && fedID <= ESFedRangeMax_) {
if (ESOnFed_[fedID - ESFedRangeMin_])
ESFedCount++;
if (meESDaqActive_[fedID - ESFedRangeMin_])
meESDaqActive_[fedID - ESFedRangeMin_]->Fill(1.0);
if (meESDaqActiveMap_) {
for (int x = 0; x < 80; x++) {
for (int y = 0; y < 80; y++) {
if (fedID == getFEDNumber(x, y))
meESDaqActiveMap_->setBinContent(x + 1, y + 1, 1.0);
}
}
}
if (meESDaqFraction_)
meESDaqFraction_->Fill(ESFedCount / 40.);
if (meESDaqError_) {
for (int i = 0; i < 56; i++) {
if (ESOnFed_[fedID - ESFedRangeMin_])
meESDaqError_->setBinContent(i + 1, 1.0);
else
meESDaqError_->setBinContent(i + 1, 2.0);
}
}
}
}
} else {
LogWarning("ESDaqInfoTask") << "Cannot find any RunInfoRcd" << endl;
}
}
void ESDaqInfoTask::endLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) {}
void ESDaqInfoTask::reset(void) {
if (meESDaqFraction_)
meESDaqFraction_->Reset();
for (int i = 0; i < 56; i++) {
if (meESDaqActive_[i])
meESDaqActive_[i]->Reset();
}
if (meESDaqActiveMap_)
meESDaqActiveMap_->Reset();
if (meESDaqError_)
meESDaqError_->Reset();
}
void ESDaqInfoTask::analyze(const Event& e, const EventSetup& c) {}
DEFINE_FWK_MODULE(ESDaqInfoTask);
|