]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/CALO/AliHLTCaloClusterAnalyser.cxx
- Reshuffling of the particle codes in AliPID. Now the light nuclei are between the
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloClusterAnalyser.cxx
index 44f3b604dad602a3a3bad9aa6b2dc8ddd5086d5d..66fee315f8385824a4824010b203229cc5107f74 100644 (file)
@@ -39,7 +39,7 @@
 #include "TVector3.h"
 #include "TH1F.h"
 #include "TFile.h"
-#include "AliHLTCaloClusterizer.h"
+#include "AliHLTCaloRecoParamHandler.h"
 
 ClassImp(AliHLTCaloClusterAnalyser);
 
@@ -57,7 +57,14 @@ AliHLTCaloClusterAnalyser::AliHLTCaloClusterAnalyser() :
   fDoPID(false),
   fHaveDistanceToBadChannel(false),
   fGeometry(0),
-  fClusterType(AliESDCaloCluster::kPHOSCluster)
+#ifndef HAVE_NOT_ALIVCLUSTER // backward compatibility for r42844
+  fClusterType(AliVCluster::kPHOSNeutral),
+#else
+  fClusterType(AliESDCaloCluster::kPHOSCluster),
+#endif
+  fRecoParamsPtr(0),
+  fCutOnSingleCellClusters(false),
+  fSingleCellEnergyCut(0.5)
 {
   //See header file for documentation
 }
@@ -82,7 +89,7 @@ AliHLTCaloClusterAnalyser::SetRecPointArray(AliHLTCaloRecPointDataStruct **recPo
 }
 
 void 
-AliHLTCaloClusterAnalyser::SetDigitDataArray(AliHLTCaloDigitDataStruct *digits) 
+AliHLTCaloClusterAnalyser::SetDigitDataArray(AliHLTCaloDigitDataStruct **digits) 
 { 
 //   AliHLTCaloClusterizer cl("PHOS");
   // cl.CheckDigits(fRecPointArray, digits, fNRecPoints);
@@ -114,42 +121,50 @@ AliHLTCaloClusterAnalyser::CalculateCenterOfGravity()
        x = 0; 
        z = 0;
 
-       /*Float_t maxAmp = 0;
+/*       Float_t maxAmp = 0;
        Int_t maxX = 0;
-       Int_t maxZ = 0;
-      */for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++)
-       {
-
-         digit = &(fDigitDataArray[*digitIndexPtr]);
-
-         xi = digit->fX+0.5;
-         zi = digit->fZ+0.5;
-
-         if (recPoint->fAmp > 0 && digit->fEnergy > 0) 
-           {
-             Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
-             x    += xi * w ;
-             z    += zi * w ;
-             wtot += w ;
-/*           if(digit->fEnergy > maxAmp)
-             {
-                maxAmp = digit->fEnergy;
-                maxX = digit->fX + 0.5;
-                maxZ = digit->fZ + 0.5;
-             }*/
-           }
-         digitIndexPtr++;
-       }
-
-      if (wtot>0) 
-       {
-         recPoint->fX = x/wtot ;
-         recPoint->fZ = z/wtot ;
-       }
-      else
-       {
-         recPoint->fAmp = 0;
-       }
+       Int_t maxZ = 0;*/
+       if (fDigitDataArray[*digitIndexPtr])
+
+        for(iDigit = 0; iDigit < recPoint->fMultiplicity; iDigit++)
+          {
+            
+            digit = fDigitDataArray[*digitIndexPtr];
+            
+            xi = digit->fX;
+            zi = digit->fZ;
+            
+            //xi = digit->fX+0.5;
+            //zi = digit->fZ+0.5;
+            
+            if (recPoint->fAmp > 0 && digit->fEnergy > 0) 
+              {
+                Float_t w = TMath::Max( 0., fLogWeight + TMath::Log( digit->fEnergy / recPoint->fAmp ) ) ;
+                x    += xi * w ;
+                z    += zi * w ;
+                wtot += w ;
+                /*           if(digit->fEnergy > maxAmp)
+                             {
+                             maxAmp = digit->fEnergy;
+                             maxX = digit->fX;// + 0.5;
+                             maxZ = digit->fZ;// + 0.5;
+                             }*/
+              }
+            digitIndexPtr++;
+          }
+       
+       if (wtot>0) 
+        {
+          recPoint->fX = x/wtot ;
+          recPoint->fZ = z/wtot ;
+        }
+       else
+        {
+          recPoint->fX = -9999;
+          recPoint->fZ =-9999;
+          // no good crashes depth with FP exception
+          //recPoint->fAmp = 0;
+        }
 //     printf("Max digit: E = %f, x = %d, z= %d, cluster: E = %f, x = %f, z = %f\n" , maxAmp, maxX, maxZ, recPoint->fAmp, recPoint->fX, recPoint->fZ);
     }
   return 0;
