LCDJetFinder Class Reference

#include <LCDJetFinder.h>

List of all members.

Public Member Functions

 LCDJetFinder ()
 LCDJetFinder (Double_t ycut)
 ~LCDJetFinder ()
void SetPartList (TObjArray *e)
void SetYCut (Double_t ycut)
void doFindJets ()
void doFindJets (Double_t ycut)
Int_t doFindJets (Int_t njet)
Int_t njets ()
TLorentzVector * jet4vec (Int_t index)
Int_t nParticlesPerJet (Int_t index)
TArrayI GetPartIndex ()
Int_t GetPartIndexAt (Int_t a)
TArrayI * GetPartIndexPtr ()
Double_t GetYmin ()
Int_t fewestParts ()
Double_t GetYCut ()
void SetDURHAM ()
void SetJADE ()
void SetJADEE ()
Double_t calcinvmass (const TLorentzVector &jet1, const TLorentzVector &jet2)

Private Attributes

Int_t m_njets
Double_t m_ymin
TClonesArray * m_jet
TArrayI m_ipart_jet_assoc
TArrayI m_inparts_per_jet
Int_t m_ifewest_parts
Double_t m_evis
Double_t m_dycut
Int_t m_algorithm
TObjArray * m_4vec
TClonesArray * m_part

Static Private Attributes

static const Int_t UNASSOC
static const Int_t DURHAM
static const Int_t JADE = 2
static const Int_t JADEE = 3


Detailed Description

Definition at line 32 of file LCDJetFinder.h.


Constructor & Destructor Documentation

LCDJetFinder::LCDJetFinder  ) 
 

Definition at line 47 of file LCDJetFinder.cxx.

00047                           : 
00048     m_ymin(1e20),m_evis(0.),m_dycut(0.1),
00049     m_algorithm(LCDJetFinder::DURHAM){ // Default constructor  uses Durham
00050     m_jet  = new TClonesArray("TLorentzVector", 20);
00051     m_part = new TClonesArray("TLorentzVector",200);
00052 }

LCDJetFinder::LCDJetFinder Double_t  ycut  ) 
 

Definition at line 54 of file LCDJetFinder.cxx.

References m_jet, and m_part.

00054                                        : 
00055     m_ymin(0.0),m_evis(0.),m_dycut(ycut),
00056     m_algorithm(LCDJetFinder::DURHAM){ // Default constructor  uses Durham
00057     m_jet  = new TClonesArray("TLorentzVector", 20);
00058     m_part = new TClonesArray("TLorentzVector",200);
00059 }

LCDJetFinder::~LCDJetFinder  ) 
 

Definition at line 62 of file LCDJetFinder.cxx.

References m_jet, and m_part.

00062                             {
00063   m_jet->Delete();  delete m_jet;
00064   m_part->Delete(); delete m_part;
00065 }


Member Function Documentation

Double_t LCDJetFinder::calcinvmass const TLorentzVector &  jet1,
const TLorentzVector &  jet2
 

Definition at line 392 of file LCDJetFinder.cxx.

References DURHAM, JADE, JADEE, and m_algorithm.

00393                                                               {
00394   TVector3 P_jet1 = jet1.Vect();
00395   TVector3 P_jet2 = jet2.Vect();
00396   Double_t costh = (P_jet1 * P_jet2)/P_jet1.Mag()/P_jet2.Mag();
00397 
00398   if     (m_algorithm == LCDJetFinder::DURHAM) {  // DURHAM
00399     Double_t minT = TMath::Min(jet1.E(),jet2.E());
00400     return 2. * minT*minT * (1.-costh);
00401   } else if (m_algorithm == LCDJetFinder::JADE)   {  // JADE    
00402     return 2. * (jet1.E())*(jet2.E()) * (1.-costh) ; 
00403   } else if (m_algorithm == LCDJetFinder::JADEE)  {  // JADE E
00404     return (jet1 + jet2).M2();
00405   }
00406 
00407   printf(" Strange Algorithm!!!! \n");
00408   return 0.;
00409 
00410 };

Int_t LCDJetFinder::doFindJets Int_t  njet  ) 
 

Definition at line 246 of file LCDJetFinder.cxx.

References m_4vec.

