CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MeasurementDiffEntry.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 // Id: Measurement.C
3 // CAT: Model
4 // ---------------------------------------------------------------------------
5 // History: v1.0
6 // Authors:
7 // Pedro Arce
8 
14 #include <iostream>
15 #include <iomanip>
16 #include <cstdlib>
17 #include <cmath> // include floating-point std::abs functions
18 #ifdef COCOA_VIS
19 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
20 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
21 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
22 #endif
23 
24 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
25 void MeasurementDiffEntry::buildOptONamesList(const std::vector<ALIstring>& wl) {
26  int NPairs = (wl.size() + 1) / 2; // Number of OptO names ( pair of name and '&' )
27 
28  //--------- Fill list with names
29  for (int ii = 0; ii < NPairs; ii++) {
30  //--- take out Entry names from object names
31  int isl = wl[ii * 2].rfind('/');
32  AddOptONameListItem(wl[ii * 2].substr(0, isl));
33  // Check for separating '&'
34  if (ii != NPairs - 1 && wl[2 * ii + 1] != ALIstring("&")) {
36  std::cerr << "!!! Measured Optical Objects should be separated by '&', not by" << wl[2 * ii + 1] << std::endl;
37  exit(2);
38  }
39  //---- Fill entry names
40  if (ii == 0) {
41  theEntryNameFirst = wl[ii * 2].substr(isl + 1, 999);
42  } else if (ii == 1) {
43  theEntryNameSecond = wl[ii * 2].substr(isl + 1, 999);
44  }
45  }
46 }
47 
48 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
49 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
50 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
52  if (ALIUtils::debug >= 2)
53  printStartCalculateSimulatedValue(this); // important for Examples/FakeMeas
54 
55  //---------- Loop list of OptO that take part in measurement
56  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
57  if (ALIUtils::debug >= 5)
58  std::cout << "OptOList size" << OptOList().size() << std::endl;
59 
60  //----- Check that there are only two objects
61  if (OptOList().size() == !true) {
62  std::cerr << "!!! ERROR in MeasurementDiffEntry: " << name() << " There should only be two objects " << std::endl;
63  std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite + 1)->name() << std::endl;
66  }
67 
68 #ifdef COCOA_VIS
69  ALIVisLightPath* vispath = 0;
70  if (ALIUtils::getFirstTime()) {
72  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
73  vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
74  }
75  }
76 #endif
77 
78  //--- This is a special 'measurement': it represents the fact that you have measured two entries one relative to the other (e.g. relative angle of two objects)
79  Entry* entry1 = Model::getEntryByName((*(OptOList().begin()))->longName(), theEntryNameFirst);
80  Entry* entry2 = Model::getEntryByName((*(OptOList().begin() + 1))->longName(), theEntryNameSecond);
81  if (ALIUtils::debug >= 5)
82  std::cout << " entry1 " << (*(OptOList().begin()))->longName() << "/" << entry1->name() << " ->valueDisplaced() "
83  << entry1->valueDisplaced() << " entry2 " << (*(OptOList().begin() + 1))->longName() << "/"
84  << entry2->name() << " ->valueDisplaced() " << entry2->valueDisplaced() << std::endl;
85  setValueSimulated(0, entry1->valueDisplaced() - entry2->valueDisplaced());
86 
87  if (ALIUtils::debug >= 2) {
88  ALIdouble detD = 1000 * valueSimulated(0);
89  if (std::abs(detD) <= 1.e-9)
90  detD = 0.;
91  std::cout << "REAL value: "
92  << "D: " << 1000. * value()[0] << " (mm) " << (this)->name() << " DIFF= " << detD - 1000 * value()[0]
93  << std::endl;
94  std::cout << "SIMU value: "
95  << "D: " << detD << " (mm) " << (this)->name() << std::endl;
96  }
97 
98  if (ALIUtils::debug >= 5)
99  std::cout << "end calculateSimulatedValue" << std::endl;
100 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIFileIn & getInstance(const ALIstring &name)
Definition: ALIFileIn.cc:22
Definition: Entry.h:18
static ALIint debug
Definition: ALIUtils.h:34
static ALIstring & SDFName()
the name of the System Description File
Definition: Model.h:93
static GlobalOptionMgr * getInstance()
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
void AddOptONameListItem(ALIstring optos)
Definition: Measurement.h:140
void DumpBadOrderOptOs()
Definition: Measurement.cc:469
bool ALIbool
Definition: CocoaGlobals.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void setValueSimulated(ALIint coor, ALIdouble value)
Definition: Measurement.h:146
void buildOptONamesList(const std::vector< ALIstring > &wl) override
const ALIstring & name() const
Definition: Entry.h:50
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:101
void ErrorInLine()
Definition: ALIFileIn.cc:196
static ALIbool getFirstTime()
Definition: ALIUtils.h:87
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
const ALIdouble * value() const
Definition: Measurement.h:109
std::string ALIstring
Definition: CocoaGlobals.h:9
void printStartCalculateSimulatedValue(const Measurement *meas)
Definition: Measurement.cc:427
const ALIstring & name() const
Definition: Measurement.h:86
const ALIdouble valueSimulated(ALIuint ii) const
Definition: Measurement.h:105
tuple cout
Definition: gather_cfg.py:144
virtual ALIdouble valueDisplaced() const
Definition: Entry.cc:311
tuple size
Write out results.
void calculateSimulatedValue(ALIbool firstTime) override