]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDtracker.cxx
defects fixed
[u/mrichter/AliRoot.git] / PMD / AliPMDtracker.cxx
index 016f5fe2489ecaf31f24d22dd2c356feaf342d24..27ef93aa3b5ec88786230a8372124cc28cd23109 100644 (file)
 #include <TNtuple.h>
 #include <TParticle.h>
 
+#include <TGeoMatrix.h>
+
+#include "AliGeomManager.h"
+
 #include "AliPMDcluster.h"
 #include "AliPMDclupid.h"
 #include "AliPMDrecpoint1.h"
@@ -142,10 +146,10 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
   // algorithm on CPV plane and PREshower plane
   //
 
-  Int_t   idet;
-  Int_t   ismn;
-  Int_t   trackno, trackpid;
-  Float_t clusdata[6];
+  Int_t   idet = 0;
+  Int_t   ismn = 0;
+  Int_t   trackno = 1, trackpid = 0;
+  Float_t clusdata[6] = {0.,0.,0.,0.,0.,0.};
   
   Int_t *irow;
   Int_t *icol;
@@ -193,7 +197,7 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
          clusdata[3] = fPMDrecpoint->GetClusCells();
          clusdata[4] = fPMDrecpoint->GetClusSigmaX();
          clusdata[5] = fPMDrecpoint->GetClusSigmaY();
-         
+
          if (clusdata[4] >= 0. && clusdata[5] >= 0.)
            { 
              // extract the associated cell information
@@ -205,7 +209,15 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
              itra = new Int_t[nenbr1];
              ipid = new Int_t[nenbr1];
              cadc = new Float_t[nenbr1];
-
+             
+             for (Int_t ient1 = 0; ient1 < nenbr1; ient1++)
+               {
+                 irow[ient1] = -99;
+                 icol[ient1] = -99;
+                 itra[ient1] = -99;
+                 ipid[ient1] = -99;
+                 cadc[ient1] = 0.;
+               }
              for (Int_t ient1 = 0; ient1 < nenbr1; ient1++)
                {
                  rechit = (AliPMDrechit*)fRechits->UncheckedAt(ient1);
@@ -215,8 +227,16 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
                  ipid[ient1] = rechit->GetCellPid();
                  cadc[ient1] = rechit->GetCellAdc();
                }
-             AssignTrPidToCluster(nenbr1, itra, ipid, cadc,
-                                  trackno, trackpid);
+             if (idet == 0)
+               {
+                 AssignTrPidToCluster(nenbr1, itra, ipid, cadc,
+                                      trackno, trackpid);
+               }
+             else if (idet == 1)
+               {
+                 trackno  = itra[0];
+                 trackpid = ipid[0];
+               }
 
              delete [] irow;
              delete [] icol;
@@ -232,17 +252,42 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
        }
     }
 
-  AliPMDDiscriminator *pmddiscriminator = new AliPMDEmpDiscriminator();
-  pmddiscriminator->Discrimination(fPMDcontin,fPMDcontout);
+  AliPMDEmpDiscriminator pmddiscriminator;
+  pmddiscriminator.Discrimination(fPMDcontin,fPMDcontout);
+
+  // alignment implemention
+
+  Double_t sectr[4][3] = { {0.,0.,0.},{0.,0.,0.},{0.,0.,0.},{0.,0.,0.}};
+  TString snsector="PMD/Sector";
+  TString symname;
+  TGeoHMatrix gpmdor;
+  
+  for(Int_t isector=1; isector<=4; isector++)
+    {
+      symname = snsector;
+      symname += isector;
+      TGeoHMatrix *gpmdal = AliGeomManager::GetMatrix(symname);
+      Double_t *tral = gpmdal->GetTranslation();
+
+      AliGeomManager::GetOrigGlobalMatrix(symname, gpmdor);
+      Double_t *tror = gpmdor.GetTranslation();
+      
+      for(Int_t ixyz=0; ixyz<3; ixyz++)
+       {
+         sectr[isector-1][ixyz] = tral[ixyz] - tror[ixyz];
+       }
+    }
 
   const Float_t kzpos = 361.5;    // middle of the PMD
 
-  Int_t   det,smn,trno,trpid,mstat;
-  Float_t xpos,ypos;
-  Float_t adc, ncell, radx, rady;
+  Int_t   ix = -1, iy = -1;
+  Int_t   det = 0, smn = 0, trno = 1, trpid = 0, mstat = 0;
+  Float_t xpos = 0., ypos = 0.;
+  Float_t adc = 0., ncell = 0., radx = 0., rady = 0.;
   Float_t xglobal = 0., yglobal = 0., zglobal = 0;
-  Float_t pid;
+  Float_t pid = 0.;
 
