CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:23:37 2009 for CMSSW by  doxygen 1.5.4