CMS 3D CMS Logo

SurveyPxbImageReader.h
Go to the documentation of this file.
1 #ifndef GUARD_surveypxbimagereader_h
2 #define GUARD_surveypxbimagereader_h
3 
5 
6 #include <algorithm>
7 #include <iostream>
8 #include <sstream>
9 #include <vector>
10 #include <fstream>
11 #include <string>
12 
14 template <class T>
16 public:
17  typedef std::vector<T> measurements_t;
18 
19  // Constructors
23  SurveyPxbImageReader(std::ifstream &infile, measurements_t &measurements, SurveyPxbImage::count_t reserve = 800) {
24  read(infile, measurements, reserve);
25  };
26 
29  std::ifstream infile(filename.c_str());
30  if (!infile) {
31  std::cerr << "Cannot open file " << filename << " - operation aborted." << std::endl;
32  }
33  read(infile, measurements, reserve);
34  };
35 
43  measurements_t &measurements,
44  SurveyPxbImage::count_t reserve = 830) {
45  // prepare the measurements vector
46  measurements.clear();
47  measurements.reserve(reserve);
48 
49  // container for the current line
50  std::string aLine;
51 
52  // loop over lines of input file
53  while (std::getline(infile, aLine)) {
54  // strip off everything after a hash
55  std::string stripped = "";
56  std::string::iterator iter = std::find(aLine.begin(), aLine.end(), '#');
57  std::copy(aLine.begin(), iter, std::back_inserter(stripped));
58  // read one measurment and add to vector if successfull
59  std::istringstream iss(stripped, std::istringstream::in);
60  T curMeas(iss);
61  if (curMeas.isValid()) {
62  measurements.push_back(curMeas);
63  }
64  }
65 
66  return measurements.size();
67  }
68 
69 protected:
70 };
71 
72 #endif
SurveyPxbImageReader::SurveyPxbImageReader
SurveyPxbImageReader(std::string filename, measurements_t &measurements, SurveyPxbImage::count_t reserve=800)
Constructor with filename and destination vector.
Definition: SurveyPxbImageReader.h:28
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
SurveyPxbImage.h
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
SurveyPxbImageReader
Class to hold one picture of the BPix survey.
Definition: SurveyPxbImageReader.h:15
SurveyPxbImageReader::measurements_t
std::vector< T > measurements_t
Definition: SurveyPxbImageReader.h:17
callgraph.stripped
stripped
Definition: callgraph.py:65
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
SurveyPxbImageReader::SurveyPxbImageReader
SurveyPxbImageReader(std::ifstream &infile, measurements_t &measurements, SurveyPxbImage::count_t reserve=800)
Constructor with ifstream and destination vector.
Definition: SurveyPxbImageReader.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SurveyPxbImage::count_t
unsigned int count_t
Definition: SurveyPxbImage.h:14
recoMuon::in
Definition: RecoMuonEnumerators.h:6
T
long double T
Definition: Basic3DVectorLD.h:48
SurveyPxbImageReader::SurveyPxbImageReader
SurveyPxbImageReader()
Empty default constructor.
Definition: SurveyPxbImageReader.h:21
SurveyPxbImageReader::read
SurveyPxbImage::count_t read(std::ifstream &infile, measurements_t &measurements, SurveyPxbImage::count_t reserve=830)
Definition: SurveyPxbImageReader.h:42
timingPdfMaker.infile
infile
Definition: timingPdfMaker.py:350
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8