CMS 3D CMS Logo

Public Types | Public Member Functions

SurveyPxbImageReader< T > Class Template Reference

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

#include <SurveyPxbImageReader.h>

List of all members.

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 (std::ifstream &infile, measurements_t &measurements, SurveyPxbImage::count_t reserve=800)
 Constructor with ifstream and destination vector.
 SurveyPxbImageReader (std::string filename, measurements_t &measurements, SurveyPxbImage::count_t reserve=800)
 Constructor with filename and destination vector.
 SurveyPxbImageReader ()
 Empty default constructor.

Detailed Description

template<class T>
class SurveyPxbImageReader< T >

Class to hold one picture of the BPix survey.

Definition at line 10 of file SurveyPxbImageReader.h.


Member Typedef Documentation

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

Definition at line 13 of file SurveyPxbImageReader.h.


Constructor & Destructor Documentation

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

Empty default constructor.

Definition at line 17 of file SurveyPxbImageReader.h.

{};
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 19 of file SurveyPxbImageReader.h.

References SurveyPxbImageReader< T >::read().

        {
                read(infile, measurements, reserve);
        };
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 25 of file SurveyPxbImageReader.h.

References dtNoiseDBValidation_cfg::cerr, EdgesToViz::infile, and SurveyPxbImageReader< T >::read().

        { 
                std::ifstream infile(filename.c_str());
                if (!infile)
                {
                        std::cerr << "Cannot open file " << filename
                             << " - operation aborted." << std::endl;
                }
                read(infile, measurements, reserve);
        };

Member Function Documentation

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.

References filterCSVwithJSON::copy, spr::find(), recoMuon::in, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by SurveyPxbImageReader< T >::SurveyPxbImageReader().

        {

                // prepare the measurements vector
                measurements.clear();
                measurements.reserve(reserve);

                // container for the current line
                std::string aLine;

            // loop over lines of input file
            while (std::getline(infile,aLine))
            {
                // strip off everything after a hash
                std::string stripped = "";
                std::string::iterator iter = std::find(aLine.begin(), aLine.end(), '#');
                std::copy(aLine.begin(), iter, std::back_inserter(stripped));
                // read one measurment and add to vector if successfull
                std::istringstream iss(stripped, std::istringstream::in);
                T curMeas(iss);
                if (curMeas.isValid())
                {
                     measurements.push_back(curMeas);
                }
            }

                return measurements.size();
        }