]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
First version of a container class for SPD tracklets (by Jan-Fiete).
authormarkus <markus@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jul 2007 15:48:43 +0000 (15:48 +0000)
committermarkus <markus@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 10 Jul 2007 15:48:43 +0000 (15:48 +0000)
STEER/AliAODTracklets.cxx [new file with mode: 0644]
STEER/AliAODTracklets.h [new file with mode: 0644]

diff --git a/STEER/AliAODTracklets.cxx b/STEER/AliAODTracklets.cxx
new file mode 100644 (file)
index 0000000..00b490d
--- /dev/null
@@ -0,0 +1,106 @@
+/**************************************************************************
+ * Copyright(c) 1998-2007, 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$ */
+
+//-------------------------------------------------------------------------
+//     AOD class to store tracklets
+//     Author: Jan Fiete Grosse-Oetringhaus, CERN
+//     Class created from AliMultiplicity
+//-------------------------------------------------------------------------
+
+#include "AliAODTracklets.h"
+
+ClassImp(AliAODTracklets)
+
+AliAODTracklets::AliAODTracklets() : TNamed(), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0)
+{
+  // default constructor
+}
+
+AliAODTracklets::AliAODTracklets(const char* name, const char* title) : TNamed(name, title), fNTracks(0), fTheta(0), fPhi(0), fDeltaPhi(0), fLabels(0)
+{
+  // TNamed constructor
+}
+
+void AliAODTracklets::CreateContainer(Int_t nTracks)
+{
+  // function that creates container to store tracklets
+
+  DeleteContainer();
+  
+  fNTracks = nTracks;
+
+  if (fNTracks <= 0)
+    return;
+
+  fTheta = new Float_t[fNTracks];
+  fPhi = new Float_t[fNTracks];
+  fDeltaPhi = new Float_t[fNTracks];
+  fLabels = new Int_t[fNTracks];
+}
+
+AliAODTracklets::~AliAODTracklets()
+{
+  // destructor
+
+  DeleteContainer();
+}
+
+void AliAODTracklets::DeleteContainer()
+{
+  // deletes allocated memory
+
+  if (fTheta)
+  {
+    delete[] fTheta;
+    fTheta = 0;
+  }
+
+  if (fPhi)
+  {
+    delete[] fPhi;
+    fPhi = 0;
+  }
+
+  if (fDeltaPhi)
+  {
+    delete[] fDeltaPhi;
+    fDeltaPhi = 0;
+  }
+
+  if (fLabels)
+  {
+    delete[] fLabels;
+    fLabels = 0;
+  }
+
+  fNTracks = 0;
+}
+
+Bool_t AliAODTracklets::SetTracklet(Int_t pos, Float_t theta, Float_t phi, Float_t deltaPhi, Int_t label)
+{
+  // Sets a tracklet at the given position
+
+  if (pos < 0 || pos >= fNTracks)
+    return kFALSE;
+
+  fTheta[pos] = theta;
+  fPhi[pos] = phi;
+  fDeltaPhi[pos] = deltaPhi;
+  fLabels[pos] = label;
+
+  return kTRUE;
+}
diff --git a/STEER/AliAODTracklets.h b/STEER/AliAODTracklets.h
new file mode 100644 (file)
index 0000000..60a8226
--- /dev/null
@@ -0,0 +1,90 @@
+/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id$ */
+
+//-------------------------------------------------------------------------
+//     AOD class to store tracklets
+//     Author: Jan Fiete Grosse-Oetringhaus, CERN
+//     Class created from AliMultiplicity
+//-------------------------------------------------------------------------
+
+#ifndef ALIAODTRACKLETS_H
+#define ALIAODTRACKLETS_H
+
+#include <TNamed.h>
+
+class AliAODTracklets : public TNamed 
+{
+ public:
+  AliAODTracklets();
+  AliAODTracklets(const char* name, const char* title);
+
+  virtual ~AliAODTracklets();
+
+  void CreateContainer(Int_t nTracks);
+  void DeleteContainer();
+
+  Bool_t SetTracklet(Int_t pos, Float_t theta, Float_t phi, Float_t deltaPhi, Int_t label);
+
+  Int_t GetNumberOfTracklets() const { return fNTracks; }
+  inline Float_t GetTheta(Int_t i) const;
+  inline Float_t GetPhi(Int_t i) const;
+  inline Float_t GetDeltaPhi(Int_t i) const;
+  inline Int_t   GetLabel(Int_t i) const;
+
+ protected:
+  Int_t    fNTracks;      // Number of tracklets
+  Float_t *fTheta;        //[fNTracks] array with theta values
+  Float_t *fPhi;          //[fNTracks] array with phi values
+  Float_t *fDeltaPhi;     //[fNTracks] array with delta phi values
+  Int_t   *fLabels;       //[fNTracks] array with labels of tracklets
+
+ private:
+  AliAODTracklets(const AliAODTracklets& evt); 
+  AliAODTracklets& operator=(const AliAODTracklets& evt);
+
+  ClassDef(AliAODTracklets, 1);
+};
+
+Float_t AliAODTracklets::GetTheta(Int_t i) const 
+{ 
+  if (i>=0 && i<fNTracks) 
+  {
+    return fTheta[i];
+  }
+  else 
+    Error("GetTheta","Invalid track number %d",i); return -9999.;
+}
+
+Float_t AliAODTracklets::GetPhi(Int_t i) const 
+{ 
+  if (i>=0 && i<fNTracks) 
+  {
+    return fPhi[i];
+  }
+  else 
+    Error("GetPhi","Invalid track number %d",i); return -9999.;
+}
+
+Float_t AliAODTracklets::GetDeltaPhi(Int_t i) const 
+{
+  if (i>=0 && i<fNTracks) 
+  {
+    return fDeltaPhi[i];
+  }
+  else 
+    Error("GetDeltaPhi","Invalid track number %d",i); return -9999.;
+}
+
+Int_t AliAODTracklets::GetLabel(Int_t i) const 
+{
+  if (i>=0 && i<fNTracks) 
+  {
+    return fLabels[i];
+  }
+  else 
+    Error("GetLabel","Invalid track number %d",i); return -9999;
+}
+
+#endif