CMS 3D CMS Logo

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