]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnAnalysisME.cxx
Update
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisME.cxx
index 1fce9872ab61d622db76f9fddafeb185d8299f9a..951b10a51af7ec0f0f764a05fb3712b1bbf4857b 100644 (file)
@@ -1,12 +1,18 @@
 //
 // Class AliRsnAnalysisME
 //
-// TODO
+//
+// Virtual Class derivated from AliRsnVAnalysisTaskME which will be base class
+// for all RSN SE tasks
 //
 // authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
 //          Martin Vala (martin.vala@cern.ch)
 //
 
+#include "AliESDEvent.h"
+#include "AliMCEvent.h"
+#include "AliAODEvent.h"
+#include "AliMultiEventInputHandler.h"
 #include "AliRsnAnalysisME.h"
 
 ClassImp(AliRsnAnalysisME)
@@ -14,110 +20,170 @@ ClassImp(AliRsnAnalysisME)
 //_____________________________________________________________________________
 AliRsnAnalysisME::AliRsnAnalysisME(const char *name) :
     AliRsnVAnalysisTaskME(name),
-    fRsnAnalysisManager()
+    fRsnAnalysisManager(),
+    fEvent(),
+    fEventMix(),
+    fOutList(0x0)
 {
 //
 // Default constructor
 //
-  AliDebug(AliLog::kDebug+2,"<-");
+  AliDebug(AliLog::kDebug+2, "<-");
+
+  DefineOutput(2, TList::Class());
   AliDebug(AliLog::kDebug+2,"->");
 }
 
 AliRsnAnalysisME::AliRsnAnalysisME(const AliRsnAnalysisME& copy) : AliRsnVAnalysisTaskME(copy),
-    fRsnAnalysisManager(copy.fRsnAnalysisManager)
+    fRsnAnalysisManager(copy.fRsnAnalysisManager),
+    fEvent(copy.fEvent),
+    fEventMix(copy.fEvent),
+    fOutList(0x0)
 {
-  AliDebug(AliLog::kDebug+2,"<-");
+  AliDebug(AliLog::kDebug+2, "<-");
   AliDebug(AliLog::kDebug+2,"->");
 }
 
 //_____________________________________________________________________________
 void AliRsnAnalysisME::RsnUserCreateOutputObjects()
 {
-  AliLog::SetClassDebugLevel(GetName(), fLogType);
-  AliDebug(AliLog::kDebug+2,"<-");
-//     AliRsnVAnalysisTaskME::UserCreateOutputObjects();
+//
+// 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 = new TList();
+  fOutList->SetOwner();
+
+  fRsnAnalysisManager.InitAllPairs(fOutList);
 
-//       fRsnEvent = new AliRsnEvent();
-//       fRsnEvent->SetName("rsnEvents");
-//       fRsnEvent->Init();
-//       AddAODBranch("AliRsnEvent", &fRsnEvent);
+  PostData(2, fOutList);
 
-//     fOutList = new TList();
+  AliDebug(AliLog::kDebug+2,"->");
+}
+
+void AliRsnAnalysisME::RsnUserExec(Option_t*)
+{
 //
-//     fOutList->Add(fTaskInfo.GenerateInfoList());
+// Rsn User Exec
+//
+
+  fTaskInfo.SetEventUsed(kFALSE);
+
+  AliDebug(AliLog::kDebug+2, "<-");
+  if (!CheckAndPrintEvents()) return;
 
-  fOutList->Add(fRsnAnalysisManager.InitAllPairMgrs());
-//     fRsnAnalysisManager.Print();
+  DoMixing(GetEvent(0));
+
+
+  // if cuts are passed or not cuts were defined,
+  // update the task info...
+  fTaskInfo.SetEventUsed(kTRUE);
+
+  PostData(2, fOutList);
 
   AliDebug(AliLog::kDebug+2,"->");
 }
 
