CMS 3D CMS Logo

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  if (ALIUtils::debug >= 2)
22  printStartCalculateSimulatedValue(this); // important for Examples/FakeMeas
23 
24  //--------- Check there is only one OptO of type 'tiltmeter'
25  std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
26  if (OptOList().size() != 1 || (*vocite)->type() == "distancemeter") {
27  std::cerr << "!!! ERROR in MeasurementTiltmeter: " << name()
28  << " There should only be one object of type 'tiltmeter' " << std::endl;
30  exit(1);
31  }
32 
33  //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
34  ALIstring behav = getMeasuringBehaviour(vocite);
35 
36  //---------- participate in Measurement
37  LightRay ll;
38  (*vocite)->participateInMeasurement(ll, *this, behav);
39 
40  if (ALIUtils::debug >= 5)
41  std::cout << "end calculateSimulatedValue" << std::endl;
42 }
43 
44 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
45 //@@ You input 8 numbers after 'TILMETER':
46 //@@
47 //@@ set the conversion factor from mV to mrad and the pedestal
48 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
49 void MeasurementTiltmeter::setConversionFactor(const std::vector<ALIstring>& wordlist) {
50  //--------- Check that the format is OK
51  if (wordlist.size() == 1)
52  return;
53  if (wordlist.size() != 7 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
54  !ALIUtils::IsNumber(wordlist[4]) || !ALIUtils::IsNumber(wordlist[6]) || wordlist[2] != ALIstring("+-") ||
55  wordlist[5] != ALIstring("+-")) {
56  std::cerr << "!! Tiltmeter Measurement setConversionFactor: WRONG FORMAT " << std::endl
57  << "It should be: TILTEMETER factor +- error constant_term +- error" << (wordlist.size() != 7)
58  << !ALIUtils::IsNumber(wordlist[1]) << !ALIUtils::IsNumber(wordlist[3])
59  << !ALIUtils::IsNumber(wordlist[4])
60  << !ALIUtils::IsNumber(wordlist[6])
61  // << (wordlist[2] != ALIstring("+-")) << (wordlist[5] != ALIstring("+-"))
62  << std::endl
63  << "It is: ";
64  ALIUtils::dumpVS(wordlist, " ", std::cerr);
65  exit(1);
66  }
67  theFactor = atof(wordlist[1].c_str());
68 
69  //------ correct by dimension of value of tiltmeter
71  ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("tiltmeter_meas_value_dimension")]);
72  if (dimfac == 0) {
73  theFactor *= 1.;
74  } else if (dimfac == 1) {
75  theFactor *= 1.E-3;
76  } else if (dimfac == 2) {
77  theFactor *= 1.E-6;
78  } else {
79  std::cerr
80  << " !!!EXITING: error in global option tiltmeter_meas_value_dimension, it can only take values 0,1,2, not "
81  << dimfac;
82  }
83  theFactorSigma = atof(wordlist[3].c_str());
84  theConstantTerm = atof(wordlist[4].c_str()) * valueDimensionFactor();
85  theConstantTermSigma = atof(wordlist[6].c_str()) * sigmaDimensionFactor();
86  //- std::cout << "correctVal theConstantTerm" << theConstantTerm << valueDimensionFactor() << std::endl;
87  //----- Change value and sigma to dimensions used in SDF, because constant term and pedestal are in dimensions of SDF
88  //- thePedestal = atof(wordlist[7].c_str()) * valueDimensionFactor();
89  //-thePedestalSigma = atof(wordlist[9].c_str()) * sigmaDimensionFactor();
90  // std::cout << "reading thePedestalSigma " << thePedestalSigma << "= " << wordlist[9] << std::endl;
91  // TILTMETER 458.84 +- 1.58 0. +- 0. 1 +- 0
92 }
93 
94 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
95 //@@ Value is given in V: substract constant term, and convert to rad (taking into account the error in the constant term)
96 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
98  ALIdouble val = value()[0];
99  ALIdouble sig = sigma()[0];
100  if (ALIUtils::debug >= 4)
101  std::cout << "MeasurementTiltmeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
102  //---------- Substract pedestal
103  val -= theConstantTerm;
104  //- sig = sqrt(sig*sig + thePedestalSigma*thePedestalSigma );
105  //- std::cout << " sigma + pedestalSigma " << sig << " " << thePedestalSigma << std::endl;
106  //-if( thePedestal != 0. ) {
107  //- sig += sqrt( sig*sig + val*val*thePedestalSigma*thePedestalSigma/thePedestal/thePedestal );
108  //-}
109  //---------- Add error in constant term
110  sig = sqrt(sig * sig + theConstantTermSigma * theConstantTermSigma);
111  //- std::cout << " sigma + costantTermSigma " << sig << " " << theConstantTermSigma << std::endl;
112 
113  //---------- Convert to rad
114  //- std::cout << "FACTOR " << theFactor << "correct " << val << " " << thePedestal << std::endl;
115  val *= theFactor;
116  //-------- Do not correct the sigma!!!!
117  //- sig /= theFactor;
118  if (ALIUtils::debug >= 4)
119  std::cout << "MeasurementTiltmeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
120  setValue(0, val);
121  setSigma(0, sig);
122 }
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
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
MeasurementTiltmeter::theFactor
ALIdouble theFactor
Definition: MeasurementTiltmeter.h:41
GlobalOptionMgr.h
MeasurementTiltmeter::calculateSimulatedValue
void calculateSimulatedValue(ALIbool firstTime) override
Definition: MeasurementTiltmeter.cc:20
LightRay.h
ALIUtils::IsNumber
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
MeasurementTiltmeter::setConversionFactor
void setConversionFactor(const std::vector< ALIstring > &wordlist) override
Definition: MeasurementTiltmeter.cc:49
MeasurementTiltmeter::theConstantTerm
ALIdouble theConstantTerm
Definition: MeasurementTiltmeter.h:43
MeasurementTiltmeter.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
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
Measurement::OptOList
const std::vector< OpticalObject * > & OptOList() const
Definition: Measurement.h:101
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
Measurement::sigmaDimensionFactor
virtual const ALIdouble sigmaDimensionFactor() const
Definition: Measurement.h:120
MeasurementTiltmeter::theConstantTermSigma
ALIdouble theConstantTermSigma
Definition: MeasurementTiltmeter.h:44
ALIint
int ALIint
Definition: CocoaGlobals.h:15
MeasurementTiltmeter::correctValueAndSigma
void correctValueAndSigma() override
Definition: MeasurementTiltmeter.cc:97
Measurement::value
const ALIdouble * value() const
Definition: Measurement.h:109
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
MeasurementTiltmeter::theFactorSigma
ALIdouble theFactorSigma
Definition: MeasurementTiltmeter.h:42
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