CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Static Private Attributes

Measurement Class Reference

#include <Measurement.h>

Inheritance diagram for Measurement:
MeasurementCOPS MeasurementDiffEntry MeasurementDistancemeter MeasurementDistancemeter3dim MeasurementSensor2D MeasurementTiltmeter

List of all members.

Public Member Functions

void addAffectingEntriesFromOptO (const OpticalObject *optoP)
void AddOptOListItem (OpticalObject *opto)
void AddOptONameListItem (ALIstring optos)
const std::vector< Entry * > & affectingEntryList () const
void buildAffectingEntryList ()
void buildOptOList ()
virtual void buildOptONamesList (const std::vector< ALIstring > &wl)
void calculateOriginalSimulatedValue ()
virtual void calculateSimulatedValue (ALIbool firstTime)
void construct ()
void constructFromOA (OpticalAlignMeasurementInfo &measInfo)
void copyMeas (Measurement *meas, const std::string &subsstr1, const std::string &subsstr2)
virtual void correctValueAndSigma ()
std::vector< ALIdoubleDerivativeRespectEntry (Entry *entry)
const ALIuint dim () const
void DumpBadOrderOptOs ()
void fillData (ALIuint coor, OpticalAlignParam *oaParam)
void fillData (ALIuint coor, const std::vector< ALIstring > &wl)
const CLHEP::Hep3Vector & getLightRayDirection () const
const CLHEP::Hep3Vector & getLightRayPosition () const
ALIstring getMeasuringBehaviour (const std::vector< OpticalObject * >::const_iterator vocite)
const OpticalObjectgetPreviousOptO (const OpticalObject *Popto) const
 Measurement ()
 Measurement (const ALIint measdim, ALIstring &type, ALIstring &name)
const ALIstringname () const
std::vector< OpticalObject * > & OptOList ()
const std::vector< ALIstring > & OptONameList () const
void postConstruct ()
const ALIstringsensorName ()
virtual void setConversionFactor (const std::vector< ALIstring > &wordlist)
void SetDimension (ALIuint dim)
void setLightRayDirection (const CLHEP::Hep3Vector &lightRayDirection)
void setLightRayPosition (const CLHEP::Hep3Vector &lightRayPosition)
void setName ()
void setSigma (ALIint coor, ALIdouble val)
void setType (ALIstring type)
void setValue (ALIint coor, ALIdouble val)
void setValueSimulated (ALIint coor, ALIdouble value)
void setValueSimulated_orig (ALIint coor, ALIdouble value)
virtual void setXlaserLine (ALIuint ii, int val)
const ALIdoublesigma () const
const ALIdouble sigma (ALIuint ii) const
virtual const ALIdouble sigmaDimensionFactor () const
const ALIstringtype () const
const ALIdouble value (ALIuint ii) const
const ALIdoublevalue () const
virtual const ALIdouble valueDimensionFactor () const
bool valueIsSimulated (ALIint coor)
const ALIdouble valueSimulated (ALIuint ii) const
const ALIdouble valueSimulated_orig (ALIuint ii) const
const ALIstring valueType (ALIuint ii) const
virtual int xlaserLine (ALIuint ii)
virtual ~Measurement ()

Static Public Member Functions

static ALIstring getCurrentDate ()
static ALIstring getCurrentTime ()
static ALIstringmeasurementsFileName ()
static void setCurrentDate (const std::vector< ALIstring > &wl)
 set the date of the current measurement
static void setMeasurementsFileName (const ALIstring &filename)

Static Public Attributes

static ALIdouble cameraScaleFactor = 1.
static ALIbool only1 = 0
static ALIstring only1Date = ""
static ALIstring only1Time = ""

Protected Member Functions

void printStartCalculateSimulatedValue (const Measurement *meas)
void Substitute2p (ALIstring &ref, const ALIstring &firstref, int NtwoPoints)

Private Attributes

std::vector< OpticalObject * > _OptOList
std::vector< ALIstring_OptONameList
std::vector< Entry * > theAffectingEntryList
ALIuint theDim
CLHEP::Hep3Vector theLightRayDirection
CLHEP::Hep3Vector theLightRayPosition
ALIstring theName
ALIdoubletheSigma
ALIstring theType
ALIdoubletheValue
ALIbooltheValueIsSimulated
ALIdoubletheValueSimulated
ALIdoubletheValueSimulated_orig
ALIstringtheValueType

Static Private Attributes

static ALIstring theCurrentDate = "99/99/99"
static ALIstring theCurrentTime = "99:99"
static ALIstring theMeasurementsFileName = ""

Detailed Description

Definition at line 27 of file Measurement.h.


Constructor & Destructor Documentation

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

Definition at line 32 of file Measurement.h.

{ };   
Measurement::~Measurement ( ) [virtual]

Definition at line 579 of file Measurement.cc.

References theSigma, and theValue.

{
  //  delete[] _name; 
  delete[] theValue;
  delete[] theSigma;

}

Member Function Documentation

void Measurement::addAffectingEntriesFromOptO ( const OpticalObject optoP)

Definition at line 389 of file Measurement.cc.

References OpticalObject::CoordinateEntryList(), gather_cfg::cout, ALIUtils::debug, OpticalObject::ExtraEntryList(), spr::find(), OpticalObject::name(), OpticalObject::parent(), and theAffectingEntryList.

Referenced by buildAffectingEntryList().

