test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
CocoaDaqReaderText Class Reference

#include <CocoaDaqReaderText.h>

Inheritance diagram for CocoaDaqReaderText:
CocoaDaqReader

Public Member Functions

virtual void BuildMeasurementsFromOptAlign (std::vector< OpticalAlignMeasurementInfo > &measList)
 
 CocoaDaqReaderText (const std::string &fileName)
 
int GetNEvents () const
 
virtual bool ReadNextEvent ()
 
virtual ~CocoaDaqReaderText ()
 
- Public Member Functions inherited from CocoaDaqReader
 CocoaDaqReader ()
 
int GetNEvents () const
 
virtual bool ReadEvent (int nev)
 
virtual ~CocoaDaqReader ()
 

Protected Attributes

int nev
 
int nextEvent
 
ALIFileIn theFilein
 
- Protected Attributes inherited from CocoaDaqReader
int nev
 
int nextEvent
 

Additional Inherited Members

- Static Public Member Functions inherited from CocoaDaqReader
static CocoaDaqReaderGetDaqReader ()
 
static void SetDaqReader (CocoaDaqReader *reader)
 

Detailed Description

Definition at line 11 of file CocoaDaqReaderText.h.

Constructor & Destructor Documentation

CocoaDaqReaderText::CocoaDaqReaderText ( const std::string &  fileName)

Definition at line 12 of file CocoaDaqReaderText.cc.

References gather_cfg::cout, ALIUtils::debug, ALIFileIn::getInstance(), and CocoaDaqReader::SetDaqReader().

13 {
14 
15  if(ALIUtils::debug >= 5) std::cout << " CocoaDaqReaderText::CocoaDaqReaderText from file " << fileName << std::endl;
16 
18 
20 
21 }
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:23
static ALIint debug
Definition: ALIUtils.h:35
static void SetDaqReader(CocoaDaqReader *reader)
tuple cout
Definition: gather_cfg.py:121
CocoaDaqReaderText::~CocoaDaqReaderText ( )
virtual

Definition at line 24 of file CocoaDaqReaderText.cc.

25 {
26 }

Member Function Documentation

void CocoaDaqReaderText::BuildMeasurementsFromOptAlign ( std::vector< OpticalAlignMeasurementInfo > &  measList)
virtual

Reimplemented from CocoaDaqReader.

Definition at line 136 of file CocoaDaqReaderText.cc.

137 {
138 
139 }
int CocoaDaqReaderText::GetNEvents ( ) const
inline

Definition at line 21 of file CocoaDaqReaderText.h.

References nev.

21 { return nev; }
bool CocoaDaqReaderText::ReadNextEvent ( )
virtual

Implements CocoaDaqReader.

Definition at line 29 of file CocoaDaqReaderText.cc.

References begin, dtNoiseDBValidation_cfg::cerr, Measurement::correctValueAndSigma(), gather_cfg::cout, ALIUtils::debug, Measurement::dim(), ALIUtils::dumpVS(), end, cmsRelvalreport::exit, Measurement::fillData(), GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), cuy::ii, Model::MeasurementList(), Measurement::setCurrentDate(), Measurement::setSigma(), Measurement::sigma(), and Measurement::valueType().

