CMS 3D CMS Logo

ESRawDataTask.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <vector>
4 
9 
11 
16 
21 
23 
24 using namespace cms;
25 using namespace edm;
26 using namespace std;
27 
29  prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
30 
31  FEDRawDataCollection_ = consumes<FEDRawDataCollection>(ps.getParameter<InputTag>("FEDRawDataCollection"));
32  dccCollections_ = consumes<ESRawDataCollection>(ps.getParameter<InputTag>("ESDCCCollections"));
33 
34  ievt_ = 0;
35 }
36 
38  const edm::EventSetup& c) const {
39  auto lumiCache = std::make_shared<ESRawLSCache>();
40  lumiCache->ievtLS_ = 0;
41 
42  meL1ADCCErrorsByLS_->Reset();
43  meBXDCCErrorsByLS_->Reset();
44  meOrbitNumberDCCErrorsByLS_->Reset();
45 
46  return lumiCache;
47 }
48 
50 
52  char histo[200];
53 
54  iBooker.setCurrentFolder(prefixME_ + "/ESRawDataTask");
55 
56  //sprintf(histo, "ES run number errors");
57  //meRunNumberErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
58  //meRunNumberErrors_->setAxisTitle("ES FED", 1);
59  //meRunNumberErrors_->setAxisTitle("Num of Events", 2);
60 
61  sprintf(histo, "ES L1A DCC errors");
62  meL1ADCCErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
63  meL1ADCCErrors_->setAxisTitle("ES FED", 1);
64  meL1ADCCErrors_->setAxisTitle("Num of Events", 2);
65 
66  sprintf(histo, "ES BX DCC errors");
67  meBXDCCErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
68  meBXDCCErrors_->setAxisTitle("ES FED", 1);
69  meBXDCCErrors_->setAxisTitle("Num of Events", 2);
70 
71  sprintf(histo, "ES Orbit Number DCC errors");
72  meOrbitNumberDCCErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
73  meOrbitNumberDCCErrors_->setAxisTitle("ES FED", 1);
74  meOrbitNumberDCCErrors_->setAxisTitle("Num of Events", 2);
75 
76  sprintf(histo, "Difference between ES and GT L1A");
77  meL1ADiff_ = iBooker.book1D(histo, histo, 201, -100.5, 100.5);
78  meL1ADiff_->setAxisTitle("ES - GT L1A", 1);
79  meL1ADiff_->setAxisTitle("Num of Events", 2);
80 
81  sprintf(histo, "Difference between ES and GT BX");
82  meBXDiff_ = iBooker.book1D(histo, histo, 201, -100.5, 100.5);
83  meBXDiff_->setAxisTitle("ES - GT BX", 1);
84  meBXDiff_->setAxisTitle("Num of Events", 2);
85 
86  sprintf(histo, "Difference between ES and GT Orbit Number");
87  meOrbitNumberDiff_ = iBooker.book1D(histo, histo, 201, -100.5, 100.5);
88  meOrbitNumberDiff_->setAxisTitle("ES - GT orbit number", 1);
89  meOrbitNumberDiff_->setAxisTitle("Num of Events", 2);
90 
91  // LS-based histos
92  iBooker.setCurrentFolder(prefixME_ + "/ByLumiSection");
93 
94  sprintf(histo, "ES L1A DCC errors");
95  meL1ADCCErrorsByLS_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
96  meL1ADCCErrorsByLS_->setAxisTitle("ES FED", 1);
97  meL1ADCCErrorsByLS_->setAxisTitle("Num of Events", 2);
98 
99  sprintf(histo, "ES BX DCC errors");
100  meBXDCCErrorsByLS_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
101  meBXDCCErrorsByLS_->setAxisTitle("ES FED", 1);
102  meBXDCCErrorsByLS_->setAxisTitle("Num of Events", 2);
103 
104  sprintf(histo, "ES Orbit Number DCC errors");
105  meOrbitNumberDCCErrorsByLS_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
106  meOrbitNumberDCCErrorsByLS_->setAxisTitle("ES FED", 1);
107  meOrbitNumberDCCErrorsByLS_->setAxisTitle("Num of Events", 2);
108 }
109 
110 void ESRawDataTask::analyze(const Event& e, const EventSetup& c) {
111  ievt_++;
112  runNum_ = e.id().run();
113 
114  int gt_L1A = 0, gt_OrbitNumber = 0, gt_BX = 0;
115  int esDCC_L1A_MostFreqCounts = 0;
116  int esDCC_BX_MostFreqCounts = 0;
117  int esDCC_OrbitNumber_MostFreqCounts = 0;
118 
120  Handle<FEDRawDataCollection> allFedRawData;
121 
122  int gtFedDataSize = 0;
123 
124  if (e.getByToken(FEDRawDataCollection_, allFedRawData)) {
125  // GT FED data
126  const FEDRawData& gtFedData = allFedRawData->FEDData(812);
127 
128  gtFedDataSize = gtFedData.size() / sizeof(uint64_t);
129 
130  if (gtFedDataSize > 0) {
131  FEDHeader header(gtFedData.data());
132 
133  gt_L1A = header.lvl1ID();
134  gt_OrbitNumber = e.orbitNumber();
135  gt_BX = e.bunchCrossing();
136  } else {
137  map<int, int> esDCC_L1A_FreqMap;
138  map<int, int> esDCC_BX_FreqMap;
139  map<int, int> esDCC_OrbitNumber_FreqMap;
140 
141  if (e.getByToken(dccCollections_, dccs)) {
142  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
143  const ESDCCHeaderBlock& esdcc = (*dccItr);
144 
145  esDCC_L1A_FreqMap[esdcc.getLV1()]++;
146  esDCC_BX_FreqMap[esdcc.getBX()]++;
147  esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()]++;
148 
149  if (esDCC_L1A_FreqMap[esdcc.getLV1()] > esDCC_L1A_MostFreqCounts) {
150  esDCC_L1A_MostFreqCounts = esDCC_L1A_FreqMap[esdcc.getLV1()];
151  gt_L1A = esdcc.getLV1();
152  }
153 
154  if (esDCC_BX_FreqMap[esdcc.getBX()] > esDCC_BX_MostFreqCounts) {
155  esDCC_BX_MostFreqCounts = esDCC_BX_FreqMap[esdcc.getBX()];
156  gt_BX = esdcc.getBX();
157  }
158 
159  if (esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()] > esDCC_OrbitNumber_MostFreqCounts) {
160  esDCC_OrbitNumber_MostFreqCounts = esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()];
161  gt_OrbitNumber = esdcc.getOrbitNumber();
162  }
163  }
164  } else {
165  LogWarning("ESRawDataTask") << "dccCollections not available";
166  }
167  }
168  } else {
169  LogWarning("ESRawDataTask") << "FEDRawDataCollection not available";
170  }
171 
172  // DCC
173  vector<int> fiberStatus;
174  if (e.getByToken(dccCollections_, dccs)) {
175  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
176  const ESDCCHeaderBlock& dcc = (*dccItr);
177 
178  //if (dcc.getRunNumber() != runNum_) {
179  //meRunNumberErrors_->Fill(dcc.fedId());
180  //cout<<"Run # err : "<<dcc.getRunNumber()<<" "<<runNum_<<endl;
181  //}
182 
183  if (dcc.getLV1() != gt_L1A) {
184  meL1ADCCErrors_->Fill(dcc.fedId());
185  meL1ADCCErrorsByLS_->Fill(dcc.fedId());
186  Float_t l1a_diff = dcc.getLV1() - gt_L1A;
187  if (l1a_diff > 100)
188  l1a_diff = 100;
189  else if (l1a_diff < -100)
190  l1a_diff = -100;
191  meL1ADiff_->Fill(l1a_diff);
192  }
193 
194  if (dcc.getBX() != gt_BX) {
195  meBXDCCErrors_->Fill(dcc.fedId());
196  meBXDCCErrorsByLS_->Fill(dcc.fedId());
197  Float_t bx_diff = dcc.getBX() - gt_BX;
198  if (bx_diff > 100)
199  bx_diff = 100;
200  else if (bx_diff < -100)
201  bx_diff = -100;
202  meBXDiff_->Fill(bx_diff);
203  }
204  if (dcc.getOrbitNumber() != gt_OrbitNumber) {
205  meOrbitNumberDCCErrors_->Fill(dcc.fedId());
206  meOrbitNumberDCCErrorsByLS_->Fill(dcc.fedId());
207  Float_t orbitnumber_diff = dcc.getOrbitNumber() - gt_OrbitNumber;
208  if (orbitnumber_diff > 100)
209  orbitnumber_diff = 100;
210  else if (orbitnumber_diff < -100)
211  orbitnumber_diff = -100;
212  meOrbitNumberDiff_->Fill(orbitnumber_diff);
213  }
214  }
215  }
216 }
217 
void globalEndLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &c) override
End Lumi.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::vector< T >::const_iterator const_iterator
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:48
int getOrbitNumber() const
ESRawDataTask(const edm::ParameterSet &ps)
std::shared_ptr< ESRawLSCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &c) const override
Begin Lumi.
T getUntrackedParameter(std::string const &, T const &) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Setup.
int getLV1() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const_iterator begin() 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
HLT enums.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
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
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)