CMS 3D CMS Logo

SiStripDaqInfo.cc
Go to the documentation of this file.
4 
6 
7 #include "SiStripDaqInfo.h"
10 
11 //Run Info
13 
14 // FED cabling and numbering
16 
17 #include <cassert>
18 #include <cmath>
19 #include <cstdio>
20 #include <iomanip>
21 #include <iostream>
22 #include <sstream>
23 #include <string>
24 #include <vector>
25 
27  : fedCablingToken_{esConsumes<edm::Transition::BeginRun>()},
28  tTopoToken_{esConsumes<edm::Transition::BeginRun>()},
29  runInfoToken_{esConsumes<edm::Transition::BeginRun>()} {
30  edm::LogInfo("SiStripDaqInfo") << "SiStripDaqInfo::Deleting SiStripDaqInfo ";
31 }
32 
33 //
34 // -- Book MEs for SiStrip Daq Fraction
35 //
37  edm::LogInfo("SiStripDcsInfo") << " SiStripDaqInfo::bookStatus " << bookedStatus_;
38  if (bookedStatus_)
39  return;
40 
41  dqm_store.cd();
42  std::string strip_dir = "";
43  SiStripUtility::getTopFolderPath(dqm_store, "SiStrip", strip_dir);
44  if (!strip_dir.empty())
45  dqm_store.setCurrentFolder(strip_dir + "/EventInfo");
46  else
47  dqm_store.setCurrentFolder("SiStrip/EventInfo");
48 
49  daqFraction_ = dqm_store.bookFloat("DAQSummary");
50 
51  dqm_store.cd();
52  if (!strip_dir.empty())
53  dqm_store.setCurrentFolder(strip_dir + "/EventInfo/DAQContents");
54  else
55  dqm_store.setCurrentFolder("SiStrip/EventInfo/DAQContents");
56 
57  std::vector<std::string> det_types;
58  det_types.push_back("TIB");
59  det_types.push_back("TOB");
60  det_types.push_back("TIDF");
61  det_types.push_back("TIDB");
62  det_types.push_back("TECF");
63  det_types.push_back("TECB");
64 
65  for (auto const& det : det_types) {
66  std::string const me_name{"SiStrip_" + det};
67  SubDetMEs local_mes{dqm_store.bookFloat(me_name), 0};
68  subDetMEsMap_.emplace(det, local_mes);
69  }
70  bookedStatus_ = true;
71  dqm_store.cd();
72 }
73 //
74 // -- Fill with Dummy values
75 //
77  if (!bookedStatus_) {
78  bookStatus(dqm_store);
79  }
81 
82  for (auto& pr : subDetMEsMap_) {
83  pr.second.daqFractionME->Reset();
84  pr.second.daqFractionME->Fill(-1.0);
85  }
87  daqFraction_->Fill(-1.0);
88 }
89 
91  edm::LogInfo("SiStripDaqInfo") << "SiStripDaqInfo:: Begining of Run";
92 
93  // Check latest Fed cabling and create TrackerMapCreator
94  if (fedCablingWatcher_.check(eSetup)) {
96  readFedIds(fedCabling_, eSetup);
97  }
98  auto& dqm_store = *edm::Service<DQMStore>{};
99  if (!bookedStatus_) {
100  bookStatus(dqm_store);
101  }
102  if (nFedTotal_ == 0) {
103  fillDummyStatus(dqm_store);
104  edm::LogInfo("SiStripDaqInfo") << " SiStripDaqInfo::No FEDs Connected!!!";
105  return;
106  }
107 
108  float nFEDConnected = 0.0;
109  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
110  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
111 
112  if (!eSetup.tryToGet<RunInfoRcd>())
113  return;
114  auto sumFED = eSetup.getHandle(runInfoToken_);
115  if (!sumFED)
116  return;
117 
118  auto const& fedsInIds = sumFED->m_fed_in;
119  for (auto const fedID : fedsInIds) {
120  if (fedID >= siStripFedIdMin && fedID <= siStripFedIdMax)
121  ++nFEDConnected;
122  }
123  edm::LogInfo("SiStripDaqInfo") << " SiStripDaqInfo::Total # of FEDs " << nFedTotal_ << " Connected FEDs "
124  << nFEDConnected;
125  if (nFEDConnected > 0) {
126  daqFraction_->Reset();
127  daqFraction_->Fill(nFEDConnected / nFedTotal_);
128  readSubdetFedFractions(dqm_store, fedsInIds, eSetup);
129  }
130 }
131 
133 
134 //
135 // -- Read Sub Detector FEDs
136 //
137 void SiStripDaqInfo::readFedIds(const SiStripFedCabling* fedcabling, edm::EventSetup const& iSetup) {
138  //Retrieve tracker topology from geometry
139  const auto tTopo = &iSetup.getData(tTopoToken_);
140 
141  auto feds = fedCabling_->fedIds();
142 
143  nFedTotal_ = feds.size();
144  for (auto const fed : feds) {
145  auto fedChannels = fedCabling_->fedConnections(fed);
146  for (auto const& conn : fedChannels) {
147  if (!conn.isConnected())
148  continue;
149  uint32_t detId = conn.detId();
150  if (detId == 0 || detId == 0xFFFFFFFF)
151  continue;
154  subDetFedMap_[subdet_tag].push_back(fed);
155  break;
156  }
157  }
158 }
159 //
160 // -- Fill Subdet FEDIds
161 //
163  std::vector<int> const& fed_ids,
164  edm::EventSetup const& iSetup) {
165  //Retrieve tracker topology from geometry
166  const auto tTopo = &iSetup.getData(tTopoToken_);
167 
168  constexpr int siStripFedIdMin{FEDNumbering::MINSiStripFEDID};
169  constexpr int siStripFedIdMax{FEDNumbering::MAXSiStripFEDID};
170 
171  // initialiase
172  for (auto const& pr : subDetFedMap_) {
173  auto const& name = pr.first;
174  auto iPos = subDetMEsMap_.find(name);
175  if (iPos == subDetMEsMap_.end())
176  continue;
177  iPos->second.connectedFeds = 0;
178  }
179  // count sub detector feds
180 
181  for (auto const& [name, subdetIds] : subDetFedMap_) {
182  auto iPos = subDetMEsMap_.find(name);
183  if (iPos == subDetMEsMap_.end())
184  continue;
185  iPos->second.connectedFeds = 0;
186  for (auto const subdetId : subdetIds) {
187  bool fedid_found = false;
188  for (auto const fedId : fed_ids) {
189  if (fedId < siStripFedIdMin || fedId > siStripFedIdMax)
190  continue;
191  if (subdetId == fedId) {
192  fedid_found = true;
193  iPos->second.connectedFeds++;
194  break;
195  }
196  }
197  if (!fedid_found)
198  findExcludedModule(dqm_store, subdetId, tTopo);
199  }
200  if (auto nFedSubDet = subdetIds.size(); nFedSubDet > 0) {
201  iPos->second.daqFractionME->Reset();
202  int const nFedsConnected = iPos->second.connectedFeds;
203  iPos->second.daqFractionME->Fill(nFedsConnected * 1.0 / nFedSubDet);
204  }
205  }
206 }
207 //
208 // -- find Excluded Modules
209 //
211  unsigned short const fed_id,
212  TrackerTopology const* tTopo) {
213  dqm_store.cd();
214  std::string mdir = "MechanicalView";
215  if (!SiStripUtility::goToDir(dqm_store, mdir)) {
216  dqm_store.setCurrentFolder("SiStrip/" + mdir);
217  }
218  std::string mechanical_dir = dqm_store.pwd();
219  auto fedChannels = fedCabling_->fedConnections(fed_id);
220  int ichannel = 0;
221  std::string tag = "ExcludedFedChannel";
222  std::string bad_module_folder;
223  for (auto const& conn : fedChannels) {
224  if (!conn.isConnected())
225  continue;
226  uint32_t detId = conn.detId();
227  if (detId == 0 || detId == 0xFFFFFFFF)
228  continue;
229 
230  ichannel++;
231  if (ichannel == 1) {
232  std::string subdet_folder;
233  SiStripFolderOrganizer folder_organizer;
234  folder_organizer.getSubDetFolder(detId, tTopo, subdet_folder);
235  if (!dqm_store.dirExists(subdet_folder)) {
236  subdet_folder = mechanical_dir + subdet_folder.substr(subdet_folder.find(mdir) + mdir.size());
237  }
238  bad_module_folder = subdet_folder + "/" + "BadModuleList";
239  dqm_store.setCurrentFolder(bad_module_folder);
240  }
241  std::ostringstream detid_str;
242  detid_str << detId;
243  std::string full_path = bad_module_folder + "/" + detid_str.str();
244  MonitorElement* me = dqm_store.get(full_path);
245  uint16_t flag = 0;
246  if (me) {
247  flag = me->getIntValue();
248  me->Reset();
249  } else
250  me = dqm_store.bookInt(detid_str.str());
252  me->Fill(flag);
253  }
254  dqm_store.cd();
255 }
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
FEDNumbering.h
l1tstage2emulator_dqm_sourceclient-live_cfg.feds
feds
Definition: l1tstage2emulator_dqm_sourceclient-live_cfg.py:153
MessageLogger.h
SiStripFolderOrganizer.h
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
SiStripDaqInfo
Definition: SiStripDaqInfo.h:47
edm::Run
Definition: Run.h:45
TrackerTopology
Definition: TrackerTopology.h:16
SiStripDaqInfo::findExcludedModule
void findExcludedModule(DQMStore &dqm_store, unsigned short fed_id, TrackerTopology const *tTopo)
Definition: SiStripDaqInfo.cc:210
SiStripDaqInfo::runInfoToken_
edm::ESGetToken< RunInfo, RunInfoRcd > runInfoToken_
Definition: SiStripDaqInfo.h:82
SiStripCommissioningClient_cfg.conn
conn
Definition: SiStripCommissioningClient_cfg.py:5
SiStripDaqInfo::subDetFedMap_
std::map< std::string, std::vector< unsigned short > > subDetFedMap_
Definition: SiStripDaqInfo.h:64
cms::cuda::assert
assert(be >=bs)
DQMStore.h
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
SiStripUtility.h
MakerMacros.h
edm::EventSetup::tryToGet
std::optional< T > tryToGet() const
Definition: EventSetup.h:108
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:728
Service.h
SiStripDaqInfo::SiStripDaqInfo
SiStripDaqInfo(edm::ParameterSet const &ps)
Definition: SiStripDaqInfo.cc:26
SiStripDaqInfo::daqFraction_
MonitorElement * daqFraction_
Definition: SiStripDaqInfo.h:66
FEDNumbering::MINSiStripFEDID
Definition: FEDNumbering.h:29
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
dqm::impl::MonitorElement::Reset
virtual void Reset()
Remove all data from the ME, keept the empty histogram with all its settings.
Definition: MonitorElement.cc:354
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
SiStripDaqInfo::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: SiStripDaqInfo.cc:132
SiStripDaqInfo::bookedStatus_
bool bookedStatus_
Definition: SiStripDaqInfo.h:76
RunInfoRcd
Definition: RunSummaryRcd.h:26
SiStripDaqInfo::fillDummyStatus
void fillDummyStatus(DQMStore &dqm_store)
Definition: SiStripDaqInfo.cc:76
dqm::implementation::DQMStore::pwd
std::string pwd() override
Definition: DQMStore.h:567
edm::ParameterSet
Definition: ParameterSet.h:47
sipixeldigitoraw
Definition: SiPixelDigiToRaw.cc:32
SiStripFolderOrganizer::getSubDetFolder
void getSubDetFolder(const uint32_t &detid, const TrackerTopology *tTopo, std::string &folder_name)
Definition: SiStripFolderOrganizer.cc:406
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
SiStripDaqInfo::tTopoToken_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
Definition: SiStripDaqInfo.h:81
SiStripDaqInfo::readFedIds
void readFedIds(const SiStripFedCabling *fedcabling, edm::EventSetup const &iSetup)
Definition: SiStripDaqInfo.cc:137
SiStripDaqInfo::fedCablingWatcher_
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
Definition: SiStripDaqInfo.h:79
SiStripUtility::goToDir
static bool goToDir(DQMStore &dqm_store, std::string const &name)
Definition: SiStripUtility.cc:252
dqm::implementation::IBooker::bookInt
MonitorElement * bookInt(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:73
SiStripDaqInfo::fedCabling_
const SiStripFedCabling * fedCabling_
Definition: SiStripDaqInfo.h:78
edm::Service
Definition: Service.h:30
SiStripDaqInfo::fedCablingToken_
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Definition: SiStripDaqInfo.h:80
SiStripDaqInfo::SubDetMEs
Definition: SiStripDaqInfo.h:68
SiStripDaqInfo::nFedTotal_
int nFedTotal_
Definition: SiStripDaqInfo.h:75
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
SiStripDaqInfo::readSubdetFedFractions
void readSubdetFedFractions(DQMStore &dqm_store, std::vector< int > const &fed_ids, edm::EventSetup const &iSetup)
Definition: SiStripDaqInfo.cc:162
edm::EventSetup
Definition: EventSetup.h:58
l1tstage2_dqm_sourceclient-live_cfg.fedId
fedId
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:89
SiStripDaqInfo.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SiStripUtility::getSubDetectorTag
static void getSubDetectorTag(uint32_t det_id, std::string &subdet_tag, const TrackerTopology *tTopo)
Definition: SiStripUtility.cc:296
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
RunInfo.h
writedatasetfile.run
run
Definition: writedatasetfile.py:27
SiStripFolderOrganizer
Definition: SiStripFolderOrganizer.h:27
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
FEDNumbering::MAXSiStripFEDID
Definition: FEDNumbering.h:30
SiStripFedCabling::fedIds
FedsConstIterRange fedIds() const
Definition: SiStripFedCabling.h:154
SiStripDaqInfo::subDetMEsMap_
std::map< std::string, SubDetMEs > subDetMEsMap_
Definition: SiStripDaqInfo.h:73
SiStripDaqInfo::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup) override
Definition: SiStripDaqInfo.cc:90
ParameterSet.h
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
xuti::subdet_tag
const std::string subdet_tag("SubDet")
SiStripDaqInfo::bookStatus
void bookStatus(DQMStore &dqm_store)
Definition: SiStripDaqInfo.cc:36
event
Definition: event.py:1
SiStripFedCabling::fedConnections
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Definition: SiStripFedCabling.cc:160
edm::Event
Definition: Event.h:73
SiStripUtility::setBadModuleFlag
static void setBadModuleFlag(std::string &hname, uint16_t &flg)
Definition: SiStripUtility.cc:328
dqm::implementation::IGetter::dirExists
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:730
SiStripUtility::getTopFolderPath
static void getTopFolderPath(DQMStore &dqm_store, std::string const &top_dir, std::string &path)
Definition: SiStripUtility.cc:362
dqm::implementation::DQMStore::cd
void cd() override
Definition: DQMStore.h:564
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117