00246                                         {
00247 
00248   Int_t np = m_4vec->GetEntries();      
00249   if (np < njet) return -1;
00250 
00251   TObject* o;
00252   Int_t ipart;
00253   for(ipart=0; ipart < np ; ipart++) {
00254     o = m_4vec->At(ipart);
00255     TString nam(o->IsA()->GetName());
00256     if (nam.Contains("TLorentzVector")) {
00257       new((*m_part)[ipart]) TLorentzVector(*((TLorentzVector*)o));
00258     } else if (nam.Contains("TVector3")) {
00259       new((*m_part)[ipart]) TLorentzVector(((TVector3 *) o)->X(),
00260                                            ((TVector3 *) o)->Y(),
00261                                            ((TVector3 *) o)->Z(),
00262                                            ((TVector3 *) o)->Mag());
00263     } else {
00264       printf("LCDJetFinder::SetEvent input is not a TVector3 or a TLorentzVector\n");
00265     }
00266   }
00267 
00268   m_ipart_jet_assoc.Reset();
00269   m_ipart_jet_assoc.Set(np);
00270   for (Int_t m=0; m<np; m++) m_ipart_jet_assoc[m] = UNASSOC;
00271 
00272   m_njets = 0;
00273 
00274   //
00275   // create invariant mass pair array.
00276   //
00277   TMatrix ymass = TMatrix(np,np);
00278   
00279   for (Int_t i1 = 0; i1 < np - 1; i1++ ) {
00280     for (Int_t i2 = i1 + 1 ; i2 < np ; i2++ ) {
00281       ymass(i1,i2) = calcinvmass(*(TLorentzVector*)m_part->At(i1),
00282                                  *(TLorentzVector*)m_part->At(i2));
00283     }
00284   }
00285   
00286   Int_t im,jm;
00287   Int_t i,j;
00288   Int_t imin;
00289   Int_t imax;
00290   Int_t nj=np;
00291   for (;;) {
00292     im = -1;
00293     jm = -1;
00294     m_ymin=1E20;
00295     //
00296     // find least invariant mass pair.
00297     //
00298     for(i = 0 ; i < np - 1 ; i++ ) {
00299       for(j = i + 1 ; j < np ; j++ ) {
00300         if (m_ipart_jet_assoc[i] != LCDJetFinder::UNASSOC) continue;
00301         if (m_ipart_jet_assoc[j] != LCDJetFinder::UNASSOC) continue;
00302         if (ymass(i,j) > m_ymin) continue;
00303           
00304         m_ymin = ymass(i,j);
00305         im = i;  jm = j;
00306       }
00307     }
00308 
00309     //
00310     // combine particles im and jm.
00311     //
00312     *((TLorentzVector*)m_part->At(im)) += *((TLorentzVector*)m_part->At(jm));
00313 
00314     for(ipart = 0; ipart < np; ipart++ ){
00315       if(m_ipart_jet_assoc[ipart] == jm) m_ipart_jet_assoc[ipart] = im;
00316     }
00317     m_ipart_jet_assoc[jm] = im;
00318     m_ymin/= m_evis;
00319     m_ymin/= m_evis;
00320     if (--nj == njet) break;
00321 
00322     //
00323     // Recalculate invariant masses for newly combined particle
00324     //
00325     for (ipart = 0; ipart < np ; ipart++) {
00326       if (ipart == im) continue;
00327       if (m_ipart_jet_assoc[ipart] != UNASSOC ) continue;
00328       
00329       imin = TMath::Min(ipart,im);
00330       imax = TMath::Max(ipart,im);
00331       
00332       ymass(imin,imax) = calcinvmass(*((TLorentzVector*)m_part->At(imin)),
00333                                      *((TLorentzVector*)m_part->At(imax)));
00334     }
00335     
00336   }
00337   //
00338   // finish up by filling jet array.
00339   //
00340   
00341   for (ipart = 0 ; ipart < np ; ipart++) {
00342     if (m_ipart_jet_assoc[ipart] == UNASSOC) m_njets++;                 
00343   }
00344 
00345   //For debug...
00346   if (m_njets != njet) {
00347     fprintf(stderr,"LCDJetFinder::doFindJets error m_njets=%d njet=%d\n",
00348             m_njets,njet);
00349     return -1;
00350   }
00351   
00352   m_jet->Delete();
00353   m_inparts_per_jet.Reset();
00354   m_inparts_per_jet.Set(m_njets);
00355 
00356   nj = 0;
00357   Int_t npart;
00358   m_ifewest_parts = 100000; // Starting min value
00359   for(i = 0 ; i < np ; i++ ){
00360     if (m_ipart_jet_assoc[i] != UNASSOC) continue;
00361 
00362     new((*m_jet)[nj]) TLorentzVector(*((TLorentzVector*)m_part->At(i)));
00363 
00364     npart = 1;
00365     for (j = 0 ; j < np ; j++) {
00366       if(m_ipart_jet_assoc[j] == i) {
00367         m_ipart_jet_assoc[j] = nj;
00368         npart++;
00369       }
00370     }
00371     m_ipart_jet_assoc[i] = nj;
00372     m_inparts_per_jet[nj] = npart;
00373     if( npart < m_ifewest_parts) m_ifewest_parts = npart;
00374     nj++;
00375   }
00376   m_part->Delete();
00377 
00378   return 0;
00379 }

