CMS 3D CMS Logo

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