CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
14  for(;;) {
15 
16  uint32_t fed_id;
17  inputFile_ >> fed_id;
18 
19  if ( !( inputFile_.eof() || inputFile_.fail() ) ) {
20 
21  std::vector<uint16_t>::const_iterator it = find( fedIds_.begin(), fedIds_.end(), fed_id );
22  if( it == fedIds_.end() ) { fedIds_.push_back(fed_id); }
23  else {
24  edm::LogWarning("Unknown")
25  << "[SiStripFedIdListReader::" << __func__ << "]"
26  << " FedId " << fed_id << " has already been found in file!" << std::endl;
27  continue;
28  }
29 
30  } else if ( inputFile_.eof() ) {
31  edm::LogVerbatim("Unknown")
32  << "[SiStripFedIdListReader::" << __func__ << "]"
33  << " End of file reached! Found " << fedIds_.size()
34  << " valid FedIds!" << std::endl;
35  break;
36  } else if ( inputFile_.fail() ) {
37  edm::LogVerbatim("Unknown")
38  << "[SiStripFedIdListReader::" << __func__ << "]"
39  << " Error while reading file \"" << filePath << "\"!" << std::endl;
40  break;
41  }
42  }
43 
44  inputFile_.close();
45  } else {
46  edm::LogVerbatim("Unknown")
47  << "[SiStripFedIdListReader::" << __func__ << "]"
48  << " Unable to open file \"" << filePath << "\"!" << std::endl;
49  return;
50 
51  }
52 
53 }
54 
55 // -----------------------------------------------------------------------------
56 //
58  edm::LogVerbatim("Unknown")
59  << "[SiStripFedIdListReader::" << __func__ << "]";
60  fedIds_ = copy.fedIds_;
61 }
62 
63 // -----------------------------------------------------------------------------
64 //
66  edm::LogVerbatim("Unknown")
67  << "[SiStripFedIdListReader::" << __func__ << "]";
68  fedIds_ = copy.fedIds_;
69  return *this;
70 }
71 
72 // -----------------------------------------------------------------------------
73 //
75  edm::LogVerbatim("Unknown")
76  << "[SiStripFedIdListReader::" << __func__ << "]";
77 }
78 
79 
80 // -----------------------------------------------------------------------------
81 //
82 std::ostream& operator<< ( std::ostream& os, const SiStripFedIdListReader& in ) {
83  std::vector<uint16_t> fed_ids = in.fedIds();
84  std::stringstream ss;
85  ss << "[SiStripFedIdListReader::" << __func__ << "]"
86  << " Found " << fed_ids.size() << " valid FED ids with values: ";
87  std::vector<uint16_t>::const_iterator iter = fed_ids.begin();
88  for ( ; iter != fed_ids.end(); ++iter ) { ss << *iter << " "; }
89  os << ss.str();
90  return os;
91 }
92 
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const std::vector< uint16_t > & fedIds() const
std::vector< uint16_t > fedIds_
SiStripFedIdListReader & operator=(const SiStripFedIdListReader &)