void LCDJetFinder::doFindJets Double_t  ycut  ) 
 

Definition at line 110 of file LCDJetFinder.cxx.

References doFindJets(), and SetYCut().

00110                                           {
00111   SetYCut(ycut);
00112   doFindJets();
00113 }

void LCDJetFinder::doFindJets  ) 
 

Definition at line 116 of file LCDJetFinder.cxx.

References m_4vec, and m_part.

Referenced by doFindJets().

00116                              {
00117 
00118   Int_t np = m_4vec->GetEntries();      
00119   if (np < 2) return;
00120 
00121   TObject* o;
00122   Int_t ipart;
00123   for(ipart=0; ipart < np ; ipart++) {
00124     o = m_4vec->At(ipart);
00125     TString nam(o->IsA()->GetName());
00126     if (nam.Contains("TLorentzVector")) {
00127       new((*m_part)[ipart]) TLorentzVector(*((TLorentzVector*)o));
00128     } else if (nam.Contains("TVector3")) {
00129       new((*m_part)[ipart]) TLorentzVector(((TVector3 *) o)->X(),
00130                                            ((TVector3 *) o)->Y(),
00131                                            ((TVector3 *) o)->Z(),
00132                                            ((TVector3 *) o)->Mag());
00133     } else {
00134       printf("LCDJetFinder::SetEvent input is not a TVector3 or a TLorentzVector\n");
00135     }
00136   }
00137 
00138   m_ipart_jet_assoc.Reset();
00139   m_ipart_jet_assoc.Set(np);
00140   for (Int_t m=0; m<np; m++) m_ipart_jet_assoc[m] = UNASSOC;
00141 
00142   m_njets = 0;
00143 
00144   //
00145   // create invariant mass pair array.
00146   //
00147   TMatrix ymass = TMatrix(np,np);
00148   
00149   for (Int_t i1 = 0; i1 < np - 1; i1++ ) {
00150     for (Int_t i2 = i1 + 1 ; i2 < np ; i2++ ) {
00151       ymass(i1,i2) = calcinvmass(*(TLorentzVector*)m_part->At(i1),
00152                                  *(TLorentzVector*)m_part->At(i2));
00153     }
00154   }
00155   
00156   Double_t masscut = m_dycut * m_evis * m_evis ;
00157 
00158   Int_t im,jm;
00159   Double_t minmass;
00160   Int_t i,j;
00161   Int_t imin;
00162   Int_t imax;
00163   for (;;) {
00164     im = -1;
00165     jm = -1;
00166     minmass = 100000000.;
00167     if ( minmass <= masscut ) minmass = masscut * 10.;
00168     //
00169     // find least invariant mass pair.
00170     //
00171     for(i = 0 ; i < np - 1 ; i++ ) {
00172       for(j = i + 1 ; j < np ; j++ ) {
00173         if (m_ipart_jet_assoc[i] != LCDJetFinder::UNASSOC) continue;
00174         if (m_ipart_jet_assoc[j] != LCDJetFinder::UNASSOC) continue;
00175         if (ymass(i,j) > minmass) continue;
00176           
00177         minmass = ymass(i,j);
00178         im = i;  jm = j;
00179       }
00180     }
00181 
00182     m_ymin=minmass/m_evis/m_evis;
00183 
00184     if (minmass > masscut) break;
00185     //
00186     // combine particles im and jm.
00187     //
00188     *((TLorentzVector*)m_part->At(im)) += *((TLorentzVector*)m_part->At(jm));
00189 
00190     for(ipart = 0; ipart < np; ipart++ ){
00191       if(m_ipart_jet_assoc[ipart] == jm) m_ipart_jet_assoc[ipart] = im;
00192     }
00193     //
00194     // Recalculate invariant masses for newly combined particle
00195     //
00196     m_ipart_jet_assoc[jm] = im;
00197     for (ipart = 0; ipart < np ; ipart++) {
00198       if (ipart == im) continue;
00199       if (m_ipart_jet_assoc[ipart] != UNASSOC ) continue;
00200       
00201       imin = TMath::Min(ipart,im);
00202       imax = TMath::Max(ipart,im);
00203       
00204       ymass(imin,imax) = calcinvmass(*((TLorentzVector*)m_part->At(imin)),
00205                                      *((TLorentzVector*)m_part->At(imax)));
00206     }
00207     
00208   }
00209   //
00210   // finish up by filling jet array.
00211   //
00212   
00213   for (ipart = 0 ; ipart < np ; ipart++) {
00214     if (m_ipart_jet_assoc[ipart] == UNASSOC) m_njets++;                 
00215   }
00216   
00217   m_jet->Delete();
00218   m_inparts_per_jet.Reset();
00219   m_inparts_per_jet.Set(m_njets);
00220 
00221   Int_t nj = 0;
00222   Int_t npart;
00223   m_ifewest_parts = 100000; // Starting min value
00224   for(i = 0 ; i < np ; i++ ){
00225     if (m_ipart_jet_assoc[i] != UNASSOC) continue;
00226 
00227     new((*m_jet)[nj]) TLorentzVector(*((TLorentzVector*)m_part->At(i)));
00228 
00229     npart = 1;
00230     for (j = 0 ; j < np ; j++) {
00231       if(m_ipart_jet_assoc[j] == i) {
00232         m_ipart_jet_assoc[j] = nj;
00233         npart++;
00234       }
00235     }
00236     m_ipart_jet_assoc[i] = nj;
00237     m_inparts_per_jet[nj] = npart;
00238     if( npart < m_ifewest_parts) m_ifewest_parts = npart;
00239     nj++;
00240   }  
00241   m_part->Delete();
00242 
00243 }

