CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Alignment/CocoaModel/src/MeasurementTiltmeter.cc

Go to the documentation of this file.
00001 // COCOA class implementation file
00002 // Id:  MeasurementTiltmeter.cc
00003 // CAT: Model
00004 // ---------------------------------------------------------------------------
00005 // History: v1.0 
00006 // Authors:
00007 //   Pedro Arce
00008 
00009 #include "Alignment/CocoaModel/interface/MeasurementTiltmeter.h"
00010 #include "Alignment/CocoaModel/interface/LightRay.h"
00011 #include "Alignment/CocoaModel/interface/OpticalObject.h"
00012 #include "Alignment/CocoaUtilities/interface/GlobalOptionMgr.h"
00013 #include <iostream>
00014 #include <iomanip>
00015 #include <cstdlib>
00016 
00017 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00018 //@@ calculate the simulated value propagating the light ray through the OptO that take part in the Measurement
00019 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00020 void MeasurementTiltmeter::calculateSimulatedValue( ALIbool firstTime ) 
00021 {
00022  
00023   if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this ); // important for Examples/FakeMeas
00024 
00025   //--------- Check there is only one OptO of type 'tiltmeter'
00026   std::vector<OpticalObject*>::const_iterator vocite =  OptOList().begin();
00027   if( OptOList().size() != 1 ||
00028       (*vocite)->type() == "distancemeter") {
00029     std::cerr << "!!! ERROR in MeasurementTiltmeter: " << name() << " There should only be one object of type 'tiltmeter' " << std::endl;
00030     DumpBadOrderOptOs();
00031     exit(1);
00032   }     
00033   
00034   //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
00035   ALIstring behav = getMeasuringBehaviour(vocite);
00036   
00037   //---------- participate in Measurement
00038   LightRay ll;
00039   (*vocite)->participateInMeasurement( ll, *this, behav );
00040 
00041   if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl;
00042   
00043 }
00044 
00045 
00046 
00047 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00048 //@@ You input 8 numbers after 'TILMETER':
00049 //@@  
00050 //@@ set the conversion factor from mV to mrad and the pedestal 
00051 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00052 void MeasurementTiltmeter::setConversionFactor( const std::vector<ALIstring>& wordlist ) 
00053 {
00054   //--------- Check that the format is OK
00055   if(wordlist.size() == 1) return; 
00056   if( wordlist.size() != 7
00057     || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) 
00058     || !ALIUtils::IsNumber(wordlist[4]) || !ALIUtils::IsNumber(wordlist[6])
00059     || wordlist[2] != ALIstring("+-")|| wordlist[5] != ALIstring("+-") ){  
00060     std::cerr << "!! Tiltmeter Measurement setConversionFactor: WRONG FORMAT "<<  std::endl 
00061          << "It should be: TILTEMETER factor +- error constant_term +- error"
00062          << (wordlist.size() != 7)
00063          <<  !ALIUtils::IsNumber(wordlist[1])  << !ALIUtils::IsNumber(wordlist[3]) 
00064          << !ALIUtils::IsNumber(wordlist[4]) << !ALIUtils::IsNumber(wordlist[6])
00065       //         << (wordlist[2] != ALIstring("+-")) << (wordlist[5] != ALIstring("+-")) 
00066 <<  std::endl 
00067          << "It is: ";
00068     ALIUtils::dumpVS( wordlist, " ", std::cerr );
00069     exit(1);
00070   }
00071   theFactor = atof(wordlist[1].c_str());
00072 
00073   //------ correct by dimension of value of tiltmeter
00074   GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
00075   ALIint dimfac = ALIint( gomgr->GlobalOptions()[ ALIstring("tiltmeter_meas_value_dimension") ] );
00076   if( dimfac == 0 ) {
00077     theFactor *= 1.;
00078   } else if( dimfac == 1 ) {
00079     theFactor *= 1.E-3;
00080   } else if( dimfac == 2 ) {
00081     theFactor *= 1.E-6;
00082   } else {
00083     std::cerr << " !!!EXITING: error in global option tiltmeter_meas_value_dimension, it can only take values 0,1,2, not " << dimfac;
00084   }
00085   theFactorSigma = atof(wordlist[3].c_str());
00086   theConstantTerm = atof(wordlist[4].c_str()) * valueDimensionFactor();
00087   theConstantTermSigma = atof(wordlist[6].c_str()) * sigmaDimensionFactor();
00088   //-  std::cout << "correctVal  theConstantTerm" <<  theConstantTerm <<  valueDimensionFactor() << std::endl; 
00089   //----- Change value and sigma to dimensions used in SDF, because constant term and pedestal are in dimensions of SDF
00090   //-  thePedestal = atof(wordlist[7].c_str()) * valueDimensionFactor();
00091   //-thePedestalSigma = atof(wordlist[9].c_str()) * sigmaDimensionFactor();
00092   //  std::cout << "reading thePedestalSigma " << thePedestalSigma  << "= " << wordlist[9] << std::endl;
00093   //  TILTMETER 458.84 +- 1.58  0. +- 0. 1 +- 0
00094 }
00095 
00096 
00097 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00098 //@@ Value is given in V: substract constant term, and convert to rad (taking into account the error in the constant term)
00099 //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
00100 void MeasurementTiltmeter::correctValueAndSigma()
00101 {
00102   ALIdouble val = value()[0];
00103   ALIdouble sig = sigma()[0];
00104   if(ALIUtils::debug >= 4) std::cout << "MeasurementTiltmeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;
00105    //---------- Substract pedestal
00106   val -= theConstantTerm;
00107   //-  sig = sqrt(sig*sig  + thePedestalSigma*thePedestalSigma );
00108   //-  std::cout << " sigma + pedestalSigma " << sig << " " << thePedestalSigma << std::endl;
00109   //-if( thePedestal != 0. ) {
00110     //-    sig += sqrt( sig*sig + val*val*thePedestalSigma*thePedestalSigma/thePedestal/thePedestal );
00111   //-}
00112   //---------- Add error in constant term
00113   sig = sqrt( sig*sig + theConstantTermSigma*theConstantTermSigma );
00114   //- std::cout << " sigma + costantTermSigma " << sig << " " << theConstantTermSigma << std::endl;
00115 
00116   //---------- Convert to rad 
00117   //- std::cout << "FACTOR " << theFactor << "correct " << val << " "  << thePedestal << std::endl; 
00118   val *= theFactor; 
00119   //-------- Do not correct the sigma!!!!
00120   //-  sig /= theFactor; 
00121   if(ALIUtils::debug >= 4) std::cout << "MeasurementTiltmeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
00122   setValue( 0, val );
00123   setSigma( 0, sig );
00124 
00125 }
00126