]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - JETAN/AliJet.cxx
Fixes to calls for MeanMaterialBudget (now in AliTracker) (From Jouri Belikov)
[u/mrichter/AliRoot.git] / JETAN / AliJet.cxx
index 5e1576268b6b13ca10b5669893b97fa330c83bac..d6940978b03fda17920a9828709a185a9b3fe04f 100644 (file)
-// $Id$
-
-//__________________________________________________________
-///////////////////////////////////////////////////////////////////
-//
-// class AliJet
-//
-// loizides@ikf.uni-frankfurt.de
-//
-///////////////////////////////////////////////////////////////////
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
 
+/* $Id$ */
+//---------------------------------------------------------------------
+// Jet class 
+// Stores the output of a jet algorithm
+// Author: jgcn@mda.cinvestav.mx
+//---------------------------------------------------------------------
 #include <Riostream.h>
 #include <TClonesArray.h>
-#include "AliJetParticle.h"
-#include "AliJet.h"
+#include <TLorentzVector.h>
 
+#include "AliJet.h"
 ClassImp(AliJet)
+  
+AliJet::AliJet():
+  fNInput(0),
+  fNJets(0),
+  fEtAvg(0),
+  fInJet(0),
+  fMultiplicities(0),
+  fNCells(0),
+  fPtFromSignal(0),
+  fJets(0),
+  fEtaIn(0),
+  fPhiIn(0),
+  fPtIn(0)
+{
+  // Default constructor
+  fJets = new TClonesArray("TLorentzVector",1000);
+  fInJet = TArrayI();
+  fPtIn = TArrayF();
+  fEtaIn = TArrayF();
+  fPhiIn = TArrayF();
+  fPtFromSignal = TArrayF();
+  fMultiplicities = TArrayI();
+  fNCells = TArrayI();
+} 
 
-#if 0
-/**************************************************************************/ 
-AliJetEvent::AliJetEvent(Int_t size) :
-  fNParticles(0),
-  fParticles(new TClonesArray("AliJetParticle",size)),
-  fVertexX(0.),
-  fVertexY(0.),
-  fVertexZ(0.)
+////////////////////////////////////////////////////////////////////////
+
+AliJet::~AliJet()
 {
-  //default constructor   
+  // destructor
+  if (fJets) {
+    fJets->Delete();
+    delete fJets;
+  }
 }
 
-/**************************************************************************/ 
-AliJetEvent::AliJetEvent(const AliJetEvent& source) :
-  TObject(source), 
-  fNParticles(source.fNParticles),
-  fParticles(new TClonesArray("AliJetEvent",source.fNParticles)),
-  fVertexX(0.),
-  fVertexY(0.),
-  fVertexZ(0.)
+////////////////////////////////////////////////////////////////////////
+
+Bool_t AliJet::OutOfRange(Int_t i, const char *s) const
 {
-  //copy constructor
-  for(Int_t i =0; i<fNParticles; i++)
-    {
-      const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
-      fParticles->AddAt(new AliJetParticle(*(kjp)),i);
-    }
+  // checks if i is a valid index. s = name of calling method
+  if (i >= fNJets || i < 0) {
+    cout << s << " Index " << i << " out of range" << endl;
+    return kTRUE;
+  }
+  return kFALSE;
 }
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-AliJetEvent::~AliJetEvent()
+TLorentzVector* AliJet::GetJet(Int_t i)
 {
-  //destructor   
-  Reset();
-  delete fParticles;
+  // returns i-jet
+  if (OutOfRange(i, "AliJet::GetJet:")) return 0;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv; 
 }
 
+////////////////////////////////////////////////////////////////////////
+
+Int_t AliJet::GetMultiplicity(Int_t i) const
+{
+  // gets multiplicity of i-jet
+  if (OutOfRange(i, "AliJet::GetMultiplicity:")) return 0;
+  return fMultiplicities[i];
+}
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void  AliJetEvent::Reset(Int_t size)
+Int_t AliJet::GetNCell(Int_t i) const
 {
-  //deletes all particles from the event
+  // gets number of cell of i-jet
+  if (OutOfRange(i, "AliJet::GetNCell:")) return 0;
+  return fNCells[i];
+}
 
