Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:02

0001 // COCOA class implementation file

0002 // Id:  MeasurementTiltmeter.cc

0003 // CAT: Model

0004 // ---------------------------------------------------------------------------

0005 // History: v1.0

0006 // Authors:

0007 //   Pedro Arce

0008 
0009 #include "Alignment/CocoaModel/interface/MeasurementTiltmeter.h"
0010 #include "Alignment/CocoaModel/interface/LightRay.h"
0011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
0012 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
0013 #include <iostream>
0014 #include <iomanip>
0015 #include <cstdlib>
0016 
0017 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0018 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement

0019 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0020 void MeasurementTiltmeter::calculateSimulatedValue(ALIbool firstTime) {
0021   if (ALIUtils::debug >= 2)
0022     printStartCalculateSimulatedValue(this);  // important for Examples/FakeMeas

0023 
0024   //--------- Check there is only one OptO of type 'tiltmeter'

0025   std::vector<OpticalObject*>::const_iterator vocite = OptOList().begin();
0026   if (OptOList().size() != 1 || (*vocite)->type() == "distancemeter") {
0027     std::cerr << "!!! ERROR in MeasurementTiltmeter: " << name()
0028               << " There should only be one object of type 'tiltmeter' " << std::endl;
0029     DumpBadOrderOptOs();
0030     exit(1);
0031   }
0032 
0033   //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)

0034   ALIstring behav = getMeasuringBehaviour(vocite);
0035 
0036   //---------- participate in Measurement

0037   LightRay ll;
0038   (*vocite)->participateInMeasurement(ll, *this, behav);
0039 
0040   if (ALIUtils::debug >= 5)
0041     std::cout << "end calculateSimulatedValue" << std::endl;
0042 }
0043 
0044 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0045 //@@ You input 8 numbers after 'TILMETER':

0046 //@@

0047 //@@ set the conversion factor from mV to mrad and the pedestal

0048 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0049 void MeasurementTiltmeter::setConversionFactor(const std::vector<ALIstring>& wordlist) {
0050   //--------- Check that the format is OK

0051   if (wordlist.size() == 1)
0052     return;
0053   if (wordlist.size() != 7 || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) ||
0054       !ALIUtils::IsNumber(wordlist[4]) || !ALIUtils::IsNumber(wordlist[6]) || wordlist[2] != ALIstring("+-") ||
0055       wordlist[5] != ALIstring("+-")) {
0056     std::cerr << "!! Tiltmeter Measurement setConversionFactor: WRONG FORMAT " << std::endl
0057               << "It should be: TILTEMETER factor +- error constant_term +- error" << (wordlist.size() != 7)
0058               << !ALIUtils::IsNumber(wordlist[1]) << !ALIUtils::IsNumber(wordlist[3])
0059               << !ALIUtils::IsNumber(wordlist[4])
0060               << !ALIUtils::IsNumber(wordlist[6])
0061               //     << (wordlist[2] != ALIstring("+-")) << (wordlist[5] != ALIstring("+-"))

0062               << std::endl
0063               << "It is: ";
0064     ALIUtils::dumpVS(wordlist, " ", std::cerr);
0065     exit(1);
0066   }
0067   theFactor = atof(wordlist[1].c_str());
0068 
0069   //------ correct by dimension of value of tiltmeter

0070   GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
0071   ALIint dimfac = ALIint(gomgr->GlobalOptions()[ALIstring("tiltmeter_meas_value_dimension")]);
0072   if (dimfac == 0) {
0073     theFactor *= 1.;
0074   } else if (dimfac == 1) {
0075     theFactor *= 1.E-3;
0076   } else if (dimfac == 2) {
0077     theFactor *= 1.E-6;
0078   } else {
0079     std::cerr
0080         << " !!!EXITING: error in global option tiltmeter_meas_value_dimension, it can only take values 0,1,2, not "
0081         << dimfac;
0082   }
0083   theFactorSigma = atof(wordlist[3].c_str());
0084   theConstantTerm = atof(wordlist[4].c_str()) * valueDimensionFactor();
0085   theConstantTermSigma = atof(wordlist[6].c_str()) * sigmaDimensionFactor();
0086   //-  std::cout << "correctVal  theConstantTerm" <<  theConstantTerm <<  valueDimensionFactor() << std::endl;

0087   //----- Change value and sigma to dimensions used in SDF, because constant term and pedestal are in dimensions of SDF

0088   //-  thePedestal = atof(wordlist[7].c_str()) * valueDimensionFactor();

0089   //-thePedestalSigma = atof(wordlist[9].c_str()) * sigmaDimensionFactor();

0090   //  std::cout << "reading thePedestalSigma " << thePedestalSigma  << "= " << wordlist[9] << std::endl;

0091   //  TILTMETER 458.84 +- 1.58  0. +- 0. 1 +- 0

0092 }
0093 
0094 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0095 //@@ Value is given in V: substract constant term, and convert to rad (taking into account the error in the constant term)

0096 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

0097 void MeasurementTiltmeter::correctValueAndSigma() {
0098   ALIdouble val = value()[0];
0099   ALIdouble sig = sigma()[0];
0100   if (ALIUtils::debug >= 4)
0101     std::cout << "MeasurementTiltmeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
0102   //---------- Substract pedestal

0103   val -= theConstantTerm;
0104   //-  sig = sqrt(sig*sig  + thePedestalSigma*thePedestalSigma );

0105   //-  std::cout << " sigma + pedestalSigma " << sig << " " << thePedestalSigma << std::endl;

0106   //-if( thePedestal != 0. ) {

0107   //-    sig += sqrt( sig*sig + val*val*thePedestalSigma*thePedestalSigma/thePedestal/thePedestal );

0108   //-}

0109   //---------- Add error in constant term

0110   sig = sqrt(sig * sig + theConstantTermSigma * theConstantTermSigma);
0111   //- std::cout << " sigma + costantTermSigma " << sig << " " << theConstantTermSigma << std::endl;

0112 
0113   //---------- Convert to rad

0114   //- std::cout << "FACTOR " << theFactor << "correct " << val << " "  << thePedestal << std::endl;

0115   val *= theFactor;
0116   //-------- Do not correct the sigma!!!!

0117   //-  sig /= theFactor;

0118   if (ALIUtils::debug >= 4)
0119     std::cout << "MeasurementTiltmeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
0120   setValue(0, val);
0121   setSigma(0, sig);
0122 }