30 {
31  std::vector<ALIstring> wordlist;
32  //---------- read date
33  // ALIint retfil = filein.getWordsInLine(wordlist);
34  // std::cout << "@@@@@@@@@@@@@@@ RETFIL " << retfil << std::endl;
35  //if( retfil == 0 ) {
36  if( theFilein.getWordsInLine(wordlist) == 0 ) {
37  if(ALIUtils::debug>=4 ) std::cout << "@@@@ No more measurements left" << std::endl;
38  return 0;
39  }
40 
42  // struct tm tim;
43  //t Model::setMeasurementsTime( tim );
44 
45  //set date and time of current measurement
46  if( wordlist[0] == "DATE:" ) {
47  Measurement::setCurrentDate( wordlist );
48  }
49 
50  //---------- loop measurements
51  ALIint nMeas = Model::MeasurementList().size();
52  if(ALIUtils::debug >= 4) {
53  std::cout << " Reading " << nMeas << " measurements from file " << theFilein.name()
54  << " DATE: " << wordlist[1] << " " << wordlist[1] << std::endl;
55  }
56  for( ALIint im = 0; im < nMeas; im++) {
57  theFilein.getWordsInLine(wordlist);
58  if( wordlist[0] == ALIstring("SENSOR2D") || wordlist[0] == ALIstring("TILTMETER") || wordlist[0] == ALIstring("DISTANCEMETER") || wordlist[0] == ALIstring("DISTANCEMETER1DIM") || wordlist[0] == ALIstring("COPS") ) {
59  if( wordlist.size() != 2 ) {
60  std::cerr << "!!!EXITING Model::readMeasurementsFromFile. number of words should be 2 instead of " << wordlist.size() << std::endl;
61  ALIUtils::dumpVS( wordlist, " " );
62  exit(1);
63  }
64  std::vector< Measurement* >::const_iterator vmcite;
65  for( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); vmcite++ ) {
66  //---- Look for Measurement
67  /* ALIint last_slash = (*vmcite)->name().rfind('/');
68  ALIstring oname = (*vmcite)->name();
69  if( last_slash != -1 ) {
70  oname = oname.substr(last_slash+1, (*vmcite)->name().size()-1);
71  }
72  */
73  ALIint fcolon = (*vmcite)->name().find(':');
74  ALIstring oname = (*vmcite)->name();
75  oname = oname.substr(fcolon+1,oname.length());
76  //- std::cout << " measurement name " << (*vmcite)->name() << " short " << oname << std::endl;
77  if( oname == wordlist[1] ) {
78  //-------- Measurement found, fill data
79  //- std::cout << " measurement name found " << oname << std::endl;
80  if( (*vmcite)->type() != wordlist[0] ) {
81  std::cerr << "!!! Reading measurement from file: type in file is "
82  << wordlist[0] << " and should be " << (*vmcite)->type() << std::endl;
83  exit(1);
84  }
85  Measurement* meastemp = *vmcite;
86 
88  ALIbool sigmaFF = gomgr->GlobalOptions()["measurementErrorFromFile"];
89  //---------- Read the data
90  for ( unsigned int ii=0; ii < meastemp->dim(); ii++){
91  theFilein.getWordsInLine( wordlist );
92  ALIdouble sigma = 0.;
93  if( !sigmaFF ) {
94  // keep the sigma, do not read it from file
95  const ALIdouble* sigmav = meastemp->sigma();
96  sigma = sigmav[ii];
97  }
98  //---- Check measurement value type is OK
99  if( meastemp->valueType(ii) != wordlist[0] ) {
101  std::cerr << "!!!FATAL ERROR: Measurement value type is " << wordlist[0] << " while in setup definition was " << meastemp->valueType(ii) << std::endl;
102  exit(1);
103  }
104  meastemp->fillData( ii, wordlist );
105  if( !sigmaFF ) {
106  meastemp->setSigma( ii, sigma );
107  }
108  }
109  meastemp->correctValueAndSigma();
110  break;
111  }
112  }
113  if( vmcite == Model::MeasurementList().end() ) {
114  for( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); vmcite++ ) {
115  std::cerr << "MEAS: " << (*vmcite)->name() << " " << (*vmcite)->type() << std::endl;
116  }
117  std::cerr << "!!! Reading measurement from file: measurement not found in list: type in file is " << wordlist[1] << std::endl;
118  exit(1);
119  }
120  } else {
121  std::cerr << " wrong type of measurement: " << wordlist[0] << std::endl
122  << " Available types are SENSOR2D, TILTMETER, DISTANCEMETER, DISTANCEMETER1DIM, COPS" << std::endl;
123  exit(1);
124  }
125  }
126  //- std::cout << " returning readmeasff" << std::endl;
127 
128  if( theFilein.eof() ) {
129  return 0;
130  } else {
131  return 1;
132  }
133 }
long double ALIdouble
Definition: CocoaGlobals.h:11
ALIbool eof()
Definition: ALIFileIn.cc:211
const ALIstring & name()
Definition: ALIFileIn.h:44
const ALIuint dim() const
Definition: Measurement.h:82
const ALIstring valueType(ALIuint ii) const
Definition: Measurement.h:140
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:35
static GlobalOptionMgr * getInstance()
int ii
Definition: cuy.py:588
bool ALIbool
Definition: CocoaGlobals.h:19
void fillData(ALIuint coor, const std::vector< ALIstring > &wl)
Definition: Measurement.cc:200
void setSigma(ALIint coor, ALIdouble val)
Definition: Measurement.h:171
const ALIdouble * sigma() const
Definition: Measurement.h:132
#define end
Definition: vmac.h:37
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:83
void ErrorInLine()
Definition: ALIFileIn.cc:204
static void dumpVS(const std::vector< ALIstring > &wl, const std::string &msg, std::ostream &outs=std::cout)
dumps a vector of strings with a message to outs
Definition: ALIUtils.cc:501
#define begin
Definition: vmac.h:30
std::string ALIstring
Definition: CocoaGlobals.h:9
tuple cout
Definition: gather_cfg.py:121
virtual void correctValueAndSigma()
Definition: Measurement.h:67
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:79
static void setCurrentDate(const std::vector< ALIstring > &wl)
set the date of the current measurement
Definition: Measurement.cc:631

Member Data Documentation

int CocoaDaqReaderText::nev
protected

Definition at line 24 of file CocoaDaqReaderText.h.

Referenced by GetNEvents().

int CocoaDaqReaderText::nextEvent
protected

Definition at line 25 of file CocoaDaqReaderText.h.

ALIFileIn CocoaDaqReaderText::theFilein
protected

Definition at line 26 of file CocoaDaqReaderText.h.