Index: external/Hector/H_AbstractBeamLine.cc
===================================================================
--- external/Hector/H_AbstractBeamLine.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_AbstractBeamLine.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,13 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_AbstractBeamLine.cc
@@ -27,10 +21,10 @@
 
 // ROOT #includes
-#include "TPaveLabel.h"
-#include "TLine.h"
-#include "TGaxis.h"
-#include "TLegend.h"
-#include "TF1.h"
-#include "TROOT.h"
+//#include "TPaveLabel.h"
+//#include "TLine.h"
+//#include "TGaxis.h"
+//#include "TLegend.h"
+//#include "TF1.h"
+//#include "TROOT.h"
 
 // local #includes
@@ -39,10 +33,10 @@
 #include "H_Drift.h"
 #include "H_AbstractBeamLine.h"
+#include "H_BeamParticle.h"
 #include "H_RomanPot.h"
 using namespace std;
 
 void H_AbstractBeamLine::init(const float length) {
-	beam_mat.ResizeTo(MDIM,MDIM);
-	beam_mat = driftmat(length);
+	beam_mat = new TMatrix(MDIM,MDIM);
   	beam_length = length;
 	H_Drift * drift0 = new H_Drift("Drift0",0.,length);
@@ -51,10 +45,8 @@
 }
 
-H_AbstractBeamLine::H_AbstractBeamLine(const H_AbstractBeamLine& beamline) : 
-	matrices(beamline.matrices)   {
-	//elements = beamline.elements; //<-- bad ! the new vector contains the same pointers as the previous one
-	cloneElements(beamline);
-	beam_mat.ResizeTo(MDIM,MDIM);
-	beam_mat = beamline.beam_mat;
+H_AbstractBeamLine::H_AbstractBeamLine(const H_AbstractBeamLine& beamline) {
+	elements = beamline.elements;
+	matrices = beamline.matrices;
+	beam_mat = new TMatrix(*(beamline.beam_mat));
 	beam_length = beamline.beam_length;
 }
@@ -62,24 +54,9 @@
 H_AbstractBeamLine& H_AbstractBeamLine::operator=(const H_AbstractBeamLine& beamline) {
 	if(this== &beamline) return *this;
-	//elements = beamline.elements; //<-- bad ! the new vector contains the same pointers as the previous one
-	cloneElements(beamline);
+        elements = beamline.elements;
         matrices = beamline.matrices;
-        beam_mat = beamline.beam_mat;
+        beam_mat = new TMatrix(*(beamline.beam_mat));
 	beam_length = beamline.beam_length;
 	return *this;
-}
-
-H_AbstractBeamLine* H_AbstractBeamLine::clone() const {
-	H_AbstractBeamLine* temp_beam = new H_AbstractBeamLine(beam_length);
-	vector<H_OpticalElement*>::const_iterator element_i;
-	for (element_i = elements.begin(); element_i<elements.end(); element_i++) {
-		if((*element_i)->getType()!=DRIFT) {
-			H_OpticalElement* temp_el = (*element_i)->clone();
-			temp_beam->add(temp_el);
-		}
-	}
-	temp_beam->beam_mat = beam_mat;
-	temp_beam->matrices = matrices;
-	return temp_beam;
 }
 
@@ -91,12 +68,5 @@
 	elements.clear(); 
 	matrices.clear(); 
-}
-
-void H_AbstractBeamLine::cloneElements(const H_AbstractBeamLine& beam) {
-	vector<H_OpticalElement*>::const_iterator element_i;
-        for (element_i = beam.elements.begin(); element_i< beam.elements.end(); element_i++) {
-        	H_OpticalElement* temp_el = (*element_i)->clone();
-                elements.push_back(temp_el);
-        }
+	delete beam_mat;
 }
 
@@ -110,16 +80,30 @@
 	if (a > beam_length)	{
 		beam_length = a;
-		if(VERBOSE) cout<<"<H_AbstractBeamLine> WARNING : element ("<< newElement->getName()<<") too far away. The beam length has been extended to "<< beam_length << ". "<<endl;
+		if(VERBOSE) cout<<"WARNING : element ("<< newElement->getName()<<") too far away. The beam length has been extended to "<< beam_length << ". "<<endl;
 	}
 	calcSequence();
 	calcMatrix();
-	return;
-}
-
-const TMatrix H_AbstractBeamLine::getBeamMatrix() const {
-	return beam_mat;
-}
-
-const TMatrix H_AbstractBeamLine::getBeamMatrix(const float eloss,const float p_mass, const float p_charge) {
+}
+
+void H_AbstractBeamLine::add(H_OpticalElement & newElement) {
+	/// @param newElement is added to the beamline
+//	H_OpticalElement * el = new H_OpticalElement(newElement);
+//	elements.push_back(el);
+	elements.push_back(&newElement);
+ 	float a = newElement.getS()+newElement.getLength();
+	if (a > beam_length)	{
+		beam_length = a;
+		if(VERBOSE) cout<<"WARNING : element ("<< newElement.getName()<<") too far away. The beam length has been extended to "<< beam_length << ". "<<endl;
+	}
+	calcSequence();
+	calcMatrix();
+}
+
+const TMatrix * H_AbstractBeamLine::getBeamMatrix() const {
+	TMatrix * mat = new TMatrix(*beam_mat);
+	return mat;
+}
+
+const TMatrix * H_AbstractBeamLine::getBeamMatrix(const float eloss,const float p_mass, const float p_charge) {
 
 	vector<H_OpticalElement*>::iterator element_i;
@@ -134,8 +118,9 @@
 		calc_mat *= (*element_i)->getMatrix(eloss,p_mass,p_charge);
 	}
-	return calc_mat;
-}
-
-const TMatrix H_AbstractBeamLine::getPartialMatrix(const string& elname, const float eloss, const float p_mass, const float p_charge) {
+	const TMatrix* bmat = new TMatrix(calc_mat);
+	return bmat;
+}
+
+const TMatrix * H_AbstractBeamLine::getPartialMatrix(const string elname, const float eloss, const float p_mass, const float p_charge) {
 
 	vector<H_OpticalElement*>::iterator element_i;
@@ -147,18 +132,20 @@
 		calc_mat *= (*element_i)->getMatrix(eloss,p_mass,p_charge);
 		if(elname==(*element_i)->getName()) {
-			return calc_mat;
-		}
-	}
-	cout<<"<H_AbstractBeamLine> Element "<<elname<<" desn't exist. Returning full beam matrix"<<endl;
-	return calc_mat;
-}
-
-const TMatrix H_AbstractBeamLine::getPartialMatrix(const unsigned int element_position) const {
+			const TMatrix* bmat = new TMatrix(calc_mat);
+			return bmat;
+		}
+	}
+	cout<<"Element "<<elname<<" desn't exist. Returning full beam matrix"<<endl;
+	const TMatrix* bmat = new TMatrix(calc_mat);
+	return bmat;
+}
+
+const TMatrix * H_AbstractBeamLine::getPartialMatrix(const unsigned int element_position) const {
  	//const int N = (element_position<0)?0:(( (element_position)>elements.size()-1)?elements.size()-1:element_position);
 	const int N = (element_position>elements.size()-1)?elements.size()-1:element_position;
-	return *(matrices.begin()+N); // //for optimization of the code :same as return &matrices[N];
-}
-
-const TMatrix H_AbstractBeamLine::getPartialMatrix(const H_OpticalElement * element) const{
+	return &(*(matrices.begin()+N)); // //for optimization of the code :same as return &matrices[N];
+}
+
+const TMatrix * H_AbstractBeamLine::getPartialMatrix(const H_OpticalElement * element) const{
 	// returns the transport matrix to transport until the end of the specified element
 	// !!! 2 elements should never have the same name in "elements" !!!
@@ -166,5 +153,5 @@
 	vector<H_OpticalElement*>::const_iterator element_i;
 	vector<TMatrix>::const_iterator matrix_i;
-	TMatrix calc_mat(MDIM,MDIM);
+	TMatrix * calc_mat = new TMatrix(MDIM,MDIM);
 
 	// parses the list of optical elements and find the searched one
@@ -172,8 +159,8 @@
 		if(element->getName() == (*element_i)->getName()) {
 			// element has been found
-			calc_mat = *matrix_i;
+			calc_mat = const_cast<TMatrix*>( &(*matrix_i));
         	}
 	}
-	return calc_mat;
+	return (const TMatrix*) calc_mat;
 }
 
@@ -183,5 +170,5 @@
 }
 
