CMS 3D CMS Logo

CocoaDaqReaderText.cc
Go to the documentation of this file.
6 
7 using namespace std;
8 #include <iostream>
9 #include <cstdlib>
10 
11 //----------------------------------------------------------------------
13  if (ALIUtils::debug >= 5)
14  std::cout << " CocoaDaqReaderText::CocoaDaqReaderText from file " << fileName << std::endl;
15 
17 
18  theFilein = ALIFileIn::getInstance(fileName);
19 }
20 
21 //----------------------------------------------------------------------
23 
24 //----------------------------------------------------------------------
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]) {
99  theFilein.ErrorInLine();
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 }
135 
136 //----------------------------------------------------------------------
137 void CocoaDaqReaderText::BuildMeasurementsFromOptAlign(std::vector<OpticalAlignMeasurementInfo>& measList) {}
ALIbool
bool ALIbool
Definition: CocoaGlobals.h:19
Model.h
CocoaDaqReaderText::BuildMeasurementsFromOptAlign
void BuildMeasurementsFromOptAlign(std::vector< OpticalAlignMeasurementInfo > &measList) override
Definition: CocoaDaqReaderText.cc:137
Measurement::fillData
void fillData(ALIuint coor, const std::vector< ALIstring > &wl)
Definition: Measurement.cc:192
GlobalOptionMgr::GlobalOptions
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
Definition: GlobalOptionMgr.h:31
Model::MeasurementList
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:88
GlobalOptionMgr
Definition: GlobalOptionMgr.h:18
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
CocoaDaqReaderText::~CocoaDaqReaderText
~CocoaDaqReaderText() override
Definition: CocoaDaqReaderText.cc:22
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
GlobalOptionMgr.h
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
Measurement::dim
const ALIuint dim() const
Definition: Measurement.h:82
mps_fire.end
end
Definition: mps_fire.py:242
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
Measurement
Definition: Measurement.h:27
ALIFileIn::getInstance
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
Measurement.h
ALIUtils.h
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
Measurement::valueType
const ALIstring valueType(ALIuint ii) const
Definition: Measurement.h:116
Measurement::setSigma
void setSigma(ALIint coor, ALIdouble val)
Definition: Measurement.h:131
Measurement::setCurrentDate
static void setCurrentDate(const std::vector< ALIstring > &wl)
set the date of the current measurement
Definition: Measurement.cc:605
ALIUtils::dumpVS
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
Measurement::correctValueAndSigma
virtual void correctValueAndSigma()
Definition: Measurement.h:66
std
Definition: JetResolutionObject.h:76
CocoaDaqReaderText::CocoaDaqReaderText
CocoaDaqReaderText(const std::string &fileName)
Definition: CocoaDaqReaderText.cc:12
CocoaDaqReaderText::ReadNextEvent
bool ReadNextEvent() override
Definition: CocoaDaqReaderText.cc:25
ALIint
int ALIint
Definition: CocoaGlobals.h:15
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
CocoaDaqReaderText.h
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
CocoaDaqReader::SetDaqReader
static void SetDaqReader(CocoaDaqReader *reader)
Definition: CocoaDaqReader.cc:7
cuy.ii
ii
Definition: cuy.py:590
heppy_report.oname
oname
Definition: heppy_report.py:58
Measurement::sigma
const ALIdouble * sigma() const
Definition: Measurement.h:112