CMS 3D CMS Logo

ESFEDIntegrityTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <vector>
4 
10 
13 
20 
21 using namespace cms;
22 using namespace edm;
23 using namespace std;
24 
26  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
27  fedDirName_ = ps.getUntrackedParameter<string>("FEDDirName", "FEDIntegrity");
28  debug_ = ps.getUntrackedParameter<bool>("debug", false);
29 
30  dccCollections_ = consumes<ESRawDataCollection>(ps.getParameter<InputTag>("ESDCCCollections"));
31  FEDRawDataCollection_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("FEDRawDataCollection"));
32 
33  meESFedsEntries_ = nullptr;
34  meESFedsFatal_ = nullptr;
35  meESFedsNonFatal_ = nullptr;
36 
37  ievt_ = 0;
38 }
39 
41  char histo[200];
42 
43  iBooker.setCurrentFolder(prefixME_ + "/" + fedDirName_);
44 
45  sprintf(histo, "FEDEntries");
46  meESFedsEntries_ = iBooker.book1D(histo, histo, 56, 520, 576);
47 
48  sprintf(histo, "FEDFatal");
49  meESFedsFatal_ = iBooker.book1D(histo, histo, 56, 520, 576);
50 
51  sprintf(histo, "FEDNonFatal");
52  meESFedsNonFatal_ = iBooker.book1D(histo, histo, 56, 520, 576);
53 }
54 
56  ievt_++;
57 
58  int gt_L1A = 0;
59  // int gt_OrbitNumber = 0, gt_BX = 0;
60  int esDCC_L1A_MostFreqCounts = 0;
61  int esDCC_BX_MostFreqCounts = 0;
62  int esDCC_OrbitNumber_MostFreqCounts = 0;
63  int gtFedDataSize = 0;
64 
66  Handle<FEDRawDataCollection> allFedRawData;
67 
68  if (e.getByToken(FEDRawDataCollection_, allFedRawData)) {
69  // ES FEDs
70  for (int esFED = 520; esFED <= 575; ++esFED) {
71  const FEDRawData& fedData = allFedRawData->FEDData(esFED);
72  int length = fedData.size() / sizeof(uint64_t);
73 
74  if (length > 0)
75  if (meESFedsEntries_)
76  meESFedsEntries_->Fill(esFED);
77  }
78 
79  // GT FED data
80  const FEDRawData& gtFedData = allFedRawData->FEDData(812);
81 
82  gtFedDataSize = gtFedData.size() / sizeof(uint64_t);
83 
84  if (gtFedDataSize > 0) {
85  FEDHeader header(gtFedData.data());
86 
87  gt_L1A = header.lvl1ID();
88  //gt_OrbitNumber = e.orbitNumber();
89  //gt_BX = e.bunchCrossing();
90  } else {
91  map<int, int> esDCC_L1A_FreqMap;
92  map<int, int> esDCC_BX_FreqMap;
93  map<int, int> esDCC_OrbitNumber_FreqMap;
94 
95  if (e.getByToken(dccCollections_, dccs)) {
96  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
97  ESDCCHeaderBlock esdcc = (*dccItr);
98 
99  esDCC_L1A_FreqMap[esdcc.getLV1()]++;
100  esDCC_BX_FreqMap[esdcc.getBX()]++;
101  esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()]++;
102 
103  if (esDCC_L1A_FreqMap[esdcc.getLV1()] > esDCC_L1A_MostFreqCounts) {
104  esDCC_L1A_MostFreqCounts = esDCC_L1A_FreqMap[esdcc.getLV1()];
105  gt_L1A = esdcc.getLV1();
106  }
107 
108  if (esDCC_BX_FreqMap[esdcc.getBX()] > esDCC_BX_MostFreqCounts) {
109  esDCC_BX_MostFreqCounts = esDCC_BX_FreqMap[esdcc.getBX()];
110  //gt_BX = esdcc.getBX();
111  }
112 
113  if (esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()] > esDCC_OrbitNumber_MostFreqCounts) {
114  esDCC_OrbitNumber_MostFreqCounts = esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()];
115  //gt_OrbitNumber = esdcc.getOrbitNumber();
116  }
117  }
118  } else {
119  LogWarning("ESFEDIntegrityTask") << "dccCollections not available";
120  }
121  }
122 
123  } else {
124  LogWarning("ESFEDIntegrityTask") << "FEDRawDataCollection not available";
125  }
126 
127  vector<int> fiberStatus;
128  if (e.getByToken(dccCollections_, dccs)) {
129  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
130  ESDCCHeaderBlock dcc = (*dccItr);
131 
132  if (dcc.getDCCErrors() > 0) {
133  if (meESFedsFatal_)
134  meESFedsFatal_->Fill(dcc.fedId());
135 
136  } else {
137  if (debug_)
138  cout << dcc.fedId() << " " << dcc.getOptoRX0() << " " << dcc.getOptoRX1() << " " << dcc.getOptoRX2() << endl;
139  fiberStatus = dcc.getFEChannelStatus();
140 
141  if (dcc.getOptoRX0() == 128) {
142  meESFedsNonFatal_->Fill(dcc.fedId(), 1. / 3.);
143  } else if (dcc.getOptoRX0() == 129) {
144  for (unsigned int i = 0; i < 12; ++i) {
145  if (fiberStatus[i] == 8 || fiberStatus[i] == 10 || fiberStatus[i] == 11 || fiberStatus[i] == 12)
146  if (meESFedsNonFatal_)
147  meESFedsNonFatal_->Fill(dcc.fedId(), 1. / 12.);
148  }
149  }
150  if (dcc.getOptoRX1() == 128) {
151  meESFedsNonFatal_->Fill(dcc.fedId(), 1. / 3.);
152  } else if (dcc.getOptoRX1() == 129) {
153  for (unsigned int i = 12; i < 24; ++i) {
154  if (fiberStatus[i] == 8 || fiberStatus[i] == 10 || fiberStatus[i] == 11 || fiberStatus[i] == 12)
155  if (meESFedsNonFatal_)
156  meESFedsNonFatal_->Fill(dcc.fedId(), 1. / 12.);
157  }
158  }
159  if (dcc.getOptoRX2() == 128) {
160  meESFedsNonFatal_->Fill(dcc.fedId(), 1. / 3.);
161  } else if (dcc.getOptoRX2() == 129) {
162  for (unsigned int i = 24; i < 36; ++i) {
163  if (fiberStatus[i] == 8 || fiberStatus[i] == 10 || fiberStatus[i] == 11 || fiberStatus[i] == 12)
164  if (meESFedsNonFatal_)
165  meESFedsNonFatal_->Fill(dcc.fedId(), 1. / 12.);
166  }
167  }
168  }
169 
170  if (dcc.getLV1() != gt_L1A)
171  meESFedsNonFatal_->Fill(dcc.fedId());
172  //if (dcc.getBX() != gt_BX) meESFedsNonFatal_->Fill(dcc.fedId());
173  //if (dcc.getOrbitNumber() != gt_OrbitNumber) meESFedsNonFatal_->Fill(dcc.fedId());
174  }
175  }
176 
177  //for (ESLocalRawDataCollection::const_iterator kItr = kchips->begin(); kItr != kchips->end(); ++kItr) {
178 
179  //ESKCHIPBlock kchip = (*kItr);
180 
181  //Int_t nErr = 0;
182  //if (kchip.getFlag1() > 0) nErr++;
183  //if (kchip.getFlag2() > 0) nErr++;
184  //if (kchip.getBC() != kchip.getOptoBC()) nErr++;
185  //if (kchip.getEC() != kchip.getOptoEC()) nErr++;
186  //if (nErr>0) meESFedsNonFatal_->Fill(dcc.fedId());
187  //}
188 }
189 
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
int getOptoRX1() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< T >::const_iterator const_iterator
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
int getOrbitNumber() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T getUntrackedParameter(std::string const &, T const &) const
int getOptoRX2() const
int getLV1() const
int getDCCErrors() const
ESFEDIntegrityTask(const edm::ParameterSet &ps)
const_iterator begin() const
const int fedId() const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Namespace of DDCMS conversion namespace.
const_iterator end() const
unsigned long long uint64_t
Definition: Time.h:13
int getOptoRX0() const
HLT enums.
const std::vector< int > & getFEChannelStatus() const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: Run.h:45