CMS 3D CMS Logo

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