CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiPixelFEDChannelContainer.cc
Go to the documentation of this file.
4 #include <iostream>
5 #include <iomanip> // std::setw
6 
7 //****************************************************************************//
9  const SiPixelFEDChannelCollection &theBadFEDChannels) {
10  if (m_scenarioMap.find(theScenarioId) != m_scenarioMap.end()) {
11  edm::LogWarning("SiPixelFEDChannelContainer")
12  << "Scenario: " << theScenarioId << " is already in the map!" << std::endl;
13  return;
14  } else {
15  m_scenarioMap.emplace(theScenarioId, theBadFEDChannels);
16  }
17 }
18 
19 //****************************************************************************//
21  const std::string &theScenarioId) const {
22  SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId);
23 
24  if (it != m_scenarioMap.end()) {
25  return it->second;
26  } else {
27  throw cms::Exception("SiPixelFEDChannelContainer")
28  << "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n";
29  }
30 }
31 
32 //****************************************************************************//
34  const std::string &theScenarioId) {
35  SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId);
36 
37  if (it != m_scenarioMap.end()) {
38  return it->second;
39  } else {
40  throw cms::Exception("SiPixelFEDChannelContainer")
41  << "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n";
42  }
43 }
44 
45 //****************************************************************************//
47  const std::string &theScenarioId, DetId theDetId) {
48  SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId);
49 
50  if (it == m_scenarioMap.end()) {
51  throw cms::Exception("SiPixelFEDChannelContainer")
52  << "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n";
53  } else {
54  SiPixelFEDChannelCollection::const_iterator it2 = (it->second).find(theDetId);
55 
56  if (it2 == (it->second).end()) {
57  throw cms::Exception("SiPixelFEDChannelContainer")
58  << "No Bad Pixel FEDChannels defined for DetId:" << theDetId << " in Scenario id: " << theScenarioId << "\n";
59  }
60  return it2->second;
61  }
62 }
63 
64 //****************************************************************************//
65 std::unique_ptr<PixelFEDChannelCollection> SiPixelFEDChannelContainer::getDetSetBadPixelFedChannels(
66  const std::string &theScenarioId) const {
67  SiPixelBadFEDChannelsScenarioMap::const_iterator it = m_scenarioMap.find(theScenarioId);
68 
69  if (it == m_scenarioMap.end()) {
70  throw cms::Exception("SiPixelFEDChannelContainer")
71  << "No Bad Pixel FEDChannels defined for Scenario id: " << theScenarioId << "\n";
72  }
73 
74  std::unique_ptr<PixelFEDChannelCollection> disabled_channelcollection =
75  std::make_unique<edmNew::DetSetVector<PixelFEDChannel> >();
76  auto SiPixelBadFedChannels = it->second;
77  for (const auto &entry : SiPixelBadFedChannels) {
78  disabled_channelcollection->insert(entry.first, entry.second.data(), entry.second.size());
79  }
80  return disabled_channelcollection;
81 }
82 
83 //****************************************************************************//
85  edm::LogVerbatim("SiPixelFEDChannelContainer") << "SiPixelFEDChannelContainer::printAll()";
86  edm::LogVerbatim("SiPixelFEDChannelContainer") << " ================================================================="
87  "==================================================";
88  for (auto it = m_scenarioMap.begin(); it != m_scenarioMap.end(); ++it) {
89  edm::LogVerbatim("SiPixelFEDChannelContainer") << "run :" << it->first << " \n ";
90  for (const auto &thePixelFEDChannel : it->second) {
91  DetId detId = thePixelFEDChannel.first;
92 
93  edm::LogVerbatim("SiPixelFEDChannelContainer") << "DetId :" << detId << " \n ";
94 
95  for (const auto &entry : thePixelFEDChannel.second) {
96  //unsigned int fed, link, roc_first, roc_last;
97  edm::LogVerbatim("SiPixelFEDChannelContainer")
98  << " fed : " << entry.fed << " link : " << entry.link << " roc_first : " << entry.roc_first
99  << " roc_last: : " << entry.roc_last;
100  }
101  }
102  }
103 }
104 
105 //****************************************************************************//
106 void SiPixelFEDChannelContainer::print(std::ostream &os) const {
107  for (auto it = m_scenarioMap.begin(); it != m_scenarioMap.end(); ++it) {
108  os << "run :" << it->first << " \n ";
109  for (const auto &thePixelFEDChannel : it->second) {
110  DetId detId = thePixelFEDChannel.first;
111  os << "DetId :" << detId << " \n ";
112  for (const auto &entry : thePixelFEDChannel.second) {
113  os << " fed : " << entry.fed << " link : " << entry.link << " roc_first : " << entry.roc_first
114  << " roc_last: : " << entry.roc_last;
115  }
116  }
117  }
118 }
119 
120 //****************************************************************************//
121 std::vector<std::string> SiPixelFEDChannelContainer::getScenarioList() const {
122  std::vector<std::string> scenarios;
123  scenarios.reserve(m_scenarioMap.size());
124 
125  for (auto it = m_scenarioMap.begin(); it != m_scenarioMap.end(); ++it) {
126  scenarios.push_back(it->first);
127  }
128  return scenarios;
129 }
130 
131 //****************************************************************************//
132 std::ostream &operator<<(std::ostream &os, SiPixelFEDChannelContainer FEDChannels) {
133  std::stringstream ss;
134  FEDChannels.print(ss);
135  os << ss.str();
136  return os;
137 }
SiPixelBadFEDChannelsScenarioMap m_scenarioMap
Log< level::Info, true > LogVerbatim
std::vector< std::string > getScenarioList() const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
void print(std::ostream &os) const
Definition: DetId.h:17
void setScenario(const std::string &theScenarioId, const SiPixelFEDChannelCollection &theBadFEDChannels)
SiPixelFEDChannelCollection getSiPixelBadFedChannels(const std::string &ScenarioId) const
std::unique_ptr< PixelFEDChannelCollection > getDetSetBadPixelFedChannels(const std::string &ScenarioId) const
list entry
Definition: mps_splice.py:68
Log< level::Warning, false > LogWarning
const std::vector< PixelFEDChannel > & getSiPixelBadFedChannelsInDetId(const std::string &theScenarioId, DetId theDetId)
std::map< DetId, std::vector< PixelFEDChannel > > SiPixelFEDChannelCollection