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

AlephAlgoThrust.h

Go to the documentation of this file.
00001 
00002 // part of AlephCollection.h
00003 // Subclass of vector.h
00004 //
00005 // Author: Dan Wallin  Date: 2000-08-11
00006 // modified 9/3/2001 : sphericity,...  C.Delaere
00007 //
00009 
00011 template <class Type>
00012 AlThrust AlephCollection<Type>::AThrust() const
00013 {
00014   const_iterator i;  
00015   for (i=begin();i<end();i++)
00016     if ((**i).TYPE() != TRACK  && (**i).TYPE() != EFLOW   && 
00017         (**i).TYPE() != GAMPEC && (**i).TYPE() != ALJET   &&
00018         (**i).TYPE() != MUON && (**i).TYPE() != ELEC  &&
00019         (**i).TYPE() != ALTAU )
00020       {
00021         cout << "AThrust : WARNING : type not supported!" << endl;
00022         exit(1);
00023       }
00024   vector<Hep3Vector> p;   
00025   int Np = size();      //number of particles
00026   AlThrust thr;         //variables of thr are zero as set 
00027                         //by the default constructor 
00028                           
00029   // select the three-momenta (use only unlocked objects)    
00030   for(int i=0; i < Np; i++) 
00031     if (!((*this)[i]->isLocked()))
00032             p.push_back((*this)[i]->A4V().vect());
00033   Np = p.size(); 
00034   Hep3Vector qtbo;
00035   Hep3Vector zero(0.,0.,0.);
00036   float vnew;
00037   
00038   // for more than 2 tracks
00039   if (Np > 2)
00040     { 
00041       float vmax  = 0.;
00042       Hep3Vector vn, vm, vc, vl;
00043       
00044       for(int i=0; i< Np-1; i++) 
00045         for(int j=i+1; j < Np; j++)
00046           {
00047             vc = p[i].cross(p[j]);
00048             vl = zero; 
00049             
00050             for(int k=0; k<Np; k++)
00051               if ((k != i) && (k != j))
00052                 if (p[k].dot(vc) >= 0.) vl = vl + p[k];
00053                 else vl = vl - p[k];
00054             
00055             // make all four sign-combinations for i,j
00056             
00057             vn = vl + p[j] + p[i];
00058             vnew = vn.mag2();
00059             if (vnew >  vmax)
00060               {  
00061                 vmax = vnew;
00062                 vm = vn;
00063               }
00064             
00065             vn = vl + p[j] - p[i];
00066             vnew = vn.mag2();
00067             if (vnew >  vmax)
00068               {  
00069                 vmax = vnew;
00070                 vm = vn;
00071               }
00072             
00073             vn = vl - p[j] + p[i];
00074             vnew = vn.mag2();
00075             if (vnew >  vmax)
00076               {  
00077                 vmax = vnew;
00078                 vm = vn;
00079               }
00080             
00081             vn = vl - p[j] - p[i];
00082             vnew = vn.mag2();
00083             if (vnew >  vmax)
00084               {  
00085                 vmax = vnew;
00086                 vm = vn;
00087               }    
00088             
00089           }
00090       // sum momenta of all particles and iterate
00091       
00092       for(int iter=1; iter<=4; iter++)
00093         {  
00094           qtbo = zero;
00095           for(int i=0; i< Np; i++)
00096             if (vm.dot(p[i]) >= 0.) 
00097               qtbo = qtbo + p[i];
00098             else 
00099               qtbo = qtbo - p[i];
00100           vnew = qtbo.mag2();
00101           if (vnew  == vmax) break;
00102           fout << endl << " I have to iterate again " <<  endl << endl;
00103           vmax = vnew;
00104           vm = qtbo;
00105         }
00106     }  // of if Np > 2
00107   else
00108     if (Np == 2)
00109       if (p[0].dot(p[1]) >= 0.) 
00110         qtbo = p[0] + p[1];
00111       else
00112         qtbo = p[0] - p[1];
00113     else if (Np == 1)
00114       qtbo = p[0];
00115     else
00116       {
00117         qtbo = zero;
00118         // thrustvalue and direction are set to zero by default constructor
00119         // shall it also be filled into ObjectV ???
00120         return thr;
00121       }
00122   
00123   // normalize thrust -division by total momentum-
00124   float vsum = 0.;
00125   for(int i=0; i < Np; i++) vsum = vsum + p[i].mag();
00126   vnew  = qtbo.mag();
00127   float v = vnew/vsum; 
00128   float x = qtbo.x()/vnew;
00129   float y = qtbo.y()/vnew;
00130   float z = qtbo.z()/vnew;
00131   thr.setA4V(x, y, z, v);
00132   return thr;
00133 }
00134 
00135 template <class Type>
00136 float AlephCollection<Type>::Sphericity() const
00137 {
00138   // First a critical check
00139   if (size()==0)
00140     {
00141       cerr << "ERROR: cannot compute Sphericity on an empty vector. ABORTING" << endl;
00142       exit(-1);
00143     }
00144   // first fill the momentum tensor
00145   HepSymMatrix MomentumTensor(3,0);
00146   for(const_iterator vec=begin();vec<end();vec++)
00147    {
00148       for(int i=0;i<3;i++)
00149         for(int j=0;j<=i;j++)
00150           if(!((*vec)->isLocked()))
00151              MomentumTensor[i][j] += (((*vec)->A4V()[i])*((*vec)->A4V()[j]));
00152    }
00153   MomentumTensor/=(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
00154   // find the eigen values (as the values on the diag matrix)
00155   HepMatrix U=diagonalize(&MomentumTensor);
00156   vector<float> eigenvalues(3);
00157   eigenvalues[0] = MomentumTensor[0][0];
00158   eigenvalues[1] = MomentumTensor[1][1];
00159   eigenvalues[2] = MomentumTensor[2][2];
00160   sort(eigenvalues.begin(),eigenvalues.end());
00161   // compute spericity
00162   float sph = ( 1.5*(1-eigenvalues[2]));
00163   return sph;
00164 }
00165 
00166 template <class Type>
00167 float AlephCollection<Type>::Aplanarity() const
00168 {
00169   // First a critical check
00170   if (size()==0)
00171     {
00172       cerr << "ERROR: cannot compute aplanarity on an empty vector. ABORTING" << endl;
00173       exit(-1);
00174     }
00175   // first fill the momentum tensor
00176   HepSymMatrix MomentumTensor(3,0);
00177   for(const_iterator vec=begin();vec<end();vec++)
00178    {
00179       for(int i=0;i<3;i++)
00180         for(int j=0;j<=i;j++)
00181           if(!((*vec)->isLocked()))
00182              MomentumTensor[i][j] += (((*vec)->A4V()[i])*((*vec)->A4V()[j]));
00183    }
00184   MomentumTensor/=(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
00185   // find the eigen values (as the values on the diag matrix)
00186   HepMatrix U = diagonalize(&MomentumTensor) ;
00187   vector<float> eigenvalues(3);
00188   eigenvalues[0] = MomentumTensor[0][0];
00189   eigenvalues[1] = MomentumTensor[1][1];
00190   eigenvalues[2] = MomentumTensor[2][2];
00191   sort(eigenvalues.begin(),eigenvalues.end());
00192   // compute aplanarity
00193   return ( 1.5*eigenvalues[0]);
00194 }
00195 
00196 template <class Type>
00197 float AlephCollection<Type>::Planarity() const
00198 {
00199   // First a critical check
00200   if (size()==0)
00201     {
00202       cerr << "ERROR: cannot compute planarity on an empty vector. ABORTING" << endl;
00203       exit(-1);
00204     }
00205   // first fill the momentum tensor
00206   HepSymMatrix MomentumTensor(3,0);
00207   for(const_iterator vec=begin();vec<end();vec++)
00208    {
00209       for(int i=0;i<3;i++)
00210         for(int j=0;j<=i;j++)
00211           if(!((*vec)->isLocked()))
00212              MomentumTensor[i][j] += (((*vec)->A4V()[i])*((*vec)->A4V()[j]));
00213    }
00214   MomentumTensor/=(MomentumTensor[0][0]+MomentumTensor[1][1]+MomentumTensor[2][2]);
00215   // find the eigen values (as the values on the diag matrix)
00216   HepMatrix U = diagonalize(&MomentumTensor) ;
00217   vector<float> eigenvalues(3);
00218   eigenvalues[0] = MomentumTensor[0][0];
00219   eigenvalues[1] = MomentumTensor[1][1];
00220   eigenvalues[2] = MomentumTensor[2][2];
00221   sort(eigenvalues.begin(),eigenvalues.end());
00222   // compute planarity
00223   return (eigenvalues[0]/eigenvalues[1]);
00224 }
00225 

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