CMS 3D CMS Logo

MeasurementDistancemeter3dim.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 #include <iostream>
13 #include <iomanip>
14 #include <cstdlib>
15 #ifdef COCOA_VIS
16 #include "Alignment/CocoaVisMgr/interface/ALIVRMLMgr.h"
17 #include "Alignment/IgCocoaFileWriter/interface/IgCocoaFileMgr.h"
18 #include "Alignment/IgCocoaFileWriter/interface/ALIVisLightPath.h"
19 #endif
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  //---------- Loop list of OptO that take part in measurement
30  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
31  if (ALIUtils::debug >= 5)
32  std::cout << "OptOList size" << OptOList().size() << std::endl;
33 
34  //----- Check that there are only two measurements that are 'distance_target' and 'distancemeter3dim'
35  ALIbool right_objects = false;
36  if (OptOList().size() == 2) {
37  if ((*vocite)->type() == "distance_target" && ((*(vocite + 1))->type() == "distancemeter3dim")) {
38  right_objects = true;
39  }
40  }
41  if (!right_objects) {
42  std::cerr << "!!! ERROR in MeasurementDistancemeter3dim: " << name()
43  << " There should only be two objects of type 'distance_target' and 'distancemeter3dim' " << std::endl;
44  std::cerr << " 1st " << (*vocite)->name() << " 2nd " << (*vocite + 1)->name() << std::endl;
45  std::cerr << " 1st " << (*vocite)->type() << " 2nd " << (*vocite + 1)->type() << std::endl;
46 
49  }
50 
51 #ifdef COCOA_VIS
52  ALIVisLightPath* vispath = 0;
53  if (ALIUtils::getFirstTime()) {
55  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
56  vispath = IgCocoaFileMgr::getInstance().newLightPath(name());
57  }
58  }
59 #endif
60 
61  ALIuint isec = 0; //security variable to check OptOList().size()
62  for (vocite = OptOList().begin(); vocite != OptOList().end(); ++vocite) {
63  if (ALIUtils::debug >= 2)
64  std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;
65  isec++;
66 
67  //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
68  ALIstring behav = getMeasuringBehaviour(vocite);
69 
70  //---------- participate in measurement
71  LightRay lightray; //it is not used in this measurement type
72  (*vocite)->participateInMeasurement(lightray, *this, behav);
73 
74 #ifdef COCOA_VIS
75  if (ALIUtils::getFirstTime()) {
77  if (gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
78  ALIVRMLMgr::getInstance().addLightPoint(lightray.point());
79  if (ALIUtils::debug >= 5)
80  std::cout << "ALIVRMLMg addLightPoint " << lightray.point() << (*vocite)->name() << std::endl;
81  }
82  if (gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
83  vispath->addLightPoint(lightray.point(), *vocite);
84  }
85  }
86 #endif
87 
88  if (isec > OptOList().size()) {
89  std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
91  }
92  }
93 
94  if (ALIUtils::debug >= 5)
95  std::cout << "end calculateSimulatedValue" << std::endl;
96 }
97 
98 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
99 //@@ You input 2 numbers after 'DISTANCEMETER':
100 //@@
101 //@@ set the conversion factor from mV to mm
102 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
103 void MeasurementDistancemeter3dim::setConversionFactor(const std::vector<ALIstring>& wordlist) {
104  //--------- Check that the format is OK
105  if (wordlist.size() == 1)
106  return;
107  if (wordlist.size() != 4 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
108  wordlist[2] != ALIstring("+-")) {
109  std::cerr << "!! Distancemeter3dim Measurement setConversionFactor: WRONG FORMAT " << std::endl
110  << "It should be: DISTANCEMETER3DIM factor +- error " << std::endl
111  << "It is: ";
112  ALIUtils::dumpVS(wordlist, " ", std::cerr);
113  std::exception();
114  }
115  theFactor = atof(wordlist[1].c_str());
116  //------ correct by dimension of value of tiltmeter
118  ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("distancemeter_meas_value_dimension")]);
119  if (dimfac == 0) {
120  theFactor *= 1.;
121  } else if (dimfac == 1) {
122  theFactor *= 1.E-3;
123  } else if (dimfac == 2) {
124  theFactor *= 1.E-6;
125  } else {
126  std::cerr << " !!!EXITING: error in global option distancemeter3dim_meas_value_dimension, it can only take values "
127  "0,1,2, not "
128  << dimfac;
129  std::exception();
130  }
131  theFactorSigma = atof(wordlist[3].c_str());
132 }
133 
134 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
135 //@@ Value is given in mV: convert to mm
136 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
138  ALIdouble val = value()[0];
139  ALIdouble sig = sigma()[0];
140  if (ALIUtils::debug >= 4)
141  std::cout << "MeasurementDistancemeter3dim::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
142 
143  //- std::cout << "FACTOR " << theFactor << "correct " << val << " " << thePedestal << std::endl;
144  val *= theFactor;
145  //-------- Do not correct the sigma!!!!
146  //- sig *= theFactor;
147  if (ALIUtils::debug >= 4)
148  std::cout << "MeasuremenDistancemeter3dim::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
149  setValue(0, val);
150  setSigma(0, sig);
151 }
ALIbool
bool ALIbool
Definition: CocoaGlobals.h:19
OpticalObject.h
MeasurementDistancemeter3dim::calculateSimulatedValue
void calculateSimulatedValue(ALIbool firstTime) override
Definition: MeasurementDistancemeter3dim.cc:25
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
GlobalOptionMgr::getInstance
static GlobalOptionMgr * getInstance()
Definition: GlobalOptionMgr.cc:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
GlobalOptionMgr.h
LightRay.h
ALIUtils::IsNumber
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
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
MeasurementDistancemeter3dim.h
MeasurementDistancemeter3dim::theFactorSigma
ALIdouble theFactorSigma
Definition: MeasurementDistancemeter3dim.h:36
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
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
MeasurementDistancemeter3dim::theFactor
ALIdouble theFactor
Definition: MeasurementDistancemeter3dim.h:35
Measurement::DumpBadOrderOptOs
void DumpBadOrderOptOs()
Definition: Measurement.cc:469
Measurement::setSigma
void setSigma(ALIint coor, ALIdouble val)
Definition: Measurement.h:131
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
ALIint
int ALIint
Definition: CocoaGlobals.h:15
Measurement::value
const ALIdouble * value() const
Definition: Measurement.h:109
MeasurementDistancemeter3dim::correctValueAndSigma
void correctValueAndSigma() override
Definition: MeasurementDistancemeter3dim.cc:137
MeasurementDistancemeter3dim::setConversionFactor
void setConversionFactor(const std::vector< ALIstring > &wordlist) override
Definition: MeasurementDistancemeter3dim.cc:103
begin
#define begin
Definition: vmac.h:32
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
Measurement::setValue
void setValue(ALIint coor, ALIdouble val)
Definition: Measurement.h:129
Measurement::sigma
const ALIdouble * sigma() const
Definition: Measurement.h:112