Index: trunk/external/Hector/H_RecRPObject.h
===================================================================
--- trunk/external/Hector/H_RecRPObject.h	(revision 1360)
+++ trunk/external/Hector/H_RecRPObject.h	(revision 1365)
@@ -2,82 +2,108 @@
 #define _H_RecRPObject_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  A fast simulator --<--<--     *
-*                 / --<--<--     of particle   --<--<--     *
-*  ----HECTOR----<                                          *
-*                 \ -->-->-- transport through -->-->--     *
-*                   -->-->-- generic beamlines -->-->--     *
-*                                                           *
-* JINST 2:P09005 (2007)                                     *
-*      X Rouby, J de Favereau, K Piotrzkowski (CP3)         *
-*       http://www.fynu.ucl.ac.be/hector.html               *
-*                                                           *
-* Center for Cosmology, Particle Physics and Phenomenology  *
-*              Universite catholique de Louvain             *
-*                 Louvain-la-Neuve, Belgium                 *
- *                                                         *
-   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/*
+---- Hector the simulator ----
+   A fast simulator of particles through generic beamlines.
+   J. de Favereau, X. Rouby ~~~ hector_devel@cp3.phys.ucl.ac.be
+
+        http://www.fynu.ucl.ac.be/hector.html
+
+   Centre de Physique des Particules et de PhÃ©nomÃ©nologie (CP3)
+   UniversitÃ© Catholique de Louvain (UCL)
+*/
 
 /// \file H_RecRPObject.h
-/// \brief Reconstructed information from objects detected by two roman pots
+/// \brief Reconstructed information from objects detected by two roman pots 
 
-#include "TF1.h"
-#include <cmath>
-
-#include "H_BeamLine.h"
+// local #includes
+#include "H_Parameters.h"
+#include "H_AbstractBeamLine.h"
+#include <math.h>
+using namespace std;
 
 #define NOT_YET_COMPUTED -666
+// trivial (TM), angle compensation (AM) and position compensation (PM) methods
+#define TM 1
+#define AM 2
+#define PM 3
 