-H_OpticalElement * H_AbstractBeamLine::getElement(const unsigned int element_position) const {
+const H_OpticalElement * H_AbstractBeamLine::getElement(const unsigned int element_position) const {
 	const unsigned int N = (element_position>elements.size())?elements.size():element_position;
         return *(elements.begin()+N);//for optimization of the code :same as return &elements[N];
@@ -189,32 +176,30 @@
 
 
-H_OpticalElement * H_AbstractBeamLine::getElement(const string& el_name) {
+H_OpticalElement * H_AbstractBeamLine::getElement(const string el_name) {
 	for(unsigned int i=0; i < elements.size(); i++) {
 		if( (*(elements.begin()+i))->getName() == el_name ) 
 			return *(elements.begin()+i);
 	} // if found -> return ; else : not found at all !	
-	cout<<"<H_AbstractBeamLine> Element "<<el_name<<" not found"<<endl;
+	cout<<"Element "<<el_name<<" not found"<<endl;
 	return *(elements.begin()+1);
 }
 
-H_OpticalElement * H_AbstractBeamLine::getElement(const string& el_name) const {
+const H_OpticalElement * H_AbstractBeamLine::getElement(const string el_name) const {
         for(unsigned int i=0; i < elements.size(); i++) {
 		if( (*(elements.begin()+i))->getName() == el_name)
 			return *(elements.begin()+i);
 	} // if found -> return ; else : not found at all !
-	cout<<"<H_AbstractBeamLine> Element "<<el_name<<" not found"<<endl;
+	cout<<"Element "<<el_name<<" not found"<<endl;
 	return *(elements.begin()+1);
 }
 
-std::ostream& operator<< (std::ostream& os, const H_AbstractBeamLine& be) {
-        vector<H_OpticalElement*>::const_iterator element_i;
-        os << "Beamline content" << endl;
-        for (element_i = be.elements.begin(); element_i < be.elements.end(); element_i++) {
-                os << (int)(element_i - be.elements.begin()) << "\t" << (*element_i)->getName() << "\t" << (*element_i)->getS() << endl;
-        }
-  return os;
-}
-
-void H_AbstractBeamLine::printProperties() const { cout << *this; return; }
+void H_AbstractBeamLine::printProperties() const {
+	vector<H_OpticalElement*>::const_iterator element_i;
+	cout << "Pointeurs des elements du faisceau" << endl;
+	for (element_i = elements.begin(); element_i < elements.end(); element_i++) {
+		cout << (int)(element_i-elements.begin()) << "\t" << (*element_i)->getName() << "\t" << (*element_i)->getS() << endl;	
+	}
+	return;
+}
 
 void H_AbstractBeamLine::showElements() const{
@@ -254,5 +239,5 @@
 		temp = *matrix_i;
 		cout << "Matrix for transport until s=" << (*element_i)->getS() + (*element_i)->getLength() << "m (" << (*element_i)->getName() << "). " << endl;
-		printMatrix(temp);
+		printMatrix(&temp);
 		cout << endl;
 	}
@@ -271,5 +256,5 @@
 	// getting rid of drifts before calculating
 	for(element_i = elements.begin(); element_i < elements.end(); element_i++) {
-		if((*element_i)->getType() == DRIFT) {delete (*element_i); elements.erase(element_i); }
+		if((*element_i)->getType() == DRIFT) {elements.erase(element_i); }
 	}
 
@@ -296,8 +281,5 @@
 			temp_elements.push_back(dr);
 	}
-	
-	// cleaning : avoid some memory leaks
 	elements.clear();
-
 	for(element_i=temp_elements.begin(); element_i < temp_elements.end(); element_i++) {
 		elements.push_back(*element_i);
@@ -321,6 +303,5 @@
   	}
 
-	beam_mat.ResizeTo(MDIM,MDIM);
-	beam_mat = calc_mat;
+	*beam_mat = calc_mat;
 	return;
 }
@@ -338,9 +319,8 @@
 }
 
-void H_AbstractBeamLine::draw(const float xmin, const float ymin, const float xmax, const float ymax) const{
-	gROOT->SetStyle("Plain");
-	TLegend* leg = new TLegend(xmin,ymin,xmax,ymax,""); 
+void H_AbstractBeamLine::draw() const{
+/*	gROOT->SetStyle("Plain");
+	TLegend* leg = new TLegend(0.85,0.50,1,1,"Legend");
 	leg->SetBorderSize(1);
-	leg->SetFillColor(kWhite);
 	TBox* b1 = new TBox();
 	TBox* b2 = new TBox(0,0,10,10);
@@ -365,4 +345,5 @@
 	leg->AddEntry(b7,"RCollimator");
 	leg->Draw();
+*/ 
 /*	TLine* l1 = new TLine(0.05,0.5,0.95,0.5);
 	TLine* l2 = new TLine(0.1,0.1,0.1,0.9);
@@ -413,8 +394,7 @@
 }
 
-void H_AbstractBeamLine::drawX(const float a_min, const float a_max, const float scale) const{
+void H_AbstractBeamLine::drawX(const float a_min, const float a_max) const{
 	/// @param a_min defines the size of the drawing
 	/// @param a_max defines the size of the drawing
-	/// @param scale allows to multiply the drawing, i.e. changing the units
 	const int N = getNumberOfElements();
 	for(int i=0;i<N;i++) {
@@ -422,5 +402,5 @@
         	float meight = fabs(a_min);
         	float size = (height>meight)?meight:height;
-		float middle = getElement(i)->getX()*URAD*scale;
+		float middle = getElement(i)->getX()*URAD;
         	if(getElement(i)->getType()!=DRIFT) getElement(i)->draw(middle+size/2.,middle-size/2.);
     	}
@@ -440,5 +420,5 @@
 }
 
-void H_AbstractBeamLine::moveElement(const string& name, const float new_s) {
+void H_AbstractBeamLine::moveElement(const string name, const float new_s) {
 	/// @param name identifies the element to move
 	/// @param new_s is where to put it
@@ -453,5 +433,5 @@
 }
 
-void H_AbstractBeamLine::alignElement(const string& name, const float disp_x, const float disp_y) {
+void H_AbstractBeamLine::alignElement(const string name, const float disp_x, const float disp_y) {
 	/// @param name identifies the element to move
 	/// @param disp_x identifies the displacement to add in x [\f$ \mu m \f$]
@@ -465,9 +445,10 @@
 			}
 		}
-		cout<<"<H_AbstractBeamLine> WARNING : Element "<<name<<" not found."<<endl; 
+		cout<<"Element "<<name<<" not found."<<endl; 
+		if(VERBOSE) cout<<"Element "<<name<<" not found."<<endl;
 		return;
 }
 
-void H_AbstractBeamLine::tiltElement(const string& name, const float ang_x, const float ang_y) {
+void H_AbstractBeamLine::tiltElement(const string name, const float ang_x, const float ang_y) {
 	/// @param name identifies the element to move
 	/// @param ang_x identifies the angle to add in x
@@ -481,5 +462,5 @@
 			}
 		}
-		cout<<"<H_AbstractBeamLine> WARNING : Element "<<name<<" not found."<<endl; 
+		if(VERBOSE) cout<<"Element "<<name<<" not found."<<endl;
 		return;
 }
@@ -500,4 +481,5 @@
 }
 
+/*
 TGraph * H_AbstractBeamLine::getBetaX() const{
         const int N = elements.size();
@@ -648,3 +630,3 @@
         return rely;
 }
-
+*/
Index: external/Hector/H_AbstractBeamLine.h
===================================================================
--- external/Hector/H_AbstractBeamLine.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_AbstractBeamLine.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,27 +2,19 @@
 #define _H_AbstractBeamLine_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_AbstractBeamLine.h
 /// \brief Class aiming at simulating the LHC beamline.
 ///
-/// Units : angles [urad], distances [um], energies [GeV], c=[1].
+/// Units : angles [µrad], distances [µm], energies [GeV], c=[1].
 
 	/// default length of the beam line
@@ -37,5 +29,5 @@
 // ROOT #includes
 #include "TMatrix.h"
-#include "TGraph.h"
+////#include "TGraph.h"
 
 // local #includes
@@ -47,4 +39,5 @@
 
 	public:
+		void init(const float );
 		///     Constructors, destructor and operator
 		//@{
@@ -53,32 +46,34 @@
 		H_AbstractBeamLine(const H_AbstractBeamLine &);
 		H_AbstractBeamLine& operator=(const H_AbstractBeamLine&);
-		H_AbstractBeamLine* clone() const ;
 		~H_AbstractBeamLine();
 		//@}
 		///     Adds an element to the beamline
+		//@{
 		void add(H_OpticalElement *);
+		void add(H_OpticalElement &);
+		//@}
 		///     Returns the (float) length of the beamline
-  		const float getLength() const { return beam_length;};
+  		inline float getLength() const { return beam_length;};
 		///     Returns the (int) number of optics element of the beamline, including drifts
-  		const unsigned int getNumberOfElements() const { return elements.size();}; 
+  		inline int getNumberOfElements() const { return (int)elements.size();}; 
 		///     Returns the transport matrix for the whole beam
-		const TMatrix getBeamMatrix() const;
+		const TMatrix * getBeamMatrix() const;
 		///     Returns the transport matrix for the whole beam, for given energy loss/mass/charge
-		const TMatrix getBeamMatrix(const float , const float, const float ) ;
+		const TMatrix * getBeamMatrix(const float , const float, const float ) ;
 		///     Returns the transport matrix for a part of the beam from the IP to a given element
-		const TMatrix getPartialMatrix(const H_OpticalElement *) const;
+		const TMatrix * getPartialMatrix(const H_OpticalElement *) const;
 		///     Returns the transport matrix for a part of the beam from the IP to the ith element
-		const TMatrix getPartialMatrix(const unsigned int ) const;
+		const TMatrix * getPartialMatrix(const unsigned int ) const;
 		///     Returns the transport matrix for a part of the beam from the IP to a given element, given energy loss/mass/charge
-		const TMatrix getPartialMatrix(const string&, const float, const float, const float);
+		const TMatrix * getPartialMatrix(const string, const float, const float, const float);
 		///     Returns the ith element of the beamline
 		//@{
 		H_OpticalElement * getElement(const unsigned int );
-		H_OpticalElement * getElement(const unsigned int ) const;
+                const H_OpticalElement * getElement(const unsigned int ) const;
 		//@}
 		///	Returns a given element of the beamline, choosen by name 
 		//@{
-		H_OpticalElement * getElement(const string& );
-		H_OpticalElement * getElement(const string& ) const;
+		H_OpticalElement * getElement(const string );
+                const H_OpticalElement * getElement(const string ) const;
 		//@}
 		///	Print some info
@@ -96,52 +91,48 @@
 		/// 	Computes global transport matrix
 		void calcMatrix();
-		/// 	Draws the legend of the elements of the beam
-		void draw(const float xmin =0.85, const float ymin=0.5, const float xmax=1, const float ymax=1) const;
+		/// 	Draws the elements of the beam
+		void draw() const;
 		/// 	Draws the elements of the beam in the (x,s) plane
-		void drawX(const float, const float, const float scale=1) const;
+		void drawX(const float, const float) const;
 		/// 	Draws the elements of the beam in the (y,s) plane
 		void drawY(const float, const float) const;
 		///	Moves an element in the list, reorders the lists and recomputes the transport matrix
-		void moveElement(const string&, const float ); 
+		void moveElement(const string, const float ); 
 		/// Moves the given element tranversely by given amounts.
-		void alignElement(const string&, const float, const float);
+		void alignElement(const string, const float, const float);
 		/// Tilts the given element tranversely by given angles.
-		void tiltElement(const string&, const float, const float);
+		void tiltElement(const string, const float, const float);
 		///	Offsets all element in X pos from the start position
 		void offsetElements(const float start, const float offset);
 		///	Draws the beta functions, from MAD
 		//@{
-		TGraph * getBetaX() const;
-		TGraph * getBetaY() const;
+		////TGraph * getBetaX() const;
+		////TGraph * getBetaY() const;
 		//@}
                 ///     Draws the dispersion functions, from MAD
                 //@{
-                TGraph * getDX() const;
-                TGraph * getDY() const;
+                ////TGraph * getDX() const;
+                ////TGraph * getDY() const;
                 //@}
                 ///     Draws the relative position functions, from MAD
                 //@{
-                TGraph * getRelX() const;
-                TGraph * getRelY() const;
+                ////TGraph * getRelX() const;
+                ////TGraph * getRelY() const;
                 //@}
 
 
 	private:
+	        /// list of all optics elements, including drifts
+		vector<H_OpticalElement*> elements; 
         	/// list of matrices, 1 matrix = the transport till the end of each element
 		vector<TMatrix> matrices; 
 	        /// transport matrix for the whole beam
-		TMatrix beam_mat;
-                /// list of all optics elements, including drifts
-                vector<H_OpticalElement*> elements;
+		TMatrix * beam_mat;		    	
 		/// Orderting method for the vector of H_OpticalElement*
-		struct ordering{ bool operator()(const H_OpticalElement* el1, const H_OpticalElement* el2) const {return (*el1 < *el2);}};
-		// private method for copying the contents of "elements"
-		void cloneElements(const H_AbstractBeamLine&);
+		struct ordering{ bool operator()(H_OpticalElement* el1, H_OpticalElement* el2) const { return (*el1 < *el2);}};
 
 	protected:
-		void init(const float );
 		/// total length of the beamline
 		float beam_length;
-	friend std::ostream& operator<< (std::ostream& os, const H_AbstractBeamLine& be);
 };
 
Index: external/Hector/H_Aperture.cc
===================================================================
--- external/Hector/H_Aperture.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Aperture.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Aperture.cc
@@ -27,22 +20,44 @@
 using namespace std;
 
-H_Aperture::H_Aperture() :
-        type_(NONE), x1(0), x2(0), x3(0), x4(0), fx(0), fy(0),  aptypestring(getApertureString()) {
+H_Aperture::H_Aperture() {
+        type = NONE;
+        setApertureString();
+        x1 = 0;
+        x2 = 0;
+        x3 = 0;
+        x4 = 0;
+        fx = 0;
+        fy = 0;
 }
 
-H_Aperture::H_Aperture(const int dtype, const float size1, const float size2, const float size3, const float size4, const float posx, const float posy) :
-        type_(dtype), x1(size1), x2(size2), x3(size3), x4(size4), fx(posx), fy(posy), aptypestring(getApertureString()) {
+H_Aperture::H_Aperture(const int dtype, const float size1, const float size2, const float size3, const float size4, const float posx, const float posy) {
     /// @param dtype defines the aperture shape
         /// @param size1, size2, size3, size4 are the geometrical sizes (length/width or great/small radii) in m
 	/// @param posx, posy are the (x,y) coordinates of the center of the aperture [m]
+        type = dtype;
+        setApertureString();
+        x1 = size1;
+        x2 = size2;
+	x3 = size3;
+	x4 = size4;
+        fx = posx;
+        fy = posy;
 }
 
-H_Aperture::H_Aperture(const H_Aperture& ap) :
-        type_(ap.type_), x1(ap.x1), x2(ap.x2), x3(ap.x3), x4(ap.x4), fx(ap.fx), fy(ap.fy), aptypestring(ap.aptypestring) {
+H_Aperture::H_Aperture(const H_Aperture& ap) {
+        type = ap.type;
+	aptypestring = ap.aptypestring;
+        x1 = ap.x1;
+        x2 = ap.x2;
+        x3 = ap.x3;
+        x4 = ap.x4;
+        fx = ap.fx;
+        fy = ap.fy;
 }
 
 H_Aperture& H_Aperture::operator=(const H_Aperture& ap) {
 	if(this==&ap) return *this;
-	type_ = ap.type_;
+	type = ap.type;
+	aptypestring = ap.aptypestring;
 	x1 = ap.x1;
 	x2 = ap.x2;
@@ -51,16 +66,10 @@
 	fx = ap.fx;
 	fy = ap.fy;
-	aptypestring = ap.aptypestring;
 	return *this;
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Aperture& ap) {
-	os << "Aperture shape:" << ap.aptypestring << ", parameters "<<ap.x1<<", "<<ap.x2<<", "<<ap.x3<<", "<<ap.x4<<endl;
-	os << " \t Center : " << ap.fx << "," << ap.fy << endl;
-	return os;
-}
-
 void H_Aperture::printProperties() const {
-	cout << *this;
+        cout << "Aperture shape:" << getTypeString() << ", parameters"<<x1<<", "<<x2<<", "<<x3<<", "<<x4<<endl;
+        cout << " \t Center : " << fx << "," << fy << endl;
         return;
 }
@@ -74,13 +83,13 @@
 }
 
-bool H_Aperture::isInside(const float , const float ) const {
+bool H_Aperture::isInside(const float x, const float y) const {
         /// @param x, y are the (x,y) coordinates of the proton, in [m]
-        //cout << "aperture::isInside" << endl;
+        cout << "aperture::isInside" << endl;
         return false;
 }
 
 
-/*void H_Aperture::setApertureString() {
-	switch (type_) {
+void H_Aperture::setApertureString() {
+	switch (type) {
 		case NONE: aptypestring = NONENAME; break;
  		case RECTANGULAR: aptypestring = RECTANGULARNAME; break;
@@ -91,17 +100,2 @@
 	}
 }
-*/
-
-const string H_Aperture::getApertureString() const {
-	string str;
-        switch (type_) {
-                case NONE: str = NONENAME; break;
-                case RECTANGULAR: str = RECTANGULARNAME; break;
-                case ELLIPTIC: str = ELLIPTICNAME; break;
-                case CIRCULAR: str = CIRCULARNAME; break;
-                case RECTELLIPSE: str = RECTELLIPSENAME; break;
-                default: str = NONENAME; break;
-        }
-	return str;
-}
-
Index: external/Hector/H_Aperture.h
===================================================================
--- external/Hector/H_Aperture.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Aperture.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_Aperture_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Aperture.h
@@ -25,9 +18,12 @@
 // C++ #defines
 #include <string>
-#include <iostream>
 using namespace std;
 
 // local #defines
-enum {NONE=0, RECTANGULAR, ELLIPTIC, CIRCULAR, RECTELLIPSE};
+#define NONE        0
+#define RECTANGULAR 1
+#define ELLIPTIC    2
+#define CIRCULAR    3
+#define RECTELLIPSE 4
 #define NONENAME        "None       "
 #define RECTANGULARNAME "Rectangle  "
@@ -46,13 +42,11 @@
 		H_Aperture(const H_Aperture&);
 		H_Aperture& operator=(const H_Aperture&);
-		virtual ~H_Aperture() { };
-		virtual H_Aperture* clone() const { return new H_Aperture(type_,x1,x2,x3,x4,fx,fy); };
+		virtual ~H_Aperture() {return;};
 		//@}
 
 		/// Prints the aperture features
-		//virtual void printProperties() const;
-		void printProperties() const;
+		virtual void printProperties() const;
 		/// Draws the aperture shape
-		virtual void draw(const float) const {return;};
+		virtual void draw() const {return;};
 		/// Sets the (x,y) position in [m]
 		void setPosition(const float,const float);
@@ -60,5 +54,5 @@
 		virtual bool isInside(const float, const float) const; 
 		/// Returns the (int) type of aperture
-		inline int getType() const {return type_;};
+		inline int getType() const {return type;};
 		/// Returns the (string) type of the aperture
 		inline const string getTypeString() const { return aptypestring; }
@@ -67,23 +61,20 @@
 	protected:
 		/// Aperture shape (either RECTANGULAR or ELLIPTIC or ...)
-		int type_;
+		int type;
+		/// Aperture shape string
+		string aptypestring;
+
 		/// Aperture geometrical sizes (length/width or great/small radii) [m]
 		//@{
 		float x1, x2, x3, x4; 
 		//@}
+
 		/// Horizontal coordinate of the aperture center [m] (from the nominal beam position).
 		//@{
 		float fx, fy;
 		//@}
-                /// Aperture shape string
-                string aptypestring;
-		// Sets the name of the aperture from its type.
-		//void setApertureString();
-		/// Gets the name of the aperture from its type.
-		const string getApertureString() const;
-
-	friend std::ostream& operator<< (std::ostream& os, const H_Aperture& ap);
+		/// Sets the name of the aperture from its type.
+		void setApertureString();
 };
 
-
 #endif
Index: external/Hector/H_Beam.cc
===================================================================
--- external/Hector/H_Beam.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Beam.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Beam.cc
@@ -22,5 +15,5 @@
 
 // ROOT #includes
-#include "TGraph.h"
+//#include "TGraph.h"
 #include "TRandom.h"
 
@@ -62,5 +55,9 @@
 };
 
-void H_Beam::createBeamParticles(const unsigned int Number_of_particles, const double p_mass, const double p_charge, TRandom* r) {
+void H_Beam::createBeamParticles(const unsigned int Number_of_particles) {
+	createBeamParticles(Number_of_particles,MP,QP);
+}
+
+void H_Beam::createBeamParticles(const unsigned int Number_of_particles, const double p_mass, const double p_charge) {
 	beamParticles.clear();
 	Nparticles = (Number_of_particles<1) ? 1 : Number_of_particles;
@@ -69,42 +66,12 @@
 		p.setPosition(fx_ini,fy_ini,tx_ini,ty_ini,fs_ini);
 		p.setE(fe_ini);
-		p.smearPos(x_disp,y_disp,r);
-		p.smearAng(tx_disp,ty_disp,r);
-		p.smearE(e_disp,r);
-		p.smearS(s_disp,r);
+		p.smearPos(x_disp,y_disp);
+		p.smearAng(tx_disp,ty_disp);
+		p.smearE(e_disp);
+		p.smearS(s_disp);
 		if (VERBOSE) {if (i==0) cout << " x_ini , tx_ini " << p.getX() << " " << p.getTX() << endl;}
 		beamParticles.push_back(p);
 	}
 }
-
-//void H_Beam::particleGun(const unsigned int Number_of_particles, const float E_min=BE, const float E_max=BE, const float fs_min=0, const float fs_max=0, const float fx_min=0, const float fx_max=0, const float fy_min=0, const float fy_max=0, const float tx_min=-PI/2., const float tx_max=PI/2., const float ty_min=-PI/2., const float ty_max=PI/2., const float p_mass=MP, const double p_charge=QP) {
-void H_Beam::particleGun(const unsigned int Number_of_particles, const float E_min, const float E_max, const float fs_min, const float fs_max, const float fx_min, const float fx_max, const float fy_min, const float fy_max, const float tx_min, const float tx_max, const float ty_min, const float ty_max, const float p_mass, const double p_charge, const bool flat, TRandom* r) {
-        beamParticles.clear();
-        Nparticles = (Number_of_particles<2) ? 2 : Number_of_particles;
-        float gx,gy,gs,gtx,gty,gE;
-        for (unsigned int i=0; i<Nparticles; i++) {
-                H_BeamParticle p(p_mass,p_charge);
-                if (flat) {
-                        gx = r->Uniform(fx_min,fx_max);
-                        gy = r->Uniform(fy_min,fy_max);
-                        gs = r->Uniform(fs_min,fs_max);
-                        gtx = r->Uniform(tx_min,tx_max);
-                        gty = r->Uniform(ty_min,ty_max);
-                        gE = r->Uniform(E_min,E_max);
-                } else {
-                        gx = r->Gaus((fx_min+fx_max)/2,(-fx_min+fx_max)/2);
-                        gy = r->Gaus((fy_min+fy_max)/2,(-fy_min+fy_max)/2);
-                        gs = r->Gaus((fs_min+fs_max)/2,(-fs_min+fs_max)/2);
-                        gtx = r->Gaus((tx_min+tx_max)/2,(-tx_min+tx_max)/2);
-                        gty = r->Gaus((ty_min+ty_max)/2,(-ty_min+ty_max)/2);
-                        gE = r->Gaus ((E_min+E_max)/2,(-E_min+E_max)/2);
-                }
-                p.setPosition(gx,gy,gtx,gty,gs);
-                p.setE(gE);
-                beamParticles.push_back(p);
-        }
-        return;
-}
-
 
 void H_Beam::createXScanningBeamParticles(const unsigned int Number_of_particles, const float fx_max) {
@@ -182,4 +149,8 @@
 }
 
+void H_Beam::computePath(const H_AbstractBeamLine * beamline) {
+	computePath(beamline,false);
+}
+
 /// Propagates the beam until a given s
 void H_Beam::propagate(const float position) {
@@ -188,4 +159,10 @@
                 particle_i->propagate(position);
         }
+}
+
+void H_Beam::emitGamma(const double gee, const double gq2) {
+	/// @param gee = \f$ E_{\gamma} \f$ is the photon energy
+	/// @param gq2 = \f$ Q^2 < 0 \f$ is virtuality of photon \f$ Q^{2} = E^{2}-\vec{k}^{2} \f$
+	emitGamma(gee,gq2,0,2*PI);
 }
 
@@ -237,5 +214,5 @@
 	return EY2;
 }
-
+/*
 TGraphErrors * H_Beam::getBetaX(const float length, const unsigned int number_of_points) {
 	/// @param length [m]
@@ -277,4 +254,5 @@
 	return betay;
 }
+*/
 
 float H_Beam::getX(const float s, float& error_on_posx) {
@@ -313,7 +291,5 @@
 }
 
-vector<TVectorD> H_Beam::getStoppingElements(const H_AbstractBeamLine * beamline, vector<H_OpticalElement>& list, vector<int>& numb) {
-
-		vector<TVectorD> stop_positions;
+void H_Beam::getStoppingElements(const H_AbstractBeamLine * beamline, vector<H_OpticalElement>& list, vector<int>& numb) {
         vector<H_BeamParticle>::iterator particle_i;
         vector<H_OpticalElement>::iterator element_i;
@@ -331,10 +307,8 @@
                 if(particle_i->stopped(beamline)) {
                         temp_el = *(particle_i->getStoppingElement());
-						stop_positions.push_back(*(particle_i->getStopPosition()));
                         if(list.size()==0) {
                                 number=1;
                                 list.push_back(temp_el);
                                 numb.push_back(number);
-
                         } else {
                                 for (element_i = list.begin(), n_i = numb.begin(); element_i < list.end(); element_i++, n_i++) {
@@ -356,5 +330,4 @@
                 } // if particle_i->stopped
         }// for particle_i
-		return stop_positions;
 } // H_Beam::getStoppingElements
 
@@ -379,11 +352,10 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Beam& be) {
+void H_Beam::printProperties() const {
 	vector<H_BeamParticle>::const_iterator particle_i;
-	cout << "There are " << be.Nparticles << " in the beam." << endl;
-	for (particle_i = be.beamParticles.begin(); particle_i < be.beamParticles.end(); particle_i++) {
-		cout << *particle_i;
-	}
-   return os;
+	cout << "There are " << Nparticles << " in the beam." << endl;
+	for (particle_i = beamParticles.begin();particle_i < beamParticles.end(); particle_i++) {
+		particle_i->printProperties();
+	}
 }
 
@@ -400,53 +372,5 @@
 	}
 } // H_Beam::printStoppingElements
-
-TH2F *  H_Beam::drawAngleProfile(const float s) {
-        /// not a const method because does a propagate to s!
-        char title[50];
-        sprintf(title,"Beam profile at %.2f m",s);
-        vector<H_BeamParticle>::iterator particle_i;
-        float xmax, xmin, ymax, ymin;
-        float xx, yy, xborder, yborder;
-
-        particle_i=beamParticles.begin();
-        xmin = particle_i->getTX();
-        xmax = particle_i->getTX();
-        ymin = particle_i->getTY();
-        ymax = particle_i->getTY();
-
-        for (particle_i = beamParticles.begin(); particle_i < beamParticles.end(); particle_i++) {
-                particle_i->propagate(s);
-                xx = particle_i->getTX();
-                yy = particle_i->getTY();
-
-                xmax = xx>xmax ? xx : xmax;
-                ymax = yy>ymax ? yy : ymax;
-                xmin = xx<xmin ? xx : xmin;
-                ymin = yy<ymin ? yy : ymin;
-        }
-
-        // in order to avoid some drawing problems, when the beam divergence is null
-        if(!(xmax || xmin)) xmax +=0.1;
-        if(!(ymax || ymin)) xmax +=0.1;
-
-        if(xmax == xmin) xmax *= 1.1;
-        if(ymax == ymin) ymax *= 1.1;
-
-        xborder = (xmax-xmin)*0.2;
-        yborder = (ymax-ymin)*0.2;
-
-        xmax += xborder;
-        xmin -= xborder;
-        ymax += yborder;
-        ymin -= yborder;
-
-        TH2F * profile = new TH2F("profile",title,10000,xmin,xmax,1000,ymin,ymax);
-        for (particle_i = beamParticles.begin(); particle_i < beamParticles.end(); particle_i++) {
-                profile->Fill(particle_i->getTX(), particle_i->getTY());
-        }
-        return profile;
-}
-
-
+/*
 TH2F *  H_Beam::drawProfile(const float s) {
 	/// not a const method because does a propagate to s!
@@ -475,7 +399,4 @@
 
 	// in order to avoid some drawing problems, when the beam divergence is null
-        if(!(xmax || xmin)) xmax +=0.1;
-        if(!(ymax || ymin)) xmax +=0.1;
-
 	if(xmax == xmin) xmax += 0.1;
 	if(ymax == ymin) ymax += 0.1;
@@ -494,6 +415,6 @@
 	}
 	return profile;
-}
-
+}*/
+/*
 TMultiGraph * H_Beam::drawBeamX(const int color) const {
 	int mycolor = color;
@@ -519,2 +440,3 @@
         return beam_profile_y;
 }
+*/
Index: external/Hector/H_Beam.h
===================================================================
--- external/Hector/H_Beam.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Beam.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_Beam_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Beam.h
@@ -31,8 +24,7 @@
 
 // ROOT #includes
-#include "TH2F.h"
-#include "TGraphErrors.h"
-#include "TMultiGraph.h"
-#include "TMath.h"
+////#include "TH2F.h"
+////#include "TGraphErrors.h"
+////#include "TMultiGraph.h"
 
 // local #includes
@@ -63,9 +55,9 @@
 		~H_Beam();
 	//@}
-        /// Fills the beam with particles in given position/angle/energy        intervals (flat distribution)
-                void particleGun(const unsigned int Number_of_particles, const float E_min=BE, const float E_max=BE, const float fs_min=0, const float fs_max=0, const float fx_min=0, const float fx_max=0, const float fy_min=0, const float fy_max=0, const float tx_min=-TMath::Pi()/2., const float tx_max=TMath::Pi()/2., const float ty_min=-TMath::Pi()/2., const float ty_max=TMath::Pi()/2., const float p_mass=MP, const double p_charge=QP, const bool flat = true, TRandom* r=gRandom);
-
 	/// Fills the beam with particles
-		void createBeamParticles(const unsigned int Number_of_particles, const double p_mass=MP, const double p_charge=QP, TRandom* r=gRandom);
+	//@{
+		void createBeamParticles(const unsigned int , const double , const double );
+		void createBeamParticles(const unsigned int);
+	//@}
 	/// Fills the beam with particles with incremental offset and no initial transverse momentum
 	//@{
@@ -86,7 +78,13 @@
 		void add(const H_BeamParticle&);
 	/// Compute the position of each particle in the beamline
-		void computePath(const H_AbstractBeamLine * beamline, const bool NonLinear=false);
+	//@{	
+		void computePath(const H_AbstractBeamLine *, const bool);
+		void computePath(const H_AbstractBeamLine *);
+	//@}
 	// Photon emission by the particle
-                void emitGamma(const double gee, const double gq2, const double phimin=0, const double phimax=2*TMath::Pi());
+	// @{
+                void emitGamma(const double, const double, const double, const double);
+		void emitGamma(const double, const double);
+	//@}
 	// Propagates the beam until a given s
 		void propagate(const float );
@@ -98,6 +96,6 @@
 	/// Draws the \f$ \beta \f$ function of the beam
 	//@{
-		TGraphErrors  * getBetaX(const float, const unsigned int);
-		TGraphErrors  * getBetaY(const float, const unsigned int);
+        ////	TGraphErrors  * getBetaX(const float, const unsigned int);
+	////	TGraphErrors  * getBetaY(const float, const unsigned int);
 	//@}
         /// Returns the position of the beam
@@ -108,6 +106,6 @@
 	/// Returns the emittance \f$ \epsilon \f$ of the beam in x and y
 	//@{
-	inline const float getEmittanceX() const {
-			if(!x_disp*tx_disp) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl; 	
+		inline const float getEmittanceX() const {
+		    if(!x_disp*tx_disp) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl; 	
 			return x_disp * tan(tx_disp/URAD)/URAD;
 		}
@@ -140,9 +138,9 @@
 		unsigned int getStoppedNumber(const H_AbstractBeamLine *);
 	/// Returns the list of the stopping elements in the beamline
-		vector<TVectorD> getStoppingElements(const H_AbstractBeamLine *, vector<H_OpticalElement>&, vector<int>&);
+		void getStoppingElements(const H_AbstractBeamLine *, vector<H_OpticalElement>&, vector<int>&);
 	/// Prints the initial parameters
 		void printInitialState() const;
 	/// Prints the properties for each particle
-		void printProperties() const {cout << *this; return;}
+		void printProperties() const;
 	/// Prints the list of the stopping elements in the beamline
 		void printStoppingElements(const vector<H_OpticalElement>&, const vector<int>&) const;
@@ -150,10 +148,9 @@
 		const int getNumberOfBeamParticles() const {return Nparticles;}
 	/// Draws the beam profile at a given s
-		TH2F * drawProfile(const float);
-		TH2F * drawAngleProfile(const float);
+	////	TH2F * drawProfile(const float);
 	/// Draws the beam width and height
 	//@{
-		TMultiGraph * drawBeamX(const int) const;
-		TMultiGraph * drawBeamY(const int) const ;
+	////	TMultiGraph * drawBeamX(const int) const;
+	////	TMultiGraph * drawBeamY(const int) const ;
 	//@}
 
@@ -183,6 +180,4 @@
 	/// Number of particles in this beam
 		unsigned int Nparticles;
-
-	friend std::ostream& operator<< (std::ostream& os, const H_Beam& be);
 };
 
Index: external/Hector/H_BeamLine.cc
===================================================================
--- external/Hector/H_BeamLine.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_BeamLine.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_BeamLine.cc
@@ -24,5 +17,4 @@
 #include <fstream>
 #include <sstream>
-#include <cstdlib>
 
 // local #includes
@@ -47,19 +39,14 @@
 // are opposite to Wille's. See fill() for more details.
 
-H_BeamLine::H_BeamLine(): H_AbstractBeamLine(), 
-	direction(1), ips(0), ipx(0), ipy(0), iptx(0), ipty(0) {
-}
-
-H_BeamLine::H_BeamLine(const int si, const float length) : H_AbstractBeamLine(length),
-	direction((si >= abs(si)) ? 1 : -1), ips(0), ipx(0), ipy(0), iptx(0), ipty(0) {
-}
-
-H_BeamLine::H_BeamLine(const H_BeamLine& beam) : H_AbstractBeamLine(beam),
-	direction(beam.direction), ips(beam.ips), ipx(beam.ipx), ipy(beam.ipy), iptx(beam.iptx), ipty(beam.ipty) {
-}
-
-H_BeamLine& H_BeamLine::operator=(const H_BeamLine& beam) {
-	if(this==&beam) return *this;
-	H_AbstractBeamLine::operator=(beam); // call the mother's operator=
+H_BeamLine::H_BeamLine(const int si, const float length) : H_AbstractBeamLine(length){
+	direction = (si >= abs(si)) ? 1 : -1;
+	ips=0;
+	ipx=0;
+	ipy=0;
+	iptx=0;
+	ipty=0;
+}
+
+H_BeamLine::H_BeamLine(const H_BeamLine& beam) : H_AbstractBeamLine(beam) {
 	direction = beam.direction;
 	ips = beam.ips;
@@ -68,11 +55,26 @@
 	iptx = beam.iptx;
 	ipty = beam.ipty;
+}
+
+H_BeamLine& H_BeamLine::operator=(const H_BeamLine& beam) {
+	if(this==&beam) return *this;
+	direction = beam.direction;
+	ips = beam.ips;
+	ipx = beam.ipx;
+    ipy = beam.ipy;
+    iptx = beam.iptx;
+    ipty = beam.ipty;
 	return *this;
 }
 
-void H_BeamLine::findIP(const string& filename, const string& ipname) {
+void H_BeamLine::findIP(const string filename) {
+	findIP(filename,"IP5");
+	return;
+}
+
+void H_BeamLine::findIP(const string filename, const string ipname) {
 	// searches for the IP position in the extended table.
 	ifstream tabfile(filename.c_str());
-		if (! tabfile.is_open()) cout << "<H_BeamLine> ERROR: I Can't open \"" << filename << "\"" << endl;
+		if (! tabfile.is_open()) cout << "\t ERROR: I Can't open \"" << filename << "\"" << endl;
 	bool found = false;
 	int N_col=0;
@@ -112,5 +114,5 @@
 	} // while (!eof)
 
-	if (!found) cout << "<H_BeamLine> ERROR ! IP not found." << endl;
+	if (!found) cout << "\t ERROR ! IP not found." << endl;
 	tabfile.close();
 }
@@ -125,11 +127,16 @@
 }
 
-
-void H_BeamLine::fill(const string& filename, const int dir, const string& ipname) {
+void H_BeamLine::fill(const string filename) {
+	fill(filename,1,"IP5");
+	return;
+}
+
+
+void H_BeamLine::fill(const string filename, const int dir, const string ipname) {
 	string headers[40];  // table of all column headers
 	int header_type[40]; // table of all column types
 	findIP(filename,ipname);
 	ifstream tabfile(filename.c_str());
-		if (! tabfile.is_open()) cout << "<H_BeamLine> ERROR: I Can't open \"" << filename << "\"" << endl;
+		if (! tabfile.is_open()) cout << "\t ERROR: I Can't open \"" << filename << "\"" << endl;
 	if(VERBOSE) {
 		cout<<"Using file : "<< filename <<" in the "<<((direction>0)?"positive":"negative")<<" direction."<<endl;
@@ -187,47 +194,42 @@
 			}
 
+			ap = 0; //init
+			if(e.aper_1 !=0 || e.aper_2 !=0 || e.aper_3 !=0 || e.aper_4 != 0) {
+				e.aper_1 *= URAD;
+				e.aper_2 *= URAD;
+				e.aper_3 *= URAD;
+				e.aper_4 *= URAD; // in [m] in the tables !
+
+				if(strstr(e.apertype.c_str(),"RECTELLIPSE")) ap = new H_RectEllipticAperture(e.aper_1,e.aper_2,e.aper_3,e.aper_4,0,0);
+				else if(strstr(e.apertype.c_str(),"CIRCLE")) ap = new H_CircularAperture(e.aper_1,0,0);
+				else if(strstr(e.apertype.c_str(),"RECTANGLE")) ap = new H_RectangularAperture(e.aper_1,e.aper_2,0,0);
+				else if(strstr(e.apertype.c_str(),"ELLIPSE")) ap = new H_EllipticAperture(e.aper_1,e.aper_2,0,0);
+			}
+
 			if(el!=0) {
-				ap = 0; //init
-				if(e.aper_1 !=0 || e.aper_2 !=0 || e.aper_3 !=0 || e.aper_4 != 0) {
-					e.aper_1 *= URAD;
-					e.aper_2 *= URAD;
-					e.aper_3 *= URAD;
-					e.aper_4 *= URAD; // in [m] in the tables !
-
-					if(strstr(e.apertype.c_str(),"RECTELLIPSE")) 
-						ap = new H_RectEllipticAperture(e.aper_1,e.aper_2,e.aper_3,e.aper_4,0,0);
-					else if(strstr(e.apertype.c_str(),"CIRCLE")) 
-						ap = new H_CircularAperture(e.aper_1,0,0);
-					else if(strstr(e.apertype.c_str(),"RECTANGLE")) 
-						ap = new H_RectangularAperture(e.aper_1,e.aper_2,0,0);
-					else if(strstr(e.apertype.c_str(),"ELLIPSE")) 
-						ap = new H_EllipticAperture(e.aper_1,e.aper_2,0,0);
+				if (direction<0) {
+					el->setBetaX(e.betx);
+					el->setBetaY(e.bety);
+					el->setDX(e.dx);
+					el->setDY(e.dy);
+					el->setRelX(e.x);
+					el->setRelY(e.y);
+				} else {
+					el->setBetaX(previous_betax);
+					el->setBetaY(previous_betay);
+					el->setDX(previous_dx);
+					el->setDY(previous_dy);
+					el->setRelX(previous_x);
+					el->setRelY(previous_y);
+				}
+				if(ap!=0) { 
+					el->setAperture(ap); 
+				//		delete ap; // ap deleted in H_AbstractBeamLine::~H_AbstractBeamLine
 				}
 	
-				if (direction<0) {
-					el->setBetaX(e.betx);	el->setBetaY(e.bety);
-					el->setDX(e.dx);	el->setDY(e.dy);
-					el->setRelX(e.x);	el->setRelY(e.y);
-				} else {
-					el->setBetaX(previous_betax); 	el->setBetaY(previous_betay);
-					el->setDX(previous_dx);		el->setDY(previous_dy);
-					el->setRelX(previous_x);	el->setRelY(previous_y);
-				}
-				if(ap!=0) { 
-					el->setAperture(ap);
-					delete ap;
-					// if memory is allocated, i.e. if ap!=0,
-					// it wont be deallocated in H_OpticalElement::~H_OpticalElement
-					// ap should then be deleted here
-				} // memory leak-free!
-	
-				/// Parses all the elements from the beginning of the file, 
-				/// but only keeps the ones from the IP till the desired length
-				if(e.s>=0 && e.s<beam_length) add(el);
-				else { delete el;} 
-				// NB : if "el" is added to the beamline, it will be 
-				// deleted by H_AbstractBeamLine::~H_AbstractBeamLine
-				// Otherwise, it should be deleted explicitly
-
+				/// Parses all the elements, but only keeps the ones from the IP till the desired length
+				if(e.s>=0 && e.s<beam_length) add(*el);
+
+			// delete el; // el deleted in H_AbstractBeamLine::~H_AbstractBeamLine
 			} // if(el!=0)
 		} // if (found)
Index: external/Hector/H_BeamLine.h
===================================================================
--- external/Hector/H_BeamLine.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_BeamLine.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_BeamLine_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_BeamLine.h
@@ -39,16 +32,22 @@
 	///     Constructors and destructor
 	//@{
-		H_BeamLine();
+		H_BeamLine():H_AbstractBeamLine() {direction=1; ips=0; };
 		H_BeamLine(const H_BeamLine& );
 		H_BeamLine(const int, const float);
 		H_BeamLine& operator=(const H_BeamLine& );
-		~H_BeamLine() {};
+		~H_BeamLine() {return;};
 	//@
 		///     Finds the IP position (s) from the MAD table. Should be "IP5" or "IP1".
-		void findIP(const string& filename, const string& ipname="IP5");
+		//@{
+		void findIP(const string);
+		void findIP(const string, const string);
+		//@}
 		///     Reader for the external MAD table
-		void fill(const string& filename, const int dir=1, const string& ipname="IP5");
+		//@{
+		void fill(const string);
+		void fill(const string, const int, const string );
+		//@}
 		///     Returns the IP position (s)
-		double getIP() const {return ips;};
+		double getIP() {return ips;};
 		///		Returns positions and angles of beam at IP
 		double* getIPProperties();
Index: external/Hector/H_BeamLineParser.cc
===================================================================
--- external/Hector/H_BeamLineParser.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_BeamLineParser.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,25 +1,18 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_BeamLineParser.cc
 /// \brief Reader for madx tables
 ///
-/// Notes : Verifier que tous les SBEND sont toujours appeles MB. Et seulement comme ca !
-/// Verifier qu'il n'y a pas de problemes d'inversion H/V QUADRUPOLES
+/// Notes : Vï¿œifier que tous les SBEND sont toujours appelï¿œ MB. Et seulement comme ï¿œ !
+/// Vï¿œifier qu'il n'y a pas de problï¿œe d'inversion H/V QUADRUPOLES
 /// no distinction between H and Vkickers ?
 /// The identification of the element is based on the values of k1l, k2l, hkick, vkick and on their name.
@@ -38,5 +31,5 @@
 
 /// Identifies the column content from its header
-int column_identification(const string& header) {
+int column_identification(const string header) {
 	// identifies the column type from its name
 
Index: external/Hector/H_BeamLineParser.h
===================================================================
--- external/Hector/H_BeamLineParser.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_BeamLineParser.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_BeamLineParser_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_BeamLineParser.h
@@ -78,5 +71,5 @@
 */
 
-extern int column_identification(const string& );
+extern int column_identification(const string );
 
 /// \brief Reader for madx tables to use in H_BeamLine
@@ -89,5 +82,5 @@
 	//@{
 		H_BeamLineParser() {init();}
-		~H_BeamLineParser() {}
+		~H_BeamLineParser() {return;}
 	//@}
 		void init();
Index: external/Hector/H_BeamParticle.cc
===================================================================
--- external/Hector/H_BeamParticle.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_BeamParticle.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_BeamParticle.cc
@@ -26,5 +19,4 @@
 // c++ #includes
 #include <iostream>
-#include <fstream>
 #include <iomanip>
 #include <vector>
@@ -35,9 +27,10 @@
 #include "H_Parameters.h"
 #include "TRandom.h"
-#include "TVectorD.h"
+//#include "TView.h"
+//#include "TPolyLine3D.h"
 #ifdef _include_pythia_
 #include "TPythia6.h"
+#include "TRandom.h"
 #endif
-
 // local #includes
 #include "H_OpticalElement.h"
@@ -47,5 +40,5 @@
 using namespace std;
 
-void H_BeamParticle::init() { // for more efficiency, put the objects away from init!
+void H_BeamParticle::init() {
 	mp = MP;
 	qp = QP;
@@ -65,14 +58,23 @@
 }
 
-H_BeamParticle::H_BeamParticle() { 
+H_BeamParticle::H_BeamParticle() {
 	init();
 }
 
-H_BeamParticle::H_BeamParticle(const H_BeamParticle& p): 
-	mp(p.mp), qp(p.qp), fs(p.fs), fx(p.fx), fy(p.fy), thx(p.thx), thy(p.thy), 
-	energy(p.energy), hasstopped(p.hasstopped), hasemitted(p.hasemitted),
-	isphysical(p.isphysical), stop_position(new TVectorD(*(p.stop_position))),
-	stop_element(0), positions(p.positions) {
+H_BeamParticle::H_BeamParticle(const H_BeamParticle& p) {
+	mp = p.mp;
+	qp = p.qp;
+	fx = p.fx;
+	fy = p.fy;
+	thx = p.thx;
+	thy = p.thy;
+	fs = p.fs;
+	energy = p.energy;
+	hasstopped = p.hasstopped;
+	hasemitted = p.hasemitted;
+	isphysical = p.isphysical;
+	stop_position = new TVectorD(*(p.stop_position));
 	if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element)); 
+	positions = p.positions;
 }
 
@@ -99,10 +101,9 @@
         stop_position = new TVectorD(*(p.stop_position));
 	if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element));
-	else stop_element = 0;
         positions = p.positions;
 	return *this;
 }
 
-const bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) {
+bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) {
 	vector<TVectorD>::const_iterator position_i;
 	for(position_i = positions.begin(); position_i < positions.end()-1; position_i++) {
@@ -110,29 +111,11 @@
 		if(beamline->getElement(pos)->getAperture()->getType()!=NONE) {
 			bool has_passed_entrance = beamline->getElement(pos)->isInside((*position_i)[INDEX_X],(*position_i)[INDEX_Y]);
-			bool has_passed_exit     = beamline->getElement(pos)->isInside((*(position_i+1))[INDEX_X],(*(position_i+1))[INDEX_Y]);
-			// here we should distinguish between particles passing the input or not.
-			//  - particles not passing the input are logically stopped at the input position. period.
-			//  - particles passing the input but not the output are stopped somewhere in the element
-			//  - particles passing both the input and the output could have been stopped somewhere inside too (less likely)
-			if(!has_passed_entrance) {
-				if(VERBOSE) cout<<"Stopped at the entrance of "<<beamline->getElement(pos)->getName();
-				hasstopped=true;
-				stop_element = const_cast<H_OpticalElement*>(beamline->getElement(pos));
-				*stop_position = *position_i;
-				if(VERBOSE) cout<<" at s = "<<(*stop_position)[4]<<endl;
-				return hasstopped;
-			} else if (!has_passed_exit) {
-				if(VERBOSE) cout<<"Stopped inside "<<beamline->getElement(pos)->getName();
-				hasstopped=true;
-				stop_element = const_cast<H_OpticalElement*>(beamline->getElement(pos));
-				// this should be computed using the element-based method "H_OpticalElement::getHitPosition" (caution : always nonlinear).
-				*stop_position = beamline->getElement(pos)->getHitPosition(*position_i,BE-energy,mp,qp);
-				if(VERBOSE) cout<<" at s = "<<(*stop_position)[4]<<endl;
-				return hasstopped;
-			}
-/*
+			bool has_passed_exit     = beamline->getElement(pos)->isInside((*(position_i+1))[INDEX_X],(*(position_i+1))[INDEX_Y]); 
 			if(!(has_passed_entrance && has_passed_exit)) {
+	//			cout << "p =" << (*position_i)[INDEX_X] << "; el=" << beamline->getElement(pos)->getX()<<endl;
+	//			beamline->getElement(position_i-positions.begin())->printProperties();
 				if(VERBOSE) cout<<"particle stopped at "<<(beamline->getElement(pos))->getName();
 				if(VERBOSE) cout<<" (s = "<<(*position_i)[4] << ")" << endl;
+				if(VERBOSE && !has_passed_exit) cout << "Particle stopped inside the element" << endl;
 				hasstopped=true;
 				stop_element = const_cast<H_OpticalElement*>(beamline->getElement(pos));
@@ -140,5 +123,5 @@
 				return hasstopped;
 			} // if
-*/
+//			else cout << "outside aperture " << endl;
 		} // if
 	} // for
@@ -159,6 +142,4 @@
 }
 
-
-
 void H_BeamParticle::smearPos(const double dx,const double dy, TRandom* r) {
   // the beam is centered on (fx,fy) at IP
@@ -191,5 +172,4 @@
 }
 
-
 void H_BeamParticle::set4Momentum(const double px, const double py, const double pz, const double ene) {
 	/// @param px, py, pz, ene is \f$ (\vec p , E) [GeV]\f$ 
@@ -207,11 +187,4 @@
         addPosition(fx,thx,fy,thy,fs);
 	return;
-}
-
-void H_BeamParticle::set4Momentum(const TLorentzVector& pmu) {
-	/// @param pmu is the particle 4-momentum \f$ p^\mu \f$
-	///
-	/// Clears the H_BeamParticle::positions vector.
-	set4Momentum(pmu.Px(), pmu.Py(), pmu.Pz(), pmu.E());
 }
 
@@ -242,4 +215,9 @@
 }
 
+void H_BeamParticle::emitGamma(const double gee, const double gq2) {
+	emitGamma(gee,gq2,0,2*PI);
+	return;
+}
+
 void H_BeamParticle::emitGamma(const double gee, const double gq2, const double phimin, const double phimax) {
 	/// @param gee = \f$ E_{\gamma} \f$ is the photon energy
@@ -271,9 +249,9 @@
 	
 	if( (gq2>q2max) || (gq2<q2min)) {
-		if(VERBOSE) cout<<"<H_BeamParticle> WARNING : Non physical particle ! Q2 (" << q2 << ") and E ("<<gee << ") are not compatible." << endl; 
+		if(VERBOSE) cout<<"Non physical particle ! Q2 (" << q2 << ") and E ("<<gee << ") are not compatible." << endl; 
 		isphysical = false; 
 	}
 
-	if(hasemitted) { cout<<"<H_BeamParticle> WARNING : particle has already emitted at least one gamma !"<<endl;}
+	if(hasemitted) { cout<<"particle has already emitted at least one gamma !"<<endl;}
 	hasemitted = true;
 	energy = energy - gee;
@@ -330,13 +308,13 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_BeamParticle& p) {
-        os << " M   = " << p.getM()  << "GeV ";
-        os << " Q   = " << p.getQ()  << "e";
-        os << " fx  = " << p.getX()  << "m   ";
-        os << " fy  = " << p.getY()  << "m   ";
-        os << " thx = " << p.getTX() << "rad ";
-        os << " thy = " << p.getTY() << "rad ";
-        os << endl;
-   return os;
+void H_BeamParticle::printProperties() const {
+	cout << " M   = " << getM()  << "GeV ";
+	cout << " Q   = " << getQ()  << "e";
+	cout << " fx  = " << getX()  << "m   ";
+ 	cout << " fy  = " << getY()  << "m   ";
+	cout << " thx = " << getTX() << "rad ";
+	cout << " thy = " << getTY() << "rad ";
+	cout << endl;
+	return;
 }
 
@@ -378,10 +356,10 @@
 			if((*position_i)[INDEX_S]>=position) {
 				if(position_i==positions.begin()) {
-					if(VERBOSE) cout<<"<H_BeamParticle> ERROR : non reachable value"<<endl;
+					if(VERBOSE) cout<<"ERROR : non reachable value"<<endl;
 					return;
 				}
 				l = (*position_i)[INDEX_S] - (*(position_i-1))[INDEX_S];
 				if(l==0) {
-					if(VERBOSE) cout<<"<H_BeamParticle> WARNING : no luck in choosing position, no propagation done"<<endl;
+					if(VERBOSE) cout<<"WARNING : no luck in choosing position, no propagation done"<<endl;
 					return;
 				}
@@ -396,13 +374,13 @@
 		position_i = positions.begin();
 		cout << "Desired position is : " << position << " & positions.begin() is " << (*position_i)[INDEX_S] << endl;
-		cout<<"<H_BeamParticle> ERROR : position not reachable"<<endl;	
+		cout<<"ERROR : position not reachable"<<endl;	
 		return;
 	}
 }
 
-/// Caution : do not use this method (obsolete) !!!
+/// Caution : do not use this method !!!
 void H_BeamParticle::propagate(const H_AbstractBeamLine * beam, const H_OpticalElement * element) {
 	TMatrixD X(*getV());
-	X *= beam->getPartialMatrix(element);
+	X *= *(beam->getPartialMatrix(element));
 	fx = URAD*(X.GetMatrixArray())[0];
 	thx = URAD*atan((X.GetMatrixArray())[1]);
@@ -412,6 +390,6 @@
 }
 
-void H_BeamParticle::propagate(const H_AbstractBeamLine * beam, const string& el_name) {
-	propagate(beam->getElement(el_name)->getS()+beam->getElement(el_name)->getLength());
+void H_BeamParticle::propagate(const H_AbstractBeamLine * beam, const string el_name) {
+	propagate(beam->getElement(el_name)->getS());
 	return;
 }
@@ -419,5 +397,5 @@
 void H_BeamParticle::propagate(const H_AbstractBeamLine * beam) {
 	TMatrixD X(*getV());
-	X  *= beam->getBeamMatrix();
+	X  *= *(beam->getBeamMatrix());
 	fx  = URAD*(X.GetMatrixArray())[0];
 	thx = URAD*atan((X.GetMatrixArray())[1]);
@@ -436,11 +414,11 @@
 	return ;
 }
-
+/*
 TGraph * H_BeamParticle::getPath(const int x_or_y, const int color) const{
         /// @param x_or_y = 0(1) draws the x(y) component;
 
         const int N = (int) positions.size();
-		int mycolor = color;
-        if(N<2) cout<<"<H_BeamParticle> WARNING : particle positions not calculated : please run computePath"<<endl; 
+	int mycolor = color;
+        if(N<2) cout<<"particle positions not calculated : please run computePath"<<endl; 
         double * s = new double[N], * graph = new double[N];
 
@@ -461,18 +439,42 @@
 }
 
-void H_BeamParticle::getPath(const int x_or_y, const string& filename) const{
-        /// @param x_or_y = 0(1) draws the x(y) component;
-	ofstream outfile(filename.c_str());
-
-        int index;
-        if(x_or_y==0) {index = INDEX_X;} else {index = INDEX_Y;}
+TPolyLine3D *  H_BeamParticle::getPath3D(const H_AbstractBeamLine * beam, const bool isfirst, const int color, const int side) const{
+        const int N = (int) positions.size();
+	int mycolor = color;
+        if(N<2) cout<<"WARNING : particle positions not calculated. Run computePath"<<endl;
+        double * s = new double[N], * graphx = new double[N], * graphy = new double[N];
+	int direction = (side<0)?-1:1;
+
 
         vector<TVectorD>::const_iterator position_i;
         for(position_i = positions.begin(); position_i < positions.end(); position_i++) {
-		outfile << (*position_i)[index] << "\t" << (*position_i)[INDEX_S] << endl;
+                graphx[(int)(position_i-positions.begin())] = (*position_i)[INDEX_X];
+                graphy[(int)(position_i-positions.begin())] = (*position_i)[INDEX_Y];
+                s[(int)(position_i-positions.begin())] = (*position_i)[INDEX_S]*1000*direction;
         }
-	outfile.close();
-}
-
+
+        float coi[3] = {beam->getLength()*(-1000),-10000,-5000};
+        float cof[3] = {beam->getLength()*1000,10000,5000};
+        TView *view = TView::CreateView(11);
+        view->SetRange(coi[0],coi[1],coi[2],cof[0],cof[1],cof[2]);
+        TPolyLine3D* ppath = new TPolyLine3D(N,s,graphx,graphy);
+	ppath->SetLineColor(mycolor);
+
+        if(isfirst) {
+                ppath->Draw();
+                view->ShowAxis();
+        } else {
+                ppath->Draw("same");
+        }
+
+        delete [] s;
+        delete [] graphx;
+        delete [] graphy;
+        return ppath;
+} // getPath3D
+*/
+void H_BeamParticle::computePath(const H_AbstractBeamLine * beam) {
+	computePath(beam,true);
+}
 
 // should be removed later, to keep only computePath(const H_AbstractBeamLine & , const bool)
@@ -505,51 +507,26 @@
 	for (int i=0; i<N; i++) {
 		const unsigned pos = i;
-		if(fs < beam->getElement(pos)->getS() && fs > beam->getElement(pos-1)->getS()) {
-			if(beam->getElement(pos-1)->getType()!=DRIFT) { 
-				cout<<"Path starts inside element "<<beam->getElement(pos-1)->getName()<<endl;
-			} else { 
-				cout<<"Path starts inside unnamed drift "<<endl;
-			}
-			H_OpticalElement* temp_el = beam->getElement(pos-1)->clone();
-			temp_el->setS(fs);
-			temp_el->setLength(beam->getElement(pos)->getS() - fs);
-			mat[0][0] = mat[0][0] - temp_el->getX();
-			mat[0][1] = mat[0][1] - tan(temp_el->getTX());
-			mat[0][2] = mat[0][2] - temp_el->getY();
-			mat[0][3] = mat[0][3] - tan(temp_el->getTY());
-			mat *= temp_el->getMatrix(energy_loss,mp,qp);
-			mat[0][0] = mat[0][0] + temp_el->getX();
-			mat[0][1] = mat[0][1] + tan(temp_el->getTX());
-			mat[0][2] = mat[0][2] + temp_el->getY();
-			mat[0][3] = mat[0][3] + tan(temp_el->getTY());
-			xys[0] = mat.GetMatrixArray()[0]*URAD;
-			xys[1] = atan(mat.GetMatrixArray()[1])*URAD;
-			xys[2] = mat.GetMatrixArray()[2]*URAD;
-			xys[3] = atan(mat.GetMatrixArray()[3])*URAD;
-			xys[4] = temp_el->getS()+temp_el->getLength();
-			addPosition(xys[0],xys[1],xys[2],xys[3],xys[4]);
-			if (temp_el) delete temp_el;
-		} 
-		if(fs <= beam->getElement(pos)->getS()) {
-			mat[0][0] = mat[0][0] - beam->getElement(pos)->getX();
-			mat[0][1] = mat[0][1] - tan(beam->getElement(pos)->getTX()/URAD)*URAD;
-			mat[0][2] = mat[0][2] - beam->getElement(pos)->getY();
-			mat[0][3] = mat[0][3] - tan(beam->getElement(pos)->getTY()/URAD)*URAD;
-			mat *= beam->getElement(pos)->getMatrix(energy_loss,mp,qp);
-			mat[0][0] = mat[0][0] + beam->getElement(pos)->getX();
-			mat[0][1] = mat[0][1] + tan(beam->getElement(pos)->getTX()/URAD)*URAD;
-			mat[0][2] = mat[0][2] + beam->getElement(pos)->getY();
-			mat[0][3] = mat[0][3] + tan(beam->getElement(pos)->getTY()/URAD)*URAD;
-			xys[0] = mat.GetMatrixArray()[0]*URAD;
-			xys[1] = atan(mat.GetMatrixArray()[1])*URAD;
-			xys[2] = mat.GetMatrixArray()[2]*URAD;
-			xys[3] = atan(mat.GetMatrixArray()[3])*URAD;
-			xys[4] = beam->getElement(pos)->getS()+beam->getElement(pos)->getLength();
-			addPosition(xys[0],xys[1],xys[2],xys[3],xys[4]);
-		}
-	}
-}
-
-// part about non-ip particle is not ready yet. use the above method in the meantime
+		mat[0][0] = mat[0][0] - beam->getElement(pos)->getX();
+		mat[0][1] = mat[0][1] - tan(beam->getElement(pos)->getTX()/URAD)*URAD;
+		mat[0][2] = mat[0][2] - beam->getElement(pos)->getY();
+		mat[0][3] = mat[0][3] - tan(beam->getElement(pos)->getTY()/URAD)*URAD;
+		mat *= beam->getElement(pos)->getMatrix(energy_loss,mp,qp);
+		mat[0][0] = mat[0][0] + beam->getElement(pos)->getX();
+		mat[0][1] = mat[0][1] + tan(beam->getElement(pos)->getTX()/URAD)*URAD;
+		mat[0][2] = mat[0][2] + beam->getElement(pos)->getY();
+		mat[0][3] = mat[0][3] + tan(beam->getElement(pos)->getTY()/URAD)*URAD;
+                xys[0] = mat.GetMatrixArray()[0]*URAD;
+                xys[1] = atan(mat.GetMatrixArray()[1])*URAD;
+                xys[2] = mat.GetMatrixArray()[2]*URAD;
+                xys[3] = atan(mat.GetMatrixArray()[3])*URAD;
+                xys[4] = beam->getElement(pos)->getS()+beam->getElement(pos)->getLength();
+                addPosition(xys[0],xys[1],xys[2],xys[3],xys[4]);
+                fx = xys[0];
+                fy = xys[2];
+                thx = xys[1];
+                thy = xys[3];
+        }
+}
+
 void H_BeamParticle::computePath(const H_AbstractBeamLine & beam, const bool NonLinear) {
 	TMatrixD temp_mat(MDIM,MDIM);
@@ -578,47 +555,26 @@
 	double energy_loss = NonLinear?BE-energy:0;
 
-	// modify here to allow starting at non-IP positions
-	// s is distance to IP
-	// initial position is already in positions vector ?
 	for (int i=0; i<N; i++) {
 		const unsigned pos = i;
-		// if we are inside an element, we should start by adding the action
-		// of the rest of this element
-		if(pos > 0 && fs < beam.getElement(pos)->getS() && fs > beam.getElement(pos-1)->getS()) {
-			cout<<"Path starts inside element "<<beam.getElement(pos-1)->getName()<<endl;
-			H_OpticalElement* temp_el = new H_OpticalElement(*(beam.getElement(pos-1)));
-			temp_el->setS(fs);
-			temp_el->setLength(beam.getElement(pos)->getS() - fs);
-			mat[0][0] = mat[0][0] - temp_el->getX();
-			mat[0][1] = mat[0][1] - tan(temp_el->getTX());
-			mat[0][2] = mat[0][2] - temp_el->getY();
-			mat[0][3] = mat[0][3] - tan(temp_el->getTY());
-			mat *= temp_el->getMatrix(energy_loss,mp,qp);
-			mat[0][0] = mat[0][0] + temp_el->getX();
-			mat[0][1] = mat[0][1] + tan(temp_el->getTX());
-			mat[0][2] = mat[0][2] + temp_el->getY();
-			mat[0][3] = mat[0][3] + tan(temp_el->getTY());
-		} else if(fs >= beam.getElement(pos)->getS()) {
-			mat[0][0] = mat[0][0] - beam.getElement(pos)->getX();
-			mat[0][1] = mat[0][1] - tan(beam.getElement(pos)->getTX());
-			mat[0][2] = mat[0][2] - beam.getElement(pos)->getY();
-			mat[0][3] = mat[0][3] - tan(beam.getElement(pos)->getTY());
-			mat *= beam.getElement(pos)->getMatrix(energy_loss,mp,qp);
-			mat[0][0] = mat[0][0] + beam.getElement(pos)->getX();
-			mat[0][1] = mat[0][1] + tan(beam.getElement(pos)->getTX());
-			mat[0][2] = mat[0][2] + beam.getElement(pos)->getY();
-			mat[0][3] = mat[0][3] + tan(beam.getElement(pos)->getTY());
-		}
-		xys[0] = mat.GetMatrixArray()[0]*URAD;
-		xys[1] = atan(mat.GetMatrixArray()[1])*URAD;
-		xys[2] = mat.GetMatrixArray()[2]*URAD;
-		xys[3] = atan(mat.GetMatrixArray()[3])*URAD;
-		xys[4] = beam.getElement(pos)->getS()+beam.getElement(pos)->getLength();
-		addPosition(xys[0],xys[1],xys[2],xys[3],xys[4]);
-		fx = xys[0];
-		fy = xys[2];
-		thx = xys[1];
-		thy = xys[3];
-	}
+		mat[0][0] = mat[0][0] - beam.getElement(pos)->getX();
+		mat[0][1] = mat[0][1] - tan(beam.getElement(pos)->getTX());
+		mat[0][2] = mat[0][2] - beam.getElement(pos)->getY();
+		mat[0][3] = mat[0][3] - tan(beam.getElement(pos)->getTY());
+		mat *= beam.getElement(pos)->getMatrix(energy_loss,mp,qp);
+		mat[0][0] = mat[0][0] + beam.getElement(pos)->getX();
+		mat[0][1] = mat[0][1] + tan(beam.getElement(pos)->getTX());
+		mat[0][2] = mat[0][2] + beam.getElement(pos)->getY();
+		mat[0][3] = mat[0][3] + tan(beam.getElement(pos)->getTY());
+                xys[0] = mat.GetMatrixArray()[0]*URAD;
+                xys[1] = atan(mat.GetMatrixArray()[1])*URAD;
+                xys[2] = mat.GetMatrixArray()[2]*URAD;
+                xys[3] = atan(mat.GetMatrixArray()[3])*URAD;
+                xys[4] = beam.getElement(pos)->getS()+beam.getElement(pos)->getLength();
+                addPosition(xys[0],xys[1],xys[2],xys[3],xys[4]);
+                fx = xys[0];
+                fy = xys[2];
+                thx = xys[1];
+                thy = xys[3];
+        }
 }
 
