Index: trunk/Utilities/Hector/src/H_AbstractBeamLine.cc
===================================================================
--- trunk/Utilities/Hector/src/H_AbstractBeamLine.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_AbstractBeamLine.cc	(revision 281)
@@ -1,13 +1,19 @@
-/*
----- 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)
-*/
-
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_AbstractBeamLine.cc
@@ -45,7 +51,8 @@
 }
 
-H_AbstractBeamLine::H_AbstractBeamLine(const H_AbstractBeamLine& beamline) {
-	elements = beamline.elements;
-	matrices = beamline.matrices;
+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;
@@ -55,5 +62,6 @@
 H_AbstractBeamLine& H_AbstractBeamLine::operator=(const H_AbstractBeamLine& beamline) {
 	if(this== &beamline) return *this;
-        elements = beamline.elements;
+	//elements = beamline.elements; //<-- bad ! the new vector contains the same pointers as the previous one
+	cloneElements(beamline);
         matrices = beamline.matrices;
         beam_mat = beamline.beam_mat;
@@ -83,4 +91,12 @@
 	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);
+        }
 }
 
@@ -101,18 +117,4 @@
 }
 
-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<<"<H_AbstractBeamLine> 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 {
 	return beam_mat;
@@ -205,12 +207,14 @@
 }
 
