CMS 3D CMS Logo

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