]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FLOW/AliAnalysisTaskScalarProduct.cxx
new methods and possiility to run all methods in same run
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliAnalysisTaskScalarProduct.cxx
index c0c4add805941dbacabd41fdbea0b20ac553539f..7106fcfb366a6f46951890fe6f9e6798588b5856 100644 (file)
@@ -32,9 +32,12 @@ class AliAnalysisTask;
 #include "AliMCEventHandler.h"
 #include "AliMCEvent.h"
 
+#include "../../CORRFW/AliCFManager.h"
+
 #include "AliAnalysisTaskScalarProduct.h"
 #include "AliFlowEventSimpleMaker.h"
 #include "AliFlowAnalysisWithScalarProduct.h"
+#include "AliFlowCommonHist.h"
 
 // AliAnalysisTaskScalarProduct:
 //
@@ -45,14 +48,19 @@ class AliAnalysisTask;
 ClassImp(AliAnalysisTaskScalarProduct)
 
 //________________________________________________________________________
-AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name) : 
+AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name, Bool_t on) : 
   AliAnalysisTask(name, ""), 
   fESD(NULL),
   fAOD(NULL),
   fSP(NULL),
   fEventMaker(NULL),
   fAnalysisType("ESD"),
-  fListHistos(NULL)
+  fCFManager1(NULL),
+  fCFManager2(NULL),
+  fListHistos(NULL),
+  fQAInt(NULL),
+  fQADiff(NULL),
+  fQA(on)
 {
   // Constructor
   cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name)"<<endl;
@@ -62,7 +70,9 @@ AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct(const char *name) :
   DefineInput(0, TChain::Class());
   // Output slot #0 writes into a TList container
   DefineOutput(0, TList::Class());  
-
+  if(on) {
+    DefineOutput(1, TList::Class());
+    DefineOutput(2, TList::Class()); }  
 }
 
 //________________________________________________________________________
@@ -72,7 +82,12 @@ AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct() :
   fSP(NULL),
   fEventMaker(NULL),
   fAnalysisType("ESD"),
-  fListHistos(NULL)
+  fCFManager1(NULL),
+  fCFManager2(NULL),
+  fListHistos(NULL),
+  fQAInt(NULL),
+  fQADiff(NULL),
+  fQA(kFALSE)
 {
   // Constructor
   cout<<"AliAnalysisTaskScalarProduct::AliAnalysisTaskScalarProduct()"<<endl;
@@ -107,7 +122,6 @@ void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
   } else {
     // Disable all branches and enable only the needed ones
     if (fAnalysisType == "MC") {
-      cout<<"!!!!!reading MC kinematics only"<<endl;
       // we want to process only MC
       tree->SetBranchStatus("*", kFALSE);
 
@@ -119,8 +133,7 @@ void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
        fESD = esdH->GetEvent();
       }
     }
-    else if (fAnalysisType == "ESD") {
-      cout<<"!!!!!reading the ESD only"<<endl;
+    else if (fAnalysisType == "ESD" || fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1") {
       tree->SetBranchStatus("*", kFALSE);
       tree->SetBranchStatus("Tracks.*", kTRUE);
 
@@ -132,7 +145,6 @@ void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
        fESD = esdH->GetEvent();
     }
     else if (fAnalysisType == "AOD") {
-      cout<<"!!!!!reading the AOD only"<<endl;
       AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
 
       if (!aodH) {
@@ -143,7 +155,7 @@ void AliAnalysisTaskScalarProduct::ConnectInputData(Option_t *)
       }
     }
     else {
-      Printf("!!!!!Wrong analysis type: Only ESD, AOD and MC types are allowed!");
+      Printf("!!!!!Wrong analysis type: Only ESD, ESDMC0, ESDMC1, AOD and MC types are allowed!");
       exit(1);
       
     }
@@ -155,6 +167,12 @@ void AliAnalysisTaskScalarProduct::CreateOutputObjects()
 {
   // Called at every worker node to initialize
   cout<<"AliAnalysisTaskScalarProduct::CreateOutputObjects()"<<endl;
+
+  if (!(fAnalysisType == "AOD" || fAnalysisType == "ESD" || fAnalysisType == "ESDMC0"  || fAnalysisType == "ESDMC1" || fAnalysisType == "MC")) {
+    cout<<"WRONG ANALYSIS TYPE! only ESD, ESDMC0, ESDMC1, AOD and MC are allowed."<<endl;
+    exit(1);
+  }
+
   //event maker
   fEventMaker = new AliFlowEventSimpleMaker();
   //Analyser
@@ -163,9 +181,9 @@ void AliAnalysisTaskScalarProduct::CreateOutputObjects()
   
 
   if (fSP->GetHistList()) {
-    // fSP->GetHistList()->Print();
-    fListHistos = fSP->GetHistList();
-    // fListHistos->Print();
+    //fSP->GetHistList()->Print();
+       fListHistos = fSP->GetHistList();
+       fListHistos->Print();
   }
   else {Printf("ERROR: Could not retrieve histogram list"); }
 }
@@ -176,9 +194,7 @@ void AliAnalysisTaskScalarProduct::Exec(Option_t *)
   // Main loop
   // Called for each event
 
-  
-
-      
+        
   if (fAnalysisType == "MC") {
 
     // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
@@ -196,9 +212,12 @@ void AliAnalysisTaskScalarProduct::Exec(Option_t *)
       return;
     }
 
+    fCFManager1->SetEventInfo(mcEvent);
+    fCFManager2->SetEventInfo(mcEvent);
+
     // analysis 
     Printf("MC particles: %d", mcEvent->GetNumberOfTracks());
-    AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent);
+    AliFlowEventSimple* fEvent = fEventMaker->FillTracks(mcEvent,fCFManager1,fCFManager2);
     fSP->Make(fEvent);
 
     delete fEvent;
