CMS 3D CMS Logo

RawDataTask.cc
Go to the documentation of this file.
2 
6 
9 
11 
12 namespace ecaldqm {
13 
15  : DQWorkerTask(), runNumber_(0), l1A_(0), orbit_(0), bx_(0), triggerType_(0), feL1Offset_(0) {}
16 
18  _dependencies.push_back(Dependency(kEcalRawData, kSource));
19  }
20 
21  void RawDataTask::beginRun(edm::Run const& _run, edm::EventSetup const&) { runNumber_ = _run.run(); }
22 
24  // Reset by LS plots at beginning of every LS
25  MEs_.at("DesyncByLumi").reset();
26  MEs_.at("FEByLumi").reset();
27  MEs_.at("FEStatusErrMapByLumi").reset();
28  }
29 
31  orbit_ = _evt.orbitNumber() & 0xffffffff;
32  bx_ = _evt.bunchCrossing() & 0xfff;
33  triggerType_ = _evt.experimentType() & 0xf;
34  l1A_ = 0;
35  feL1Offset_ = _evt.isRealData() ? 1 : 0;
36  }
37 
39  MESet& meCRC(MEs_.at("CRC"));
40 
41  // Get GT L1 info
42  const FEDRawData& gtFED(_fedRaw.FEDData(812));
43  if (gtFED.size() > sizeof(uint64_t)) { // FED header is one 64 bit word
44  const uint32_t* halfHeader = reinterpret_cast<const uint32_t*>(gtFED.data());
45  l1A_ = *(halfHeader + 1) & 0xffffff;
46  }
47 
48  for (int iFED(601); iFED <= 654; iFED++) {
49  const FEDRawData& fedData(_fedRaw.FEDData(iFED));
50  unsigned length(fedData.size() / sizeof(uint64_t));
51  if (length > 1) { // FED header is one 64 bit word
52  const uint64_t* pData(reinterpret_cast<uint64_t const*>(fedData.data()));
53  if ((pData[length - 1] & 0x4) != 0)
54  meCRC.fill(iFED - 600);
55  }
56  }
57  }
58 
60  using namespace std;
61 
62  MESet& meRunNumber(MEs_.at("RunNumber"));
63  MESet& meOrbit(MEs_.at("Orbit"));
64  MESet& meOrbitDiff(MEs_.at("OrbitDiff"));
65  MESet& meTriggerType(MEs_.at("TriggerType"));
66  MESet& meL1ADCC(MEs_.at("L1ADCC"));
67  MESet& meBXDCC(MEs_.at("BXDCC"));
68  MESet& meBXDCCDiff(MEs_.at("BXDCCDiff"));
69  MESet& meBXFE(MEs_.at("BXFE"));
70  MESet& meBXFEDiff(MEs_.at("BXFEDiff"));
71  MESet& meBXFEInvalid(MEs_.at("BXFEInvalid"));
72  MESet& meL1AFE(MEs_.at("L1AFE"));
73  MESet& meFEStatus(MEs_.at("FEStatus"));
74  MESet& meFEStatusErrMapByLumi(MEs_.at("FEStatusErrMapByLumi"));
75  MESet& meDesyncByLumi(MEs_.at("DesyncByLumi"));
76  MESet& meDesyncTotal(MEs_.at("DesyncTotal"));
77  MESet& meFEByLumi(MEs_.at("FEByLumi"));
78  MESet& meBXTCC(MEs_.at("BXTCC"));
79  MESet& meL1ATCC(MEs_.at("L1ATCC"));
80  MESet& meBXSRP(MEs_.at("BXSRP"));
81  MESet& meL1ASRP(MEs_.at("L1ASRP"));
82  MESet& meTrendNSyncErrors(MEs_.at("L1ATCC"));
83  MESet& meEventTypePreCalib(MEs_.at("EventTypePreCalib"));
84  MESet& meEventTypeCalib(MEs_.at("EventTypeCalib"));
85  MESet& meEventTypePostCalib(MEs_.at("EventTypePostCalib"));
86 
87  if (!l1A_) {
88  // majority vote on L1A.. is there no better implementation?
89  map<int, int> l1aCounts;
90  for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr) {
91  l1aCounts[dcchItr->getLV1()]++;
92  }
93  int maxVote(0);
94  for (map<int, int>::iterator l1aItr(l1aCounts.begin()); l1aItr != l1aCounts.end(); ++l1aItr) {
95  if (l1aItr->second > maxVote) {
96  maxVote = l1aItr->second;
97  l1A_ = l1aItr->first;
98  }
99  }
100  }
101 
102  for (EcalRawDataCollection::const_iterator dcchItr(_dcchs.begin()); dcchItr != _dcchs.end(); ++dcchItr) {
103  int dccId(dcchItr->id());
104 
105  int dccL1A(dcchItr->getLV1());
106  short dccL1AShort(dccL1A & 0xfff);
107  int dccBX(dcchItr->getBX());
108 
109  meOrbitDiff.fill(dccId, dcchItr->getOrbit() - orbit_);
110  meBXDCCDiff.fill(dccId, dccBX - bx_);
111  if (dccBX == -1)
112  meBXFEInvalid.fill(dccId, 68.5);
113 
114  if (dcchItr->getRunNumber() != int(runNumber_))
115  meRunNumber.fill(dccId);
116  if (dcchItr->getOrbit() != orbit_)
117  meOrbit.fill(dccId);
118  if (dcchItr->getBasicTriggerType() != triggerType_)
119  meTriggerType.fill(dccId);
120  if (dccL1A != l1A_)
121  meL1ADCC.fill(dccId);
122  if (dccBX != bx_)
123  meBXDCC.fill(dccId);
124 
125  const vector<short>& feStatus(dcchItr->getFEStatus());
126  const vector<short>& feBxs(dcchItr->getFEBxs());
127  const vector<short>& feL1s(dcchItr->getFELv1());
128 
129  double feDesync(0.);
130  double statusError(0.);
131 
132  for (unsigned iFE(0); iFE < feStatus.size(); iFE++) {
133  if (!ccuExists(dccId, iFE + 1))
134  continue;
135 
136  short status(feStatus[iFE]);
137 
138  if (feBxs[iFE] != -1 && dccBX != -1) {
139  meBXFEDiff.fill(dccId, feBxs[iFE] - dccBX);
140  }
141  if (feBxs[iFE] == -1)
142  meBXFEInvalid.fill(dccId, iFE + 0.5);
143 
144  if (status != BXDesync && status != L1ABXDesync) { // BX desync not detected in the DCC
145  if (feBxs[iFE] != dccBX && feBxs[iFE] != -1 && dccBX != -1) {
146  meBXFE.fill(dccId, iFE + 0.5);
147  feDesync += 1.;
148  }
149  }
150 
151  if (status != L1ADesync && status != L1ABXDesync) {
152  if (feL1s[iFE] + feL1Offset_ != dccL1AShort && feL1s[iFE] != -1 && dccL1AShort != 0) {
153  meL1AFE.fill(dccId, iFE + 0.5);
154  feDesync += 1.;
155  }
156  }
157 
158  if (iFE >= 68)
159  continue;
160 
161  DetId id(getElectronicsMap()->dccTowerConstituents(dccId, iFE + 1).at(0));
162  meFEStatus.fill(id, status);
163  // Fill FE Status Error Map with error states only
165  status != ForcedZS)
166  meFEStatusErrMapByLumi.fill(id, status);
167 
168  switch (status) {
169  case Timeout:
170  case HeaderError:
171  case ChannelId:
172  case LinkError:
173  case BlockSize:
174  case L1ADesync:
175  case BXDesync:
176  case L1ABXDesync:
177  case HParity:
178  case VParity:
179  statusError += 1.;
180  break;
181  default:
182  continue;
183  }
184  }
185 
186  if (feDesync > 0.) {
187  meDesyncByLumi.fill(dccId, feDesync);
188  meDesyncTotal.fill(dccId, feDesync);
189  meTrendNSyncErrors.fill(double(timestamp_.iLumi), feDesync);
190  }
191  if (statusError > 0.)
192  meFEByLumi.fill(dccId, statusError);
193 
194  const vector<short>& tccBx(dcchItr->getTCCBx());
195  const vector<short>& tccL1(dcchItr->getTCCLv1());
196 
197  if (tccBx.size() == 4) { // EB uses tccBx[0]; EE uses all
198  if (dccId <= kEEmHigh + 1 || dccId >= kEEpLow + 1) {
199  for (int iTCC(0); iTCC < 4; iTCC++) {
200  if (tccBx[iTCC] != dccBX && tccBx[iTCC] != -1 && dccBX != -1)
201  meBXTCC.fill(dccId);
202 
203  if (tccL1[iTCC] != dccL1AShort && tccL1[iTCC] != -1 && dccL1AShort != 0)
204  meL1ATCC.fill(dccId);
205  }
206  } else {
207  if (tccBx[0] != dccBX && tccBx[0] != -1 && dccBX != -1)
208  meBXTCC.fill(dccId);
209 
210  if (tccL1[0] != dccL1AShort && tccL1[0] != -1 && dccL1AShort != 0)
211  meL1ATCC.fill(dccId);
212  }
213  }
214 
215  short srpBx(dcchItr->getSRPBx());
216  short srpL1(dcchItr->getSRPLv1());
217 
218  if (srpBx != dccBX && srpBx != -1 && dccBX != -1)
219  meBXSRP.fill(dccId);
220 
221  if (srpL1 != dccL1AShort && srpL1 != -1 && dccL1AShort != 0)
222  meL1ASRP.fill(dccId);
223 
224  const int calibBX(3490);
225 
226  short runType(dcchItr->getRunType() + 1);
227  if (runType < 0 || runType > 22)
228  runType = 0;
229  if (dccBX < calibBX)
230  meEventTypePreCalib.fill(dccId, runType, 1. / 54.);
231  else if (dccBX == calibBX)
232  meEventTypeCalib.fill(dccId, runType, 1. / 54.);
233  else
234  meEventTypePostCalib.fill(dccId, runType, 1. / 54.);
235  }
236  }
237 
239 } // namespace ecaldqm
ecaldqm::RawDataTask::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: RawDataTask.cc:21
ecaldqm::RawDataTask::beginEvent
void beginEvent(edm::Event const &, edm::EventSetup const &) override
Definition: RawDataTask.cc:30
EcalElectronicsId.h
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
edm::EventBase::bunchCrossing
int bunchCrossing() const
Definition: EventBase.h:64
ecaldqm
Definition: DQWorker.h:24
ecaldqm::RawDataTask::bx_
int bx_
Definition: RawDataTask.h:34
ecaldqm::RawDataTask::runOnSource
void runOnSource(FEDRawDataCollection const &)
Definition: RawDataTask.cc:38
ecaldqm::DependencySet
Definition: DQWorkerTask.h:44
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
ecaldqm::HParity
Definition: FEFlags.h:22
ecaldqm::kSource
Definition: Collections.h:9
mps_update.status
status
Definition: mps_update.py:69
ecaldqm::RawDataTask::l1A_
int l1A_
Definition: RawDataTask.h:32
edm::Run
Definition: Run.h:45
FEDRawDataCollection
Definition: FEDRawDataCollection.h:18
ecaldqm::Enabled
Definition: FEFlags.h:9
ecaldqm::LinkError
Definition: FEFlags.h:14
edm::SortedCollection
Definition: SortedCollection.h:49
ecaldqm::Suppressed
Definition: FEFlags.h:16
ecaldqm::Dependency
Definition: DQWorkerTask.h:19
edm::EventBase::experimentType
edm::EventAuxiliary::ExperimentType experimentType() const
Definition: EventBase.h:63
ecaldqm::kEcalRawData
Definition: Collections.h:10
ecaldqm::RawDataTask::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: RawDataTask.cc:23
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
ecaldqm::RawDataTask::RawDataTask
RawDataTask()
Definition: RawDataTask.cc:14
ecaldqm::FIFOFullL1ADesync
Definition: FEFlags.h:21
FEFlags.h
FEDRawData
Definition: FEDRawData.h:19
ecaldqm::RawDataTask
Definition: RawDataTask.h:12
ecaldqm::HeaderError
Definition: FEFlags.h:12
ecaldqm::L1ADesync
Definition: FEFlags.h:18
DetId
Definition: DetId.h:17
ecaldqm::BlockSize
Definition: FEFlags.h:15
ecaldqm::ChannelId
Definition: FEFlags.h:13
ecaldqm::DQWorkerTask
Definition: DQWorkerTask.h:71
ecaldqm::RawDataTask::feL1Offset_
int feL1Offset_
Definition: RawDataTask.h:36
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
ecaldqm::BXDesync
Definition: FEFlags.h:19
Run.h
ecaldqm::ccuExists
bool ccuExists(unsigned, unsigned)
Definition: EcalDQMCommonUtils.cc:403
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
ecaldqm::DQWorker::MEs_
MESetCollection MEs_
Definition: DQWorker.h:78
ecaldqm::Timeout
Definition: FEFlags.h:11
RawDataTask.h
ecaldqm::VParity
Definition: FEFlags.h:23
Event.h
edm::EventBase::isRealData
bool isRealData() const
Definition: EventBase.h:62
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ecaldqm::DependencySet::push_back
void push_back(Dependency const &_d)
Definition: DQWorkerTask.h:46
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:57
ecaldqm::RawDataTask::orbit_
int orbit_
Definition: RawDataTask.h:33
ecaldqm::RawDataTask::runOnRawData
void runOnRawData(EcalRawDataCollection const &)
Definition: RawDataTask.cc:59
ecaldqm::DQWorker::Timestamp::iLumi
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:35
ecaldqm::L1ABXDesync
Definition: FEFlags.h:20
std
Definition: JetResolutionObject.h:76
ecaldqm::RawDataTask::triggerType_
short triggerType_
Definition: RawDataTask.h:35
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
edm::EventBase::orbitNumber
int orbitNumber() const
Definition: EventBase.h:65
ecaldqm::kEEpLow
Definition: EcalDQMCommonUtils.h:83
ecaldqm::DQWorker::timestamp_
Timestamp timestamp_
Definition: DQWorker.h:81
ecaldqm::RawDataTask::runNumber_
edm::RunNumber_t runNumber_
Definition: RawDataTask.h:31
ecaldqm::ForcedZS
Definition: FEFlags.h:24
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
DEFINE_ECALDQM_WORKER
#define DEFINE_ECALDQM_WORKER(TYPE)
Definition: DQWorker.h:112
ParameterSet.h
EcalCondDBWriter_cfi.runType
runType
Definition: EcalCondDBWriter_cfi.py:64
ecaldqm::RawDataTask::addDependencies
void addDependencies(DependencySet &) override
Definition: RawDataTask.cc:17
ecaldqm::getElectronicsMap
const EcalElectronicsMapping * getElectronicsMap()
Definition: EcalDQMCommonUtils.cc:438
edm::Event
Definition: Event.h:73
ecaldqm::FIFOFull
Definition: FEFlags.h:17
sistrip::runNumber_
static const char runNumber_[]
Definition: ConstantsForDqm.h:33
EcalDQMCommonUtils.h
ecaldqm::MESet
Definition: MESet.h:27
ecaldqm::dccId
unsigned dccId(DetId const &)
Definition: EcalDQMCommonUtils.cc:16