From 1ea19f39c1537bbc6a2eb0d0485c7d846a4ec49b Mon Sep 17 00:00:00 2001 From: loizides Date: Fri, 17 Jan 2014 09:32:42 +0100 Subject: [PATCH] Attempt to monitor what file is read and merged by what job --- PWG/CMakelibPWGEMCAL.pkg | 1 + PWG/EMCAL/AliEmcalDebugTask.cxx | 107 +++++++++++++++++++++++++++ PWG/EMCAL/AliEmcalDebugTask.h | 36 +++++++++ PWG/EMCAL/macros/AddTaskEmcalDebug.C | 58 +++++++++++++++ PWG/PWGEMCALLinkDef.h | 1 + 5 files changed, 203 insertions(+) create mode 100644 PWG/EMCAL/AliEmcalDebugTask.cxx create mode 100644 PWG/EMCAL/AliEmcalDebugTask.h create mode 100644 PWG/EMCAL/macros/AddTaskEmcalDebug.C diff --git a/PWG/CMakelibPWGEMCAL.pkg b/PWG/CMakelibPWGEMCAL.pkg index 843f4e8d9d7..440a7fe8886 100644 --- a/PWG/CMakelibPWGEMCAL.pkg +++ b/PWG/CMakelibPWGEMCAL.pkg @@ -36,6 +36,7 @@ set ( SRCS EMCAL/AliEmcalClusterMaker.cxx EMCAL/AliEmcalCompatTask.cxx EMCAL/AliEmcalContainer.cxx + EMCAL/AliEmcalDebugTask.cxx EMCAL/AliEmcalEsdTrackFilterTask.cxx EMCAL/AliEmcalMCTrackSelector.cxx EMCAL/AliEmcalParticle.cxx diff --git a/PWG/EMCAL/AliEmcalDebugTask.cxx b/PWG/EMCAL/AliEmcalDebugTask.cxx new file mode 100644 index 00000000000..fc02429022c --- /dev/null +++ b/PWG/EMCAL/AliEmcalDebugTask.cxx @@ -0,0 +1,107 @@ +// $Id$ +// +// Task to debug problems +// +// Author: C.Loizides + +#include "AliEmcalDebugTask.h" +#include +#include +#include +#include +#include "AliAnalysisManager.h" +#include "AliESDEvent.h" +#include "AliInputEventHandler.h" +#include "AliLog.h" + +ClassImp(AliEmcalDebugTask) + +//________________________________________________________________________ +AliEmcalDebugTask::AliEmcalDebugTask() : + AliAnalysisTaskSE(), + fId(0), + fFileTest(), + fPrintEnv(0), + fOutput(0), + fFileName(), + fRand(0) +{ + // Constructor. +} + +//________________________________________________________________________ +AliEmcalDebugTask::AliEmcalDebugTask(const char *name) : + AliAnalysisTaskSE(name), + fId(0), + fFileTest(), + fPrintEnv(0), + fOutput(0), + fFileName(), + fRand(0) +{ + // Constructor. + + DefineOutput(1, TList::Class()); + fBranchNames = "ESD:AliESDHeader.,AliESDRun.,Tracks"; +} + +//________________________________________________________________________ +AliEmcalDebugTask::~AliEmcalDebugTask() +{ + // Destructor. +} + +//________________________________________________________________________ +void AliEmcalDebugTask::UserCreateOutputObjects() +{ + // Create user objects + + fOutput = new TList(); + fOutput->SetOwner(); + + TRandom3 r(0); + fRand = r.Integer(kMaxUInt); + fOutput->Add(new TNamed(Form("%u",fId),Form("%u",fRand))); + + AliInfo(Form("AliEmcalDebug: %u %u",fId,fRand)); + if (fPrintEnv) + gSystem->Exec("env"); + + PostData(1, fOutput); +} + +//________________________________________________________________________ +void AliEmcalDebugTask::UserExec(Option_t *) +{ + // Main loop, called for each event. + + AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); + if (!am) { + AliError("Manager zero, returning"); + return; + } + + TString filename; + + TTree *t = am->GetTree(); + if (t) { + TFile *f = t->GetCurrentFile(); + if (f) { + filename = f->GetName(); + } + } + + if (filename==fFileName) + return; + + if (fFileTest.Length()>0) { + if (!fFileName.Contains(fFileTest)) { + AliError(Form("Filename %s does not contain %s", fFileName.Data(), fFileTest.Data())); + return; + } + } + fFileName = filename; + + AliInfo(Form("New file: %s", fFileName.Data())); + fOutput->Add(new TNamed(Form("%u:%u",fId,fRand),fFileName.Data())); +} diff --git a/PWG/EMCAL/AliEmcalDebugTask.h b/PWG/EMCAL/AliEmcalDebugTask.h new file mode 100644 index 00000000000..532a0d339e1 --- /dev/null +++ b/PWG/EMCAL/AliEmcalDebugTask.h @@ -0,0 +1,36 @@ +#ifndef ALIEMCALDEBUGTASK_H +#define ALIEMCALDEBUGTASK_H + +// $Id$ + +#include "AliAnalysisTaskSE.h" + +class AliEmcalDebugTask : public AliAnalysisTaskSE { + public: + AliEmcalDebugTask(); + AliEmcalDebugTask(const char *name); + virtual ~AliEmcalDebugTask(); + + void SetId(UInt_t id) { fId = id; } + void SetFileTest(const char *n) { fFileTest = n; } + void SetPrintEnv(Bool_t b) { fPrintEnv = b; } + + protected: + void UserCreateOutputObjects(); + void UserExec(Option_t *option); + + UInt_t fId; //id to be stored in the output file + TString fFileTest; //path name test + Bool_t fPrintEnv; //print env if true + TList *fOutput; //!output list + TString fFileName; //!current file name + UInt_t fRand; //!random number + + private: + AliEmcalDebugTask(const AliEmcalDebugTask&); // not implemented + AliEmcalDebugTask &operator=(const AliEmcalDebugTask&); // not implemented + + ClassDef(AliEmcalDebugTask, 1); // Class to be able to run on skimmed ESDs +}; + +#endif diff --git a/PWG/EMCAL/macros/AddTaskEmcalDebug.C b/PWG/EMCAL/macros/AddTaskEmcalDebug.C new file mode 100644 index 00000000000..b2192a4207e --- /dev/null +++ b/PWG/EMCAL/macros/AddTaskEmcalDebug.C @@ -0,0 +1,58 @@ +// $Id$ + +AliEmcalDebugTask* AddTaskEmcalDebug( + const UInt_t id = 0, + const char *fnametest = 0, + const char *tnamebase = "DebugTask", + const char *outputfn = "AnalysisResults.root" +) +{ + // Get the pointer to the existing analysis manager via the static access method. + //============================================================================== + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + if (!mgr) + { + ::Error("AddTaskEmcalCompat", "No analysis manager to connect to."); + return NULL; + } + + // Check the analysis type using the event handlers connected to the analysis manager. + //============================================================================== + if (!mgr->GetInputEventHandler()) + { + ::Error("AddTaskEmcalCompat", "This task requires an input event handler"); + return NULL; + } + + //------------------------------------------------------- + // Init the task and do settings + //------------------------------------------------------- + + AliEmcalDebugTask *dtask = new AliEmcalDebugTask(tnamebase); + UInt_t tid = id; + if (id==0) { + TRandom3 r(0); + tid = r.Integer(kMaxUInt); + } + ::Info("AddTaskEmcalDebug","Setting up debug task with id %u", tid); + dtask->SetId(tid); + if (fnametest) + dtask->SetFileTest(fnametest); + dtask->SelectCollisionCandidates(0); + + //------------------------------------------------------- + // Final settings, pass to manager and set the containers + //------------------------------------------------------- + mgr->AddTask(dtask); + + // Create containers for input/output + AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer(); + AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("%s_%u",tnamebase,tid), + TList::Class(), + AliAnalysisManager::kOutputContainer, + outputfn); + mgr->ConnectInput(dtask, 0, cinput); + mgr->ConnectOutput(dtask,1,coutput); + + return dtask; +} diff --git a/PWG/PWGEMCALLinkDef.h b/PWG/PWGEMCALLinkDef.h index 4587dcac2ae..5d60dd33fd8 100644 --- a/PWG/PWGEMCALLinkDef.h +++ b/PWG/PWGEMCALLinkDef.h @@ -13,6 +13,7 @@ #pragma link C++ class AliEmcalClusterMaker+; #pragma link C++ class AliEmcalCompatTask+; #pragma link C++ class AliEmcalContainer+; +#pragma link C++ class AliEmcalDebugTask+; #pragma link C++ class AliEmcalEsdTrackFilterTask; #pragma link C++ class AliEmcalMCTrackSelector+; #pragma link C++ class AliEmcalParticle+; -- 2.43.0