]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnAnalysisSE.cxx
Major upgrade to the package, in order to speed-up the execution and remove some...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisSE.cxx
index c0979333f78268f050d1cd14a18af086f8a5a437..cce2d73c6ca85ab112706d2ec2bde5bc61f6d25e 100644 (file)
@@ -1,37 +1,55 @@
 //
-// Class AliRsnAnalysisME
+// Class AliRsnAnalysisSE
 //
-// TODO
+// Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class
+// for all RSN SE tasks
 //
-// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
-//          Martin Vala (martin.vala@cern.ch)
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
 //
 
+#include <Riostream.h>
+#include <TList.h>
+#include "AliESDEvent.h"
+#include "AliMCEvent.h"
+#include "AliAODEvent.h"
+
+#include "AliRsnCutSet.h"
+#include "AliRsnVATProcessInfo.h"
 #include "AliRsnAnalysisSE.h"
 
 ClassImp(AliRsnAnalysisSE)
 
 //_____________________________________________________________________________
-AliRsnAnalysisSE::AliRsnAnalysisSE(const char *name) :
-    AliRsnVAnalysisTaskSE(name),
-    fRsnAnalysisManager(),
-    fPIDIndex(0),
-    fEvent(),
-    fESDCuts(0)
+AliRsnAnalysisSE::AliRsnAnalysisSE(const char *name, Bool_t useKine) :
+  AliRsnVAnalysisTaskSE(name, useKine),
+  fRsnAnalysisManager(),
+  fEventCuts(0x0),
+  fOutList(0x0),
+  fZeroEventPercentWarning(50),
+  fUseZeroEventWarning(kTRUE)
 {
 //
-// Default constructor
+// Default constructor.
 //
-  AliDebug(AliLog::kDebug+2,"<-");
+
+  DefineOutput(2, TList::Class());
   AliDebug(AliLog::kDebug+2,"->");
 }
 
-AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) : AliRsnVAnalysisTaskSE(copy),
-    fRsnAnalysisManager(copy.fRsnAnalysisManager),
-    fPIDIndex(copy.fPIDIndex),
-    fEvent(copy.fEvent),
-    fESDCuts(copy.fESDCuts)
+//_____________________________________________________________________________
+AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) :
+  AliRsnVAnalysisTaskSE(copy),
+  fRsnAnalysisManager(copy.fRsnAnalysisManager),
+  fEventCuts(copy.fEventCuts),
+  fOutList(0x0),
+  fZeroEventPercentWarning(copy.fZeroEventPercentWarning),
+  fUseZeroEventWarning(copy.fUseZeroEventWarning)
 {
+//
+// Copy constructor.
+//
+
   AliDebug(AliLog::kDebug+2,"<-");
   AliDebug(AliLog::kDebug+2,"->");
 }
@@ -39,106 +57,104 @@ AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) : AliRsnVAnalys
 //_____________________________________________________________________________
 void AliRsnAnalysisSE::RsnUserCreateOutputObjects()
 {
+//
+// Creation of output objects.
+// These are created through the utility methods in the analysis manager,
+// which produces a list of histograms for each specified set of pairs.
+// Each of these lists is added to the main list of this task.
+//
+
   AliDebug(AliLog::kDebug+2,"<-");
 
-  fOutList->Add(fRsnAnalysisManager.InitAllPairMgrs());
+  fOutList = new TList;
+  fRsnAnalysisManager.InitAllPairs(fOutList);
+  
+  AliError("\n\n***LIST***\n\n");
+  fOutList->Print();
+
+  PostData(2, fOutList);
 
   AliDebug(AliLog::kDebug+2,"->");
 }
 