Index: external/Hector/H_BeamParticle.h
===================================================================
--- external/Hector/H_BeamParticle.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_BeamParticle.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_BeamParticle_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_BeamParticle.h
@@ -33,6 +26,6 @@
 #include "TMatrixD.h"
 #include "TVectorD.h"
-#include "TLorentzVector.h"
-#include "TRandom3.h"
+//#include "TPolyLine3D.h"
+#include "TRandom.h"
 
 // local #includes
@@ -43,8 +36,18 @@
 using namespace std;
 
+// local defines
+#define LENGTH_VEC 5
+#define INDEX_X 0
+#define INDEX_TX 1
+#define INDEX_Y 2
+#define INDEX_TY 3
+#define INDEX_S 4
+// (x,theta_x,y,theta_y,s)
+
 /// Defines a particle from the beam and its transport through the beamline
 class H_BeamParticle {
 
 	public:
+		void init();
 		/// Constructors and Destructor
 		//@{
@@ -53,5 +56,5 @@
 		H_BeamParticle(const double, const double);
 		H_BeamParticle& operator=(const H_BeamParticle&);
-		~H_BeamParticle() {if(stop_position) delete stop_position; if(!stop_element) delete stop_element; positions.clear();}
+		~H_BeamParticle() {delete stop_position; if(!stop_element) delete stop_element; positions.clear(); return; }
 		//@}
 		/// Smears the (x,y) coordinates of the particle [\f$ \mu m \f$]
@@ -67,27 +70,25 @@
 		/// Sets the particle 4-momentum \f$ P^\mu \f$
 		void set4Momentum(const double, const double, const double, const double);	
-		/// Sets the particle 4-momentum \f$ P^\mu \f$
-		void set4Momentum(const TLorentzVector&);	
 		/// Clears H_BeamParticle::positions and sets the initial one.
 		void setPosition(const double , const double , const double , const double , const double );
 		/// Returns the particle mass [GeV]
-		const double getM() const {return mp;};
+		double getM() const {return mp;};
 		/// Returns the particle charge [e]
-		const double getQ() const {return qp;};
+		double getQ() const {return qp;};
 		/// Returns the current x coordinate [\f$ \mu \f$m]
-		const double getX() const {return fx;};
+		double getX() const {return fx;};
 		/// Returns the current y coordinate [\f$ \mu \f$m]
-		const double getY() const {return fy;};
+		double getY() const {return fy;};
 		/// Returns the current s coordinate [m]
-		const double getS() const {return fs;};
+		inline double getS() const {return fs;};
 		/// Returns the current \f$ \theta_x \f$ angular coordinate [\f$ \mu \f$rad]
-		const double getTX() const {return thx;};
+		inline double getTX() const {return thx;};
 		/// Returns the current \f$ \theta_y \f$ angular coordinate [\f$ \mu \f$rad]
-		const double getTY() const {return thy;};
+		inline double getTY() const {return thy;};
 		/// Returns the current particle energy [GeV]
-		const double getE() const {return energy;};
+		inline double getE() const {return energy;};
 		/// Returns all the positions 
 		vector<TVectorD> getPositions() const {return positions;};
-		const bool isPhysical() const {return isphysical;};
+		bool isPhysical() const {return isphysical;};
 		/// \brief Simulates the emission of a photon in a random direction
 		///
@@ -98,5 +99,6 @@
         	/// \f$ Q^{2}_{max} = -2 * \big( \frac{M_{p} E_{\gamma}}{p_{1}+p_{2}} \big) \big[ 1 + \frac{E^{2}_{1} + E^{2}_{2} - M^{2}_{p} }{ E_{1} E_{2} + p_{1} p_{2}} \big]    \f$
 		//@{
-		void emitGamma(const double gee, const double gq2, const double phimin=0, const double phimax=2*TMath::Pi());
+		void emitGamma(const double, const double, const double, const double);
+		void emitGamma(const double, const double);
 		//@}
                 /// uses Pythia to generate some inelastic pp->pX collision as background
@@ -110,5 +112,5 @@
 		void propagate(const H_AbstractBeamLine *, const H_OpticalElement *);
 		/// Propagates the particle accross the beamline until a given element
-		void propagate(const H_AbstractBeamLine *, const string&);
+		void propagate(const H_AbstractBeamLine *, const string);
 		/// Propagates the particle until the end of the beamline
 		void propagate(const H_AbstractBeamLine *);
@@ -118,5 +120,5 @@
 		const TVectorD * getPosition(const int ) const;
 		/// Prints the properties of the particle
-		void printProperties() const {cout << *this; return;};
+		void printProperties() const;
 		/// Prints the phase vector of the particle
 		void printV() const;
@@ -124,5 +126,5 @@
 		const H_OpticalElement * getStoppingElement() const;
 		/// Checks if the particle has been stopped in any element of the beamline
-		const bool stopped(const H_AbstractBeamLine *);
+		bool stopped(const H_AbstractBeamLine *);
 		/// Returns the StopPosition vector
 		inline const TVectorD * getStopPosition() const { return stop_position; };
@@ -131,15 +133,17 @@
 		void showPositions() const; 
 		/// Returns the particle path in the beamline
-		TGraph * getPath(const int , const int ) const;
-		void getPath(const int x_or_y, const string& filename) const;
+		////TGraph * getPath(const int , const int ) const;
+		/// Draws the particle path in the beamline in 3D
+		////TPolyLine3D * getPath3D(const H_AbstractBeamLine *, const bool, const int, const int) const;
+		/// Computes the position of the particle at the end of each element of the beam, without non linear effects
+		void computePath(const H_AbstractBeamLine *);
 		/// Computes the position of the particle at the end of each element of the beam.
-		void computePath(const H_AbstractBeamLine * beam, const bool NonLinear=true);
+		void computePath(const H_AbstractBeamLine *, const bool);
 		/// Computes the position of the particle at the end of each element of the beam.
-		void computePath(const H_AbstractBeamLine & beam, const bool NonLinear=true);
+		void computePath(const H_AbstractBeamLine &, const bool);
 		/// Clears H_BeamParticle::positions but keeps the initial vector.
 		void resetPath();
 
 	private:
-		void init();
 		/// Particle mass [GeV]
 		double mp;
@@ -172,6 +176,4 @@
 		/// Adds a new vector (x,tx,y,ty,s) at the end of H_BeamParticle::positions
   		void addPosition(const double , const double , const double , const double , const double );
-
-	friend std::ostream& operator<< (std::ostream& os, const H_BeamParticle& p);
 };
 #endif
