]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALReconstructor.cxx
Rongrong: 1. All the extrapolation methods are implemented in AliEMCALTracker; 2...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALReconstructor.cxx
index af5ae92542e50540417d49288e6b43f3f7965c18..15d62ba7a801d830f12169c1084717d07bb34613 100644 (file)
@@ -1,4 +1,5 @@
 /**************************************************************************
+#/eliza17/alice/esdfiles/data/2011/LHC11a/000146805/ESDs/pass2_without_SDD/11000146805038.550/root_archive.zip#AliESDs.root
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
  * Author: The ALICE Off-line Project.                                    *
 #include "AliEMCALRawUtils.h"
 #include "AliEMCALDigit.h"
 #include "AliEMCALClusterizerv1.h"
+#include "AliEMCALClusterizerv2.h"
 #include "AliEMCALClusterizerNxN.h"
 #include "AliEMCALRecPoint.h"
 #include "AliEMCALPID.h"
-#include "AliEMCALTrigger.h"
+#include "AliEMCALTracker.h"
 #include "AliRawReader.h"
 #include "AliCDBEntry.h"
 #include "AliCDBManager.h"
@@ -80,7 +82,9 @@ AliEMCALReconstructor::AliEMCALReconstructor()
   : fGeom(0),fCalibData(0),fPedestalData(0),fTriggerData(0x0), fMatches(0x0)
 {
   // ctor
-  
+
+  // AliDebug(2, "Mark.");  
+
   fgRawUtils = new AliEMCALRawUtils;
   
   //To make sure we match with the geometry in a simulation file,
@@ -143,7 +147,9 @@ AliEMCALReconstructor::AliEMCALReconstructor()
 AliEMCALReconstructor::~AliEMCALReconstructor()
 {
   // dtor
-  
+
+  //AliDebug(2, "Mark.");
+
   if(fGeom)              delete fGeom;
   
   //No need to delete, recovered from OCDB
@@ -200,24 +206,34 @@ void AliEMCALReconstructor::InitClusterizer() const
       //printf("ReCreate clusterizer? Clusterizer set <%d>, Clusterizer in use <%s>\n",
       //     clusterizerType, fgClusterizer->Version());
       
-      if     (clusterizerType == AliEMCALRecParam::kClusterizerv1 && !strcmp(fgClusterizer->Version(),"clu-v1")) return;
+      if     (clusterizerType == AliEMCALRecParam::kClusterizerv1  && !strcmp(fgClusterizer->Version(),"clu-v1"))  return;
       
       else if(clusterizerType == AliEMCALRecParam::kClusterizerNxN && !strcmp(fgClusterizer->Version(),"clu-NxN")) return;
       
+      else if(clusterizerType == AliEMCALRecParam::kClusterizerv2  && !strcmp(fgClusterizer->Version(),"clu-v2"))  return;
+      
       //Need to create new clusterizer, the one set previously is not the correct one     
       delete fgClusterizer;
     }
     else return;
   }
   
-  if (clusterizerType  == AliEMCALRecParam::kClusterizerv1)
+  if      (clusterizerType  == AliEMCALRecParam::kClusterizerv1)
     {
-      fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData);
+      fgClusterizer = new AliEMCALClusterizerv1 (fGeom, fCalibData,fPedestalData);
     }
-  else
+  else if (clusterizerType  == AliEMCALRecParam::kClusterizerNxN)
     {
       fgClusterizer = new AliEMCALClusterizerNxN(fGeom, fCalibData,fPedestalData);
     }
+  else if (clusterizerType  == AliEMCALRecParam::kClusterizerv2)
+  {
+    fgClusterizer = new AliEMCALClusterizerv2   (fGeom, fCalibData,fPedestalData);
+  }
+  else 
+  {
+    AliFatal(Form("Unknown clusterizer %d ", clusterizerType));
+  }
 }
 
 //____________________________________________________________________________
@@ -255,6 +271,9 @@ void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree)
   }//not a LED event
   
   clustersTree->Fill();        
+
+  // Deleting the recpoints at the end of the reconstruction call
+  fgClusterizer->DeleteRecPoints();
 }
 
 //____________________________________________________________________________
@@ -291,7 +310,7 @@ void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
     fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold());
     fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples());
     fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels());
-    fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
+    if (!fgRawUtils->GetFittingAlgorithm()) fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm());
     fgRawUtils->SetFALTROUsage(GetRecParam()->UseFALTRO());
     
     //fgRawUtils->SetTimeMin(GetRecParam()->GetTimeMin());
@@ -419,17 +438,19 @@ void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
   
   Int_t nDigits = fgDigitsArr->GetEntries(), idignew = 0 ;
   AliDebug(1,Form("%d digits",nDigits));
-  
   AliESDCaloCells &emcCells = *(esd->GetEMCALCells());
   emcCells.CreateContainer(nDigits);
   emcCells.SetType(AliVCaloCells::kEMCALCell);
   Float_t energy = 0;
+  Float_t time   = 0;
   for (Int_t idig = 0 ; idig < nDigits ; idig++) {
     const AliEMCALDigit * dig = (const AliEMCALDigit*)fgDigitsArr->At(idig);
-    if(dig->GetAmplitude() > 0 ){
-      energy = fgClusterizer->Calibrate(dig->GetAmplitude(),dig->GetTime(),dig->GetId()); //TimeR or Time?
-      if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them     
-        emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime());   
+    time   = dig->GetTime();      // Time already calibrated in clusterizer
+    energy = dig->GetAmplitude(); // energy calibrated in clusterizer
+    if(energy > 0 ){
+      fgClusterizer->Calibrate(energy,time,dig->GetId()); //Digits already calibrated in clusterizers
+      if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them
+        emcCells.SetCell(idignew,dig->GetId(),energy, time);   
         idignew++;
       }
     }
@@ -679,6 +700,9 @@ Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCl
 
   // If the esdFriend is available, use the TPCOuter point as the starting point of extrapolation
   // Otherwise use the TPCInner point
+
+  dEta = -999, dPhi = -999;
+
   AliExternalTrackParam *trkParam = 0;
   const AliESDfriendTrack*  friendTrack = track->GetFriendTrack();
   if(friendTrack && friendTrack->GetTPCOut())
@@ -687,34 +711,8 @@ Bool_t AliEMCALReconstructor::CalculateResidual(AliESDtrack *track, AliESDCaloCl
     trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam());
   if(!trkParam) return kFALSE;
 
-  //Perform extrapolation
-  Double_t trkPos[3];
-  Float_t  clsPos[3];
-
   AliExternalTrackParam trkParamTmp (*trkParam);
-  cluster->GetPosition(clsPos);
-  TVector3 vec(clsPos[0],clsPos[1],clsPos[2]);
-  Double_t alpha =  ((int)(vec.Phi()*TMath::RadToDeg()/20)+0.5)*20*TMath::DegToRad();
-  //Rotate to proper local coordinate
-  vec.RotateZ(-alpha); 
-  trkParamTmp.Rotate(alpha); 
-  //extrapolation is done here
-  if(!AliTrackerBase::PropagateTrackToBxByBz(&trkParamTmp, vec.X(), track->GetMass(), GetRecParam()->GetExtrapolateStep(), kFALSE, 0.8, -1)) 
-    return kFALSE; 
-
-  //Calculate the residuals
-  trkParamTmp.GetXYZ(trkPos); 
-   
-  TVector3 clsPosVec(clsPos[0],clsPos[1],clsPos[2]);
-  TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
-      
-  Double_t clsPhi = clsPosVec.Phi();
-  if(clsPhi<0) clsPhi+=2*TMath::Pi();
-  Double_t trkPhi = trkPosVec.Phi();
-  if(trkPhi<0) trkPhi+=2*TMath::Pi();
-
-  dPhi = clsPhi-trkPhi;
-  dEta = clsPosVec.Eta()-trkPosVec.Eta();
+  if(!AliEMCALTracker::ExtrapolateTrackToCluster(&trkParamTmp, cluster, track->GetMass(), GetRecParam()->GetExtrapolateStep(), dEta, dPhi)) return kFALSE;
 
   return kTRUE;
 }