]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrBase/AliIsolationCut.cxx
Fix Coverity
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliIsolationCut.cxx
index a68c0db85dc17eafcd47b9c0b9a6b72abc189063..a46fb9c67c7cb0f0cb9dc45f13058a31ad145e06 100755 (executable)
-/**************************************************************************\r
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
- *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-/* $Id:  $ */\r
-\r
-//_________________________________________________________________________\r
-// Class containing methods for the isolation cut. \r
-// An AOD candidate (AliAODPWG4ParticleCorrelation type)\r
-// is passed. Look in a cone around the candidate and study\r
-// the hadronic activity inside to decide if the candidate is isolated\r
-//\r
-//\r
-//*-- Author: Gustavo Conesa (LNF-INFN) \r
-\r
-//-Yaxian Mao (add the possibility for different IC method with different pt range, 01/10/2010)\r
-//-Yaxian Mao (check the candidate particle is the leading particle or not at the same hemishere)\r
-\r
-//////////////////////////////////////////////////////////////////////////////\r
-  \r
-  \r
-// --- ROOT system --- \r
-//#include <Riostream.h>\r
-#include <TLorentzVector.h>\r
-#include <TObjArray.h>\r
-\r
-// --- AliRoot system --- \r
-#include "AliIsolationCut.h" \r
-#include "AliAODPWG4ParticleCorrelation.h"\r
-#include "AliAODTrack.h"\r
-#include "AliVCluster.h"\r
-#include "AliCaloTrackReader.h"\r
-#include "AliMixedEvent.h"\r
-\r
-ClassImp(AliIsolationCut)\r
-  \r
-//____________________________________________________________________________\r
-  AliIsolationCut::AliIsolationCut() : \r
-    TObject(),\r
-    fConeSize(0.),fPtThreshold(0.), fSumPtThreshold(0.), fPtFraction(0.), fICMethod(0),fPartInCone(0)\r
\r
-{\r
-  //default ctor\r
-  \r
-  //Initialize parameters\r
-  InitParameters();\r
-\r
-}\r
-\r
-//____________________________________________________________________________\r
-TString AliIsolationCut::GetICParametersList()\r
-{\r
-  //Put data member values in string to keep in output container\r
-  \r
-  TString parList ; //this will be list of parameters used for this analysis.\r
-  const Int_t buffersize = 255;\r
-  char onePar[buffersize] ;\r
-  \r
-  snprintf(onePar,buffersize,"--- AliIsolationCut ---\n") ;\r
-  parList+=onePar ;    \r
-  snprintf(onePar,buffersize,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;\r
-  parList+=onePar ;\r
-  snprintf(onePar,buffersize,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;\r
-  parList+=onePar ;\r
-  snprintf(onePar,buffersize,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;\r
-  parList+=onePar ;\r
-  snprintf(onePar,buffersize,"fICMethod=%d (isolation cut case) \n",fICMethod) ;\r
-  parList+=onePar ;\r
-  snprintf(onePar,buffersize,"fPartInCone=%d \n",fPartInCone) ;\r
-  parList+=onePar ;\r
-\r
-  return parList; \r
-}\r
-\r
-//____________________________________________________________________________\r
-void AliIsolationCut::InitParameters()\r
-{\r
-  //Initialize the parameters of the analysis.\r
-  \r
-  fConeSize       = 0.4 ; \r
-  fPtThreshold    = 1.  ; \r
-  fSumPtThreshold = 0.5 ; \r
-  fPtFraction     = 0.1 ; \r
-  fPartInCone     = kOnlyCharged;\r
-  fICMethod       = kSumPtFracIC; // 0 pt threshol method, 1 cone pt sum method\r
-  \r
-}\r
-\r
-//__________________________________________________________________\r
-void  AliIsolationCut::MakeIsolationCut(TObjArray * const plCTS,  TObjArray * const plNe, AliCaloTrackReader * const reader, \r
-                                       const Bool_t bFillAOD, AliAODPWG4ParticleCorrelation  *pCandidate, \r
-                                       const TString & aodArrayRefName,\r
-                                       Int_t & n, Int_t & nfrac, Float_t &coneptsum,  Bool_t  &isolated, Bool_t &leading) const\r
-{  \r
-  //Search in cone around a candidate particle if it is isolated \r
-  Float_t phiC  = pCandidate->Phi() ;\r
-  Float_t etaC  = pCandidate->Eta() ;\r
-  Float_t ptC   = pCandidate->Pt() ;\r
-  Float_t pt    = -100. ;\r
-  Float_t eta   = -100. ;\r
-  Float_t phi   = -100. ;\r
-  Float_t rad   = -100. ;\r
-  \r
-  n         = 0 ;\r
-  nfrac     = 0 ;\r
-  coneptsum = 0.; \r
-  isolated  = kFALSE;\r
-  leading = kTRUE;\r
-\r
-  //Initialize the array with refrences\r
-  TObjArray * refclusters = 0x0;\r
-  TObjArray * reftracks   = 0x0;\r
-  Int_t ntrackrefs   = 0;\r
-  Int_t nclusterrefs = 0;\r
-  //Check charged particles in cone.\r
-  if(plCTS && (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged)){\r
-    TVector3 p3;\r
-    for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){\r
-      AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; \r
-      //Do not count the candidate (pion, conversion photon) or the daughters of the candidate\r
-      if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1) \r
-        || track->GetID() == pCandidate->GetTrackLabel(2) || track->GetID() == pCandidate->GetTrackLabel(3) \r
-        ) continue ;\r
-      p3.SetXYZ(track->Px(),track->Py(),track->Pz());\r
-      pt   = p3.Pt();\r
-      eta  = p3.Eta();\r
-      phi  = p3.Phi() ;\r
-      if(phi<0) phi+=TMath::TwoPi();\r
-      \r
-      //only loop the particle at the same side of candidate\r
-      if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;\r
-      //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events\r
-      if(pt > ptC){\r
-        n         = -1;\r
-        nfrac     = -1;\r
-        coneptsum = -1;\r
-        isolated  = kFALSE;\r
-       leading = kFALSE;\r
-        if(bFillAOD && reftracks) {\r
-          reftracks->Clear(); \r
-          delete reftracks;\r
-        }\r
-        return ;\r
-      }\r
-      //Check if there is any particle inside cone with pt larger than  fPtThreshold\r
-      rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));\r
-      \r
-      if(rad < fConeSize){\r
-        if(bFillAOD) {\r
-          ntrackrefs++;\r
-          if(ntrackrefs == 1){\r
-            reftracks = new TObjArray(0);\r
-            //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));\r
-            TString tempo(aodArrayRefName)  ; \r
-            tempo += "Tracks" ; \r
-            reftracks->SetName(tempo);\r
-            reftracks->SetOwner(kFALSE);\r
-          }\r
-          reftracks->Add(track);\r
-        }\r
-        //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);\r
-        coneptsum+=pt;\r
-        if(pt > fPtThreshold )    n++;\r
-        if(pt > fPtFraction*ptC ) nfrac++;  \r
-      } // Inside cone\r
-    }// charged particle loop\r
-  }//Tracks\r
-  \r
-  //Check neutral particles in cone.  \r
-  if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){\r
-         \r
-    //Get vertex for photon momentum calculation\r
-    //Double_t vertex2[] = {0,0,0} ; //vertex second AOD input ;\r
-    //if(reader->GetDataType()!= AliCaloTrackReader::kMC) \r
-    //{\r
-      //if(reader->GetSecondInputAODTree()) reader->GetSecondInputAODVertex(vertex2);\r
-    //}\r
-    TLorentzVector mom ;\r
-    for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){\r
-      AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;\r
-      \r
-      //Get the index where the cluster comes, to retrieve the corresponding vertex\r
-      Int_t evtIndex = 0 ; \r
-      if (reader->GetMixedEvent()) {\r
-        evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; \r
-      }\r
-      \r
-      //Do not count the candidate (photon or pi0) or the daughters of the candidate\r
-      if(calo->GetID() == pCandidate->GetCaloLabel(0) || calo->GetID() == pCandidate->GetCaloLabel(1)) continue ;      //Skip matched clusters with tracks\r
-      \r
-      if(calo->GetNTracksMatched() > 0) continue ; \r
-      \r
-      //Input from second AOD?\r
-      //Int_t input = 0;\r
-      //      if     (pCandidate->GetDetector() == "EMCAL" && reader->GetAODEMCALNormalInputEntries() <= ipr) input = 1 ;\r
-      //      else if(pCandidate->GetDetector() == "PHOS"  && reader->GetAODPHOSNormalInputEntries()  <= ipr) input = 1;\r
-      \r
-      //Get Momentum vector, \r
-      //if     (input == 0) \r
-      calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;//Assume that come from vertex in straight line\r
-      //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line  \r
-      \r
-      pt   = mom.Pt();\r
-      eta  = mom.Eta();\r
-      phi  = mom.Phi() ;\r
-      if(phi<0) phi+=TMath::TwoPi();\r
-      //only loop the particle at the same side of candidate\r
-      \r
-      if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;\r
-      //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events\r
-      if(pt > ptC){\r
-        n         = -1;\r
-        nfrac     = -1;\r
-        coneptsum = -1;\r
-        isolated  = kFALSE;\r
-       leading = kFALSE;\r
-        if(bFillAOD){\r
-          if(reftracks){  \r
-            reftracks  ->Clear();\r
-            delete reftracks;\r
-          }\r
-          if(refclusters){\r
-            refclusters->Clear(); \r
-            delete refclusters;\r
-          }\r
-        }\r
-        return ;\r
-      }\r
-      \r
-      //Check if there is any particle inside cone with pt larger than  fPtThreshold\r
-      rad = TMath::Sqrt((eta-etaC)*(eta-etaC)+ (phi-phiC)*(phi-phiC));\r
-      if(rad < fConeSize){\r
-        if(bFillAOD) {\r
-          nclusterrefs++;\r
-          if(nclusterrefs==1){\r
-            refclusters = new TObjArray(0);\r
-            //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));\r
-            TString tempo(aodArrayRefName)  ; \r
-            tempo += "Clusters" ; \r
-            refclusters->SetName(tempo);\r
-            refclusters->SetOwner(kFALSE);\r
-          }\r
-          refclusters->Add(calo);\r
-        }\r
-        //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);\r
-        coneptsum+=pt;\r
-        if(pt > fPtThreshold )     n++;\r
-        //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly\r
-        if(fPtFraction*ptC<fPtThreshold) {\r
-            if(pt>fPtThreshold)    nfrac++ ;\r
-        }\r
-        else {\r
-            if(pt>fPtFraction*ptC) nfrac++; \r
-        }\r
-      }//in cone\r
-    }// neutral particle loop\r
-  }//neutrals\r
-\r
-  //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);\r
-  \r
-  //Add reference arrays to AOD when filling AODs only\r
-  if(bFillAOD) {\r
-    if(refclusters)    pCandidate->AddObjArray(refclusters);\r
-    if(reftracks)        pCandidate->AddObjArray(reftracks);\r
-  }\r
-  //Check isolation, depending on method.\r
-  if( fICMethod == kPtThresIC){\r
-    if(n==0) isolated = kTRUE ;\r
-  }\r
-  else if( fICMethod == kSumPtIC){\r
-    if(coneptsum < fSumPtThreshold)\r
-      isolated  =  kTRUE ;\r
-  }\r
-  else if( fICMethod == kPtFracIC){\r
-    if(nfrac==0) isolated = kTRUE ;\r
-  }\r
-  else if( fICMethod == kSumPtFracIC){\r
-    //when the fPtFraction*ptC < fSumPtThreshold then consider the later case\r
-    if(fPtFraction*ptC < fSumPtThreshold  && coneptsum < fSumPtThreshold) isolated  =  kTRUE ;\r
-    if(fPtFraction*ptC > fSumPtThreshold  && coneptsum < fPtFraction*ptC) isolated  =  kTRUE ;\r
-  }\r
-  \r
-}\r
-\r
-//__________________________________________________________________\r
-void AliIsolationCut::Print(const Option_t * opt) const\r
-{\r
-  \r
-  //Print some relevant parameters set for the analysis\r
-  if(! opt)\r
-    return;\r
-  \r
-  printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;\r
-  \r
-  printf("IC method          =     %d\n", fICMethod) ; \r
-  printf("Cone Size          =     %1.2f\n", fConeSize) ; \r
-  printf("pT threshold       =     %2.1f\n", fPtThreshold) ;\r
-  printf("pT fraction        =     %3.1f\n", fPtFraction) ;\r
-  printf("particle type in cone =  %d\n",fPartInCone);\r
-  printf("    \n") ;\r
-  \r
-} \r
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+/* $Id:  $ */
+
+//_________________________________________________________________________
+// Class containing methods for the isolation cut. 
+// An AOD candidate (AliAODPWG4ParticleCorrelation type)
+// is passed. Look in a cone around the candidate and study
+// the hadronic activity inside to decide if the candidate is isolated
+//
+//
+//*-- Author: Gustavo Conesa (LNF-INFN) 
+
+//-Yaxian Mao (add the possibility for different IC method with different pt range, 01/10/2010)
+//-Yaxian Mao (check the candidate particle is the leading particle or not at the same hemishere)
+
+//////////////////////////////////////////////////////////////////////////////
+  
+  
+// --- ROOT system --- 
+#include <TLorentzVector.h>
+#include <TObjArray.h>
+
+// --- AliRoot system --- 
+#include "AliIsolationCut.h" 
+#include "AliAODPWG4ParticleCorrelation.h"
+#include "AliAODTrack.h"
+#include "AliVCluster.h"
+#include "AliCaloTrackReader.h"
+#include "AliMixedEvent.h"
+#include "AliCaloPID.h"
+
+ClassImp(AliIsolationCut)
+  
+//____________________________________
+AliIsolationCut::AliIsolationCut() : 
+TObject(),
+fConeSize(0.),
+fPtThreshold(0.), 
+fSumPtThreshold(0.), 
+fPtFraction(0.), 
+fICMethod(0),
+fPartInCone(0)
+
+{
+  //default ctor
+  
+  //Initialize parameters
+  InitParameters();
+  
+}
+
+//____________________________________________
+TString AliIsolationCut::GetICParametersList()
+{
+  //Put data member values in string to keep in output container
+  
+  TString parList ; //this will be list of parameters used for this analysis.
+  const Int_t buffersize = 255;
+  char onePar[buffersize] ;
+  
+  snprintf(onePar,buffersize,"--- AliIsolationCut ---\n") ;
+  parList+=onePar ;    
+  snprintf(onePar,buffersize,"fConeSize: (isolation cone size) %1.2f\n",fConeSize) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"fPtThreshold =%1.2f (isolation pt threshold) \n",fPtThreshold) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"fPtFraction=%1.2f (isolation pt threshold fraction ) \n",fPtFraction) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"fICMethod=%d (isolation cut case) \n",fICMethod) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"fPartInCone=%d \n",fPartInCone) ;
+  parList+=onePar ;
+  
+  return parList; 
+}
+
+//____________________________________
+void AliIsolationCut::InitParameters()
+{
+  //Initialize the parameters of the analysis.
+  
+  fConeSize       = 0.4 ; 
+  fPtThreshold    = 1.  ; 
+  fSumPtThreshold = 0.5 ; 
+  fPtFraction     = 0.1 ; 
+  fPartInCone     = kOnlyCharged;
+  fICMethod       = kSumPtFracIC; // 0 pt threshol method, 1 cone pt sum method
+  
+}
+
+//________________________________________________________________________________
+void  AliIsolationCut::MakeIsolationCut(const TObjArray * plCTS, 
+                                        const TObjArray * plNe, 
+                                        const AliCaloTrackReader * reader, 
+                                        const AliCaloPID * pid, 
+                                        const Bool_t bFillAOD, 
+                                        AliAODPWG4ParticleCorrelation  *pCandidate, 
+                                        const TString & aodArrayRefName,
+                                        Int_t & n, 
+                                        Int_t & nfrac, 
+                                        Float_t &coneptsum,  
+                                        Bool_t  &isolated) const
+{  
+  //Search in cone around a candidate particle if it is isolated 
+  Float_t phiC  = pCandidate->Phi() ;
+  if(phiC<0) phiC+=TMath::TwoPi();
+  Float_t etaC  = pCandidate->Eta() ;
+  Float_t ptC   = pCandidate->Pt() ;
+  Float_t pt    = -100. ;
+  Float_t eta   = -100. ;
+  Float_t phi   = -100. ;
+  Float_t rad   = -100. ;
+  
+  n         = 0 ;
+  nfrac     = 0 ;
+  coneptsum = 0.; 
+  isolated  = kFALSE;
+  
+  //Initialize the array with refrences
+  TObjArray * refclusters = 0x0;
+  TObjArray * reftracks   = 0x0;
+  Int_t ntrackrefs   = 0;
+  Int_t nclusterrefs = 0;
+  
+  //Check charged particles in cone.
+  if(plCTS && (fPartInCone==kOnlyCharged || fPartInCone==kNeutralAndCharged)){
+    TVector3 p3;
+    for(Int_t ipr = 0;ipr < plCTS->GetEntries() ; ipr ++ ){
+      AliAODTrack* track = (AliAODTrack *)(plCTS->At(ipr)) ; 
+      //Do not count the candidate (pion, conversion photon) or the daughters of the candidate
+      if(track->GetID() == pCandidate->GetTrackLabel(0) || track->GetID() == pCandidate->GetTrackLabel(1) 
+         || track->GetID() == pCandidate->GetTrackLabel(2) || track->GetID() == pCandidate->GetTrackLabel(3) 
+         ) continue ;
+      p3.SetXYZ(track->Px(),track->Py(),track->Pz());
+      pt   = p3.Pt();
+      eta  = p3.Eta();
+      phi  = p3.Phi() ;
+      if(phi<0) phi+=TMath::TwoPi();
+      
+      //only loop the particle at the same side of candidate
+      if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
+      //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
+      if(pt > ptC){
+        n         = -1;
+        nfrac     = -1;
+        coneptsum = -1;
+        isolated  = kFALSE;
+        if(bFillAOD && reftracks) {
+          reftracks->Clear(); 
+          delete reftracks;
+        }
+        return ;
+      }
+      
+      //Check if there is any particle inside cone with pt larger than  fPtThreshold
+
+      rad = Radius(etaC, phiC, eta, phi);
+      
+      if(rad < fConeSize){
+        if(bFillAOD) {
+          ntrackrefs++;
+          if(ntrackrefs == 1){
+            reftracks = new TObjArray(0);
+            //reftracks->SetName(Form("Tracks%s",aodArrayRefName.Data()));
+            TString tempo(aodArrayRefName)  ; 
+            tempo += "Tracks" ; 
+            reftracks->SetName(tempo);
+            reftracks->SetOwner(kFALSE);
+          }
+          reftracks->Add(track);
+        }
+        //printf("charged in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
+        coneptsum+=pt;
+        if(pt > fPtThreshold )    n++;
+        if(pt > fPtFraction*ptC ) nfrac++;  
+      } // Inside cone
+    }// charged particle loop
+  }//Tracks
+  
+  //Check neutral particles in cone.  
+  if(plNe && (fPartInCone==kOnlyNeutral || fPartInCone==kNeutralAndCharged)){
+         
+    
+    TLorentzVector mom ;
+    for(Int_t ipr = 0;ipr < plNe->GetEntries() ; ipr ++ ){
+      AliVCluster * calo = (AliVCluster *)(plNe->At(ipr)) ;
+      
+      //Get the index where the cluster comes, to retrieve the corresponding vertex
+      Int_t evtIndex = 0 ; 
+      if (reader->GetMixedEvent()) {
+        evtIndex=reader->GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ; 
+      }
+      
+      //Do not count the candidate (photon or pi0) or the daughters of the candidate
+      if(calo->GetID() == pCandidate->GetCaloLabel(0) || 
+         calo->GetID() == pCandidate->GetCaloLabel(1)) continue ;      
+      
+      //Skip matched clusters with tracks
+      if( pid->IsTrackMatched(calo,reader->GetCaloUtils(),reader->GetInputEvent()) ) continue ;
+    
+      //Assume that come from vertex in straight line
+      calo->GetMomentum(mom,reader->GetVertex(evtIndex)) ;
+      
+      pt   = mom.Pt();
+      eta  = mom.Eta();
+      phi  = mom.Phi() ;
+      if(phi<0) phi+=TMath::TwoPi();
+      //only loop the particle at the same side of candidate
+      
+      //if at the same side has particle larger than candidate, then candidate can not be the leading, skip such events
+      if(TMath::Abs(phi-phiC)>TMath::PiOver2()) continue ;
+      
+      if(pt > ptC){
+        n         = -1;
+        nfrac     = -1;
+        coneptsum = -1;
+        isolated  = kFALSE;
+        if(bFillAOD){
+          if(reftracks){  
+            reftracks  ->Clear();
+            delete reftracks;
+          }
+          if(refclusters){
+            refclusters->Clear(); 
+            delete refclusters;
+          }
+        }
+        return ;
+      }
+      
+      //Check if there is any particle inside cone with pt larger than  fPtThreshold
+
+      rad = Radius(etaC, phiC, eta, phi);
+      
+      if(rad < fConeSize){
+        if(bFillAOD) {
+          nclusterrefs++;
+          if(nclusterrefs==1){
+            refclusters = new TObjArray(0);
+            //refclusters->SetName(Form("Clusters%s",aodArrayRefName.Data()));
+            TString tempo(aodArrayRefName)  ; 
+            tempo += "Clusters" ; 
+            refclusters->SetName(tempo);
+            refclusters->SetOwner(kFALSE);
+          }
+          refclusters->Add(calo);
+        }
+        //printf("neutral in isolation cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
+        coneptsum+=pt;
+        if(pt > fPtThreshold )     n++;
+        //if fPtFraction*ptC<fPtThreshold then consider the fPtThreshold directly
+        if(fPtFraction*ptC<fPtThreshold) {
+          if(pt>fPtThreshold)    nfrac++ ;
+        }
+        else {
+          if(pt>fPtFraction*ptC) nfrac++; 
+        }
+      }//in cone
+    }// neutral particle loop
+  }//neutrals
+  
+  //printf("Isolation Cut: in cone with: pT>pTthres %d, pT > pTfrac*pTcandidate %d \n",n,nfrac);
+  
+  //Add reference arrays to AOD when filling AODs only
+  if(bFillAOD) {
+    if(refclusters)    pCandidate->AddObjArray(refclusters);
+    if(reftracks)        pCandidate->AddObjArray(reftracks);
+  }
+  //Check isolation, depending on method.
+  if( fICMethod == kPtThresIC){
+    if(n==0) isolated = kTRUE ;
+  }
+  else if( fICMethod == kSumPtIC){
+    if(coneptsum < fSumPtThreshold)
+      isolated  =  kTRUE ;
+  }
+  else if( fICMethod == kPtFracIC){
+    if(nfrac==0) isolated = kTRUE ;
+  }
+  else if( fICMethod == kSumPtFracIC){
+    //when the fPtFraction*ptC < fSumPtThreshold then consider the later case
+    if(fPtFraction*ptC < fSumPtThreshold  && coneptsum < fSumPtThreshold) isolated  =  kTRUE ;
+    if(fPtFraction*ptC > fSumPtThreshold  && coneptsum < fPtFraction*ptC) isolated  =  kTRUE ;
+  }
+  
+}
+
+//_____________________________________________________
+void AliIsolationCut::Print(const Option_t * opt) const
+{
+  
+  //Print some relevant parameters set for the analysis
+  if(! opt)
+    return;
+  
+  printf("**** Print %s %s **** \n", GetName(), GetTitle() ) ;
+  
+  printf("IC method          =     %d\n",    fICMethod   ) ; 
+  printf("Cone Size          =     %1.2f\n", fConeSize   ) ; 
+  printf("pT threshold       =     %2.1f\n", fPtThreshold) ;
+  printf("pT fraction        =     %3.1f\n", fPtFraction ) ;
+  printf("particle type in cone =  %d\n",    fPartInCone ) ;
+  printf("    \n") ;
+  
+} 
+
+//___________________________________________________________________________
+Float_t AliIsolationCut::Radius(const Float_t etaC, const Float_t phiC, 
+                                const Float_t eta , const Float_t phi) const
+{
+  // Calculate the distance to trigger from any particle
+
+  Float_t dEta = etaC-eta;
+  Float_t dPhi = phiC-phi;
+  
+  if(TMath::Abs(dPhi) >= TMath::Pi()) 
+    dPhi = TMath::TwoPi()-TMath::Abs(dPhi);
+  
+  return TMath::Sqrt( dEta*dEta + dPhi*dPhi );
+  
+}
+
+
+