CMS 3D CMS Logo

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