CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions
SurveyPxbImageReader< T > Class Template Reference

Class to hold one picture of the BPix survey. More...

#include <SurveyPxbImageReader.h>

Public Types

typedef std::vector< Tmeasurements_t
 

Public Member Functions

SurveyPxbImage::count_t read (std::ifstream &infile, measurements_t &measurements, SurveyPxbImage::count_t reserve=830)
 
 SurveyPxbImageReader ()
 Empty default constructor. More...
 
 SurveyPxbImageReader (std::ifstream &infile, measurements_t &measurements, SurveyPxbImage::count_t reserve=800)
 Constructor with ifstream and destination vector. More...
 
 SurveyPxbImageReader (std::string filename, measurements_t &measurements, SurveyPxbImage::count_t reserve=800)
 Constructor with filename and destination vector. More...
 

Detailed Description

template<class T>
class SurveyPxbImageReader< T >

Class to hold one picture of the BPix survey.

Definition at line 15 of file SurveyPxbImageReader.h.

Member Typedef Documentation

◆ measurements_t

template<class T >
typedef std::vector<T> SurveyPxbImageReader< T >::measurements_t

Definition at line 17 of file SurveyPxbImageReader.h.

Constructor & Destructor Documentation

◆ SurveyPxbImageReader() [1/3]

template<class T >
SurveyPxbImageReader< T >::SurveyPxbImageReader ( )
inline

Empty default constructor.

Definition at line 21 of file SurveyPxbImageReader.h.

21 {};

◆ SurveyPxbImageReader() [2/3]

template<class T >
SurveyPxbImageReader< T >::SurveyPxbImageReader ( std::ifstream &  infile,
measurements_t measurements,
SurveyPxbImage::count_t  reserve = 800 
)
inline

Constructor with ifstream and destination vector.

Definition at line 23 of file SurveyPxbImageReader.h.

23  {
24  read(infile, measurements, reserve);
25  };

References timingPdfMaker::infile, and SurveyPxbImageReader< T >::read().

◆ SurveyPxbImageReader() [3/3]

template<class T >
SurveyPxbImageReader< T >::SurveyPxbImageReader ( std::string  filename,
measurements_t measurements,
SurveyPxbImage::count_t  reserve = 800 
)
inline

Constructor with filename and destination vector.

Definition at line 28 of file SurveyPxbImageReader.h.

28  {
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  };

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, corrVsCorr::filename, timingPdfMaker::infile, and SurveyPxbImageReader< T >::read().

Member Function Documentation

◆ read()

template<class T >
SurveyPxbImage::count_t SurveyPxbImageReader< T >::read ( std::ifstream &  infile,
measurements_t measurements,
SurveyPxbImage::count_t  reserve = 830 
)
inline

Reads a file, parses its content and fills the data vector All data after a hash sign (#) is treated as a comment and not read

Parameters
filenameFilename of the file to be read
measurementsVector containing the measurements, previous content will be deleted
reserveInitial size of the vector, set with vector::reserve()
Returns
number of succesfully read entries

Definition at line 42 of file SurveyPxbImageReader.h.

44  {
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  }

References filterCSVwithJSON::copy, spr::find(), recoMuon::in, timingPdfMaker::infile, AlCaHLTBitMon_QueryRunRegistry::string, and callgraph::stripped.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), and SurveyPxbImageReader< T >::SurveyPxbImageReader().

filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
callgraph.stripped
stripped
Definition: callgraph.py:100
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
recoMuon::in
Definition: RecoMuonEnumerators.h:6
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
T
long double T
Definition: Basic3DVectorLD.h:48
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:349
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8