{
  if(ALIUtils::debug >= 3)  std::cout << "Measurement::addAffectingEntriesFromOptO: OptO taking part in Measurement: " << optoP->name() << std::endl;
      //---------- Loop entries in this OptO           
  std::vector< Entry* >::const_iterator vecite;
  std::vector< Entry* >::const_iterator fvecite;
  for (vecite = optoP->CoordinateEntryList().begin();
      vecite != optoP->CoordinateEntryList().end(); vecite++) {
    //T     if( find( theAffectingEntryList.begin(), theAffectingEntryList.end(), (*vecite) ) == theAffectingEntryList.end() ){
    //t      theAffectingEntryList.push_back(*vecite);
    //T    }
    fvecite = find( theAffectingEntryList.begin(), theAffectingEntryList.end(), (*vecite) );
    if (fvecite == theAffectingEntryList.end() ){
      theAffectingEntryList.push_back(*vecite);
      if(ALIUtils::debug >= 4)  std::cout << "Entry that may affect Measurement: " << (*vecite)->name() << std::endl;
    }
  }
  for (vecite = optoP->ExtraEntryList().begin();
      vecite != optoP->ExtraEntryList().end(); vecite++) {
    fvecite = find( theAffectingEntryList.begin(), theAffectingEntryList.end(), (*vecite) );
    if (fvecite == theAffectingEntryList.end() ){
      theAffectingEntryList.push_back(*vecite);
      if(ALIUtils::debug >= 4)  std::cout << "Entry that may affect Measurement: " << (*vecite)->name() << std::endl;
    }
  }
  if(optoP->parent() != 0) {
    addAffectingEntriesFromOptO( optoP->parent() );
  }
}
void Measurement::AddOptOListItem ( OpticalObject opto) [inline]

Definition at line 188 of file Measurement.h.

References _OptOList.

                                            {
      _OptOList.push_back( opto );
  }
void Measurement::AddOptONameListItem ( ALIstring  optos) [inline]

Definition at line 184 of file Measurement.h.

References _OptONameList.

Referenced by MeasurementDiffEntry::buildOptONamesList().

                                            {
      _OptONameList.push_back( optos );
  }
const std::vector<Entry*>& Measurement::affectingEntryList ( ) const [inline]

Definition at line 113 of file Measurement.h.

References theAffectingEntryList.

                                                      {
    return theAffectingEntryList;
  }
void Measurement::buildAffectingEntryList ( )

Definition at line 374 of file Measurement.cc.

References _OptOList, and addAffectingEntriesFromOptO().

Referenced by postConstruct().

                                         {
  
  //---------- Loop OptO MeasuredList
  std::vector< OpticalObject* >::const_iterator vocite;
  for (vocite = _OptOList.begin();
       vocite != _OptOList.end(); vocite++) {
      addAffectingEntriesFromOptO( *vocite );
  }
}
void Measurement::buildOptOList ( )

Definition at line 316 of file Measurement.cc.

References _OptOList, _OptONameList, dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, cmsRelvalreport::exit, Model::getOptOByName(), OpticalObject::name(), and Substitute2p().

Referenced by postConstruct().

{
  //-  if ( ALIUtils::debug >= 3 ) std::cout << std::endl << " MEASUREMENT: " << " " << this->name() << std::endl; 
  ALIstring twopoints(".."); // .. goes one level up in the tree fo OptOs

//---------------------------------------- Loop OptONameList
  std::vector<ALIstring>::iterator vsite;
  for (vsite = _OptONameList.begin();
       vsite != _OptONameList.end(); vsite++) {
//----------------------------------- Count how many '..' there are in the name
    ALIuint ii = 0;
    //    ALIuint slen = (*vsite).length();
    ALIuint Ntwopoints = 0;    //---- No '..' in ALIstring
    for(;;) {
      int i2p = (*vsite).find_first_of( twopoints, 3*ii ); // if it is ., it also finds it!!!
      if ( i2p < 0 ) break;
      if ( i2p != ALIint(3*ii)) {
        std::cerr << i2p << "!!! Bad position of '..' in reference ALIstring: " 
             << (*vsite).c_str() << std::endl; 
        exit(2);
      } else {
        Ntwopoints++;
        if ( ALIUtils::debug >=9 ) std::cout << "N2p" << Ntwopoints;
      }
      ii++;   
    }     
    //------ Substitute '..' by reference (the last OptO in list)
    if (Ntwopoints != 0) {
      Substitute2p( (*vsite), *(_OptONameList.end()-1), Ntwopoints);
    }
    //----- Get OpticalObject* that correspond to ALIstring and fill list
    ALIstring referenceOptO = (*vsite);
    //--- a ':' is used in OptOs that have several possible behavious
    ALIint colon = referenceOptO.find(':');
    if ( colon != -1 ) {
      if (ALIUtils::debug >=99) { 
        std::cout << "colon in reference OptO name " << colon << 
          referenceOptO.c_str() << std::endl;
      }
      referenceOptO = referenceOptO.substr( 0, colon );
    }
    OpticalObject* OptOitem = Model::getOptOByName( referenceOptO );
    if ( ALIUtils::debug >= 3 ) std::cout << "Measurement::buildOptOList: OptO in Measurement: " << OptOitem->name() << std::endl;
    if ( OptOitem != (OpticalObject*)0 ) {
      _OptOList.push_back( OptOitem);
    } else {
      std::cerr << "!!! Error in Measurement: can't find Optical Object " <<
        (*vsite).c_str() << std::endl;
      exit(2);
    }      
  }
}
void Measurement::buildOptONamesList ( const std::vector< ALIstring > &  wl) [virtual]

Reimplemented in MeasurementDiffEntry.

Definition at line 177 of file Measurement.cc.

References _OptONameList, dtNoiseDBValidation_cfg::cerr, and cmsRelvalreport::exit.

Referenced by construct(), constructFromOA(), and copyMeas().

{

  int NPairs = (wl.size()+1)/2;   // Number of OptO names ( pair of name and '&' )

  //--------- Fill list with names 
  for ( int ii=0; ii<NPairs; ii++ ) {
    _OptONameList.push_back( wl[ii*2] );
    // Check for separating '&'
    if (ii != NPairs-1 && wl[2*ii+1] != ALIstring("&") ) {
      //      ALIFileIn::getInstance( Model::SDFName() ).ErrorInLine();
      std::cerr << "!!! Measured Optical Objects should be separated by '&', not by" 
                << wl[2*ii+1] << std::endl; 
      exit(2);
    }
  }
 
}
void Measurement::calculateOriginalSimulatedValue ( )

