]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
added some QA to flow track cuts and event cuts, trackID fix, better redoFinish and...
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskFlowEvent.cxx
index b0cf95555ffe6fc2b57c3ce2729933f8f1dcf6ed..eb5d4d7a023c6b251361b1644de164b2f1d76078 100644 (file)
@@ -33,7 +33,6 @@
 #include "TH2F.h"
 #include "TRandom3.h"
 #include "TTimeStamp.h"
-#include "TF1.h"
 
 // ALICE Analysis Framework
 #include "AliAnalysisManager.h"
@@ -87,15 +86,14 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
   fCutsEvent(NULL),
   fCutsRP(NULL),
   fCutsPOI(NULL),
-  fQAInt(NULL),
-  fQADiff(NULL),
+  fQAList(NULL),
   fMinMult(0),
   fMaxMult(10000000),
   fMinA(-1.0),
   fMaxA(-0.01),
   fMinB(0.01),
   fMaxB(1.0),
-  fQA(kFALSE),
+  fQAon(kFALSE),
   fLoadCandidates(kFALSE),
   fNbinsMult(10000),
   fNbinsPt(100),   
@@ -122,7 +120,8 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
   fV2(0.),
   fV3(0.),
   fV4(0.),
-  fV2Function(0),
+  fV5(0.),
+  fFlowEvent(NULL),
   fMyTRandom3(NULL)
 {
   // Constructor
@@ -140,15 +139,14 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   fCutsEvent(NULL),
   fCutsRP(NULL),
   fCutsPOI(NULL),
-  fQAInt(NULL),
-  fQADiff(NULL),
+  fQAList(NULL),
   fMinMult(0),
   fMaxMult(10000000),
   fMinA(-1.0),
   fMaxA(-0.01),
   fMinB(0.01),
   fMaxB(1.0),
-  fQA(on),
+  fQAon(on),
   fLoadCandidates(bCandidates),
   fNbinsMult(10000),
   fNbinsPt(100),   
@@ -175,7 +173,8 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   fV2(0.),
   fV3(0.),
   fV4(0.),
-  fV2Function(0),
+  fV5(0.),
+  fFlowEvent(NULL),
   fMyTRandom3(NULL)
 {
   // Constructor
@@ -195,11 +194,7 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   // Define output slots here
   // Define here the flow event output
   DefineOutput(1, AliFlowEventSimple::Class());
-  if(on)
-  {
-    DefineOutput(2, TList::Class());
-    DefineOutput(3, TList::Class());
-  }
+  DefineOutput(2, TList::Class());
 
   // and for testing open an output file
   //  fOutputFile = new TFile("FlowEvents.root","RECREATE");
@@ -213,6 +208,11 @@ AliAnalysisTaskFlowEvent::~AliAnalysisTaskFlowEvent()
   // Destructor
   //
   delete fMyTRandom3;
+  delete fFlowEvent;
+  delete fCutsEvent;
+  delete fCutsRP;
+  delete fCutsPOI;
+  delete fQAList;
   // objects in the output list are deleted
   // by the TSelector dtor (I hope)
 
@@ -259,6 +259,17 @@ void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
   cc->SetQMin(fQMin);
   cc->SetQMax(fQMax);
 
+  fFlowEvent = new AliFlowEvent(3000);
+
+  if (fQAon)
+  {
+    fQAList=new TList();
+    fQAList->SetName(Form("%s QA",GetName()));
+    if (fCutsEvent->GetQA()) fQAList->Add(fCutsEvent->GetQA());
+    if (fCutsRP->GetQA()) fQAList->Add(fCutsRP->GetQA());
+    if (fCutsPOI->GetQA())fQAList->Add(fCutsPOI->GetQA());
+    PostData(2,fQAList);
+  }
 }
 
 //________________________________________________________________________
@@ -266,7 +277,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
 {
   // Main loop
   // Called for each event
-  AliFlowEvent* flowEvent = NULL;
+  //delete fFlowEvent;
   AliMCEvent*  mcEvent = MCEvent();                              // from TaskSE
   AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
   AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
@@ -281,7 +292,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
     return;
   }
 
-  //use the new and temporarily incomplete way of doing things
+  //DEFAULT - automatically takes care of everything
   if (fAnalysisType == "AUTOMATIC")
   {
     //check event cuts
@@ -292,10 +303,12 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
     fCutsPOI->SetEvent( InputEvent(), MCEvent() );
 
     //then make the event
-    flowEvent = new AliFlowEvent( fCutsRP, fCutsPOI );
+    fFlowEvent->Fill( fCutsRP, fCutsPOI );
+    //fFlowEvent = new AliFlowEvent( fCutsRP, fCutsPOI );
+
     if (myESD)
-      flowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent()));
-    if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
+      fFlowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent()));
+    if (mcEvent && mcEvent->GenEventHeader()) fFlowEvent->SetMCReactionPlaneAngle(mcEvent);
   }
 
   // Make the FlowEvent for MC input
@@ -325,7 +338,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
       AliWarning("Event does not pass multiplicity cuts"); return;
     }
     //make event
-    flowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
+    fFlowEvent = new AliFlowEvent(mcEvent,fCFManager1,fCFManager2);
   }
 
   // Make the FlowEvent for ESD input
