Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

AlephDurhamAlgo.h

Go to the documentation of this file.
00001 #include "DurhamProtoJet.h"
00002 #include <float.h>
00003 
00004 // From Orca 
00005 // Written by J.P. Wellisch, 25. Jan 1999
00006 // Adapted to Alpha++ by C. Delaere
00007 //              Added : - DurhamYn
00008 //                      - fixed number of jets
00009 
00011 
00024 template <class Type>
00025 AlephCollection<AlJet> AlephCollection<Type>::DurhamJet(float theYCut, int Scheme, float Qelep) const
00026 {
00027   // update the static member of DurhamProtoJet: used to add 2 protojets
00028   DurhamProtoJet::Scheme = Scheme;
00029   // the result...
00030   AlephCollection<AlJet> result;
00031   // the temp vector to work
00032   vector<DurhamProtoJet> theProtoJets;
00033   const_iterator i = begin();
00034   double totalEnergy = 0.;
00035   // make a copy of the original vector (as protojets) and compute Evis 
00036   for (i = begin(); i != end(); i++)
00037     if (!((*i)->isLocked()))
00038       {
00039         totalEnergy += (*i)->A4V().e() ;
00040         DurhamProtoJet aProtoJet(*(*i));
00041         theProtoJets.push_back(aProtoJet);
00042       }
00043   if(Qelep != 0.) totalEnergy=Qelep;
00044   int Np = theProtoJets.size();
00045   double totalE2 = totalEnergy*totalEnergy;
00046 
00047   // Check if # of particles is o.k.
00048   if (Np < 2)
00049     {
00050       result.resize(0);
00051       fout << 
00052         "there is only one particle, therefore Jet Algorithm cannot be performed" 
00053            << endl;
00054       return result;
00055     }
00056 
00057   double minY = 0;
00058   int iYcut = (int) theYCut;
00059   // Main loop
00060   while(((minY<theYCut) && (theYCut >= 0.)) || 
00061         (((int)theProtoJets.size() != -iYcut) && (theYCut < 0.)))
00062   {
00063     minY = DBL_MAX;
00064     vector<DurhamProtoJet>::iterator aCandidate = 0;
00065     vector<DurhamProtoJet>::iterator aNextNeighbour = 0;
00066     vector<DurhamProtoJet>::iterator i1 = theProtoJets.begin();
00067     for(i1 = theProtoJets.begin(); i1!= theProtoJets.end(); i1++)
00068       {
00069         double y = DBL_MAX;
00070         vector<DurhamProtoJet>::iterator aNeighbour = i1->findNextNeighbour(theProtoJets);
00071         if(aNeighbour != 0) y = i1->getYTimesE2(aNeighbour)/totalE2;
00072         if(y<minY) 
00073           {
00074             minY = y;
00075             aCandidate = i1;
00076             aNextNeighbour = aNeighbour;
00077           }
00078       }
00079     if(((minY<theYCut) && (theYCut >= 0.)) || 
00080        (((int)theProtoJets.size() != -iYcut) && (theYCut < 0.)))
00081       {
00082         *aCandidate += *aNextNeighbour;
00083         theProtoJets.erase(aNextNeighbour);
00084       }
00085   }
00086   
00087   // build the result from the protojets 
00088   // (uses the conversion constructor of AlJet)
00089   vector<DurhamProtoJet>::iterator aJetList;
00090   for(aJetList = theProtoJets.begin();
00091       aJetList != theProtoJets.end();
00092       aJetList++)
00093     result.push_back(*aJetList);
00094   // return an AlephCollection of AlJet
00095   return result;
00096 }
00097 
00099 
00108 template <class Type>
00109 vector<float> AlephCollection<Type>::DurhamYn(int Scheme, float Qelep) const
00110 {
00111   // update the static member of DurhamProtoJet: used to add 2 protojets
00112   DurhamProtoJet::Scheme = Scheme;
00113   // the temp vector to work
00114   vector<DurhamProtoJet> theProtoJets;
00115   const_iterator i = begin();
00116   double totalEnergy = 0.;
00117   // make a copy of the original vector (as protojets) and compute Evis 
00118   for (i = begin(); i != end(); i++)
00119     if (!((*i)->isLocked()))
00120       {
00121         totalEnergy += (*i)->A4V().e() ;
00122         DurhamProtoJet aProtoJet(*(*i));
00123         theProtoJets.push_back(aProtoJet);
00124       }
00125   if(Qelep != 0.) totalEnergy=Qelep;
00126   int Np = theProtoJets.size();
00127   // the result...
00128   vector<float> Yn(Np-1);
00129   double totalE2 = totalEnergy*totalEnergy;
00130 
00131   // Check if # of particles is o.k.
00132   if (Np < 2)
00133     {
00134       Yn.resize(0);
00135       fout << "there is only one particle, therefore AJetJn cannot be performed" << endl;
00136       return Yn;
00137     }
00138 
00139   double minY = 0;
00140   // Main loop
00141   while( theProtoJets.size() != 1)
00142   {
00143     minY = DBL_MAX;
00144     vector<DurhamProtoJet>::iterator aCandidate = 0;
00145     vector<DurhamProtoJet>::iterator aNextNeighbour = 0;
00146     vector<DurhamProtoJet>::iterator i1 = theProtoJets.begin();
00147     for(i1 = theProtoJets.begin(); i1!= theProtoJets.end(); i1++)
00148       {
00149         double y = DBL_MAX;
00150         vector<DurhamProtoJet>::iterator aNeighbour = i1->findNextNeighbour(theProtoJets);
00151         if(aNeighbour != 0) y = i1->getYTimesE2(aNeighbour)/totalE2;
00152         if(y<minY) 
00153           {
00154             minY = y;
00155             aCandidate = i1;
00156             aNextNeighbour = aNeighbour;
00157           }
00158       }
00159         *aCandidate += *aNextNeighbour;
00160         theProtoJets.erase(aNextNeighbour);
00161         Yn[theProtoJets.size()-1]=minY;
00162   }
00163   // return a vector of float
00164   return Yn;
00165 }
00166 
00167 

Generated at Wed Jun 18 17:19:09 2003 for ALPHA++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001