AliPhysics  2c6b7ad (2c6b7ad)
AliTestAD.cxx
Go to the documentation of this file.
1 #include "AliTestAD.h"
2 #include "AliAnalysisManager.h"
3 #include "AliInputEventHandler.h"
4 #include "AliPhysicsSelection.h"
5 #include "AliAnalysisUtils.h"
6 #include "AliESDVertex.h"
7 #include "AliESDEvent.h"
8 #include "AliLog.h"
9 #include <TList.h>
10 #include <TH2.h>
11 
12 //====================================================================
13 namespace {
14  AliInputEventHandler* GetInputHandler()
15  {
16  AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
17  if (!am) {
18  Warning("GetPhysicsSelection", "No analysis manager");
19  return 0;
20  }
21 
22  // Get the input handler - should always be there
23  AliInputEventHandler* ih =
24  dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
25  if (!ih) {
26  Warning("GetPhysicsSelection", "No input handler");
27  return 0;
28  }
29  return ih;
30  }
31  AliPhysicsSelection* GetPhysicsSelection()
32  {
33  AliInputEventHandler* ih = GetInputHandler();
34  if (!ih) return 0;
35 
36  // Get the physics selection - should always be there
37  AliPhysicsSelection* ps =
38  dynamic_cast<AliPhysicsSelection*>(ih->GetEventSelection());
39  if (!ps) {
40  Warning("GetPhysicsSelection", "No physics selection");
41  return 0;
42  }
43  return ps;
44  }
45 }
46 
47 //====================================================================
49  : AliAnalysisTaskSE("ad"),
50  fList(0),
51  fAD(),
52  fIPz0(0),
53  fIPz1(0),
54  fIPz2(0),
55  fIPzSat0(0),
56  fIPzSat1(0),
57  fIPzSat2(0),
58  fIPzSatP(0),
59  fIsInit()
60 {
61  DefineOutput(1, TList::Class());
62 }
63 //--------------------------------------------------------------------
65 {
66  // Get the analysis manager and connect this task
67  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
68  // Add to the manager
69  mgr->AddTask(this);
70 
71  // Connect input
72  mgr->ConnectInput(this, 0, mgr->GetCommonInputContainer());
73 
74  // Connect output
75  AliAnalysisDataContainer* sumCon =
76  mgr->CreateContainer("ad", TList::Class(),
77  AliAnalysisManager::kOutputContainer,
78  AliAnalysisManager::GetCommonFileName());
79  mgr->ConnectOutput(this, 1, sumCon);
80 }
81 //--------------------------------------------------------------------
83 {
84  // Define output list
85  fList = new TList;
86  fList->SetName(GetName());
87  fList->SetOwner();
88 
89  Int_t nSatIPz = 4000;
90  Double_t maxSatIPz = 400;
91  // MAke correlation histogram
92  fIPz0 = new TH2D("ipZ0", "AD vs SPD IP_{#it{z}} (>0)",
93  100, -50, 50, nSatIPz, -maxSatIPz, +maxSatIPz);
94  fIPz0->SetDirectory(0);
95  fIPz0->SetXTitle("SPD IP_{#it{z}} [cm]");
96  fIPz0->SetYTitle("AD IP_{#it{z}} [cm]");
97  fIPz0->SetZTitle("Events");
98  fIPz0->SetDirectory(0);
99 
100  fIPz1 = static_cast<TH2*>(fIPz0->Clone("ipZ1"));
101  fIPz1->SetTitle("AD vs SPD IP_{#it{z}} (>1)");
102  fIPz1->SetDirectory(0);
103 
104  fIPz2 = static_cast<TH2*>(fIPz0->Clone("ipZ2"));
105  fIPz2->SetTitle("AD vs SPD IP_{#it{z}} (>2)");
106  fIPz2->SetDirectory(0);
107 
108  fIPzSat0 = new TH1D("ipZSat0", "Satellite IP_{#it{z}} (SPD>0 veto)",
109  nSatIPz, -maxSatIPz, +maxSatIPz);
110  fIPzSat0->SetXTitle("AD IP_{#it{z}} [cm]");
111  fIPzSat0->SetYTitle("Events");
112  fIPzSat0->SetFillStyle(3001);
113  fIPzSat0->SetFillColor(kRed-3);
114  fIPzSat0->SetLineColor(kRed-3);
115  fIPzSat0->SetDirectory(0);
116 
117  fIPzSat1 = static_cast<TH1*>(fIPzSat0->Clone("ipZSat1"));
118  fIPzSat1->SetTitle("Satellite IP_{#it{z}} (SPD>1 veto)");
119  fIPzSat1->SetFillColor(kGreen-3);
120  fIPzSat1->SetLineColor(kGreen-3);
121  fIPzSat1->SetDirectory(0);
122 
123  fIPzSat2 = static_cast<TH1*>(fIPzSat0->Clone("ipZSat2"));
124  fIPzSat2->SetTitle("Satellite IP_{#it{z}} (SPD>2 veto)");
125  fIPzSat2->SetFillColor(kBlue-3);
126  fIPzSat2->SetLineColor(kBlue-3);
127  fIPzSat2->SetDirectory(0);
128 
129 
130  fIPzSatP = static_cast<TH1*>(fIPzSat0->Clone("ipZSatP"));
131  fIPzSatP->SetTitle("Satellite IP_{#it{z}} (SPD pile-up veto)");
132  fIPzSatP->SetFillColor(kMagenta-3);
133  fIPzSatP->SetLineColor(kMagenta-3);
134  fIPzSatP->SetDirectory(0);
135 
136  fList->Add(fIPz0);
137  fList->Add(fIPz1);
138  fList->Add(fIPz2);
139  fList->Add(fIPzSat0);
140  fList->Add(fIPzSat1);
141  fList->Add(fIPzSat2);
142  fList->Add(fIPzSatP);
143 
144  PostData(1,fList);
145 }
146 //--------------------------------------------------------------------
148 {
149  // Check for an event
150  AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
151  if (!esd) {
152  AliWarning("No ESD event found for input event");
153  return;
154  }
155 
156  // IF we have a physis selection, check that we have a trigger
157  UInt_t trg = (GetPhysicsSelection() ?
158  GetInputHandler()->IsEventSelected() :
159  AliVEvent::kMB);
160  if (!trg) return;
161 
162  // If not initialized yet, do so here.
163  if (!fIsInit) {
164  fAD.SetupForData(fList, "", false);
165  fIsInit = true;
166  }
167 
168  // Let sub-procedure test the event
169  fAD.Process(esd);
170 
171  // Get and check SPD ip
175  const AliESDVertex* ip = esd->GetPrimaryVertexSPD();
176  if (ip && ip->GetZRes() <= 0.2) {
177  if (ip->GetNContributors() >= 1) spdZ0 = ip->GetZ();
178  if (ip->GetNContributors() >= 2) spdZ1 = ip->GetZ();
179  if (ip->GetNContributors() >= 3) spdZ2 = ip->GetZ();
180  }
181 
182  // Fill Correlation of vertex
184  fIPz0->Fill(spdZ0, fAD.GetIPz());
186  fIPz1->Fill(spdZ1, fAD.GetIPz());
188  fIPz2->Fill(spdZ2, fAD.GetIPz());
189 
190  Bool_t pileup = esd->IsPileupFromSPDInMultBins();
191 
192  if (fAD.IsSatellite()) {
194  fIPzSat0->Fill(fAD.GetIPz());
196  fIPzSat1->Fill(fAD.GetIPz());
198  fIPzSat2->Fill(fAD.GetIPz());
199  if (!pileup)
200  fIPzSatP->Fill(fAD.GetIPz());
201  }
202 
203  // Post to output
204  PostData(1,fList);
205 }
206 //--------------------------------------------------------------------
207 //
208 // EOF
209 //
double Double_t
Definition: External.C:58
TH1 * fIPzSatP
Definition: AliTestAD.h:53
AliDisplacedVertexSelectionAD fAD
Definition: AliTestAD.h:46
TH1 * fIPzSat2
Definition: AliTestAD.h:52
TH2 * fIPz0
Definition: AliTestAD.h:47
TList * fList
Definition: AliTestAD.h:45
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
Definition: External.C:228
Definition: External.C:212
AliTestAD()
Definition: AliTestAD.h:12
Bool_t fIsInit
Definition: AliTestAD.h:54
TH1 * fIPzSat0
Definition: AliTestAD.h:50
void UserCreateOutputObjects()
Definition: AliTestAD.cxx:82
TH2 * fIPz2
Definition: AliTestAD.h:49
Definition: External.C:220
void SetupForData(TList *l, const char *name=0, Bool_t mc=false)
TH1 * fIPzSat1
Definition: AliTestAD.h:51
Bool_t Process(const AliESDEvent *esd)
const char Option_t
Definition: External.C:48
void Connect()
Definition: AliTestAD.cxx:64
bool Bool_t
Definition: External.C:53
TH2 * fIPz1
Definition: AliTestAD.h:48
Definition: External.C:196
void UserExec(Option_t *option)
Definition: AliTestAD.cxx:147