Definition at line 452 of file Measurement.cc.

References calculateSimulatedValue(), gather_cfg::cout, ALIUtils::debug, dim(), ALIUtils::getFirstTime(), GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), setValue(), setValueSimulated_orig(), valueIsSimulated(), and valueSimulated().

{
  //----------  Calculate the simulated value of the Measurement
  calculateSimulatedValue( 1 );

#ifdef COCOA_VIS
  if( ALIUtils::getFirstTime() ) {
    GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance();
    if(gomgr->GlobalOptions()["VisWriteVRML"] > 1) {
      ALIVRMLMgr::getInstance().newLightRay();
    }
    /*-    if(Model::GlobalOptions()["VisWriteIguana"] > 1) {
           IgCocoaFileMgr::getInstance().newLightPath( theName );
           } */
  }
#endif

  //---------- Set original simulated values to it
  //-  if(ALIUtils::debug >= 5) std::cout << "MEAS DIMENSION" << dim() << std::endl;
  for ( ALIuint ii = 0; ii < dim(); ii++) {
    setValueSimulated_orig( ii, valueSimulated(ii) );
    if ( ALIUtils::debug >= 4 ) std::cout << "SETsimuvalOriginal" << valueSimulated(ii) << std::endl;
    //----- If Measurement has as value 'simulated_value', set the value to the simulated one
    if( valueIsSimulated(ii) == 1 ){
      setValue( ii, valueSimulated(ii) );
      //- std::cout << ii << " setting value as simulated " <<  valueSimulated(ii) << " " << value(ii) << this << std::endl;
    }
  }
 
}
virtual void Measurement::calculateSimulatedValue ( ALIbool  firstTime) [inline, virtual]
void Measurement::construct ( )

Definition at line 62 of file Measurement.cc.

References buildOptONamesList(), filterCSVwithJSON::copy, correctValueAndSigma(), gather_cfg::cout, ALIUtils::debug, dim(), fillData(), ALIFileIn::getInstance(), ALIFileIn::getWordsInLine(), name(), postConstruct(), Model::SDFName(), type(), and valueIsSimulated().

Referenced by Model::readSystemDescription().

{

  ALIFileIn& filein = ALIFileIn::getInstance( Model::SDFName() );

  //---------- Read OptOs that take part in this Measurement
  std::vector<ALIstring> wordlist;
  filein.getWordsInLine( wordlist );

  //--------- Fill the list of names of OptOs that take part in this measurement ( names only )
  buildOptONamesList( wordlist );
  
  if(ALIUtils::debug >= 3) {
    std::cout << "@@@@ Reading Measurement " << name() << " TYPE= " << type() << std::endl
              << " MEASURED OPTO NAMES: ";
    std::ostream_iterator<ALIstring> outs(std::cout," ");
    copy(wordlist.begin(), wordlist.end(), outs);
    std::cout << std::endl;
  }


  //---------- Read the data 
  for ( unsigned int ii=0; ii<dim(); ii++){
    filein.getWordsInLine( wordlist );
    fillData( ii, wordlist );
  }

  if( !valueIsSimulated(0) ) correctValueAndSigma();

  postConstruct();
}
void Measurement::constructFromOA ( OpticalAlignMeasurementInfo measInfo)

Definition at line 95 of file Measurement.cc.

References _OptONameList, buildOptONamesList(), gather_cfg::cout, ALIUtils::debug, dim(), ALIUtils::dumpVS(), fillData(), OpticalAlignMeasurementInfo::isSimulatedValue_, OpticalAlignMeasurementInfo::measObjectNames_, name(), postConstruct(), sigmaDimensionFactor(), type(), valueDimensionFactor(), and OpticalAlignMeasurementInfo::values_.

Referenced by Model::BuildMeasurementsFromOA().

{
  //---- Build wordlist to build object name list
  std::vector<std::string> objNames = measInfo.measObjectNames_;
  std::vector<std::string>::const_iterator site;
  std::vector<ALIstring> wordlist;
  //--- Fill the list of names of OptOs that take part in this measurement ( names only )
  for( site = objNames.begin(); site != objNames.end(); site++) {
    if( site != objNames.begin() ) wordlist.push_back("&");
    wordlist.push_back(*site);
  }
  buildOptONamesList( wordlist );

  if(ALIUtils::debug >= 3) {
    std::cout << "@@@@ Reading Measurement " << name() << " TYPE= " << type() << " " << measInfo << std::endl
              << " MEASURED OPTO NAMES: ";
    for( size_t ii = 0; ii < _OptONameList.size(); ii++ ){
      std::cout << _OptONameList[ii] << " ";
    }
    std::cout << std::endl;
  }

  //---------- No data, set to simulated_value
  for ( unsigned int ii=0; ii<dim(); ii++){
    wordlist.clear();
    wordlist.push_back( (measInfo.values_)[ii].name_ );
    char ctmp[20];
    if( measInfo.isSimulatedValue_[ii] ){
      if ( ALIUtils::debug >= 5 ) {
        std::cout << "Measurement::constructFromOA:  meas value " << ii << " "  << dim() << " = simulated_value" << std::endl;
      }
      wordlist.push_back("simulated_value");
    } else { 
      if ( ALIUtils::debug >= 5 ) {
        std::cout << "Measurement::constructFromOA:  meas value " << ii << " "  << dim() << " = " << measInfo.values_.size() << std::endl;
      }
      ALIdouble val = (measInfo.values_)[ii].value_ / valueDimensionFactor(); //in XML  values are without dimensions, so neutralize multiplying by valueDimensionFactor() in fillData
      gcvt( val, 10, ctmp );
      wordlist.push_back( ctmp );
    }
    ALIdouble err = (measInfo.values_)[ii].error_ / sigmaDimensionFactor(); //in XML  values are without dimensions, so neutralize multiplying by valueDimensionFactor() in fillData
    gcvt( err, 10, ctmp );
    wordlist.push_back( ctmp );
    std::cout << " sigma " << err << " = " << ctmp << " " << (measInfo.values_)[ii].error_ << std::endl;
    //-    wordlist.push_back( "simulated_value" );
    //-   wordlist.push_back( "1." );
      if ( ALIUtils::debug >= 5 ) ALIUtils::dumpVS(wordlist, " Measurement: calling fillData ");
    //-    std::cout << " MEAS INFO " << measInfo << std::endl;
    //-   std::cout << ii << " MEAS INFO PARAM " <<  (measInfo.values_)[ii] << std::endl;
    //- std::cout << ii << " MEAS INFO PARAM VALUE " <<  (measInfo.values_)[ii].value_ << std::endl;
    fillData( ii, wordlist );
  }

  postConstruct();

}
void Measurement::copyMeas ( Measurement meas,
const std::string &  subsstr1,
const std::string &  subsstr2 
)