-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;
-}
+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::showElements() const{
@@ -485,5 +489,5 @@
 	/// @param offset In meters
 
-	extern bool relative_energy;
+	extern int relative_energy;
 	if(!relative_energy) {
 		vector<H_OpticalElement*>::iterator element_i;
Index: trunk/Utilities/Hector/src/H_Aperture.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Aperture.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Aperture.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Aperture.cc
@@ -20,44 +27,22 @@
 using namespace std;
 
-H_Aperture::H_Aperture() {
-        type = NONE;
-        setApertureString();
-        x1 = 0;
-        x2 = 0;
-        x3 = 0;
-        x4 = 0;
-        fx = 0;
-        fy = 0;
+H_Aperture::H_Aperture() :
+        type_(NONE), x1(0), x2(0), x3(0), x4(0), fx(0), fy(0),  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) {
+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()) {
     /// @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;
-	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(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::operator=(const H_Aperture& ap) {
 	if(this==&ap) return *this;
-	type = ap.type;
-	aptypestring = ap.aptypestring;
+	type_ = ap.type_;
 	x1 = ap.x1;
 	x2 = ap.x2;
@@ -66,10 +51,16 @@
 	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 << "Aperture shape:" << getTypeString() << ", parameters "<<x1<<", "<<x2<<", "<<x3<<", "<<x4<<endl;
-        cout << " \t Center : " << fx << "," << fy << endl;
+	cout << *this;
         return;
 }
@@ -90,6 +81,6 @@
 
 
-void H_Aperture::setApertureString() {
-	switch (type) {
+/*void H_Aperture::setApertureString() {
+	switch (type_) {
 		case NONE: aptypestring = NONENAME; break;
  		case RECTANGULAR: aptypestring = RECTANGULARNAME; break;
@@ -100,2 +91,17 @@
 	}
 }
+*/
+
+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: trunk/Utilities/Hector/src/H_Beam.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Beam.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Beam.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Beam.cc
@@ -55,9 +62,5 @@
 };
 
-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) {
+void H_Beam::createBeamParticles(const unsigned int Number_of_particles, const double p_mass, const double p_charge, TRandom* r) {
 	beamParticles.clear();
 	Nparticles = (Number_of_particles<1) ? 1 : Number_of_particles;
@@ -66,8 +69,8 @@
 		p.setPosition(fx_ini,fy_ini,tx_ini,ty_ini,fs_ini);
 		p.setE(fe_ini);
-		p.smearPos(x_disp,y_disp);
-		p.smearAng(tx_disp,ty_disp);
-		p.smearE(e_disp);
-		p.smearS(s_disp);
+		p.smearPos(x_disp,y_disp,r);
+		p.smearAng(tx_disp,ty_disp,r);
+		p.smearE(e_disp,r);
+		p.smearS(s_disp,r);
 		if (VERBOSE) {if (i==0) cout << " x_ini , tx_ini " << p.getX() << " " << p.getTX() << endl;}
 		beamParticles.push_back(p);
@@ -76,5 +79,5 @@
 
 //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) {
+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;
@@ -83,17 +86,17 @@
                 H_BeamParticle p(p_mass,p_charge);
                 if (flat) {
-                        gx = gRandom->Uniform(fx_min,fx_max);
-                        gy = gRandom->Uniform(fy_min,fy_max);
-                        gs = gRandom->Uniform(fs_min,fs_max);
-                        gtx = gRandom->Uniform(tx_min,tx_max);
-                        gty = gRandom->Uniform(ty_min,ty_max);
-                        gE = gRandom->Uniform(E_min,E_max);
+                        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 = gRandom->Gaus((fx_min+fx_max)/2,(-fx_min+fx_max)/2);
-                        gy = gRandom->Gaus((fy_min+fy_max)/2,(-fy_min+fy_max)/2);
-                        gs = gRandom->Gaus((fs_min+fs_max)/2,(-fs_min+fs_max)/2);
-                        gtx = gRandom->Gaus((tx_min+tx_max)/2,(-tx_min+tx_max)/2);
-                        gty = gRandom->Gaus((ty_min+ty_max)/2,(-ty_min+ty_max)/2);
-                        gE = gRandom->Gaus ((E_min+E_max)/2,(-E_min+E_max)/2);
+                        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);
@@ -179,8 +182,4 @@
 }
 
-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) {
@@ -189,10 +188,4 @@
                 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);
 }
 
@@ -386,10 +379,11 @@
 }
 
-void H_Beam::printProperties() const {
+std::ostream& operator<< (std::ostream& os, const H_Beam& be) {
 	vector<H_BeamParticle>::const_iterator particle_i;
-	cout << "There are " << Nparticles << " in the beam." << endl;
-	for (particle_i = beamParticles.begin();particle_i < beamParticles.end(); particle_i++) {
-		particle_i->printProperties();
-	}
+	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;
 }
 
Index: trunk/Utilities/Hector/src/H_BeamLine.cc
===================================================================
--- trunk/Utilities/Hector/src/H_BeamLine.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_BeamLine.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_BeamLine.cc
@@ -39,14 +46,19 @@
 // are opposite to Wille's. See fill() for more details.
 
-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) {
+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=
 	direction = beam.direction;
 	ips = beam.ips;
@@ -55,20 +67,5 @@
 	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) {
-	findIP(filename,"IP5");
-	return;
 }
 
@@ -125,9 +122,4 @@
 	temp[3] = ipty;
 	return temp;
-}
-
-void H_BeamLine::fill(const string& filename) {
-	fill(filename,1,"IP5");
-	return;
 }
 
Index: trunk/Utilities/Hector/src/H_BeamLineParser.cc
===================================================================
--- trunk/Utilities/Hector/src/H_BeamLineParser.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_BeamLineParser.cc	(revision 281)
@@ -1,18 +1,25 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_BeamLineParser.cc
 /// \brief Reader for madx tables
 ///
-/// 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
+/// 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
 /// 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.
Index: trunk/Utilities/Hector/src/H_BeamParticle.cc
===================================================================
--- trunk/Utilities/Hector/src/H_BeamParticle.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_BeamParticle.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_BeamParticle.cc
@@ -39,5 +46,5 @@
 using namespace std;
 
-void H_BeamParticle::init() {
+void H_BeamParticle::init() { // for more efficiency, put the objects away from init!
 	mp = MP;
 	qp = QP;
@@ -57,23 +64,14 @@
 }
 
-H_BeamParticle::H_BeamParticle() {
+H_BeamParticle::H_BeamParticle() { 
 	init();
 }
 
-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));
+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) {
 	if(p.hasstopped) stop_element = new H_OpticalElement(*(p.stop_element)); 
-	positions = p.positions;
 }
 
@@ -100,9 +98,10 @@
         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;
 }
 
-bool H_BeamParticle::stopped(const H_AbstractBeamLine * beamline) {
+const 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++) {
@@ -159,8 +158,19 @@
 }
 
