]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FLOW/AliFlowTasks/AliAnalysisTaskFlowEvent.cxx
facilitates analysis of kine trees without esd
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowTasks / AliAnalysisTaskFlowEvent.cxx
index 4cc3d604cee396b63e1d6c0b4b7ebb901893d7af..981162f9759f801638c3ec4aef1ac503edc918c2 100644 (file)
@@ -86,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),   
@@ -111,6 +110,8 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
   fEtaMax(5.),      
   fQMin(0.),        
   fQMax(3.),
+  fHistWeightvsPhiMin(0.),
+  fHistWeightvsPhiMax(3.),
   fExcludedEtaMin(0.), 
   fExcludedEtaMax(0.), 
   fExcludedPhiMin(0.),
@@ -121,6 +122,8 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent() :
   fV2(0.),
   fV3(0.),
   fV4(0.),
+  fV5(0.),
+  fFlowEvent(NULL),
   fMyTRandom3(NULL)
 {
   // Constructor
@@ -138,15 +141,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),   
@@ -163,6 +165,8 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   fEtaMax(5.),      
   fQMin(0.),        
   fQMax(3.),
+  fHistWeightvsPhiMin(0.),
+  fHistWeightvsPhiMax(3.),
   fExcludedEtaMin(0.), 
   fExcludedEtaMax(0.), 
   fExcludedPhiMin(0.),
@@ -173,6 +177,8 @@ AliAnalysisTaskFlowEvent::AliAnalysisTaskFlowEvent(const char *name, TString RPt
   fV2(0.),
   fV3(0.),
   fV4(0.),
+  fV5(0.),
+  fFlowEvent(NULL),
   fMyTRandom3(NULL)
 {
   // Constructor
@@ -192,11 +198,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");
@@ -210,6 +212,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)
 
@@ -255,7 +262,22 @@ void AliAnalysisTaskFlowEvent::UserCreateOutputObjects()
   cc->SetEtaMax(fEtaMax);
   cc->SetQMin(fQMin);
   cc->SetQMax(fQMax);
+  cc->SetHistWeightvsPhiMax(fHistWeightvsPhiMax);
+  cc->SetHistWeightvsPhiMin(fHistWeightvsPhiMin);
 
+  fFlowEvent = new AliFlowEvent(3000);
+
+  if (fQAon)
+  {
+    fQAList=new TList();
+    fQAList->SetOwner();
+    fQAList->SetName(Form("%s QA",GetName()));
+    if (fCutsEvent->GetQA()) fQAList->Add(fCutsEvent->GetQA()); //0
+    if (fCutsRP->GetQA()) fQAList->Add(fCutsRP->GetQA());  //1
+    if (fCutsPOI->GetQA())fQAList->Add(fCutsPOI->GetQA()); //2
+    fQAList->Add(new TH1F("event plane angle","event plane angle;angle [rad];",100,0.,TMath::TwoPi())); //3
+    PostData(2,fQAList);
+  }
 }
 
 //________________________________________________________________________
@@ -263,27 +285,14 @@ 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
   AliMultiplicity* myTracklets = NULL;
   AliESDPmdTrack* pmdtracks = NULL;//pmd      
-  TH2F* histFMD = NULL;
 
   int availableINslot=1;
-  if(strcmp(fRPType,"FMD")==0) {
-    TList* FMDdata = dynamic_cast<TList*>(GetInputData(availableINslot++));
-    if(!FMDdata) {
-      cout<<" No FMDdata "<<endl;
-      exit(2);
-    }
-    histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
-    if (!histFMD) {
-      cout<< "No histFMD"<<endl;
-      exit(2);
-    }
-  }
 
   if (!(fCutsRP&&fCutsPOI&&fCutsEvent))
   {
@@ -291,25 +300,27 @@ 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
-    if (!fCutsEvent->IsSelected(InputEvent())) return;
+    if (InputEvent() && !fCutsEvent->IsSelected(InputEvent())) return;
 
     //first attach all possible information to the cuts
     fCutsRP->SetEvent( InputEvent(), MCEvent() );  //attach event
     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
-  if (fAnalysisType == "MC")
+  else if (fAnalysisType == "MC")
   {
     // Process MC truth, therefore we receive the AliAnalysisManager and ask it for the AliMCEventHandler
     // This handler can return the current MC event
@@ -335,7 +346,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
@@ -363,29 +374,39 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
 
     //make event
     if (fRPType == "Global") {
-      flowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
+      fFlowEvent = new AliFlowEvent(myESD,fCFManager1,fCFManager2);
     }
-    if (fRPType == "TPCOnly") {
-      flowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
+    else if (fRPType == "TPCOnly") {
+      fFlowEvent = new AliFlowEvent(myESD,fCFManager2,kFALSE);
     }
-    if (fRPType == "TPCHybrid") {
-      flowEvent = new AliFlowEvent(myESD,fCFManager2,kTRUE);
+    else if (fRPType == "TPCHybrid") {
+      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"){
-      flowEvent = new AliFlowEvent(myESD,histFMD,fCFManager2);
+      TList* FMDdata = dynamic_cast<TList*>(GetInputData(availableINslot++));
+      if(!FMDdata) {
+        cout<<" No FMDdata "<<endl;
+        return;
+      }
+      TH2F* histFMD = dynamic_cast<TH2F*>(FMDdata->FindObject("dNdetadphiHistogramTrVtx"));
+      if (!histFMD) {
+        cout<< "No histFMD"<<endl;
+        return;
+      }
+      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,16 +442,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 (!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")
@@ -441,7 +463,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
@@ -459,8 +481,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;
@@ -473,13 +495,15 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
           }
           //printf("\n");
         }
-        flowEvent->AddTrack(cand);
+        fFlowEvent->AddTrack(cand);
       }
     }
   }
 
+  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)
   {
@@ -487,7 +511,7 @@ void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
   }
 
   //define dead zone
-  flowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
+  fFlowEvent->DefineDeadZone(fExcludedEtaMin, fExcludedEtaMax, fExcludedPhiMin, fExcludedPhiMax );
 
 
   //////////////////////////////////////////////////////////////////////////////
@@ -495,25 +519,27 @@ 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->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)
+  //QA
+  if (fQAon)
   {
-    PostData(2,fQAInt);
-    PostData(3,fQADiff);
+    TH1* h1 = static_cast<TH1*>(fQAList->At(3));
+    h1->Fill(fFlowEvent->GetMCReactionPlaneAngle());
   }
+
+  //fListHistos->Print();
+  //fOutputFile->WriteObject(fFlowEvent,"myFlowEventSimple");
+  PostData(1,fFlowEvent);
 }
 
 //________________________________________________________________________