Int_t LCDJetFinder::fewestParts  )  [inline]
 

Definition at line 76 of file LCDJetFinder.h.

References m_ifewest_parts.

00076 { return m_ifewest_parts; };

TArrayI LCDJetFinder::GetPartIndex  )  [inline]
 

Definition at line 67 of file LCDJetFinder.h.

References m_ipart_jet_assoc.

00067 { return m_ipart_jet_assoc; };

Int_t LCDJetFinder::GetPartIndexAt Int_t  a  )  [inline]
 

Definition at line 68 of file LCDJetFinder.h.

References m_ipart_jet_assoc.

00068 { return m_ipart_jet_assoc[a]; };

TArrayI* LCDJetFinder::GetPartIndexPtr  )  [inline]
 

Definition at line 69 of file LCDJetFinder.h.

References m_ipart_jet_assoc.

00069 { return &m_ipart_jet_assoc; };

Double_t LCDJetFinder::GetYCut  )  [inline]
 

Definition at line 79 of file LCDJetFinder.h.

References m_dycut.

00079 { return m_dycut; };

Double_t LCDJetFinder::GetYmin  )  [inline]
 

Definition at line 74 of file LCDJetFinder.h.

References m_ymin.

00074 { return m_ymin; }

TLorentzVector * LCDJetFinder::jet4vec Int_t  index  ) 
 

Definition at line 68 of file LCDJetFinder.cxx.

References m_jet.

00068                                                  {
00069   return (TLorentzVector*)m_jet->At(index);
00070 }

Int_t LCDJetFinder::njets  )  [inline]
 

Definition at line 56 of file LCDJetFinder.h.

References m_njets.

00056 { return m_njets; };

Int_t LCDJetFinder::nParticlesPerJet Int_t  index  ) 
 

Definition at line 73 of file LCDJetFinder.cxx.

References m_inparts_per_jet.

00073                                                 {
00074   return m_inparts_per_jet[index];
00075 }

void LCDJetFinder::SetDURHAM  ) 
 

Definition at line 382 of file LCDJetFinder.cxx.

References DURHAM, and m_algorithm.

00382                             {
00383   m_algorithm = LCDJetFinder::DURHAM; 
00384 }

void LCDJetFinder::SetJADE  ) 
 

