CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalFEDMonitor.cc
Go to the documentation of this file.
4 
5 template <int SUBDET>
7  : folderName_(_ps.getUntrackedParameter<std::string>("folderName")),
8  FEDRawDataToken_(consumes<FEDRawDataCollection>(_ps.getParameter<edm::InputTag>("FEDRawDataCollection"))),
9  ebGainErrorsToken_(),
10  eeGainErrorsToken_(),
11  ebChIdErrorsToken_(),
12  eeChIdErrorsToken_(),
13  ebGainSwitchErrorsToken_(),
14  eeGainSwitchErrorsToken_(),
15  towerIdErrorsToken_(
16  consumes<EcalElectronicsIdCollection>(_ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection1"))),
17  blockSizeErrorsToken_(
18  consumes<EcalElectronicsIdCollection>(_ps.getParameter<edm::InputTag>("EcalElectronicsIdCollection2"))),
19  elecMapHandle(esConsumes<edm::Transition::BeginRun>()),
20  MEs_(nMEs, nullptr) {
21  if (_ps.existsAs<edm::InputTag>("EBDetIdCollection1"))
22  ebGainErrorsToken_ = consumes<EBDetIdCollection>(_ps.getParameter<edm::InputTag>("EBDetIdCollection1"));
23  if (_ps.existsAs<edm::InputTag>("EEDetIdCollection1"))
24  eeGainErrorsToken_ = consumes<EEDetIdCollection>(_ps.getParameter<edm::InputTag>("EEDetIdCollection1"));
25  if (_ps.existsAs<edm::InputTag>("EBDetIdCollection2"))
26  ebChIdErrorsToken_ = consumes<EBDetIdCollection>(_ps.getParameter<edm::InputTag>("EBDetIdCollection2"));
27  if (_ps.existsAs<edm::InputTag>("EEDetIdCollection2"))
28  eeChIdErrorsToken_ = consumes<EEDetIdCollection>(_ps.getParameter<edm::InputTag>("EEDetIdCollection2"));
29  if (_ps.existsAs<edm::InputTag>("EBDetIdCollection3"))
30  ebGainSwitchErrorsToken_ = consumes<EBDetIdCollection>(_ps.getParameter<edm::InputTag>("EBDetIdCollection3"));
31  if (_ps.existsAs<edm::InputTag>("EEDetIdCollection3"))
32  eeGainSwitchErrorsToken_ = consumes<EEDetIdCollection>(_ps.getParameter<edm::InputTag>("EEDetIdCollection3"));
33 }
34 
35 template <int SUBDET>
37  setElectronicsMap(_es);
38 }
39 
40 template <int SUBDET>
42  _ibooker.cd();
43 
45 
46  if (SUBDET == EcalBarrel || SUBDET < 0) {
47  _ibooker.setCurrentFolder("EcalBarrel/" + folderName_);
48 
49  name = "FEDEntries";
50  MEs_[kEBOccupancy] = _ibooker.book1D(name, name, 36, 610, 646);
51 
52  name = "FEDFatal";
53  MEs_[kEBFatal] = _ibooker.book1D(name, name, 36, 610, 646);
54 
55  name = "FEDNonFatal";
56  MEs_[kEBNonFatal] = _ibooker.book1D(name, name, 36, 610, 646);
57  }
58  if (SUBDET == EcalEndcap || SUBDET < 0) {
59  _ibooker.setCurrentFolder("EcalEndcap/" + folderName_);
60 
61  name = "FEDEntries";
62  MEs_[kEEOccupancy] = _ibooker.book1D(name, name, 54, 601, 655);
63 
64  name = "FEDFatal";
65  MEs_[kEEFatal] = _ibooker.book1D(name, name, 54, 601, 655);
66 
67  name = "FEDNonFatal";
68  MEs_[kEENonFatal] = _ibooker.book1D(name, name, 54, 601, 655);
69  }
70 }
71 
72 template <int SUBDET>
75  if (_evt.getByToken(FEDRawDataToken_, fedHndl)) {
76  for (unsigned fedId(601); fedId <= 654; fedId++) {
77  if (SUBDET == EcalBarrel && (fedId < 610 || fedId > 645))
78  continue;
79  if (SUBDET == EcalEndcap && (fedId > 609 && fedId < 646))
80  continue;
81 
82  unsigned occupancy(-1);
83  // unsigned fatal(-1);
84  if (fedId < 610 || fedId > 645) {
85  occupancy = kEEOccupancy;
86  // fatal = kEEFatal;
87  } else {
88  occupancy = kEBOccupancy;
89  // fatal = kEBFatal;
90  }
91 
92  const FEDRawData& fedData(fedHndl->FEDData(fedId));
93  unsigned length(fedData.size() / sizeof(uint64_t));
94 
95  if (length > 1) { // FED header is one 64 bit word
96  MEs_[occupancy]->Fill(fedId + 0.5);
97 
98  // const uint64_t* pData(reinterpret_cast<const uint64_t*>(fedData.data()));
99  // bool crcError(((pData[length - 1] >> 2) & 0x1) == 0x1);
100 
101  // if(crcError) MEs_[fatal]->Fill(fedId + 0.5);
102  }
103  }
104  }
105 
109 
110  if ((SUBDET == EcalBarrel || SUBDET < 0) && _evt.getByToken(ebGainErrorsToken_, ebHndl)) {
111  EBDetIdCollection::const_iterator ebEnd(ebHndl->end());
112  for (EBDetIdCollection::const_iterator ebItr(ebHndl->begin()); ebItr != ebEnd; ++ebItr) {
113  unsigned iDCC(ecaldqm::dccId(*ebItr, GetElectronicsMap()) - 1);
114 
115  double normalization(ecaldqm::nCrystals(iDCC + 1));
116  if (normalization < 1.)
117  continue;
118 
119  MEs_[kEBNonFatal]->Fill(iDCC + 601.5, 1. / normalization);
120  }
121  }
122  if ((SUBDET == EcalEndcap || SUBDET < 0) && _evt.getByToken(eeGainErrorsToken_, eeHndl)) {
123  EEDetIdCollection::const_iterator eeEnd(eeHndl->end());
124  for (EEDetIdCollection::const_iterator eeItr(eeHndl->begin()); eeItr != eeEnd; ++eeItr) {
125  unsigned iDCC(ecaldqm::dccId(*eeItr, GetElectronicsMap()) - 1);
126 
127  double normalization(ecaldqm::nCrystals(iDCC + 1));
128  if (normalization < 1.)
129  continue;
130 
131  MEs_[kEENonFatal]->Fill(iDCC + 601.5, 1. / normalization);
132  }
133  }
134 
135  if ((SUBDET == EcalBarrel || SUBDET < 0) && _evt.getByToken(ebChIdErrorsToken_, ebHndl)) {
136  EBDetIdCollection::const_iterator ebEnd(ebHndl->end());
137  for (EBDetIdCollection::const_iterator ebItr(ebHndl->begin()); ebItr != ebEnd; ++ebItr) {
138  unsigned iDCC(ecaldqm::dccId(*ebItr, GetElectronicsMap()) - 1);
139 
140  double normalization(ecaldqm::nCrystals(iDCC + 1));
141  if (normalization < 1.)
142  continue;
143 
144  MEs_[kEBNonFatal]->Fill(iDCC + 601.5, 1. / normalization);
145  }
146  }
147  if ((SUBDET == EcalEndcap || SUBDET < 0) && _evt.getByToken(eeChIdErrorsToken_, eeHndl)) {
148  EEDetIdCollection::const_iterator eeEnd(eeHndl->end());
149  for (EEDetIdCollection::const_iterator eeItr(eeHndl->begin()); eeItr != eeEnd; ++eeItr) {
150  unsigned iDCC(ecaldqm::dccId(*eeItr, GetElectronicsMap()) - 1);
151 
152  double normalization(ecaldqm::nCrystals(iDCC + 1));
153  if (normalization < 1.)
154  continue;
155 
156  MEs_[kEENonFatal]->Fill(iDCC + 601.5, 1. / normalization);
157  }
158  }
159 
160  if ((SUBDET == EcalBarrel || SUBDET < 0) && _evt.getByToken(ebGainSwitchErrorsToken_, ebHndl)) {
161  EBDetIdCollection::const_iterator ebEnd(ebHndl->end());
162  for (EBDetIdCollection::const_iterator ebItr(ebHndl->begin()); ebItr != ebEnd; ++ebItr) {
163  unsigned iDCC(ecaldqm::dccId(*ebItr, GetElectronicsMap()) - 1);
164 
165  double normalization(ecaldqm::nCrystals(iDCC + 1));
166  if (normalization < 1.)
167  continue;
168 
169  MEs_[kEBNonFatal]->Fill(iDCC + 601.5, 1. / normalization);
170  }
171  }
172  if ((SUBDET == EcalEndcap || SUBDET < 0) && _evt.getByToken(eeGainSwitchErrorsToken_, eeHndl)) {
173  EEDetIdCollection::const_iterator eeEnd(eeHndl->end());
174  for (EEDetIdCollection::const_iterator eeItr(eeHndl->begin()); eeItr != eeEnd; ++eeItr) {
175  unsigned iDCC(ecaldqm::dccId(*eeItr, GetElectronicsMap()) - 1);
176 
177  double normalization(ecaldqm::nCrystals(iDCC + 1));
178  if (normalization < 1.)
179  continue;
180 
181  MEs_[kEENonFatal]->Fill(iDCC + 601.5, 1. / normalization);
182  }
183  }
184 
185  if (_evt.getByToken(towerIdErrorsToken_, eleHndl)) {
186  EcalElectronicsIdCollection::const_iterator eleEnd(eleHndl->end());
187  for (EcalElectronicsIdCollection::const_iterator eleItr(eleHndl->begin()); eleItr != eleEnd; ++eleItr) {
188  unsigned iDCC(eleItr->dccId() - 1);
189 
190  unsigned nonfatal(-1);
191  if ((SUBDET == EcalBarrel || SUBDET < 0) && iDCC >= ecaldqm::kEBmLow && iDCC <= ecaldqm::kEBpHigh)
192  nonfatal = kEBNonFatal;
193  else if ((SUBDET == EcalEndcap || SUBDET < 0) && (iDCC <= ecaldqm::kEEmHigh || iDCC >= ecaldqm::kEEpLow))
194  nonfatal = kEENonFatal;
195  else
196  continue;
197 
198  double normalization(ecaldqm::nCrystals(iDCC + 1));
199  if (normalization < 1.)
200  continue;
201 
202  MEs_[nonfatal]->Fill(iDCC + 601.5, 25. / normalization);
203  }
204  }
205 
206  if (_evt.getByToken(blockSizeErrorsToken_, eleHndl)) {
207  EcalElectronicsIdCollection::const_iterator eleEnd(eleHndl->end());
208  for (EcalElectronicsIdCollection::const_iterator eleItr(eleHndl->begin()); eleItr != eleEnd; ++eleItr) {
209  unsigned iDCC(eleItr->dccId() - 1);
210 
211  unsigned nonfatal(-1);
212  if ((SUBDET == EcalBarrel || SUBDET < 0) && iDCC >= ecaldqm::kEBmLow && iDCC <= ecaldqm::kEBpHigh)
213  nonfatal = kEBNonFatal;
214  else if ((SUBDET == EcalEndcap || SUBDET < 0) && (iDCC <= ecaldqm::kEEmHigh || iDCC >= ecaldqm::kEEpLow))
215  nonfatal = kEENonFatal;
216  else
217  continue;
218 
219  double normalization(ecaldqm::nCrystals(iDCC + 1));
220  if (normalization < 1.)
221  continue;
222 
223  MEs_[nonfatal]->Fill(iDCC + 601.5, 25. / normalization);
224  }
225  }
226 }
227 
228 template <int SUBDET>
230  electronicsMap = &_es.getData(elecMapHandle);
231 }
232 
233 template <int SUBDET>
235  if (!electronicsMap)
236  throw cms::Exception("InvalidCall") << "Electronics Mapping not initialized";
237  return electronicsMap;
238 }
239 
243 
EcalElectronicsMapping const * GetElectronicsMap()
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
EcalFEDMonitorTemp< EcalBarrel > EBHltTask
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::EDGetTokenT< EBDetIdCollection > ebChIdErrorsToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< EEDetIdCollection > eeGainSwitchErrorsToken_
EcalFEDMonitorTemp< EcalEndcap > EEHltTask
void setElectronicsMap(edm::EventSetup const &)
edm::EDGetTokenT< EBDetIdCollection > ebGainSwitchErrorsToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
unsigned nCrystals(unsigned)
Transition
Definition: Transition.h:12
unsigned dccId(DetId const &, EcalElectronicsMapping const *)
edm::EDGetTokenT< EEDetIdCollection > eeGainErrorsToken_
EcalFEDMonitorTemp<-1 > EcalFEDMonitor
unsigned long long uint64_t
Definition: Time.h:13
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< EEDetIdCollection > eeChIdErrorsToken_
void analyze(edm::Event const &, edm::EventSetup const &) override
EcalFEDMonitorTemp(edm::ParameterSet const &)
edm::EDGetTokenT< EBDetIdCollection > ebGainErrorsToken_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Definition: Run.h:45
std::vector< T >::const_iterator const_iterator
Definition: EDCollection.h:19