Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:00

0001 // COCOA class header file

0002 // Id:  Measurement.h

0003 // CAT: Model

0004 //

0005 // Class for measurements

0006 //

0007 // History: v1.0.0

0008 // v1.1.0: add measurementsFileName

0009 //

0010 // Authors:

0011 //   Pedro Arce

0012 
0013 #ifndef _MEASUREMENT_HH
0014 #define _MEASUREMENT_HH
0015 
0016 #include <vector>
0017 #include <cstdlib>
0018 
0019 #include "Alignment/CocoaUtilities/interface/CocoaGlobals.h"
0020 #include "Alignment/CocoaUtilities/interface/ALIUtils.h"
0021 class OpticalObject;
0022 class Entry;
0023 class EntryLength;
0024 class OpticalAlignMeasurementInfo;
0025 class OpticalAlignParam;
0026 
0027 class Measurement {
0028 public:
0029   //----- Constructors / destructor

0030   Measurement(const ALIint measdim, ALIstring& type, ALIstring& name);
0031   Measurement(){};
0032   virtual ~Measurement();
0033 
0034   // construct Measurement reading date from file

0035   void construct();
0036   void postConstruct();
0037   // Fill the list of names of OptOs that take part in this measurement ( names only )

0038   virtual void buildOptONamesList(const std::vector<ALIstring>& wl);
0039   // Fill the data

0040   void fillData(ALIuint coor, const std::vector<ALIstring>& wl);
0041   void fillData(ALIuint coor, OpticalAlignParam* oaParam);
0042 
0043   // Convert OptOs names in OptOs pointers

0044   void buildOptOList();
0045   // Make list including every entry of every ancestor of each Measured OptO

0046   void buildAffectingEntryList();
0047   void addAffectingEntriesFromOptO(const OpticalObject* optoP);
0048 
0049   // Get simulated value (called every time a parameter is displaced)

0050   virtual void calculateSimulatedValue(ALIbool firstTime){};
0051   // Get simulated value original (called every time a parameter value is changed: after getting values from file and every non-linear fit iteration )

0052   void calculateOriginalSimulatedValue();
0053 
0054   // Dump the list of OptO names (used mainly when checking their order)

0055   void DumpBadOrderOptOs();
0056 
0057   // Calculate derivative of this Measurement with respect to a parameter of an Entry

0058   std::vector<ALIdouble> DerivativeRespectEntry(Entry* entry);
0059 
0060   // get the ':X' that determines how the behaviour of the OptO w.r.t. this Measurement

0061   ALIstring getMeasuringBehaviour(const std::vector<OpticalObject*>::const_iterator vocite);
0062 
0063   // Get the previous OptOs in the list of OptO that take part in this measurement

0064   const OpticalObject* getPreviousOptO(const OpticalObject* Popto) const;
0065   //---------- Add any correction between the measurement data and the default format in COCOA

0066   virtual void correctValueAndSigma(){};
0067 
0068   //---------- Convert from V to rad

0069   virtual void setConversionFactor(const std::vector<ALIstring>& wordlist) {
0070     std::cerr << " Measurement::setConversionFactor should never be called " << std::endl;
0071     exit(1);
0072   };
0073 
0074   //! set the date of the current measurement

0075   static void setCurrentDate(const std::vector<ALIstring>& wl);
0076 
0077   void copyMeas(Measurement* meas, const std::string& subsstr1, const std::string& subsstr2);
0078 
0079   void constructFromOA(OpticalAlignMeasurementInfo& measInfo);
0080 
0081   // ACCESS DATA MEMBERS

0082   const ALIuint dim() const { return theDim; }
0083 
0084   const ALIstring& type() const { return theType; }
0085 
0086   const ALIstring& name() const { return theName; }
0087 
0088   const ALIstring& sensorName() {
0089     ALIstring sensName = theName;
0090     ALIint colon = theName.find(':');
0091     theName = theName.substr(colon + 1, theName.length() - colon);
0092     return theName;
0093   }
0094 
0095   //  const OpticalObject* OptOCurrent() const {

0096   //  return _OptOCurrent;

0097   // }

0098 
0099   const std::vector<ALIstring>& OptONameList() const { return _OptONameList; }
0100 
0101   const std::vector<OpticalObject*>& OptOList() const { return _OptOList; }
0102 
0103   const std::vector<Entry*>& affectingEntryList() const { return theAffectingEntryList; }
0104 
0105   const ALIdouble valueSimulated(ALIuint ii) const { return theValueSimulated[ii]; }
0106 
0107   const ALIdouble valueSimulated_orig(ALIuint ii) const { return theValueSimulated_orig[ii]; }
0108 
0109   const ALIdouble* value() const { return theValue; }
0110   const ALIdouble value(ALIuint ii) const { return theValue[ii]; }
0111 
0112   const ALIdouble* sigma() const { return theSigma; }
0113 
0114   const ALIdouble sigma(ALIuint ii) const { return theSigma[ii]; }
0115 
0116   const ALIstring valueType(ALIuint ii) const { return theValueType[ii]; }
0117 
0118   virtual const ALIdouble valueDimensionFactor() const { return ALIUtils::LengthValueDimensionFactor(); }
0119 
0120   virtual const ALIdouble sigmaDimensionFactor() const { return ALIUtils::LengthSigmaDimensionFactor(); }
0121 
0122   static ALIstring getCurrentDate() { return theCurrentDate; }
0123   static ALIstring getCurrentTime() { return theCurrentTime; }
0124 
0125   const CLHEP::Hep3Vector& getLightRayPosition() const { return theLightRayPosition; }
0126   const CLHEP::Hep3Vector& getLightRayDirection() const { return theLightRayDirection; }
0127 
0128   // SET DATA MEMBERS

0129   void setValue(ALIint coor, ALIdouble val) { theValue[coor] = val; }
0130 
0131   void setSigma(ALIint coor, ALIdouble val) {
0132     theSigma[coor] = val;
0133     //-    std::cout << coor << " setting sigma " << theSigma[coor] << std::endl;

0134   }
0135 
0136   void setType(ALIstring type) { theType = type; }
0137 
0138   void SetDimension(ALIuint dim) { theDim = dim; }
0139 
0140   void AddOptONameListItem(ALIstring optos) { _OptONameList.push_back(optos); }
0141 
0142   void AddOptOListItem(OpticalObject* opto) { _OptOList.push_back(opto); }
0143 
0144   void setValueSimulated_orig(ALIint coor, ALIdouble value) { theValueSimulated_orig[coor] = value; }
0145 
0146   void setValueSimulated(ALIint coor, ALIdouble value) { theValueSimulated[coor] = value; }
0147   virtual int xlaserLine(ALIuint ii) {
0148     std::cerr << "!!!! Measurement::xlaserLine is not returning anything " << std::endl;
0149     abort();
0150   };
0151 
0152   //----- Set name as type plus name of last OptO

0153   void setName();
0154 
0155   // Check is value is simulated

0156   bool valueIsSimulated(ALIint coor) { return theValueIsSimulated[coor]; }
0157 
0158   virtual void setXlaserLine(ALIuint ii, int val){};
0159 
0160   static ALIdouble cameraScaleFactor;
0161 
0162   static ALIstring& measurementsFileName() { return theMeasurementsFileName; }
0163   static void setMeasurementsFileName(const ALIstring& filename) {
0164     //-   std::cout << " setting file name " << filename << std::endl;

0165     theMeasurementsFileName = filename;
0166     //-   std::cout << " dsetting file name " << filename << std::endl;

0167   }
0168 
0169   void setLightRayPosition(const CLHEP::Hep3Vector& lightRayPosition) { theLightRayPosition = lightRayPosition; }
0170   void setLightRayDirection(const CLHEP::Hep3Vector& lightRayDirection) { theLightRayDirection = lightRayDirection; }
0171 
0172 protected:
0173   // Substitute '..' by parent OptO in name

0174   void Substitute2p(ALIstring& ref, const ALIstring& firstref, int NtwoPoints);
0175   void printStartCalculateSimulatedValue(const Measurement* meas);
0176 
0177   // private DATA MEMBERS

0178 private:
0179   ALIuint theDim;
0180   ALIstring theType;
0181   ALIdouble* theValue;
0182   ALIdouble* theSigma;
0183   ALIstring theName;        //name of last OptO

0184   ALIstring* theValueType;  //type of each measurement value (e.g. H:, TA:)

0185 
0186   //----- values of measurement obtained simulating the light ray through all the OptO that take part in the measurement

0187   ALIdouble* theValueSimulated;
0188   //----- values of measurement obtained simulating the light ray through all the OptO that take part in the measurement, for original values of every entry

0189   ALIdouble* theValueSimulated_orig;
0190 
0191   //-  ALIdouble* theSigmaErrorPropagation;

0192   //-  ALIdouble* theSigmaRegression;

0193 
0194   //----- Boolean to indicate if theValueSimulated_orig is set equal to the simulated values with original entries

0195   ALIbool* theValueIsSimulated;
0196 
0197   //----- List of OptOs that take part in this measurement ( names only )

0198   std::vector<ALIstring> _OptONameList;
0199   //----- List of OptOs that take part in this measurement ( pointers )

0200   std::vector<OpticalObject*> _OptOList;
0201   //----- List of OptOs Measured and their ancestors

0202   std::vector<Entry*> theAffectingEntryList;
0203 
0204   CLHEP::Hep3Vector theLightRayPosition;
0205   CLHEP::Hep3Vector theLightRayDirection;
0206   static ALIstring theMeasurementsFileName;
0207 
0208   static ALIstring theCurrentDate;
0209   static ALIstring theCurrentTime;
0210 
0211 public:
0212   static ALIbool only1;
0213   static ALIstring only1Date;
0214   static ALIstring only1Time;
0215 };
0216 
0217 #endif