-  if(fParticles) fParticles->Clear();
-  if(size>=0) fParticles->Expand(size);
-  fNParticles = 0;
-} 
+////////////////////////////////////////////////////////////////////////
+
+Double_t AliJet::GetPx(Int_t i)
+{
+// Get Px component of jet i
+  if (OutOfRange(i, "AliJet::GetPx:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->Px();
+}
+
+////////////////////////////////////////////////////////////////////////
+
+Double_t AliJet::GetPy(Int_t i)
+{
+// Get Py component of jet i
+  if (OutOfRange(i, "AliJet::GetPy:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->Py();
+}
+
+////////////////////////////////////////////////////////////////////////
+
+Double_t AliJet::GetPz(Int_t i)
+{
+// Get Pz component of jet i
+  if (OutOfRange(i, "AliJet::GetPz:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->Pz();
+}
+
+////////////////////////////////////////////////////////////////////////
+
+Double_t AliJet::GetP(Int_t i)
+{
+// Get momentum of jet i
+  if (OutOfRange(i, "AliJet::GetP:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->P();
+}
+
+////////////////////////////////////////////////////////////////////////
+
+Double_t AliJet::GetE(Int_t i)
+{
+// Get energy of jet i
+  if (OutOfRange(i, "AliJet::GetE:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->E();
+}
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void AliJetEvent::AddParticle(AliJetParticle* part)
+Double_t AliJet::GetPt(Int_t i)
 {
-  //Adds new particle to the event
-  fParticles->AddAt(part,fNParticles++);
+// Get transverse momentum of jet i
+  if (OutOfRange(i, "AliJet::GetPt:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->Pt();
 }
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void AliJetEvent::AddParticle(const AliJetParticle* part)
+Double_t AliJet::GetEta(Int_t i)
 {
-  //Adds new particle to the event
-  fParticles->AddAt(new AliJetParticle(*part),fNParticles++); 
+// Get eta of jet i
+  if (OutOfRange(i, "AliJet::GetEta:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->Eta();
 }
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void AliJetEvent::AddParticle(const TParticle* part,Int_t idx, Int_t l)
+Double_t AliJet::GetPhi(Int_t i)
 {
-  //Adds new particle to the event
-  new((*fParticles)[fNParticles++]) AliJetParticle(part,idx,l);
+// Get phi of jet i
+  if (OutOfRange(i, "AliJet::GetPhi:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return ( (lv->Phi() < 0) ? (lv->Phi()) + 2. * TMath::Pi() : lv->Phi());
 }
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void AliJetEvent::AddParticle(Float_t px, Float_t py, Float_t pz, 
-                              Float_t etot, Int_t idx, Int_t l)
+Double_t AliJet::GetTheta(Int_t i)
 {
-  //Adds new particle to the event
-  new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l); 
+// Get theta of jet i
+  if (OutOfRange(i, "AliJet::GetTheta:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->Theta();
 }
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void AliJetEvent::AddParticle(Float_t px, Float_t py, Float_t pz, Float_t etot, Int_t idx, Int_t l,
-                             Float_t pt, Float_t phi, Float_t eta)
+Double_t AliJet::GetMass(Int_t i)
 {
-  //Adds new particle to the event
-  new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,pt,phi,eta); 
+// Get invariant mass of jet i
+  if (OutOfRange(i, "AliJet::GetMass:")) return -1e30;
+  TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
+  return lv->M();
 }
 
+////////////////////////////////////////////////////////////////////////
 
-/**************************************************************************/ 
+void AliJet::AddJet(Double_t px, Double_t py, Double_t pz, Double_t e)
+{
+// Add new jet to the list
+  new ((*fJets)[fNJets++]) TLorentzVector(px,py,pz,e);
+}
 
-const AliJetParticle* AliJetEvent::GetParticleSafely(Int_t n)
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::SetInJet(Int_t* j)
 {
-  //returns nth particle with range check
-  if( (n<0) || (fNParticles<=n) ) return 0;
-  return (const AliJetParticle*)fParticles->At(n);
+  // set information of which input object belongs
+  // to each jet. If zero, object was not assigned to
+  // a jet, if n,positive, it was assiged to jet n
+  // if n, negative, it is within cone of jet n, but
+  // it did not passed the user cuts. filled in by AliJetFinder
+  if (fNInput>0) fInJet.Set(fNInput, j);
 }
 
-/**************************************************************************/ 
+////////////////////////////////////////////////////////////////////////
 
-void AliJetEvent::Print(Option_t* /*t*/) const
+void AliJet::SetEtaIn(Float_t* r)
 {
-  if(fHeader.Length()) cout << fHeader.Data() << endl;
-  cout << "no of particles: " << fNParticles << endl;
+  if (fNInput>0) fEtaIn.Set(fNInput, r);
 }
 
-#endif
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::SetPtIn(Float_t* pt)
+{
+  if (fNInput>0) fPtIn.Set(fNInput, pt);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::SetPhiIn(Float_t* x)
+{
+  if (fNInput>0) fPhiIn.Set(fNInput, x);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::SetPtFromSignal(Float_t* p)
+{
+  // set information of percentage of pt of jets
+  // coming from signal (ie Pythia)
+  if (fNJets>0) fPtFromSignal.Set(fNJets, p);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::SetMultiplicities(Int_t* m)
+{
+  // set information of jet multiplicities
+  // filled in by AliJetFinder
+  if (fNJets>0) fMultiplicities.Set(fNJets, m);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::SetNCells(Int_t* n)
+{
+  if (fNJets>0) fNCells.Set(fNJets, n);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::ClearJets(Option_t *option)
+{
+  // reset all values
+  fJets->Clear(option);
+  fNInput=0;
+  fNJets=0;
+  fMultiplicities.Set(0);
+  fInJet.Set(0); 
+  fPtFromSignal.Set(0);
+  fPhiIn.Set(0);
+  fEtaIn.Set(0);
+  fPtIn.Set(0);
+  fNCells.Set(0);
+}
+
+////////////////////////////////////////////////////////////////////////
+
+void AliJet::PrintJets()
+{
+// Print jet information
+  if (fNJets == 0) {
+    cout << " AliJet::PrintJets: There are no jets in this event " << endl;
+    return;
+  }
+  cout << " AliJet::PrintJets: There are " << fNJets
+       << " jets in this event" << endl;
+  for(Int_t i=0;i<fNJets;i++) {
+    cout << "   Jet " << i << " (px,py,pz,en)=(" << GetPx(i)
+        << "," << GetPy(i)
+        << "," << GetPz(i)
+        << "," << GetE(i) 
+        << ")" << endl;
+    cout << "         (pt,eta,phi)=(" << GetPt(i)
+        << "," << GetEta(i)
+        << "," << GetPhi(i) << ")" << endl;
+    cout << "         # of tracks =" << GetMultiplicity(i) << endl;
+  }
+}