00001 00023 #ifndef __PARTICLECONSTRAINT_H 00024 #define __PARTICLECONSTRAINT_H 00025 00026 #include<vector> 00027 #include<cassert> 00028 #include "BaseConstraint.h" 00029 00030 class ParticleFitObject; 00031 00032 // Class ParticleConstraint: 00034 00071 class ParticleConstraint: public BaseConstraint { 00072 public: 00074 inline ParticleConstraint(); 00076 virtual ~ParticleConstraint() {}; 00077 00079 virtual void setFOList(std::vector <ParticleFitObject*> *fitobjects_ 00080 ){ 00081 for (int i = 0; i < (int) fitobjects_->size(); i++) { 00082 fitobjects.push_back ((*fitobjects_)[i]); 00083 flags.push_back (1); 00084 } 00085 }; 00087 virtual void addToFOList(ParticleFitObject& fitobject, int flag = 1 00088 ){ 00089 fitobjects.push_back (&fitobject); 00090 flags.push_back (flag); 00091 }; 00093 virtual double getValue() const = 0; 00094 00097 virtual void getDerivatives(int idim, 00098 double der[] 00099 ) const = 0; 00101 virtual void add1stDerivativesToMatrix(int idim, 00102 double *M 00103 ) const 00104 {assert (false);} 00106 virtual void add2ndDerivativesToMatrix(int idim, 00107 double *M, 00108 double lambda 00109 ) const 00110 {assert (false);} 00111 00113 virtual int getGlobalNum() const 00114 {return globalNum;} 00116 virtual void setGlobalNum (int iglobal 00117 ) 00118 {globalNum = iglobal;} 00119 00121 virtual void invalidateCache() const 00122 {} 00123 00124 protected: 00126 typedef std::vector <ParticleFitObject *> FitObjectContainer; 00128 typedef FitObjectContainer::iterator FitObjectIterator; 00130 typedef FitObjectContainer::const_iterator ConstFitObjectIterator; 00132 FitObjectContainer fitobjects; 00134 std::vector <double> derivatives; 00137 std::vector <int> flags; 00138 00140 int globalNum; 00141 00142 }; 00143 00144 ParticleConstraint::ParticleConstraint() { 00145 invalidateCache(); 00146 } 00147 00148 #endif // __PARTICLECONSTRAINT_H