Definition at line 649 of file Measurement.cc.

References buildOptONamesList(), ALIUtils::changeName(), filterCSVwithJSON::copy, gather_cfg::cout, ALIUtils::debug, dim(), name(), OptOList(), postConstruct(), sigma(), theDim, theName, theSigma, theType, theValue, theValueIsSimulated, theValueSimulated, theValueSimulated_orig, type(), value(), valueIsSimulated(), valueSimulated(), and valueSimulated_orig().

Referenced by Model::copyMeasurements().

{
  theDim = meas->dim();
  theType = meas->type();
  theName =  ALIUtils::changeName( meas->name(), subsstr1, subsstr2);

   //  _OptOnames = new ALIstring[theDim];
  theValueSimulated = new ALIdouble[theDim];
  theValueSimulated_orig = new ALIdouble[theDim];
  theValueIsSimulated = new ALIbool[theDim];
  theValue = const_cast<ALIdouble*>(meas->value());
  theSigma = const_cast<ALIdouble*>(meas->sigma());

  unsigned int ii;
  for(ii = 0; ii < theDim; ii++) {
    theValueSimulated[ii] = meas->valueSimulated( ii );
    theValueSimulated_orig[ii] = meas->valueSimulated_orig( ii );
    theValueIsSimulated[ii] = meas->valueIsSimulated( ii );
  }

  //--------- Fill the list of names of OptOs that take part in this measurement ( names only )

  std::vector<std::string> wordlist;
  std::vector<OpticalObject*>& optolist = meas->OptOList();
  ALIuint nOptos = optolist.size();
  for ( ALIuint ii = 0; ii < nOptos; ii++ ) {
    wordlist.push_back( ALIUtils::changeName( optolist[ii]->longName(), subsstr1, subsstr2) );
    std::cout << " copymeas " << ALIUtils::changeName( optolist[ii]->longName(), subsstr1, subsstr2) << std::endl;
    if( ii != nOptos -1 ) wordlist.push_back("&");
  }

  buildOptONamesList( wordlist );
  
  if(ALIUtils::debug >= 3) {
    std::cout << "@@@@ Reading Measurement " << name() << " TYPE= " << type() << std::endl
              << " MEASURED OPTO NAMES: ";
    std::ostream_iterator<ALIstring> outs(std::cout," ");
    copy(wordlist.begin(), wordlist.end(), outs);
    std::cout << std::endl;
  }


  postConstruct();

}
virtual void Measurement::correctValueAndSigma ( ) [inline, virtual]
std::vector< ALIdouble > Measurement::DerivativeRespectEntry ( Entry entry)

Definition at line 511 of file Measurement.cc.

References calculateSimulatedValue(), dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, Entry::displace(), cmsRelvalreport::exit, ALIUtils::getMaximumDeviationDerivative(), OpticalObject::name(), Entry::name(), name(), Entry::OptOCurrent(), OpticalObject::resetGlobalCoordinates(), Entry::startingDisplacement(), theDim, theValueSimulated, and theValueSimulated_orig.

{
  //---------- std::vector of derivatives to return
  std::vector<ALIdouble> deriv;
  ALIdouble sumderiv;
  
  //---------- displacement to start with 
  ALIdouble displacement = entry->startingDisplacement();
  //----- all angles are in radians, so, if displace is not, rescale it before making the displacement 
  //-  displacement *= entry->SigmaDimensionFactor();
  if( ALIUtils::debug >= 3) std::cout << std::endl << "%%% Derivative w.r.t. entry " << entry->name() << ": displacement = " << displacement << std::endl;
  
  ALIint count_itera = 0; 
  
  //---------- Loop decreasing the displacement a factor 2, until the precision set is reached
  do {
    count_itera++;
    entry->displace( displacement );
    
    if ( ALIUtils::debug >= 5) std::cout << "Get simulated value for displacement " << displacement << std::endl;
    calculateSimulatedValue( 0 ); 
    
    //---------- Get sum of derivatives
    sumderiv = 0;   
    for ( ALIuint ii = 0; ii < theDim; ii++) {
      sumderiv += fabs( theValueSimulated[ii] - theValueSimulated_orig[ii] );
      if( ALIUtils::debug >= 4 ) {
        std::cout << "iteration " << count_itera << " COOR " << ii 
             << " difference =" << ( theValueSimulated[ii] - theValueSimulated_orig[ii] )
          //-             << "  " << theValueSimulated[ii] << "  " << theValueSimulated_orig[ii] 
             << " derivative = " << (theValueSimulated[ii] - theValueSimulated_orig[ii]) /displacement << " disp " << displacement 
             << " sum derivatives = " << sumderiv << std::endl;
      }
      if( ALIUtils::debug >= 5 ) {
        std::cout << " new simu value= " << theValueSimulated[ii] << " orig simu value " << theValueSimulated_orig[ii] << std::endl;
       }
    }
    if (count_itera >= 100) {
      std::cerr << "EXITING: too many iterations in derivative, displacement is " <<
        displacement << " sum of derivatives is " << sumderiv << std::endl;
      exit(3);   
    }
    displacement /= 2.; 
    //-    std::cout << "sumderiv " << sumderiv << " maximu " <<  Fit::maximum_deviation_derivative << std::endl;
  }while( sumderiv > ALIUtils::getMaximumDeviationDerivative() );
  displacement *= 2; 
  
  //---------- Enough precision reached: pass result
  for ( ALIuint ii = 0; ii < theDim; ii++) {
    deriv.push_back( ( theValueSimulated[ii] - theValueSimulated_orig[ii] ) / displacement );
    //----- change it to entry sigma dimensions
    //     deriv[ii] /= entry->SigmaDimensionFactor();
    if( ALIUtils::debug >= 1) std::cout << name() << ": " <<  entry->OptOCurrent()->name() << " " <<  entry->name() << " " << ii << "### DERIVATIVE: " << deriv[ii] <<  std::endl;
  }
  //-  if(ALIUtils::debug >= 5) std::cout << "END derivative: " << deriv << "disp" << displacement << std::endl;
  
  //--------------------- Reset _centreGlob and _rmGlob of OptO entry belongs to (and component OptOs)
  entry->OptOCurrent()->resetGlobalCoordinates();
  
  return deriv;
 
}
const ALIuint Measurement::dim ( ) const [inline]
void Measurement::DumpBadOrderOptOs ( )