-/// Reconstruction of parameters at IP using measurements with roman pots
+/// Reconstructed information from objects detected by two roman pots
 class H_RecRPObject {
+/// Uses (s1,x1,y1) and (s2,x2,y2) to compute the energy, the virtuality of the event, as well as the positions (x,y)  and angles (thx, thy) at IP.
 	public:
+		/// Constructors, destructor and operators
+		//@{
 		H_RecRPObject();
-		H_RecRPObject(const float, const float, const H_AbstractBeamLine* );
-		H_RecRPObject(const float, const float, const H_AbstractBeamLine& ); // old-fashioned -- to be deleted
+		H_RecRPObject(const float, const float, const H_AbstractBeamLine& );
 		H_RecRPObject(const H_RecRPObject&);
 		H_RecRPObject& operator=(const H_RecRPObject&);
-		~H_RecRPObject() {delete f_1; delete f_2; delete g_1; delete g_2; 
-				  delete d_1; delete d_2; delete k_1; delete k_2; 
-				  delete l_1; delete l_2; 
-				  delete thebeam;};
+		~H_RecRPObject() {delete matrp1; delete matrp2; delete thebeam; return;};
+		//@}
 
-		inline float getX1() const {return x1;};
-		inline float getX2() const {return x2;};
-		inline float getY1() const {return y1;};
-		inline float getY2() const {return y2;};
-		inline float getS1() const {return s1;};
-		inline float getS2() const {return s2;};
+		/// Getters 
+		//@{
+		inline float getX1() const {return x1; /*horizontal position at first roman pot, in \mu m */}
+		inline float getY1() const {return y1; /*vertical position at first roman pot, in \mu m */}
+		inline float getS1() const {return s1; /*longitudinal position of the first roman pot, in m, from IP*/}
+		inline float getX2() const {return x2; /*horizontal position at second RP in \mu m*/}
+		inline float getY2() const {return y2; /*vertical position at second RP in \mu m*/}
+		inline float getS2() const {return s2; /*longitudinal position of the second RP, in m, from IP*/}
+		inline float getTXRP() const {return URAD*atan((x2-x1)/((s2-s1)*URAD)); /* horizontal angle at first RP, in \mu rad*/ }
+		inline float getTYRP() const {return URAD*atan((y2-y1)/((s2-s1)*URAD)); /* vertical angle at first RP, in \mu rad*/ }
+		float getX0() {return (x0==NOT_YET_COMPUTED) ? computeX0():x0; /*reconstructed horizontal position at IP*/}
+		float getY0() {return (y0==NOT_YET_COMPUTED) ? computeY0():y0; /*reconstructed vertical position at IP*/}
+		float getTXIP() {return (thx==NOT_YET_COMPUTED) ? computeTX():thx; /*reconstructed horizontal angle at IP*/}
+		float getTYIP() {return (thy==NOT_YET_COMPUTED) ? computeTY():thy; /*reconstructed vertical angle at IP*/}
+		float getE(const unsigned int); /*returns the reconstructed energy*/
+		float getE(); /*returns the reconstructed energy if already computed*/ 
+		float getQ2() {return (virtuality==NOT_YET_COMPUTED) ? computeQ2():virtuality; /*returns the reconstructed virtuality*/}
+		//@}
 
-		float getTX();
-		float getTY();
-		float getE();
-		float getE(int );
-		float getQ2();
-		float getPt();
+		// Sets the proton hit positions
+		void setPositions(const float, const float, const float, const float);
+		// Shows the variable content.
+		void printProperties() const;		
+	protected:
+		/// Measured particle coordinates at RP (X - horizontal and Y - vertical in [\f$ \mu \f$m], S -longitudinal in [m])
+		//@{
+		float x1, x2, y1, y2, s1, s2; 
+		//@}
 
-		void setPositions(const float, const float, const float, const float);
-		void setPosition_det1(const float, const float);
-		void setPosition_det2(const float, const float);
-		void setDetPos(const float, const float);
-		void setERange(const float, const float);
-		void computeERange();
-		void initialize();
-		void computeAll();
-
-	protected:
-
-		float emin, emax;
-		float x1, x2, y1, y2, s1, s2;
-		float txip, tyip, energy, q2, pt;
-		H_AbstractBeamLine* thebeam;
-		TF1* f_1, *f_2;
-		TF1* g_1, *g_2;
-		TF1* d_1, *d_2;
-		TF1* k_1, *k_2;
-		TF1* l_1, *l_2;
-	friend std::ostream& operator<< (std::ostream& os, const H_RecRPObject& rp);
+		/// Reconstructed positions and angles at IP in [\f$ \mu m\f$] and [\f$ \mu rad\f$] 
+		//@{
+		float x0, y0, thx, thy;
+		//@}
+	
+		/// Reconstructed energy and virtuality at IP in GeV and GeV\f$^2\f$ 
+		//@{
+		float energy, virtuality;
+		//@}
+	
+		float computeX0();
+		float computeY0();	
+		float computeTX();
+		float computeTY();
+		/// Energy reconstruction : trivial method
+		float computeE_TM();
+		/// Energy reconstruction : angle compensation method
+		float computeE_AM();
+		/// Energy reconstruction : position compensation method
+		float computeE_PM();
+		/// Virtuality reconstruction. Energy should be reconstructed before.
+		float computeQ2();
+		/// Calibrates the energy reconstruction with respect to the chromaticity of the transfer matrices
+		float getECorrectionFactor(const unsigned int, const unsigned int );
+		/// The beamline : 
+		H_AbstractBeamLine * thebeam;
+		/// The matrices
+		//@{
+		TMatrix * matrp1;
+		TMatrix * matrp2;
+		//@}
+		/// The correction factors
+		//@{
+		float corr1_TM, corr2_TM, corr1_AM, corr2_AM;
+		//@}
 };
 
 #endif
-
