CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Alignment/CocoaModel/interface/Measurement.h

Go to the documentation of this file.
00001 // COCOA class header file
00002 // Id:  Measurement.h
00003 // CAT: Model
00004 //
00005 // Class for measurements
00006 // 
00007 // History: v1.0.0
00008 // v1.1.0: add measurementsFileName
00009 // 
00010 // Authors:
00011 //   Pedro Arce
00012 
00013 #ifndef _MEASUREMENT_HH
00014 #define _MEASUREMENT_HH
00015 
00016 #include <vector>
00017 #include <cstdlib>
00018 
00019 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
00020 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
00021 class OpticalObject;
00022 class Entry;
00023 class EntryLength;
00024 class OpticalAlignMeasurementInfo;
00025 class OpticalAlignParam;
00026 
00027 class Measurement
00028 { 
00029 public:
00030   //----- Constructors / destructor
00031   Measurement( const ALIint measdim, ALIstring& type, ALIstring& name );
00032   Measurement(){ };   
00033   virtual ~Measurement();
00034     
00035   // construct Measurement reading date from file
00036   void construct();
00037   void postConstruct();
00038   // Fill the list of names of OptOs that take part in this measurement ( names only )
00039   virtual void buildOptONamesList( const std::vector<ALIstring>& wl );
00040   // Fill the data 
00041   void fillData(ALIuint coor, const std::vector<ALIstring>& wl );
00042   void fillData( ALIuint coor, OpticalAlignParam* oaParam);
00043 
00044   // Convert OptOs names in OptOs pointers
00045   void buildOptOList();
00046   // Make list including every entry of every ancestor of each Measured OptO
00047   void buildAffectingEntryList();
00048   void addAffectingEntriesFromOptO( const OpticalObject* optoP );
00049 
00050   // Get simulated value (called every time a parameter is displaced)
00051   virtual void calculateSimulatedValue( ALIbool firstTime ) {};
00052   // Get simulated value original (called every time a parameter value is changed: after getting values from file and every non-linear fit iteration )
00053   void calculateOriginalSimulatedValue();
00054 
00055   // Dump the list of OptO names (used mainly when checking their order)
00056   void DumpBadOrderOptOs();
00057 
00058   // Calculate derivative of this Measurement with respect to a parameter of an Entry
00059   std::vector<ALIdouble> DerivativeRespectEntry( Entry* entry );
00060 
00061   // get the ':X' that determines how the behaviour of the OptO w.r.t. this Measurement
00062   ALIstring getMeasuringBehaviour( const std::vector< OpticalObject* >::const_iterator vocite);
00063 
00064  // Get the previous OptOs in the list of OptO that take part in this measurement
00065   const OpticalObject* getPreviousOptO( const OpticalObject* Popto ) const;
00066   //---------- Add any correction between the measurement data and the default format in COCOA
00067   virtual void correctValueAndSigma(){};
00068 
00069   //---------- Convert from V to rad
00070   virtual void setConversionFactor( const std::vector<ALIstring>& wordlist ){
00071     std::cerr << " Measurement::setConversionFactor should never be called " << std::endl;
00072     exit(1); };
00073 
00075   static void setCurrentDate( const std::vector<ALIstring>& wl );
00076 
00077   void copyMeas( Measurement* meas, const std::string& subsstr1, const std::string& subsstr2 );
00078 
00079   void constructFromOA( OpticalAlignMeasurementInfo&  measInfo);
00080 
00081  // ACCESS DATA MEMBERS
00082   const ALIuint dim() const { 
00083     return theDim;
00084   }
00085  
00086   const ALIstring& type() const {
00087     return theType;
00088   }
00089   
00090   const ALIstring& name() const {
00091     return theName;
00092   }
00093 
00094   const ALIstring& sensorName() {
00095     ALIstring sensName = theName;
00096     ALIint colon = theName.find(':');
00097     theName = theName.substr(colon+1, theName.length()-colon);
00098     return theName;
00099   }
00100   
00101   //  const OpticalObject* OptOCurrent() const {
00102   //  return _OptOCurrent;
00103   // }
00104   
00105   const std::vector<ALIstring>& OptONameList() const {
00106     return _OptONameList;
00107   }
00108   
00109   std::vector<OpticalObject*>& OptOList() {
00110     return _OptOList;
00111   }
00112   
00113   const std::vector<Entry*>& affectingEntryList() const {
00114     return theAffectingEntryList;
00115   }
00116   
00117   const  ALIdouble valueSimulated( ALIuint ii ) const {
00118     return theValueSimulated[ii];
00119   }
00120 
00121   const ALIdouble valueSimulated_orig( ALIuint ii ) const {
00122     return theValueSimulated_orig[ii];
00123   }
00124 
00125   const ALIdouble* value() const {
00126     return theValue;
00127   } 
00128   const ALIdouble value( ALIuint ii ) const {
00129     return theValue[ii];
00130   } 
00131 
00132   const ALIdouble* sigma() const {
00133     return theSigma;
00134   } 
00135 
00136   const ALIdouble sigma( ALIuint ii) const {
00137     return theSigma[ii];
00138   } 
00139 
00140   const ALIstring valueType( ALIuint ii) const {
00141     return theValueType[ii];
00142   } 
00143 
00144   virtual const ALIdouble valueDimensionFactor() const{
00145     return ALIUtils::LengthValueDimensionFactor();
00146   }
00147 
00148   virtual const ALIdouble sigmaDimensionFactor() const{
00149     return ALIUtils::LengthSigmaDimensionFactor();
00150   }
00151 
00152   static ALIstring getCurrentDate(){
00153     return theCurrentDate;
00154   }
00155   static ALIstring getCurrentTime(){
00156     return theCurrentTime;
00157   }
00158 
00159   const CLHEP::Hep3Vector& getLightRayPosition( ) const{
00160     return theLightRayPosition; 
00161   }
00162   const CLHEP::Hep3Vector& getLightRayDirection( ) const{ 
00163     return theLightRayDirection; 
00164   }
00165 
00166  // SET DATA MEMBERS
00167   void setValue( ALIint coor, ALIdouble val) {
00168     theValue[coor] = val;
00169   }
00170   
00171   void setSigma( ALIint coor, ALIdouble val) {
00172     theSigma[coor] = val;
00173     //-    std::cout << coor << " setting sigma " << theSigma[coor] << std::endl;
00174   }
00175 
00176   void setType( ALIstring type ) {
00177     theType = type;
00178   }
00179 
00180   void SetDimension(ALIuint dim) {
00181     theDim = dim;
00182   }    
00183 
00184   void AddOptONameListItem(ALIstring optos) {
00185       _OptONameList.push_back( optos );
00186   }
00187 
00188   void AddOptOListItem(OpticalObject* opto) {
00189       _OptOList.push_back( opto );
00190   }
00191 
00192   void setValueSimulated_orig( ALIint coor, ALIdouble value) {
00193       theValueSimulated_orig[coor] = value;
00194   }
00195 
00196   void setValueSimulated( ALIint coor, ALIdouble value) {
00197       theValueSimulated[coor] = value;
00198   }
00199   virtual int xlaserLine( ALIuint ii) { std::cerr << "!!!! Measurement::xlaserLine is not returning anything " << std::endl; abort(); };
00200  
00201   //----- Set name as type plus name of last OptO 
00202   void setName();
00203 
00204   // Check is value is simulated
00205   bool valueIsSimulated(ALIint coor) {
00206       return theValueIsSimulated[coor];
00207   }
00208 
00209   virtual void setXlaserLine( ALIuint ii, int val ) { };
00210 
00211  static ALIdouble cameraScaleFactor;
00212 
00213  static ALIstring& measurementsFileName() { 
00214    return theMeasurementsFileName;
00215  }
00216  static void setMeasurementsFileName( const ALIstring& filename ) { 
00217    //-   std::cout << " setting file name " << filename << std::endl;
00218    theMeasurementsFileName = filename;
00219    //-   std::cout << " dsetting file name " << filename << std::endl;
00220  }
00221 
00222  void setLightRayPosition( const CLHEP::Hep3Vector& lightRayPosition )
00223    { theLightRayPosition = lightRayPosition; }
00224  void setLightRayDirection( const CLHEP::Hep3Vector& lightRayDirection )
00225    { theLightRayDirection = lightRayDirection; }
00226 
00227  protected:  
00228   // Substitute '..' by parent OptO in name 
00229   void Substitute2p( ALIstring& ref, const ALIstring& firstref, int NtwoPoints);
00230   void printStartCalculateSimulatedValue( const Measurement* meas);
00231 
00232 
00233  // private DATA MEMBERS
00234 private:
00235   ALIuint theDim;
00236   ALIstring theType;
00237   ALIdouble* theValue;  
00238   ALIdouble* theSigma;
00239   ALIstring theName;  //name of last OptO
00240   ALIstring* theValueType;  //type of each measurement value (e.g. H:, TA:)
00241 
00242   //----- values of measurement obtained simulating the light ray through all the OptO that take part in the measurement
00243   ALIdouble* theValueSimulated;
00244   //----- values of measurement obtained simulating the light ray through all the OptO that take part in the measurement, for original values of every entry
00245   ALIdouble* theValueSimulated_orig;
00246 
00247   //-  ALIdouble* theSigmaErrorPropagation;
00248   //-  ALIdouble* theSigmaRegression;
00249 
00250   //----- Boolean to indicate if theValueSimulated_orig is set equal to the simulated values with original entries
00251   ALIbool* theValueIsSimulated;
00252 
00253   //----- List of OptOs that take part in this measurement ( names only )
00254   std::vector<ALIstring> _OptONameList;
00255   //----- List of OptOs that take part in this measurement ( pointers )
00256   std::vector<OpticalObject*> _OptOList;
00257   //----- List of OptOs Measured and their ancestors
00258   std::vector<Entry*> theAffectingEntryList;
00259 
00260   CLHEP::Hep3Vector theLightRayPosition;
00261   CLHEP::Hep3Vector theLightRayDirection;
00262   static ALIstring theMeasurementsFileName;
00263 
00264   static ALIstring theCurrentDate;  
00265   static ALIstring theCurrentTime;  
00266  public:
00267   static ALIbool only1;
00268   static ALIstring only1Date;
00269   static ALIstring only1Time;
00270 
00271 };
00272 
00273 #endif