Definition at line 487 of file Measurement.cc.

References begin, dtNoiseDBValidation_cfg::cerr, ALIUtils::debug, cmsRelvalreport::exit, and OptONameList().

Referenced by MeasurementSensor2D::calculateSimulatedValue(), MeasurementTiltmeter::calculateSimulatedValue(), MeasurementCOPS::calculateSimulatedValue(), MeasurementDistancemeter3dim::calculateSimulatedValue(), MeasurementDistancemeter::calculateSimulatedValue(), and MeasurementDiffEntry::calculateSimulatedValue().

{
  std::cerr << " Detector can not make measurement with these optical objects " << std::endl;
  if (ALIUtils::debug >= 1) {
    //  std::vector<OpticalObject*>::iterator voite;
    //      for ( voite = _OptOList.begin(); 
    //     voite != _OptOList.end(); voite++) {
    //    std::cout << (*voite)->type() << " : " << (*voite)->name() << std::endl;
    // }
    std::vector<ALIstring>::const_iterator vsite;
    for ( vsite = OptONameList().begin(); 
          vsite != OptONameList().end(); vsite++) {
      std::cerr << (*vsite) << " : " ;
    }
    std::cerr << std::endl;
  }
  exit(2);

}
void Measurement::fillData ( ALIuint  coor,
const std::vector< ALIstring > &  wl 
)

Definition at line 200 of file Measurement.cc.

References dtNoiseDBValidation_cfg::cerr, filterCSVwithJSON::copy, gather_cfg::cout, ALIUtils::debug, cmsRelvalreport::exit, ParameterMgr::getInstance(), ParameterMgr::getParameterValue(), ALIUtils::IsNumber(), sigmaDimensionFactor(), theDim, theSigma, theValue, theValueIsSimulated, theValueType, and valueDimensionFactor().

Referenced by construct(), constructFromOA(), Model::readMeasurementsFromFile(), and CocoaDaqReaderText::ReadNextEvent().

{
  if ( ALIUtils::debug >= 3 ) {
    std::cout << "@@ Filling coordinate " << coor << std::endl ;
    //-   ostream_iterator<ALIstring> outs(std::cout," ");
    //-  copy(wordlist.begin(), wordlist.end(), outs);
  }
  
  ParameterMgr* parmgr = ParameterMgr::getInstance();

  //---------- Check that there are 3 attributes: name, value, error
  if( wordlist.size() != 3 ) {
    //    ALIFileIn::getInstance( Model::SDFName() ).ErrorInLine();
    std::cerr << " Incorrect format for Measurement value:" << std::endl; 
    std::ostream_iterator<ALIstring> outs(std::cout," ");
    copy(wordlist.begin(), wordlist.end(), outs);
    std::cout << std::endl << "There should be three words: name value sigma " << std::endl;
    exit(2);
  }

  //---------- check coor value
  if (coor >= theDim ) {
    // ALIFileIn::getInstance( Model::SDFName() ).ErrorInLine();
    std::cerr << "Trying to fill Measurement coordinate No "
         << coor << " but the dimension is " << theDim << std::endl; 
    exit(2);
  }

  //---------- set data members 
  //----- Set valueType
  theValueType[coor] = wordlist[0];

  //----- Set value (translate it if a PARAMETER is used)
  ALIdouble val = 0.;
  theValueIsSimulated[coor] = 0;
  if( !ALIUtils::IsNumber(wordlist[1]) ) {
    if ( parmgr->getParameterValue( wordlist[1], val ) == 0 ) {
      if( wordlist[1] == ALIstring("simulated_value") ) {
        theValueIsSimulated[coor] = 1;
      } else {
        //      ALIFileIn::getInstance( Model::SDFName() ).ErrorInLine();
        std::cerr << "!!! parameter for value not found: " << wordlist[1].c_str() << std::endl;
        exit(2);
      }
    }
    //d val *= valueDimensionFactor();
  } else {
    //d val = DimensionMgr()::getInstance()->extractValue( wordlist[1], ValueDimensionFactor() );
    val = atof( wordlist[1].c_str() ); 
  }
  val *= valueDimensionFactor();
  if( ALIUtils::debug >= 3 ) std::cout << "Meas VALUE= " << val << " (ValueDimensionFactor= " << valueDimensionFactor() <<std::endl;

  //----- Set sigma (translate it if a PARAMETER is used)
  ALIdouble sig = 0.;
  if( !ALIUtils::IsNumber(wordlist[2]) ) {
    if ( parmgr->getParameterValue( wordlist[2], sig ) == 0 ) {
      // ALIFileIn::getInstance( Model::SDFName() ).ErrorInLine();
      std::cerr << "!!! parameter for sigma not found: " << wordlist[2].c_str() << std::endl;
      exit(2);
    }
    //d sig *= sigmaDimensionFactor();
  } else {
    //    sig = DimensionMgr()::getInstance()->extractValue( wordlist[2], ValueDimensionFactor() );
    sig = atof( wordlist[2].c_str() );  
  }
  sig *= sigmaDimensionFactor();
  if( ALIUtils::debug >= 3) std::cout << "SIGMA= " << sig << " (SigmaDimensionFactor= " << sigmaDimensionFactor() <<std::endl;
  
  //----- set theValue & theSigma
  theValue[coor] = val;
  theSigma[coor] = sig;

}
void Measurement::fillData ( ALIuint  coor,
OpticalAlignParam oaParam 
)