@@ -183,12 +198,17 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
 {
   //See header file for documentation
 
+   if(fRecoParamsPtr)
+   {
+      fLogWeight = fRecoParamsPtr->GetLogWeight();
+   }
    
   fNRecPoints = nRecPoints;
 
   if(fGeometry == 0)
   {
      HLTError("No geometry object is initialised, creation of clusters stopped");
+     return  -1;
   }
 
   CalculateCenterOfGravity();
@@ -208,6 +228,11 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
         HLTError("Out of buffer: available size is: %d, total size used: %d", availableSize, totSize);
         return -ENOBUFS;
       }
+      
+      AliHLTCaloRecPointDataStruct *recPointPtr = fRecPointArray[i];
+
+      if(fCutOnSingleCellClusters && recPointPtr->fAmp > fSingleCellEnergyCut && recPointPtr->fMultiplicity == 1) continue;
+      
       totSize += sizeof(AliHLTCaloClusterDataStruct);
       
       caloClusterPtr = fCaloClusterDataPtr;
@@ -225,14 +250,15 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
       caloClusterPtr->fNCells = 0;
       caloClusterPtr->fNExMax = 0;
       caloClusterPtr->fTOF = 0;
-      caloClusterPtr->fTrackDx = 0;
-      caloClusterPtr->fTrackDz = 0;
-     
-      AliHLTCaloRecPointDataStruct *recPointPtr = fRecPointArray[i];
+      caloClusterPtr->fTrackDx = -999;
+      caloClusterPtr->fTrackDz = -999;
       
       AliHLTCaloGlobalCoordinate globalCoord;
-      fGeometry->GetGlobalCoordinates(*recPointPtr, globalCoord);
 
+      // 0 = assume photon
+      fGeometry->GetGlobalCoordinates(*recPointPtr, globalCoord, 0);
+
+      caloClusterPtr->fModule = recPointPtr->fModule;
       caloClusterPtr->fGlobalPos[0] =  globalCoord.fX;
       caloClusterPtr->fGlobalPos[1] =  globalCoord.fY;
       caloClusterPtr->fGlobalPos[2] =  globalCoord.fZ;
@@ -257,18 +283,20 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
         HLTError("Out of buffer, available size is: %d, total size used: %d, extra size needed: %d", availableSize, totSize, tmpSize);
         return -ENOBUFS;
       }
+      
       Int_t *digitIndexPtr = &(recPointPtr->fDigits);
       Int_t id = 0;
 
        AliHLTCaloCellDataStruct *cellPtr = &(caloClusterPtr->fCaloCells);
-       
+      Float_t maxTime = 0; //time of maximum amplitude cell is assigned to cluster 
       for(UInt_t j = 0; j < caloClusterPtr->fNCells; j++)
        {
-          digitPtr = &(fDigitDataArray[*digitIndexPtr]);
+          digitPtr = fDigitDataArray[*digitIndexPtr];
           fGeometry->GetCellAbsId(recPointPtr->fModule, digitPtr->fX, digitPtr->fZ, id);
           
          cellPtr->fCellsAbsId= id;
          cellPtr->fCellsAmpFraction = digitPtr->fEnergy/recPointPtr->fAmp;
+               if(digitPtr->fTime > maxTime) maxTime = digitPtr->fTime; 
          //printf("Cell ID pointer: %x\n", cellIDPtr);
         //printf("Cell Amp Pointer: %x\n", cellAmpFracPtr);
         //printf("Cell pos: x = %d, z = %d\n", digitPtr->fX, digitPtr->fZ);
@@ -281,9 +309,20 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
 
       totSize += tmpSize;
 
-      caloClusterPtr->fEnergy = recPointPtr->fAmp;
+      if(fRecoParamsPtr)
+      {
+        caloClusterPtr->fEnergy = fRecoParamsPtr->GetCorrectedEnergy(recPointPtr->fAmp);
+      }
+      else
+      {
+        caloClusterPtr->fEnergy = recPointPtr->fAmp;
+      }
+      
+      // Set the time of the maximum digit as cluster time
+      //caloClusterPtr->fTOF = recPointPtr->fTime;
+                       caloClusterPtr->fTOF = maxTime;
       
-      HLTDebug("Cluster global position: x = %f, y = %f, z = %f, energy: %f, number of cells: %d, cluster pointer: %x", globalCoord.fX, globalCoord.fY, globalCoord.fZ, caloClusterPtr->fEnergy, caloClusterPtr->fNCells,  caloClusterPtr);
+      HLTDebug("Cluster global position: x = %f, y = %f, z = %f, energy: %f, time: %f, number of cells: %d, cluster pointer: %x", globalCoord.fX, globalCoord.fY, globalCoord.fZ, caloClusterPtr->fEnergy, caloClusterPtr->fTOF, caloClusterPtr->fNCells,  caloClusterPtr);
 
       if(fDoClusterFit)
        {
@@ -311,7 +350,7 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
        }
       else
        {
-         for(Int_t k = 0; k < AliPID::kSPECIESN; k++)
+         for(Int_t k = 0; k < AliPID::kSPECIESCN; k++)
            {
              caloClusterPtr->fPID[k] = 0;
            }