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 
FEDNumbering.h
mps_fire.i
i
Definition: mps_fire.py:428
ESFEDIntegrityTask
Definition: ESFEDIntegrityTask.h:14
ESDCCHeaderBlock::getOptoRX2
int getOptoRX2() const
Definition: ESDCCHeaderBlock.h:95
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
ESHandle.h
edm::Run
Definition: Run.h:45
ESDCCHeaderBlock::getLV1
int getLV1() const
Definition: ESDCCHeaderBlock.h:78
edm
HLT enums.
Definition: AlignableModifier.h:19
ESDCCHeaderBlock::getOptoRX0
int getOptoRX0() const
Definition: ESDCCHeaderBlock.h:93
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ESDCCHeaderBlock::getOptoRX1
int getOptoRX1() const
Definition: ESDCCHeaderBlock.h:94
ESDCCHeaderBlock::getFEChannelStatus
const std::vector< int > & getFEChannelStatus() const
Definition: ESDCCHeaderBlock.h:99
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
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
ESFEDIntegrityTask.h
FEDRawData
Definition: FEDRawData.h:19
ESFEDIntegrityTask::analyze
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
Definition: ESFEDIntegrityTask.cc:55
MakerMacros.h
ESKCHIPBlock.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESDCCHeaderBlock::getDCCErrors
int getDCCErrors() const
Definition: ESDCCHeaderBlock.h:84
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
ESFEDIntegrityTask::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: ESFEDIntegrityTask.cc:40
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:57
ESFEDIntegrityTask::ESFEDIntegrityTask
ESFEDIntegrityTask(const edm::ParameterSet &ps)
Definition: ESFEDIntegrityTask.cc:25
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
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
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
FEDHeader
Definition: FEDHeader.h:14
edm::Event
Definition: Event.h:73
FEDHeader.h
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
FEDTrailer.h