@@ -211,10 +230,44 @@ void AliAnalysisTaskScalarProduct::Exec(Option_t *)
     Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
     
     // analysis 
-    AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD);
+    AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fESD,fCFManager1,fCFManager2);
+    fSP->Make(fEvent);
+    delete fEvent;
+  }
+else if (fAnalysisType == "ESDMC0" || fAnalysisType == "ESDMC1" ) {
+    if (!fESD) {
+      Printf("ERROR: fESD not available");
+      return;
+    }
+    Printf("There are %d tracks in this event", fESD->GetNumberOfTracks());
+    
+    AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
+    if (!eventHandler) {
+      Printf("ERROR: Could not retrieve MC event handler");
+      return;
+    }
+
+    AliMCEvent* mcEvent = eventHandler->MCEvent();
+    if (!mcEvent) {
+      Printf("ERROR: Could not retrieve MC event");
+      return;
+    }
+
+    fCFManager1->SetEventInfo(mcEvent);
+    fCFManager2->SetEventInfo(mcEvent);
+
+    //lee yang zeros analysis 
+    AliFlowEventSimple* fEvent=NULL;
+    if (fAnalysisType == "ESDMC0") { 
+      fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 0); //0 = kine from ESD, 1 = kine from MC
+    } else if (fAnalysisType == "ESDMC1") {
+      fEvent = fEventMaker->FillTracks(fESD, mcEvent, fCFManager1, fCFManager2, 1); //0 = kine from ESD, 1 = kine from MC
+    }
     fSP->Make(fEvent);
     delete fEvent;
+    //delete mcEvent;
   }
+  
   else if (fAnalysisType == "AOD") {
     if (!fAOD) {
       Printf("ERROR: fAOD not available");
@@ -223,31 +276,31 @@ void AliAnalysisTaskScalarProduct::Exec(Option_t *)
     Printf("There are %d tracks in this event", fAOD->GetNumberOfTracks());
 
     // analysis 
+    //For the moment don't use CF //AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD,fCFManager1,fCFManager2);
     AliFlowEventSimple* fEvent = fEventMaker->FillTracks(fAOD);
     fSP->Make(fEvent);
     delete fEvent;
   }
 
-  //  fListHistos->Print();    
+  //fListHistos->Print();      
   PostData(0,fListHistos);
+  if (fQA) {
+    PostData(1,fQAInt);
+    PostData(2,fQADiff); }
 } 
 
 //________________________________________________________________________
 void AliAnalysisTaskScalarProduct::Terminate(Option_t *) 
 {
-  // Called once at the end of the query
+  // Called once at the end of the query -- do not call in case of CAF
   //  fSP->Finish();
   //  PostData(0,fListHistos);
+
   fListHistos = (TList*)GetOutputData(0);
   cout << "histgram list in Terminate" << endl;
-  if (fListHistos) 
-    {
-      fListHistos->Print();
-    }  
-  else
-    {
-      cout << "histgram list pointer is empty" << endl;
-    }
-  //  delete fSP;
-  //  delete fEventMaker;
+  if (fListHistos)  {
+    fListHistos->Print();
+  }    
+  else { cout << "histgram list pointer is empty" << endl; }
+
 }