CMS 3D CMS Logo

Public Member Functions | Private Attributes

MeasurementDistancemeter Class Reference

#include <MeasurementDistancemeter.h>

Inheritance diagram for MeasurementDistancemeter:
Measurement

List of all members.

Public Member Functions

virtual void calculateSimulatedValue (ALIbool firstTime)
virtual void correctValueAndSigma ()
 MeasurementDistancemeter (const ALIint measdim, ALIstring &type, ALIstring &name)
 MeasurementDistancemeter ()
virtual void setConversionFactor (const std::vector< ALIstring > &wordlist)
 ~MeasurementDistancemeter ()

Private Attributes

ALIdouble theFactor
ALIdouble theFactorSigma

Detailed Description

Definition at line 18 of file MeasurementDistancemeter.h.


Constructor & Destructor Documentation

MeasurementDistancemeter::MeasurementDistancemeter ( const ALIint  measdim,
ALIstring type,
ALIstring name 
) [inline]

Definition at line 21 of file MeasurementDistancemeter.h.

    : Measurement( measdim, type, name ), theFactor(1.), theFactorSigma(0.){};
MeasurementDistancemeter::MeasurementDistancemeter ( ) [inline]

Definition at line 23 of file MeasurementDistancemeter.h.

{ };   
MeasurementDistancemeter::~MeasurementDistancemeter ( ) [inline]

Definition at line 24 of file MeasurementDistancemeter.h.

{ };

Member Function Documentation

void MeasurementDistancemeter::calculateSimulatedValue ( ALIbool  firstTime) [virtual]

Reimplemented from Measurement.

Definition at line 26 of file MeasurementDistancemeter.cc.

References begin, dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, Measurement::DumpBadOrderOptOs(), exception, ALIUtils::getFirstTime(), GlobalOptionMgr::getInstance(), Measurement::getMeasuringBehaviour(), GlobalOptionMgr::GlobalOptions(), Measurement::name(), Measurement::OptOList(), LightRay::point(), Measurement::printStartCalculateSimulatedValue(), findQualityFiles::size, and Measurement::type().

{
 
  if( ALIUtils::debug >= 2) printStartCalculateSimulatedValue( this ); // important for Examples/FakeMeas

  //---------- Loop list of OptO that take part in measurement
  std::vector<OpticalObject*>::const_iterator vocite =  OptOList().begin();
  if( ALIUtils::debug >= 5) std::cout  << "OptOList size= " <<OptOList().size() << std::endl;

  //----- Check that there are only two measurements that are 'distance_target' and 'distancemeter'
  ALIbool right_objects = 0;
  if( OptOList().size() == 2 ) {
    if( (*vocite)->type() == "distance_target"
        && ( (*(vocite+1))->type() == "distancemeter" || 
        (*(vocite+1))->type() == "distancemeter1dim" ) ) { 
      right_objects = 1;
    } 
  }
  if( !right_objects ) {
    std::cerr << "!!! ERROR in MeasurementDistancemeter: " << name() << " There should only be two objects of type 'distance_target' and 'distancemeter' " << std::endl;
 std::cerr       << " 1st: " << (*vocite)->name() << " 2nd: " << (*vocite+1)->name()  << std::endl;
    std::cerr << " 1st " << (*vocite)->type() << " 2nd " << (*vocite+1)->type() << std::endl;

    DumpBadOrderOptOs();
    std::exception();
  }     

#ifdef COCOA_VIS
  ALIVisLightPath* vispath = 0;
  if( ALIUtils::getFirstTime() ) {
    GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
    if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
      vispath = IgCocoaFileMgr::getInstance().newLightPath( name() );
    } 
  }