Index: external/Hector/H_CircularAperture.cc
===================================================================
--- external/Hector/H_CircularAperture.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_CircularAperture.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_CircularAperture.cc
@@ -30,11 +23,14 @@
 using namespace std;
 
-H_CircularAperture* H_CircularAperture::clone() const {
-	return new H_CircularAperture(x1,fx,fy);
+/// Circular apertures
+H_CircularAperture::H_CircularAperture(const float r, const float posx, const float posy) :H_EllipticAperture(r,r,posx,posy) { 
+        /// @param r is the radius of the circular shape
+        /// @param posx, posy are the (x,y) coordinates of the center of the circle
+	type= CIRCULAR; 
 }
 
-std::ostream& operator<< (std::ostream& os, const H_CircularAperture& ap) {
-        os     << "Aperture shape:" << ap.aptypestring << ", aperture radius : " << ap.x1 << endl;
-        os     << " \t Center : " << ap.fx << "," << ap.fy << endl;
-        return os;
+void H_CircularAperture::printProperties() const {
+        cout << "Aperture shape:" << getTypeString() << ", aperture radius : " << x1 << endl;
+        cout << " \t Center : " << fx << "," << fy << endl;
+        return;
 }
Index: external/Hector/H_CircularAperture.h
===================================================================
--- external/Hector/H_CircularAperture.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_CircularAperture.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_CircularAperture_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_CircularAperture.h
@@ -33,12 +26,9 @@
 		/// Constructors and destructor
 		//@{
-		H_CircularAperture():H_EllipticAperture(CIRCULAR,0,0,0,0) {};
-		H_CircularAperture(const float r, const float posx, const float posy) : H_EllipticAperture(CIRCULAR,r,r,posx,posy) {};
-		/// @param r is the radius of the circular shape
-        	/// @param posx, posy are the (x,y) coordinates of the center of the circle
-		~H_CircularAperture() {};
-		H_CircularAperture* clone() const;
+		H_CircularAperture():H_EllipticAperture(0,0,0,0) {type = CIRCULAR; setApertureString();}
+		H_CircularAperture(const float, const float, const float);
+		~H_CircularAperture() {return;};
 		//@}
-	friend std::ostream& operator<< (std::ostream& os, const H_CircularAperture& ap);
+		virtual void printProperties() const;
 };
 
Index: external/Hector/H_Dipole.cc
===================================================================
--- external/Hector/H_Dipole.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Dipole.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Dipole.cc
@@ -26,5 +19,4 @@
 	// needed for call from R- and S-Dipoles constructor
 	// must be in public section
-	    element_mat.ResizeTo(MDIM,MDIM);
 		setTypeString();
 		if (fk !=0 ) setMatrix(0,MP,QP);
@@ -32,12 +24,17 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Dipole& el) {
-	os << el.typestring << el.name <<"\t at s = "<< el.fs <<"\t length = "<< el.element_length <<"\t k0 = "<<el.fk << endl;
-        if(el.element_aperture->getType()!=NONE) {
-                os << *(el.element_aperture) << endl;
+void H_Dipole::printProperties() const {
+	cout << typestring;
+	cout << name;
+	cout<<"\t at s = "<< fs;
+	cout<<"\t length = "<< element_length;
+	cout<<"\t k0 = "<<fk;
+	cout<<endl;
+        if(element_aperture->getType()!=NONE) {
+        	cout <<"\t aperture type = " << element_aperture->getTypeString();
+                element_aperture->printProperties();
 	}
 
-	if(el.element_length<0)  { if(VERBOSE) os <<"<H_Dipole> ERROR : Interpenetration of elements !"<<endl; }
-	if(el.element_length==0) { if(VERBOSE) os <<"<H_Dipole> WARNING : 0-length "<< el.name << " !" << endl; }
-   return os;
+	if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+	if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length "<< name << " !" << endl; }
 }
Index: external/Hector/H_Dipole.h
===================================================================
--- external/Hector/H_Dipole.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Dipole.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 /// \brief Class aiming at simulating LHC beam dipoles.
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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)
+*/
 
 #ifndef _H_Dipole_
@@ -33,17 +26,15 @@
 		H_Dipole():H_OpticalElement() {}
 		H_Dipole(const int dtype, const double s, const double k, const double l):H_OpticalElement(dtype,s,k,l){}
-		H_Dipole(const string& nameE, const int dtype, const double s, const double k, const double l):H_OpticalElement(nameE,dtype,s,k,l){}
-	        virtual ~H_Dipole() {};
+		H_Dipole(const string nameE, const int dtype, const double s, const double k, const double l):H_OpticalElement(nameE,dtype,s,k,l){}
+	        virtual ~H_Dipole() {return;};
 		//@}
 		/// Prints the properties of the element
-		virtual void printProperties() const { cout << *this; return;};
-		virtual H_Dipole* clone() const =0;
-		void init();
+        	virtual void printProperties() const;
+	        void init();
 
  	protected:
     		virtual void setTypeString() =0;
-	    	virtual void setMatrix(const float, const float, const float) = 0;
-    
-	friend std::ostream& operator<< (std::ostream& os, const H_Dipole& el);
+	    	virtual void setMatrix(const float, const float, const float) const =0;
+    	
 };
 
Index: external/Hector/H_Drift.cc
===================================================================
--- external/Hector/H_Drift.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Drift.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Drift.cc
@@ -24,8 +17,6 @@
 #include "H_TransportMatrices.h"
 
-
 void H_Drift::init() {
 	// must be in public section
-	element_mat.ResizeTo(MDIM,MDIM);
 	setTypeString();
 	setMatrix(0,MP,QP);
@@ -33,29 +24,19 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Drift& el) {
-	os << el.typestring << el.name << "\t\t at s = " << el.fs << "\t length = " << el.element_length <<endl;
-	if(el.element_aperture->getType()!=NONE) {
-		os << *(el.element_aperture) << endl;
+void H_Drift::printProperties() const {
+	cout << typestring << name;
+	cout << "\t\t at s = " << fs;
+	cout << "\t length = " << element_length;
+	cout<<endl;
+	if(element_aperture->getType()!=NONE) {
+		cout <<"\t aperture type = " << element_aperture->getTypeString();
+                element_aperture->printProperties();
         }
-	if(el.element_length<0 && VERBOSE) os <<"<H_Drift> ERROR : Interpenetration of elements !"<<endl;
-	else if(el.element_length==0 && VERBOSE) os <<"<H_Drift> WARNING : 0-length "<< el.name << " !" << endl;
-   return os;
+	if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+	if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length "<< name << " !" << endl; }
 }
 
-//void H_Drift::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-void H_Drift::setMatrix(const float , const float , const float ) {
-	element_mat = driftmat(element_length);
+void H_Drift::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+		*element_mat = driftmat(element_length);
 	return ;
 }
-
-H_Drift* H_Drift::clone() const {
-	H_Drift* temp_drift = new H_Drift(name,fs,element_length);
-	temp_drift->setX(xpos);
-	temp_drift->setY(ypos);
-	temp_drift->setTX(txpos);
-	temp_drift->setTY(typos);
-	temp_drift->setBetaX(betax);
-	temp_drift->setBetaY(betay); 
-	return temp_drift;
-}
-
Index: external/Hector/H_Drift.h
===================================================================
--- external/Hector/H_Drift.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Drift.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_Drift_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Drift.h
@@ -34,15 +27,13 @@
 		H_Drift():H_OpticalElement(DRIFT,0.,0.,0.) {init();}
         	H_Drift(const double s, const double l):H_OpticalElement(DRIFT,s,0.,l){init();}
-	        H_Drift(const string& nameE, const double s, const double l):H_OpticalElement(nameE,DRIFT,s,0.,l){init();}
-	        ~H_Drift() { };
+	        H_Drift(const string nameE, const double s, const double l):H_OpticalElement(nameE,DRIFT,s,0.,l){init();}
+	        ~H_Drift() { return; };
 	//@}
+        	virtual void printProperties() const;
 	        void init();
-		virtual void printProperties() const { cout << *this; return;};
-		H_Drift* clone() const;
 
-	protected:
+	private:
         	virtual void setTypeString() {typestring = DRIFTNAME;};
-	        virtual void setMatrix(const float, const float, const float) ;
-	friend std::ostream& operator<< (std::ostream& os, const H_Drift& el);
+	        virtual void setMatrix(const float, const float, const float) const ;
 };
 
Index: external/Hector/H_EllipticAperture.cc
===================================================================
--- external/Hector/H_EllipticAperture.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_EllipticAperture.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_EllipticAperture.cc
@@ -24,5 +17,5 @@
 
 // ROOT #includes
-#include "TEllipse.h"
+//#include "TEllipse.h"
 
 // local #includes
@@ -32,26 +25,7 @@
 using namespace std;
 
-H_EllipticAperture::H_EllipticAperture(const int type, const float l, const float h, const float posx, const float posy) :
-	H_Aperture(type,l,h,0,0,posx,posy) {
-        /// @param type is the aperture type (ELLIPTIC or CIRCULAR)
-        /// @param l, h are the length and height of the elliptic shape
+H_EllipticAperture::H_EllipticAperture(const float x1, const float x2, const float posx, const float posy) :H_Aperture(ELLIPTIC,x1,x2,0,0,posx,posy) {
+        /// @param x1, x2 are the length and height of the elliptic shape
         /// @param posx, posy are the (x,y) coordinates of the center of the ellipse
-
-	if (type!= ELLIPTIC && type != CIRCULAR) { 
-		cout << "Warning: trying to define an EllipticalAperture which is neither elliptical nor circular." << endl;
-		cout << "'Elliptical' type forced\n"; 
-		type_ = ELLIPTIC; 
-		aptypestring = getApertureString(); 
-	}
-}
-
-H_EllipticAperture::H_EllipticAperture(const float l, const float h, const float posx, const float posy) :
-	H_Aperture(ELLIPTIC,l,h,0,0,posx,posy) {
-        /// @param l, h are the length and height of the elliptic shape
-        /// @param posx, posy are the (x,y) coordinates of the center of the ellipse
-}
-
-H_EllipticAperture* H_EllipticAperture::clone() const {
-	return new H_EllipticAperture(x1,x2,fx,fy);
 }
 
@@ -61,16 +35,17 @@
 }
 
-void H_EllipticAperture::draw(const float scale) const {
-	TEllipse* te = new TEllipse(fx*scale,fy*scale,x1*scale,x2*scale);
+void H_EllipticAperture::draw() const {
+/* 	Ellipse* te = new TEllipse(fx,fy,x1,x2);
 	te->SetFillStyle(3003);
-	te->SetLineColor(39);
-	te->SetFillColor(39);
-	te->Draw("f");
+	te->SetLineColor(2);
+	te->SetFillColor(2);
+	te->Draw();
+	return;
+*/
+}
+
+void H_EllipticAperture::printProperties() const {
+	cout<< "Aperture shape:" << getTypeString() << ", ellipse axes : "<<x1<<", "<<x2<<endl;
+	cout << " \t Center : " << fx << "," << fy << endl;
 	return;
 }
-
-std::ostream& operator<< (std::ostream& os, const H_EllipticAperture& ap) {
-	os<< "Aperture shape:" << ap.aptypestring << ", ellipse axes : "<< ap.x1 <<", " << ap.x2 << endl;
-	os << " \t Center : "  << ap.fx << "," << ap.fy << endl;
-	return os;
-}
Index: external/Hector/H_EllipticAperture.h
===================================================================
--- external/Hector/H_EllipticAperture.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_EllipticAperture.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_EllipticAperture_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_EllipticAperture.h
@@ -33,14 +26,12 @@
 		//@{
 		H_EllipticAperture():H_Aperture(ELLIPTIC,0,0,0,0,0,0) {}
-		H_EllipticAperture(const int, const float, const float, const float, const float);
 		H_EllipticAperture(const float, const float, const float, const float);
-		~H_EllipticAperture() {};
-		virtual H_EllipticAperture* clone() const;
+		~H_EllipticAperture() {return;};
 		//@}
 		/// Checks whether the point is inside the aperture or not
 		virtual bool isInside(const float, const float) const;
 		/// Draws the aperture shape.
-		virtual void draw(const float scale=1) const;
-	friend std::ostream& operator<< (std::ostream& os, const H_EllipticAperture& ap);
+		virtual void draw() const;
+		virtual void printProperties() const;
 };
 
Index: external/Hector/H_HorizontalKicker.cc
===================================================================
--- external/Hector/H_HorizontalKicker.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_HorizontalKicker.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_HorizontalKicker.cc
@@ -28,24 +21,11 @@
 int kickers_on = 0;
 
-void H_HorizontalKicker::setMatrix(const float eloss, const float p_mass, const float p_charge) {
+void H_HorizontalKicker::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
 	extern int kickers_on;
 	if(kickers_on) {
-		element_mat = hkickmat(element_length,fk,eloss,p_mass,p_charge);
+		*element_mat = hkickmat(element_length,fk,eloss,p_mass,p_charge);
 	} else {
-		element_mat = driftmat(element_length);
+		*element_mat = driftmat(element_length);
 	}
 	return ;
 }
-
-H_HorizontalKicker* H_HorizontalKicker::clone() const {
-	H_HorizontalKicker* temp_kick = new H_HorizontalKicker(name,fs,fk,element_length);
-	temp_kick->setAperture(element_aperture);
-	temp_kick->setX(xpos);
-	temp_kick->setY(ypos);
-	temp_kick->setTX(txpos);
-	temp_kick->setTY(typos);
-	temp_kick->setBetaX(betax);
-	temp_kick->setBetaY(betay);
-	return temp_kick;
-}
-
Index: external/Hector/H_HorizontalKicker.h
===================================================================
--- external/Hector/H_HorizontalKicker.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_HorizontalKicker.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,27 +1,20 @@
-#ifndef _H_HorizontalKicker_
-#define _H_HorizontalKicker_
-
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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                 *
- *                                                         *
-   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
 /// \file H_HorizontalKicker.h
 /// \brief Classes aiming at simulating horizontal kickers in beamline.
 ///
 /// fk [rad] for kickers !!!!
+
+/*
+---- 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)
+*/
+
+#ifndef _H_HorizontalKicker_
+#define _H_HorizontalKicker_
 
 // local #includes
@@ -36,11 +29,10 @@
 		H_HorizontalKicker():H_Kicker(HKICKER,0.,0.,0.) {init();}
 		H_HorizontalKicker(const double s, const double k, const double l) :H_Kicker(HKICKER,s,k,l){init();}
-		H_HorizontalKicker(const string &nameE, const double s, const double k, const double l) :H_Kicker(nameE,HKICKER,s,k,l){init();}
-		~H_HorizontalKicker() {};
+		H_HorizontalKicker(const string nameE, const double s, const double k, const double l) :H_Kicker(nameE,HKICKER,s,k,l){init();}
+		~H_HorizontalKicker() {return;};
 	//@}
-		H_HorizontalKicker* clone() const;
 	private:
 		virtual void setTypeString() {typestring=HKICKERNAME;};
-		virtual void setMatrix(const float, const float, const float) ;
+		virtual void setMatrix(const float, const float, const float) const ;
 };
 
Index: external/Hector/H_HorizontalQuadrupole.cc
===================================================================
--- external/Hector/H_HorizontalQuadrupole.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_HorizontalQuadrupole.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,45 +1,26 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_HorizontalQuadrupole.cc
-/// \brief Classes aiming at simulating horizontal quadrupoles in beamline
+/// \brief Classes aiming at simulating horizontal kickers in beamline
 
 // local #includes
 #include "H_HorizontalQuadrupole.h"
 
-void H_HorizontalQuadrupole::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-	if (fk>0)  { if(VERBOSE) cout<<"<H_HorizontalQuadrupole> ERROR : k1 should be < 0 (" << name << ")!"<<endl; }
-		if (fk !=0 ) element_mat = hquadmat(element_length,fk,eloss, p_mass, p_charge);
+void H_HorizontalQuadrupole::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+	if (fk>0)  { if(VERBOSE) cout<<"\t ERROR : k1 should be < 0 for H_HorizontalQuadrupole (" << name << ")!"<<endl; }
+		if (fk !=0 ) *element_mat = hquadmat(element_length,fk,eloss, p_mass, p_charge);
 		else  {
-			element_mat = driftmat(element_length);
-			if(VERBOSE) cout<<"<H_HorizontalQuadrupole> WARNING : k1= 0 ; drift-like quadrupole (" << name << ") !" << endl;
+			*element_mat = driftmat(element_length);
+			if(VERBOSE) cout<<"\t WARNING : k1= 0 ; drift-like quadrupole (" << name << ") !" << endl;
    		}
 	return ;
 }
-
-H_HorizontalQuadrupole* H_HorizontalQuadrupole::clone() const {
-	H_HorizontalQuadrupole* temp_quad = new H_HorizontalQuadrupole(name,fs,fk,element_length);
-	temp_quad->setAperture(element_aperture);
-	temp_quad->setX(xpos);
-	temp_quad->setY(ypos);
-	temp_quad->setTX(txpos);
-	temp_quad->setTY(typos);
-	temp_quad->setBetaX(betax);
-	temp_quad->setBetaY(betay);
-	return temp_quad;
-}
Index: external/Hector/H_HorizontalQuadrupole.h
===================================================================
--- external/Hector/H_HorizontalQuadrupole.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_HorizontalQuadrupole.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_HorizontalQuadrupole_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_HorizontalQuadrupole.h
@@ -34,11 +27,10 @@
 		H_HorizontalQuadrupole():H_Quadrupole(HQUADRUPOLE,0.,0.,0.) {init();}
 		H_HorizontalQuadrupole(const double s, const double k, const double l) : H_Quadrupole(HQUADRUPOLE,s,k,l){init();}
-		H_HorizontalQuadrupole(const string& nameE, const double s, const double k, const double l) : H_Quadrupole(nameE,HQUADRUPOLE,s,k,l){init();}
-		~H_HorizontalQuadrupole() {};
+		H_HorizontalQuadrupole(const string nameE, const double s, const double k, const double l) : H_Quadrupole(nameE,HQUADRUPOLE,s,k,l){init();}
+		~H_HorizontalQuadrupole() {return;};
 	//@}
-		H_HorizontalQuadrupole* clone() const ;
 	private:
 		virtual void setTypeString() {typestring = HQUADRUPOLENAME;};
-		virtual void setMatrix(const float, const float, const float) ;
+		virtual void setMatrix(const float, const float, const float) const ;
 };
 
