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  char histo[200];
39 
40  iBooker.setCurrentFolder(prefixME_ + "/ESRawDataTask");
41 
42  //sprintf(histo, "ES run number errors");
43  //meRunNumberErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
44  //meRunNumberErrors_->setAxisTitle("ES FED", 1);
45  //meRunNumberErrors_->setAxisTitle("Num of Events", 2);
46 
47  sprintf(histo, "ES L1A DCC errors");
48  meL1ADCCErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
49  meL1ADCCErrors_->setAxisTitle("ES FED", 1);
50  meL1ADCCErrors_->setAxisTitle("Num of Events", 2);
51 
52  sprintf(histo, "ES BX DCC errors");
53  meBXDCCErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
54  meBXDCCErrors_->setAxisTitle("ES FED", 1);
55  meBXDCCErrors_->setAxisTitle("Num of Events", 2);
56 
57  sprintf(histo, "ES Orbit Number DCC errors");
58  meOrbitNumberDCCErrors_ = iBooker.book1D(histo, histo, 56, 519.5, 575.5);
59  meOrbitNumberDCCErrors_->setAxisTitle("ES FED", 1);
60  meOrbitNumberDCCErrors_->setAxisTitle("Num of Events", 2);
61 
62  sprintf(histo, "Difference between ES and GT L1A");
63  meL1ADiff_ = iBooker.book1D(histo, histo, 201, -100.5, 100.5);
64  meL1ADiff_->setAxisTitle("ES - GT L1A", 1);
65  meL1ADiff_->setAxisTitle("Num of Events", 2);
66 
67  sprintf(histo, "Difference between ES and GT BX");
68  meBXDiff_ = iBooker.book1D(histo, histo, 201, -100.5, 100.5);
69  meBXDiff_->setAxisTitle("ES - GT BX", 1);
70  meBXDiff_->setAxisTitle("Num of Events", 2);
71 
72  sprintf(histo, "Difference between ES and GT Orbit Number");
73  meOrbitNumberDiff_ = iBooker.book1D(histo, histo, 201, -100.5, 100.5);
74  meOrbitNumberDiff_->setAxisTitle("ES - GT orbit number", 1);
75  meOrbitNumberDiff_->setAxisTitle("Num of Events", 2);
76 }
77 
78 void ESRawDataTask::analyze(const Event& e, const EventSetup& c) {
79  ievt_++;
80  runNum_ = e.id().run();
81 
82  int gt_L1A = 0, gt_OrbitNumber = 0, gt_BX = 0;
83  int esDCC_L1A_MostFreqCounts = 0;
84  int esDCC_BX_MostFreqCounts = 0;
85  int esDCC_OrbitNumber_MostFreqCounts = 0;
86 
88  Handle<FEDRawDataCollection> allFedRawData;
89 
90  int gtFedDataSize = 0;
91 
92  if (e.getByToken(FEDRawDataCollection_, allFedRawData)) {
93  // GT FED data
94  const FEDRawData& gtFedData = allFedRawData->FEDData(812);
95 
96  gtFedDataSize = gtFedData.size() / sizeof(uint64_t);
97 
98  if (gtFedDataSize > 0) {
99  FEDHeader header(gtFedData.data());
100 
101  gt_L1A = header.lvl1ID();
102  gt_OrbitNumber = e.orbitNumber();
103  gt_BX = e.bunchCrossing();
104  } else {
105  map<int, int> esDCC_L1A_FreqMap;
106  map<int, int> esDCC_BX_FreqMap;
107  map<int, int> esDCC_OrbitNumber_FreqMap;
108 
109  if (e.getByToken(dccCollections_, dccs)) {
110  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
111  ESDCCHeaderBlock esdcc = (*dccItr);
112 
113  esDCC_L1A_FreqMap[esdcc.getLV1()]++;
114  esDCC_BX_FreqMap[esdcc.getBX()]++;
115  esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()]++;
116 
117  if (esDCC_L1A_FreqMap[esdcc.getLV1()] > esDCC_L1A_MostFreqCounts) {
118  esDCC_L1A_MostFreqCounts = esDCC_L1A_FreqMap[esdcc.getLV1()];
119  gt_L1A = esdcc.getLV1();
120  }
121 
122  if (esDCC_BX_FreqMap[esdcc.getBX()] > esDCC_BX_MostFreqCounts) {
123  esDCC_BX_MostFreqCounts = esDCC_BX_FreqMap[esdcc.getBX()];
124  gt_BX = esdcc.getBX();
125  }
126 
127  if (esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()] > esDCC_OrbitNumber_MostFreqCounts) {
128  esDCC_OrbitNumber_MostFreqCounts = esDCC_OrbitNumber_FreqMap[esdcc.getOrbitNumber()];
129  gt_OrbitNumber = esdcc.getOrbitNumber();
130  }
131  }
132  } else {
133  LogWarning("ESRawDataTask") << "dccCollections not available";
134  }
135  }
136  } else {
137  LogWarning("ESRawDataTask") << "FEDRawDataCollection not available";
138  }
139 
140  // DCC
141  vector<int> fiberStatus;
142  if (e.getByToken(dccCollections_, dccs)) {
143  for (ESRawDataCollection::const_iterator dccItr = dccs->begin(); dccItr != dccs->end(); ++dccItr) {
144  ESDCCHeaderBlock dcc = (*dccItr);
145 
146  //if (dcc.getRunNumber() != runNum_) {
147  //meRunNumberErrors_->Fill(dcc.fedId());
148  //cout<<"Run # err : "<<dcc.getRunNumber()<<" "<<runNum_<<endl;
149  //}
150 
151  if (dcc.getLV1() != gt_L1A) {
152  meL1ADCCErrors_->Fill(dcc.fedId());
153  //cout<<"L1A err : "<<dcc.getLV1()<<" "<<gt_L1A<<endl;
154  Float_t l1a_diff = dcc.getLV1() - gt_L1A;
155  if (l1a_diff > 100)
156  l1a_diff = 100;
157  else if (l1a_diff < -100)
158  l1a_diff = -100;
159  meL1ADiff_->Fill(l1a_diff);
160  }
161 
162  if (dcc.getBX() != gt_BX) {
163  meBXDCCErrors_->Fill(dcc.fedId());
164  //cout<<"BX err : "<<dcc.getBX()<<" "<<gt_BX<<endl;
165  Float_t bx_diff = dcc.getBX() - gt_BX;
166  if (bx_diff > 100)
167  bx_diff = 100;
168  else if (bx_diff < -100)
169  bx_diff = -100;
170  meBXDiff_->Fill(bx_diff);
171  }
172  if (dcc.getOrbitNumber() != gt_OrbitNumber) {
173  meOrbitNumberDCCErrors_->Fill(dcc.fedId());
174  //cout<<"Orbit err : "<<dcc.getOrbitNumber()<<" "<<gt_OrbitNumber<<endl;
175  Float_t orbitnumber_diff = dcc.getOrbitNumber() - gt_OrbitNumber;
176  if (orbitnumber_diff > 100)
177  orbitnumber_diff = 100;
178  else if (orbitnumber_diff < -100)
179  orbitnumber_diff = -100;
180  meOrbitNumberDiff_->Fill(orbitnumber_diff);
181  }
182  }
183  }
184 }
185 
FEDNumbering.h
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
ESRawDataTask.h
edm::Run
Definition: Run.h:45
ESDCCHeaderBlock::getLV1
int getLV1() const
Definition: ESDCCHeaderBlock.h:78
edm
HLT enums.
Definition: AlignableModifier.h:19
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
timingPdfMaker.histo
histo
Definition: timingPdfMaker.py:279
DQMStore.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ESDetId.h
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
FEDRawData::data
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
FEDRawData
Definition: FEDRawData.h:19
ESDataFrame.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
Service.h
FEDRawDataCollection::FEDData
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
Definition: FEDRawDataCollection.cc:19
ESRawDataTask::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Definition: ESRawDataTask.cc:78
edm::ParameterSet
Definition: ParameterSet.h:47
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
ESDCCHeaderBlock::getBX
int getBX() const
Definition: ESDCCHeaderBlock.h:79
ESDCCHeaderBlock::getOrbitNumber
int getOrbitNumber() const
Definition: ESDCCHeaderBlock.h:90
ESDCCHeaderBlock
Definition: ESDCCHeaderBlock.h:5
edm::EventSetup
Definition: EventSetup.h:58
FEDRawData::size
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
ESDCCHeaderBlock::fedId
const int fedId() const
Definition: ESDCCHeaderBlock.h:29
ESDCCHeaderBlock.h
std
Definition: JetResolutionObject.h:76
ESRawDataTask
Definition: ESRawDataTask.h:14
DetId.h
Frameworkfwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
FEDHeader
Definition: FEDHeader.h:14
edm::Event
Definition: Event.h:73
ESRawDataTask::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Setup.
Definition: ESRawDataTask.cc:37
FEDHeader.h
dqm::impl::MonitorElement::setAxisTitle
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:800
edm::InputTag
Definition: InputTag.h:15
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
ESRawDataTask::ESRawDataTask
ESRawDataTask(const edm::ParameterSet &ps)
Definition: ESRawDataTask.cc:28
FEDTrailer.h