CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
CocoaDaqReaderText Class Reference

#include <CocoaDaqReaderText.h>

Inheritance diagram for CocoaDaqReaderText:
CocoaDaqReader

Public Member Functions

void BuildMeasurementsFromOptAlign (std::vector< OpticalAlignMeasurementInfo > &measList) override
 
 CocoaDaqReaderText (const std::string &fileName)
 
int GetNEvents () const
 
bool ReadNextEvent () override
 
 ~CocoaDaqReaderText () override
 
- 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 10 of file CocoaDaqReaderText.h.

Constructor & Destructor Documentation

◆ CocoaDaqReaderText()

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

Definition at line 12 of file CocoaDaqReaderText.cc.

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

12  {
13  if (ALIUtils::debug >= 5)
14  std::cout << " CocoaDaqReaderText::CocoaDaqReaderText from file " << fileName << std::endl;
15 
17 
19 }
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:21
static ALIint debug
Definition: ALIUtils.h:34
static void SetDaqReader(CocoaDaqReader *reader)

◆ ~CocoaDaqReaderText()

CocoaDaqReaderText::~CocoaDaqReaderText ( )
override

Definition at line 22 of file CocoaDaqReaderText.cc.

22 {}

Member Function Documentation

◆ BuildMeasurementsFromOptAlign()

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

Reimplemented from CocoaDaqReader.

Definition at line 137 of file CocoaDaqReaderText.cc.

137 {}

◆ GetNEvents()

int CocoaDaqReaderText::GetNEvents ( ) const
inline

Definition at line 19 of file CocoaDaqReaderText.h.

References nev.

19 { return nev; }

◆ ReadNextEvent()

bool CocoaDaqReaderText::ReadNextEvent ( )
overridevirtual

Implements CocoaDaqReader.

Definition at line 25 of file CocoaDaqReaderText.cc.

References DMR_cfg::cerr, Measurement::correctValueAndSigma(), gather_cfg::cout, ALIUtils::debug, Measurement::dim(), ALIUtils::dumpVS(), beamvalidation::exit(), Measurement::fillData(), GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), cuy::ii, Model::MeasurementList(), heppy_report::oname, Measurement::setCurrentDate(), Measurement::setSigma(), Measurement::sigma(), and Measurement::valueType().

