Base_ModelB.h

Go to the documentation of this file.
00001 //! \author{Anselmo Cervera, Juan J. Gomez-Cadenas and Jose Angel Hernando}
00002 //! \date{11/01}
00003 
00004 #ifndef ModelB_h
00005 #define ModelB_h 1
00006 
00007 #include <assert.h>
00008 
00009 #include "Kalman/Interface_IModel.h"
00010 
00011 //! Base class for Model
00012 class ModelB : public IModel
00013 {
00014  public:
00015 
00016   //! default constructor
00017   ModelB(){m_measNdim=1;m_dynamicNdim=1;load();}
00018 
00019   //! constructor providing the dimensions of the state and the measurement
00020   ModelB(int measNdim, int dynamicNdim){m_measNdim=measNdim; m_dynamicNdim=dynamicNdim;load();}
00021     
00022   //! destructor
00023   virtual ~ModelB(){}
00024 
00025   //--------
00026 
00027   //! returns specific model properties
00028   virtual std::string modelProperties() 
00029     {cout << "There are not specific properties !!!" <<endl; return "";}
00030   //! set properties of the model in the case there is a choice
00031   virtual void setModelProperties(void* prop)
00032      {cout << "You cannot select specific properties !!! " << (int)prop << endl;}; //ME added address of prop
00033 
00034   //------------- PROJECTOR -------------------------
00035  
00036   //! set the projector by name
00037   virtual void setProjector(std::string name) {m_projectorName=name;}
00038   //! add a projector to the list
00039   virtual void addProjector(std::string name, IProjector* p){m_projectorMap[name]=p;}
00040 
00041   //! returns the H matrix for the state
00042   virtual EMatrix HMatrix(const IState& state, const IMeasurement& meas)
00043   {return projector(meas.type()).HMatrix(state, meas);} 
00044 
00045 
00046 
00047   //! project the state of the point 
00048   virtual bool project(IPoint& point)
00049     {return projector(point.measType()).project(point);} 
00050   
00051 
00052   //!   Project the dynamic vector
00053   virtual EVector projectionVector(const IState& state, const IMeasurement& meas)
00054   {return projector(meas.type()).projectionVector(state, meas);} 
00055 
00056 
00057   //!   Project the dynamic matrix
00058   virtual EMatrix projectionMatrix(const IState& state, const IMeasurement& meas)
00059     {return projector(meas.type()).projectionMatrix(state, meas);}  
00060 
00061   //!   Project the dynamicHV
00062   virtual HyperVector projectionHV(const IState& state, const IMeasurement& meas)
00063     {return projector(meas.type()).projectionHV(state, meas);}
00064 
00065   
00066   virtual EMatrix measurementProjector(const IState& state, const IMeasurement& meas)
00067     {return projector(meas.type()).measurementProjector(state, meas);}
00068 
00069 
00070   //! Returns the A matrix (dx/dr) for the Kalman vertex fit
00071   virtual EMatrix AMatrix(const IState& state, const IMeasurement& meas)
00072     {return projector(meas.type()).AMatrix(state, meas);}
00073 
00074   //! Returns the B matrix (dx/dp) for the Kalman vertex fit
00075   virtual EMatrix BMatrix(const IState& state, const IMeasurement& meas)
00076     {return projector(meas.type()).BMatrix(state, meas);}
00077 
00078   //! Returns the c0 vector for the Kalman vertex fit
00079   virtual EVector c0(const IState& state, const IMeasurement& meas)
00080     {return projector(meas.type()).c0(state, meas);}
00081 
00082 
00083 
00084 
00085   //------------- PROPAGATOR ------------------------
00086 
00087   //! returns the propagator name
00088   virtual std::string propagatorName() const {return m_propagatorName;}
00089   //! set the propagator by name
00090   virtual void setPropagator(std::string name) {m_propagatorName=name;}
00091   //! set externally the propagator
00092   virtual void addPropagator(std::string name, IPropagator* p) {m_propagatorMap[name]=p;}
00093 
00094   //! set propagator vervosity 
00095   virtual void setPropagatorVerbosity(int v){propagator().setVerbosity(v);}
00096   //! return propagator vervosity 
00097   virtual int propagatorVerbosity(){return propagator().verbosity();}      
00098 
00099   //! returns specific propagator properties
00100   virtual std::string propagatorProperties() 
00101     {return propagator().propagatorProperties();}
00102   //! set properties of the propagator in the case there is a choice
00103   virtual void setPropagatorProperties(void* prop)
00104      {propagator().setPropagatorProperties(prop);} 
00105 
00106   //!   If the Propagator it is linear returns the F matrix
00107   //!   (if not returns the 1st term of Taylor expansion)
00108   virtual EMatrix FMatrix() {return propagator().FMatrix();}
00109   
00110   //!   Returns the matrix of random extra errors added to the state during the
00111   //!   progation (null if non)
00112   virtual EMatrix QMatrix() {return propagator().QMatrix();}
00113 
00114 
00115   //! Propagate an state to a surface
00116   //! It compute the dynamicHV and the runningHV in the new surface, set the values in the state
00117   //! It has the extra possibility of propagate an state with a different model
00118   virtual bool propagate(const IState& iniS,
00119              const ISurface& surf, 
00120              IState& finalS);
00121 
00122 
00123   //!   Propagate an state to a given length
00124   virtual bool propagate(const IState& iniS,
00125              const ISurface& surf,
00126              const HyperVector& natHV, 
00127              IState& finalS);
00128 
00129 
00130 
00131   //!   Propagate an state in steps
00132   virtual bool propagateInSteps(const IState& iniS,
00133                 const ISurface& surf,
00134                 const HyperVector& natHV, 
00135                 IState& finalS);
00136 
00137   // functions for propagation in steps
00138   virtual void actionBeforeFirstStep(const ISurface& surf, IState& state);
00139   virtual void actionBeforeStep(HyperVector& natHV, IState& state);
00140   virtual void actionAfterStep(HyperVector& natHV, IState& state);
00141   virtual void actionBeforeLastStep(const ISurface& surf, IState& state);
00142 
00143   
00144   //!  Returns the dynamicHV of the state when propagate an state to a surface
00145   virtual HyperVector propagateDynamicHV(const IState& iniS, 
00146                      const ISurface& surf);
00147   
00148 
00149   // computes the path lentgh between a state and a straight line, 
00150   // providing rl0 and ul0 such that rl = rl0 + ul0*s
00151   virtual double pathLengthToStraightLine(const IState& iniS, 
00152                       const EVector& rl0,
00153                       const EVector& ul0)
00154     { 
00155       cout << "ModelB  ERROR:   pathLengthToStraightLine " << rl0 << " " << ul0 << endl; 
00156       iniS.info(2);
00157       assert(false);
00158       return -1.0;
00159     }  //ME added return and warning mesages
00160 
00161 
00162   //---------------- NOISERS -------------------------
00163 
00164   //! add a Noiser to the Model
00165   virtual void addNoiser(std::string name, INoiser* noiser) 
00166     {noiser->setName(name);m_noiserVector.push_back(noiser);}
00167 
00168   //! number of noisers
00169   virtual int nNoisers() const { return m_noiserVector.size();}
00170 
00171   //! set is Used 
00172   virtual void setNoiserIsUsed(std::string name, bool flag) 
00173     {noiser(name).setIsUsed(flag);}
00174   virtual bool noiserIsUsed(std::string name)    //TODO const
00175     {return noiser(name).isUsed();}
00176 
00177   //! Compute the Q matrix
00178   virtual EMatrix computeQMatrix(const IState& iniS, const HyperVector& natHV) const;
00179 
00180 
00181   //------------------ SURFACE INTERSECTOR ---------------
00182 
00183   //! add a surface intersector
00184   virtual void addSurfaceIntersector(std::string name, IModelSurfaceIntersector* surfaceIntersector) 
00185     {m_surfaceIntersectorMap[name]=surfaceIntersector;}
00186   
00187 
00188   //! computes the natural HyperVector when intersecting a surface
00189   virtual bool naturalHVAtSurface(const IState& iniS,
00190                   const ISurface& surf, 
00191                   HyperVector& natHV)   
00192     {return surfaceIntersector(surf).naturalHVAtSurface(iniS, surf, natHV);}
00193 
00194   //! computes the natural HyperVector when intersecting a surface and check that the intersection point 
00195   //! is inside the surface
00196   virtual bool naturalHVAtFiniteSurface(const IState& iniS, 
00197                     const ISurface& surf,
00198                     HyperVector& natHV)     
00199     {return surfaceIntersector(surf).naturalHVAtFiniteSurface(iniS, surf, natHV);}
00200 
00201   
00202 
00203   //! computes the surface perpendicular to the trajectory and containing the point measHV. 
00204   //! Computes also the natural HyperVector when intersecting that surface.
00205   virtual bool naturalHVAtNormalSurface(const IState& prevState, 
00206                     const HyperVector& measHV,
00207                     const std::string surfType,
00208                     ISurface& surf,
00209                     HyperVector& natHV)    
00210     {return surfaceIntersector(surfType).naturalHVAtNormalSurface(prevState, measHV, surf, natHV);}
00211 
00212   //---------
00213 
00214   //! get dimension of the dynamic vector
00215   virtual const int dynamicNdim() const {return m_dynamicNdim;}
00216   //! set dimension of the dynamic vector
00217   virtual void setDynamicNdim(const int dim) {m_dynamicNdim=dim;}
00218   
00219   //! get dimension of the measurement
00220   virtual const int measNdim() const {return m_measNdim;}
00221   //! set dimension of the measurement vector
00222   virtual void setMeasNdim(const int dim) {m_measNdim=dim;}
00223 
00224   //-------
00225 
00226   //!  The name of the model
00227   virtual void setName(std::string name) {m_name = name;}
00228   //!   Return of the model name
00229   virtual std::string name() const {return m_name;}
00230   
00231   //!  The volume  //TODO
00232   virtual void setVolume(IVolume& vol);
00233   virtual IVolume& volume() const {return *m_volume;}
00234 
00235   //! set verbosity 
00236   virtual void setVerbosity(int v);
00237   //! return verbosity 
00238   virtual int verbosity() const {return m_verbosity;}  
00239 
00240   //! list the available options
00241   virtual void menu() const;
00242 
00243   //! returns the components
00244   virtual const int irun()    const {return m_irun;}
00245   virtual const int istate0() const {return m_istate0;}
00246   virtual const int istate1() const {return m_istate1;}
00247 
00248   //! interpretation of states
00249   virtual const EVector directionVector(const IState& state) const { state.info(2); return EVector( 1, 0 ); }       //ME added info and return
00250   virtual const EVector positionVector(const IState& state) const { state.info(2); return EVector( 1, 0 ); }        //ME added info and return
00251   virtual const EMatrix directionMatrix(const IState& state) const { state.info(2); return EMatrix( 1, 1, 0 ); }    //ME added info and return
00252   virtual const EMatrix positionMatrix(const IState& state) const { state.info(2); return EMatrix( 1, 1, 0 ); }     //ME added info and return
00253   virtual const EVector momentumVector(const IState& state) const { state.info(2); return EVector( 1, 0 ); }        //ME added info and return
00254   virtual const EMatrix momentumMatrix(const IState& state) const { state.info(2); return EMatrix( 1, 1, 0 ); }     //ME added info and return
00255   virtual const double momentum(const IState& state) const { state.info(2); return -1.0; };             //ME added info and return
00256   virtual const double momentumError2(const IState& state) const { state.info(2); return -1.0; };               //ME added info and return
00257   virtual const double charge(const IState& state) const { state.info(2); return 0; };                  //ME added info and return
00258 
00259   //! interpretation of vertex parameters
00260   virtual const EVector directionVectorVertex(const IState& state) const;
00261   virtual const EVector positionVectorVertex(const IState& state) const;
00262   virtual const EMatrix directionMatrixVertex(const IState& state) const;
00263   virtual const EMatrix positionMatrixVertex(const IState& state) const;
00264   virtual const EVector momentumVectorVertex(const IState& state) const;
00265   virtual const EMatrix momentumMatrixVertex(const IState& state) const;
00266   virtual const EMatrix positionMomentumMatrixVertex(const IState& state) const;
00267 
00268  protected:
00269   
00270   //! load the predefined projectors and propagators
00271   virtual void load();
00272   
00273   //! returns the projector
00274   virtual IProjector& projector(std::string name) {return *m_projectorMap[name];}
00275  
00276  
00277   //! returns the propagator
00278   virtual IPropagator& propagator() {return *m_propagatorMap[m_propagatorName];}
00279 
00280   //! returns the noiser
00281   virtual INoiser& noiser(int i) const {return *m_noiserVector[i];} 
00282   virtual INoiser& noiser(std::string name);
00283 
00284   //! returns the Surface Intersector for a given surface type
00285   virtual IModelSurfaceIntersector& surfaceIntersector(std::string name)   
00286     {return *m_surfaceIntersectorMap[name];}
00287    
00288 
00289   //! returns the Surface Intersector for a given surface
00290   virtual IModelSurfaceIntersector& surfaceIntersector(const ISurface& surf) 
00291     {return *m_surfaceIntersectorMap[surf.type()];}
00292       
00293   //temporary //todo
00294   virtual EVector energyLossParameters(){ return m_energyLossParameters;}
00295 
00296  protected:
00297 
00298   std::string m_name;
00299 
00300   IVolume* m_volume;
00301 
00302   int m_dynamicNdim;
00303   int m_measNdim;
00304   
00305   std::string m_propagatorName;
00306   std::string m_projectorName;
00307 
00308   
00309   std::map<std::string, IPropagator*> m_propagatorMap;
00310   std::map<std::string, IProjector*> m_projectorMap;
00311 
00312   std::vector<INoiser*> m_noiserVector; 
00313 
00314   std::map<std::string, IModelSurfaceIntersector*> m_surfaceIntersectorMap; 
00315 
00316   int m_verbosity;
00317 
00318   
00319   // components 
00320   int m_irun;
00321   int m_istate0;
00322   int m_istate1;
00323         
00324 
00325 
00326   double m_stepEnergyLoss;
00327   EVector m_energyLossParameters;
00328 
00329 
00330   bool m_propagateInSteps;
00331   bool m_propagateInStepsNow;
00332         
00333   double m_stepLength;  
00334 
00335   int m_nSteps;
00336   int m_nMaxSteps;
00337 
00338   double m_side;
00339 
00340 };
00341 
00342 #endif
00343 

Generated on Mon Nov 23 08:01:43 2009 for MIPP(E907) by  doxygen 1.4.7