-void H_BeamParticle::smearPos(const double dx,const double dy) {
+
+
+void H_BeamParticle::smearPos(const double dx,const double dy, TRandom* r) {
   // the beam is centered on (fx,fy) at IP
-        fx = gRandom->Gaus(fx,dx);
-        fy = gRandom->Gaus(fy,dy);
+        fx = r->Gaus(fx,dx);
+        fy = r->Gaus(fy,dy);
+        positions.clear();
+        addPosition(fx,thx,fy,thy,fs);
+        return;
+}
+
+void H_BeamParticle::smearAng(const double tx, const double ty, TRandom* r) {
+  // the beam transverse direction is centered on (thx,thy) at IP
+        thx = r->Gaus(thx,tx);
+        thy = r->Gaus(thy,ty);
 	positions.clear();
 	addPosition(fx,thx,fy,thy,fs);
@@ -168,43 +178,11 @@
 }
 
-void H_BeamParticle::smearPos() {
-  // the beam is centered on (fx,fy) at IP
-	fx = gRandom->Gaus(fx,SX);
-	fy = gRandom->Gaus(fy,SY);
-	positions.clear();
-	addPosition(fx,thx,fy,thy,fs);
-	return;
-}
-
-void H_BeamParticle::smearAng(const double tx, const double ty) {
-  // the beam transverse direction is centered on (thx,thy) at IP
-        thx = gRandom->Gaus(thx,tx);
-        thy = gRandom->Gaus(thy,ty);
-	positions.clear();
-	addPosition(fx,thx,fy,thy,fs);
-	return;
-}
-
-void H_BeamParticle::smearAng() {
-   // the beam transverse direction is centered on (thx,thy) at IP
-	thx = gRandom->Gaus(thx,STX);
-	thy = gRandom->Gaus(thy,STY);
-	positions.clear();
-	addPosition(fx,thx,fy,thy,fs);
-	return;
-}
-
-void H_BeamParticle::smearE(const double erre) {
-	energy = gRandom->Gaus(energy,erre);
-	return;
-}
-
-void H_BeamParticle::smearE() {
-	energy = gRandom->Gaus(energy,SBE);
-	return;
-}
-
-void H_BeamParticle::smearS(const double errs) {
-        fs= gRandom->Gaus(fs,errs);
+void H_BeamParticle::smearE(const double erre, TRandom* r) {
+	energy = r->Gaus(energy,erre);
+	return;
+}
+
+void H_BeamParticle::smearS(const double errs, TRandom* r) {
+        fs= r->Gaus(fs,errs);
 	positions.clear();
 	addPosition(fx,thx,fy,thy,fs);
@@ -212,10 +190,4 @@
 }
 
-void H_BeamParticle::smearS() {
-        fs = gRandom->Gaus(fs,SS);
-	positions.clear();
-	addPosition(fx,thx,fy,thy,fs);
-        return;
-}
 
 void H_BeamParticle::set4Momentum(const double px, const double py, const double pz, const double ene) {
@@ -267,9 +239,4 @@
 	if(hasstopped) return stop_element;
 	else { H_OpticalElement * dummy_el = new H_Drift("",0,0); return dummy_el;}
-}
-
-void H_BeamParticle::emitGamma(const double gee, const double gq2) {
-	emitGamma(gee,gq2,0,2*pi);
-	return;
 }
 
@@ -362,13 +329,13 @@
 }
 
-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;
+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;
 }
 
@@ -491,8 +458,4 @@
 	delete [] graph;
         return ppath;
-}
-
-void H_BeamParticle::computePath(const H_AbstractBeamLine * beam) {
-	computePath(beam,true);
 }
 
Index: trunk/Utilities/Hector/src/H_CircularAperture.cc
===================================================================
--- trunk/Utilities/Hector/src/H_CircularAperture.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_CircularAperture.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_CircularAperture.cc
@@ -23,18 +30,11 @@
 using namespace std;
 
-/// 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; 
-}
-
 H_CircularAperture* H_CircularAperture::clone() const {
 	return new H_CircularAperture(x1,fx,fy);
 }
 
-void H_CircularAperture::printProperties() const {
-        cout << "Aperture shape:" << getTypeString() << ", aperture radius : " << x1 << endl;
-        cout << " \t Center : " << fx << "," << fy << endl;
-        return;
+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;
 }
Index: trunk/Utilities/Hector/src/H_Dipole.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Dipole.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Dipole.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Dipole.cc
@@ -25,17 +32,12 @@
 }
 
-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();
+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;
 	}
 
-	if(element_length<0)  { if(VERBOSE) cout<<"<H_Dipole> ERROR : Interpenetration of elements !"<<endl; }
-	if(element_length==0) { if(VERBOSE) cout<<"<H_Dipole> WARNING : 0-length "<< name << " !" << endl; }
+	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;
 }
Index: trunk/Utilities/Hector/src/H_Drift.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Drift.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Drift.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Drift.cc
@@ -26,15 +33,12 @@
 }
 
