CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MeasurementTiltmeter.cc
Go to the documentation of this file.
1 // COCOA class implementation file
2 // Id: MeasurementTiltmeter.cc
3 // CAT: Model
4 // ---------------------------------------------------------------------------
5 // History: v1.0
6 // Authors:
7 // Pedro Arce
8 
13 #include <iostream>
14 #include <iomanip>
15 #include <cstdlib>
16 
17 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
18 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
19 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
21 {
22 
23  if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this ); // important for Examples/FakeMeas
24 
25  //--------- Check there is only one OptO of type 'tiltmeter'
26  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
27  if( OptOList().size() != 1 ||
28  (*vocite)->type() == "distancemeter") {
29  std::cerr << "!!! ERROR in MeasurementTiltmeter: " << name() << " There should only be one object of type 'tiltmeter' " << std::endl;
31  exit(1);
32  }
33 
34  //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
35  ALIstring behav = getMeasuringBehaviour(vocite);
36 
37  //---------- participate in Measurement
38  LightRay ll;
39  (*vocite)->participateInMeasurement( ll, *this, behav );
40 
41  if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl;
42 
43 }
44 
45 
46 
47 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
48 //@@ You input 8 numbers after 'TILMETER':
49 //@@
50 //@@ set the conversion factor from mV to mrad and the pedestal
51 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
52 void MeasurementTiltmeter::setConversionFactor( const std::vector<ALIstring>& wordlist )
53 {
54  //--------- Check that the format is OK
55  if(wordlist.size() == 1) return;
56  if( wordlist.size() != 7
57  || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3])
58  || !ALIUtils::IsNumber(wordlist[4]) || !ALIUtils::IsNumber(wordlist[6])
59  || wordlist[2] != ALIstring("+-")|| wordlist[5] != ALIstring("+-") ){
60  std::cerr << "!! Tiltmeter Measurement setConversionFactor: WRONG FORMAT "<< std::endl
61  << "It should be: TILTEMETER factor +- error constant_term +- error"
62  << (wordlist.size() != 7)
63  << !ALIUtils::IsNumber(wordlist[1]) << !ALIUtils::IsNumber(wordlist[3])
64  << !ALIUtils::IsNumber(wordlist[4]) << !ALIUtils::IsNumber(wordlist[6])
65  // << (wordlist[2] != ALIstring("+-")) << (wordlist[5] != ALIstring("+-"))
66 << std::endl
67  << "It is: ";
68  ALIUtils::dumpVS( wordlist, " ", std::cerr );
69  exit(1);
70  }
71  theFactor = atof(wordlist[1].c_str());
72 
73  //------ correct by dimension of value of tiltmeter
75  ALIint dimfac = ALIint( gomgr->GlobalOptions()[ ALIstring("tiltmeter_meas_value_dimension") ] );
76  if( dimfac == 0 ) {
77  theFactor *= 1.;
78  } else if( dimfac == 1 ) {
79  theFactor *= 1.E-3;
80  } else if( dimfac == 2 ) {
81  theFactor *= 1.E-6;
82  } else {
83  std::cerr << " !!!EXITING: error in global option tiltmeter_meas_value_dimension, it can only take values 0,1,2, not " << dimfac;
84  }
85  theFactorSigma = atof(wordlist[3].c_str());
86  theConstantTerm = atof(wordlist[4].c_str()) * valueDimensionFactor();
87  theConstantTermSigma = atof(wordlist[6].c_str()) * sigmaDimensionFactor();
88  //- std::cout << "correctVal theConstantTerm" << theConstantTerm << valueDimensionFactor() << std::endl;
89  //----- Change value and sigma to dimensions used in SDF, because constant term and pedestal are in dimensions of SDF
90  //- thePedestal = atof(wordlist[7].c_str()) * valueDimensionFactor();
91  //-thePedestalSigma = atof(wordlist[9].c_str()) * sigmaDimensionFactor();
92  // std::cout << "reading thePedestalSigma " << thePedestalSigma << "= " << wordlist[9] << std::endl;
93  // TILTMETER 458.84 +- 1.58 0. +- 0. 1 +- 0
94 }
95 
96 
97 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
98 //@@ Value is given in V: substract constant term, and convert to rad (taking into account the error in the constant term)
99 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
101 {
102  ALIdouble val = value()[0];
103  ALIdouble sig = sigma()[0];
104  if(ALIUtils::debug >= 4) std::cout << "MeasurementTiltmeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
105  //---------- Substract pedestal
106  val -= theConstantTerm;
107  //- sig = sqrt(sig*sig + thePedestalSigma*thePedestalSigma );
108  //- std::cout << " sigma + pedestalSigma " << sig << " " << thePedestalSigma << std::endl;
109  //-if( thePedestal != 0. ) {
110  //- sig += sqrt( sig*sig + val*val*thePedestalSigma*thePedestalSigma/thePedestal/thePedestal );
111  //-}
112  //---------- Add error in constant term
114  //- std::cout << " sigma + costantTermSigma " << sig << " " << theConstantTermSigma << std::endl;
115 
116  //---------- Convert to rad
117  //- std::cout << "FACTOR " << theFactor << "correct " << val << " " << thePedestal << std::endl;
118  val *= theFactor;
119  //-------- Do not correct the sigma!!!!
120  //- sig /= theFactor;
121  if(ALIUtils::debug >= 4) std::cout << "MeasurementTiltmeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
122  setValue( 0, val );
123  setSigma( 0, sig );
124 
125 }
126 
virtual const ALIdouble sigmaDimensionFactor() const
Definition: Measurement.h:148
long double ALIdouble
Definition: CocoaGlobals.h:11
virtual const ALIdouble valueDimensionFactor() const
Definition: Measurement.h:144
virtual void setConversionFactor(const std::vector< ALIstring > &wordlist)
void setValue(ALIint coor, ALIdouble val)
Definition: Measurement.h:167
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:35
static GlobalOptionMgr * getInstance()
ALIstring getMeasuringBehaviour(const std::vector< OpticalObject * >::const_iterator vocite)
Definition: Measurement.cc:591
void DumpBadOrderOptOs()
Definition: Measurement.cc:487
bool ALIbool
Definition: CocoaGlobals.h:19
void setSigma(ALIint coor, ALIdouble val)
Definition: Measurement.h:171
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:34
bool firstTime
Definition: QTestHandle.cc:16
const ALIdouble * sigma() const
Definition: Measurement.h:132
T sqrt(T t)
Definition: SSEVec.h:18
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:109
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:501
const ALIdouble * value() const
Definition: Measurement.h:125
std::string ALIstring
Definition: CocoaGlobals.h:9
void printStartCalculateSimulatedValue(const Measurement *meas)
Definition: Measurement.cc:444
const ALIstring & name() const
Definition: Measurement.h:90
tuple cout
Definition: gather_cfg.py:145
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
tuple size
Write out results.
virtual void calculateSimulatedValue(ALIbool firstTime)
virtual void correctValueAndSigma()