]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Attempt to monitor what file is read and merged by what job
authorloizides <cloizides@lbl.gov>
Fri, 17 Jan 2014 08:32:42 +0000 (09:32 +0100)
committerloizides <cloizides@lbl.gov>
Fri, 17 Jan 2014 08:32:51 +0000 (09:32 +0100)
PWG/CMakelibPWGEMCAL.pkg
PWG/EMCAL/AliEmcalDebugTask.cxx [new file with mode: 0644]
PWG/EMCAL/AliEmcalDebugTask.h [new file with mode: 0644]
PWG/EMCAL/macros/AddTaskEmcalDebug.C [new file with mode: 0644]
PWG/PWGEMCALLinkDef.h

index 843f4e8d9d7284d1483d0624910b9c1a7c7df315..440a7fe88861e58d41fd562edd0df3505aed998c 100644 (file)
@@ -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 (file)
index 0000000..fc02429
--- /dev/null
@@ -0,0 +1,107 @@
+// $Id$
+//
+// Task to debug problems
+//
+// Author: C.Loizides
+
+#include "AliEmcalDebugTask.h"
+#include <TClonesArray.h>
+#include <TFile.h>
+#include <TRandom3.h>
+#include <TSystem.h>
+#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 (file)
index 0000000..532a0d3
--- /dev/null
@@ -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 (file)
index 0000000..b2192a4
--- /dev/null
@@ -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;
+}
index 4587dcac2ae8d2184b6b7f0f1d7cf4c1b6b6fa4e..5d60dd33fd8957ecbeb83ffa1b13b00570dad4ac 100644 (file)
@@ -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+;