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
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
ecaldqm::RawDataTask::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: RawDataTask.cc:22
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:37
ecaldqm::RawDataTask::bx_
int bx_
Definition: RawDataTask.h:33
ecaldqm::RawDataTask::runOnSource
void runOnSource(FEDRawDataCollection const &)
Definition: RawDataTask.cc:45
LumiConstants::numBX
static const unsigned int numBX
Definition: LumiConstants.h:8
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:68
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
LumiConstants.h
ecaldqm::RawDataTask::RawDataTask
RawDataTask()
Definition: RawDataTask.cc:15
ecaldqm::FIFOFullL1ADesync
Definition: FEFlags.h:21
ecaldqm::DQWorker::GetElectronicsMap
const EcalElectronicsMapping * GetElectronicsMap()
Definition: DQWorker.cc:118
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::MESet::reset
virtual void reset(EcalElectronicsMapping const *, double=0., double=0., double=0.)
Definition: MESet.cc:98
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:125
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:399
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:58
ecaldqm::dccId
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
Definition: EcalDQMCommonUtils.cc:16
ecaldqm::RawDataTask::orbit_
int orbit_
Definition: RawDataTask.h:32
ecaldqm::RawDataTask::runOnRawData
void runOnRawData(EcalRawDataCollection const &)
Definition: RawDataTask.cc:66
ecaldqm::DQWorker::Timestamp::iLumi
edm::LuminosityBlockNumber_t iLumi
Definition: DQWorker.h:48
ecaldqm::L1ABXDesync
Definition: FEFlags.h:20
ecaldqm::DQWorker::getEcalDQMSetupObjects
const EcalDQMSetupObjects getEcalDQMSetupObjects()
Definition: DQWorker.cc:142
ecaldqm::RawDataTask::beginEvent
void beginEvent(edm::Event const &, edm::EventSetup const &, bool const &, bool &) override
Definition: RawDataTask.cc:24
std
Definition: JetResolutionObject.h:76
ecaldqm::RawDataTask::triggerType_
short triggerType_
Definition: RawDataTask.h:34
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
edm::EventBase::orbitNumber
int orbitNumber() const
Definition: EventBase.h:65
ecaldqm::kEEpLow
Definition: EcalDQMCommonUtils.h:82
ecaldqm::DQWorker::timestamp_
Timestamp timestamp_
Definition: DQWorker.h:128
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:162
ParameterSet.h
EcalCondDBWriter_cfi.runType
runType
Definition: EcalCondDBWriter_cfi.py:64
ecaldqm::RawDataTask::addDependencies
void addDependencies(DependencySet &) override
Definition: RawDataTask.cc:18
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:42