CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FittedEntriesReader.cc
Go to the documentation of this file.
7 
8 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
11  theFile = ALIFileIn::getInstance(filename);
12  std::vector<ALIstring> wl;
14  if (wl[0] == ALIstring("DIMENSIONS:")) {
19  } else {
20  ALIUtils::dumpVS(wl, "!!! FATAL ERROR FittedEntriesReader: first line is not dimensions ");
22  }
23 }
24 
25 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
27  if (ALIUtils::debug >= 5)
28  std::cout << " readFittedEntriesFromFile " << theFileName << std::endl;
29  std::map<OpticalObject*, ALIRmDataFromFile> affAngles;
30 
31  std::vector<ALIstring> wl;
33  unsigned int siz = wl.size();
34  for (size_t ii = 1; ii < siz; ii += 3) {
35  ALIstring optOentryName = substitutePointBySlash(wl[ii]);
36  Entry* entry = Model::getEntryByName(optOentryName);
37  if (ALIUtils::debug >= 5)
38  std::cout << entry->name() << " readFittedEntriesFromFile " << entry->value() << " "
39  << ALIUtils::getFloat(wl[ii + 1]) << std::endl;
40  if (entry->name().substr(0, 6) != "angles") {
41  entry->displaceOriginalOriginal(entry->value() - ALIUtils::getFloat(wl[ii + 1]) * theLengthDim);
42  } else {
43  OpticalObject* opto = entry->OptOCurrent();
44  if (affAngles.find(opto) == affAngles.end()) {
45  affAngles[opto] = ALIRmDataFromFile();
46  }
47  std::map<OpticalObject*, ALIRmDataFromFile>::iterator ite = affAngles.find(opto);
48  (*ite).second.setAngle(optOentryName.substr(optOentryName.size() - 1, 1),
49  ALIUtils::getFloat(wl[ii + 1]) * theAngleDim);
50  if (ALIUtils::debug >= 5)
51  std::cout << " setting angle from file " << ALIUtils::getFloat(wl[ii + 1]) * theAngleDim << " " << wl[ii + 1]
52  << " " << theAngleDim << std::endl;
53  }
54  entry->setSigma(ALIUtils::getFloat(wl[ii + 2]) * theAngleDim);
55  // ar.lass6.laser.angles_X -159.7524 7.2208261
56  }
57 
58  ALIstring coordi("XYZ");
59  std::map<OpticalObject*, ALIRmDataFromFile>::const_iterator ite;
60  for (ite = affAngles.begin(); ite != affAngles.end(); ++ite) {
61  ALIRmDataFromFile dff = (*ite).second;
62  OpticalObject* opto = (*ite).first;
63  for (size_t ii = 0; ii < 3; ii++) {
64  int ifound = dff.dataFilled().find(coordi[ii]);
65  if (ALIUtils::debug >= 5)
66  std::cout << ii << " dataFilled " << ifound << std::endl;
67  if (ifound == -1) { //angles not read from file are taken as the original value
68  ALIdouble entval = opto->getEntryRMangle(coordi.substr(ii, 1));
69  dff.setAngle(coordi.substr(ii, 1), entval);
70  }
71  }
72  dff.constructRm();
73  opto->setGlobalRMOriginalOriginal(dff.rm());
74  }
75 
76  return true; // to avoid warning
77 }
78 
79 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
81  ALIstring nameWithSlash = nameWithPoints;
82 
83  size_t siz = nameWithPoints.length();
84 
85  for (size_t ii = 0; ii < siz; ii++) {
86  if (nameWithSlash[ii] == '.')
87  nameWithSlash[ii] = '/';
88  }
89  nameWithSlash = "s/" + nameWithSlash;
90  if (ALIUtils::debug >= 5)
91  std::cout << " substitutePointBySlash " << nameWithSlash << " " << std::endl;
92 
93  return nameWithSlash;
94 }
const double getEntryRMangle(const XYZcoor coor) const
void setGlobalRMOriginalOriginal(const CLHEP::HepRotation &rmoriori)
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:22
ALIstring dataFilled() const
Definition: Entry.h:18
ALIdouble value() const
Definition: Entry.h:53
ALIbool setAngle(const ALIstring &coord, const ALIdouble val)
static ALIint debug
Definition: ALIUtils.h:34
ALIstring substitutePointBySlash(const ALIstring &nameWithPoints) const
int ii
Definition: cuy.py:589
static Entry * getEntryByName(const ALIstring &opto_name, const ALIstring &entry_name)
--— Search an Entry name in the Entry* list and return a pointer to it
Definition: Model.cc:615
static double getFloat(const ALIstring &str)
Convert a string to an float, checking that it is really a number.
Definition: ALIUtils.cc:373
bool ALIbool
Definition: CocoaGlobals.h:19
static ALIdouble CalculateAngleDimensionFactorFromString(ALIstring dimstr)
Definition: ALIUtils.cc:218
void setSigma(ALIdouble sig)
Definition: Entry.h:79
CLHEP::HepRotation rm() const
static ALIdouble CalculateLengthDimensionFactorFromString(ALIstring dimstr)
Definition: ALIUtils.cc:179
const ALIstring & name() const
Definition: Entry.h:50
ALIint getWordsInLine(std::vector< ALIstring > &wl)
Definition: ALIFileIn.cc:74
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::string ALIstring
Definition: CocoaGlobals.h:9
tuple filename
Definition: lut2db_cfg.py:20
list entry
Definition: mps_splice.py:68
tuple cout
Definition: gather_cfg.py:144
OpticalObject * OptOCurrent() const
Definition: Entry.h:59
virtual void displaceOriginalOriginal(ALIdouble disp)
Definition: Entry.cc:269