]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New analysis task objects with the capability to do mixing
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 25 Jan 2011 13:12:11 +0000 (13:12 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 25 Jan 2011 13:12:11 +0000 (13:12 +0000)
PWG2/RESONANCES/AliRsnAnalysisTask.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnAnalysisTask.h [new file with mode: 0644]
PWG2/RESONANCES/AliRsnVAnalysisTask.cxx [new file with mode: 0644]
PWG2/RESONANCES/AliRsnVAnalysisTask.h [new file with mode: 0644]

diff --git a/PWG2/RESONANCES/AliRsnAnalysisTask.cxx b/PWG2/RESONANCES/AliRsnAnalysisTask.cxx
new file mode 100644 (file)
index 0000000..d694c2f
--- /dev/null
@@ -0,0 +1,185 @@
+//
+// Class AliRsnAnalysisTask
+//
+// Virtual Class derivated from AliRsnVAnalysisTask which will be base class
+// for all RSN SE tasks
+//
+// 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 "AliRsnAnalysisTask.h"
+
+ClassImp(AliRsnAnalysisTask)
+
+//_____________________________________________________________________________
+AliRsnAnalysisTask::AliRsnAnalysisTask(const char *name, Bool_t useKine) :
+  AliRsnVAnalysisTask(name, useKine),
+  fRsnAnalysisManager(),
+  fEventCuts("eventCuts", AliRsnCut::kEvent),
+  fOutList(0x0),
+  fZeroEventPercentWarning(100),
+  fUseZeroEventWarning(kTRUE)
+{
+//
+// Default constructor.
+// Defines another output slot for histograms/ntuples
+//
+
+  DefineOutput(2, TList::Class());
+}
+
+//_____________________________________________________________________________
+AliRsnAnalysisTask::AliRsnAnalysisTask(const AliRsnAnalysisTask& copy) :
+  AliRsnVAnalysisTask(copy),
+  fRsnAnalysisManager(copy.fRsnAnalysisManager),
+  fEventCuts(copy.fEventCuts),
+  fOutList(0x0),
+  fZeroEventPercentWarning(copy.fZeroEventPercentWarning),
+  fUseZeroEventWarning(copy.fUseZeroEventWarning)
+{
+//
+// Copy constructor.
+//
+}
+
+//_____________________________________________________________________________
+AliRsnAnalysisTask& AliRsnAnalysisTask::operator=(const AliRsnAnalysisTask& copy)
+{
+//
+// Assigment operator.
+//
+
+  AliRsnVAnalysisTask::operator=(copy);
+  
+  fRsnAnalysisManager = copy.fRsnAnalysisManager;
+  fEventCuts = copy.fEventCuts;
+  if (fOutList) fOutList->Clear();
+  fZeroEventPercentWarning = copy.fZeroEventPercentWarning;
+  fUseZeroEventWarning = copy.fUseZeroEventWarning;
+  
+  return (*this);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask::RsnUserCreateOutputObjects()
+{
+//
+// Creation of output objects.
+// These are created through the utility methods in the analysis manager,
+// which asks all the AliRsnPair objects to initialize their output which
+// is then linked to the TList data member of this, which will contain all the output.
+//
+
+  if (!fOutList) fOutList = new TList;
+  fOutList->Clear();
+  
+  fRsnAnalysisManager.InitAllPairs(fOutList);
+
+  PostData(2, fOutList);
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask::RsnUserExec(Option_t*)
+{
+//
+// Execution of the analysis task.
+// Recovers the input event and processes it with all included pair objects,
+// using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
+//
+       if (IsMixing()) return;
+  
+       if (fMCOnly) 
+    fRsnAnalysisManager.ProcessAllPairsMC();
+  else 
+    fRsnAnalysisManager.ProcessAllPairs();
+
+       PostData(2, fOutList);
+}
+
+void AliRsnAnalysisTask::RsnUserExecMix(Option_t* /*opt*/)
+{
+  if (!IsMixing()) return;
+  AliDebug(AliLog::kDebug,Form("RSN Mixing %lld %d [%lld,%lld] %d",fMixedEH->CurrentEntry(),fMixedEH->NumberMixed(),fMixedEH->CurrentEntryMain(),fMixedEH->CurrentEntryMix(),fMixedEH->CurrentBinIndex()));
+  
+  // the virtual class has already sorted tracks in the PID index
+  // so we need here just to call the execution of analysis
+  if (!fMCOnly) 
+               fRsnAnalysisManager.ProcessAllPairs();
+  else 
+               fRsnAnalysisManager.ProcessAllPairsMC();
+}
+
+//_____________________________________________________________________________
+void AliRsnAnalysisTask::RsnTerminate(Option_t*)
+{
+//
+// Termination.
+// Could be added some monitor histograms here.
+//
+}
+
+//______________________________________________________________________________
+Bool_t AliRsnAnalysisTask::EventProcess()
+{
+//
+// Customized event pre-processing.
+// First checks if the current event passes all cuts,
+// and if it does, updates the informations and then
+// call the operations which are already defined in the
+// omonyme function in mother class
+//
+
+  // initially, an event is expected to be bad
+  fTaskInfo.SetEventUsed(kFALSE);
+  
+  // check #1: number of tracks in event (reject empty events)
+  Int_t    ntracks = fRsnEvent[0].GetMultiplicity();
+  Double_t zeroEventPercent = 0.0;
+  if (ntracks < 1) 
+  {
+    // if using the checker for amount of empty events, update it
+    if (fUseZeroEventWarning)
+    {
+      TH1I *hist = (TH1I*)fInfoList->FindObject(fTaskInfo.GetEventHistogramName());
+      if (hist)
+      {
+        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));
+      }
+    }
+    
+    // empty events are rejected by default
+    fTaskInfo.SetEventUsed(kFALSE);
+    AliDebug(AliLog::kDebug, "Empty event. Skipping...");
+    return kFALSE;
+  }
+
+  // check the event cuts and update the info data accordingly
+  // events not passing the cuts must be rejected
+  if (!fEventCuts.IsSelected(&fRsnEvent[0]))
+  {
+    fTaskInfo.SetEventUsed(kFALSE);
+    return kFALSE;
+  }
+  
+  // if we reach this point, cuts were passed;
+  // then additional operations can be done
+  
+  // find leading particle (without any PID/momentum restriction)
+  fRsnEvent[0].SelectLeadingParticle(0);
+  
+  // final return value is positive
+  // but call the mother class method which updates info object
+  fTaskInfo.SetEventUsed(kTRUE);
+  return AliRsnVAnalysisTask::EventProcess();
+}
diff --git a/PWG2/RESONANCES/AliRsnAnalysisTask.h b/PWG2/RESONANCES/AliRsnAnalysisTask.h
new file mode 100644 (file)
index 0000000..21bfb3c
--- /dev/null
@@ -0,0 +1,56 @@
+//
+// Class AliRsnAnalysisTask
+//
+// Virtual Class derivated from AliRsnVAnalysisTask which will be base class
+// for all RSN SE tasks
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+#ifndef ALIRSNANALYSISTASK_H
+#define ALIRSNANALYSISTASK_H
+
+#include "AliPID.h"
+#include "AliRsnVAnalysisTask.h"
+#include "AliRsnAnalysisManager.h"
+#include "AliRsnEvent.h"
+#include "AliRsnCutSet.h"
+
+class AliRsnPIDDefESD;
+
+class AliRsnAnalysisTask : public AliRsnVAnalysisTask
+{
+  public:
+  
+    AliRsnAnalysisTask(const char *name = "AliRsnAnalysisTask", Bool_t useKine = kFALSE);
+    AliRsnAnalysisTask(const AliRsnAnalysisTask& copy);
+    AliRsnAnalysisTask& operator=(const AliRsnAnalysisTask& copy);
+    virtual ~AliRsnAnalysisTask() {}
+
+    virtual void            RsnUserCreateOutputObjects();
+    virtual void            RsnUserExec(Option_t*);
+    virtual void            RsnUserExecMix(Option_t* );
+    virtual void            RsnTerminate(Option_t*);
+    virtual Bool_t          EventProcess();
+
+    AliRsnCutSet*           GetEventCuts()                           {return &fEventCuts;}
+    AliRsnAnalysisManager*  GetAnalysisManager()                     {return &fRsnAnalysisManager;}
+    void                    SetAnalysisManagerName(const char *name) {fRsnAnalysisManager.SetName(name);}
+
+    Double_t                GetZeroEventPercentWarning() const            {return fZeroEventPercentWarning;}
+    void                    SetZeroEventPercentWarning(Double_t val = 50) {fZeroEventPercentWarning = val;}
+    void                    UseZeroEventWarning(Bool_t b = kTRUE)         {fUseZeroEventWarning = b;}
+
+  private:
+
+    AliRsnAnalysisManager   fRsnAnalysisManager;      // analysis main engine
+    AliRsnCutSet            fEventCuts;               // event cuts
+    TList                  *fOutList;                 // list of output events
+
+    Double_t                fZeroEventPercentWarning; // Percent Number for Zero Event Warning
+    Bool_t                  fUseZeroEventWarning;     // flag if Zero Event Warning is used (default is true)
+
+    ClassDef(AliRsnAnalysisTask, 1)
+};
+
+#endif
diff --git a/PWG2/RESONANCES/AliRsnVAnalysisTask.cxx b/PWG2/RESONANCES/AliRsnVAnalysisTask.cxx
new file mode 100644 (file)
index 0000000..93a391c
--- /dev/null
@@ -0,0 +1,439 @@
+//
+// Class AliRsnVAnalysisTask
+//
+// Virtual Class derivated from AliAnalysisTaskSE which will be base class
+// for all RSN SE tasks
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#include <Riostream.h>
+
+#include "AliESDEvent.h"
+#include "AliMCEvent.h"
+#include "AliAODEvent.h"
+#include "AliAnalysisManager.h"
+#include "AliMCEventHandler.h"
+#include "AliMultiInputEventHandler.h"
+#include "AliMixInputEventHandler.h"
+
+
+#include "AliRsnEvent.h"
+#include "AliRsnTarget.h"
+
+#include "AliRsnVAnalysisTask.h"
+
+ClassImp(AliRsnVAnalysisTask)
+
+//_____________________________________________________________________________
+AliRsnVAnalysisTask::AliRsnVAnalysisTask
+(const char *name, Bool_t mcOnly) :
+  AliAnalysisTaskSE(name),
+  fLogType(AliLog::kInfo),
+  fLogClassesString(""),
+  fIsMixing(kFALSE),
+  fMCOnly(mcOnly),
+  fInfoList(0x0),
+  fTaskInfo(name),
+  fMixedEH(0)
+{
+//
+// Default constructor.
+// Define the output slot for histograms.
+//
+
+  DefineOutput(1, TList::Class());
+  DefineOutput(2, TList::Class());
+       for(Int_t i=0;i<2;i++) {
+    fESDEvent[i] = 0;
+    fMCEvent[i]=0;
+    fAODEventIn[i]=0;
+    fAODEventOut[i]=0;
+  }
+}
+
+//_____________________________________________________________________________
+AliRsnVAnalysisTask::AliRsnVAnalysisTask(const AliRsnVAnalysisTask& copy) :
+  AliAnalysisTaskSE(copy),
+  fLogType(copy.fLogType),
+  fLogClassesString(copy.fLogClassesString),
+  fIsMixing(copy.fIsMixing),
+  fMCOnly(copy.fMCOnly),
+  fInfoList(0x0),
+  fTaskInfo(copy.fTaskInfo),
+  fMixedEH(copy.fMixedEH)
+{
+//
+// Copy constructor.
+// Defined for coding conventions compliance but never used.
+//
+  AliDebug(AliLog::kDebug+2, "<-");
+  for(Int_t i=0;i<2;i++) {
+    fESDEvent[i] = copy.fESDEvent[i];
+    fMCEvent[i]=copy.fMCEvent[i];
+    fAODEventIn[i]=copy.fAODEventIn[i];
+    fAODEventOut[i]=copy.fAODEventOut[i];
+               fRsnEvent[i]=copy.fRsnEvent[i];
+  }
+  AliDebug(AliLog::kDebug+2, "->");
+
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::LocalInit()
+{
+//
+// Local initialization.
+// Defines the debug message level and calls the mother class LocalInit().
+//
+
+  AliAnalysisTaskSE::LocalInit();
+  SetDebugForAllClasses();
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnVAnalysisTask::UserNotify()
+{
+//
+// Calls the mother class Notify()
+//
+
+  return AliAnalysisTaskSE::UserNotify();
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::ConnectInputData(Option_t *opt)
+{
+//
+// Connect input data, which consist in initializing properly
+// the pointer to the input event, which is dynamically casted
+// to all available types, and this allows to know its type.
+// Calls also the mother class omonyme method.
+// 
+
+  AliAnalysisTaskSE::ConnectInputData(opt);
+
+  // get AliESDEvent and, if successful
+  // retrieve the corresponding MC if exists
+  fESDEvent[0] = dynamic_cast<AliESDEvent *>(fInputEvent);
+  if (fESDEvent[0])
+  {
+    fMCEvent[0] = (AliMCEvent*) MCEvent();
+    AliInfo(Form("Input event is of type ESD   (%p)", fESDEvent[0]));
+    if (fMCEvent[0]) AliInfo(Form("Input has an associated MC (%p)", fMCEvent[0]));
+  }
+
+  // get AliAODEvent from input and, if successful
+  // it will contain both the reconstructed and MC informations
+  fAODEventIn[0] = dynamic_cast<AliAODEvent *>(fInputEvent);
+  if (fAODEventIn[0])
+  {
+    AliInfo(Form("Input event if of type native AOD (%p)", fAODEventIn[0]));
+  }
+
+  // get AliAODEvent from output of previous task
+  fAODEventOut[0] = dynamic_cast<AliAODEvent *>(AODEvent());
+  if (fAODEventOut[0])
+  {
+    AliInfo(Form("Input event if of type produced AOD from previous step (%p)",fAODEventOut[0]));
+  }
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::UserCreateOutputObjects()
+{
+//
+// Creates and links to task all output objects.
+// Does explicitly the initialization for the event info class,
+// and then calls the customized function which must be overloaded
+// in the applications of this base class.
+//
+
+  SetDebugForAllClasses();
+
+  // set event info outputs
+  fInfoList = new TList();
+  fInfoList->SetOwner();
+  fTaskInfo.GenerateInfoList(fInfoList);
+  
+  // create customized outputs
+  RsnUserCreateOutputObjects();
+
+  PostData(1, fInfoList);
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::UserExec(Option_t* opt)
+{
+//
+// Prepares for execution, setting the correct pointers of the
+// RSN package event interface, which will point to the not NULL
+// objects obtained from dynamic-casts called in ConnectInputData().
+//
+  if (!IsMixing()) {
+               if (fMCOnly && fMCEvent)
+               {
+                       fRsnEvent[0].SetRef  (fMCEvent[0]);
+      fRsnEvent[0].SetRefMC(fMCEvent[0]);
+               }
+               else if (fESDEvent[0])
+               {
+                       fRsnEvent[0].SetRef  (fESDEvent[0]);
+      fRsnEvent[0].SetRefMC(fMCEvent[0]);
+               }
+               else if (fAODEventOut)
+               {
+      fRsnEvent[0].SetRef  (fAODEventOut[0]);
+      fRsnEvent[0].SetRefMC(fAODEventOut[0]);
+               }
+               else if (fAODEventIn)
+               {
+      fRsnEvent[0].SetRef  (fAODEventIn[0]);
+      fRsnEvent[0].SetRefMC(fAODEventIn[0]);
+               }
+               else 
+               {
+                       AliError("Unknown input event format. Skipping");
+                       return;
+               }
+
+               // since this class is for single-event analysis
+               // both static pointers of AliRsnEvent class 
+               // will point to the same unique datamember
+               AliRsnEvent::SetCurrentEvent1(&fRsnEvent[0], fEntry);
+               AliRsnEvent::SetCurrentEvent2(&fRsnEvent[0], fEntry);
+               AliRsnTarget::SwitchToFirst();
+               
+               // call event preprocessing...
+               Bool_t preCheck = EventProcess();
+               // ...then fill the information object and print informations...
+               fTaskInfo.FillInfo();
+               fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed());
+               // ...and return if event did not pass selections
+               if (!preCheck)
+               {
+                       AliDebug(AliLog::kDebug, "Event preprocessing has failed. Skipping event");
+                       return;
+               }
+               
+               
+               // call customized implementation for execution
+               RsnUserExec(opt);
+       }
+  // post outputs for the info object
+  // (eventually others are done in the derived classes)
+  PostData(1, fInfoList);
+}
+
+void AliRsnVAnalysisTask::UserExecMix(Option_t* option)
+{
+    AliDebug(AliLog::kDebug+2,"<-");
+    
+    
+    if (!IsMixing()) return;
+    
+    SetupMixingEvents();
+    
+    if (!fMixedEH) return;
+    
+    if (fMCOnly && fMCEvent[0])
+    {
+      fRsnEvent[0].SetRef  (fMCEvent[0]);
+      fRsnEvent[0].SetRefMC(fMCEvent[0]);
+      fRsnEvent[1].SetRef  (fMCEvent[1]);
+      fRsnEvent[1].SetRefMC(fMCEvent[1]);
+    }
+    else if (fESDEvent[0])
+    {
+      fRsnEvent[0].SetRef  (fESDEvent[0]);
+      fRsnEvent[0].SetRefMC(fMCEvent[0]);
+      fRsnEvent[1].SetRef  (fESDEvent[1]);
+      fRsnEvent[1].SetRefMC(fMCEvent[1]);
+    }
+    else if (fAODEventOut)
+    {
+      fRsnEvent[0].SetRef  (fAODEventOut[0]);
+      fRsnEvent[0].SetRefMC(fAODEventOut[0]);
+      fRsnEvent[1].SetRef  (fAODEventOut[1]);
+      fRsnEvent[1].SetRefMC(fAODEventOut[1]);
+    }
+    else if (fAODEventIn)
+    {
+      fRsnEvent[0].SetRef  (fAODEventIn[0]);
+      fRsnEvent[0].SetRefMC(fAODEventIn[0]);
+      fRsnEvent[1].SetRef  (fAODEventIn[1]);
+      fRsnEvent[1].SetRefMC(fAODEventIn[1]);
+    }
+    else {
+      AliError("NO ESD or AOD object!!! Skipping ...");
+      return;
+    }
+    // since this class is for single-event analysis
+    // both static pointers of AliRsnEvent class 
+    // will point to the same unique datamember
+
+    
+    AliRsnEvent::SetCurrentEvent1(&fRsnEvent[0], fMixedEH->CurrentEntryMain());
+    AliRsnEvent::SetCurrentEvent2(&fRsnEvent[1], fMixedEH->CurrentEntryMix());
+    AliRsnTarget::SwitchToFirst();
+
+    // call event preprocessing...
+    Bool_t preCheck = EventProcess();
+    // ...then fill the information object and print informations...
+    fTaskInfo.FillInfo();
+    fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed());
+    // ...and return if event did not pass selections
+    if (!preCheck)
+    {
+      AliDebug(AliLog::kDebug, "Event preprocessing has failed. Skipping event");
+      return;
+    }
+    
+    RsnUserExecMix(option);
+    AliDebug(AliLog::kDebug+2,"->");
+}
+
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::Terminate(Option_t* opt)
+{
+//
+// Termination routines.
+// Stores all histograms (after checking they exist)
+// and includes to the TList all task informations.
+//
+
+  AliAnalysisTask::Terminate();
+
+  TList* list  = dynamic_cast<TList*>(GetOutputData(1));
+  if (!list) 
+  {
+    AliError(Form("At end of analysis, fOutList is %p", list));
+    return;
+  }
+
+  RsnTerminate(opt);
+
+  TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName());
+  if (!hEventInfo) 
+  {
+    AliError(Form("hEventInfo is %p", hEventInfo));
+    return;
+  }
+  AliInfo(Form("=== %s ==================",GetName()));
+  AliInfo(Form("Number Of Events Processed : %10lld",(Long64_t)hEventInfo->Integral()));
+  AliInfo(Form("Number Of Events Accepted  : %10lld",(Long64_t)hEventInfo->GetBinContent(2)));
+  AliInfo(Form("Number Of Events Skipped   : %10lld",(Long64_t)hEventInfo->GetBinContent(1)));
+  AliInfo(Form("=== end %s ==============",GetName()));
+
+  AliDebug(AliLog::kDebug+2, "->");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::RsnUserCreateOutputObjects()
+{
+//
+// Define here all instructions to create output objects.
+// This method will be called inside the "UserCreateOutputObjects"
+// in the used task.
+//
+
+  AliWarning("Implement this in derived classes");
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::RsnUserExec(Option_t*)
+{
+//
+//
+//
+
+  AliWarning("Implement this in derived classes");
+}
+
+void AliRsnVAnalysisTask::RsnUserExecMix(Option_t* )
+{
+  //
+  //
+  //
+  
+  AliWarning("Implement this in derived classes"); 
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::RsnTerminate(Option_t*)
+{
+//
+// Overload this to add additional termination operations
+//
+
+  AliWarning("Implement this in derived classes");
+}
+
+//_____________________________________________________________________________
+Bool_t AliRsnVAnalysisTask::EventProcess()
+{
+//
+// Performs some pre-processing of current event,
+// which is useful for all the operations which 
+// need to be done only once for each event.
+//
+  
+  // in this case, return always a success
+  return kTRUE;
+}
+
+void AliRsnVAnalysisTask::SetupMixingEvents()
+{
+  // mixing setup
+  
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  AliMultiInputEventHandler *inEvHMain = dynamic_cast<AliMultiInputEventHandler *>(mgr->GetInputEventHandler());
+  if(inEvHMain) {
+    fMixedEH = dynamic_cast<AliMixInputEventHandler *>(inEvHMain->GetFirstMultiInputHandler());
+    if(fMixedEH) {
+      AliMultiInputEventHandler *inEvHMainTmpMix = dynamic_cast<AliMultiInputEventHandler *>(fMixedEH->InputEventHandler(0));
+      if(!inEvHMainTmpMix) return;
+      AliInputEventHandler *inEvHMixTmp = dynamic_cast<AliInputEventHandler *>(inEvHMainTmpMix->GetFirstInputEventHandler());
+      AliMCEventHandler *inEvHMCMixTmp = dynamic_cast<AliMCEventHandler *>(inEvHMainTmpMix->GetFirstMCEventHandler());
+      if(!inEvHMixTmp) return;
+      fESDEvent[1] = dynamic_cast<AliESDEvent *>(inEvHMixTmp->GetEvent());
+      if (fESDEvent[1]) AliDebug(AliLog::kDebug,Form("Input is ESD (%p) MIXED", fESDEvent[1]));
+      // getting AliAODEvent from input
+      fAODEventIn[1] = dynamic_cast<AliAODEvent *>(inEvHMixTmp->GetEvent());
+      if (fAODEventIn[1]) AliDebug(AliLog::kDebug,Form("Input is AOD (%p) MIXED", fAODEventIn[1]));
+      // getting AliAODEvent if it is output from previous task (not supported)
+      fAODEventOut[1] = 0;
+      
+      if(inEvHMCMixTmp) {
+        fMCEvent[1] = inEvHMCMixTmp->MCEvent();
+        if (fMCEvent[1]) AliDebug(AliLog::kDebug,Form("Input is ESDMC (%p) MIXED", fMCEvent[1]));
+      }
+      
+    }
+    
+  }
+}
+
+//_____________________________________________________________________________
+void AliRsnVAnalysisTask::SetDebugForAllClasses()
+{
+//
+// Set debug level for all classes for which it is required
+//
+
+  TObjArray  *array = fLogClassesString.Tokenize(":");
+  TObjString *objStr;
+  TString     str;
+  Int_t       i, n = array->GetEntriesFast();
+  
+  for (i = 0; i < n; i++)
+  {
+    objStr = (TObjString*)array->At(i);
+    str    = objStr->GetString();
+    AliLog::SetClassDebugLevel(str.Data(), fLogType);
+    AliInfo(Form("Setting Debug to %s", str.Data()));
+  }
+}
+
diff --git a/PWG2/RESONANCES/AliRsnVAnalysisTask.h b/PWG2/RESONANCES/AliRsnVAnalysisTask.h
new file mode 100644 (file)
index 0000000..78a4e40
--- /dev/null
@@ -0,0 +1,90 @@
+//
+// Class AliRsnVAnalysisTask
+//
+// Virtual Class derivated from AliAnalysisTaskSE which will be base class
+// for all RSN Multi tasks
+//
+// authors: Martin Vala (martin.vala@cern.ch)
+//          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//
+
+#ifndef ALIRSNVANALYSISTASK_H
+#define ALIRSNVANALYSISTASK_H
+
+#include <TH1.h>
+
+#include "AliAnalysisTaskSE.h"
+
+#include "AliRsnEvent.h"
+#include "AliRsnVATProcessInfo.h"
+#include <AliMixInputEventHandler.h>
+
+class AliESDEvent;
+class AliAODEvent;
+class AliMCEvent;
+
+class AliRsnVAnalysisTask : public AliAnalysisTaskSE
+{
+  public:
+  
+    AliRsnVAnalysisTask(const char *name = "AliRsnVAnalysisTask", Bool_t mcOnly = kFALSE);
+    AliRsnVAnalysisTask(const AliRsnVAnalysisTask& copy);
+    AliRsnVAnalysisTask& operator= (const AliRsnVAnalysisTask& /*copy*/) { return *this; }
+    virtual ~AliRsnVAnalysisTask() {/* Does nothing*/;}
+
+    // basic interface methods
+    virtual void    LocalInit();
+    virtual Bool_t  UserNotify();
+    virtual void    ConnectInputData(Option_t *opt);
+    virtual void    UserCreateOutputObjects();
+    virtual void    UserExec(Option_t* opt);
+               virtual void    UserExecMix(Option_t* option = "");
+    virtual void    Terminate(Option_t* opt);
+
+    // customized methods (to be implemented in derived classes)
+    virtual void    RsnUserCreateOutputObjects();
+    virtual void    RsnUserExec(Option_t*);
+    virtual void    RsnUserExecMix(Option_t*);
+    virtual void    RsnTerminate(Option_t*);
+
+    // event pre-processing functions
+    virtual Bool_t  EventProcess();
+
+    // getters
+    AliRsnEvent*           GetRsnEvent(Int_t i=0) {return &fRsnEvent[i];}
+    AliRsnVATProcessInfo*  GetInfo()     {return &fTaskInfo;}
+
+    // setters
+    void SetMCOnly(Bool_t mcOnly = kTRUE)                           {fMCOnly = mcOnly;}
+    void SetLogType(AliLog::EType_t type, const char *classes = "") {fLogType = type; fLogClassesString = classes;}
+    void SetPrintInfoNumber(const Long64_t &num = 100)              {fTaskInfo.SetPrintInfoNumber(num);}
+    
+    void SetMixing(Bool_t doMix = kTRUE) {fIsMixing = doMix;}
+    Bool_t IsMixing() { return fIsMixing;}
+
+  protected:
+
+    AliLog::EType_t         fLogType;          //  log type
+    TString                 fLogClassesString; //  all classes string divided with ":"
+
+    AliESDEvent            *fESDEvent[2];         //  ESD event
+    AliMCEvent             *fMCEvent[2];          //  MC event
+    AliAODEvent            *fAODEventIn[2];       //  AOD event from input
+    AliAODEvent            *fAODEventOut[2];      //  AOD event from output from previous taks
+
+    Bool_t                  fIsMixing;        // flag is using mixing
+    Bool_t                  fMCOnly;           //  use only MC information
+    AliRsnEvent             fRsnEvent[2];         //  interface to event for RSN package
+
+    TList                  *fInfoList;         //! output list for informations
+    AliRsnVATProcessInfo    fTaskInfo;         //  task info
+    
+    AliMixInputEventHandler *fMixedEH;         //! mixed event hadnler
+
+    void                    SetupMixingEvents();
+    void                    SetDebugForAllClasses();
+
+    ClassDef(AliRsnVAnalysisTask, 1)
+};
+
+#endif