Definition at line 277 of file Measurement.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, cmsRelvalreport::exit, GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), OpticalAlignParam::sigma(), sigmaDimensionFactor(), theDim, theSigma, theValue, theValueIsSimulated, OpticalAlignParam::value(), and valueDimensionFactor().

{
  if ( ALIUtils::debug >= 3 ) {
    std::cout << "@@ Filling coordinate " << coor << std::endl ;
  }
  
  //  ParameterMgr* parmgr = ParameterMgr::getInstance();

  //---------- check coor value
  if (coor >= theDim ) {
    std::cerr << "Trying to fill Measurement coordinate No "
         << coor << " but the dimension is " << theDim << std::endl; 
    exit(2);
  }

  //---------- set data members 
  //----- Set value (translate it if a PARAMETER is used)
  ALIdouble val = 0.;
  theValueIsSimulated[coor] = 0;
  val = oaParam->value();
  val *= valueDimensionFactor();
  theValue[coor] = val;
  if( ALIUtils::debug >= 3 ) std::cout << "Meas VALUE= " << val << " (ValueDimensionFactor= " << valueDimensionFactor() <<std::endl;

  ALIbool sigmaFF = GlobalOptionMgr::getInstance()->GlobalOptions()["measurementErrorFromFile"];
  if( sigmaFF ) {
    //----- Set sigma (translate it if a PARAMETER is used)
    ALIdouble sig = 0.;
    sig = oaParam->sigma(); // it is in mm always
    sig *= sigmaDimensionFactor();
    theSigma[coor] = sig;
    if( ALIUtils::debug >= 3) std::cout << "SIGMA= " << sig << " (SigmaDimensionFactor= " << sigmaDimensionFactor() <<std::endl;
   
  }
}
static ALIstring Measurement::getCurrentDate ( ) [inline, static]

Definition at line 152 of file Measurement.h.

References theCurrentDate.

Referenced by FittedEntriesSet::FittedEntriesSet().

                                   {
    return theCurrentDate;
  }
static ALIstring Measurement::getCurrentTime ( ) [inline, static]

Definition at line 155 of file Measurement.h.

References theCurrentTime.

                                   {
    return theCurrentTime;
  }
const CLHEP::Hep3Vector& Measurement::getLightRayDirection ( ) const [inline]

Definition at line 162 of file Measurement.h.

References theLightRayDirection.

                                                      { 
    return theLightRayDirection; 
  }
const CLHEP::Hep3Vector& Measurement::getLightRayPosition ( ) const [inline]

Definition at line 159 of file Measurement.h.

References theLightRayPosition.

                                                     {
    return theLightRayPosition; 
  }
ALIstring Measurement::getMeasuringBehaviour ( const std::vector< OpticalObject * >::const_iterator  vocite)

Definition at line 591 of file Measurement.cc.

References _OptOList, and _OptONameList.

Referenced by MeasurementSensor2D::calculateSimulatedValue(), MeasurementTiltmeter::calculateSimulatedValue(), MeasurementCOPS::calculateSimulatedValue(), MeasurementDistancemeter3dim::calculateSimulatedValue(), and MeasurementDistancemeter::calculateSimulatedValue().

                                                                                                    { 
  std::vector<ALIstring>::const_iterator vscite = _OptONameList.begin() +
    ( vocite - _OptOList.begin() ); // point to corresponding name of this OptO
  ALIint colon = (*vscite).find(':');
  ALIstring behav;
  if(colon != -1 ) {
    behav = (*vscite).substr(colon+1,(*vscite).size());
  } else {
    behav = " ";
  }
  return behav;
}
const OpticalObject * Measurement::getPreviousOptO ( const OpticalObject Popto) const

Definition at line 608 of file Measurement.cc.

References _OptOList, dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, OpticalObject::name(), and name().

Referenced by OptODistancemeter::makeMeasurement(), and OptODistancemeter3dim::makeMeasurement().

{
  //--------- Loop OptOs that take part in this measurement
  std::vector<OpticalObject*>::const_iterator vocite;
  for( vocite = _OptOList.begin(); vocite != _OptOList.end(); vocite++ ){
    if( *vocite == Popto ) {
      if( vocite == _OptOList.begin() ) {
        std::cerr << " ERROR in  getPreviousOptO of measurement " << name() << std::endl;
        std::cerr << " OptO " << Popto->name() << " is the first one " << std::endl;
        exit(1);
      } else {
        return *(vocite-1);
      }
    }
  }
  
  std::cerr << " ERROR in  getPreviousOptO of measurement " << name() << std::endl;
  std::cerr << " OptO " << Popto->name() << " not found " << std::endl;
  exit(1);
}
static ALIstring& Measurement::measurementsFileName ( ) [inline, static]