Index: external/Hector/H_Kicker.cc
===================================================================
--- external/Hector/H_Kicker.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Kicker.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Kicker.cc
@@ -34,13 +27,17 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Kicker& el) {
-	os << el.typestring << el.name <<"\t at s = "<< el.fs <<"\t length = "<< el.element_length;
-	os<<"\t k0 = "<< el.fk <<endl;
-	if(el.element_aperture->getType()!=NONE) {
-		os << *(el.element_aperture) << endl;
+void H_Kicker::printProperties() const {
+	cout << typestring;
+	cout << name;
+	cout<<"\t at s = "<< fs;
+	cout<<"\t length = "<< element_length;
+	cout<<"\t k0 = "<<fk;
+	cout<<endl;
+	if(element_aperture->getType()!=NONE) {
+		cout <<"\t aperture type = " << element_aperture->getTypeString();
+                element_aperture->printProperties();
         }
 
-	if(el.element_length<0 && VERBOSE) os<<"<H_Kicker> ERROR : Interpenetration of elements !"<<endl; 
-	else if(el.element_length==0 && VERBOSE) os<<"<H_Kicker> WARNING : 0-length "<< el.name << " !" << endl; 
-  return os;
+	if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+	if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length "<< name << " !" << endl; }
 }
Index: external/Hector/H_Kicker.h
===================================================================
--- external/Hector/H_Kicker.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Kicker.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,26 +1,19 @@
-#ifndef _H_Kicker_
-#define _H_Kicker_
-
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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                 *
- *                                                         *
-   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
 /// \file H_Kicker.h
 /// \brief Classes aiming at simulating kickers in LHC beamline.
 /// fk [rad] for kickers !!!!
+
+/*
+---- 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)
+*/
+
+#ifndef _H_Kicker_
+#define _H_Kicker_
 
 // local #includes
@@ -35,15 +28,14 @@
 		H_Kicker():H_OpticalElement() {}
 		H_Kicker(const int dtype, const double s, const double k, const double l):H_OpticalElement(dtype,s,k,l){}
-		H_Kicker(const string& nameE, const int dtype, const double s, const double k, const double l):H_OpticalElement(nameE,dtype,s,k,l){}
-		virtual ~H_Kicker() {};
+		H_Kicker(const string nameE, const int dtype, const double s, const double k, const double l):H_OpticalElement(nameE,dtype,s,k,l){}
+		virtual ~H_Kicker() {return;};
 	//@}
-		virtual H_Kicker* clone() const = 0;
-		virtual void printProperties() const { cout << *this; return;};
+	/// prints the kicker properties
+		virtual void printProperties() const;
 		void init();
 
  	protected:
-		virtual void setTypeString() = 0;
-		virtual void setMatrix(const float, const float, const float) = 0;
-	friend std::ostream& operator<< (std::ostream& os, const H_Kicker& el);
+		virtual void setTypeString() =0;
+		virtual void setMatrix(const float, const float, const float) const =0;
 };
 
Index: external/Hector/H_Marker.cc
===================================================================
--- external/Hector/H_Marker.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Marker.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Marker.cc
@@ -31,27 +24,15 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Marker& el) {
-	os << el.typestring << el.name << "\t\t at s = " << el.fs;
-	if(el.element_aperture->getType()!=NONE) {
-                os << *(el.element_aperture) << endl;
+void H_Marker::printProperties() const {
+	cout << typestring << name;
+	cout << "\t\t at s = " << fs << endl;
+	if(element_aperture->getType()!=NONE) {
+		cout <<"\t aperture type = " << element_aperture->getTypeString();
+                element_aperture->printProperties();
         }
-   return os;
 }
 
-//void H_Marker::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-void H_Marker::setMatrix(const float , const float , const float ) {
-		element_mat = driftmat(0);
+void H_Marker::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+		*element_mat = driftmat(0);
 	return ;
 }
-
-H_Marker* H_Marker::clone() const {
-	H_Marker* temp_mkr = new H_Marker(name,fs);
-	temp_mkr->setAperture(element_aperture);
-	temp_mkr->setX(xpos);
-	temp_mkr->setY(ypos);
-	temp_mkr->setTX(txpos);
-	temp_mkr->setTY(typos);
-	temp_mkr->setBetaX(betax);
-	temp_mkr->setBetaY(betay);
-	return temp_mkr;
-}
Index: external/Hector/H_Marker.h
===================================================================
--- external/Hector/H_Marker.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Marker.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_Marker_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Marker.h
@@ -24,24 +17,23 @@
 
 // local includes
-#include "H_Drift.h"
+#include "H_OpticalElement.h"
 
 /// \brief Class defining a marker in the beamline (e.g. for interaction point)
-class H_Marker : public H_Drift {
+class H_Marker : public H_OpticalElement {
 
 	public:
 	/// Constructors and destructor
 	//@{
-		H_Marker():H_Drift() { type = MARKER; init();}
-        	H_Marker(const double s):H_Drift(s,0.) { type =MARKER; init();}
-	        H_Marker(const string& nameE, const double s):H_Drift(nameE,s,0.) { type=MARKER; init();}
-	        ~H_Marker() { };
+		H_Marker():H_OpticalElement(MARKER,0.,0.,0.) {init();}
+        	H_Marker(const double s):H_OpticalElement(MARKER,s,0.,0.){init();}
+	        H_Marker(const string nameE, const double s):H_OpticalElement(nameE,MARKER,s,0.,0.){init();}
+	        ~H_Marker() { return; };
 	//@}
-		H_Marker* clone() const ;
+        	virtual void printProperties() const;
 	        void init();
 
 	private:
         	virtual void setTypeString() {typestring = MARKERNAME;};
-	        virtual void setMatrix(const float , const float, const float) ;
-	friend std::ostream& operator<< (std::ostream& os, const H_Marker& el);
+	        virtual void setMatrix(const float , const float, const float) const ;
 };
 
Index: external/Hector/H_OpticalElement.cc
===================================================================
--- external/Hector/H_OpticalElement.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_OpticalElement.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_OpticalElement.cc
@@ -25,8 +18,7 @@
 
 // ROOT #includes
-#include "TPaveLabel.h"
+//#include "TPaveLabel.h"
 
 // local #includes
-#include "H_Parameters.h"
 #include "H_TransportMatrices.h"
 #include "H_Aperture.h"
@@ -35,5 +27,5 @@
 
 /// called by the constructors
-void H_OpticalElement::init(const string& nameE, const int typeE, const double s, const double k, const double l) {
+void H_OpticalElement::init(const string nameE, const int typeE, const double s, const double k, const double l, H_Aperture* the_app) {
 	// this is called by the constructors
 	// must be in public section !
@@ -48,33 +40,34 @@
  	element_length = l;
  	type = typeE;
-	element_mat.ResizeTo(MDIM,MDIM);
- 	element_mat = driftmat(l);
-
-	// do NOT use setAperture for the initialisation ! there are protections there
+ 	element_mat = new TMatrix(MDIM,MDIM);
+	setAperture(the_app);
 	
-	if(element_length<0)  { if(VERBOSE) cout<<"<H_OpticalElement> ERROR : Interpenetration of elements !"<<endl; }
-	if(element_length==0) { if(VERBOSE) cout<<"<H_OpticalElement> WARNING : 0-length element ! (" << name << ") " << " at " << fs << endl; }
+	if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+	if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length element ! (" << name << ") " << " at " << fs << endl; }
 	betax =0;
 	betay =0;
 }
 
-H_OpticalElement::H_OpticalElement() : element_aperture(new H_Aperture()) {
-	init("",DRIFT,0.,0.,0.1);
+H_OpticalElement::H_OpticalElement() {
+	H_Aperture* the_app = new H_Aperture();
+	init("",DRIFT,0.,0.,0.1,the_app);
 }
 
-H_OpticalElement::H_OpticalElement(const string& nameE, const int typeE, const double s, const double k, const double l) : element_aperture(new H_Aperture()) {
-	init(nameE,typeE,s,k,l);
+H_OpticalElement::H_OpticalElement(const string nameE, const int typeE, const double s, const double k, const double l) {
+	H_Aperture* the_app = new H_Aperture();
+	init(nameE,typeE,s,k,l,the_app);
 }
 
-H_OpticalElement::H_OpticalElement(const string& nameE, const int typeE, const double s, const double k, const double l, H_Aperture* the_app) : element_aperture(the_app->clone()) {
-	init(nameE,typeE,s,k,l);
+H_OpticalElement::H_OpticalElement(const string nameE, const int typeE, const double s, const double k, const double l, H_Aperture* the_app) {
+	init(nameE,typeE,s,k,l,the_app);
 }
 
-H_OpticalElement::H_OpticalElement(const int typeE, const double s, const double k, const double l, H_Aperture* the_app) : element_aperture(the_app->clone()) {
-	init("",typeE,s,k,l);
+H_OpticalElement::H_OpticalElement(const int typeE, const double s, const double k, const double l, H_Aperture* the_app) {
+	init("",typeE,s,k,l,the_app);
 }
 
-H_OpticalElement::H_OpticalElement(const int typeE, const double s, const double k, const double l) : element_aperture(new H_Aperture()) {
-	init("",typeE,s,k,l);
+H_OpticalElement::H_OpticalElement(const int typeE, const double s, const double k, const double l) {
+	H_Aperture* the_app = new H_Aperture();
+	init("",typeE,s,k,l,the_app);
 }
 
@@ -92,7 +85,6 @@
 	name = el.name;
 	typestring = el.typestring;
-	element_mat.ResizeTo(MDIM,MDIM);
-	element_mat = el.element_mat;
-	element_aperture = el.element_aperture->clone();
+	element_mat = new TMatrix(*(el.element_mat));
+	element_aperture = new H_Aperture(*(el.element_aperture));
 }
 
@@ -104,6 +96,6 @@
         xpos = el.xpos;
         ypos = el.ypos;
-	txpos = el.txpos;
-	typos = el.typos;
+		txpos = el.txpos;
+		typos = el.typos;
         betax = el.betax;
         betay = el.betay;
@@ -111,71 +103,56 @@
         name = el.name;
         typestring = el.typestring;
-	element_mat.ResizeTo(MDIM,MDIM);
-        element_mat = el.element_mat;
-        element_aperture = el.element_aperture->clone();
+	delete element_mat;
+	delete element_aperture;
+        element_mat = new TMatrix(*(el.element_mat));
+        element_aperture = new H_Aperture(*(el.element_aperture));
 	return *this;
 }
 
-void H_OpticalElement::setAperture(const H_Aperture* ap) {
-	// do NOT use setAperture in your constructor, as element_aperture is not initialized
-	// this function do not take into account ap if ap=0
-	// do nothing if element_mat = ap
-		if (!ap) {cout << "<H_OpticalElement> Trying to set an empty pointer for the aperture ! Nothing done.\n"; return;}
-		if (element_aperture != ap) {
-			delete element_aperture;
-			element_aperture = ap->clone();
-		}
+void H_OpticalElement::setAperture(H_Aperture * ap) {
+//	element_aperture = const_cast<H_Aperture*>(ap);
+	element_aperture = ap;
 	return;
 }
-/*
-void H_OpticalElement::setAperture(H_Aperture* ap) {
-        // do NOT use setAperture in your constructor, as element_aperture is not initialized
-        // this function do not take into account ap if ap=0
-        // do nothing if element_mat = ap
-                if (!ap) {cout << "<H_OpticalElement> Trying to set an empty pointer for the aperture ! Nothing done.\n"; return;}
-                if (element_aperture != ap) {
-                        delete element_aperture;
-                        element_aperture = ap; //->clone();
-                }
-        return;
-}
-*/
 
-std::ostream& operator<< (std::ostream& os, const H_OpticalElement& el) {
-        os << el.typestring << el.name << "\t at s = " << el.fs << "\t length = "<< el.element_length;
-        if(el.fk!=0) os <<"\t strength = " << el.fk;
-        if(el.element_aperture->getType()!=NONE) {
-                os << *(el.element_aperture) << endl;
-        }
-        os<<endl;
-        if(el.element_length<0 && VERBOSE) 
-		os <<"<H_OpticalElement> ERROR : Interpenetration of elements !"<<endl; 
-        else if(el.element_length==0 && VERBOSE) 
-		os <<"<H_OpticalElement> WARNING : 0-length "<< el.typestring << " !" << endl;
-  return os;
+void H_OpticalElement::printProperties() const {
+		cout << typestring;
+		cout << name;
+		cout <<"\t at s = " << fs;
+		cout <<"\t length = "<< element_length;
+		if(fk!=0) cout <<"\t strength = " << fk;
+		if(element_aperture->getType()!=NONE) { 
+			cout <<"\t aperture type = " << element_aperture->getTypeString();
+			element_aperture->printProperties();			
+		}
+	
+		cout<<endl;
+		if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+		if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length "<< typestring << " !" << endl; }
+
+ return;
 }
 
 void H_OpticalElement::showMatrix() const {
-	printMatrix(element_mat);
+		printMatrix(element_mat);
 	return;
 }
 
 void H_OpticalElement::drawAperture() const {
-	element_aperture->draw(1);
+	element_aperture->draw();
 	return;
 }
 
-TMatrix H_OpticalElement::getMatrix() {
-	setMatrix(0,MP,1);
-	return element_mat;
+TMatrix H_OpticalElement::getMatrix() const {
+	return *element_mat;
 }
 
-TMatrix H_OpticalElement::getMatrix(const float eloss, const float p_mass, const float p_charge) {
+TMatrix H_OpticalElement::getMatrix(const float eloss, const float p_mass, const float p_charge) const {
 	setMatrix(eloss,p_mass,p_charge);
-	return element_mat;
+	return *element_mat;
 }
 
 void H_OpticalElement::draw(const float meight, const float height) const{
-	/// @param meight is the minimal extend of the graph
+/*	/// @param meight is the minimal extend of the graph
 	/// @param height is the maximal extend of the graph
 	float x1 = getS();
@@ -188,128 +165,5 @@
 	cur_box->SetFillColor((int)getType());
 	cur_box->Draw();
+*/
 }
 
-TVectorD H_OpticalElement::getHitPosition(const TVectorD& init_pos, const double energy_loss, const double mp, const double qp) {
-	if(!element_length) {
-		// cout<<"O-length element ("<<getName()<<"), should not appear here !"<<endl;
-		return init_pos;
-	}
-	// some declarations
-	bool inside = false;
-	double vec[MDIM] = {init_pos[INDEX_X]/URAD,  tan(init_pos[INDEX_TX]/URAD),
-                            init_pos[INDEX_Y]/URAD,  tan(init_pos[INDEX_TY]/URAD), 
-			    -energy_loss,            1};
-	TMatrixD mat_init(1,MDIM,vec);
-	TMatrixD mat_min(1,MDIM,vec);
-	TMatrixD mat_max(1,MDIM,vec);
-	TMatrixD mat_stop(1,MDIM,vec);
-	H_OpticalElement* temp_el = clone();
-	// initialasing boundaries
-	double min_pos = 0;
-	double max_pos = element_length/2.;
-	double max_old = element_length/2.;
-	// number of iterations 
-	// (idea : fix precision instead of number of iterations + add security)
-	// (idea : interpolate between max and min and give the error)
-	const int N = 10;
-	// starting search loop
-	for(int i = 0; i < N; i++) {
-		// fixing position to be investigated 
-		temp_el->setLength(max_pos);
-		// initialising the vector at the initial vector + possible shift/tilt
-		mat_max[0][0] = mat_init[0][0] - temp_el->getX();
-		mat_max[0][1] = mat_init[0][1] - tan(temp_el->getTX());
-		mat_max[0][2] = mat_init[0][2] - temp_el->getY();
-		mat_max[0][3] = mat_init[0][3] - tan(temp_el->getTY());
-		// propagating
-		mat_max *= temp_el->getMatrix(energy_loss,mp,qp);
-		// compensating for the previously stated shifts/tilts
-		mat_max[0][0] = mat_max[0][0] + temp_el->getX();
-		mat_max[0][1] = mat_max[0][1] + tan(temp_el->getTX());
-		mat_max[0][2] = mat_max[0][2] + temp_el->getY();
-		mat_max[0][3] = mat_max[0][3] + tan(temp_el->getTY());
-		// fixing new boundaries 
-		if(temp_el->isInside(mat_max.GetMatrixArray()[0]*URAD,mat_max.GetMatrixArray()[2]*URAD)) {
-			max_old = max_pos;
-			max_pos = max_pos + (max_pos - min_pos)/2.;
-			min_pos = max_old;
-			inside = true;
-		} else {
-			max_pos = min_pos + (max_pos - min_pos)/2.;
-			inside = false;
-		}
-		// end of loop
-	}
-	// if it passes at the last iteration, choosing the other rangeÂ²
-	if(inside) min_pos = max_old;
-	// here the interpolation method : now we are sure that the intercept is between min_pos and max_pos
-	// getting vector at min_pos (for first boundary) :
-	bool precision_estimate = false;
-	if(precision_estimate) {
-		temp_el->setLength(min_pos);
-		mat_min[0][0] = mat_init[0][0] - temp_el->getX();
-		mat_min[0][1] = mat_init[0][1] - tan(temp_el->getTX());
-		mat_min[0][2] = mat_init[0][2] - temp_el->getY();
-		mat_min[0][3] = mat_init[0][3] - tan(temp_el->getTY());
-		mat_min *= temp_el->getMatrix(energy_loss,mp,qp);
-		mat_min[0][0] = mat_min[0][0] + temp_el->getX();
-   		mat_min[0][1] = mat_min[0][1] + tan(temp_el->getTX());
- 	  	mat_min[0][2] = mat_min[0][2] + temp_el->getY();
-		mat_min[0][3] = mat_min[0][3] + tan(temp_el->getTY());
-		mat_min[0][4] = min_pos + init_pos[4];
-		// getting vector at max_pos (for second boundary) :
-		temp_el->setLength(max_pos);
-	   	mat_max[0][0] = mat_init[0][0] - temp_el->getX();
-		mat_max[0][1] = mat_init[0][1] - tan(temp_el->getTX());
-		mat_max[0][2] = mat_init[0][2] - temp_el->getY();
-		mat_max[0][3] = mat_init[0][3] - tan(temp_el->getTY());
-		mat_max *= temp_el->getMatrix(energy_loss,mp,qp);
-		mat_max[0][0] = mat_max[0][0] + temp_el->getX();
-		mat_max[0][1] = mat_max[0][1] + tan(temp_el->getTX());
-		mat_max[0][2] = mat_max[0][2] + temp_el->getY();
-		mat_max[0][3] = mat_max[0][3] + tan(temp_el->getTY());
-		mat_max[0][4] = max_pos + init_pos[4];
-	}
-	// getting vector in the middle (for estimate) :
-	temp_el->setLength((max_pos+min_pos)/2.);
-	mat_stop[0][0] = mat_init[0][0] - temp_el->getX();
-	mat_stop[0][1] = mat_init[0][1] - tan(temp_el->getTX());
-	mat_stop[0][2] = mat_init[0][2] - temp_el->getY();
-	mat_stop[0][3] = mat_init[0][3] - tan(temp_el->getTY());
-	mat_stop *= temp_el->getMatrix(energy_loss,mp,qp);
-	mat_stop[0][0] = mat_stop[0][0] + temp_el->getX();
-	mat_stop[0][1] = mat_stop[0][1] + tan(temp_el->getTX());
-	mat_stop[0][2] = mat_stop[0][2] + temp_el->getY();
-	mat_stop[0][3] = mat_stop[0][3] + tan(temp_el->getTY());
-	mat_stop[0][4] = (max_pos+min_pos)/2. + init_pos[4];
-
-	double xys[LENGTH_VEC];
-	xys[INDEX_X]=  mat_stop[0][0]*URAD;
-	xys[INDEX_TX]= atan(mat_stop[0][1])*URAD;
-	xys[INDEX_Y]=  mat_stop[0][2]*URAD;
-	xys[INDEX_TY]= atan(mat_stop[0][3])*URAD;
-	xys[INDEX_S]=  mat_stop[0][4] ;
-	TVectorD temp_vec(LENGTH_VEC,xys);
-
-	if(precision_estimate) {
-		cout<<"--- Results and precision estimates ---"<<endl;
-		cout<<"\t Stopping element : "<<getName()<<endl;
-		cout<<"\t hit point s  : "<<mat_stop[0][4]<<" m +- "<<(mat_max[0][4]-mat_stop[0][4])*1000.<<" mm"<<endl;
-		cout<<"\t hit point x  : "<<mat_stop[0][0]*URAD;
-		cout<<" + "<<fabs(((mat_min[0][0]<mat_max[0][0])?(mat_max[0][0]-mat_stop[0][0])*URAD:(mat_min[0][0]-mat_stop[0][0])*URAD));
-		cout<<" - "<<fabs(((mat_min[0][0]<mat_max[0][0])?(mat_stop[0][0]-mat_min[0][0])*URAD:(mat_stop[0][0]-mat_max[0][0])*URAD))<<" Âµm"<<endl;
-		cout<<"\t hit point y  : "<<mat_stop[0][2]*URAD;
-		cout<<" + "<<fabs(((mat_min[0][0]<mat_max[0][2])?(mat_max[0][2]-mat_stop[0][2])*URAD:(mat_min[0][2]-mat_stop[0][2])*URAD));
-		cout<<" - "<<fabs(((mat_min[0][0]<mat_max[0][2])?(mat_stop[0][2]-mat_min[0][2])*URAD:(mat_stop[0][2]-mat_max[0][2])*URAD))<<" Âµm"<<endl;
-		cout<<"\t hit point tx : "<<mat_stop[0][1]*URAD;
-		cout<<" + "<<fabs(((mat_min[0][0]<mat_max[0][1])?(mat_max[0][1]-mat_stop[0][1])*URAD:(mat_min[0][1]-mat_stop[0][1])*URAD));
-		cout<<" - "<<fabs(((mat_min[0][0]<mat_max[0][1])?(mat_stop[0][1]-mat_min[0][1])*URAD:(mat_stop[0][1]-mat_max[0][1])*URAD))<<" Âµrad"<<endl;
-		cout<<"\t hit point ty : "<<mat_stop[0][3]*URAD;
-		cout<<" + "<<fabs(((mat_min[0][0]<mat_max[0][3])?(mat_max[0][3]-mat_stop[0][3])*URAD:(mat_min[0][3]-mat_stop[0][3])*URAD));
-		cout<<" - "<<fabs(((mat_min[0][0]<mat_max[0][3])?(mat_stop[0][3]-mat_min[0][3])*URAD:(mat_stop[0][3]-mat_max[0][3])*URAD))<<" Âµrad"<<endl;
-
-	}
-
-	delete temp_el;
-	return temp_vec;
-}
Index: external/Hector/H_OpticalElement.h
===================================================================
--- external/Hector/H_OpticalElement.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_OpticalElement.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_OpticalElement_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_OpticalElement.h
@@ -33,5 +26,4 @@
 // ROOT #includes
 #include "TMatrix.h"
-#include "TVectorD.h"
 
 // local #includes
@@ -43,5 +35,17 @@
 
 	// type #defines
-enum {DRIFT=1, RDIPOLE, SDIPOLE, VQUADRUPOLE, HQUADRUPOLE, VKICKER, HKICKER, RCOLLIMATOR, ECOLLIMATOR, CCOLLIMATOR, RP, IP, MARKER};
+#define DRIFT        1
+#define RDIPOLE      2
+#define SDIPOLE      3
+#define VQUADRUPOLE  4
+#define HQUADRUPOLE  5
+#define VKICKER      6
+#define HKICKER      7
+#define RCOLLIMATOR  8
+#define ECOLLIMATOR  9
+#define CCOLLIMATOR 10
+#define RP          11
+#define IP          12
+#define MARKER      13
 
 	// typestring[30] #defines
@@ -65,17 +69,17 @@
 	public:
         ///     init method for constructors
-                void init(const string&, const int , const double , const double , const double);
+                void init(const string, const int , const double , const double , const double, H_Aperture*);
 		/// Constructors and destructor
 		//@{
-		H_OpticalElement(const string&, const int, const double, const double, const double, H_Aperture*);
+		H_OpticalElement(const string, const int, const double, const double, const double, H_Aperture*);
 		H_OpticalElement(const int, const double, const double, const double, H_Aperture*);
-		H_OpticalElement(const string&, const int, const double, const double, const double);
+		H_OpticalElement(const string, const int, const double, const double, const double);
 		H_OpticalElement(const int, const double, const double, const double);
 		H_OpticalElement();
 		H_OpticalElement(const H_OpticalElement&);
-		virtual ~H_OpticalElement() { delete element_aperture;};
+	        virtual ~H_OpticalElement() {delete element_mat; delete element_aperture;};
 		//@}
 		///     Prints the element features
-	        virtual void printProperties() const { cout << *this; return;};
+	        virtual void printProperties() const ;
 		///     Shows the element transport matrix
 	        void showMatrix() const ;
@@ -83,9 +87,9 @@
 	        void drawAperture() const ;
 		///     Sets the aperture of the element
-		void setAperture(const H_Aperture*);
+		void setAperture(H_Aperture *);
 		///     Ordering operator acting on the s coordinate
-		inline bool operator>(const H_OpticalElement& tocomp) const {return ( fs>tocomp.getS() ); };
+		inline bool operator>(const H_OpticalElement tocomp) const {if(fs>tocomp.getS()) { return true; } else { return false; }};
 		///     Ordering operator acting on the s coordinate
-		inline bool operator<(const H_OpticalElement& tocomp) const {return ( fs<tocomp.getS() ); };
+		inline bool operator<(const H_OpticalElement tocomp) const {if(fs<tocomp.getS()) { return true; } else { return false; }};
 		/// 	Copy operator
 		H_OpticalElement& operator=(const H_OpticalElement&); 
@@ -93,5 +97,4 @@
 		//@{
 		inline void setS(const double new_s) {fs=new_s;};
-		inline void setLength(const double new_l) { element_length = new_l;};
 		inline void setX(const double new_pos) {
 		        /// @param new_pos in [m]
@@ -136,9 +139,9 @@
 		///     Returns the element transport matrix
 		//@{
-		TMatrix getMatrix() ;
-		TMatrix getMatrix(const float, const float, const float) ;
+		TMatrix getMatrix() const;
+		TMatrix getMatrix(const float, const float, const float) const;
 		//@}
 		///     Returns the element aperture
-		H_Aperture* getAperture() const {return element_aperture;};
+		H_Aperture * getAperture() const {return element_aperture;};
 		///	Sets the beta functions
 		//@{
@@ -172,6 +175,4 @@
                 inline double getRelY() const {return rely;};
                 //@}
-		virtual H_OpticalElement* clone() const { return new H_OpticalElement();};
-		TVectorD getHitPosition(const TVectorD& , const double, const double, const double);
 
 
@@ -205,11 +206,9 @@
 		virtual void setTypeString() {return;};
 		/// Optical element transport matrix.
-		virtual void setMatrix(const float, const float, const float) { cout<<"dummy setmatrix"<<endl; return;};
+	    	virtual void setMatrix(const float, const float, const float) const {return;};
 		/// Optical element transport matrix.
- 		TMatrix element_mat;
-		/// Optical element aperture. 
-	    	H_Aperture* element_aperture;
-
-	friend std::ostream& operator<< (std::ostream& os, const H_OpticalElement& el);
+ 		TMatrix * element_mat;
+		/// Optical element aperture.
+	    	H_Aperture * element_aperture;
 };
 
Index: external/Hector/H_Parameters.cc
===================================================================
--- external/Hector/H_Parameters.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Parameters.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Parameters.cc
Index: external/Hector/H_Parameters.h
===================================================================
--- external/Hector/H_Parameters.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Parameters.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _Hector_parameters_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Parameters.h
@@ -25,58 +18,80 @@
 /// Units : angles [\f$ \mu \f$rad], distances [\f$ \mu \f$m], energies [GeV], c=[1].
 
-#include <cmath>
-
 /* from physics and maths */
    /// proton mass [GeV]
 const double MP=0.93827;
    /// proton charge [e]
-const double QP=1.;
+const double QP=1;
+   /// pi
+#define PI 3.14159265359
    /// conversion factor for \f$\mu\f$rad <-> rad
-const double URAD=1000000.;
+#define URAD 1000000.
+   /// in thx = thx* / 3 <==> thx* = THX thx
+#define THX 3.86 
+   /// in dy = 10 thy*   <==> thy* = dy / THY
+#define THY 51.4       
 
 /* beam parameters */
    /// beam nominal energy in GeV
+//#define BE  7000.
 const double BE=7000.;
    /// beam energy divergence, in GeV
-const double SBE=0.79;
+#define SBE 0.79
    /// beam nominal energy in TeV
-const double BETEV=7.;
+#define BETEV 7.
    /// beam S @ IP
-const double PS=0.;
+#define PS 0.
    /// beam X @ IP
-const double PX=-500.;    
+#define PX  -500.      
    /// beam Y @ IP
-const double PY=0.;
+#define PY  0.      
    /// beam longitudinal dispersion
-const double SS=0.;
+#define SS 0.
    /// beam lateral width SX @ IP
-const double SX=16.63;
+#define SX  16.63
+// #define SX  0.      
    /// beam lateral width SY @ IP
-const double SY=16.63;
+#define SY  16.63
+// #define SY 0.
    /// beam transverse direction angle TX @ IP
-const double TX=0.;
+#define TX 0.
    /// beam transverse direction angle TY @ IP
-const double TY=0.;
+#define TY 0.      
    /// beam angular divergence STX @ IP
-const double STX=30.23;
+//#define STX 0.
+#define STX 30.23      
    /// beam angular divergence STY @ IP
-const double STY=30.23;
+//#define STY 0.
+#define STY 30.23      
+   /// beam dispersion
+//#define D   120000.
+const double D=120000.;
 	/// half crossing angle at IP [\f$ \mu \f$RAD]
-const double CRANG=142.5;
+#define CRANG 142.5 
 
-// local defines, used in H_BeamParticle & H_OpticalElements
-enum {INDEX_X=0, INDEX_TX, INDEX_Y, INDEX_TY, INDEX_S, LENGTH_VEC};
-// (x,theta_x,y,theta_y,s)
-
-/// include Pythia libraries ? (not included on some ROOT installations)
-//#define _include_pythia_
-
-const unsigned int TM = 0; // not used anymore. left for backward compatibility
-const unsigned int AM = 1; // not used anymore. left for backward compatibility
-
+/* roman pots parameters */
+   /// granularity in X position
+#define GRANPOSX 5.
+   /// granularity in Y position
+#define GRANPOSY 5.
+   /// granularity in X angle
+#define GRANANGX 10.
+   /// granularity in Y angle
+#define GRANANGY 10.
+   /// Distance between rp's
+#define DISTRP 4000000.
+   /// RP resolution in X, for smearing
+#define RESX 10.
+   /// RP resolution in Y, for smearing
+#define RESY 10.
+   /// Radius of the hole in the RP
+#define RADIUS 1000.
 
 /* display parameters */
    /// Verbose mode ?
-const bool VERBOSE=false; 
+#define VERBOSE 0 
+
+/// include Pythia libraries ? (not included on some ROOT installations) 
+//#define _include_pythia_
 
 #endif
Index: external/Hector/H_Quadrupole.cc
===================================================================
--- external/Hector/H_Quadrupole.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Quadrupole.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Quadrupole.cc
@@ -25,5 +18,4 @@
 	// needed for call from H- and V-Quadrupoles constructor
 	// must be in public section
-		element_mat.ResizeTo(MDIM,MDIM);
 		setTypeString();
 		setMatrix(0,MP,QP);
@@ -31,12 +23,17 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_Quadrupole& el) {
-	os << el.typestring  << el.name  << "\t at s = " << el.fs << "\t length = " << el.element_length << "\t k1 = " << el.fk <<endl;
-        if(el.element_aperture->getType()!=NONE) {
-        	os << *(el.element_aperture) << endl;
+void H_Quadrupole::printProperties() const{
+	cout << typestring;
+	cout << name;
+	cout << "\t at s = " << fs;
+	cout << "\t length = " << element_length;
+	cout << "\t k1 = " << fk;
+	cout<<endl;
+        if(element_aperture->getType()!=NONE) {
+        	cout <<"\t aperture type = " << element_aperture->getTypeString();
+                element_aperture->printProperties();
 	}
 
-	if(el.element_length<0 && VERBOSE) os<<"<H_Quadrupole> ERROR : Interpenetration of elements !"<<endl; 
-	else if(el.element_length==0 && VERBOSE) os<<"<H_Quadrupole> WARNING : 0-length "<< el.typestring << " !" << endl; 
-   return os;
+	if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+	if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length "<< typestring << " !" << endl; }
 }
Index: external/Hector/H_Quadrupole.h
===================================================================
--- external/Hector/H_Quadrupole.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_Quadrupole.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_Quadrupole_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_Quadrupole.h
@@ -34,16 +27,14 @@
 		H_Quadrupole():H_OpticalElement() {}
 		H_Quadrupole(const int dtype, const double s, const double k, const double l) : H_OpticalElement(dtype,s,k,l) {}
-		H_Quadrupole(const string& nameE, const int dtype, const double s, const double k, const double l) : H_OpticalElement(nameE,dtype,s,k,l) {}
-		virtual ~H_Quadrupole() {};
+		H_Quadrupole(const string nameE, const int dtype, const double s, const double k, const double l) : H_OpticalElement(nameE,dtype,s,k,l) {}
+		virtual ~H_Quadrupole() {return;};
 	//@}	
-		virtual H_Quadrupole* clone() const =0 ;
-		virtual void printProperties() const { cout << *this; return;};
+		virtual void printProperties() const;
 		void init();
 
  	protected:
 		virtual void setTypeString() =0;
-		virtual void setMatrix(const float, const float, const float) = 0;
+		virtual void setMatrix(const float, const float, const float) const =0;
 	   	
-	friend std::ostream& operator<< (std::ostream& os, const H_Quadrupole& el);
 };
 
Index: external/Hector/H_RecRPObject.cc
===================================================================
--- external/Hector/H_RecRPObject.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RecRPObject.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,24 +1,24 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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.cc
-/// \brief Class performing the reconstruction based on forward detector measurements
-///
-/// Units : angles [rad], distances [m], energies [GeV], c=[1].
+/// \brief Classes aiming at reconstruction particle properties
+
+// C++ #includes
+#include <iostream>
+#include <iomanip>
+
+// ROOT #includes
+//#include "TGraph.h"
+//#include "TF1.h"
+//#include "TCanvas.h"
 
 // local #includes
@@ -28,344 +28,326 @@
 using namespace std;
 
-// reconstruction class for forward detectors.
-// Featuring the brand-new reco method from the 
-// louvain group !
-
-#define MEGA 1000000.
-
-H_RecRPObject::H_RecRPObject(): emin(0), emax(-1), x1(0), x2(0), y1(0), y2(0), s1(0), s2(0), 
-				txip(NOT_YET_COMPUTED), tyip(NOT_YET_COMPUTED), energy(NOT_YET_COMPUTED), q2(NOT_YET_COMPUTED), pt(NOT_YET_COMPUTED), 
-				thebeam(new H_AbstractBeamLine()),
-				f_1(new TF1("f_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				f_2(new TF1("f_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				g_1(new TF1("g_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				g_2(new TF1("g_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				d_1(new TF1("d_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				d_2(new TF1("d_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				k_1(new TF1("k_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				k_2(new TF1("k_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				l_1(new TF1("l_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				l_2(new TF1("l_2","[0] + [1]*x + [2]*x*x ",emin,emax)) 
-{}
-
-H_RecRPObject::H_RecRPObject(const float ss1, const float ss2, const H_AbstractBeamLine* beam) : emin(0), emax(-1), x1(0), x2(0), y1(0), y2(0), s1(ss1), s2(ss2), 
-				txip(NOT_YET_COMPUTED), tyip(NOT_YET_COMPUTED), energy(NOT_YET_COMPUTED), q2(NOT_YET_COMPUTED), pt(NOT_YET_COMPUTED), 
-				thebeam(beam->clone()),
-				f_1(new TF1("f_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				f_2(new TF1("f_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				g_1(new TF1("g_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				g_2(new TF1("g_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				d_1(new TF1("d_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				d_2(new TF1("d_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				k_1(new TF1("k_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				k_2(new TF1("k_2","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				l_1(new TF1("l_1","[0] + [1]*x + [2]*x*x ",emin,emax)), 
-				l_2(new TF1("l_2","[0] + [1]*x + [2]*x*x ",emin,emax))
-	{if(ss1==ss2) cout<<"<H_RecRPObject> WARNING : detectors are on same position"<<endl;
-}
-
-
-H_RecRPObject::H_RecRPObject(const float ss1, const float ss2, const H_AbstractBeamLine& beam) : emin(0), emax(-1), x1(0), x2(0), y1(0), y2(0), s1(ss1), s2(ss2),
-                                txip(NOT_YET_COMPUTED), tyip(NOT_YET_COMPUTED), energy(NOT_YET_COMPUTED), q2(NOT_YET_COMPUTED), pt(NOT_YET_COMPUTED),
-                                thebeam(beam.clone()),
-                                f_1(new TF1("f_1","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                f_2(new TF1("f_2","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                g_1(new TF1("g_1","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                g_2(new TF1("g_2","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                d_1(new TF1("d_1","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                d_2(new TF1("d_2","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                k_1(new TF1("k_1","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                k_2(new TF1("k_2","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                l_1(new TF1("l_1","[0] + [1]*x + [2]*x*x ",emin,emax)),
-                                l_2(new TF1("l_2","[0] + [1]*x + [2]*x*x ",emin,emax))
-        {if(ss1==ss2) cout<<"<H_RecRPObject> WARNING : detectors are on same position"<<endl;
-}
-
-
-H_RecRPObject::H_RecRPObject(const H_RecRPObject& r):
-   emin(r.emin), emax(r.emax), x1(r.x1), x2(r.x2), y1(r.y1), y2(r.y2), s1(r.s1), s2(r.s2),
-   txip(r.txip), tyip(r.tyip), energy(r.energy), q2(r.q2),  pt(r.pt), 
-   //thebeam(r.thebeam->clone()),
-   thebeam(new H_AbstractBeamLine(*(r.thebeam))),
-   f_1(new TF1(*(r.f_1))),  f_2(new TF1(*(r.f_2))),  g_1(new TF1(*(r.g_1))),  g_2(new TF1(*(r.g_2))),
-   d_1(new TF1(*(r.d_1))),  d_2(new TF1(*(r.d_2))),  k_1(new TF1(*(r.k_1))),  k_2(new TF1(*(r.k_2))),
-   l_1(new TF1(*(r.l_1))),  l_2(new TF1(*(r.l_2)))
- {}
+H_RecRPObject::H_RecRPObject() {
+	x1 = 0.;
+	x2 = 0.;
+	y1 = 0.;
+	y2 = 0.;
+	s1 = 0.;
+	s2 = 0.;
+	corr1_TM = 0;
+	corr2_TM = 0;
+	corr1_AM = 0;
+	corr2_AM = 0;
+	thx = NOT_YET_COMPUTED;
+	thy = NOT_YET_COMPUTED;
+	x0  = NOT_YET_COMPUTED;
+	y0  = NOT_YET_COMPUTED;
+	energy = NOT_YET_COMPUTED;
+	virtuality = NOT_YET_COMPUTED;
+	matrp1 = new TMatrix(MDIM,MDIM);
+	matrp2 = new TMatrix(MDIM,MDIM);
+	thebeam = new H_AbstractBeamLine();
+}
+
+H_RecRPObject::H_RecRPObject(const float S1, const float S2, const H_AbstractBeamLine& beamline) {
+	x1 = 0;
+	x2 = 0;
+	y1 = 0;
+	y2 = 0;
+	s1 = S1;
+	s2 = S2;
+	thx = NOT_YET_COMPUTED;
+	thy = NOT_YET_COMPUTED;
+	x0  = NOT_YET_COMPUTED;
+	y0  = NOT_YET_COMPUTED;
+	energy = NOT_YET_COMPUTED;
+	virtuality = NOT_YET_COMPUTED;
+//	matrp1 = new TMatrix(MDIM,MDIM);
+//	matrp2 = new TMatrix(MDIM,MDIM);
+	thebeam = new H_AbstractBeamLine(beamline);
+	H_RomanPot * rp1 = new H_RomanPot("rp1",s1,0);
+	thebeam->add(rp1);
+	H_RomanPot * rp2 = new H_RomanPot("rp2",s2,0);
+	thebeam->add(rp2);
+	matrp1 = new TMatrix(*(thebeam->getPartialMatrix("rp1",0.,MP,QP)));
+	matrp2 = new TMatrix(*(thebeam->getPartialMatrix("rp2",0.,MP,QP)));
+
+	corr1_TM = getECorrectionFactor(0,TM);
+	corr2_TM = getECorrectionFactor(1,TM);
+	corr1_AM = getECorrectionFactor(0,AM);
+	corr2_AM = getECorrectionFactor(1,AM);
+//	cout << corr1_TM << " " << corr2_TM << endl;
+//	cout << corr1_AM << " " << corr2_AM << endl;
+}
+
+H_RecRPObject::H_RecRPObject(const H_RecRPObject& r) {
+	x1 = r.x1;
+	x2 = r.x2;
+	y1 = r.y1;
+	y2 = r.y2;
+	s1 = r.s1;
+	s2 = r.s2;
+	x0 = r.x0;
+	y0 = r.y0;
+	thx = r.thx;
+	thy = r.thy;
+	energy = r.energy;
+	virtuality = r.virtuality;
+	matrp1 = new TMatrix(*(r.matrp1));
+	matrp2 = new TMatrix(*(r.matrp2));
+	corr1_TM = r.corr1_TM;
+	corr2_TM = r.corr2_TM;
+	corr1_AM = r.corr1_AM;
+	corr2_AM = r.corr2_AM;
+	thebeam = new H_AbstractBeamLine(*(r.thebeam));
+}
 
 H_RecRPObject& H_RecRPObject::operator=(const H_RecRPObject& r) {
-  if (this == &r) return *this;
-   emin = r.emin, emax = r.emax;
-   x1 = r.x1;   x2 = r.x2; 
-   y1 = r.y1;   y2 = r.y2; 
-   s1 = r.s1;   s2 = r.s2;
-   txip= r.txip; tyip=r.tyip;
-   energy= r.energy; q2= r.q2;  pt= r.pt;
-   //thebeam = r.thebeam->clone();
-   thebeam = new H_AbstractBeamLine(*(r.thebeam));
-   f_1 = new TF1(*(r.f_1));
-   f_2 = new TF1(*(r.f_2));
-   g_1 = new TF1(*(r.g_1));
-   g_2 = new TF1(*(r.g_2));
-   d_1 = new TF1(*(r.d_1));
-   d_2 = new TF1(*(r.d_2));
-   k_1 = new TF1(*(r.k_1));
-   k_2 = new TF1(*(r.k_2));
-   l_1 = new TF1(*(r.l_1));
-   l_2 = new TF1(*(r.l_2));
-  return *this;
-}
-
-void H_RecRPObject::initialize() {
-	// this method sets the functions that will be used for reco later
-	// it should be used only once per beamline after the energy range was fixed. 
-	// copying beamline and adding detectors
+	if(this==&r) return *this;
+	x1 = r.x1;
+	x2 = r.x2;
+	y1 = r.y1;
+	y2 = r.y2;
+	s1 = r.s1;
+	s2 = r.s2;
+	x0 = r.x0;
+	y0 = r.y0;
+	thx = r.thx;
+	thy = r.thy;
+	energy = r.energy;
+	virtuality = r.virtuality;
+	matrp1 = new TMatrix(*(r.matrp1));
+	matrp2 = new TMatrix(*(r.matrp2));
+	corr1_TM = r.corr1_TM;
+	corr2_TM = r.corr2_TM;
+	corr1_AM = r.corr1_AM;
+	corr2_AM = r.corr2_AM;
+	thebeam = new H_AbstractBeamLine(*(r.thebeam));
+	return *this;
+}
+
+float H_RecRPObject::getECorrectionFactor(const unsigned int facn, const unsigned int method) {
+/*
+ * commented out because CMSSW does not want any TGraph/TCanvas/TFit
+ *
+ * to be fixed !
+ * X.R. 07/05/2009
+ *
+	float beta1 = ((thebeam->getPartialMatrix("rp1",0,MP,QP))->GetMatrixArray())[1*MDIM];
+	float beta2 = ((thebeam->getPartialMatrix("rp2",0,MP,QP))->GetMatrixArray())[1*MDIM];
+	float disp1 = ((thebeam->getPartialMatrix("rp1",0,MP,QP))->GetMatrixArray())[4*MDIM]*URAD;
+	float disp2 = ((thebeam->getPartialMatrix("rp2",0,MP,QP))->GetMatrixArray())[4*MDIM]*URAD;
+	const int n = 20; //using 20 points to get a good quadratic fit
+	float ee[n], rece[n];
+
+	for(int i = 0; i < n; i++) {
+		ee[i] = 10 + i*200./((float)n-1);
+		H_BeamParticle p1;
+		p1.emitGamma(ee[i],0.);
+		p1.computePath(thebeam,1);
+		p1.propagate(s1);
+		float x1 = p1.getX();
+		p1.propagate(s2);
+		float x2 = p1.getX();
+		switch (method) {
+			case TM: { rece[i] = -x1/disp1; }; break;
+			case AM: { rece[i] = -(beta2*x1-beta1*x2)/(beta2*disp1-beta1*disp2); }; break;
+			case PM: { rece[i] = -x1/disp1; cout<<"this method has not been implemented, using trivial reconstruction"<<endl; } break;
+			default: { rece[i] = -(beta2*x1-beta1*x2)/(beta2*disp1-beta1*disp2); }; break;
+		}
+		ee[i] = ee[i] - rece[i];
+	}
+	char mytitle[50];
+	sprintf(mytitle,"c_%d",method);
+//	TCanvas*c = new TCanvas();
+//	c->SetTitle(mytitle);
+	TGraph* g1 = new TGraph(n,rece,ee);
+	TF1* fit1 = new TF1("fit1","[0]*x + [1]*x*x",0,100);
+	g1->Fit("fit1","Q");
+	float xfact = fit1->GetParameter(facn);
+//	g1->Draw("APL");
+	delete g1;
+	delete fit1;
+
+	return xfact;
+*/
+        return 1.;
+}
+
+
+void H_RecRPObject::setPositions(const float X1, const float Y1, const float X2, const float Y2) {
+	thx = NOT_YET_COMPUTED;
+	thy = NOT_YET_COMPUTED;
+	x0  = NOT_YET_COMPUTED;
+	y0  = NOT_YET_COMPUTED;
+	energy = NOT_YET_COMPUTED;
+	virtuality = NOT_YET_COMPUTED;
+	x1 = X1;
+	x2 = X2;
+	y1 = Y1;
+	y2 = Y2;
 	
-	if(emax<0) {
-		cout<<"<H_RecRPObject> ERROR : energy range has to be set first !"<<endl;
-		cout<<"<H_RecRPObject> Please run setERange() or computeERange()"<<endl;
-		cout<<"<H_RecRPObject> initialization aborted"<<endl;
-		return;
-	}
-
-	if(emax<emin) {
-		cout<<"<H_RecRPObject> ERROR : maximum energy lower than minimum !"<<endl;
-		cout<<"<H_RecRPObject> Please (re-)do setERange()"<<endl;
-		cout<<"<H_RecRPObject> initialization aborted"<<endl;
-		return;
-	}
-
-	H_AbstractBeamLine * b1 = thebeam->clone();
-	H_RomanPot * rp1 = new H_RomanPot("rp1",s1,0);
-	H_RomanPot * rp2 = new H_RomanPot("rp2",s2,0);
-	b1->add(rp1);
-	b1->add(rp2);
-
-	// fitting parameters
-	const int N = 20;
-	double e_i[N];
-	double f_1i[N], f_2i[N], g_1i[N], g_2i[N], d_1i[N], d_2i[N];
-	double k_1i[N], k_2i[N], l_1i[N], l_2i[N];
+	return;
+}
+
+void H_RecRPObject::printProperties() const {
+	cout << "Roman pot variables :" << endl;
+	cout << "\t pot 1 : (x,y,s) = (" << x1 << " , " << y1 << " , " << s1 << " )" << endl;
+	cout << "\t pot 2 : (x,y,s) = (" << x2 << " , " << y2 << " , " << s2 << " )" << endl;
+	cout << endl << "Reconstructed variables :" << endl;
+	cout << "\t IP : (x,y) = (" << x0 << " , " << y0 << ") and (theta_x, theta_y) = (" << thx << " , " << thy << " )" << endl;
+	if (energy==NOT_YET_COMPUTED) cout << "\t Energy not yet computed" << endl;
+	else cout << "\t Energy = " << energy << " GeV" << endl;	
+	if (virtuality==NOT_YET_COMPUTED) cout << "\t Virtuality not yet computed" << endl;
+	else cout << "\t Virtuality = " << virtuality << " GeV^2" << endl;
+	cout << endl;
+}
+
+float H_RecRPObject::getE() {
+	if(energy==NOT_YET_COMPUTED) {
+		cout<<"Please first compute energy using your favourite method"<<endl;
+		return NOT_YET_COMPUTED;
+	}
+	return energy;
+}
+
+float H_RecRPObject::getE(const unsigned int method) {
+	switch (method) {
+		case TM: {energy = computeE_TM();} break;
+		case AM: {energy = computeE_AM();} break;
+		case PM: {energy = computeE_PM();} break;
+		default: {energy = computeE_AM();} break;
+	};
+	return energy;
+}
+
+float H_RecRPObject::computeX0() {
+	if(energy==NOT_YET_COMPUTED) {
+		cout<<"Please first compute energy using your favourite method"<<endl;
+		return NOT_YET_COMPUTED;
+	}
+	float alpha1 = (matrp1->GetMatrixArray())[0];
+	float alpha2 = (matrp2->GetMatrixArray())[0];
+	float disp1 = (matrp1->GetMatrixArray())[4*MDIM]*URAD;
+	float disp2 = (matrp2->GetMatrixArray())[4*MDIM]*URAD;
+	x0 = (disp2*x1-disp1*x2)/(disp2*alpha1-disp1*alpha2);
+	return x0;
+}
+
+float H_RecRPObject::computeY0() {
+	if(energy==NOT_YET_COMPUTED) {
+		cout<<"Please first compute energy using your favourite method"<<endl;
+		return NOT_YET_COMPUTED;
+	}
+	float gamma1 = (matrp1->GetMatrixArray())[2*MDIM+2];
+	float gamma2 = (matrp2->GetMatrixArray())[2*MDIM+2];
+	float delta1 = (matrp1->GetMatrixArray())[3*MDIM+2];
+	float delta2 = (matrp2->GetMatrixArray())[3*MDIM+2];
+	y0 = (delta2*y1-delta1*y2)/(delta2*gamma1-delta1*gamma2);
+	return y0;
+}
+
+float H_RecRPObject::computeTX() {
+	if(energy==NOT_YET_COMPUTED) {
+	        cout<<"Please first compute energy using your favourite method"<<endl;
+	        return NOT_YET_COMPUTED;
+	} 
+	float beta1 = (matrp1->GetMatrixArray())[1*MDIM];
+	float beta2 = (matrp2->GetMatrixArray())[1*MDIM];
+	float disp1 = (matrp1->GetMatrixArray())[4*MDIM]*URAD;
+	float disp2 = (matrp2->GetMatrixArray())[4*MDIM]*URAD;
+	// computes thx (murad)
+	thx = (x1*disp2-x2*disp1)/(beta1*disp2-beta2*disp1);
+	return thx;
+}
+
+float H_RecRPObject::computeTY() {
+	if(energy==NOT_YET_COMPUTED) {
+		cout<<"Please first compute energy using your favourite method"<<endl;
+		return NOT_YET_COMPUTED;
+	}
+	float gamma1 = (matrp1->GetMatrixArray())[2*MDIM+2];
+	float gamma2 = (matrp2->GetMatrixArray())[2*MDIM+2];
+	float delta1 = (matrp1->GetMatrixArray())[3*MDIM+2];
+	float delta2 = (matrp2->GetMatrixArray())[3*MDIM+2];
+	// computes thy (murad)
+	thy = (y1*gamma2-y2*gamma1)/(delta1*gamma2-delta2*gamma1);
+	return thy;
+}
+
+float H_RecRPObject::computeE_TM() {
+	// computes the emitted particle energy, from the trivial method
+	float disp = ((thebeam->getPartialMatrix("rp1",0,MP,QP))->GetMatrixArray())[4*MDIM]*URAD;
+	energy = -x1/disp;
+	// corrects for nonlinear effects
+	energy = (1+corr1_TM)*energy + corr2_TM*energy*energy;
+	// sets the rp matrices at obtained energy
+	delete matrp1;
+	delete matrp2;
+	matrp1 = new TMatrix(*(thebeam->getPartialMatrix("rp1",energy,MP,QP)));
+	matrp2 = new TMatrix(*(thebeam->getPartialMatrix("rp2",energy,MP,QP)));
+	// returns ...
+	return energy;
+}
+
+float H_RecRPObject::computeE_AM() {
+	// computes the emitted particle energy, from the angle compensation method, iterative way
+	const int N = 10;
+	delete matrp1;
+	delete matrp2;
+	matrp1 = new TMatrix(*(thebeam->getPartialMatrix("rp1",0,MP,QP)));
+	float disp = (matrp1->GetMatrixArray())[4*MDIM]*URAD;
+	delete matrp1;
+	energy = -x1/disp;
+	matrp1 = new TMatrix(*(thebeam->getPartialMatrix("rp1",energy,MP,QP)));
+	matrp2 = new TMatrix(*(thebeam->getPartialMatrix("rp2",energy,MP,QP)));
+	float beta1 = (matrp1->GetMatrixArray())[1*MDIM];
+	float beta2 = (matrp2->GetMatrixArray())[1*MDIM];
+	float disp1 = (matrp1->GetMatrixArray())[4*MDIM]*URAD;
+	float disp2 = (matrp2->GetMatrixArray())[4*MDIM]*URAD;
 	for(int i = 0; i < N; i++) {
-		e_i[i] = emin + i * (emax - emin)/((double)N-1);
-		// 
-		// the bug seems to be linked to the delete operator of the TMatrixT class in root.
-		// valgrind shows memory problems at that point.
-		// for unknwown reasons, copying the matrix gets around this bug.
-		// valgrind (related) ouptut :
-		//
-		// ==13029== Invalid read of size 4
-		// ==13029==    at 0x5E75DB6: H_RecRPObject::initialize() (in /home/jdf/GGamma/Hector/lib/libHector.so)
-		// ==13029==    by 0x804A2D8: intelligentreco_rpo(double, double, double, double, std::string, int) (H_IntelligentReco.cpp:314)
-		// ==13029==    by 0x804A937: main (H_IntelligentReco.cpp:542)
-		// ==13029==  Address 0x64AC740 is 80 bytes inside a block of size 144 free'd
-		// ==13029==    at 0x4021D18: operator delete[](void*) (vg_replace_malloc.c:256)
-		// ==13029==    by 0x5651F57: TMatrixT<float>::Delete_m(int, float*&) (in /home/jdf/root/5.12/lib/libMatrix.so)
-		// ==13029==    by 0x565CC5D: TMatrixT<float>::~TMatrixT() (in /home/jdf/root/5.12/lib/libMatrix.so)
-		// ==13029==    by 0x5E75D25: H_RecRPObject::initialize() (in /home/jdf/GGamma/Hector/lib/libHector.so)
-		//
-		//
-		TMatrix el_mattt(b1->getPartialMatrix("rp1",e_i[i],MP,QP));
-		const float *el_mat1 = el_mattt.GetMatrixArray();
-		// 
-		// conclusion : first line of el_mat1 is completely messed-up if it is taken directly from 
-		// the return of getpartialmatrix like this : 
-		// const float *el_mat1 = (b1->getPartialMatrix("rp1",e_i[i],MP,QP)).GetMatrixArray()
-		//
-		// long-term solution (apart noticing root staff) : replacing el_mat1[i] by the equivalent el_mattt(j,k)
-		// which is anyway more transparent for the reader.
-		//
-		f_1i[i] = el_mat1[0];
-		g_1i[i] = el_mat1[1*MDIM];
-		d_1i[i] = MEGA*el_mat1[4*MDIM];
-		k_1i[i] = el_mat1[2*MDIM+2];
-		l_1i[i] = el_mat1[3*MDIM+2];
-		const float* el_mat2 = (b1->getPartialMatrix("rp2",e_i[i],MP,QP).GetMatrixArray());
-		f_2i[i] = el_mat2[0];
-		g_2i[i] = el_mat2[1*MDIM];
-		d_2i[i] = MEGA*el_mat2[4*MDIM];
-		k_2i[i] = el_mat2[2*MDIM+2];
-		l_2i[i] = el_mat2[3*MDIM+2];
-	}
-	TGraph gf_1(N,e_i,f_1i);
-	TGraph gg_1(N,e_i,g_1i);
-	TGraph gd_1(N,e_i,d_1i);
-	TGraph gf_2(N,e_i,f_2i);
-	TGraph gg_2(N,e_i,g_2i);
-	TGraph gd_2(N,e_i,d_2i);
-	TGraph gk_1(N,e_i,k_1i);
-	TGraph gl_1(N,e_i,l_1i);
-	TGraph gk_2(N,e_i,k_2i);
-	TGraph gl_2(N,e_i,l_2i);
-
-    // functions get their final shape	
-	gf_1.Fit("f_1","Q");
-	gg_1.Fit("g_1","Q");
-	gd_1.Fit("d_1","Q");
-	gf_2.Fit("f_2","Q");
-	gg_2.Fit("g_2","Q");
-	gd_2.Fit("d_2","Q");
-	gk_1.Fit("k_1","Q");
-	gl_1.Fit("l_1","Q");
-	gk_2.Fit("k_2","Q");
-	gl_2.Fit("l_2","Q");
-
-	// cleaning the rest
-	delete b1;
-
-	// the end
-	return;
-}
-
-void H_RecRPObject::setDetPos(const float ss1, const float ss2) {
+		energy = -(beta2*x1-beta1*x2)/(beta2*disp1-beta1*disp2);
+		delete matrp1;
+		delete matrp2;
+		matrp1 = new TMatrix(*(thebeam->getPartialMatrix("rp1",energy,MP,QP)));
+		matrp2 = new TMatrix(*(thebeam->getPartialMatrix("rp2",energy,MP,QP)));
+		beta1 = (matrp1->GetMatrixArray())[1*MDIM];
+		beta2 = (matrp2->GetMatrixArray())[1*MDIM];
+		disp1 = (matrp1->GetMatrixArray())[4*MDIM]*URAD;
+		disp2 = (matrp2->GetMatrixArray())[4*MDIM]*URAD;
+	}
+	// returns ...
+	return energy;
+}
+
+float H_RecRPObject::computeE_PM() {
+	cout<<"Not yet implemented, nothing done"<<endl;
 	energy = NOT_YET_COMPUTED;
-	s1 = ss1;
-	s2 = ss2;
-	if(ss1==ss2) cout<<"<H_RecRPObject> WARNING : detectors are on same position"<<endl;
-	return;
-}
-
-void H_RecRPObject::setPositions(const float xx1, const float xx2, const float yy1, const float yy2) {
-	energy = NOT_YET_COMPUTED;
-	x1 = xx1;
-	x2 = xx2;
-	y1 = yy1;
-	y2 = yy2;
-	return;
-}
-
-void H_RecRPObject::setPosition_det1(const float xx1, const float yy1) {
-	energy = NOT_YET_COMPUTED;
-	x1 = xx1;
-	y1 = yy1;
-}
-
-void H_RecRPObject::setPosition_det2(const float xx2, const float yy2) {
-	energy = NOT_YET_COMPUTED;
-	x2 = xx2;
-	y2 = yy2;
-}
-
-void H_RecRPObject::setERange(const float eemin, const float eemax) {
-	energy = NOT_YET_COMPUTED;
-	emin = eemin;
-	emax = eemax;
-	f_1->SetRange(emin,emax);
-	f_2->SetRange(emin,emax);
-	g_1->SetRange(emin,emax);
-	g_2->SetRange(emin,emax);
-	d_1->SetRange(emin,emax);
-	d_2->SetRange(emin,emax);
-	k_1->SetRange(emin,emax);
-	k_2->SetRange(emin,emax);
-	l_1->SetRange(emin,emax);
-	l_2->SetRange(emin,emax);
-    return;
-}
-
-
-void H_RecRPObject::computeERange() {
-	// optional method to determine the energy range of the FIRST detector 
-	// in order to refine the fits and get maximum precision.
-	energy = NOT_YET_COMPUTED;
-	H_AbstractBeamLine * b1 = thebeam->clone();
-	H_RomanPot * rp1 = new H_RomanPot("rp1",s1,0);
-	b1->add(rp1);
-	float max = 1;
-	// number of energies to check 
-	const int N = 1000;
-	for(int i=0; i<N; i++) {
-		H_BeamParticle p;
-		p.setE(BE - (emin + i*(BE-emin)/((float)N)));
-		p.computePath(b1);
-		if(p.stopped(b1)) {
-			if(p.getStoppingElement()->getName()=="rp1") {
-				max = emin + i*(BE-emin)/((float)N);
-			}
-		}
-	}
-	cout<<"<H_RecRPObject> Valid energy losses run from 0 (default) to "<<max+20.<<" GeV"<<endl;
-	setERange(0,max+20.);
-	delete b1;
-	return;
-}
-
-void H_RecRPObject::computeAll() {
-	// The big game :
-	// computing E, tx, ty, Q2 and Pt and filling the variables.
-	//
-	// The root TF1 class features nice bugs, which explains the
-	// seemingly-dumb structures happening sometimes here as
-	// workarounds for these bugs. The overall thing works very
-	// well but will be cleaned later anyway.
-
-	if(energy!=NOT_YET_COMPUTED) {
-		cout<<"<H_RecRPObject> already computed variables, skipping ..."<<endl;
-		return;
-	}
-
-	TF1 par0("par0","[0]",emin,emax);
-	par0.SetParameter(0,-x1);
-	TF1 par2("par2","[0]",emin,emax);
-	par2.SetParameter(0,-y1);
-	TF1 par1("par1","[0]",emin,emax);
-	par1.SetParameter(0,-x2);
-	TF1 par3("par3","[0]",emin,emax);
-	par3.SetParameter(0,-y2);
-
-	// angle compensating method :
-	TF1 xx_E("xx_E","(g_2*(par0-d_1*x)-g_1*(par1-d_2*x))/(f_2*g_1-f_1*g_2)",emin,emax);
-	TF1 yy_E("yy_E","(par2*l_2 - par3*l_1) / (k_2*l_1 - k_1*l_2)",emin,emax);
-	TF1 xp_E("xp_E","(f_2*(par0-d_1*x)-f_1*(par1-d_2*x))/(g_2*f_1-g_1*f_2)",emin,emax);
-	TF1 yp_E("yp_E","(par2*k_2-par3*k_1)/(l_2*k_1-l_1*k_2)",emin,emax);
-	// it is possible to refine study using y info, but effect was not tested.	
-	// TF1 p_xy_E("p_xy_E","(-xx_E*xx_E-yy_E*yy_E)",emin,emax);
-	TF1 p_xy_E("p_xy_E","(-xx_E*xx_E)",emin,emax);
-
-	energy = p_xy_E.GetMaximumX(emin,emax);
-	txip = xp_E.Eval(energy);
-	tyip = yp_E.Eval(energy);
-	pt = sqrt(BE*(BE-energy)*(txip*txip+tyip*tyip)/(MEGA*MEGA));
-
-	return;
-}
-
-float H_RecRPObject::getE(int ) {
-// put for backward compatibility
-        if(energy==NOT_YET_COMPUTED) { computeAll(); };
-        return energy;
-}  // to be removed !!!!!
-
-float H_RecRPObject::getE() {
-	if(energy==NOT_YET_COMPUTED) { computeAll(); };
-	return energy;
-}
-
-float H_RecRPObject::getTX() {
-	if(energy==NOT_YET_COMPUTED) { computeAll(); };
-	return txip;
-}
-
-float H_RecRPObject::getTY() {
-	if(energy==NOT_YET_COMPUTED) { computeAll(); };
-	return tyip;
-}
-
-float H_RecRPObject::getQ2() {
-	if(energy==NOT_YET_COMPUTED) { computeAll(); };
-	cout<<"<H_RecRPObject::getQ2> Not implemented yet"<<endl;
-	return 0;
-}
-
-float H_RecRPObject::getPt() {
-	if(energy==NOT_YET_COMPUTED) { computeAll(); };
-	return pt;
-}
-
-std::ostream& operator<< (std::ostream& os, const H_RecRPObject& rp) {
-	os << "e_min=" <<  rp.emin << "\t e_max= " << rp.emax << endl;
-	os << "x1="    << rp.x1 << "\t x2= " << rp.x2 << "\t y1=" << rp.y1 << "\t y2=" << rp.y2 
-	   << "\t s1=" << rp.s1 << "\t s2=" << rp.s2 << endl;
-	os << "txip=" << rp.txip << "\t tyip=" << rp.tyip << "\t energy=" << rp.energy << "\t q2=" << rp.q2 << "\t pt=" << rp.pt << endl;
-   return os;
-}
-
+	return energy;
+}
+
+float H_RecRPObject::computeQ2() {
+	// computes the emitted particle virtuality
+	// energy should be teconstructed first
+	if(energy==NOT_YET_COMPUTED) {
+		cout<<"Please first compute energy using your favourite method"<<endl;
+		return NOT_YET_COMPUTED;
+	} 
+	// getting parameters for reconstructed particle energy
+    float beta1 = (matrp1->GetMatrixArray())[1*MDIM];
+    float beta2 = (matrp2->GetMatrixArray())[1*MDIM];
+    float gamma1 = (matrp1->GetMatrixArray())[2*MDIM+2];
+    float gamma2 = (matrp2->GetMatrixArray())[2*MDIM+2];
+    float delta1 = (matrp1->GetMatrixArray())[3*MDIM+2];
+    float delta2 = (matrp2->GetMatrixArray())[3*MDIM+2];
+    float disp1 = (matrp1->GetMatrixArray())[4*MDIM]*URAD;
+    float disp2 = (matrp2->GetMatrixArray())[4*MDIM]*URAD;
+    // angles reconstruction
+    float rec_thx = (x1*disp2-x2*disp1)/(beta1*disp2-beta2*disp1)/URAD;
+    float rec_thy = (y1*gamma2-y2*gamma1)/(delta1*gamma2-delta2*gamma1)/URAD;
+	// QÂ² reconstruction
+    virtuality = BE*(BE-energy)*(rec_thx*rec_thx+rec_thy*rec_thy);
+	// returns ...
+	return virtuality;
+}
+
Index: external/Hector/H_RecRPObject.h
===================================================================
--- external/Hector/H_RecRPObject.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RecRPObject.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -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
-
Index: external/Hector/H_RectEllipticAperture.cc
===================================================================
--- external/Hector/H_RectEllipticAperture.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectEllipticAperture.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RectEllipticAperture.cc
@@ -27,5 +20,6 @@
 
 // ROOT #includes
-#include "TPolyLine.h"
+//#include "TEllipse.h"
+//#include "TPave.h"
 
 // local #includes
@@ -33,98 +27,23 @@
 using namespace std;
 
-H_RectEllipticAperture::H_RectEllipticAperture(const float l, const float h, const float L, const float H, const float posx, const float posy) :H_Aperture(RECTELLIPSE,((l==0)?L:l),((h==0)?H:h),L,H,posx,posy) {
-	/// @param l, h, L, H are the geometrical parameters of the rect-ellipse shape
+H_RectEllipticAperture::H_RectEllipticAperture(const float x1, const float x2, const float x3, const float x4, const float posx, const float posy) :H_Aperture(RECTELLIPSE,((x1==0)?x3:x1),((x2==0)?x4:x2),x3,x4,posx,posy) {
+	/// @param x1, x2, x3, x4 are the geometrical parameters of the rect-ellipse shape
 	/// @param posx, posy defines the (x,y) of the center of the shape
+	type= RECTELLIPSE;
 }
 
-H_RectEllipticAperture* H_RectEllipticAperture::clone() const {
-	return new H_RectEllipticAperture(x1,x2,x3,x4,fx,fy);
-}
-
-
-TPolyLine * rectellipse(const float a_e = 2, const float b_e = 1, const float a_r = 1, const float b_r = 2, const float center_x = 0, const float center_y =0) {
-        const int n = 20;  // number of points per segment
-        const int N = 4*n; // there are 4 segments
-        float x[N+1], y[N+1];
-
-   if(a_e>a_r) {
-        // a rectellipse has 4 segments
-        // 1) upper one
-        for (int i=0; i<n; i++) {
-                x[i] = -a_r + i*(2*a_r)/(float)n;
-                y[i] =  b_e * sqrt(1-pow(x[i]/a_e,2));
-        }
-
-        // 2) right vertical segment
-        // upper right corner
-        const float y2 = b_e * sqrt(1-pow(a_r/a_e,2));
-        // lower right corner
-        const float y3 = -b_e * sqrt(1-pow(a_r/a_e,2));
-        for (int i=n; i<2*n; i++) {
-                x[i] = a_r;
-                y[i] = y2 - (i-n)*(2*y2)/(float)n;
-        }
-
-        // 3) lower side
-        for (int i=2*n; i<3*n; i++) {
-                x[i] = a_r - (i-2*n)*(2*a_r)/(float)n;
-                y[i] = -b_e * sqrt(1-pow(x[i]/a_e,2));
-        }
-
-        // 4) left vertical segment
-        // lower left corner
-        const float y4 = y3;
-        for (int i=3*n; i<4*n; i++) {
-                x[i] = -a_r;
-                y[i] = y4 + (i-3*n)*(2*y2)/(float)n;
-        }
-   } else {
-	// 1) upper one : flat
-	const float x1 = -a_e * sqrt(1-pow(b_r/b_e,2));
-	const float x2 = -x1;
-	for (int i=0; i<n; i++) {
-		y[i] = b_r;
-		x[i] = x1 + i * (x2-x1)/(float)n;
-	}
-	
-	// 2) right curved border
-	for (int i=n; i<2*n; i++) {
-		y[i] = b_r - (i-n) * (2*b_r)/(float)n;
-		x[i] = a_e * sqrt(1-pow(y[i]/b_e,2));
-	}
-
-	// 3) lower side : flat
-	for (int i=2*n; i<3*n; i++) {
-		y[i] = -b_r;
-		x[i] = x2 - (i-2*n) * (2*x2)/(float)n;
-	}
-	
-	// 4) left curved border
-	for (int i=3*n; i<4*n; i++) {
-		y[i] = -b_r + (i-3*n) * (2*b_r)/(float)n;
-		x[i] = -a_e * sqrt(1-pow(y[i]/b_e,2));
-	}
-   }
-
-	// closing the polyline
-        x[N] = x[0];
-        y[N] = y[0];
-
-	// shifting the center
-        for (int i=0; i<N+1; i++) {
-                x[i] += center_x;
-                y[i] += center_y;
-        }
-
-        return new TPolyLine(N+1,x,y);
-}
-
-
-void H_RectEllipticAperture::draw(const float scale) const {
-	TPolyLine * re = rectellipse(x3*scale, x4*scale, x1*scale, x2*scale, fx*scale, fy*scale);
-	re->SetLineColor(39);
-	re->SetLineWidth(2);
-	re->Draw("l");
+void H_RectEllipticAperture::draw() const {
+/*	TEllipse* te = new TEllipse(fx,fy,x3,x4);
+	TPave* tp = new TPave(fx-x1,fy-x2,fx+x1,fy+x2,1);
+        te->SetLineColor(2);
+        te->SetFillColor(2);
+	te->SetFillStyle(3004);
+        te->Draw();
+        tp->SetLineColor(2);
+        tp->SetFillColor(2);
+	tp->SetFillStyle(3005);
+        tp->Draw();	
 	return;
+*/
 }
 
@@ -133,7 +52,7 @@
 }
 
-std::ostream& operator<< (std::ostream& os, const H_RectEllipticAperture& ap) {
-	os << "Aperture shape:" << ap.aptypestring << ", parameters " << ap.x1 <<", "<< ap.x2 <<", "<< ap.x3 <<", "<< ap.x4 << endl;
-	os << " \t Center : " << ap.fx <<", "<< ap.fy <<endl;
-	return os;
+void H_RectEllipticAperture::printProperties() const {
+	cout << "Aperture shape:" << getTypeString() << ", parameters " <<x1<<", "<<x2<<", "<<x3<<", "<<x4<< endl;
+	cout << " \t Center : "<<fx<<", "<<fy<<endl;
+	return;
 }
Index: external/Hector/H_RectEllipticAperture.h
===================================================================
--- external/Hector/H_RectEllipticAperture.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectEllipticAperture.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,24 +2,17 @@
 #define _H_RectEllipticAperture_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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                 *
- *                                                         *
-   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
 /// \file H_RectEllipticAperture.h
 /// \brief Defines the Rect-Elliptic aperture of beamline elements.
+
+/*
+---- 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)
+*/
 
 // local #includes
@@ -34,12 +27,11 @@
 		H_RectEllipticAperture():H_Aperture(RECTELLIPSE,0,0,0,0,0,0) {}
 		H_RectEllipticAperture(const float,const float,const float,const float, const float, const float);
-		~H_RectEllipticAperture() {};
-		H_RectEllipticAperture* clone() const;
+		~H_RectEllipticAperture() {return;};
 		//@}
+		virtual void printProperties() const;
 		/// Checks whether the point is inside the aperture or not
 		virtual bool isInside(const float, const float) const;
 		/// Draws the aperture shape.
-		virtual void draw(const float scale=1) const;
-	friend std::ostream& operator<< (std::ostream& os, const H_RectEllipticAperture& ap);
+		virtual void draw() const;
 };
 
Index: external/Hector/H_RectangularAperture.cc
===================================================================
--- external/Hector/H_RectangularAperture.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectangularAperture.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RectangularAperture.cc
@@ -27,5 +20,5 @@
 
 // ROOT #includes
-#include "TPave.h"
+//#include "TPave.h"
 
 // local #includes
@@ -33,11 +26,7 @@
 using namespace std;
 
-H_RectangularAperture::H_RectangularAperture(const float l, const float h, const float posx, const float posy) :H_Aperture(RECTANGULAR,l,h,0,0,posx,posy) {
-	/// @param l, h are the length and height of the rectangular shape
+H_RectangularAperture::H_RectangularAperture(const float x1, const float x2, const float posx, const float posy) :H_Aperture(RECTANGULAR,x1,x2,0,0,posx,posy) {
+	/// @param x1, x2 are the length and height of the rectangular shape
 	/// @param posx, posy are the (x,y) coordinates of the center of the rectangular shape
-}
-
-H_RectangularAperture* H_RectangularAperture::clone() const {
-	return new H_RectangularAperture(x1,x2,fx,fy);
 }
 
@@ -47,6 +36,6 @@
 }
 
-void H_RectangularAperture::draw(const float scale) const {
-	TPave* tp = new TPave((fx-x1)*scale,(fy-x2)*scale,(fx+x1)*scale,(fy+x2)*scale,1);
+void H_RectangularAperture::draw() const {
+/*	TPave* tp = new TPave(fx-x1,fy-x2,fx+x1,fy+x2,1);
 	tp->SetFillStyle(3003);
 	tp->SetLineColor(2);
@@ -54,10 +43,9 @@
 	tp->Draw();
 	return;
+*/
 }
-
-std::ostream& operator<< (std::ostream& os, const H_RectangularAperture& ap) {
-	os << "Aperture shape:" << ap.aptypestring << ", rectangle sides : " << ap. x1 <<", " << ap.x2 <<endl;
-	os << " \t Center : " << ap.fx << "," << ap.fy << endl;
-        return os;
+void H_RectangularAperture::printProperties() const {
+	cout << "Aperture shape:" << getTypeString() << ", rectangle Sides : "<<x1<<", "<<x2<<endl;
+	cout << " \t Center : " << fx << "," << fy << endl;
+	return;
 }
-
Index: external/Hector/H_RectangularAperture.h
===================================================================
--- external/Hector/H_RectangularAperture.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectangularAperture.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_RectangularAperture_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RectangularAperture.h
@@ -34,12 +27,11 @@
 		H_RectangularAperture():H_Aperture(RECTANGULAR,0,0,0,0,0,0) {}
 		H_RectangularAperture(const float,const float,const float,const float);
-		~H_RectangularAperture() {};
-		H_RectangularAperture* clone() const;
+		~H_RectangularAperture() {return;};
 		//@}
 		/// Checks whether the point is inside the aperture or not 
 		virtual bool isInside(const float, const float) const;
 		/// Draws the aperture shape.
-		virtual void draw(const float scale=1) const;
-	friend std::ostream& operator<< (std::ostream& os, const H_RectangularAperture& ap);
+		virtual void draw() const;
+		virtual void printProperties() const;
 };
 
Index: external/Hector/H_RectangularCollimator.cc
===================================================================
--- external/Hector/H_RectangularCollimator.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectangularCollimator.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RectangularCollimator.cc
@@ -31,43 +24,31 @@
 }
 
-H_RectangularCollimator::H_RectangularCollimator(const double s, const double l) :H_Drift(s,l){
-	type = RCOLLIMATOR;
-	init();
+H_RectangularCollimator::H_RectangularCollimator(const double s, const double l) :H_OpticalElement(RCOLLIMATOR,s,0.,l){
+		init();
 	return;
 }
 
-H_RectangularCollimator::H_RectangularCollimator(const string& nameE, const double s, const double l) :H_Drift(nameE,s,l){
-	type = RCOLLIMATOR;
-	init();
+H_RectangularCollimator::H_RectangularCollimator(const string nameE, const double s, const double l) :H_OpticalElement(nameE,RCOLLIMATOR,s,0.,l){
+		init();
 	return;
 }
 
-std::ostream& operator<< (std::ostream& os, const H_RectangularCollimator& el) {
-	os << el.typestring << el.name << "\t\t at s = " << el.fs << "\t length = " << el.element_length <<endl;
-	if(el.element_aperture->getType()!=NONE) {
-        	os << *(el.element_aperture) << endl;
+void H_RectangularCollimator::printProperties() const {
+	cout << typestring << name;
+	cout << "\t\t at s = " << fs;
+	cout << "\t length = " << element_length;
+	cout<<endl;
+	if(element_aperture->getType()!=NONE) {
+        	cout <<"\t aperture type = " << element_aperture->getTypeString();
+                	element_aperture->printProperties();
 	}
 
-	if(el.element_length<0 && VERBOSE) os <<"<H_RectangularCollimator> ERROR : Interpenetration of elements !"<<endl; 
-	else if(el.element_length==0 && VERBOSE) os <<"<H_RectangularCollimator> WARNING : 0-length "<< el.name << " !" << endl;
-   return os;
+	if(element_length<0)  { if(VERBOSE) cout<<"\t ERROR : Interpenetration of elements !"<<endl; }
+	if(element_length==0) { if(VERBOSE) cout<<"\t WARNING : 0-length "<< name << " !" << endl; }
 }
 
-//void H_RectangularCollimator::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-void H_RectangularCollimator::setMatrix(const float , const float , const float ) {
-	element_mat = driftmat(element_length);
+void H_RectangularCollimator::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+	//	cout<<"\t WARNING : H_RectangularCollimator matrices not yet implemented ! " << endl;
+		*element_mat = driftmat(element_length);
 	return ;
 }
-
-H_RectangularCollimator* H_RectangularCollimator::clone() const {
-	H_RectangularCollimator* temp_coll = new H_RectangularCollimator(name,fs,element_length);
-	temp_coll->setAperture(element_aperture);
-	temp_coll->setX(xpos);
-	temp_coll->setY(ypos);
-	temp_coll->setTX(txpos);
-	temp_coll->setTY(typos);
-	temp_coll->setBetaX(betax);
-	temp_coll->setBetaY(betay);
-	return temp_coll;
-}
-
Index: external/Hector/H_RectangularCollimator.h
===================================================================
--- external/Hector/H_RectangularCollimator.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectangularCollimator.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_RectangularCollimator_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RectangularCollimator.h
@@ -24,24 +17,24 @@
 
 // local #includes
-#include "H_Drift.h"
+#include "H_OpticalElement.h"
 
 /// R-Collimators for the LHC beamline.
-class H_RectangularCollimator : public H_Drift {
+class H_RectangularCollimator : public H_OpticalElement {
 
 	public:
 	/// Constructors and destructor
 	//@{
-		H_RectangularCollimator():H_Drift() {type = RCOLLIMATOR; init();}
+		H_RectangularCollimator():H_OpticalElement(RCOLLIMATOR,0.,0.,0.) {init();}
 		H_RectangularCollimator(const double, const double );
-		H_RectangularCollimator(const string&, const double, const double );
-		~H_RectangularCollimator() {};
+		H_RectangularCollimator(const string, const double, const double );
+		~H_RectangularCollimator() { return; };
 	//@}
-		H_RectangularCollimator* clone() const;
+		virtual void printProperties() const;
 		void init();
+
 	private:
 	 	virtual void setTypeString() {typestring=RCOLLIMATORNAME;};
-		virtual void setMatrix(const float, const float, const float) ;
-	
-	friend std::ostream& operator<< (std::ostream& os, const H_RectangularCollimator& el);
+		virtual void setMatrix(const float, const float, const float) const ;
+
 };
 
Index: external/Hector/H_RectangularDipole.cc
===================================================================
--- external/Hector/H_RectangularDipole.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectangularDipole.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RectangularDipole.cc
@@ -23,23 +16,10 @@
 #include "H_TransportMatrices.h"
 
-void H_RectangularDipole::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-	if (fk !=0 ) element_mat = rdipmat(element_length,fk,eloss,p_mass,p_charge);
+void H_RectangularDipole::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+	if (fk !=0 ) *element_mat = rdipmat(element_length,fk,eloss,p_mass,p_charge);
 	else  {
-		element_mat = driftmat(element_length);
-		if(VERBOSE) cout<<"<H_RectangularDipole> WARNING : k0= 0, drift-like dipole (" << name << ") !" << endl;
+		*element_mat = driftmat(element_length);
+		if(VERBOSE) cout<<"\t WARNING : k0= 0, drift-like dipole (" << name << ") !" << endl;
 	}
 	return ;
 }
-
-H_RectangularDipole* H_RectangularDipole::clone() const {
-	H_RectangularDipole* temp_dip = new H_RectangularDipole(name,fs,fk,element_length);
-	temp_dip->setAperture(element_aperture);
-	temp_dip->setX(xpos);
-	temp_dip->setY(ypos);
-	temp_dip->setTX(txpos);
-	temp_dip->setTY(typos);
-	temp_dip->setBetaX(betax);
-	temp_dip->setBetaY(betay);
-	return temp_dip;
-}
-
Index: external/Hector/H_RectangularDipole.h
===================================================================
--- external/Hector/H_RectangularDipole.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RectangularDipole.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,24 +2,17 @@
 #define _H_RectangularDipole_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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                 *
- *                                                         *
-   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
 /// \file H_RectangularDipole.h
 /// \brief Classes aiming at simulating LHC beam rectangular dipoles.
+
+/*
+---- 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)
+*/
 
 #include "H_Dipole.h"
@@ -32,12 +25,11 @@
 		//@{
 		H_RectangularDipole():H_Dipole(RDIPOLE,0.,0.,0.) {init();}
-		H_RectangularDipole(const double s, const double k, const double l) :H_Dipole(RDIPOLE,s,k,l){init();}
-		H_RectangularDipole(const string& nameE, const double s, const double k, const double l) :H_Dipole(nameE,RDIPOLE,s,k,l){init();}
-		~H_RectangularDipole() {};
+        	H_RectangularDipole(const double s, const double k, const double l) :H_Dipole(RDIPOLE,s,k,l){init();}
+	        H_RectangularDipole(const string nameE, const double s, const double k, const double l) :H_Dipole(nameE,RDIPOLE,s,k,l){init();}
+        	~H_RectangularDipole() {return;};
 		//@}
-		H_RectangularDipole* clone() const ;
 	private:
-		virtual void setTypeString() { typestring = RDIPOLENAME;};
-		virtual void setMatrix(const float, const float, const float) ;
+	        virtual void setTypeString() { typestring = RDIPOLENAME;};
+        	virtual void setMatrix(const float, const float, const float) const ;
 };
 
Index: external/Hector/H_RomanPot.cc
===================================================================
--- external/Hector/H_RomanPot.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RomanPot.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_RomanPot.cc
@@ -32,41 +25,29 @@
 }
 
-H_RomanPot::H_RomanPot(const double s, const double app) :H_Drift(s,RP_LENGTH){
-		type = RP;
+H_RomanPot::H_RomanPot(const double s, const double app) :H_OpticalElement(RP,s,0.,RP_LENGTH){
 		init();
-		if(element_aperture) delete element_aperture;
-		element_aperture = new H_RectangularAperture(app,RP_HEIGHT,0,0);
+		H_RectangularAperture* rapp = new H_RectangularAperture(app,RP_HEIGHT,0,0);
+		setAperture(rapp);
 }
 
-H_RomanPot::H_RomanPot(const string& nameE, const double s, const double app) :H_Drift(nameE,s,RP_LENGTH){
-		type = RP;
+H_RomanPot::H_RomanPot(const string nameE, const double s, const double app) :H_OpticalElement(nameE,RP,s,0.,RP_LENGTH){
 		init();
-		if(element_aperture) delete element_aperture;
-		element_aperture = new H_RectangularAperture(app,RP_HEIGHT,0,0);
+		H_RectangularAperture* rapp = new H_RectangularAperture(app,RP_HEIGHT,0,0);
+		setAperture(rapp);
 }
 
-std::ostream& operator<< (std::ostream& os, const H_RomanPot& el) {
-	os << el.typestring << el.name << "\t\t at s = " << el.fs;
-	if(el.element_aperture->getType()!=NONE) {
-		os << *(el.element_aperture) << endl;
-	}
-   return os;
+void H_RomanPot::printProperties() const {
+		cout << typestring << name;
+		cout << "\t\t at s = " << fs;
+                if(element_aperture->getType()!=NONE) {
+                        cout <<"\t aperture type = " << element_aperture->getTypeString();
+                        element_aperture->printProperties();
+                }
+
+		cout<<endl;
 }
 
-void H_RomanPot::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-		element_mat = driftmat(0);
+void H_RomanPot::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+		*element_mat = driftmat(0);
 	return ;
 }
-
-H_RomanPot* H_RomanPot::clone() const {
-	H_RomanPot* temp_rp = new H_RomanPot(name,fs,element_length);
-	temp_rp->setAperture(element_aperture);
-	temp_rp->setX(xpos);
-	temp_rp->setY(ypos);
-	temp_rp->setTX(txpos);
-	temp_rp->setTY(typos);
-	temp_rp->setBetaX(betax);
-	temp_rp->setBetaY(betay);
-	return temp_rp;
-}
-
Index: external/Hector/H_RomanPot.h
===================================================================
--- external/Hector/H_RomanPot.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_RomanPot.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,48 +1,42 @@
 #ifndef _H_RomanPot_
 #define _H_RomanPot_
-
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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                 *
- *                                                         *
-   * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 
 /// \file H_RomanPot.h
 /// \brief Roman pot class
 
+/*
+---- 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)
+*/
+
 // local #includes
-#include "H_Drift.h"
+#include "H_OpticalElement.h"
 
 #define RP_LENGTH 0.0001
 #define RP_HEIGHT 10000
 /// Roman pot as an optics element.
-class H_RomanPot : public H_Drift {
+class H_RomanPot : public H_OpticalElement {
 
 	public:
 	///     Constructors and destructor
 	//@{
-		H_RomanPot():H_Drift() {type = RP; init();}
-		H_RomanPot(const string&, const double, const double);
+		H_RomanPot():H_OpticalElement(RP,0.,0.,RP_LENGTH) {init();}
+		H_RomanPot(const string, const double, const double);
 		H_RomanPot(const double, const double);
-		~H_RomanPot() {};
+		~H_RomanPot() { return; };
 	//@}
-		H_RomanPot* clone() const ;
+		virtual void printProperties() const;
 		void init();
+
 	private:
 		virtual void setTypeString() {typestring=RPNAME;};
-		virtual void setMatrix(const float, const float, const float) ;
-	friend std::ostream& operator<< (std::ostream& os, const H_RomanPot& el);
+		virtual void setMatrix(const float, const float, const float) const;
+
 };
 
Index: external/Hector/H_SectorDipole.cc
===================================================================
--- external/Hector/H_SectorDipole.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_SectorDipole.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_SectorDipole.cc
@@ -23,23 +16,10 @@
 #include "H_TransportMatrices.h"
 
-void H_SectorDipole::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-	if (fk !=0 ) element_mat = sdipmat(element_length,fk,eloss,p_mass,p_charge);
+void H_SectorDipole::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+	if (fk !=0 ) *element_mat = sdipmat(element_length,fk,eloss,p_mass,p_charge);
 	else  {
-		element_mat = driftmat(element_length);
-		if(VERBOSE) cout<<"<H_SectorDipole> WARNING : k0= 0, drift-like dipole (" << name << ") !" << endl;
+		*element_mat = driftmat(element_length);
+		if(VERBOSE) cout<<"\t WARNING : k0= 0, drift-like dipole (" << name << ") !" << endl;
    		}
 	return ;
 }
-
-H_SectorDipole* H_SectorDipole::clone() const {
-	H_SectorDipole* temp_dip = new H_SectorDipole(name,fs,fk,element_length);
-	temp_dip->setAperture(element_aperture);
-	temp_dip->setX(xpos);
-	temp_dip->setY(ypos);
-	temp_dip->setTX(txpos);
-	temp_dip->setTY(typos);
-	temp_dip->setBetaX(betax);
-	temp_dip->setBetaY(betay);
-	return temp_dip;
-}
-
Index: external/Hector/H_SectorDipole.h
===================================================================
--- external/Hector/H_SectorDipole.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_SectorDipole.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,25 +1,18 @@
+/// \file H_SectorDipole.h
+/// \brief Classes aiming at simulating sector dipoles.
+
 #ifndef _H_SectorDipole_
 #define _H_SectorDipole_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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
 
-/// \file H_SectorDipole.h
-/// \brief Classes aiming at simulating sector dipoles.
+        http://www.fynu.ucl.ac.be/hector.html
+
+   Centre de Physique des Particules et de PhÃ©nomÃ©nologie (CP3)
+   UniversitÃ© Catholique de Louvain (UCL)
+*/
 
 #include "H_Dipole.h"
@@ -33,11 +26,10 @@
 		H_SectorDipole():H_Dipole(SDIPOLE,0.,0.,0.) {init();}
 		H_SectorDipole(const double s, const double k, const double l) :H_Dipole(SDIPOLE,s,k,l){init();}
-		H_SectorDipole(const string& nameE, const double s, const double k, const double l) :H_Dipole(nameE,SDIPOLE,s,k,l){init();}
-		~H_SectorDipole() {};
+		H_SectorDipole(const string nameE, const double s, const double k, const double l) :H_Dipole(nameE,SDIPOLE,s,k,l){init();}
+		~H_SectorDipole() {return;};
 		//@}
-		H_SectorDipole* clone() const ;
 	private:
 		virtual void setTypeString() { typestring = SDIPOLENAME;};
-		virtual void setMatrix(const float ,const float, const float) ;
+		virtual void setMatrix(const float ,const float, const float) const ;
 };
 
Index: external/Hector/H_TransportMatrices.cc
===================================================================
--- external/Hector/H_TransportMatrices.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_TransportMatrices.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_TransportMatrices.cc
@@ -36,5 +29,5 @@
 
 extern double omega(const double k, const double l) {
-		// [l] = [m] and [k] = [1/m^2] for quadrupoles
+		// [l] = [m] and [k] = [1/mï¿œ] for quadrupoles
 		// [omega] = [1]
 	return sqrt(fabs(k))*l;
@@ -42,16 +35,16 @@
 
 extern double radius(const double k) {
-		// [k] = [1/m^2] for quadrupoles
+		// [k] = [1/mï¿œ] for quadrupoles
 		// [k] = [1/m]  for dipoles
 		// [radius(k)] = [m]
-	if(k==0 && VERBOSE) cout<<"<H_TransportMatrices> ERROR : Dipole has no effect : results will be corrupted"<<endl; 
+	if(k==0 && VERBOSE) cout<<"ERROR : Dipole has no effect : results will be corrupted"<<endl; 
 	// this is protected by the "if(k==0) -> driftmat" in every matrix below (ex vquatmat)
 	return (k==0) ? 1 : 1/k;
 }
 
-extern void printMatrix(TMatrix TMat) {
+extern void printMatrix(TMatrix * TMat) {
 	char temp[20];
 	float * el = new float[MDIM*MDIM];
-	el = (TMat.GetMatrixArray());
+	el = (TMat->GetMatrixArray());
 
 	cout << endl << "\t";
@@ -156,7 +149,7 @@
 	double simp = r*2*sin(l/(2*r))*sin(l/(2*r))/BE;
 	double psy = ke*l/2.;
-	float tefmat[MDIM*MDIM] = {1., tan(psy)*ke, 0., 0., 0., 0.,
+	float tefmat[MDIM*MDIM] = {1., (float)(tan(psy)*ke), 0., 0., 0., 0.,
 	                            0., 1., 0., 0., 0., 0.,
-	                            0., 0., 1., -tan(psy)*ke, 0., 0.,
+	                            0., 0., 1., (float)(-tan(psy)*ke), 0., 0.,
 	                            0., 0., 0., 1., 0., 0.,
 	                            0., 0., 0., 0., 1., 0.,
@@ -167,5 +160,5 @@
    		           	           0.,0.,1.,0., 0., 0.,
    	            	           0.,0.,l,1., 0., 0., 
-   	                        simp, sin(l/r)/BE, 0., 0., 1., 0.,
+   	                        (float)simp, (float)(sin(l/r)/BE), 0., 0., 1., 0.,
    	                        0., 0., 0., 0., 0., 1. };
 	for(int i=0;i<MDIM*MDIM;i++) { 
@@ -216,5 +209,5 @@
 			                  0.,0.,1.,0., 0., 0.,
 			                  0.,0.,l,1., 0., 0.,
-			                  simp, sin(l/r)/BE, 0., 0., 1., 0.,
+			                  simp, (float)(sin(l/r)/BE), 0., 0., 1., 0.,
 			                  0., 0., 0., 0., 0., 1.
 				           };
@@ -265,5 +258,5 @@
                            0.,0.,l ,1.,0.,0.,
                            0.,0.,0.,0.,1.,0.,
-                           l*tan(ke)/2.,ke, 0., 0., 0., 1. 
+                           (float)(l*tan(ke)/2.),ke, 0., 0., 0., 1. 
 	};
 
@@ -292,5 +285,5 @@
                            0.,0.,l ,1.,0.,0.,
                            0.,0.,0.,0.,1.,0.,
-                           0.,0.,l*tan(ke)/2.,ke, 0., 1. 
+                           0.,0.,(float)(l*tan(ke)/2.),ke, 0., 1. 
 	};
 
Index: external/Hector/H_TransportMatrices.h
===================================================================
--- external/Hector/H_TransportMatrices.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_TransportMatrices.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_TransportMatrices_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_TransportMatrices.h
@@ -56,5 +49,5 @@
 
 /// Prints the matrix
-extern void printMatrix(TMatrix);
+extern void printMatrix(TMatrix * );
 
 /// \brief Returns the matrix for a vertically focussing quadrupole (H_VerticalQuadrupole)
Index: external/Hector/H_VerticalKicker.cc
===================================================================
--- external/Hector/H_VerticalKicker.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_VerticalKicker.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_VerticalKicker.cc
@@ -26,25 +19,11 @@
 #include "H_TransportMatrices.h"
 
-void H_VerticalKicker::setMatrix(const float eloss, const float p_mass, const float p_charge) {
+void H_VerticalKicker::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
 	extern int kickers_on;
 	if(kickers_on) {
-		element_mat = vkickmat(element_length,fk,eloss,p_mass,p_charge);
+		*element_mat = vkickmat(element_length,fk,eloss,p_mass,p_charge);
 	} else{
-		element_mat = driftmat(element_length);
+		*element_mat = driftmat(element_length);
 	}
 	return ;
 }
-
-H_VerticalKicker* H_VerticalKicker::clone() const {
-	H_VerticalKicker* temp_kick = new H_VerticalKicker(name,fs,fk,element_length);
-	temp_kick->setAperture(element_aperture);
-	temp_kick->setX(xpos);
-	temp_kick->setY(ypos);
-	temp_kick->setTX(txpos);
-	temp_kick->setTY(typos);
-	temp_kick->setBetaX(betax);
-	temp_kick->setBetaY(betay);
-	return temp_kick;
-}
-
-
Index: external/Hector/H_VerticalKicker.h
===================================================================
--- external/Hector/H_VerticalKicker.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_VerticalKicker.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,21 +2,14 @@
 #define _H_VerticalKicker_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_VerticalKicker.h
@@ -37,11 +30,10 @@
 		H_VerticalKicker():H_Kicker(VKICKER,0.,0.,0.) {init();}
 		H_VerticalKicker(const double s, const double k, const double l) :H_Kicker(VKICKER,s,k,l){init();}
-		H_VerticalKicker(const string& nameE, const double s, const double k, const double l) :H_Kicker(nameE,VKICKER,s,k,l){init();}
-		~H_VerticalKicker() {};
+		H_VerticalKicker(const string nameE, const double s, const double k, const double l) :H_Kicker(nameE,VKICKER,s,k,l){init();}
+		~H_VerticalKicker() {return;};
 	//@}
-		H_VerticalKicker* clone() const ;
 	private:
 		virtual void setTypeString() {typestring=VKICKERNAME;};
-		virtual void setMatrix(const float, const float, const float) ;
+		virtual void setMatrix(const float, const float, const float) const ;
 };
 
Index: external/Hector/H_VerticalQuadrupole.cc
===================================================================
--- external/Hector/H_VerticalQuadrupole.cc	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_VerticalQuadrupole.cc	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -1,19 +1,12 @@
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_VerticalQuadrupole.cc
@@ -23,23 +16,11 @@
 #include "H_VerticalQuadrupole.h"
 
-void H_VerticalQuadrupole::setMatrix(const float eloss, const float p_mass, const float p_charge) {
-	if (fk<0)  { if(VERBOSE) cout<<"<H_VerticalQuadrupole> ERROR : k1 should be > 0 for H_VerticalQuadrupole (" << name << ")!"<<endl; }
-		if (fk !=0 ) element_mat = vquadmat(element_length,fk,eloss, p_mass,p_charge);
+void H_VerticalQuadrupole::setMatrix(const float eloss, const float p_mass, const float p_charge) const {
+	if (fk<0)  { if(VERBOSE) cout<<"\t ERROR : k1 should be > 0 for H_VerticalQuadrupole (" << name << ")!"<<endl; }
+		if (fk !=0 ) *element_mat = vquadmat(element_length,fk,eloss, p_mass,p_charge);
 		else  {
-			element_mat = driftmat(element_length);
-			if(VERBOSE) cout<<"<H_VerticalQuadrupole> WARNING : k1= 0, drift-like quadrupole (" << name << ") !" << endl;
+			*element_mat = driftmat(element_length);
+			if(VERBOSE) cout<<"\t WARNING : k1= 0, drift-like quadrupole (" << name << ") !" << endl;
    		}
 	return ;
 }
-
-H_VerticalQuadrupole* H_VerticalQuadrupole::clone() const {
-	H_VerticalQuadrupole* temp_quad = new H_VerticalQuadrupole(name,fs,fk,element_length);
-	temp_quad->setAperture(element_aperture);
-	temp_quad->setX(xpos);
-	temp_quad->setY(ypos);
-	temp_quad->setTX(txpos);
-	temp_quad->setTY(typos);
-	temp_quad->setBetaX(betax);
-	temp_quad->setBetaY(betay);
-	return temp_quad;
-}
Index: external/Hector/H_VerticalQuadrupole.h
===================================================================
--- external/Hector/H_VerticalQuadrupole.h	(revision 5b822e567e81b047f743b282d78eaae9b7c4fb20)
+++ external/Hector/H_VerticalQuadrupole.h	(revision 64a49502a612569581d1b8c14620c9a50b74ac1e)
@@ -2,22 +2,14 @@
 #define _H_VerticalQuadrupole_
 
-  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
- *                                                         *
-*                   --<--<--  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_VerticalQuadrupole.h
@@ -35,11 +27,10 @@
 		H_VerticalQuadrupole():H_Quadrupole(VQUADRUPOLE,0.,0.,0.) {init();}
 		H_VerticalQuadrupole(const double s, const double k, const double l):H_Quadrupole(VQUADRUPOLE,s,k,l) {init();}
-		H_VerticalQuadrupole(const string& nameE, const double s, const double k, const double l):H_Quadrupole(nameE,VQUADRUPOLE,s,k,l) {init();}
-	~H_VerticalQuadrupole() {};
-//@}
-	H_VerticalQuadrupole* clone() const ;
-private:
+		H_VerticalQuadrupole(string nameE, const double s, const double k, const double l):H_Quadrupole(nameE,VQUADRUPOLE,s,k,l) {init();}
+		~H_VerticalQuadrupole() {return;};
+	//@}
+	private:
 		virtual void setTypeString() {typestring = VQUADRUPOLENAME;} ;
-		virtual void setMatrix(const float, const float, const float) ;
+		virtual void setMatrix(const float, const float, const float) const;
 };
 
