]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALRecoUtils.cxx
Implementing the wrapper volumes (Mario)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALRecoUtils.cxx
index c82d08a3f78c376628c6cf2ca8919c7fd87d0dcc..d00ac19ee6c164b9acf24b17e1d1929f2741fce5 100644 (file)
@@ -72,12 +72,13 @@ AliEMCALRecoUtils::AliEMCALRecoUtils():
   fRejectExoticCluster(kFALSE),           fRejectExoticCells(kFALSE), 
   fExoticCellFraction(0),                 fExoticCellDiffTime(0),                 fExoticCellMinAmplitude(0),
   fPIDUtils(),                            fAODFilterMask(0),
+  fAODHybridTracks(0),                    fAODTPCOnlyTracks(0),
   fMatchedTrackIndex(0x0),                fMatchedClusterIndex(0x0), 
   fResidualEta(0x0), fResidualPhi(0x0),   fCutEtaPhiSum(kFALSE),                  fCutEtaPhiSeparate(kFALSE), 
   fCutR(0),                               fCutEta(0),                             fCutPhi(0),
   fClusterWindow(0),                      fMass(0),                           
   fStepSurface(0),                        fStepCluster(0),
-  fITSTrackSA(kFALSE),
+  fITSTrackSA(kFALSE),                    fEMCalSurfaceDistance(430.),
   fTrackCutsType(0),                      fCutMinTrackPt(0),                      fCutMinNClusterTPC(0), 
   fCutMinNClusterITS(0),                  fCutMaxChi2PerClusterTPC(0),            fCutMaxChi2PerClusterITS(0),
   fCutRequireTPCRefit(kFALSE),            fCutRequireITSRefit(kFALSE),            fCutAcceptKinkDaughters(kFALSE),
@@ -119,6 +120,7 @@ AliEMCALRecoUtils::AliEMCALRecoUtils(const AliEMCALRecoUtils & reco)
   fExoticCellFraction(reco.fExoticCellFraction),             fExoticCellDiffTime(reco.fExoticCellDiffTime),               
   fExoticCellMinAmplitude(reco.fExoticCellMinAmplitude),
   fPIDUtils(reco.fPIDUtils),                                 fAODFilterMask(reco.fAODFilterMask),
+  fAODHybridTracks(reco.fAODHybridTracks),                   fAODTPCOnlyTracks(reco.fAODTPCOnlyTracks),
   fMatchedTrackIndex(  reco.fMatchedTrackIndex?  new TArrayI(*reco.fMatchedTrackIndex):0x0),
   fMatchedClusterIndex(reco.fMatchedClusterIndex?new TArrayI(*reco.fMatchedClusterIndex):0x0),
   fResidualEta(        reco.fResidualEta?        new TArrayF(*reco.fResidualEta):0x0),
@@ -127,7 +129,7 @@ AliEMCALRecoUtils::AliEMCALRecoUtils(const AliEMCALRecoUtils & reco)
   fCutR(reco.fCutR),        fCutEta(reco.fCutEta),           fCutPhi(reco.fCutPhi),
   fClusterWindow(reco.fClusterWindow),
   fMass(reco.fMass),        fStepSurface(reco.fStepSurface), fStepCluster(reco.fStepCluster),
-  fITSTrackSA(reco.fITSTrackSA),
+  fITSTrackSA(reco.fITSTrackSA),                             fEMCalSurfaceDistance(430.),
   fTrackCutsType(reco.fTrackCutsType),                       fCutMinTrackPt(reco.fCutMinTrackPt), 
   fCutMinNClusterTPC(reco.fCutMinNClusterTPC),               fCutMinNClusterITS(reco.fCutMinNClusterITS), 
   fCutMaxChi2PerClusterTPC(reco.fCutMaxChi2PerClusterTPC),   fCutMaxChi2PerClusterITS(reco.fCutMaxChi2PerClusterITS),
