]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RALICE/AliVertex.cxx
21-jul-2006 NvE AliSample extended for computation of median.
[u/mrichter/AliRoot.git] / RALICE / AliVertex.cxx
index 55847baab1a47955a55ab1fc395a4ef7f97d2315..1446c5832480ead181806be1254347a09afb6285 100644 (file)
@@ -249,7 +249,7 @@ void AliVertex::SetOwner(Bool_t own)
  AliJet::SetOwner(own);
 }
 ///////////////////////////////////////////////////////////////////////////
-AliVertex::AliVertex(AliVertex& v) : AliJet(v.fNtinit),AliPosition(v)
+AliVertex::AliVertex(const AliVertex& v) : AliJet(v.fNtinit),AliPosition(v)
 {
 // Copy constructor
  Init();
@@ -266,7 +266,7 @@ AliVertex::AliVertex(AliVertex& v) : AliJet(v.fNtinit),AliPosition(v)
  AliTrack* tx=0;
  Int_t jetflag=0,connect=0;
  AliTrack* tx2=0;
- for (Int_t it=1; it<=v.GetNtracks(); it++)
+ for (Int_t it=1; it<=v.fNtrk; it++)
  {
   tx=v.GetTrack(it);
   if (tx)
@@ -556,9 +556,17 @@ void AliVertex::AddVertex(AliVertex& v,Int_t connect)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-void AliVertex::Data(TString f)
+void AliVertex::Data(TString f,TString u)
 {
 // Provide vertex information within the coordinate frame f
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+//     "deg" : angles provided in degrees
+//
+// The defaults are f="car" and u="rad".
+
  const char* name=GetName();
  const char* title=GetTitle();
  cout << " *AliVertex::Data*";
@@ -570,16 +578,23 @@ void AliVertex::Data(TString f)
       << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx 
       << " Njets : " << fNjets << endl;
  cout << " ";
- Ali4Vector::Data(f);
+ Ali4Vector::Data(f,u);
  cout << "  Position";
- AliPosition::Data(f); 
+ AliPosition::Data(f,u); 
 } 
 ///////////////////////////////////////////////////////////////////////////
-void AliVertex::List(TString f)
+void AliVertex::List(TString f,TString u)
 {
 // Provide primary track and sec. vertex information within the coordinate frame f
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+//     "deg" : angles provided in degrees
+//
+// The defaults are f="car" and u="rad".
 
- Data(f); // Information of the current vertex
+ Data(f,u); // Information of the current vertex
 
  // The tracks of this vertex
  AliTrack* t; 
@@ -590,7 +605,7 @@ void AliVertex::List(TString f)
   {
    cout << "  ---Track no. " << it << endl;
    cout << " ";
-   t->Data(f); 
+   t->Data(f,u); 
   }
   else
   {
@@ -607,7 +622,7 @@ void AliVertex::List(TString f)
   {
    cout << "  ---Level 1 sec. vertex no. " << iv << endl;
    cout << " ";
-   v->Data(f); 
+   v->Data(f,u); 
   }
   else
   {
@@ -616,11 +631,18 @@ void AliVertex::List(TString f)
  }
 } 
 ///////////////////////////////////////////////////////////////////////////
-void AliVertex::ListAll(TString f)
+void AliVertex::ListAll(TString f,TString u)
 {
 // Provide complete (sec) vertex and (decay) track info within the coordinate frame f
+//
+// The string argument "u" allows to choose between different angular units
+// in case e.g. a spherical frame is selected.
+// u = "rad" : angles provided in radians
+//     "deg" : angles provided in degrees
+//
+// The defaults are f="car" and u="rad".
 
- Data(f); // Information of the current vertex
+ Data(f,u); // Information of the current vertex
 
  // The tracks of this vertex
  AliTrack* t; 
@@ -631,7 +653,7 @@ void AliVertex::ListAll(TString f)
   {
    cout << "  ---Track no. " << it << endl;
    cout << " ";
-   t->ListAll(f); 
+   t->ListAll(f,u); 
   }
   else
   {
@@ -640,10 +662,10 @@ void AliVertex::ListAll(TString f)
  }
 
  AliVertex* v=this;
- Dumps(v,1,f); // Information of all sec. vertices
+ Dumps(v,1,f,u); // Information of all sec. vertices
 }
 //////////////////////////////////////////////////////////////////////////
-void AliVertex::Dumps(AliVertex* v,Int_t n,TString f)
+void AliVertex::Dumps(AliVertex* v,Int_t n,TString f,TString u)
 {
 // Recursively provide the info of all secondary vertices of this vertex
  AliVertex* vs; 
@@ -654,7 +676,7 @@ void AliVertex::Dumps(AliVertex* v,Int_t n,TString f)
   {
    cout << "  ---Level " << n << " sec. vertex no. " << iv << endl;
    cout << " ";
-   vs->Data(f); 
+   vs->Data(f,u); 
 
    // The tracks of this vertex
    AliTrack* t; 
@@ -665,7 +687,7 @@ void AliVertex::Dumps(AliVertex* v,Int_t n,TString f)
     {
      cout << "  ---Track no. " << it << endl;
      cout << " ";
-     t->ListAll(f); 
+     t->ListAll(f,u); 
     }
     else
     {
@@ -674,7 +696,7 @@ void AliVertex::Dumps(AliVertex* v,Int_t n,TString f)
    }
 
    // Go for next sec. vertex level of this sec. vertex recursively
-   Dumps(vs,n+1,f);
+   Dumps(vs,n+1,f,u);
   }
   else
   {
@@ -683,13 +705,13 @@ void AliVertex::Dumps(AliVertex* v,Int_t n,TString f)
  }
 } 
 //////////////////////////////////////////////////////////////////////////
-Int_t AliVertex::GetNvertices()
+Int_t AliVertex::GetNvertices() const
 {
 // Return the current number of (secondary) vertices
  return fNvtx;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliVertex* AliVertex::GetVertex(Int_t i)
+AliVertex* AliVertex::GetVertex(Int_t i) const
 {
 // Return the i-th (secondary) vertex of the current vertex
  if (!fVertices)
@@ -712,7 +734,7 @@ AliVertex* AliVertex::GetVertex(Int_t i)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliVertex* AliVertex::GetIdVertex(Int_t id)
+AliVertex* AliVertex::GetIdVertex(Int_t id) const
 {
 // Return the (sec.) vertex with user identifier "id"
  AliVertex* vx=0;
@@ -761,7 +783,7 @@ void AliVertex::SetVertexCopy(Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliVertex::GetVertexCopy()
+Int_t AliVertex::GetVertexCopy() const
 {
 // Provide value of the VertexCopy mode.
 // 0 ==> No private copies are made; pointers of original vertices are stored.
@@ -769,13 +791,13 @@ Int_t AliVertex::GetVertexCopy()
  return fVertexCopy;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliVertex::GetNjets()
+Int_t AliVertex::GetNjets() const
 {
 // Return the current number of jets
  return fNjets;
 }
 ///////////////////////////////////////////////////////////////////////////
-AliJet* AliVertex::GetJet(Int_t i)
+AliJet* AliVertex::GetJet(Int_t i) const
 {
 // Return the i-th jet of the current vertex
  if (!fJets)
@@ -798,7 +820,7 @@ AliJet* AliVertex::GetJet(Int_t i)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-AliJet* AliVertex::GetIdJet(Int_t id)
+AliJet* AliVertex::GetIdJet(Int_t id) const
 {
 // Return the jet with user identifier "id"
  AliJet* jx=0;
@@ -847,7 +869,7 @@ void AliVertex::SetJetCopy(Int_t j)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliVertex::GetJetCopy()
+Int_t AliVertex::GetJetCopy() const
 {
 // Provide value of the JetCopy mode.
 // 0 ==> No private copies are made; pointers of original jets are stored.
@@ -855,7 +877,7 @@ Int_t AliVertex::GetJetCopy()
  return fJetCopy;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliVertex::IsConnectTrack(AliTrack* t)
+Int_t AliVertex::IsConnectTrack(AliTrack* t) const
 {
 // Indicate whether a track from the tracklist was created via the
 // connection of a (secondary) vertex or not.
@@ -869,7 +891,7 @@ Int_t AliVertex::IsConnectTrack(AliTrack* t)
  return connect;
 }
 ///////////////////////////////////////////////////////////////////////////
-Int_t AliVertex::IsJetTrack(AliTrack* t)
+Int_t AliVertex::IsJetTrack(AliTrack* t) const
 {
 // Indicate whether a track from the tracklist was created via the
 // addition of a jet or not.
@@ -992,7 +1014,152 @@ void AliVertex::Draw(Int_t secs,Int_t cons,Int_t jets)
  }
 }
 ///////////////////////////////////////////////////////////////////////////
-TObject* AliVertex::Clone(const char* name)
+TObjArray* AliVertex::SortJets(Int_t mode,TObjArray* jets)
+{
+// Order the references to an array of jets by looping over the input array "jets"
+// and checking the value of a certain observable.
+// The ordered array is returned as a TObjArray.
+// In case jets=0 (default), the registered jets of the current vertex are used. 
+// Note that the original jet array is not modified.
+// Via the "mode" argument the user can specify the observable to be checked upon
+// and specify whether sorting should be performed in decreasing order (mode<0)
+// or in increasing order (mode>0).
+//
+// The convention for the observable selection is the following :
+// mode : 1 ==> Number of tracks in the jet
+//        2 ==> Jet energy
+//        3 ==> Jet momentum
+//        4 ==> Invariant mass of the jet
+//        5 ==> Transverse momentum of the jet
+//        6 ==> Longitudinal momentum of the jet
+//        7 ==> Transverse energy of the jet
+//        8 ==> Longitudinal energy of the jet
+//        9 ==> Transverse mass of the jet
+//       10 ==> Jet rapidity
+//       11 ==> Pseudo-rapidity of the jet
+//
+// The default is mode=-1.
+//
+// Note : This sorting routine uses a common area in memory, which is used
+//        by various other sorting facilities as well.
+//        This means that the resulting sorted TObjArray may be overwritten
+//        when another sorting is invoked.
+//        To retain the sorted list of pointers, the user is advised to copy
+//        the pointers contained in the returned TObjArray into a private
+//        TObjArray instance.
+
+ if (fSelected)
+ {
+  delete fSelected;
+  fSelected=0;
+ }
+
+ if (!jets) jets=fJets;
+ if (abs(mode)>11 || !jets) return fSelected;
+
+ Int_t njets=jets->GetEntries();
+ if (!njets)
+ {
+  return fSelected;
+ }
+ else
+ {
+  fSelected=new TObjArray(njets);
+ }
+
+ Double_t val1,val2; // Values of the observable to be tested upon
+ Int_t nord=0;
+ for (Int_t i=0; i<njets; i++) // Loop over all jets of the array
+ {
+  AliJet* jx=(AliJet*)jets->At(i);
+
+  if (!jx) continue;
+  if (nord == 0) // store the first jet at the first ordered position
+  {
+   nord++;
+   fSelected->AddAt(jx,nord-1);
+   continue;
+  }
+  for (Int_t j=0; j<=nord; j++) // put jet in the right ordered position
+  {
+   if (j == nord) // jet has smallest (mode<0) or largest (mode>0) observable value seen so far
+   {
+    nord++;
+    fSelected->AddAt(jx,j); // add jet at the end
+    break; // go for next jet
+   }
+
+   val1=0;
+   val2=0;
+   
+   switch (abs(mode))
+   {
+    case 1:
+     val1=jx->GetNtracks();
+     val2=((AliJet*)fSelected->At(j))->GetNtracks();
+     break;
+    case 2:
+     val1=jx->GetEnergy();
+     val2=((AliJet*)fSelected->At(j))->GetEnergy();
+     break;
+    case 3:
+     val1=jx->GetMomentum();
+     val2=((AliJet*)fSelected->At(j))->GetMomentum();
+     break;
+    case 4:
+     val1=jx->GetInvmass();
+     val2=((AliJet*)fSelected->At(j))->GetInvmass();
+     break;
+    case 5:
+     val1=jx->GetPt();
+     val2=((AliJet*)fSelected->At(j))->GetPt();
+     break;
+    case 6:
+     val1=jx->GetPl();
+     val2=((AliJet*)fSelected->At(j))->GetPl();
+     break;
+    case 7:
+     val1=jx->GetEt();
+     val2=((AliJet*)fSelected->At(j))->GetEt();
+     break;
+    case 8:
+     val1=jx->GetEl();
+     val2=((AliJet*)fSelected->At(j))->GetEl();
+     break;
+    case 9:
+     val1=jx->GetMt();
+     val2=((AliJet*)fSelected->At(j))->GetMt();
+     break;
+    case 10:
+     val1=jx->GetRapidity();
+     val2=((AliJet*)fSelected->At(j))->GetRapidity();
+     break;
+    case 11:
+     val1=jx->GetPseudoRapidity();
+     val2=((AliJet*)fSelected->At(j))->GetPseudoRapidity();
+     break;
+   }
+
+   if (mode<0 && val1 <= val2) continue;
+   if (mode>0 && val1 >= val2) continue;
+   nord++;
+   for (Int_t k=nord-1; k>j; k--) // create empty position
+   {
+    fSelected->AddAt(fSelected->At(k-1),k);
+   }
+   fSelected->AddAt(jx,j); // put jet at empty position
+   break; // go for next jet
+  }
+ }
+ return fSelected;
+}
+///////////////////////////////////////////////////////////////////////////
+TObject* AliVertex::Clone(const char* name) const
 {
 // Make a deep copy of the current object and provide the pointer to the copy.
 // This memberfunction enables automatic creation of new objects of the