25  {
26  std::vector<ALIstring> wordlist;
27  //---------- read date
28  // ALIint retfil = filein.getWordsInLine(wordlist);
29  // std::cout << "@@@@@@@@@@@@@@@ RETFIL " << retfil << std::endl;
30  //if( retfil == 0 ) {
31  if (theFilein.getWordsInLine(wordlist) == 0) {
32  if (ALIUtils::debug >= 4)
33  std::cout << "@@@@ No more measurements left" << std::endl;
34  return false;
35  }
36 
38  // struct tm tim;
39  //t Model::setMeasurementsTime( tim );
40 
41  //set date and time of current measurement
42  if (wordlist[0] == "DATE:") {
44  }
45 
46  //---------- loop measurements
47  ALIint nMeas = Model::MeasurementList().size();
48  if (ALIUtils::debug >= 4) {
49  std::cout << " Reading " << nMeas << " measurements from file " << theFilein.name() << " DATE: " << wordlist[1]
50  << " " << wordlist[1] << std::endl;
51  }
52  for (ALIint im = 0; im < nMeas; im++) {
53  theFilein.getWordsInLine(wordlist);
54  if (wordlist[0] == ALIstring("SENSOR2D") || wordlist[0] == ALIstring("TILTMETER") ||
55  wordlist[0] == ALIstring("DISTANCEMETER") || wordlist[0] == ALIstring("DISTANCEMETER1DIM") ||
56  wordlist[0] == ALIstring("COPS")) {
57  if (wordlist.size() != 2) {
58  std::cerr << "!!!EXITING Model::readMeasurementsFromFile. number of words should be 2 instead of "
59  << wordlist.size() << std::endl;
60  ALIUtils::dumpVS(wordlist, " ");
61  exit(1);
62  }
63  std::vector<Measurement*>::const_iterator vmcite;
64  for (vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
65  //---- Look for Measurement
66  /* ALIint last_slash = (*vmcite)->name().rfind('/');
67  ALIstring oname = (*vmcite)->name();
68  if( last_slash != -1 ) {
69  oname = oname.substr(last_slash+1, (*vmcite)->name().size()-1);
70  }
71  */
72  ALIint fcolon = (*vmcite)->name().find(':');
73  ALIstring oname = (*vmcite)->name();
74  oname = oname.substr(fcolon + 1, oname.length());
75  //- std::cout << " measurement name " << (*vmcite)->name() << " short " << oname << std::endl;
76  if (oname == wordlist[1]) {
77  //-------- Measurement found, fill data
78  //- std::cout << " measurement name found " << oname << std::endl;
79  if ((*vmcite)->type() != wordlist[0]) {
80  std::cerr << "!!! Reading measurement from file: type in file is " << wordlist[0] << " and should be "
81  << (*vmcite)->type() << std::endl;
82  exit(1);
83  }
84  Measurement* meastemp = *vmcite;
85 
87  ALIbool sigmaFF = gomgr->GlobalOptions()["measurementErrorFromFile"];
88  //---------- Read the data
89  for (unsigned int ii = 0; ii < meastemp->dim(); ii++) {
90  theFilein.getWordsInLine(wordlist);
91  ALIdouble sigma = 0.;
92  if (!sigmaFF) {
93  // keep the sigma, do not read it from file
94  const ALIdouble* sigmav = meastemp->sigma();
95  sigma = sigmav[ii];
96  }
97  //---- Check measurement value type is OK
98  if (meastemp->valueType(ii) != wordlist[0]) {
100  std::cerr << "!!!FATAL ERROR: Measurement value type is " << wordlist[0]
101  << " 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]
118  << std::endl;
119  exit(1);
120  }
121  } else {
122  std::cerr << " wrong type of measurement: " << wordlist[0] << std::endl
123  << " Available types are SENSOR2D, TILTMETER, DISTANCEMETER, DISTANCEMETER1DIM, COPS" << std::endl;
124  exit(1);
125  }
126  }
127  //- std::cout << " returning readmeasff" << std::endl;
128 
129  if (theFilein.eof()) {
130  return false;
131  } else {
132  return true;
133  }
134 }
long double ALIdouble
Definition: CocoaGlobals.h:11
ALIbool eof()
Definition: ALIFileIn.cc:200
const ALIstring & name()
Definition: ALIFileIn.h:43
const ALIuint dim() const
Definition: Measurement.h:82
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
static GlobalOptionMgr * getInstance()
const ALIstring valueType(ALIuint ii) const
Definition: Measurement.h:116
bool ALIbool
Definition: CocoaGlobals.h:19
void fillData(ALIuint coor, const std::vector< ALIstring > &wl)
Definition: Measurement.cc:192
void setSigma(ALIint coor, ALIdouble val)
Definition: Measurement.h:131
ii
Definition: cuy.py:589
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:73
void ErrorInLine()
Definition: ALIFileIn.cc:195
const ALIdouble * sigma() const
Definition: Measurement.h:112
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:465
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
std::string ALIstring
Definition: CocoaGlobals.h:9
virtual void correctValueAndSigma()
Definition: Measurement.h:66
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:88
static void setCurrentDate(const std::vector< ALIstring > &wl)
set the date of the current measurement
Definition: Measurement.cc:605
def exit(msg="")

Member Data Documentation

◆ nev

int CocoaDaqReaderText::nev
protected

Definition at line 22 of file CocoaDaqReaderText.h.

Referenced by GetNEvents().

◆ nextEvent

int CocoaDaqReaderText::nextEvent
protected

Definition at line 23 of file CocoaDaqReaderText.h.

◆ theFilein

ALIFileIn CocoaDaqReaderText::theFilein
protected

Definition at line 24 of file CocoaDaqReaderText.h.