Used for Discrimination
authorbnandi <bnandi@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 Mar 2004 15:41:38 +0000 (15:41 +0000)
committerbnandi <bnandi@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 Mar 2004 15:41:38 +0000 (15:41 +0000)
PMD/AliPMDDiscriminator.cxx [new file with mode: 0644]
PMD/AliPMDDiscriminator.h [new file with mode: 0644]
PMD/AliPMDclupid.cxx [new file with mode: 0644]
PMD/AliPMDclupid.h [new file with mode: 0644]
PMD/AliPMDtracker.cxx [new file with mode: 0644]
PMD/AliPMDtracker.h [new file with mode: 0644]

diff --git a/PMD/AliPMDDiscriminator.cxx b/PMD/AliPMDDiscriminator.cxx
new file mode 100644 (file)
index 0000000..0971246
--- /dev/null
@@ -0,0 +1,281 @@
+/***************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------//
+//                                                     //
+//           Date   : August 05 2003                   //
+//  This reads the file PMD.digits.root(TreeD),        //
+//  calls the Clustering algorithm and stores the      //
+//  clustering output in PMD.RecPoints.root(TreeR)     // 
+//                                                     //
+//-----------------------------------------------------//
+
+#include <Riostream.h>
+#include <TMath.h>
+#include <TBRIK.h>
+#include <TNode.h>
+#include <TTree.h>
+#include <TGeometry.h>
+#include <TObjArray.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TNtuple.h>
+#include <TParticle.h>
+
+#include "AliPMDcluster.h"
+#include "AliPMDclupid.h"
+#include "AliPMDDiscriminator.h"
+
+ClassImp(AliPMDDiscriminator)
+
+AliPMDDiscriminator::AliPMDDiscriminator() :
+  fDiscrim(0),
+  fDebug(0)
+{
+//
+// Default Constructor
+//
+
+}
+// -----------------------------------------------------------------------
+AliPMDDiscriminator::~AliPMDDiscriminator()
+{
+  // Destructor
+}
+
+// -----------------------------------------------------------------------
+
+void AliPMDDiscriminator::Discrimination(TObjArray *pmdcontin, TObjArray *pmdcontout)
+{
+  // Does Photon/Hadron discrimination
+
+  if(fDiscrim == 0)
+    {
+      EmpDiscrimination(pmdcontin, pmdcontout);
+    }
+  else if(fDiscrim == 1)
+    {
+      NNDiscrimination();
+    }
+}
+// -----------------------------------------------------------------------
+
+void AliPMDDiscriminator::EmpDiscrimination(TObjArray *pmdcontin, TObjArray *pmdcontout)
+{
+  // Does Photon/Hadron discrimination
+  // matching the clusters of CPV and PREshower plane
+  //
+  const  Int_t kumperdet = 24;
+  static Int_t neibx[6]={1,0,-1,-1,0,1}, neiby[6]={0,1,1,0,-1,-1}; 
+  Int_t   det,smn;
+  Int_t   iprecount[24], icpvcount[24];
+  Float_t xpos,ypos;
+  Float_t adc, ncell, rad;
+  Float_t clusdata[6];
+
+  for(Int_t i = 0; i < kumperdet; i++)
+    {
+      iprecount[i] = 0;
+      icpvcount[i] = 0;
+    }
+  AliPMDcluster  *pmdcl    = 0;
+  AliPMDclupid   *pmdclout = 0;
+
+  Int_t nentries1 = pmdcontin->GetEntries();
+  cout << " nentries1 = " << nentries1 << endl;
+  for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
+    {
+      pmdcl = (AliPMDcluster*)pmdcontin->UncheckedAt(ient1);
+
+      det   = pmdcl->GetDetector();
+      smn   = pmdcl->GetSMN();
+      if(det == 0) iprecount[smn]++;
+      if(det == 1) icpvcount[smn]++;
+    } // Entries of TObjArray loop
+
+  Int_t   idet, ismn;
+  Float_t edepcpv[48][96];
+  Int_t   statuscpv[48][96];
+
+  for(Int_t i = 0; i < kumperdet; i++) // unit module
+    {
+      // Initialisation of the ADC of CPV (1UM)
+      for (Int_t ix = 0; ix < 48;ix++)
+       {
+         for (Int_t iy = 0; iy < 96;iy++)
+           {
+             edepcpv[ix][iy]   = 0.;
+             statuscpv[ix][iy] = 0;
+           }
+       }
+      Int_t precounter   = iprecount[i];
+      Int_t cpvcounter   = icpvcount[i];
+
+      Float_t *xpadpre   = new Float_t[precounter];
+      Float_t *ypadpre   = new Float_t[precounter];
+      Float_t *adcpre    = new Float_t[precounter];
+      Float_t *ncellpre  = new Float_t[precounter];
+      Float_t *radpre    = new Float_t[precounter];
+      Int_t   *sortcoord = new Int_t[precounter];
+      Int_t   *clupidpre = new Int_t[precounter];
+
+      Float_t *xpadcpv   = new Float_t[cpvcounter];
+      Float_t *ypadcpv   = new Float_t[cpvcounter];
+      Float_t *adccpv    = new Float_t[cpvcounter];
+      Float_t *ncellcpv  = new Float_t[cpvcounter];
+      Float_t *radcpv    = new Float_t[cpvcounter];
+
+      Int_t ii = 0;
+      Int_t ij = 0;
+      for (Int_t ient1 = 0; ient1 < nentries1; ient1++)
+       {
+         pmdcl = (AliPMDcluster*)pmdcontin->UncheckedAt(ient1);
+         
+         det   = pmdcl->GetDetector();
+         smn   = pmdcl->GetSMN();
+         xpos  = pmdcl->GetClusX();
+         ypos  = pmdcl->GetClusY();
+         adc   = pmdcl->GetClusADC();
+         ncell = pmdcl->GetClusCells();
+         rad   = pmdcl->GetClusRadius();
+         
+         if(det == 0 && smn == i)
+           {
+             xpadpre[ii]  = xpos;
+             ypadpre[ii]  = ypos;
+             adcpre[ii]   = adc;
+             ncellpre[ii] = ncell;
+             radpre[ii]   = rad;
+             ii++;
+           }
+         if(det == 1 && smn == i)
+           {
+             Int_t ix = (Int_t) (xpos+0.5);
+             Int_t iy = (Int_t) (ypos+0.5);
+             if(ix > 47) ix = 47;
+             if(iy > 95) iy = 95;
+             edepcpv[ix][iy] = adc;
+             xpadcpv[ij]  = xpos;
+             ypadcpv[ij]  = ypos;
+             adccpv[ij]   = adc;
+             ncellcpv[ij] = ncell;
+             radcpv[ij]   = rad;
+             ij++;
+           }
+       } // Entries of TObjArray loop
+      // sorts from lowest ADC to highest ADC
+      // and returns the coordinates
+      Bool_t jsort = false;
+      TMath::Sort(precounter,adcpre,sortcoord,jsort);
+
+      Int_t jjsort = 0;
+      for(Int_t jj=0; jj<precounter; jj++)
+       {
+         // PRE information
+         // PIDs for PRE clusters are 0(photon) and 1(hadron)
+
+         jjsort = sortcoord[jj];
+
+         Int_t ix = (Int_t) (xpadpre[jjsort]+0.5);
+         Int_t iy = (Int_t) (ypadpre[jjsort]+0.5);
+         if(ix > 47) ix = 47;
+         if(iy > 95) iy = 95;
+
+         for(Int_t jk=0; jk<6; jk++)
+           {
+             Int_t jd1 = ix + neibx[jk]; 
+             Int_t jd2 = iy + neiby[jk];
+             if(jd1 <0 ) jd1 = 0;
+             if(jd1 >47) jd1 = 47;
+             if(jd2 <0 ) jd2 = 0;
+             if(jd2 >47) jd2 = 47;
+             if(edepcpv[jd1][jd2] > 0.0 && statuscpv[jd1][jd2] == 0)
+               {
+                 statuscpv[jd1][jd2] = 1;
+                 clupidpre[jjsort]   = 1;
+                 break;
+               }
+           }
+
+         idet        = 0;
+         ismn        = i;
+         clusdata[0] = xpadpre[jjsort];
+         clusdata[1] = ypadpre[jjsort];
+         clusdata[2] = adcpre[jjsort];
+         clusdata[3] = ncellpre[jjsort];
+         clusdata[4] = radpre[jjsort];
+         clusdata[5] = (Float_t) clupidpre[jjsort];
+
+         // Temporary the cluster PID is set to 1 if the
+         // adc > 3MIP units which will be changed later on.
+
+         if (adcpre[jjsort] > 4500.)
+           {
+             clusdata[5] = 1.0;
+           }
+         else
+           {
+             clusdata[5] = 0.0;
+           }
+         pmdclout = new AliPMDclupid(idet,ismn,clusdata);
+         pmdcontout->Add(pmdclout);
+       } // jj loop
+
+      for(Int_t jj=0; jj<cpvcounter; jj++)
+       {
+         // CPV information
+         // PID for CPV clusters is 1
+
+         idet        = 1;
+         ismn        = i;
+         clusdata[0] = xpadcpv[jj];
+         clusdata[1] = ypadcpv[jj];
+         clusdata[2] = adccpv[jj];
+         clusdata[3] = ncellcpv[jj];
+         clusdata[4] = radcpv[jj];
+         clusdata[5] = 0.;
+
+         pmdclout = new AliPMDclupid(idet,ismn,clusdata);
+         pmdcontout->Add(pmdclout);
+       }
+
+      // delete all the pointers
+      delete [] xpadpre;
+      delete [] ypadpre;
+      delete [] adcpre;
+      delete [] ncellpre;
+      delete [] radpre;
+      delete [] clupidpre;
+      delete [] xpadcpv;
+      delete [] ypadcpv;
+      delete [] adccpv;
+      delete [] ncellcpv;
+      delete [] radcpv;
+    } // i loop
+
+}
+// -----------------------------------------------------------------------
+void AliPMDDiscriminator::NNDiscrimination()
+{
+  // This method does discrimination using Neural Network technique
+
+}
+// -----------------------------------------------------------------------
+void AliPMDDiscriminator::SetDiscrimination(Int_t idiscrim)
+{
+  fDiscrim = idiscrim;
+}
+// -----------------------------------------------------------------------
+
diff --git a/PMD/AliPMDDiscriminator.h b/PMD/AliPMDDiscriminator.h
new file mode 100644 (file)
index 0000000..6a70bd9
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef ALIPMDDISCRIMINATOR_H
+#define ALIPMDDISCRIMINATOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+//-----------------------------------------------------//
+//                                                     //
+//  Date   : March 03 2004                             //
+//  Does photon and Hadron discrimination              //
+//                                                     //
+//-----------------------------------------------------//
+
+class TClonesArray;
+class TFile;
+class TObjArray;
+class TTree;
+class TNtuple;
+class TMath;
+
+class AliPMDcluster;
+class AliPMDclupid;
+
+class AliPMDDiscriminator
+{
+
+ public:
+
+  AliPMDDiscriminator();
+  virtual ~AliPMDDiscriminator();
+
+  void Discrimination(TObjArray *pmdcontin, TObjArray *pmdcontout);
+  void EmpDiscrimination(TObjArray *pmdcontin, TObjArray *pmdcontout);
+  void NNDiscrimination();
+
+  void SetDiscrimination(Int_t idiscrim);
+
+ protected:
+
+  Int_t   fDiscrim;       // To switch on different discrimination method
+  Int_t   fDebug;         // Debugging switch (0:NO, 1:YES)
+
+  ClassDef(AliPMDDiscriminator,1) // To run PMD discrimination
+};
+#endif
+
diff --git a/PMD/AliPMDclupid.cxx b/PMD/AliPMDclupid.cxx
new file mode 100644 (file)
index 0000000..9b79aae
--- /dev/null
@@ -0,0 +1,123 @@
+/***************************************************************************
+ * 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.                  *
+ **************************************************************************/
+//-----------------------------------------------------//
+//                                                     //
+//  Date   : March 22 2004                             //
+//                                                     //
+//  Store cluster information                          //
+//  after discrimination                               //
+//                                                     //
+//-----------------------------------------------------//
+#include "Riostream.h"
+#include "Rtypes.h"
+#include "AliPMDclupid.h"
+#include <stdio.h>
+
+ClassImp(AliPMDclupid)
+
+AliPMDclupid::AliPMDclupid():
+  fDet(0),
+  fSMN(0)
+{
+  // Default constructor
+  for (Int_t i = 0; i < 6; i++)
+    {
+      fClusData[i] = 0.;
+    }
+}
+// ------------------------------------------------------------------ //
+AliPMDclupid::AliPMDclupid(Int_t idet, Int_t ismn, Float_t *clusdata)
+{
+  // Constructor
+  fDet = idet;
+  fSMN = ismn;
+  for (Int_t i = 0; i < 6; i++)
+    {
+      fClusData[i] = clusdata[i];
+    }
+}
+// ------------------------------------------------------------------ //
+AliPMDclupid::AliPMDclupid(const AliPMDclupid &pmdclupid):TObject(pmdclupid)
+{
+  //Copy Constructor 
+  if(&pmdclupid == this) return;
+  this->fDet = pmdclupid.fDet;
+  this->fSMN = pmdclupid.fSMN;
+  for(Int_t i=0; i<6; i++)
+    {
+      this->fClusData[i] = pmdclupid.fClusData[i];
+    }
+  return;
+}
+// ------------------------------------------------------------------ //
+AliPMDclupid & AliPMDclupid::operator=(const AliPMDclupid &pmdclupid)
+{
+  // Assignment operator 
+  if(&pmdclupid == this) return *this;
+  this->fDet = pmdclupid.fDet;
+  this->fSMN = pmdclupid.fSMN;
+  for(Int_t i=0; i<6; i++)
+    {
+      this->fClusData[i] = pmdclupid.fClusData[i];
+    }
+  return *this;
+}
+// ------------------------------------------------------------------ //
+AliPMDclupid::~AliPMDclupid()
+{
+  // Destructor
+}
+// ------------------------------------------------------------------ //
+Int_t AliPMDclupid::GetDetector() const
+{
+  return fDet;
+}
+// ------------------------------------------------------------------ //
+Int_t AliPMDclupid::GetSMN() const
+{
+  return fSMN;
+}
+// ------------------------------------------------------------------ //
+Float_t AliPMDclupid::GetClusX() const
+{
+  return fClusData[0];
+}
+// ------------------------------------------------------------------ //
+Float_t AliPMDclupid::GetClusY() const
+{
+  return fClusData[1];
+}
+// ------------------------------------------------------------------ //
+Float_t AliPMDclupid::GetClusADC() const
+{
+  return fClusData[2];
+}
+// ------------------------------------------------------------------ //
+Float_t AliPMDclupid::GetClusCells() const
+{
+  return fClusData[3];
+}
+// ------------------------------------------------------------------ //
+Float_t AliPMDclupid::GetClusRadius() const
+{
+  return fClusData[4];
+}
+// ------------------------------------------------------------------ //
+Float_t AliPMDclupid::GetClusPID() const
+{
+  return fClusData[5];
+}
+
+
diff --git a/PMD/AliPMDclupid.h b/PMD/AliPMDclupid.h
new file mode 100644 (file)
index 0000000..fb7c444
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef ALIPMDCLUPID_H
+#define ALIPMDCLUPID_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+//-----------------------------------------------------//
+//                                                     //
+//  Date   : March 22 2004                             //
+//                                                     //
+//  Store cluster informations for PMD                 //
+//  after Discrimination                               //
+//                                                     //
+//-----------------------------------------------------//
+
+#include "Rtypes.h"
+#include "TObject.h"
+class TClonesArray;
+
+class AliPMDclupid : public TObject
+{
+ public:
+  AliPMDclupid();
+  AliPMDclupid(Int_t idet, Int_t ismn, Float_t *clusdata);
+  AliPMDclupid(AliPMDclupid *pmdclupid) {*this = *pmdclupid;}
+  AliPMDclupid (const AliPMDclupid &pmdclupid);  // copy constructor
+  AliPMDclupid &operator=(const AliPMDclupid &pmdclupid); // assignment op
+  
+  virtual ~AliPMDclupid();
+
+  Int_t   GetDetector() const;
+  Int_t   GetSMN() const;
+  Float_t GetClusX() const;
+  Float_t GetClusY() const;
+  Float_t GetClusADC() const;
+  Float_t GetClusCells() const;
+  Float_t GetClusRadius() const;
+  Float_t GetClusPID() const;
+
+ protected:
+
+  Int_t   fDet;          // Detector No (0:PRE, 1:CPV)
+  Int_t   fSMN;          // Serial Module No.
+  Float_t fClusData[6];  // Array containing clupid information
+  /*
+    fDet         : Det (0:PRE, 1:CPV), fSMN         : SerialModuleNo
+    fClusData[0] : Cluster x         , fClusData[1] : Cluster y
+    fClusData[2] : Cluster adc       , fClusData[3] : Cluster Cells
+    fClusData[4] : Cluster radius    , fClusData[5] : Cluster pid
+  */
+  
+  ClassDef(AliPMDclupid,1) // Keep Cluster information
+};
+
+#endif
diff --git a/PMD/AliPMDtracker.cxx b/PMD/AliPMDtracker.cxx
new file mode 100644 (file)
index 0000000..2d13f32
--- /dev/null
@@ -0,0 +1,247 @@
+/***************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//-----------------------------------------------------//
+//                                                     //
+//           Date   : March 25 2004                    //
+//  This reads the file PMD.RecPoints.root(TreeR),     //
+//  calls the Clustering algorithm and stores the      //
+//  clustering output in PMD.RecPoints.root(TreeR)     // 
+//                                                     //
+//-----------------------------------------------------//
+
+#include <Riostream.h>
+#include <TMath.h>
+#include <TBRIK.h>
+#include <TNode.h>
+#include <TTree.h>
+#include <TGeometry.h>
+#include <TObjArray.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TBranch.h>
+#include <TNtuple.h>
+#include <TParticle.h>
+
+#include "AliPMDcluster.h"
+#include "AliPMDclupid.h"
+#include "AliPMDrecpoint1.h"
+#include "AliPMDUtility.h"
+#include "AliPMDDiscriminator.h"
+#include "AliPMDtracker.h"
+
+#include "AliESDPmdTrack.h"
+#include "AliESD.h"
+
+
+ClassImp(AliPMDtracker)
+
+AliPMDtracker::AliPMDtracker():
+  fTreeR(0),
+  fRecpoints(new TClonesArray("AliPMDrecpoint1", 1000)),
+  fPMDcontin(new TObjArray()),
+  fPMDcontout(new TObjArray()),
+  fPMDdiscriminator(new AliPMDDiscriminator()),
+  fPMDutil(new AliPMDUtility()),
+  fPMDrecpoint(0),
+  fPMDclin(0),
+  fPMDclout(0),
+  fDebug(0),
+  fXvertex(0.),
+  fYvertex(0.),
+  fZvertex(0.),
+  fSigmaX(0.),
+  fSigmaY(0.),
+  fSigmaZ(0.)
+{
+  //
+  // Default Constructor
+  //
+}
+//--------------------------------------------------------------------//
+AliPMDtracker::~AliPMDtracker()
+{
+  // Destructor
+  if (fRecpoints)
+    {
+      fRecpoints->Delete();
+      delete fRecpoints;
+      fRecpoints=0;
+    }
+  if (fPMDcontin)
+    {
+      fPMDcontin->Delete();
+      delete fPMDcontin;
+      fPMDcontin=0;
+    }
+  if (fPMDcontout)
+    {
+      fPMDcontout->Delete();
+      delete fPMDcontout;
+      fPMDcontout=0;
+    }
+}
+//--------------------------------------------------------------------//
+void AliPMDtracker::LoadClusters(TTree *treein)
+{
+  // Load the Reconstructed tree
+  fTreeR = treein;
+}
+//--------------------------------------------------------------------//
+void AliPMDtracker::Clusters2Tracks(AliESD *event)
+{
+  // Converts digits to recpoints after running clustering
+  // algorithm on CPV plane and PREshower plane
+  //
+
+  Int_t   idet;
+  Int_t   ismn;
+  Float_t clusdata[5];
+
+  TBranch *branch = fTreeR->GetBranch("PMDRecpoint");
+  branch->SetAddress(&fRecpoints);  
+  
+  Int_t   nmodules = (Int_t) fTreeR->GetEntries();
+  cout << " nmodules = " << nmodules << endl;
+  for (Int_t imodule = 0; imodule < nmodules; imodule++)
+    {
+      fTreeR->GetEntry(imodule); 
+      Int_t nentries = fRecpoints->GetLast();
+      //      cout << " nentries = " << nentries << endl;
+      for(Int_t ient = 0; ient < nentries+1; ient++)
+       {
+         fPMDrecpoint = (AliPMDrecpoint1*)fRecpoints->UncheckedAt(ient);
+         idet        = fPMDrecpoint->GetDetector();
+         ismn        = fPMDrecpoint->GetSMNumber();
+         clusdata[0] = fPMDrecpoint->GetClusX();
+         clusdata[1] = fPMDrecpoint->GetClusY();
+         clusdata[2] = fPMDrecpoint->GetClusADC();
+         clusdata[3] = fPMDrecpoint->GetClusCells();
+         clusdata[4] = fPMDrecpoint->GetClusRadius();
+         
+         fPMDclin = new AliPMDcluster(idet,ismn,clusdata);
+         fPMDcontin->Add(fPMDclin);
+       }
+    }
+
+  fPMDdiscriminator->Discrimination(fPMDcontin,fPMDcontout);
+
+  const Float_t kzpos = 361.5;
+  Int_t   ism =0, ium=0;
+  Int_t   det,smn;
+  Float_t xpos,ypos;
+  Float_t xpad = 0, ypad = 0;
+  Float_t adc, ncell, rad;
+  Float_t xglobal, yglobal;
+  Float_t pid;
+
+  Float_t zglobal = kzpos + (Float_t) fZvertex;
+
+  Int_t nentries2 = fPMDcontout->GetEntries();
+  cout << " nentries2 = " << nentries2 << endl;
+  for (Int_t ient1 = 0; ient1 < nentries2; ient1++)
+    {
+      fPMDclout = (AliPMDclupid*)fPMDcontout->UncheckedAt(ient1);
+      
+      det   = fPMDclout->GetDetector();
+      smn   = fPMDclout->GetSMN();
+      xpos  = fPMDclout->GetClusX();
+      ypos  = fPMDclout->GetClusY();
+      adc   = fPMDclout->GetClusADC();
+      ncell = fPMDclout->GetClusCells();
+      rad   = fPMDclout->GetClusRadius();
+      pid   = fPMDclout->GetClusPID();
+      
+      //
+      // Now change the xpos and ypos to its original values
+      // for the unit modules which are earlier changed.
+      // xpad and ypad are the real positions.
+      //
+      /**********************************************************************
+       *    det   : Detector, 0: PRE & 1:CPV                                *
+       *    smn   : Serial Module Number from which Super Module Number     *
+       *            and Unit Module Numbers are extracted                   *
+       *    xpos  : x-position of the cluster                               *
+       *    ypos  : y-position of the cluster                               *
+       *            THESE xpos & ypos are not the true xpos and ypos        *
+       *            for some of the unit modules. They are rotated.         *
+       *    adc   : ADC contained in the cluster                            *
+       *    ncell : Number of cells contained in the cluster                *
+       *    rad   : radius of the cluster (1d fit)                          *
+       *    ism   : Supermodule number extracted from smn                   *
+       *    ium   : Unit module number extracted from smn                   *
+       *    xpad  : TRUE x-position of the cluster                          *
+       *    ypad  : TRUE y-position of the cluster                          *
+       **********************************************************************/
+      //
+      if(det == 0 || det == 1)
+       {
+         if(smn < 12)
+           {
+             ism  = smn/6;
+             ium  = smn - ism*6;
+             xpad = ypos;
+             ypad = xpos;
+           }
+         else if( smn >= 12 && smn < 24)
+           {
+             ism  = smn/6;
+             ium  = smn - ism*6;
+             xpad = xpos;
+             ypad = ypos;
+           }
+       }
+     
+      fPMDutil->RectGeomCellPos(ism,ium,xpad,ypad,xglobal,yglobal);
+      fPMDutil->SetXYZ(xglobal,yglobal,zglobal);
+      fPMDutil->CalculateEtaPhi();
+      Float_t theta = fPMDutil->GetTheta();
+      Float_t phi   = fPMDutil->GetPhi();
+
+      // Fill ESD
+
+      AliESDPmdTrack *esdpmdtr = new  AliESDPmdTrack();
+
+      esdpmdtr->SetDetector(det);
+      esdpmdtr->SetTheta(theta);
+      esdpmdtr->SetPhi(phi);
+      esdpmdtr->SetClusterADC(adc);
+      esdpmdtr->SetClusterPID(pid);
+
+      event->AddPmdTrack(esdpmdtr);
+    }
+
+}
+//--------------------------------------------------------------------//
+void AliPMDtracker::SetVertex(Double_t vtx[3], Double_t evtx[3])
+{
+  fXvertex = vtx[0];
+  fYvertex = vtx[1];
+  fZvertex = vtx[2];
+  fSigmaX  = evtx[0];
+  fSigmaY  = evtx[1];
+  fSigmaZ  = evtx[2];
+}
+//--------------------------------------------------------------------//
+void AliPMDtracker::SetDebug(Int_t idebug)
+{
+  fDebug = idebug;
+}
+//--------------------------------------------------------------------//
+void AliPMDtracker::ResetClusters()
+{
+  if (fRecpoints) fRecpoints->Clear();
+}
+//--------------------------------------------------------------------//
diff --git a/PMD/AliPMDtracker.h b/PMD/AliPMDtracker.h
new file mode 100644 (file)
index 0000000..b933546
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef ALIPMDTRACKER_H
+#define ALIPMDTRACKER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+//-----------------------------------------------------//
+//                                                     //
+//  Date   : August 05 2003                            //
+//  This reads the file PMD.digits.root(TreeD),        //
+//  calls the Clustering algorithm and stores the      //
+//  clustering output in PMD.RecPoints.root(TreeR)     // 
+//                                                     //
+//-----------------------------------------------------//
+
+class TClonesArray;
+class TFile;
+class TObjArray;
+class TTree;
+class TNtuple;
+class TMath;
+class TBranch;
+
+class AliPMDcluster;
+class AliPMDclupid;
+class AliPMDrecpoint1;
+class AliPMDUtility;
+class AliPMDDiscriminator;
+
+class AliESDPmdTrack;
+class AliESD;
+
+class AliPMDtracker
+{
+
+ public:
+
+  AliPMDtracker();
+  virtual ~AliPMDtracker();
+
+  void LoadClusters(TTree *treein);
+  void Clusters2Tracks(AliESD *event);
+  void SetVertex(Double_t vtx[3], Double_t evtx[3]);
+  void SetDebug(Int_t idebug);
+  void ResetClusters();
+
+ protected:
+
+  TTree        *fTreeR;     // Reconstructed points
+  TClonesArray *fRecpoints; // List of reconstructed points
+  TObjArray    *fPMDcontin;
+  TObjArray    *fPMDcontout;
+
+  AliPMDDiscriminator *fPMDdiscriminator;
+  AliPMDUtility       *fPMDutil;
+  AliPMDrecpoint1     *fPMDrecpoint;
+  AliPMDcluster       *fPMDclin;
+  AliPMDclupid        *fPMDclout;
+
+  Int_t    fDebug;          // Debugging switch (0:NO, 1:YES)
+  Double_t fXvertex;        // X-vertex position
+  Double_t fYvertex;        // Y-vertex position
+  Double_t fZvertex;        // Z-vertex position
+  Double_t fSigmaX;         // X-vertex error
+  Double_t fSigmaY;         // Y-vertex error
+  Double_t fSigmaZ;         // Z-vertex error
+
+  ClassDef(AliPMDtracker,1) // To run PMD clustering
+};
+#endif
+