Definition at line 385 of file LCDJetFinder.cxx.

References JADE, and m_algorithm.

00385                           {
00386   m_algorithm = LCDJetFinder::JADE;
00387 }

void LCDJetFinder::SetJADEE  ) 
 

Definition at line 388 of file LCDJetFinder.cxx.

References JADEE, and m_algorithm.

00388                            {
00389   m_algorithm = LCDJetFinder::JADEE;
00390 }

void LCDJetFinder::SetPartList TObjArray *  e  ) 
 

Definition at line 88 of file LCDJetFinder.cxx.

References m_4vec, and m_evis.

00088                                            {
00089 
00090   m_evis = 0;
00091   m_4vec = e;
00092 
00093   Int_t ne = e->GetEntries();
00094   TObject* o;
00095   for(Int_t i=0;i<ne;i++) {
00096     o = m_4vec->At(i);
00097     TString nam(o->IsA()->GetName());
00098     if (nam.Contains("TLorentzVector")) {
00099       m_evis += ((TLorentzVector *) o)->T();
00100     } else if (nam.Contains("TVector3")) {
00101       m_evis += ((TVector3 *) o)->Mag();
00102     } else {
00103       printf("LCDJetFinder::SetEvent input is not a TVector3 or a TLorentzVector\n");
00104     }
00105   }
00106 
00107 }

void LCDJetFinder::SetYCut Double_t  ycut  ) 
 

Definition at line 78 of file LCDJetFinder.cxx.

References m_dycut.

Referenced by doFindJets().

00078                                         {
00079   m_dycut = ycut;
00080 }


Member Data Documentation

const Int_t LCDJetFinder::DURHAM [static, private]
 

Definition at line 114 of file LCDJetFinder.h.

Referenced by calcinvmass(), and SetDURHAM().

const Int_t LCDJetFinder::JADE = 2 [static, private]
 

Definition at line 115 of file LCDJetFinder.h.

Referenced by calcinvmass(), and SetJADE().

const Int_t LCDJetFinder::JADEE = 3 [static, private]
 

Definition at line 116 of file LCDJetFinder.h.

Referenced by calcinvmass(), and SetJADEE().

TObjArray* LCDJetFinder::m_4vec [private]
 

Definition at line 119 of file LCDJetFinder.h.

Referenced by doFindJets(), and SetPartList().

Int_t LCDJetFinder::m_algorithm [private]
 

Definition at line 111 of file LCDJetFinder.h.

Referenced by calcinvmass(), SetDURHAM(), SetJADE(), and SetJADEE().

Double_t LCDJetFinder::m_dycut [private]
 

Definition at line 110 of file LCDJetFinder.h.

Referenced by GetYCut(), and SetYCut().

Double_t LCDJetFinder::m_evis [private]
 

Definition at line 109 of file LCDJetFinder.h.

Referenced by SetPartList().

Int_t LCDJetFinder::m_ifewest_parts [private]
 

Definition at line 105 of file LCDJetFinder.h.

Referenced by fewestParts().

TArrayI LCDJetFinder::m_inparts_per_jet [private]
 

Definition at line 102 of file LCDJetFinder.h.

Referenced by nParticlesPerJet().

TArrayI LCDJetFinder::m_ipart_jet_assoc [private]
 

Definition at line 99 of file LCDJetFinder.h.

Referenced by GetPartIndex(), GetPartIndexAt(), and GetPartIndexPtr().

TClonesArray* LCDJetFinder::m_jet [private]
 

Definition at line 96 of file LCDJetFinder.h.

Referenced by jet4vec(), LCDJetFinder(), and ~LCDJetFinder().

Int_t LCDJetFinder::m_njets [private]
 

Definition at line 90 of file LCDJetFinder.h.

Referenced by njets().

TClonesArray* LCDJetFinder::m_part [private]
 

Definition at line 120 of file LCDJetFinder.h.

Referenced by doFindJets(), LCDJetFinder(), and ~LCDJetFinder().

Double_t LCDJetFinder::m_ymin [private]
 

Definition at line 93 of file LCDJetFinder.h.

Referenced by GetYmin().

const Int_t LCDJetFinder::UNASSOC [static, private]
 

Definition at line 113 of file LCDJetFinder.h.


The documentation for this class was generated from the following files:
Generated on Tue Jul 18 18:34:06 2006 for LCDROOT by  doxygen 1.4.6