]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx
start of moving various methods into the flowevent
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowAnalysisWithMCEventPlane.cxx
index 6acbfe7b4279c02476c2d27437e5e2561f60d63b..c6051afb38fe47f885488d3648b53bc109266aed 100644 (file)
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  * 
 **************************************************************************/
+// AliFlowAnalysisWithMCEventPlane:
+// Description: Maker to analyze Flow from the generated MC reaction plane.
+//              This class is used to get the real value of the flow 
+//              to compare the other methods to when analysing simulated events
+// author: N. van der Kolk (kolk@nikhef.nl)
 
 #define AliFlowAnalysisWithMCEventPlane_cxx
  
-#include "Riostream.h"  //needed as include
-#include "TFile.h"      //needed as include
-#include "TProfile.h"   //needed as include
-#include "TProfile2D.h"   
-#include "TComplex.h"   //needed as include
+#include "Riostream.h"
+#include "TFile.h"
+#include "TProfile.h"
+#include "TProfile2D.h"
 #include "TList.h"
+#include "TH1F.h"
+#include "TMath.h"
+#include "TVector2.h"
 
-class TH1F;
-
-#include "AliFlowCommonConstants.h"    //needed as include
+#include "AliFlowCommonConstants.h"
 #include "AliFlowEventSimple.h"
 #include "AliFlowTrackSimple.h"
 #include "AliFlowCommonHist.h"
 #include "AliFlowCommonHistResults.h"
 #include "AliFlowAnalysisWithMCEventPlane.h"
+#include "AliFlowVector.h"
 
 class AliFlowVector;
 
-// AliFlowAnalysisWithMCEventPlane:
-// Description: Maker to analyze Flow from the generated MC reaction plane.
-//              This class is used to get the real value of the flow 
-//              to compare the other methods to when analysing simulated events
-// author: N. van der Kolk (kolk@nikhef.nl)
-
 ClassImp(AliFlowAnalysisWithMCEventPlane)
 
   //-----------------------------------------------------------------------
@@ -60,7 +60,7 @@ ClassImp(AliFlowAnalysisWithMCEventPlane)
    fHistProDiffFlowPtPOI(NULL),
    fHistProDiffFlowEtaPOI(NULL),
    fHistSpreadOfFlow(NULL),
-   fHarmonic(2)\r
+   fHarmonic(2)
 {
 
   // Constructor.
@@ -123,6 +123,12 @@ void AliFlowAnalysisWithMCEventPlane::Init() {
   //Define all histograms
   cout<<"---Analysis with the real MC Event Plane---"<<endl;
 
+  //save old value and prevent histograms from being added to directory
+  //to avoid name clashes in case multiple analaysis objects are used
+  //in an analysis
+  Bool_t oldHistAddStatus = TH1::AddDirectoryStatus();
+  TH1::AddDirectory(kFALSE);
   Int_t iNbinsPt = AliFlowCommonConstants::GetMaster()->GetNbinsPt();
   Double_t dPtMin = AliFlowCommonConstants::GetMaster()->GetPtMin();        
   Double_t dPtMax = AliFlowCommonConstants::GetMaster()->GetPtMax();
@@ -187,6 +193,7 @@ void AliFlowAnalysisWithMCEventPlane::Init() {
  
   fEventNumber = 0;  //set number of events to zero
         
+  TH1::AddDirectory(oldHistAddStatus);
 } 
  
 //-----------------------------------------------------------------------
@@ -332,7 +339,7 @@ void AliFlowAnalysisWithMCEventPlane::Finish() {
   Int_t iNbinsEta = AliFlowCommonConstants::GetMaster()->GetNbinsEta(); 
   
   // access harmonic:
-  if(fCommonHists && fCommonHists->GetHarmonic())\r
+  if(fCommonHists && fCommonHists->GetHarmonic())
   {
    fHarmonic = (Int_t)(fCommonHists->GetHarmonic())->GetBinContent(1); // to be improved (moved somewhere else?)
   } 
@@ -367,7 +374,8 @@ void AliFlowAnalysisWithMCEventPlane::Finish() {
        dErrVRP += dYieldPtRP*dYieldPtRP*dErrvPtRP*dErrvPtRP;
       }
   }
-  if (dSumRP != 0. ) {
+  
+  if (!(TMath::AreEqualAbs(dSumRP, 0.0, 1e-10)) ) {
     dVRP /= dSumRP;  //because pt distribution should be normalised
     dErrVRP /= (dSumRP*dSumRP);
     dErrVRP = TMath::Sqrt(dErrVRP); 
@@ -413,7 +421,8 @@ void AliFlowAnalysisWithMCEventPlane::Finish() {
       }
     }//end of for(Int_t b=0;b<iNbinsPt;b++)  
   } else { cout<<"fHistProFlow is NULL"<<endl; }
-  if (dSumPOI != 0. ) {
+
+  if (!(TMath::AreEqualAbs(dSumPOI, 0.0, 1e-10)) ) {
     dVPOI /= dSumPOI;  //because pt distribution should be normalised
     dErrVPOI /= (dSumPOI*dSumPOI);
     dErrVPOI = TMath::Sqrt(dErrVPOI);