// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
//
+#include <Riostream.h>
+
+#include "AliESDEvent.h"
+#include "AliMCEvent.h"
+#include "AliAODEvent.h"
+#include "AliRsnEvent.h"
+#include "AliRsnTarget.h"
+
#include "AliRsnVAnalysisTaskSE.h"
ClassImp(AliRsnVAnalysisTaskSE)
//_____________________________________________________________________________
-AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const char *name) :
- AliAnalysisTaskSE(name),
- fLogType(AliLog::kInfo),
- fLogClassesString(""),
- fESDEvent(0x0),
- fMCEvent(0x0),
- fAODEventIn(0x0),
- fAODEventOut(0x0),
- fOutList(0x0),
- fTaskInfo(name)
+AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE
+(const char *name, Bool_t mcOnly) :
+ AliAnalysisTaskSE(name),
+ fLogType(AliLog::kInfo),
+ fLogClassesString(""),
+ fESDEvent(0x0),
+ fMCEvent(0x0),
+ fAODEventIn(0x0),
+ fAODEventOut(0x0),
+ fMCOnly(mcOnly),
+ fRsnEvent(),
+ fInfoList(0x0),
+ fTaskInfo(name)
{
//
// Default constructor.
// Define the output slot for histograms.
//
- AliDebug(AliLog::kDebug+2,"<-");
-
- DefineOutput(1, TList::Class());
-
- AliDebug(AliLog::kDebug+2,"->");
+ DefineOutput(1, TList::Class());
+ DefineOutput(2, TList::Class());
}
//_____________________________________________________________________________
-AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) :
- AliAnalysisTaskSE(copy),
- fLogType(copy.fLogType),
- fLogClassesString(copy.fLogClassesString),
- fESDEvent(copy.fESDEvent),
- fMCEvent(copy.fMCEvent),
- fAODEventIn(copy.fAODEventIn),
- fAODEventOut(copy.fAODEventOut),
- fOutList(copy.fOutList),
- fTaskInfo(copy.fTaskInfo)
+AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) :
+ AliAnalysisTaskSE(copy),
+ fLogType(copy.fLogType),
+ fLogClassesString(copy.fLogClassesString),
+ fESDEvent(copy.fESDEvent),
+ fMCEvent(copy.fMCEvent),
+ fAODEventIn(copy.fAODEventIn),
+ fAODEventOut(copy.fAODEventOut),
+ fMCOnly(copy.fMCOnly),
+ fRsnEvent(),
+ fInfoList(0x0),
+ fTaskInfo(copy.fTaskInfo)
{
//
// Copy constructor.
// Defined for coding conventions compliance but never used.
//
-
- AliDebug(AliLog::kDebug+2, "<-");
- AliDebug(AliLog::kDebug+2, "->");
}
//_____________________________________________________________________________
// Defines the debug message level and calls the mother class LocalInit().
//
- AliLog::SetClassDebugLevel(GetName(), fLogType);
- SetDebugForOtherClasses();
-
- AliDebug(AliLog::kDebug+2, "<-");
- AliAnalysisTaskSE::LocalInit();
- AliDebug(AliLog::kDebug+2, "->");
+ AliAnalysisTaskSE::LocalInit();
+ SetDebugForAllClasses();
}
//_____________________________________________________________________________
-Bool_t AliRsnVAnalysisTaskSE::Notify()
+Bool_t AliRsnVAnalysisTaskSE::UserNotify()
{
//
// Calls the mother class Notify()
//
- AliDebug(AliLog::kDebug+2,"<-");
- AliDebug(AliLog::kDebug+2,"->");
-
- return AliAnalysisTaskSE::Notify();
+ return AliAnalysisTaskSE::UserNotify();
}
//_____________________________________________________________________________
void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt)
{
//
-// Connect input data.
-// Links the data member pointers to any possible AliVEvenb input
-// to the appropriate object belonging to the mother class,
-// for a fast retrieval of informations from it through the
-// data interface classes provided in this package.
-// Makes use of dynamic_cast, in order to know the kind of input
-// just checking if the casted pointers are NULL or not.
-//
-
- AliDebug(AliLog::kDebug+2,"<-");
- AliAnalysisTaskSE::ConnectInputData(opt);
-
- // getting AliESDEvent
- fESDEvent = dynamic_cast<AliESDEvent *> (fInputEvent);
-
- if (fESDEvent) {
- AliInfo(Form("Input is ESD (%p)", fESDEvent));
-
- // getting AliMCEvent
- fMCEvent = (AliMCEvent*) MCEvent();
- if (fMCEvent) AliInfo(Form("Input is MC (%p)", fMCEvent));
- }
-
- // getting AliAODEvent from input
- fAODEventIn = dynamic_cast<AliAODEvent *> (fInputEvent);
- if (fAODEventIn) AliInfo(Form("Input is AOD INPUT (%p)",fAODEventIn));
-
- // getting AliAODEvent if it is output from previous task
- fAODEventOut = dynamic_cast<AliAODEvent *> (AODEvent());
- if (fAODEventOut) AliInfo(Form("Input is AOD OUTPUT (%p)",fAODEventOut));
-
- AliDebug(AliLog::kDebug+2,"->");
-}
-
-//_____________________________________________________________________________
-void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects()
-{
-//
-// Define here all instructions to create output objects.
-// This method will be called inside the "UserCreateOutputObjects"
-// in the used task.
+// 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.
//
- AliDebug(AliLog::kDebug+2,"<-");
- AliDebug(AliLog::kDebug+2,"->");
+ AliAnalysisTaskSE::ConnectInputData(opt);
+
+ // get AliESDEvent and, if successful
+ // retrieve the corresponding MC if exists
+ fESDEvent = dynamic_cast<AliESDEvent *>(fInputEvent);
+ if (fESDEvent) {
+ fMCEvent = (AliMCEvent*) MCEvent();
+ AliInfo(Form("Input event is of type ESD (%p)", fESDEvent));
+ if (fMCEvent) AliInfo(Form("Input has an associated MC (%p)", fMCEvent));
+ }
+
+ // get AliAODEvent from input and, if successful
+ // it will contain both the reconstructed and MC informations
+ fAODEventIn = dynamic_cast<AliAODEvent *>(fInputEvent);
+ if (fAODEventIn) {
+ AliInfo(Form("Input event if of type native AOD (%p)", fAODEventIn));
+ }
+
+ // get AliAODEvent from output of previous task
+ fAODEventOut = dynamic_cast<AliAODEvent *>(AODEvent());
+ if (fAODEventOut) {
+ AliInfo(Form("Input event if of type produced AOD from previous step (%p)", fAODEventOut));
+ }
}
//_____________________________________________________________________________
{
//
// Creates and links to task all output objects.
-// They are all stored inside a unique TList which will be saved
-// in output slot #1.
+// 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.
//
- AliLog::SetClassDebugLevel(GetName(), fLogType);
-
- SetDebugForOtherClasses();
-
- AliDebug(AliLog::kDebug+2, "<-");
+ SetDebugForAllClasses();
- fOutList = new TList();
- fOutList->SetOwner();
+ // set event info outputs
+ fInfoList = new TList();
+ fInfoList->SetOwner();
+ fTaskInfo.GenerateInfoList(fInfoList);
- fOutList->Add(fTaskInfo.GenerateInfoList());
+ // create customized outputs
+ RsnUserCreateOutputObjects();
- RsnUserCreateOutputObjects();
-
- AliDebug(AliLog::kDebug+2,"<-");
+ PostData(1, fInfoList);
}
//_____________________________________________________________________________
void AliRsnVAnalysisTaskSE::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().
+//
- AliDebug(AliLog::kDebug+2,"<-");
-
- RsnUserExec(opt);
-
- FillInfo();
-
- fTaskInfo.PrintInfo(fEntry);
-
- PostData(1, fOutList);
-
- AliDebug(AliLog::kDebug+2,"->");
-}
-
-//_____________________________________________________________________________
-void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t* )
-{
-
- if (fESDEvent) {
- 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 is %p", fMCEvent));
- AliDebug(AliLog::kDebug, Form("MC tracks %d", fMCEvent->GetNumberOfTracks()));
- }
- if (fAODEventIn) {
- 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()));
- }
+ if (fMCOnly && fMCEvent) {
+ fRsnEvent.SetRef(fMCEvent);
+ fRsnEvent.SetRefMC(fMCEvent);
+ } else if (fESDEvent) {
+ fRsnEvent.SetRef(fESDEvent);
+ fRsnEvent.SetRefMC(fMCEvent);
+ } else if (fAODEventOut) {
+ fRsnEvent.SetRef(fAODEventOut);
+ fRsnEvent.SetRefMC(fAODEventOut);
+ } else if (fAODEventIn) {
+ fRsnEvent.SetRef(fAODEventIn);
+ fRsnEvent.SetRefMC(fAODEventIn);
+ } 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, fEntry);
+ AliRsnEvent::SetCurrentEvent2(&fRsnEvent, 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);
}
//_____________________________________________________________________________
// and includes to the TList all task informations.
//
- AliDebug(AliLog::kDebug+2,"<-");
- AliAnalysisTask::Terminate();
+ AliAnalysisTask::Terminate();
- fOutList = dynamic_cast<TList*>(GetOutputData(1));
- if (!fOutList) {
- AliError(Form("At end of analysis, fOutList is %p", fOutList));
- return;
- }
+ TList* list = dynamic_cast<TList*>(GetOutputData(1));
+ if (!list) {
+ AliError(Form("At end of analysis, fOutList is %p", list));
+ return;
+ }
- RsnTerminate(opt);
+ RsnTerminate(opt);
- TList* lEventInfo = (TList*) fOutList->FindObject(fTaskInfo.GetName());
+ 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()));
- TH1I *hEventInfo = (TH1I*) lEventInfo->FindObject(fTaskInfo.GetEventHistogramName());
- if (!hEventInfo) {
- AliError(Form("hEventInfo is %p",hEventInfo));
- return;
- }
+ AliDebug(AliLog::kDebug + 2, "->");
+}
- AliInfo(Form("=== %s ==================",GetName()));
- AliInfo(Form("Number Of Events Processed : %10d",(Long64_t)hEventInfo->Integral()));
- AliInfo(Form("Number Of Events Accepted : %10d",(Long64_t)hEventInfo->GetBinContent(2)));
- AliInfo(Form("Number Of Events Skipped : %10d",(Long64_t)hEventInfo->GetBinContent(1)));
- AliInfo(Form("=== end %s ==============",GetName()));
+//_____________________________________________________________________________
+void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects()
+{
+//
+// Define here all instructions to create output objects.
+// This method will be called inside the "UserCreateOutputObjects"
+// in the used task.
+//
- AliDebug(AliLog::kDebug+2, "->");
+ AliWarning("Implement this in derived classes");
}
//_____________________________________________________________________________
-void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t* )
+void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t*)
{
//
-// Overload this to add additional termination operations
+//
//
- AliDebug(AliLog::kDebug+2, "<-");
- AliDebug(AliLog::kDebug+2, "->");
+ AliWarning("Implement this in derived classes");
}
//_____________________________________________________________________________
-void AliRsnVAnalysisTaskSE::FillInfo()
+void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t*)
{
//
-// Fill information object with statistics of analysis
+// Overload this to add additional termination operations
//
- AliDebug(AliLog::kDebug+2, "<-");
- /*
- if (fAODEventOut) {
- fTaskInfo.SetNumberOfTracks(fAODEventOut->GetNumberOfTracks());
- }
- else if (fESDEvent) {
- fTaskInfo.SetNumberOfTracks(fESDEvent->GetNumberOfTracks());
- }
- else if (fAODEventIn) {
- fTaskInfo.SetNumberOfTracks(fAODEventIn->GetNumberOfTracks());
- }
- */
- fTaskInfo.FillInfo();
- AliDebug(AliLog::kDebug+2,"->");
+ AliWarning("Implement this in derived classes");
}
//_____________________________________________________________________________
-void AliRsnVAnalysisTaskSE::SetLogType(AliLog::EType_t type, TString otherClasses)
+Bool_t AliRsnVAnalysisTaskSE::EventProcess()
{
//
-// Set Log level for this and other classes (list of their names)
+// Performs some pre-processing of current event,
+// which is useful for all the operations which
+// need to be done only once for each event.
//
- AliDebug(AliLog::kDebug+2,"<-");
- fLogType = type;
- fLogClassesString = otherClasses;
- AliDebug(AliLog::kDebug+2,"->");
+ // in this case, return always a success
+ return kTRUE;
}
//_____________________________________________________________________________
-void AliRsnVAnalysisTaskSE::SetDebugForOtherClasses()
+void AliRsnVAnalysisTaskSE::SetDebugForAllClasses()
{
//
// Set debug level for all classes for which it is required
//
- AliDebug(AliLog::kDebug+2, "<-");
- TObjArray* array = fLogClassesString.Tokenize(":");
- TObjString *str;
- TString strr;
- for (Int_t i=0;i< array->GetEntriesFast();i++) {
- str = (TObjString *) array->At(i);
- strr = str->GetString();
- AliLog::SetClassDebugLevel(strr.Data(), fLogType);
- }
- AliDebug(AliLog::kDebug+2,"->");
+ 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()));
+ }
}
+