CMS 3D CMS Logo

MeasurementCOPS.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 
12 #ifdef COCOA_VIS
13 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
14 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
15 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
16 #endif
17 
18 #include <iostream>
19 #include <iomanip>
20 #include <cstdlib>
21 
22 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
23 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
24 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
26  if (ALIUtils::debug >= 2)
27  printStartCalculateSimulatedValue(this); // important for Examples/FakeMeas
28 
29  //---------- Create light ray
30  LightRay* lightray = new LightRay;
31 
32  //---------- Define types of OptO that may take part in the Measurement
33  ALIuint isec = 0; //security variable to check OptOList().size()
34 
35  //---------- Loop list of OptO that take part in measurement
36  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
37  if (ALIUtils::debug >= 5)
38  std::cout << "OptOList size" << OptOList().size() << std::endl;
39 
40  //----- Check that first object is 'Xlaser'
41  if ((*vocite)->type() != "Xlaser") {
42  std::cerr << "!!ERROR MeasurementCOPS: first Optical object should be 'Xlaser'" << std::endl;
44  exit(1);
45  }
46 
47  //---------- Check that last object is a COPS Sensor (that makes measuremnt and kill the lightray)
48  if ((*(OptOList().end() - 1))->type() != "COPS") {
49  std::cerr << "!!ERROR MeasurementCOPS: last Optical object should be 'COPS'" << std::endl;
51  exit(1);
52  }
53 
54 #ifdef COCOA_VIS
55  ALIVisLightPath* vispath = 0;
56  if (ALIUtils::getFirstTime()) {
58  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
59  vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
60  }
61  }
62 #endif
63  std::cout << (vocite == OptOList().end()) << " vocite " << (*vocite)->name() << std::endl;
64  while (vocite != OptOList().end()) {
65  if (ALIUtils::debug >= -2)
66  std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
67  isec++;
68 
69  //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
70  ALIstring behav = getMeasuringBehaviour(vocite);
71 
72  if (lightray) {
73  (*vocite)->participateInMeasurement(*lightray, *this, behav);
74 #ifdef COCOA_VIS
75  if (ALIUtils::getFirstTime()) {
77  if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
78  ALIVRMLMgr::getInstance().addLightPoint(lightray->point());
79  // std::cout << "ALIVRMLMg addLightPoint " << lightray->point() << (*vocite)->name() << std::endl;
80  }
81  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
82  vispath->addLightPoint(lightray->point(), *vocite);
83  }
84  }
85 #endif
86  } else {
87  std::cerr << "!! Last object is not Sensor 2D in measurement " << name() << std::endl;
89  exit(1);
90  }
91 
92  ++vocite;
93  if (isec > OptOList().size()) {
94  std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
95  exit(5);
96  }
97  }
98 
99  if (ALIUtils::debug >= 9)
100  std::cout << "end calculateSimulatedValue" << std::endl;
101 
102  delete lightray;
103 }
104 
105 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
106 //@@ You input 8 numbers after 'TILMETER':
107 //@@
108 //@@ set the conversion factor from mV to mrad and the pedestal
109 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
110 void MeasurementCOPS::setConversionFactor(const std::vector<ALIstring>& wordlist) {
111  //--------- Set it to 0
112  ALIuint ii;
113  for (ii = 0; ii < dim(); ii++) {
114  theDisplace[ii] = 0.;
115  }
116 
117  //--------- Check that the format is OK
118  if (wordlist.size() == 1)
119  return;
120  if (wordlist.size() != 3 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[2]) ||
121  !ALIUtils::IsNumber(wordlist[3]) || !ALIUtils::IsNumber(wordlist[4])) {
122  std::cerr << "!! SensorCOPS Measurement setConversionFactor: WRONG FORMAT " << std::endl
123  << "It should be: SENSOR2D displace_U displace_D displace_L displace_R " << std::endl
124  << "It is: ";
125  ALIUtils::dumpVS(wordlist, " ", std::cerr);
126  exit(1);
127  }
128 
129  for (ii = 0; ii < dim(); ii++) {
130  theDisplace[ii] = atof(wordlist[ii + 1].c_str()) * valueDimensionFactor();
131  }
132 }
133 
135  //---------- Make displacement
136  ALIuint ii;
137  for (ii = 0; ii < dim(); ii++) {
138  ALIdouble val = value()[ii];
139  val += theDisplace[ii];
140  if (ALIUtils::debug >= 9)
141  std::cout << "MeasurementCOPS::correctValueAndSigma: old value X " << value()[ii] << " new " << val << " +- "
142  << std::endl;
143  setValue(ii, val);
144  }
145 }
size
Write out results.
long double ALIdouble
Definition: CocoaGlobals.h:11
const ALIdouble * value() const
Definition: Measurement.h:109
const ALIuint dim() const
Definition: Measurement.h:82
void calculateSimulatedValue(ALIbool firstTime) override
void setValue(ALIint coor, ALIdouble val)
Definition: Measurement.h:129
ALIstring getMeasuringBehaviour(const std::vector< OpticalObject *>::const_iterator vocite)
Definition: Measurement.cc:568
static ALIint debug
Definition: ALIUtils.h:34
static GlobalOptionMgr * getInstance()
virtual const ALIdouble valueDimensionFactor() const
Definition: Measurement.h:118
void DumpBadOrderOptOs()
Definition: Measurement.cc:469
bool ALIbool
Definition: CocoaGlobals.h:19
void correctValueAndSigma() override
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:57
ii
Definition: cuy.py:589
static ALIbool getFirstTime()
Definition: ALIUtils.h:87
void setConversionFactor(const std::vector< ALIstring > &wordlist) override
const ALIstring & type() const
Definition: Measurement.h:84
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
ALIdouble theDisplace[4]
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
std::string ALIstring
Definition: CocoaGlobals.h:9
void printStartCalculateSimulatedValue(const Measurement *meas)
Definition: Measurement.cc:427
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:101
const ALIstring & name() const
Definition: Measurement.h:86
unsigned int ALIuint
Definition: CocoaGlobals.h:17
def exit(msg="")