#endif

  ALIuint isec = 0;  //security variable to check OptOList().size()
  for( vocite = OptOList().begin(); vocite != OptOList().end(); vocite++) {
    if( ALIUtils::debug >= 2) std::cout << std::endl << "@@@@ LR:OBJECT " << (*vocite)->name() << std::endl;  
    isec ++;

    //---------- Get the behaviour of the object w.r.t the measurement (if it reflects the light, let it traverse it, ...)
    ALIstring behav = getMeasuringBehaviour(vocite);

    //---------- participate in measurement
    LightRay lightray;  //it is not used in this measurement type
    (*vocite)->participateInMeasurement( lightray, *this, behav);

#ifdef COCOA_VIS
    if( ALIUtils::getFirstTime() ) {
      GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
      if(gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
        ALIVRMLMgr::getInstance().addLightPoint( lightray.point() );
        if(ALIUtils::debug >= 5)std::cout << "ALIVRMLMg  addLightPoint " << lightray.point()  << (*vocite)->name() << std::endl;
      }
      if(gomgr->GlobalOptions()["VisWriteIguana"] > 1) {
        vispath->addLightPoint( lightray.point(), *vocite );
      }
    }
#endif    

    if ( isec > OptOList().size() ) {
      std::cerr << "ERROR DE PROGRAMACION EN GetSimulatedValue" << std::endl;
      std::exception();
    }
  }
  
  if(ALIUtils::debug >= 5) std::cout << "end calculateSimulatedValue" <<std::endl;
  
}
void MeasurementDistancemeter::correctValueAndSigma ( ) [virtual]

Reimplemented from Measurement.

Definition at line 139 of file MeasurementDistancemeter.cc.

References gather_cfg::cout, ALIUtils::debug, Measurement::setSigma(), Measurement::setValue(), Measurement::sigma(), theFactor, and Measurement::value().

{
  ALIdouble val = value()[0];
  ALIdouble sig = sigma()[0];
  if(ALIUtils::debug >= 4) std::cout << "MeasurementDistancemeter::correctValueAndSigma: old value" << val << " +- " << sig << std::endl;

  //- std::cout << "FACTOR " << theFactor << "correct " << val << " "  << thePedestal << std::endl; 
  val *= theFactor; 
  //-------- Do not correct the sigma!!!!
  //-  sig *= theFactor; 
  if(ALIUtils::debug >= 4) std::cout << "MeasuremenDistancemeter::correctValueAndSigma: new value " << val << " +- " << sig << std::endl;
  setValue( 0, val );
  setSigma( 0, sig );

}
void MeasurementDistancemeter::setConversionFactor ( const std::vector< ALIstring > &  wordlist) [virtual]

Reimplemented from Measurement.

Definition at line 104 of file MeasurementDistancemeter.cc.

References dtNoiseDBValidation_cfg::cerr, ALIUtils::dumpVS(), exception, GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), ALIUtils::IsNumber(), theFactor, and theFactorSigma.

{
  //--------- Check that the format is OK
  if(wordlist.size() == 1) return; 
  if( wordlist.size() != 4
    || !ALIUtils::IsNumber(wordlist[1]) || !ALIUtils::IsNumber(wordlist[3]) 
    || wordlist[2] != ALIstring("+-") ){  
    std::cerr << "!! Distancemeter Measurement setConversionFactor: WRONG FORMAT "<<  std::endl 
         << "It should be: DISTANCEMETER factor +- error " << std::endl 
         << "It is: ";
    ALIUtils::dumpVS( wordlist, " ", std::cerr );
    std::exception();
  }
  theFactor = atof(wordlist[1].c_str());
  //------ correct by dimension of value of tiltmeter
  GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
  ALIint dimfac = ALIint( gomgr->GlobalOptions()[ ALIstring("distancemeter_meas_value_dimension") ] );
  if( dimfac == 0 ) {
    theFactor *= 1.;
  } else if( dimfac == 1 ) {
    theFactor *= 1.E-3;
  } else if( dimfac == 2 ) {
    theFactor *= 1.E-6;
  } else {
    std::cerr << " !!!EXITING: error in global option distancemeter_meas_value_dimension, it can only take values 0,1,2, not " << dimfac;
    std::exception();
  }
  theFactorSigma = atof(wordlist[3].c_str());

}

Member Data Documentation

Definition at line 36 of file MeasurementDistancemeter.h.

Referenced by correctValueAndSigma(), and setConversionFactor().

Definition at line 37 of file MeasurementDistancemeter.h.

Referenced by setConversionFactor().