@@ -353,16 +366,16 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
 
     //make event
     if (fRPType == "Global") {
-      flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
+      fFlowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
     }
     else if (fRPType == "TPCOnly") {
-      flowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
+      fFlowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
     }
     else if (fRPType == "TPCHybrid") {
-      flowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
+      fFlowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
     }
     else if (fRPType == "Tracklet"){
-      flowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
+      fFlowEvent = new AliFlowEvent(myESD,myTracklets,fCFManager2);
     }
     else if (fRPType == "FMD"){
       TList* FMDdata = dynamic_cast<TList*>(GetInputData(availableINslot++));
@@ -375,17 +388,17 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
         cout<< "No histFMD"<<endl;
         return;
       }
-      flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
+      fFlowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
     }
     else if (fRPType == "PMD"){
-      flowEvent = new AliFlowEvent(myESD,pmdtracks,fCFManager2);
+      fFlowEvent = new AliFlowEvent(myESD,pmdtracks,fCFManager2);
     }
     else return;
     
     // if monte carlo event get reaction plane from monte carlo (depends on generator)
-    if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
+    if (mcEvent && mcEvent->GenEventHeader()) fFlowEvent->SetMCReactionPlaneAngle(mcEvent);
     //set reference multiplicity, TODO: maybe move it to the constructor?
-    flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
+    fFlowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
   }
 
   // Make the FlowEvent for ESD input combined with MC info
@@ -421,17 +434,17 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
     //make event
     if (fAnalysisType == "ESDMCkineESD")
     {
-      flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
+      fFlowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kESDkine, fCFManager1, fCFManager2 );
     }
     else if (fAnalysisType == "ESDMCkineMC")
     {
-      flowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
+      fFlowEvent = new AliFlowEvent(myESD, mcEvent, AliFlowEvent::kMCkine, fCFManager1, fCFManager2 );
     }
-    if (!flowEvent) return;
+    if (!fFlowEvent) return;
     // if monte carlo event get reaction plane from monte carlo (depends on generator)
-    if (mcEvent && mcEvent->GenEventHeader()) flowEvent->SetMCReactionPlaneAngle(mcEvent);
+    if (mcEvent && mcEvent->GenEventHeader()) fFlowEvent->SetMCReactionPlaneAngle(mcEvent);
     //set reference multiplicity, TODO: maybe move it to the constructor?
-    flowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
+    fFlowEvent->SetReferenceMultiplicity(AliESDtrackCuts::GetReferenceMultiplicity(myESD,kTRUE));
   }
   // Make the FlowEventSimple for AOD input
   else if (fAnalysisType == "AOD")
@@ -442,7 +455,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
       return;
     }
     AliInfo(Form("AOD has %d tracks", myAOD->GetNumberOfTracks()));
-    flowEvent = new AliFlowEvent(myAOD);
+    fFlowEvent = new AliFlowEvent(myAOD);
   }
 
   //inject candidates
@@ -460,8 +473,8 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
         //printf(" Ⱶ Checking at candidate %d with %d daughters\n",iCand,cand->GetNDaughters());
         for(int iDau=0; iDau!=cand->GetNDaughters(); ++iDau) {
           //printf("    Ⱶ Daughter %d with fID %d", iDau, cand->GetIDDaughter(iDau) );
-          for(int iRPs=0; iRPs!=flowEvent->NumberOfTracks(); ++iRPs ) {
-            AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(flowEvent->GetTrack( iRPs ));
+          for(int iRPs=0; iRPs!=fFlowEvent->NumberOfTracks(); ++iRPs ) {
+            AliFlowTrack *iRP = dynamic_cast<AliFlowTrack*>(fFlowEvent->GetTrack( iRPs ));
             if (!iRP) continue;
             if( !iRP->InRPSelection() )
               continue;
@@ -474,15 +487,15 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
           }
           //printf("\n");
         }
-        flowEvent->AddTrack(cand);
+        fFlowEvent->AddTrack(cand);
       }
     }
   }
 
-  if (!flowEvent) return; //shuts up coverity
+  if (!fFlowEvent) return; //shuts up coverity
 
   //check final event cuts
-  Int_t mult = flowEvent->NumberOfTracks();
+  Int_t mult = fFlowEvent->NumberOfTracks();
   AliInfo(Form("FlowEvent has %i tracks",mult));
   if (mult<fMinMult || mult>fMaxMult)
   {
@@ -490,7 +503,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
   }
 
   //define dead zone
-  flowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
+  fFlowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
 
 
   //////////////////////////////////////////////////////////////////////////////
@@ -498,26 +511,20 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
   if (fAfterburnerOn)
   {
     //if reaction plane not set from elsewhere randomize it before adding flow
-    if (!flowEvent->IsSetMCReactionPlaneAngle())
-      flowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
+    if (!fFlowEvent->IsSetMCReactionPlaneAngle())
+      fFlowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
 
-    //flowEvent->AddFlow(fV1,fV2,fV3,fV4);     //add flow
-    flowEvent->AddV2(fV2Function);
-    flowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
+    fFlowEvent->AddFlow(fV1,fV2,fV3,fV4,fV5);     //add flow
+    fFlowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
   }
   //////////////////////////////////////////////////////////////////////////////
 
   //tag subEvents
-  flowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
+  fFlowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
 
   //fListHistos->Print();
-  //fOutputFile->WriteObject(flowEvent,"myFlowEventSimple");
-  PostData(1,flowEvent);
-  if (fQA)
-  {
-    PostData(2,fQAInt);
-    PostData(3,fQADiff);
-  }
+  //fOutputFile->WriteObject(fFlowEvent,"myFlowEventSimple");
+  PostData(1,fFlowEvent);
 }
 
 //________________________________________________________________________