-void AliRsnAnalysisME::RsnUserExec(Option_t* )
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::DoMixing(AliVEvent* ev)
 {
-  AliDebug(AliLog::kDebug+2,"<-");
+//
+// Do Mixing
+//
+
+  Int_t nEvents = fInputHandler->GetBufferSize();
+  fESDEvent = dynamic_cast<AliESDEvent*>(ev);
+  fAODEvent = dynamic_cast<AliAODEvent*>(ev);
+
   if (fESDEvent) {
-    AliDebug(AliLog::kDebug+1,Form("fESDEvent if %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()));
-  }
-  if (fAODEvent) {
-    AliDebug(AliLog::kDebug+1,Form("fAODEvent if %p",fAODEvent));
-    AliDebug(AliLog::kDebug,Form("AOD tracks %d",fAODEvent->GetNumberOfTracks()));
+    AliESDEvent **esdEvent = new AliESDEvent*[nEvents];
+    for (Int_t i = 0; i < nEvents; i++) {
+      esdEvent[i] = dynamic_cast<AliESDEvent*>(GetEvent(i));
+      if (!esdEvent[i]) {
+        AliWarning(Form("Null ESD event in index %d", i));
+        continue;
+      }
+      if (i > 0)
+        DoESDMixing(esdEvent[0], esdEvent[i]);
+    }
+  } else if (fAODEvent) {
+    AliAODEvent **aodEvent = new AliAODEvent*[nEvents];
+    for (Int_t i = 0; i < nEvents; i++) {
+      aodEvent[i] = dynamic_cast<AliAODEvent*>(GetEvent(i));
+      if (!aodEvent[i]) {
+        AliWarning(Form("Null AOD event in index %d", i));
+        continue;
+      }
+      if (i > 0)
+        DoAODMixing(aodEvent[0], aodEvent[i]);
+    }
   }
 
-  AliAODEvent* aod1 = (AliAODEvent*)GetEvent(0);
-  AliAODEvent* aod2 = (AliAODEvent*)GetEvent(1);
+}
+
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::DoAODMixing(AliAODEvent* aod1, AliAODEvent* aod2)
+{
+//
+// mixing of two aod events
+//
 
   // assign events
   fEvent.SetRef(aod1);
   fEventMix.SetRef(aod2);
   if (fEvent.GetMultiplicity() < 2) return;
   if (fEventMix.GetMultiplicity() < 2) return;
+  
+  AliRsnEvent::SetCurrentEvent1(&fEvent);
+  AliRsnEvent::SetCurrentEvent2(&fEventMix);
 
-  // sort tracks w.r. to PID
-  fPIDIndex.ResetAll(fEvent.GetMultiplicity());
-  fPIDIndex.SetPriorProbability(fPrior);
-  fPIDIndex.FillFromEvent(&fEvent, fESDCuts);
-  fPIDIndex.SetCorrectIndexSize();
-
-  fPIDIndexMix.ResetAll(fEventMix.GetMultiplicity());
-  fPIDIndexMix.SetPriorProbability(fPrior);
-  fPIDIndexMix.FillFromEvent(&fEventMix, fESDCuts);
-  fPIDIndexMix.SetCorrectIndexSize();
+  fRsnAnalysisManager.ProcessAllPairs();
+  PostData(2, fOutList);
 
-  fRsnAnalysisManager.ProcessAllPairMgrs(&fPIDIndex, &fEvent, &fPIDIndexMix, &fEventMix);
+  AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod1->GetNumberOfTracks()));
+  AliDebug(AliLog::kDebug, Form("AOD tracks %d", aod2->GetNumberOfTracks()));
 
-  AliDebug(AliLog::kDebug,Form("AOD tracks %d",aod1->GetNumberOfTracks()));
-  AliDebug(AliLog::kDebug,Form("AOD tracks %d",aod2->GetNumberOfTracks()));
-  AliDebug(AliLog::kDebug+2,"->");
 }
 
 
 //_____________________________________________________________________________
-void AliRsnAnalysisME::RsnTerminate(Option_t* )
+void AliRsnAnalysisME::DoESDMixing(AliESDEvent* esd1, AliESDEvent* esd2)
 {
-  AliDebug(AliLog::kDebug+2,"<-");
-  AliDebug(AliLog::kDebug+2,"->");
+//
+// mixing of two esd events
+//
+
+  AliWarning(Form("ESD mixing not supported yet !!! (%p,%p)", esd1, esd2));
+  return;
 }
 
-AliRsnAnalysisManager* AliRsnAnalysisME::GetAnalysisManager(TString name)
+
+
+//_____________________________________________________________________________
+void AliRsnAnalysisME::RsnTerminate(Option_t*)
 {
-  if (!name.IsNull()) {
-    SetAnalysisManagerName(name.Data());
-  }
-  return &fRsnAnalysisManager;
+//
+// Rsn Terminate
+//
+
+  AliDebug(AliLog::kDebug+2, "<-");
+  AliDebug(AliLog::kDebug+2,"->");
 }
 
 //_____________________________________________________________________________
 void AliRsnAnalysisME::SetPriorProbability(AliPID::EParticleType type, Double_t p)
 {
-  //
-  // Sets the prior probability for Realistic PID, for a
-  // given particle species.
-  //
+//
+// Sets the prior probability for Realistic PID, for a
+// given particle species.
+//
 
   if (type >= 0 && type < (Int_t)AliPID::kSPECIES) {
     fPrior[type] = p;
@@ -139,11 +205,16 @@ void AliRsnAnalysisME::DumpPriors()
 }
 
 //_____________________________________________________________________________
-void AliRsnAnalysisME::GetPriorProbability(Double_t *out)
+void AliRsnAnalysisME::GetPriorProbability(Double_t *out) const
 {
+//
+// Gets all prior probabilities to out
+//
 
   Int_t i;
-  for (i=0;i<AliPID::kSPECIES;i++) {
+  for (i = 0;i < AliPID::kSPECIES;i++) {
     out[i] = fPrior[i];
   }
 }
+
+