+  fPMDutil->ApplyAlignment(sectr);
 
   Int_t nentries2 = fPMDcontout->GetEntries();
   AliDebug(1,Form("Number of clusters coming after discrimination = %d"
@@ -261,7 +306,28 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
       adc   = fPMDclout->GetClusADC();
       ncell = fPMDclout->GetClusCells();
       radx  = fPMDclout->GetClusSigmaX();
-      rady  = fPMDclout->GetClusSigmaY();
+      // Here in the variable "rady" we are keeping the row and col
+      // of the single isolated cluster having ncell = 1 for offline
+      // calibration
+      
+      if ((radx > 999. && radx < 1000.) && ncell == 1)
+       {
+         if (smn < 12)
+           {
+             ix = (Int_t) (ypos +0.5);
+             iy = (Int_t) xpos;
+           }
+         else if (smn > 12 && smn < 24)
+           {
+             ix = (Int_t) xpos;
+             iy = (Int_t) (ypos +0.5);
+           }
+         rady = (Float_t) (ix*100 + iy);
+       }
+      else
+       {
+         rady  = fPMDclout->GetClusSigmaY();
+       }
       pid   = fPMDclout->GetClusPID();
       
       //
@@ -278,17 +344,18 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
        **********************************************************************/
       //
 
-      fPMDutil->RectGeomCellPos(smn,xpos,ypos,xglobal,yglobal);
 
       if (det == 0)
        {
-         zglobal = kzpos + 1.6; // PREshower plane
+         zglobal = kzpos + 1.65; // PREshower plane
        }
       else if (det == 1)
        {
-         zglobal = kzpos - 1.7; // CPV plane
+         zglobal = kzpos - 1.65; // CPV plane
        }
 
+      fPMDutil->RectGeomCellPos(smn,xpos,ypos,xglobal,yglobal,zglobal);
+
       // Fill ESD
 
       AliESDPmdTrack *esdpmdtr = new  AliESDPmdTrack();
@@ -309,6 +376,7 @@ void AliPMDtracker::Clusters2Tracks(AliESDEvent *event)
       esdpmdtr->SetClusterSigmaY(rady);
 
       event->AddPmdTrack(esdpmdtr);
+      delete esdpmdtr;
     }
 
   fPMDcontin->Delete();
@@ -324,19 +392,31 @@ void AliPMDtracker::AssignTrPidToCluster(Int_t nentry, Int_t *itra,
   // split cluster part will be done at the time of calculating eff/pur
 
   Int_t *phentry = new Int_t [nentry];
+  Int_t *hadentry = new Int_t [nentry];
   Int_t *trenergy = 0x0;
+  Int_t *trpid    = 0x0;
   Int_t *sortcoord = 0x0;
 
   Int_t ngtrack = 0;
+  Int_t nhtrack = 0;
   for (Int_t i = 0; i < nentry; i++)
     {
       phentry[i] = -1;
+      hadentry[i] = -1;
+
       if (ipid[i] == 22)
        {
          phentry[ngtrack] = i;
          ngtrack++;
        }
+      else if (ipid[i] != 22)
+       {
+         hadentry[nhtrack] = i;
+         nhtrack++;
+       }
     }
+  
+  Int_t nghadtrack = ngtrack + nhtrack;
 
   if (ngtrack == 0)
     {
@@ -345,45 +425,66 @@ void AliPMDtracker::AssignTrPidToCluster(Int_t nentry, Int_t *itra,
       trackpid = 8;
       trackno  = -1;
     }
-  else if (ngtrack == 1)
+  else if (ngtrack >= 1)
     {
-      // only one photon track
-      // track number set to photon track
-      trackpid = 1;
-      trackno  = itra[phentry[0]];
-    }
-  else if (ngtrack > 1)
-    {
-      // more than one photon track
+      // one or more than one photon track + charged track
+      // find out which track deposits maximum energy and
+      // assign that track number and track pid
 
-      trenergy  = new Int_t [ngtrack];
-      sortcoord = new Int_t [ngtrack];
+      trenergy  = new Int_t [nghadtrack];
+      trpid     = new Int_t [nghadtrack];
+      sortcoord = new Int_t [nghadtrack];
       for (Int_t i = 0; i < ngtrack; i++)
        {
          trenergy[i] = 0.;
+         trpid[i]    = -1;
          for (Int_t j = 0; j < nentry; j++)
            {
              if (ipid[j] == 22 && itra[j] == itra[phentry[i]])
                {
                  trenergy[i] += cadc[j];
+                 trpid[i]     = 22;
                }
            }
        }
-
+      for (Int_t i = ngtrack; i < nghadtrack; i++)
+       {
+         trenergy[i] = 0.;
+         trpid[i]    = -1;
+         for (Int_t j = 0; j < nentry; j++)
+           {
+             if (ipid[j] != 22 && itra[j] == itra[hadentry[i-ngtrack]])
+               {
+                 trenergy[i] += cadc[j];
+                 trpid[i]     = ipid[j];
+               }
+           }
+       }
+      
       Bool_t jsort = true;
-      TMath::Sort(ngtrack,trenergy,sortcoord,jsort);
-
+      TMath::Sort(nghadtrack,trenergy,sortcoord,jsort);
+      
       Int_t gtr = sortcoord[0];   
-      trackno  = itra[phentry[gtr]];   // highest adc track
-      trackpid = 1;
-
+      if (trpid[gtr] == 22)
+       {
+         trackpid = 22;
+         trackno  = itra[phentry[gtr]];   // highest adc track
+       }
+      else
+       {
+         trackpid = 8;
+         trackno = -1;
+       }
+      
       delete [] trenergy;
+      delete [] trpid;
       delete [] sortcoord;
+      
+    }   // end of ngtrack >= 1
 
-    }   // end of ngtrack > 1
-
-
-
+  delete [] phentry;
+  delete [] hadentry;
+  
 }
 //--------------------------------------------------------------------//
 void AliPMDtracker::SetVertex(Double_t vtx[3], Double_t evtx[3])