-void AliRsnAnalysisSE::RsnUserExec(Option_t* )
+//_____________________________________________________________________________
+void AliRsnAnalysisSE::RsnUserExec(Option_t*)
 {
+//
+// Execution of the analysis task.
+// Recovers the input event and processes it with all included pair objects.
+//
+
   AliDebug(AliLog::kDebug+2,"<-");
+  
+  fTaskInfo.SetEventUsed(kFALSE);
+
   if (fESDEvent) {
-    AliDebug(AliLog::kDebug+1,Form("fESDEvent if %p",fESDEvent));
-    AliDebug(AliLog::kDebug,Form("ESD tracks %d",fESDEvent->GetNumberOfTracks()));
+    AliDebug(AliLog::kDebug+1, Form("fESDEvent is %p", fESDEvent));
+    AliDebug(AliLog::kDebug, Form("ESD tracks %d", fESDEvent->GetNumberOfTracks()));
   }
   if (fMCEvent) {
-    AliDebug(AliLog::kDebug+1,Form("fMCEvent if %p",fMCEvent));
-    AliDebug(AliLog::kDebug,Form("MC tracks %d",fMCEvent->GetNumberOfTracks()));
+    AliDebug(AliLog::kDebug+1, Form("fMCEvent is %p", fMCEvent));
+    AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
   }
   if (fAODEventIn) {
-    AliDebug(AliLog::kDebug+1,Form("fAODEventIn if %p",fAODEventIn));
-    AliDebug(AliLog::kDebug,Form("AOD(in) tracks %d",fAODEventIn->GetNumberOfTracks()));
+    AliDebug(AliLog::kDebug+1, Form("fAODEventIn is %p", fAODEventIn));
+    AliDebug(AliLog::kDebug, Form("AOD(in) tracks %d", fAODEventIn->GetNumberOfTracks()));
   }
-
   if (fAODEventOut) {
-    AliDebug(AliLog::kDebug+1,Form("fAODEventOut if %p",fAODEventOut));
-    AliDebug(AliLog::kDebug,Form("AOD(out) tracks %d",fAODEventOut->GetNumberOfTracks()));
+    AliDebug(AliLog::kDebug+1, Form("fAODEventOut if %p", fAODEventOut));
+    AliDebug(AliLog::kDebug, Form("AOD(out) tracks %d", fAODEventOut->GetNumberOfTracks()));
   }
 
-  // assign event
-  if (fAODEventOut)
-    fEvent.SetRef(fAODEventOut);
-  else if (fESDEvent)
-    fEvent.SetRef(fESDEvent, fMCEvent);
-  else
+  // Removing empty events
+  if (fRsnEvent.GetMultiplicity()<=0) {
+    AliDebug(AliLog::kDebug, "Zero event!!! Skipping ...");
+    fTaskInfo.SetEventUsed(kFALSE);
+    if (fUseZeroEventWarning)
+    {
+      TH1I *hist = (TH1I*)fInfoList->FindObject(fTaskInfo.GetEventHistogramName());
+      if (!hist) return;
+      Double_t zeroEventPercent = 0.0;
+      if (hist->Integral() > 1) zeroEventPercent = (Double_t)hist->GetBinContent(1) / hist->Integral() * 100;
+      if ((zeroEventPercent>fZeroEventPercentWarning)&&(fEntry>100))
+        AliWarning(Form("%3.2f%% Events are with zero tracks (CurrentEvent=%d)!!!",zeroEventPercent,fEntry));
+    }
     return;
-  if (fEvent.GetMultiplicity()<2) return;
-
-  // sort tracks w.r. to PID
-  fPIDIndex.ResetAll(fEvent.GetMultiplicity());
-  fPIDIndex.SetPriorProbability(fPrior);
-  fPIDIndex.FillFromEvent(&fEvent, fESDCuts);
-  fPIDIndex.SetCorrectIndexSize();
+  }
 
-  fRsnAnalysisManager.ProcessAllPairMgrs(&fPIDIndex, &fEvent);
+  // if general event cuts are added to the task (recommended)
+  // they are checked here on the RSN event interface and,
+  // if the event does not pass them, it is skipped and ProcessInfo
+  // is updated accordingly
+  if (fEventCuts) {
+    if (!fEventCuts->IsSelected(&fRsnEvent)) {
+      fTaskInfo.SetEventUsed(kFALSE);
+      return;
+    }
+  }
 
-  AliDebug(AliLog::kDebug+2,"->");
-}
+  // if cuts are passed or not cuts were defined,
+  // update the task info...
+  fTaskInfo.SetEventUsed(kTRUE);
 
+  // the virtual class has already sorted tracks in the PID index
+  // so we need here just to call the execution of analysis
+  fRsnAnalysisManager.ProcessAllPairs(&fRsnEvent, &fRsnEvent);
+  PostData(2, fOutList);
 
-//_____________________________________________________________________________
-void AliRsnAnalysisSE::RsnTerminate(Option_t* )
-{
-  AliDebug(AliLog::kDebug+2,"<-");
   AliDebug(AliLog::kDebug+2,"->");
 }
 
-//_____________________________________________________________________________
-AliRsnAnalysisManager* AliRsnAnalysisSE::GetAnalysisManager(TString name)
-{
-  if (!name.IsNull()) {
-    SetAnalysisManagerName(name.Data());
-  }
-
-  return &fRsnAnalysisManager;
-}
-
-
-//_____________________________________________________________________________
-void AliRsnAnalysisSE::SetPriorProbability(AliPID::EParticleType type, Double_t p)
-{
-  //
-  // Sets the prior probability for Realistic PID, for a
-  // given particle species.
-  //
-
-  if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
-    fPrior[type] = p;
-  }
-
-}
 
 //_____________________________________________________________________________
-void AliRsnAnalysisSE::DumpPriors()
+void AliRsnAnalysisSE::RsnTerminate(Option_t*)
 {
-  //
-  // Print all prior probabilities
-  //
+//
+// Termination.
+// Could be added some monitor histograms here.
+//
 
-  Int_t i;
-  for (i = 0; i < AliPID::kSPECIES; i++) {
-    AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
-  }
+  AliDebug(AliLog::kDebug+2,"<-");
+  AliDebug(AliLog::kDebug+2,"->");
 }
 
-//_____________________________________________________________________________
-void AliRsnAnalysisSE::GetPriorProbability(Double_t *out)
-{
-
-  Int_t i;
-  for (i=0;i<AliPID::kSPECIES;i++) {
-    out[i] = fPrior[i];
-  }
-}