]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/EMCAL/AliEmcalDebugTask.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWG / EMCAL / AliEmcalDebugTask.cxx
1 // $Id$
2 //
3 // Task to debug problems
4 //
5 // Author: C.Loizides
6
7 #include "AliEmcalDebugTask.h"
8 #include <TClonesArray.h>
9 #include <TFile.h>
10 #include <TRandom3.h>
11 #include <TSystem.h>
12 #include "AliAnalysisManager.h"
13 #include "AliESDEvent.h"
14 #include "AliInputEventHandler.h"
15 #include "AliLog.h"
16
17 ClassImp(AliEmcalDebugTask)
18
19 //________________________________________________________________________
20 AliEmcalDebugTask::AliEmcalDebugTask() : 
21   AliAnalysisTaskSE(),
22   fId(0),
23   fFileTest(),
24   fPrintEnv(0),
25   fOutput(0),
26   fFileName(),
27   fRand(0)
28 {
29   // Constructor.
30 }
31
32 //________________________________________________________________________
33 AliEmcalDebugTask::AliEmcalDebugTask(const char *name) : 
34   AliAnalysisTaskSE(name),
35   fId(0),
36   fFileTest(),
37   fPrintEnv(0),
38   fOutput(0),
39   fFileName(),
40   fRand(0)
41 {
42   // Constructor.
43
44   DefineOutput(1, TList::Class()); 
45   fBranchNames = "ESD:AliESDHeader.,AliESDRun.,Tracks";
46 }
47
48 //________________________________________________________________________
49 AliEmcalDebugTask::~AliEmcalDebugTask()
50 {
51   // Destructor.
52 }
53
54 //________________________________________________________________________
55 void AliEmcalDebugTask::UserCreateOutputObjects()
56 {
57   // Create user objects
58
59   fOutput = new TList();
60   fOutput->SetOwner();
61
62   TRandom3 r(0);
63   fRand = r.Integer(kMaxUInt);
64   fOutput->Add(new TNamed(Form("%u",fId),Form("%u",fRand)));
65
66   AliInfo(Form("AliEmcalDebug: %u %u",fId,fRand));
67   if (fPrintEnv)
68     gSystem->Exec("env");
69
70   PostData(1, fOutput); 
71 }
72
73 //________________________________________________________________________
74 void AliEmcalDebugTask::UserExec(Option_t *) 
75 {
76   // Main loop, called for each event.
77
78   AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
79   if (!am) {
80     AliError("Manager zero, returning");
81     return;
82   }
83
84   TString filename;
85
86   TTree *t = am->GetTree();
87   if (t) {
88     TFile *f = t->GetCurrentFile();
89     if (f) {
90       filename = f->GetName();
91     }
92   }
93
94   if (filename==fFileName)
95     return;
96
97   if (fFileTest.Length()>0) {
98     if (!fFileName.Contains(fFileTest)) {
99       AliError(Form("Filename %s does not contain %s", fFileName.Data(), fFileTest.Data()));
100       return;
101     }
102   }
103   fFileName = filename;
104
105   AliInfo(Form("New file: %s", fFileName.Data()));
106   fOutput->Add(new TNamed(Form("%u:%u",fId,fRand),fFileName.Data()));
107 }