CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SiStripFedIdListReader.cc
Go to the documentation of this file.
3 #include <algorithm>
4 #include <sstream>
5 
6 // -----------------------------------------------------------------------------
7 //
9  fedIds_.clear();
10  inputFile_.open(filePath.c_str());
11 
12  if (inputFile_.is_open()) {
13  for (;;) {
14  uint32_t fed_id;
15  inputFile_ >> fed_id;
16 
17  if (!(inputFile_.eof() || inputFile_.fail())) {
18  std::vector<uint16_t>::const_iterator it = find(fedIds_.begin(), fedIds_.end(), fed_id);
19  if (it == fedIds_.end()) {
20  fedIds_.push_back(fed_id);
21  } else {
22  edm::LogWarning("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]"
23  << " FedId " << fed_id << " has already been found in file!" << std::endl;
24  continue;
25  }
26 
27  } else if (inputFile_.eof()) {
28  edm::LogVerbatim("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]"
29  << " End of file reached! Found " << fedIds_.size() << " valid FedIds!"
30  << std::endl;
31  break;
32  } else if (inputFile_.fail()) {
33  edm::LogVerbatim("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]"
34  << " Error while reading file \"" << filePath << "\"!" << std::endl;
35  break;
36  }
37  }
38 
39  inputFile_.close();
40  } else {
41  edm::LogVerbatim("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]"
42  << " Unable to open file \"" << filePath << "\"!" << std::endl;
43  return;
44  }
45 }
46 
47 // -----------------------------------------------------------------------------
48 //
50  edm::LogVerbatim("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]";
51  fedIds_ = copy.fedIds_;
52 }
53 
54 // -----------------------------------------------------------------------------
55 //
57  edm::LogVerbatim("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]";
58  fedIds_ = copy.fedIds_;
59  return *this;
60 }
61 
62 // -----------------------------------------------------------------------------
63 //
65  edm::LogVerbatim("Unknown") << "[SiStripFedIdListReader::" << __func__ << "]";
66 }
67 
68 // -----------------------------------------------------------------------------
69 //
70 std::ostream& operator<<(std::ostream& os, const SiStripFedIdListReader& in) {
71  std::vector<uint16_t> fed_ids = in.fedIds();
72  std::stringstream ss;
73  ss << "[SiStripFedIdListReader::" << __func__ << "]"
74  << " Found " << fed_ids.size() << " valid FED ids with values: ";
75  std::vector<uint16_t>::const_iterator iter = fed_ids.begin();
76  for (; iter != fed_ids.end(); ++iter) {
77  ss << *iter << " ";
78  }
79  os << ss.str();
80  return os;
81 }
Log< level::Info, true > LogVerbatim
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
const std::vector< uint16_t > & fedIds() const
std::vector< uint16_t > fedIds_
Log< level::Warning, false > LogWarning
SiStripFedIdListReader & operator=(const SiStripFedIdListReader &)