Writting to specified file implemented
authorskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 4 Jul 2004 12:28:04 +0000 (12:28 +0000)
committerskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 4 Jul 2004 12:28:04 +0000 (12:28 +0000)
HBTAN/AliHBTAnalysis.cxx
HBTAN/AliHBTAnalysis.h

index 0a0443d..3cdd3c8 100644 (file)
@@ -20,6 +20,9 @@
 //_________________________________________________________
 
 
+#include <TSystem.h>
+#include <TFile.h>
+
 #include "AliAOD.h"
 #include "AliAODParticle.h"
 #include "AliAODPairCut.h"
@@ -31,7 +34,6 @@
 #include "AliHBTFunction.h"
 #include "AliHBTMonitorFunction.h"
  
-#include <TSystem.h>
 
 ClassImp(AliHBTAnalysis)
 
@@ -62,6 +64,7 @@ AliHBTAnalysis::AliHBTAnalysis():
   fTrackBuffer(0x0),
   fProcessOption(kSimulatedAndReconstructed),
   fNoCorrfctns(kFALSE),
+  fOutputFileName(0x0),
   fkPass(&AliHBTAnalysis::PassPartAndTrack), //by default perform cut on both track and particle pair 
   fkPass1(&AliHBTAnalysis::PassPartAndTrack1), //used onluy by ProcessTracksAndParticles
   fkPass2(&AliHBTAnalysis::PassPartAndTrack2),
@@ -96,6 +99,7 @@ AliHBTAnalysis::AliHBTAnalysis(const AliHBTAnalysis& in):
   fTrackBuffer(0x0),
   fProcessOption(kSimulatedAndReconstructed),
   fNoCorrfctns(kFALSE),
+  fOutputFileName(0x0),
   fkPass(&AliHBTAnalysis::PassPartAndTrack), //by default perform cut on both track and particle pair 
   fkPass1(&AliHBTAnalysis::PassPartAndTrack1),
   fkPass2(&AliHBTAnalysis::PassPartAndTrack2),
@@ -134,6 +138,7 @@ AliHBTAnalysis::~AliHBTAnalysis()
    delete [] fParticleAndTrackMonitorFunctions;
 
    delete fPairCut; // always have an copy of an object - we create we dstroy
+   delete fOutputFileName;
  }
 
 /*************************************************************************************/ 
@@ -1258,6 +1263,11 @@ void AliHBTAnalysis::WriteFunctions()
 {
 //Calls Write for all defined functions in analysis
 //== writes all results
+  TFile* oututfile = 0x0;
+  if (fOutputFileName)
+   {
+     oututfile = TFile::Open(*fOutputFileName,"update");
+   }
   UInt_t ii;
   for(ii = 0;ii<fNParticleFunctions;ii++)
    {
@@ -1318,6 +1328,28 @@ void AliHBTAnalysis::WriteFunctions()
       }
      fParticleAndTrackMonitorFunctions[ii]->Write();
    }
+  delete oututfile; 
+}
+/*************************************************************************************/
+
+void AliHBTAnalysis::SetOutputFileName(const char* fname)
+{
+  //Sets fiele name where to dump results, 
+  //if not specified reults are written to gDirectory
+  if (fname == 0x0)
+   {
+     delete fOutputFileName;
+     fOutputFileName = 0x0;
+     return;
+   }
+  if ( strcmp(fname,"") == 0 ) 
+   {
+     delete fOutputFileName;
+     fOutputFileName = 0x0;
+     return;
+   }
+  if (fOutputFileName == 0x0) fOutputFileName = new TString(fname);
+  else *fOutputFileName = fname;
 }
 /*************************************************************************************/
 
index 175165b..8bca073 100644 (file)
@@ -72,7 +72,8 @@ class AliHBTAnalysis: public AliAnalysis
      void SetReader(AliReader* r){fReader = r;}
      
      void WriteFunctions();
-     
+     void SetOutputFileName(const char* fname);
+          
      void SetBufferSize(Int_t buffsize){fBufferSize=buffsize;}
      void SetOwner(Bool_t owner=kTRUE){fIsOwner=owner;}
      Bool_t IsOwner() const {return fIsOwner;}
@@ -156,6 +157,7 @@ class AliHBTAnalysis: public AliAnalysis
      
      EProcessOption  fProcessOption;//Option that says waht analysis to do (Rec, Sim or SimAndRec)
      Bool_t          fNoCorrfctns;//Internal flag indicating that no cfs are set by the user (only monitor ones)
+     TString*        fOutputFileName;//Fiele name where to dump results, if not specified reults are written to gDirectory
      
    private: