initialize track cuts only once in getrefmultiplicity
authorjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 17 Jan 2011 11:01:12 +0000 (11:01 +0000)
committerjgrosseo <jgrosseo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 17 Jan 2011 11:01:12 +0000 (11:01 +0000)
ANALYSIS/AliESDtrackCuts.cxx

index 1a55300..289d64b 100644 (file)
@@ -734,15 +734,16 @@ Int_t AliESDtrackCuts::GetReferenceMultiplicity(AliESDEvent* esd, Bool_t tpcOnly
     return -1;
   }
   
-  AliESDtrackCuts* esdTrackCuts = GetStandardTPCOnlyTrackCuts();
-  esdTrackCuts->SetEtaRange(-0.8, 0.8);
-  esdTrackCuts->SetPtRange(0.15);
+  static AliESDtrackCuts* esdTrackCuts = 0;
+  if (!esdTrackCuts)
+  {
+    esdTrackCuts = GetStandardTPCOnlyTrackCuts();
+    esdTrackCuts->SetEtaRange(-0.8, 0.8);
+    esdTrackCuts->SetPtRange(0.15);
+  }
   
   Int_t nTracks = esdTrackCuts->CountAcceptedTracks(esd);
   
-  delete esdTrackCuts;
-  esdTrackCuts = 0;
-  
   return nTracks;
 }