Definition at line 213 of file Measurement.h.

References theMeasurementsFileName.

Referenced by Model::readMeasurementsFromFile().

const ALIstring& Measurement::name ( ) const [inline]
std::vector<OpticalObject*>& Measurement::OptOList ( ) [inline]
const std::vector<ALIstring>& Measurement::OptONameList ( ) const [inline]

Definition at line 105 of file Measurement.h.

References _OptONameList.

Referenced by DumpBadOrderOptOs(), and CocoaToDDLMgr::measurementsAsSpecPars().

                                                   {
    return _OptONameList;
  }
void Measurement::postConstruct ( )

Definition at line 154 of file Measurement.cc.

References Model::addMeasurementToList(), buildAffectingEntryList(), buildOptOList(), gather_cfg::cout, ALIUtils::debug, Model::MeasurementList(), and setName().

Referenced by construct(), constructFromOA(), and copyMeas().

{
  //---------- Set name as name of last OptO 
  setName();

  //---------- Transform for each Measurement the Measured OptO names to Measured OptO pointers
  buildOptOList();

  //---------- Build list of Entries that affect a Measurement 
  buildAffectingEntryList();
  
  //---------- add this measurement to the global list of measurements
  Model::addMeasurementToList( this );

  if ( ALIUtils::debug >= 10 ) {
    std::cout << Model::MeasurementList().size() << std::endl;
  }
}
void Measurement::printStartCalculateSimulatedValue ( const Measurement meas) [protected]
const ALIstring& Measurement::sensorName ( ) [inline]

Definition at line 94 of file Measurement.h.

References theName.

                                {
    ALIstring sensName = theName;
    ALIint colon = theName.find(':');
    theName = theName.substr(colon+1, theName.length()-colon);
    return theName;
  }
virtual void Measurement::setConversionFactor ( const std::vector< ALIstring > &  wordlist) [inline, virtual]

Reimplemented in MeasurementCOPS, MeasurementDistancemeter, MeasurementDistancemeter3dim, MeasurementSensor2D, and MeasurementTiltmeter.

Definition at line 70 of file Measurement.h.

References dtNoiseDBValidation_cfg::cerr, and cmsRelvalreport::exit.

Referenced by Model::readSystemDescription().

                                                                          {
    std::cerr << " Measurement::setConversionFactor should never be called " << std::endl;
    exit(1); };
void Measurement::setCurrentDate ( const std::vector< ALIstring > &  wl) [static]

set the date of the current measurement

Definition at line 631 of file Measurement.cc.

References dtNoiseDBValidation_cfg::cerr, ALIUtils::dumpVS(), cmsRelvalreport::exit, theCurrentDate, and theCurrentTime.

Referenced by Model::readMeasurementsFromFile(), and CocoaDaqReaderText::ReadNextEvent().

{

  if( wl.size() != 3 ){
    std::cerr << "!!!EXITING: reading DATE of measurements set: it must have three words, it is though " << std::endl;
    ALIUtils::dumpVS(wl, " ");
   exit(1);
  } else if(wl[0] != "DATE:" ){ 
    std::cerr << "!!!EXITING: reading DATE of measurements set: first word must be 'DATE:', it is though " << std::endl;
    ALIUtils::dumpVS( wl, " ");
    exit(1);
  } else {
    theCurrentDate = wl[1];
    theCurrentTime = wl[2];
 }
} 
void Measurement::SetDimension ( ALIuint  dim) [inline]

Definition at line 180 of file Measurement.h.

References dim(), and theDim.

                                 {
    theDim = dim;
  }    
void Measurement::setLightRayDirection ( const CLHEP::Hep3Vector &  lightRayDirection) [inline]

Definition at line 224 of file Measurement.h.

References theLightRayDirection.

Referenced by OptOSensor2D::makeMeasurement().

   { theLightRayDirection = lightRayDirection; }
void Measurement::setLightRayPosition ( const CLHEP::Hep3Vector &  lightRayPosition) [inline]

Definition at line 222 of file Measurement.h.

References theLightRayPosition.

Referenced by OptOSensor2D::makeMeasurement().

   { theLightRayPosition = lightRayPosition; }
static void Measurement::setMeasurementsFileName ( const ALIstring filename) [inline, static]

Definition at line 216 of file Measurement.h.

References lut2db_cfg::filename, and theMeasurementsFileName.

                                                                  { 
   //-   std::cout << " setting file name " << filename << std::endl;
   theMeasurementsFileName = filename;
   //-   std::cout << " dsetting file name " << filename << std::endl;
 }
void Measurement::setName ( )

Definition at line 697 of file Measurement.cc.

References _OptONameList, dtNoiseDBValidation_cfg::cerr, cmsRelvalreport::exit, theName, and type().

Referenced by postConstruct().

{
  // name already set by passing one argument with sensor type
  if( theName != "" ) return;
  if( _OptONameList.size() == 0) {
    std::cerr << " !!! Error in your code, you cannot ask for the name of the Measurement before the OptONameList is build " << std::endl;
    exit(9);
  }
  std::vector<ALIstring>::iterator vsite = (_OptONameList.end()-1);
  theName = type() + ":" + (*vsite);
}
void Measurement::setSigma ( ALIint  coor,
ALIdouble  val 
) [inline]

Definition at line 171 of file Measurement.h.

References theSigma.

Referenced by MeasurementDistancemeter::correctValueAndSigma(), MeasurementDistancemeter3dim::correctValueAndSigma(), MeasurementTiltmeter::correctValueAndSigma(), Model::readMeasurementsFromFile(), and CocoaDaqReaderText::ReadNextEvent().

                                             {
    theSigma[coor] = val;
    //-    std::cout << coor << " setting sigma " << theSigma[coor] << std::endl;
  }
void Measurement::setType ( ALIstring  type) [inline]

