]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALTasks/AliEmcalCompatTask.cxx
compare offline bits, load branches
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliEmcalCompatTask.cxx
1 // $Id$
2 //
3 // Task to setup emcal related global objects.
4 //
5 // Author: C.Loizides
6
7 #include "AliEmcalCompatTask.h"
8
9 #include <TClonesArray.h>
10
11 #include "AliAnalysisManager.h"
12 #include "AliCentrality.h"
13 #include "AliESDEvent.h"
14 #include "AliEsdTrackExt.h"
15 #include "AliEventplane.h"
16 #include "AliInputEventHandler.h"
17
18 ClassImp(AliEmcalCompatTask)
19
20 //________________________________________________________________________
21 AliEmcalCompatTask::AliEmcalCompatTask() : 
22   AliAnalysisTaskSE(),
23   fDoCent(1),
24   fDoEp(1)
25 {
26   // Constructor.
27 }
28
29 //________________________________________________________________________
30 AliEmcalCompatTask::AliEmcalCompatTask(const char *name) : 
31   AliAnalysisTaskSE(name),
32   fDoCent(1),
33   fDoEp(1)
34 {
35   // Constructor.
36
37   fBranchNames = "ESD:AliESDHeader.,AliESDRun.,Tracks";
38 }
39
40 //________________________________________________________________________
41 AliEmcalCompatTask::~AliEmcalCompatTask()
42 {
43   // Destructor.
44 }
45
46 //________________________________________________________________________
47 void AliEmcalCompatTask::UserExec(Option_t *) 
48 {
49   // Main loop, called for each event.
50
51   AliESDEvent *esdEv = dynamic_cast<AliESDEvent*>(InputEvent());
52   if (!esdEv) {
53     AliError("Task works only on ESD events, returning");
54     return;
55   }
56
57   AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
58   if (!am) {
59     AliError("Manager zero, returning");
60     return;
61   }
62
63   am->LoadBranch("AliESDHeader.");
64   am->LoadBranch("AliESDRun.");
65   LoadBranches();
66
67   AliESDHeader *header = esdEv->GetHeader();
68   TString title;
69   if (header)
70     title = header->GetTitle();
71   if (title.Length()==0) {
72     AliError("Title should encode offline trigger, returning");
73     return;
74   } else {
75     UInt_t off = header->GetUniqueID();
76     off &= 0x4FFFFFFF;
77     UInt_t res     = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected(); 
78     res &= 0x4FFFFFFF;
79     if (off!=res) {
80       AliWarning(Form("Stored offline trigger not equal computed: %ud %ud", off, res));
81     }
82   }
83
84   if (fDoCent) {
85     am->LoadBranch("Centrality.");
86     AliCentrality *centin = dynamic_cast<AliCentrality*>(esdEv->FindListObject("Centrality"));
87     AliCentrality *centout = esdEv->GetCentrality();
88     if (centin&&centout&&centout->GetQuality()==999) {
89       centout->SetQuality(centin->GetQuality());
90       centout->SetCentralityV0M(centin->GetCentralityPercentileUnchecked("V0M"));
91       centout->SetCentralityFMD(centin->GetCentralityPercentileUnchecked("FMD"));
92       centout->SetCentralityTRK(centin->GetCentralityPercentileUnchecked("TRK"));
93       centout->SetCentralityTKL(centin->GetCentralityPercentileUnchecked("TKL"));
94       centout->SetCentralityCL0(centin->GetCentralityPercentileUnchecked("CL0"));
95       centout->SetCentralityCL1(centin->GetCentralityPercentileUnchecked("CL1"));
96       centout->SetCentralityV0MvsFMD(centin->GetCentralityPercentileUnchecked("V0MvsFMD"));
97       centout->SetCentralityTKLvsV0M(centin->GetCentralityPercentileUnchecked("TKLvsV0M"));
98       centout->SetCentralityZEMvsZDC(centin->GetCentralityPercentileUnchecked("ZEMvsZDC"));
99     }
100   }
101
102   if (fDoEp) {
103     am->LoadBranch("Eventplane.");
104     AliEventplane *epin  = dynamic_cast<AliEventplane*>(esdEv->FindListObject("Eventplane"));
105     AliEventplane *epout = esdEv->GetEventplane();
106     if (epin&&epout&&(epout->GetQVector()==0)&&(epin->GetQVector()!=0)) {
107       epout->SetQVector(new TVector2(*epin->GetQVector()));
108       epout->SetEventplaneQ(epin->GetEventplane("Q"));
109       epout->SetQsub(new TVector2(*epin->GetQsub1()),new TVector2(*epin->GetQsub2()));
110       epout->SetQsubRes(epin->GetQsubRes());
111     }
112   }
113
114   TTree *tree = am->GetTree();
115   if (tree&&tree->GetBranch("PicoTracks")) {
116     am->LoadBranch("PicoTracks");
117   }
118
119   if (tree&&tree->GetBranch("Tracks")) {
120     am->LoadBranch("Tracks");
121     TClonesArray *ts = dynamic_cast<TClonesArray*>(esdEv->FindListObject("Tracks"));
122     if (ts) {
123       TString clsname(ts->GetClass()->GetName());
124       if (clsname == "AliEsdTrackExt") {
125         const Int_t N = ts->GetEntries();
126         for (Int_t i=0; i<N; ++i) {
127           AliEsdTrackExt *t = static_cast<AliEsdTrackExt*>(ts->At(i));
128           if (t) {
129             t->SetESDEvent(esdEv);
130             t->Setup();
131           }
132         }
133       }
134     }
135   }
136 }