@@ -192,6 +194,8 @@ AliEMCALRecoUtils & AliEMCALRecoUtils::operator = (const AliEMCALRecoUtils & rec
   fPIDUtils                  = reco.fPIDUtils;
 
   fAODFilterMask             = reco.fAODFilterMask;
+  fAODHybridTracks           = reco.fAODHybridTracks;
+  fAODTPCOnlyTracks          = reco.fAODTPCOnlyTracks;
   
   fCutEtaPhiSum              = reco.fCutEtaPhiSum;
   fCutEtaPhiSeparate         = reco.fCutEtaPhiSeparate;
@@ -202,7 +206,8 @@ AliEMCALRecoUtils & AliEMCALRecoUtils::operator = (const AliEMCALRecoUtils & rec
   fMass                      = reco.fMass;
   fStepSurface               = reco.fStepSurface;
   fStepCluster               = reco.fStepCluster;
-  fITSTrackSA                = reco.fITSTrackSA;  
+  fITSTrackSA                = reco.fITSTrackSA;
+  fEMCalSurfaceDistance      = reco.fEMCalSurfaceDistance;
   
   fTrackCutsType             = reco.fTrackCutsType;
   fCutMinTrackPt             = reco.fCutMinTrackPt;
@@ -995,7 +1000,9 @@ void AliEMCALRecoUtils::InitParameters()
   fExoticCellDiffTime     = 1e6;
   fExoticCellMinAmplitude = 0.5;
   
-  fAODFilterMask = 32;
+  fAODFilterMask    = 128;
+  fAODHybridTracks  = kFALSE;
+  fAODTPCOnlyTracks = kTRUE;
   
   fCutEtaPhiSum      = kTRUE;
   fCutEtaPhiSeparate = kFALSE;
@@ -1240,7 +1247,7 @@ void AliEMCALRecoUtils::RecalibrateCells(AliVCaloCells * cells,
   Double_t tcell  = 0;
   Double_t ecellin = 0;
   Double_t tcellin = 0;
-  Short_t  mclabel = -1;
+  Int_t  mclabel = -1;
   Double_t efrac = 0;
   
   Int_t nEMcell  = cells->GetNumberOfCells() ;  
@@ -1398,6 +1405,7 @@ void AliEMCALRecoUtils::RecalculateClusterPositionFromTowerIndex(const AliEMCALG
   Bool_t shared = kFALSE;
 
   Float_t clEnergy = clu->E(); //Energy already recalibrated previously.
+  
   if (clEnergy <= 0)
     return;
   GetMaxEnergyCell(geom, cells, clu, absId,  iSupModMax, ieta, iphi,shared);
@@ -1599,7 +1607,38 @@ void AliEMCALRecoUtils::RecalculateClusterShowerShapeParameters(const AliEMCALGe
   Double_t w       = 0.;
   Double_t etaMean = 0.;
   Double_t phiMean = 0.;
+  
+  //Loop on cells, calculate the cluster energy, in case a cut on cell energy is added
+  // and to check if the cluster is between 2 SM in eta
+  Int_t   iSM0   = -1;
+  Bool_t  shared = kFALSE;
+  Float_t energy = 0;
+  
+  for(Int_t iDigit=0; iDigit < cluster->GetNCells(); iDigit++)
+  {
+    //Get from the absid the supermodule, tower and eta/phi numbers
+    geom->GetCellIndex(cluster->GetCellAbsId(iDigit),iSupMod,iTower,iIphi,iIeta);
+    geom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
+    
+    //Check if there are cells of different SM
+    if     (iDigit == 0   ) iSM0 = iSupMod;
+    else if(iSupMod!= iSM0) shared = kTRUE;
+    
+    //Get the cell energy, if recalibration is on, apply factors
+    fraction  = cluster->GetCellAmplitudeFraction(iDigit);
+    if(fraction < 1e-4) fraction = 1.; // in case unfolding is off
+    
+    if(IsRecalibrationOn())
+    {
+      recalFactor = GetEMCALChannelRecalibrationFactor(iSupMod,ieta,iphi);
+    }
     
+    eCell  = cells->GetCellAmplitude(cluster->GetCellAbsId(iDigit))*fraction*recalFactor;
+    
+    energy += eCell;
+    
+  }//cell loop
+  
   //Loop on cells
   for(Int_t iDigit=0; iDigit < cluster->GetNCells(); iDigit++) 
   {
@@ -1621,6 +1660,10 @@ void AliEMCALRecoUtils::RecalculateClusterShowerShapeParameters(const AliEMCALGe
     
     eCell  = cells->GetCellAmplitude(cluster->GetCellAbsId(iDigit))*fraction*recalFactor;
     
+    // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
+    // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0
+    if(shared && iSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
+    
     if(cluster->E() > 0 && eCell > 0)
     {
       w  = GetCellWeight(eCell,cluster->E());
@@ -1669,6 +1712,10 @@ void AliEMCALRecoUtils::RecalculateClusterShowerShapeParameters(const AliEMCALGe
     }
     eCell  = cells->GetCellAmplitude(cluster->GetCellAbsId(iDigit))*fraction*recalFactor;
     
+    // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
+    // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0
+    if(shared && iSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
+    
     if(cluster->E() > 0 && eCell > 0)
     {
       w  = GetCellWeight(eCell,cluster->E());
@@ -1835,14 +1882,32 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
     {
       aodTrack = aodevent->GetTrack(itr);
       if(!aodTrack) continue;
-      if(!aodTrack->TestFilterMask(fAODFilterMask)) continue; //Select AOD tracks that fulfill GetStandardITSTPCTrackCuts2010()
+            
+      if(fAODTPCOnlyTracks) // Match with TPC only tracks, default from May 2013, before filter bit 32
+      {
+        //printf("Match with TPC only tracks, accept? %d, test bit 128 <%d> \n", aodTrack->IsTPCOnly(), aodTrack->TestFilterMask(128));
+        if(!aodTrack->IsTPCOnly()) continue ;
+      }
+      else if(fAODHybridTracks) // Match with hybrid tracks
+      {
+        //printf("Match with Hybrid tracks, accept? %d \n", aodTrack->IsHybridGlobalConstrainedGlobal());
+        if(!aodTrack->IsHybridGlobalConstrainedGlobal()) continue ;
+      }
+      else // Match with tracks on a mask
+      {
+        //printf("Match with tracks having filter bit mask %d, accept? %d \n",fAODFilterMask,aodTrack->TestFilterMask(fAODFilterMask));
+        if(!aodTrack->TestFilterMask(fAODFilterMask) ) continue; //Select AOD tracks
+      }
+      
       if(aodTrack->Pt()<fCutMinTrackPt) continue;
+
       Double_t phi = aodTrack->Phi()*TMath::RadToDeg();
       if(TMath::Abs(aodTrack->Eta())>0.8 || phi <= 20 || phi >= 240 ) continue;
       Double_t pos[3],mom[3];
       aodTrack->GetXYZ(pos);
       aodTrack->GetPxPyPz(mom);
       AliDebug(5,Form("aod track: i=%d | pos=(%5.4f,%5.4f,%5.4f) | mom=(%5.4f,%5.4f,%5.4f) | charge=%d\n",itr,pos[0],pos[1],pos[2],mom[0],mom[1],mom[2],aodTrack->Charge()));
+
       trackParam= new AliExternalTrackParam(pos,mom,cv,aodTrack->Charge());
     }
     
@@ -1862,8 +1927,8 @@ void AliEMCALRecoUtils::FindMatches(AliVEvent *event,
 
     //Extrapolate the track to EMCal surface
     AliExternalTrackParam emcalParam(*trackParam);
-    Float_t eta, phi;
-    if(!ExtrapolateTrackToEMCalSurface(&emcalParam, 430., fMass, fStepSurface, eta, phi)) 
+    Float_t eta, phi, pt;
+    if(!ExtrapolateTrackToEMCalSurface(&emcalParam, fEMCalSurfaceDistance, fMass, fStepSurface, eta, phi, pt)) 
       {
   if(aodevent && trackParam) delete trackParam;
   if(fITSTrackSA && trackParam) delete trackParam;
@@ -1941,9 +2006,9 @@ Int_t AliEMCALRecoUtils::FindMatchedClusterInEvent(const AliESDtrack *track,
     
   if(!trackParam) return index;
   AliExternalTrackParam emcalParam(*trackParam);
-  Float_t eta, phi;
+  Float_t eta, phi, pt;
 
-  if(!ExtrapolateTrackToEMCalSurface(&emcalParam, 430., fMass, fStepSurface, eta, phi))        {
+  if(!ExtrapolateTrackToEMCalSurface(&emcalParam, fEMCalSurfaceDistance, fMass, fStepSurface, eta, phi, pt))   {
        if(fITSTrackSA) delete trackParam;
        return index;
   }
@@ -2037,11 +2102,12 @@ Bool_t AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(AliExternalTrackParam *
                                                          const Double_t mass, 
                                                          const Double_t step, 
                                                          Float_t &eta, 
-                                                         Float_t &phi)
+                                                         Float_t &phi,
+                                                        Float_t &pt)
 {
   //Extrapolate track to EMCAL surface
   
-  eta = -999, phi = -999;
+  eta = -999, phi = -999, pt = -999;
   if(!trkParam) return kFALSE;
   if(!AliTrackerBase::PropagateTrackToBxByBz(trkParam, emcalR, mass, step, kTRUE, 0.8, -1)) return kFALSE;
   Double_t trkPos[3] = {0.,0.,0.};
@@ -2049,6 +2115,7 @@ Bool_t AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(AliExternalTrackParam *
   TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
   eta = trkPosVec.Eta();
   phi = trkPosVec.Phi();
+  pt = trkParam->Pt();
   if(phi<0)
     phi += 2*TMath::Pi();
 
@@ -2582,7 +2649,7 @@ void AliEMCALRecoUtils::Print(const Option_t *) const
 
   printf("Track cuts: \n");
   printf("Minimum track pT: %1.2f\n",fCutMinTrackPt);
-  printf("AOD track selection mask: %d\n",fAODFilterMask);
+  printf("AOD track selection: tpc only %d, or hybrid %d, or mask: %d\n",fAODTPCOnlyTracks,fAODHybridTracks, fAODFilterMask);
   printf("TPCRefit = %d, ITSRefit = %d\n",fCutRequireTPCRefit,fCutRequireITSRefit);
   printf("AcceptKinks = %d\n",fCutAcceptKinkDaughters);
   printf("MinNCulsterTPC = %d, MinNClusterITS = %d\n",fCutMinNClusterTPC,fCutMinNClusterITS);