-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();
+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;
         }
-	if(element_length<0)  { if(VERBOSE) cout<<"<H_Drift> ERROR : Interpenetration of elements !"<<endl; }
-	if(element_length==0) { if(VERBOSE) cout<<"<H_Drift> WARNING : 0-length "<< name << " !" << endl; }
+	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;
 }
 
Index: trunk/Utilities/Hector/src/H_EllipticAperture.cc
===================================================================
--- trunk/Utilities/Hector/src/H_EllipticAperture.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_EllipticAperture.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_EllipticAperture.cc
@@ -25,5 +32,20 @@
 using namespace std;
 
-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) {
+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
+        /// @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
@@ -48,7 +70,7 @@
 }
 
-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: trunk/Utilities/Hector/src/H_HorizontalKicker.cc
===================================================================
--- trunk/Utilities/Hector/src/H_HorizontalKicker.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_HorizontalKicker.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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.cc
Index: trunk/Utilities/Hector/src/H_HorizontalQuadrupole.cc
===================================================================
--- trunk/Utilities/Hector/src/H_HorizontalQuadrupole.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_HorizontalQuadrupole.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_HorizontalQuadrupole.cc
Index: trunk/Utilities/Hector/src/H_Kicker.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Kicker.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Kicker.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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.cc
@@ -27,17 +34,13 @@
 }
 
-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();
+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;
         }
 
-	if(element_length<0)  { if(VERBOSE) cout<<"<H_Kicker> ERROR : Interpenetration of elements !"<<endl; }
-	if(element_length==0) { if(VERBOSE) cout<<"<H_Kicker> WARNING : 0-length "<< name << " !" << endl; }
+	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;
 }
Index: trunk/Utilities/Hector/src/H_Marker.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Marker.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Marker.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Marker.cc
@@ -24,11 +31,10 @@
 }
 
-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();
+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;
         }
+   return os;
 }
 
Index: trunk/Utilities/Hector/src/H_OpticalElement.cc
===================================================================
--- trunk/Utilities/Hector/src/H_OpticalElement.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_OpticalElement.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_OpticalElement.cc
@@ -135,22 +142,16 @@
 */
 
-
-
-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<<"<H_OpticalElement> ERROR : Interpenetration of elements !"<<endl; }
-		if(element_length==0) { if(VERBOSE) cout<<"<H_OpticalElement> WARNING : 0-length "<< typestring << " !" << endl; }
-
- 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;
 }
 
@@ -189,5 +190,5 @@
 }
 
-TVectorD H_OpticalElement::getHitPosition(TVectorD init_pos, double energy_loss, double mp, double qp) {
+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;
@@ -196,5 +197,7 @@
 	// 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};
+	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);
@@ -253,39 +256,39 @@
    		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][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][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][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);
+	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) {
@@ -297,12 +300,12 @@
 		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<<" + "<<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;
+		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;
 
 	}
Index: trunk/Utilities/Hector/src/H_Parameters.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Parameters.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Parameters.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Parameters.cc
Index: trunk/Utilities/Hector/src/H_Quadrupole.cc
===================================================================
--- trunk/Utilities/Hector/src/H_Quadrupole.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_Quadrupole.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_Quadrupole.cc
@@ -24,17 +31,12 @@
 }
 
-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();
+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;
 	}
 
-	if(element_length<0)  { if(VERBOSE) cout<<"<H_Quadrupole> ERROR : Interpenetration of elements !"<<endl; }
-	if(element_length==0) { if(VERBOSE) cout<<"<H_Quadrupole> WARNING : 0-length "<< typestring << " !" << endl; }
+	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;
 }
Index: trunk/Utilities/Hector/src/H_RecRPObject.cc
===================================================================
--- trunk/Utilities/Hector/src/H_RecRPObject.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_RecRPObject.cc	(revision 281)
@@ -1,13 +1,19 @@
-/*
----- 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)
-*/
-
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_RecRPObject.cc
@@ -41,11 +47,9 @@
 				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)) 
-				{
-	// emax = -1; /* GeV */
-}
-
-H_RecRPObject::H_RecRPObject(float ss1, float ss2, H_AbstractBeamLine* beam) : emin(0), emax(-1), x1(0), x2(0), y1(0), y2(0), s1(ss1), s2(ss2), 
+{}
+
+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),
+				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)), 
@@ -58,7 +62,38 @@
 				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;