Definition at line 176 of file Measurement.h.

References theType, and type().

                                 {
    theType = type;
  }
void Measurement::setValue ( ALIint  coor,
ALIdouble  val 
) [inline]
void Measurement::setValueSimulated ( ALIint  coor,
ALIdouble  value 
) [inline]
void Measurement::setValueSimulated_orig ( ALIint  coor,
ALIdouble  value 
) [inline]

Definition at line 192 of file Measurement.h.

References theValueSimulated_orig, and value().

Referenced by calculateOriginalSimulatedValue().

virtual void Measurement::setXlaserLine ( ALIuint  ii,
int  val 
) [inline, virtual]

Reimplemented in MeasurementCOPS.

Definition at line 209 of file Measurement.h.

Referenced by OptOCOPS::makeMeasurement().

{ };
const ALIdouble Measurement::sigma ( ALIuint  ii) const [inline]

Definition at line 136 of file Measurement.h.

References theSigma.

                                           {
    return theSigma[ii];
  } 
const ALIdouble* Measurement::sigma ( ) const [inline]
virtual const ALIdouble Measurement::sigmaDimensionFactor ( ) const [inline, virtual]
void Measurement::Substitute2p ( ALIstring ref,
const ALIstring firstref,
int  NtwoPoints 
) [protected]

Definition at line 423 of file Measurement.cc.

References gather_cfg::cout, ALIUtils::debug, and cmsCodeRules::pickleFileParser::slash.

Referenced by buildOptOList().

{
  // '/' sets hierarchy of OptOs
  ALIstring slash("/");
  
  int pos1st = firstref.length();
  // Go back an '/' in firstref for each '..' in ref
  for (int ii=0; ii < Ntwopoints; ii++) {
      pos1st = firstref.find_last_of( slash, pos1st-1);
      if ( ALIUtils::debug >=9 ) std::cout << "pos1st=" << pos1st;
  }

  if ( ALIUtils::debug >=9 ) std::cout << "before change ref: " << ref << " 1ref " << firstref << std::endl;
  // Substitute name
  ref.replace( 0, (Ntwopoints*3)-1, firstref, 0, pos1st);
  if ( ALIUtils::debug >=9 ) std::cout << "after change ref: " << ref << " 1ref " << firstref << std::endl;

}
const ALIstring& Measurement::type ( ) const [inline]
const ALIdouble Measurement::value ( ALIuint  ii) const [inline]

Definition at line 128 of file Measurement.h.

References theValue.

                                            {
    return theValue[ii];
  } 
const ALIdouble* Measurement::value ( ) const [inline]
virtual const ALIdouble Measurement::valueDimensionFactor ( ) const [inline, virtual]
bool Measurement::valueIsSimulated ( ALIint  coor) [inline]
const ALIdouble Measurement::valueSimulated ( ALIuint  ii) const [inline]
const ALIdouble Measurement::valueSimulated_orig ( ALIuint  ii) const [inline]

Definition at line 121 of file Measurement.h.

References theValueSimulated_orig.

Referenced by copyMeas().

                                                          {
    return theValueSimulated_orig[ii];
  }
const ALIstring Measurement::valueType ( ALIuint  ii) const [inline]
virtual int Measurement::xlaserLine ( ALIuint  ii) [inline, virtual]

Reimplemented in MeasurementCOPS.

Definition at line 199 of file Measurement.h.

References dtNoiseDBValidation_cfg::cerr.

Referenced by OptOCOPS::makeMeasurement().

{ std::cerr << "!!!! Measurement::xlaserLine is not returning anything " << std::endl; abort(); };

Member Data Documentation

std::vector<OpticalObject*> Measurement::_OptOList [private]
std::vector<ALIstring> Measurement::_OptONameList [private]

Definition at line 209 of file Measurement.h.

Referenced by Fit::FillMatricesWithMeasurements().

Definition at line 268 of file Measurement.h.

Referenced by Model::readMeasurementsFromFile(), and Model::readSystemDescription().

Definition at line 269 of file Measurement.h.

Referenced by Model::readMeasurementsFromFile(), and Model::readSystemDescription().

std::vector<Entry*> Measurement::theAffectingEntryList [private]

Definition at line 258 of file Measurement.h.

Referenced by addAffectingEntriesFromOptO(), and affectingEntryList().

ALIstring Measurement::theCurrentDate = "99/99/99" [static, private]

Definition at line 264 of file Measurement.h.

Referenced by getCurrentDate(), and setCurrentDate().

ALIstring Measurement::theCurrentTime = "99:99" [static, private]

Definition at line 265 of file Measurement.h.

Referenced by getCurrentTime(), and setCurrentDate().

CLHEP::Hep3Vector Measurement::theLightRayDirection [private]

Definition at line 261 of file Measurement.h.

Referenced by getLightRayDirection(), and setLightRayDirection().

CLHEP::Hep3Vector Measurement::theLightRayPosition [private]

Definition at line 260 of file Measurement.h.

Referenced by getLightRayPosition(), and setLightRayPosition().

Definition at line 262 of file Measurement.h.

Referenced by measurementsFileName(), and setMeasurementsFileName().

Definition at line 239 of file Measurement.h.

Referenced by copyMeas(), name(), sensorName(), and setName().

Definition at line 238 of file Measurement.h.

Referenced by copyMeas(), fillData(), Measurement(), setSigma(), sigma(), and ~Measurement().

Definition at line 236 of file Measurement.h.

Referenced by copyMeas(), setType(), and type().

Definition at line 237 of file Measurement.h.

Referenced by copyMeas(), fillData(), Measurement(), setValue(), value(), and ~Measurement().

Definition at line 251 of file Measurement.h.

Referenced by copyMeas(), fillData(), Measurement(), and valueIsSimulated().

Definition at line 240 of file Measurement.h.

Referenced by fillData(), Measurement(), and valueType().