Index: trunk/Utilities/Fastjet/plugins/CDFCones/interface/CalTower.hh
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/interface/CalTower.hh	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/interface/CalTower.hh	(revision 35)
@@ -1,4 +1,6 @@
 #ifndef _CAL_TOWER_HH_
 #define _CAL_TOWER_HH_
+
+// Modified by X. Rouby for integration in Delphes
 
 #include <cmath>
@@ -8,49 +10,133 @@
 #endif
 
-const double TOWER_THETA[23] = {  3.000,  5.700,  8.400, 11.100, 13.800, 16.500, 19.200, 21.900, 24.600, 27.300, 30.000, 33.524,
-				  36.822, 40.261, 43.614, 47.436, 51.790, 56.735, 62.310, 68.516, 75.297, 82.526, 90.000 };
+const double pi = acos(-1);
+
+// CDF data : 23 towers. step=2.7Â° at the beginning, and after, it changes
+//const unsigned int ntower = 23;
+//const double TOWER_THETA[ntower] = {  3.000,  5.700,  8.400, 11.100, 13.800, 16.500, 19.200, 21.900, 24.600, 27.300, 30.000,// step=2.7Â°
+//          33.524,  36.822, 40.261, 43.614, 47.436, 51.790, 56.735, 62.310, 68.516, 75.297, 82.526, 90.000 };
+
+// CMS HB: 0.087 x 0.087 = 0.087 x 5Â°
+// CMS HF: 0.175 x 0.175 = 0.175 x 10Â°
+// CMS data
+const unsigned int ntower = 40;
+//const double TOWER_ETA[ntower] = {  
+//    0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609, 0.696, 0.783, 0.870, 0.957, 1.044, 1.131, 1.218, 1.305, 1.392, 1.479, 1.566,
+//    1.653, 1.740, 1.830, 1.930, 2.043, 2.172, 2.322, 2.500, 2.650, 2.868, 2.950, 3.125, 3.300, 3.475, 3.650, 3.825, 4.000, 4.175,
+//    4.350, 4.525, 4.700}
+const double TOWER_THETA[ntower] = {
+1.04221324479 ,  1.24151823936 ,  1.4789296564 ,  1.76172836867 ,  2.09858297042 ,  2.49981191976 ,  2.97769357253 ,  3.54683172517 ,  
+4.22458468545 ,  5.03156565222 ,  5.99222070913 ,  6.50323511476 ,  8.08260215014 ,  9.38520669791 ,  11.2029938559 ,  13.0015703243 ,  
+14.7731659079 ,  16.5174067026 ,  18.2267592981 ,  19.9103474053 ,  21.6789816306 ,  23.5965023504 ,  25.6731077732 ,  27.9190341722 ,  
+30.3443463769 ,  32.9586699802 ,  35.7708584993 ,  38.7885912317 ,  42.017901925 ,  45.4626450521 ,  49.1239157061 ,  52.9994507062 ,  
+57.0830516071 ,  61.3640831827 ,  65.8271109013 ,  70.4517445074 ,  75.2127486134 ,  80.0804628398 ,  85.02154355, 90
+};
 
 class CalTower
 {
  public:
-
   double Et,eta,phi;
   int iEta,iPhi;
 
   CalTower(): Et(0), eta(0), phi(0), iEta(-1), iPhi(-1) {}
-  CalTower(double Et0, double eta0, double phi0): Et(Et0), eta(eta0), phi(phi0)
+  CalTower(const double Et0, const double eta0, const double phi0): Et(Et0), eta(eta0), phi(phi0)
   {
-    if(fabs(eta) < -log(tan(TOWER_THETA[0]*M_PI/180/2))){
-      if(eta <= 0){
-	for(int i = 0; i < 22; i++)
-	  if(eta < -log(tan((180 - TOWER_THETA[i + 1])*M_PI/180/2))){
+    if(fabs(eta) < pseudorapidity(TOWER_THETA[0])) { // |eta| < 3.64
+      if(eta <= 0){ // central particle, but negative eta
+	for(unsigned int i = 0; i < ntower-1; i++)
+	  if(eta < pseudorapidity(180 - TOWER_THETA[i + 1])){ // eta < -3 ; -2.61 ; ... ; 0
 	    iEta = 4 + i;
 	    break;
 	  }
-      }
-      else{
-	for(int i = 0; i < 22; i++)
-	  if(-eta < -log(tan((180 - TOWER_THETA[i + 1])*M_PI/180/2))){
+      } // central particle but negative eta
+      else{ // central particle but positive eta
+	for(unsigned int i = 0; i < ntower-1; i++)
+	  if(-eta < pseudorapidity(180 - TOWER_THETA[i + 1])){ // eta > 3 ; 2.61 ; ... ; 0
 	    iEta = 47 - i;
 	    break;
 	  }
-      }
-      if(iEta >= 8 && iEta < 14 || iEta >= 38 && iEta < 44)
-	iPhi = int(phi/2/M_PI*48)%48;
+      } // central particle but positive eta  
+      if( (iEta >= 8 && iEta < 14) || (iEta >= 38 && iEta < 44) )
+	iPhi = int(phi/(2*pi)*48)%48;
       else
-	iPhi = int(phi/2/M_PI*24)%24;
+	iPhi = int(phi/(2*pi)*24)%24;
     }
-    else{
+    else{ // particle beyond detector reach : 
       iEta = -1;
       iPhi = -1;
     }
   }
-  CalTower(double Et0, double eta0, double phi0, int iEta0, int iPhi0): Et(Et0), eta(eta0), phi(phi0), iEta(iEta0), iPhi(iPhi0) {}
+  CalTower(const double Et0, const double eta0, const double phi0, const int iEta0, const int iPhi0): Et(Et0), eta(eta0), phi(phi0), iEta(iEta0), iPhi(iPhi0) {}
   CalTower(const CalTower& c): Et(c.Et), eta(c.eta), phi(c.phi), iEta(c.iEta), iPhi(c.iPhi) {}
-  bool isEqual(CalTower c)
+  bool isEqual(const CalTower& c)
   {
     return Et == c.Et && eta == c.eta && phi == c.phi && iEta == c.iEta && iPhi == c.iPhi;
   }
+
+// converts theta angle [degrees] into pseudorapidity
+ double pseudorapidity(const double theta) {
+         return -log(tan( (theta/2.) * (pi/180.) ));
+         }
+
 };
 
+/***** 
+ e.g. 
+  iEta==4  si -3.642 < eta < -3.000
+  iEta==47 si  3.000 < eta <  3.642
+  iEta==-1 si eta < -3.642 ou si eta > 3.642
+
+ i   theta    pseudorapidity     iEta
+--------------------------------------
+ 0   3.0      -3.00008274261        4
+ 1   5.7      -2.61134904017        5
+ 2   8.4      -2.33129451223        6
+ 3   11.1     -2.1118548488         7
+ 4   13.8     -1.93106912741        8
+ 5   16.5     -1.77704423284        9
+ 6   19.2     -1.64260787639       10
+ 7   21.9     -1.52309848418       11
+ 8   24.6     -1.41531379676       12
+ 9   27.3     -1.31695789692       13
+10   30.0     -1.19999982651       14
+11   33.524   -1.10000635195       15
+12   36.822   -1.00361552815       16
+13   40.261   -0.916007799535      17
+14   43.614   -0.822472442947      18
+15   47.436   -0.72264587494       19
+16   51.79    -0.616250691646      20
+17   56.735   -0.503273260393      21
+18   62.31    -0.384075299436      22
+19   68.516   -0.259479460739      23
+20   75.297   -0.130817437415      24
+21   82.526    1.11022302463e-16   25
+
+
+ i   theta    pseudorapidity     iEta
+--------------------------------------
+ 0   3.0      -3.00008274261      47
+ 1   5.7      -2.61134904017      46
+ 2   8.4      -2.33129451223      45
+ 3   11.1     -2.1118548488       44
+ 4   13.8     -1.93106912741      43
+ 5   16.5     -1.77704423284      42
+ 6   19.2     -1.64260787639      41
+ 7   21.9     -1.52309848418      40
+ 8   24.6     -1.41531379676      39
+ 9   27.3     -1.31695789692      38
+10   30.0     -1.19999982651      37
+11   33.524   -1.10000635195      36
+12   36.822   -1.00361552815      35
+13   40.261   -0.916007799535     34
+14   43.614   -0.822472442947     33
+15   47.436   -0.72264587494      32
+16   51.79    -0.616250691646     31
+17   56.735   -0.503273260393     30
+18   62.31    -0.384075299436     29
+19   68.516   -0.259479460739     28
+20   75.297   -0.130817437415     27
+21   82.526   1.11022302463e-16   26
+*****/
+
 #endif
+
Index: trunk/Utilities/Fastjet/plugins/CDFCones/interface/Centroid.hh
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/interface/Centroid.hh	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/interface/Centroid.hh	(revision 35)
@@ -11,5 +11,4 @@
 {
  public:
-
   double Et,eta,phi;
 
@@ -17,5 +16,5 @@
   Centroid(double centroidEt, double centroidEta, double centroidPhi): Et(centroidEt), eta(centroidEta), phi(centroidPhi) {}
   Centroid(const Centroid& c): Et(c.Et), eta(c.eta), phi(c.phi) {}
-  void add(Centroid c)
+  void add(const Centroid& c)
   {
     double newEt = Et + c.Et;
@@ -33,5 +32,5 @@
     Et = newEt;
   }
-  void subtract(Centroid c)
+  void subtract(const Centroid& c)
   {
     double newEt = Et - c.Et;
@@ -49,5 +48,5 @@
     Et = newEt;
   }
-  bool isEqual(Centroid c)
+  bool isEqual(const Centroid& c)
   {
     return Et == c.Et && eta == c.eta && phi == c.phi;
Index: trunk/Utilities/Fastjet/plugins/CDFCones/interface/Cluster.hh
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/interface/Cluster.hh	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/interface/Cluster.hh	(revision 35)
@@ -30,5 +30,5 @@
     pt_tilde = 0.0;
   }
-  void addTower(PhysicsTower p)
+  void addTower(const PhysicsTower& p)
   {
     towerList.push_back(p);
@@ -37,5 +37,5 @@
     pt_tilde += p.fourVector.pt();
   }
-  void removeTower(PhysicsTower p)
+  void removeTower(const PhysicsTower& p)
   {
     for(std::vector<PhysicsTower>::iterator towerIter = towerList.begin(); towerIter != towerList.end(); towerIter++)
Index: trunk/Utilities/Fastjet/plugins/CDFCones/interface/LorentzVector.hh
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/interface/LorentzVector.hh	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/interface/LorentzVector.hh	(revision 35)
@@ -30,5 +30,5 @@
     return r;
   }
-  void add(LorentzVector v)
+  void add(const LorentzVector& v)
   {
     px += v.px;
@@ -37,5 +37,5 @@
     E  += v.E;
   }
-  void subtract(LorentzVector v)
+  void subtract(const LorentzVector& v)
   {
     px -= v.px;
@@ -44,5 +44,5 @@
     E  -= v.E;
   }
-  bool isEqual(LorentzVector v)
+  bool isEqual(const LorentzVector& v)
   {
     return px == v.px && py == v.py && pz == v.pz && E == v.E;
Index: trunk/Utilities/Fastjet/plugins/CDFCones/interface/MidPointAlgorithm.hh
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/interface/MidPointAlgorithm.hh	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/interface/MidPointAlgorithm.hh	(revision 35)
@@ -15,5 +15,5 @@
   double _coneRadius;
   double _coneAreaFraction;
-  int    _maxPairSize;
+  unsigned int    _maxPairSize;
   int    _maxIterations;
   double _overlapThreshold;
@@ -44,5 +44,5 @@
 		   std::vector<Cluster>& stableCones, bool reduceConeSize);
   void addClustersToPairs(std::vector<int>& testPair, std::vector< std::vector<int> >& pairs,
-			  std::vector< std::vector<bool> >& distanceOK, int maxClustersInPair);
+			  std::vector< std::vector<bool> >& distanceOK, unsigned int maxClustersInPair);
   void splitAndMerge(std::vector<Cluster>& stableCones, std::vector<Cluster>& jets);
   void run(std::vector<PhysicsTower>& particles, std::vector<Cluster>& jets);
Index: trunk/Utilities/Fastjet/plugins/CDFCones/interface/PhysicsTower.hh
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/interface/PhysicsTower.hh	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/interface/PhysicsTower.hh	(revision 35)
@@ -8,14 +8,15 @@
 {
  public:
-
   LorentzVector fourVector;
   CalTower calTower;
+  /// addition by GPS (2008-08-15) for tracking within fastjet
+  int fjindex;
 
   PhysicsTower(): fourVector(LorentzVector()), calTower(CalTower()), fjindex(-1) {}
-  PhysicsTower(LorentzVector v, CalTower c): fourVector(v), calTower(c), fjindex(-1) {}
+  PhysicsTower(const LorentzVector& v, const CalTower& c): fourVector(v), calTower(c), fjindex(-1) {}
   PhysicsTower(const PhysicsTower& p): fourVector(p.fourVector), calTower(p.calTower), fjindex(p.fjindex) {}
-  PhysicsTower(CalTower c):
+  PhysicsTower(const CalTower& c):
     fourVector(LorentzVector(c.Et*cos(c.phi),c.Et*sin(c.phi),c.Et*sinh(c.eta),c.Et*cosh(c.eta))), calTower(c), fjindex(-1) {}
-  PhysicsTower(LorentzVector v): fourVector(v), calTower(CalTower(v.Et(),v.eta(),v.phi())), fjindex(-1) {}
+  PhysicsTower(const LorentzVector& v): fourVector(v), calTower(CalTower(v.Et(),v.eta(),v.phi())), fjindex(-1) {}
   double Et()   const {return calTower.Et;}
   double eta()  const {return calTower.eta;}
@@ -23,10 +24,9 @@
   int    iEta() const {return calTower.iEta;}
   int    iPhi() const {return calTower.iPhi;}
-  bool isEqual(PhysicsTower p)
+  bool isEqual(const PhysicsTower& p)
   {
     return fourVector.isEqual(p.fourVector) && calTower.isEqual(p.calTower);
   }
-  /// addition by GPS (2008-08-15) for tracking within fastjet
-  int fjindex;
+
 };
 
Index: trunk/Utilities/Fastjet/plugins/CDFCones/src/MidPointAlgorithm.cc
===================================================================
--- trunk/Utilities/Fastjet/plugins/CDFCones/src/MidPointAlgorithm.cc	(revision 34)
+++ trunk/Utilities/Fastjet/plugins/CDFCones/src/MidPointAlgorithm.cc	(revision 35)
@@ -18,9 +18,9 @@
   std::vector< std::vector<bool> > distanceOK;
   distanceOK.resize(stableCones.size() - 1);
-  for(int nCluster1 = 1; nCluster1 < stableCones.size(); nCluster1++){
+  for(unsigned int nCluster1 = 1; nCluster1 < stableCones.size(); nCluster1++){
     distanceOK[nCluster1 - 1].resize(nCluster1);
     double cluster1Rapidity = stableCones[nCluster1].fourVector.y();
     double cluster1Phi      = stableCones[nCluster1].fourVector.phi();
-    for(int nCluster2 = 0; nCluster2 < nCluster1; nCluster2++){
+    for(unsigned int nCluster2 = 0; nCluster2 < nCluster1; nCluster2++){
       double cluster2Rapidity = stableCones[nCluster2].fourVector.y();
       double cluster2Phi      = stableCones[nCluster2].fourVector.phi();
@@ -37,5 +37,5 @@
   std::vector< std::vector<int> > pairs(0);
   std::vector<int> testPair(0);
-  int maxClustersInPair = _maxPairSize;
+  unsigned int maxClustersInPair = _maxPairSize;
   if(!maxClustersInPair)
     maxClustersInPair = stableCones.size();
@@ -44,8 +44,8 @@
   // Loop over all combinations. Calculate MidPoint. Make midPointClusters.
   bool reduceConeSize = false;
-  for(int iPair = 0; iPair < pairs.size(); iPair++){
+  for(unsigned int iPair = 0; iPair < pairs.size(); iPair++){
     // Calculate rapidity, phi and pT of MidPoint.
     LorentzVector midPoint(0,0,0,0);
-    for(int iPairMember = 0; iPairMember < pairs[iPair].size(); iPairMember++)
+    for(unsigned int iPairMember = 0; iPairMember < pairs[iPair].size(); iPairMember++)
       midPoint.add(stableCones[pairs[iPair][iPairMember]].fourVector);
     iterateCone(midPoint.y(),midPoint.phi(),midPoint.pt(),towers,stableCones,reduceConeSize);
@@ -116,5 +116,5 @@
 
 void MidPointAlgorithm::addClustersToPairs(std::vector<int>& testPair, std::vector< std::vector<int> >& pairs,
-					   std::vector< std::vector<bool> >& distanceOK, int maxClustersInPair)
+					   std::vector< std::vector<bool> >& distanceOK, unsigned int maxClustersInPair)
 {
   // Recursively adds clusters to pairs, triplets, ... whose mid-points are then calculated.
@@ -124,8 +124,8 @@
   if(testPair.size())
     nextClusterStart = testPair.back() + 1;
-  for(int nextCluster = nextClusterStart; nextCluster <= distanceOK.size(); nextCluster++){
+  for(unsigned int nextCluster = nextClusterStart; nextCluster <= distanceOK.size(); nextCluster++){
     // Is new SeedCone less than 2*_coneRadius apart from all clusters in testPair?
     bool addCluster = true;
-    for(int iCluster = 0; iCluster < testPair.size() && addCluster; iCluster++)
+    for(unsigned int iCluster = 0; iCluster < testPair.size() && addCluster; iCluster++)
       if(!distanceOK[nextCluster - 1][testPair[iCluster]])
 	addCluster = false;
