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