-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
RawDataTask.cc
237 lines (198 loc) · 8.05 KB
/
RawDataTask.cc
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#include "DQM/EcalMonitorTasks/interface/RawDataTask.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
#include "DQM/EcalCommon/interface/FEFlags.h"
#include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
namespace ecaldqm {
RawDataTask::RawDataTask()
: DQWorkerTask(), runNumber_(0), l1A_(0), orbit_(0), bx_(0), triggerType_(0), feL1Offset_(0) {}
void RawDataTask::addDependencies(DependencySet& _dependencies) {
_dependencies.push_back(Dependency(kEcalRawData, kSource));
}
void RawDataTask::beginRun(edm::Run const& _run, edm::EventSetup const&) { runNumber_ = _run.run(); }
void RawDataTask::beginEvent(edm::Event const& _evt, edm::EventSetup const&, bool const& ByLumiResetSwitch, bool&) {
orbit_ = _evt.orbitNumber() & 0xffffffff;
bx_ = _evt.bunchCrossing() & 0xfff;
triggerType_ = _evt.experimentType() & 0xf;
l1A_ = 0;
feL1Offset_ = _evt.isRealData() ? 1 : 0;
if (ByLumiResetSwitch) {
MEs_.at("DesyncByLumi").reset();
MEs_.at("FEByLumi").reset();
MEs_.at("FEStatusErrMapByLumi").reset();
}
}
void RawDataTask::runOnSource(FEDRawDataCollection const& _fedRaw) {
MESet& meCRC(MEs_.at("CRC"));
// Get GT L1 info
const FEDRawData& gtFED(_fedRaw.FEDData(812));
if (gtFED.size() > sizeof(uint64_t)) { // FED header is one 64 bit word
const uint32_t* halfHeader = reinterpret_cast<const uint32_t*>(gtFED.data());
l1A_ = *(halfHeader + 1) & 0xffffff;
}
for (int iFED(601); iFED <= 654; iFED++) {
const FEDRawData& fedData(_fedRaw.FEDData(iFED));
unsigned length(fedData.size() / sizeof(uint64_t));
if (length > 1) { // FED header is one 64 bit word
const uint64_t* pData(reinterpret_cast<uint64_t const*>(fedData.data()));
if ((pData[length - 1] & 0x4) != 0)
meCRC.fill(iFED - 600);
}
}
}
void RawDataTask::runOnRawData(EcalRawDataCollection const& _dcchs) {
using namespace std;
MESet& meRunNumber(MEs_.at("RunNumber"));
MESet& meOrbit(MEs_.at("Orbit"));
MESet& meOrbitDiff(MEs_.at("OrbitDiff"));
MESet& meTriggerType(MEs_.at("TriggerType"));
MESet& meL1ADCC(MEs_.at("L1ADCC"));
MESet& meBXDCC(MEs_.at("BXDCC"));
MESet& meBXDCCDiff(MEs_.at("BXDCCDiff"));
MESet& meBXFE(MEs_.at("BXFE"));
MESet& meBXFEDiff(MEs_.at("BXFEDiff"));
MESet& meBXFEInvalid(MEs_.at("BXFEInvalid"));
MESet& meL1AFE(MEs_.at("L1AFE"));
MESet& meFEStatus(MEs_.at("FEStatus"));
MESet& meFEStatusErrMapByLumi(MEs_.at("FEStatusErrMapByLumi"));
MESet& meDesyncByLumi(MEs_.at("DesyncByLumi"));
MESet& meDesyncTotal(MEs_.at("DesyncTotal"));
MESet& meFEByLumi(MEs_.at("FEByLumi"));
MESet& meBXTCC(MEs_.at("BXTCC"));
MESet& meL1ATCC(MEs_.at("L1ATCC"));
MESet& meBXSRP(MEs_.at("BXSRP"));
MESet& meL1ASRP(MEs_.at("L1ASRP"));
MESet& meTrendNSyncErrors(MEs_.at("L1ATCC"));
MESet& meEventTypePreCalib(MEs_.at("EventTypePreCalib"));
MESet& meEventTypeCalib(MEs_.at("EventTypeCalib"));
MESet& meEventTypePostCalib(MEs_.at("EventTypePostCalib"));
if (!l1A_) {
// majority vote on L1A.. is there no better implementation?
map<int, int> l1aCounts;
for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr) {
l1aCounts[dcchItr->getLV1()]++;
}
int maxVote(0);
for (map<int, int>::iterator l1aItr(l1aCounts.begin()); l1aItr != l1aCounts.end(); ++l1aItr) {
if (l1aItr->second > maxVote) {
maxVote = l1aItr->second;
l1A_ = l1aItr->first;
}
}
}
for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr) {
int dccId(dcchItr->id());
int dccL1A(dcchItr->getLV1());
short dccL1AShort(dccL1A & 0xfff);
int dccBX(dcchItr->getBX());
meOrbitDiff.fill(dccId, dcchItr->getOrbit() - orbit_);
meBXDCCDiff.fill(dccId, dccBX - bx_);
if (dccBX == -1)
meBXFEInvalid.fill(dccId, 68.5);
if (dcchItr->getRunNumber() != int(runNumber_))
meRunNumber.fill(dccId);
if (dcchItr->getOrbit() != orbit_)
meOrbit.fill(dccId);
if (dcchItr->getBasicTriggerType() != triggerType_)
meTriggerType.fill(dccId);
if (dccL1A != l1A_)
meL1ADCC.fill(dccId);
if (dccBX != bx_)
meBXDCC.fill(dccId);
const vector<short>& feStatus(dcchItr->getFEStatus());
const vector<short>& feBxs(dcchItr->getFEBxs());
const vector<short>& feL1s(dcchItr->getFELv1());
double feDesync(0.);
double statusError(0.);
for (unsigned iFE(0); iFE < feStatus.size(); iFE++) {
if (!ccuExists(dccId, iFE + 1))
continue;
short status(feStatus[iFE]);
if (feBxs[iFE] != -1 && dccBX != -1) {
meBXFEDiff.fill(dccId, feBxs[iFE] - dccBX);
}
if (feBxs[iFE] == -1)
meBXFEInvalid.fill(dccId, iFE + 0.5);
if (status != BXDesync && status != L1ABXDesync) { // BX desync not detected in the DCC
if (feBxs[iFE] != dccBX && feBxs[iFE] != -1 && dccBX != -1) {
meBXFE.fill(dccId, iFE + 0.5);
feDesync += 1.;
}
}
if (status != L1ADesync && status != L1ABXDesync) {
if (feL1s[iFE] + feL1Offset_ != dccL1AShort && feL1s[iFE] != -1 && dccL1AShort != 0) {
meL1AFE.fill(dccId, iFE + 0.5);
feDesync += 1.;
}
}
if (iFE >= 68)
continue;
DetId id(getElectronicsMap()->dccTowerConstituents(dccId, iFE + 1).at(0));
meFEStatus.fill(id, status);
// Fill FE Status Error Map with error states only
if (status != Enabled && status != Suppressed && status != FIFOFull && status != FIFOFullL1ADesync &&
status != ForcedZS)
meFEStatusErrMapByLumi.fill(id, status);
switch (status) {
case Timeout:
case HeaderError:
case ChannelId:
case LinkError:
case BlockSize:
case L1ADesync:
case BXDesync:
case L1ABXDesync:
case HParity:
case VParity:
statusError += 1.;
break;
default:
continue;
}
}
if (feDesync > 0.) {
meDesyncByLumi.fill(dccId, feDesync);
meDesyncTotal.fill(dccId, feDesync);
meTrendNSyncErrors.fill(double(timestamp_.iLumi), feDesync);
}
if (statusError > 0.)
meFEByLumi.fill(dccId, statusError);
const vector<short>& tccBx(dcchItr->getTCCBx());
const vector<short>& tccL1(dcchItr->getTCCLv1());
if (tccBx.size() == 4) { // EB uses tccBx[0]; EE uses all
if (dccId <= kEEmHigh + 1 || dccId >= kEEpLow + 1) {
for (int iTCC(0); iTCC < 4; iTCC++) {
if (tccBx[iTCC] != dccBX && tccBx[iTCC] != -1 && dccBX != -1)
meBXTCC.fill(dccId);
if (tccL1[iTCC] != dccL1AShort && tccL1[iTCC] != -1 && dccL1AShort != 0)
meL1ATCC.fill(dccId);
}
} else {
if (tccBx[0] != dccBX && tccBx[0] != -1 && dccBX != -1)
meBXTCC.fill(dccId);
if (tccL1[0] != dccL1AShort && tccL1[0] != -1 && dccL1AShort != 0)
meL1ATCC.fill(dccId);
}
}
short srpBx(dcchItr->getSRPBx());
short srpL1(dcchItr->getSRPLv1());
if (srpBx != dccBX && srpBx != -1 && dccBX != -1)
meBXSRP.fill(dccId);
if (srpL1 != dccL1AShort && srpL1 != -1 && dccL1AShort != 0)
meL1ASRP.fill(dccId);
const int calibBX(3490);
short runType(dcchItr->getRunType() + 1);
if (runType < 0 || runType > 22)
runType = 0;
if (dccBX < calibBX)
meEventTypePreCalib.fill(dccId, runType, 1. / 54.);
else if (dccBX == calibBX)
meEventTypeCalib.fill(dccId, runType, 1. / 54.);
else
meEventTypePostCalib.fill(dccId, runType, 1. / 54.);
}
}
DEFINE_ECALDQM_WORKER(RawDataTask);
} // namespace ecaldqm