AliPhysics  ec707b8 (ec707b8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AliEmcalCompatTask.cxx
Go to the documentation of this file.
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 
19 
20 //________________________________________________________________________
22  AliAnalysisTaskSE(),
23  fDoCent(1),
24  fDoEp(1)
25 {
26  // Constructor.
27 }
28 
29 //________________________________________________________________________
31  AliAnalysisTaskSE(name),
32  fDoCent(1),
33  fDoEp(1)
34 {
35  // Constructor.
36 
37  fBranchNames = "ESD:AliESDHeader.,AliESDRun.,Tracks";
38 }
39 
40 //________________________________________________________________________
42 {
43  // Destructor.
44 }
45 
46 //________________________________________________________________________
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  else {
72  AliError(Form("%s: Header zero, returning!", GetName()));
73  return;
74  }
75 
76  if (title.Length()==0) {
77  AliError(Form("%s: Title should encode offline trigger, returning!", GetName()));
78  return;
79  } else {
80  UInt_t off = header->GetUniqueID();
81  off &= 0x4FFFFFFF;
82  UInt_t res = ((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected();
83  res &= 0x4FFFFFFF;
84  if (off!=res) {
85  AliWarning(Form("Stored offline trigger not equal computed: %ud %ud", off, res));
86  }
87  }
88 
89  if (fDoCent) {
90  am->LoadBranch("Centrality.");
91  AliCentrality *centin = dynamic_cast<AliCentrality*>(esdEv->FindListObject("Centrality"));
92  AliCentrality *centout = esdEv->GetCentrality();
93  if (centin&&centout&&centout->GetQuality()==999) {
94  centout->SetQuality(centin->GetQuality());
95  centout->SetCentralityV0M(centin->GetCentralityPercentileUnchecked("V0M"));
96  centout->SetCentralityFMD(centin->GetCentralityPercentileUnchecked("FMD"));
97  centout->SetCentralityTRK(centin->GetCentralityPercentileUnchecked("TRK"));
98  centout->SetCentralityTKL(centin->GetCentralityPercentileUnchecked("TKL"));
99  centout->SetCentralityCL0(centin->GetCentralityPercentileUnchecked("CL0"));
100  centout->SetCentralityCL1(centin->GetCentralityPercentileUnchecked("CL1"));
101  centout->SetCentralityV0MvsFMD(centin->GetCentralityPercentileUnchecked("V0MvsFMD"));
102  centout->SetCentralityTKLvsV0M(centin->GetCentralityPercentileUnchecked("TKLvsV0M"));
103  centout->SetCentralityZEMvsZDC(centin->GetCentralityPercentileUnchecked("ZEMvsZDC"));
104  }
105  }
106 
107  if (fDoEp) {
108  am->LoadBranch("Eventplane.");
109  AliEventplane *epin = dynamic_cast<AliEventplane*>(esdEv->FindListObject("Eventplane"));
110  AliEventplane *epout = esdEv->GetEventplane();
111  if (epin&&epout&&(epout->GetQVector()==0)&&(epin->GetQVector()!=0)) {
112  epout->SetQVector(new TVector2(*epin->GetQVector()));
113  epout->SetEventplaneQ(epin->GetEventplane("Q"));
114  epout->SetQsub(new TVector2(*epin->GetQsub1()),new TVector2(*epin->GetQsub2()));
115  epout->SetQsubRes(epin->GetQsubRes());
116  }
117  }
118 
119  TTree *tree = am->GetTree();
120  if (tree&&tree->GetBranch("PicoTracks")) {
121  am->LoadBranch("PicoTracks");
122  }
123 
124  if (tree&&tree->GetBranch("Tracks")) {
125  am->LoadBranch("Tracks");
126  TClonesArray *ts = dynamic_cast<TClonesArray*>(esdEv->FindListObject("Tracks"));
127  if (ts) {
128  TString clsname(ts->GetClass()->GetName());
129  if (clsname == "AliEsdTrackExt") {
130  const Int_t N = ts->GetEntries();
131  for (Int_t i=0; i<N; ++i) {
132  AliEsdTrackExt *t = static_cast<AliEsdTrackExt*>(ts->At(i));
133  if (t) {
134  t->SetESDEvent(esdEv);
135  t->Setup();
136  }
137  }
138  }
139  }
140  }
141 }
const char * title
Definition: MakeQAPdf.C:26
ClassImp(AliEmcalCompatTask) AliEmcalCompatTask
void UserExec(Option_t *option)