-	// emax = -1; /* GeV */
+	{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::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;
 }
 
@@ -308,2 +343,10 @@
 	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;
+}
Index: trunk/Utilities/Hector/src/H_RectEllipticAperture.cc
===================================================================
--- trunk/Utilities/Hector/src/H_RectEllipticAperture.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_RectEllipticAperture.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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.cc
@@ -29,5 +36,4 @@
 	/// @param l, h, L, H are the geometrical parameters of the rect-ellipse shape
 	/// @param posx, posy defines the (x,y) of the center of the shape
-	type= RECTELLIPSE;
 }
 
@@ -127,7 +133,7 @@
 }
 
-void H_RectEllipticAperture::printProperties() const {
-	cout << "Aperture shape:" << getTypeString() << ", parameters " <<x1<<", "<<x2<<", "<<x3<<", "<<x4<< endl;
-	cout << " \t Center : "<<fx<<", "<<fy<<endl;
-	return;
+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;
 }
Index: trunk/Utilities/Hector/src/H_RectangularAperture.cc
===================================================================
--- trunk/Utilities/Hector/src/H_RectangularAperture.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_RectangularAperture.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_RectangularAperture.cc
@@ -48,7 +55,9 @@
 	return;
 }
-void H_RectangularAperture::printProperties() const {
-	cout << "Aperture shape:" << getTypeString() << ", rectangle Sides : "<<x1<<", "<<x2<<endl;
-	cout << " \t Center : " << fx << "," << fy << endl;
-	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;
 }
+
Index: trunk/Utilities/Hector/src/H_RectangularCollimator.cc
===================================================================
--- trunk/Utilities/Hector/src/H_RectangularCollimator.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_RectangularCollimator.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_RectangularCollimator.cc
@@ -36,16 +43,13 @@
 }
 
-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();
+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;
 	}
 
-	if(element_length<0)  { if(VERBOSE) cout<<"<H_RectangularCollimator> ERROR : Interpenetration of elements !"<<endl; }
-	if(element_length==0) { if(VERBOSE) cout<<"<H_RectangularCollimator> WARNING : 0-length "<< name << " !" << endl; }
+	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;
 }
 
Index: trunk/Utilities/Hector/src/H_RectangularDipole.cc
===================================================================
--- trunk/Utilities/Hector/src/H_RectangularDipole.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_RectangularDipole.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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.cc
Index: trunk/Utilities/Hector/src/H_RomanPot.cc
===================================================================
--- trunk/Utilities/Hector/src/H_RomanPot.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_RomanPot.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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.cc
@@ -39,13 +46,10 @@
 }
 
-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;
+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;
 }
 
Index: trunk/Utilities/Hector/src/H_SectorDipole.cc
===================================================================
--- trunk/Utilities/Hector/src/H_SectorDipole.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_SectorDipole.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_SectorDipole.cc
Index: trunk/Utilities/Hector/src/H_TransportMatrices.cc
===================================================================
--- trunk/Utilities/Hector/src/H_TransportMatrices.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_TransportMatrices.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_TransportMatrices.cc
@@ -29,5 +36,5 @@
 
 extern double omega(const double k, const double l) {
-		// [l] = [m] and [k] = [1/mï¿œ] for quadrupoles
+		// [l] = [m] and [k] = [1/m^2] for quadrupoles
 		// [omega] = [1]
 	return sqrt(fabs(k))*l;
@@ -35,5 +42,5 @@
 
 extern double radius(const double k) {
-		// [k] = [1/mï¿œ] for quadrupoles
+		// [k] = [1/m^2] for quadrupoles
 		// [k] = [1/m]  for dipoles
 		// [radius(k)] = [m]
Index: trunk/Utilities/Hector/src/H_VerticalKicker.cc
===================================================================
--- trunk/Utilities/Hector/src/H_VerticalKicker.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_VerticalKicker.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_VerticalKicker.cc
Index: trunk/Utilities/Hector/src/H_VerticalQuadrupole.cc
===================================================================
--- trunk/Utilities/Hector/src/H_VerticalQuadrupole.cc	(revision 264)
+++ trunk/Utilities/Hector/src/H_VerticalQuadrupole.cc	(revision 281)
@@ -1,12 +1,19 @@
-/*
----- 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)
-*/
+  /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *                                                         *
+*                   --<--<--  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_VerticalQuadrupole.cc
