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 }
ALIbool
bool ALIbool
Definition: CocoaGlobals.h:19
OpticalObject.h
Measurement::printStartCalculateSimulatedValue
void printStartCalculateSimulatedValue(const Measurement *meas)
Definition: Measurement.cc:427
Measurement::getMeasuringBehaviour
ALIstring getMeasuringBehaviour(const std::vector< OpticalObject * >::const_iterator vocite)
Definition: Measurement.cc:568
GlobalOptionMgr::GlobalOptions
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
Definition: GlobalOptionMgr.h:31
GlobalOptionMgr
Definition: GlobalOptionMgr.h:18
MeasurementCOPS::theDisplace
ALIdouble theDisplace[4]
Definition: MeasurementCOPS.h:36
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
Measurement::valueDimensionFactor
virtual const ALIdouble valueDimensionFactor() const
Definition: Measurement.h:118
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
LightRay.h
ALIUtils::IsNumber
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
MeasurementCOPS.h
end
#define end
Definition: vmac.h:39
Measurement::dim
const ALIuint dim() const
Definition: Measurement.h:82
MeasurementCOPS::setConversionFactor
void setConversionFactor(const std::vector< ALIstring > &wordlist) override
Definition: MeasurementCOPS.cc:110
LightRay::point
const CLHEP::Hep3Vector & point() const
Definition: LightRay.h:57
ALIUtils::getFirstTime
static ALIbool getFirstTime()
Definition: ALIUtils.h:87
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
MeasurementCOPS::calculateSimulatedValue
void calculateSimulatedValue(ALIbool firstTime) override
Definition: MeasurementCOPS.cc:25
LightRay
Definition: LightRay.h:20
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
ALIuint
unsigned int ALIuint
Definition: CocoaGlobals.h:17
Measurement::OptOList
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:101
Measurement::type
const ALIstring & type() const
Definition: Measurement.h:84
Measurement::DumpBadOrderOptOs
void DumpBadOrderOptOs()
Definition: Measurement.cc:469
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
heppy_batch.val
val
Definition: heppy_batch.py:351
Measurement::name
const ALIstring & name() const
Definition: Measurement.h:86
Measurement::value
const ALIdouble * value() const
Definition: Measurement.h:109
MeasurementCOPS::correctValueAndSigma
void correctValueAndSigma() override
Definition: MeasurementCOPS.cc:134
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
cuy.ii
ii
Definition: cuy.py:590
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
Measurement::setValue
void setValue(ALIint coor, ALIdouble val)
Definition: Measurement.h:129