3 # include <AliAnalysisManager.h>
4 # include <AliESDEvent.h>
5 # include <AliMultiplicity.h>
6 # include <AliVEventHandler.h>
7 # include <AliESDVertex.h>
8 # include <AliProdInfo.h>
16 #include <AliAnalysisTaskSE.h>
17 class MyAnalysis : public AliAnalysisTaskSE
21 : AliAnalysisTaskSE(), fList(0), fMult(0), fVz(0), fProd(0)
23 MyAnalysis(const char* name)
24 : AliAnalysisTaskSE(name), fList(0), fMult(0), fVz(0), fProd(0)
26 DefineOutput(1, TList::Class());
27 DefineOutput(2, TList::Class()); // For output from Terminate
28 fBranchNames = "AliMultiplicity.,SPDVertex.,PrimaryVertex.";
30 MyAnalysis(const MyAnalysis& o)
31 : AliAnalysisTaskSE(o), fList(o.fList), fMult(o.fMult), fVz(o.fVz)
33 virtual ~MyAnalysis() {}
34 MyAnalysis& operator=(const MyAnalysis&) { return *this; }
35 virtual void UserCreateOutputObjects()
38 fList->SetName("Sums");
41 fMult = new TH2D("mult", "SPD tracklets", 80, -2, 2, 10, -10, 10);
42 fMult->SetXTitle("#eta");
43 fMult->SetYTitle("v_{z} [cm]");
45 fMult->SetDirectory(0); // Disassociate from file
47 fVz = new TH1D("vz", "Interaction point", 10, -10, 10);
48 fVz->SetXTitle("v_{z} [cm]");
50 fVz->SetDirectory(0); // Disassociate from file
57 virtual void UserExec(Option_t* )
60 AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
61 AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
63 Info("", "Got input handler");
64 TList *uiList = inputHandler->GetUserInfo();
66 Info("", "Got user list:");
69 fProd = new AliProdInfo(uiList);
70 Info("", "Lising production information");
76 AliESDEvent* event = dynamic_cast<AliESDEvent*>(InputEvent());
78 if (event->IsPileupFromSPD(3,0.8)) return;
80 const AliESDVertex* vtx = event->GetPrimaryVertexSPD();
81 if (!vtx || !vtx->GetStatus()) return;
82 if (vtx->IsFromVertexerZ() &&
83 (vtx->GetDispersion() > 0.2 || vtx->GetZRes() > 1.25 * 0.2))
86 const AliMultiplicity* mult = event->GetMultiplicity();
89 Double_t vz = vtx->GetZ();
92 Int_t nTracklets = mult->GetNumberOfTracklets();
93 for (Int_t i = 0; i < nTracklets; i++)
94 fMult->Fill(mult->GetEta(i), vz);
98 void Terminate(Option_t *)
100 TList* l = dynamic_cast<TList*>(GetOutputData(1));
102 Warning("Terminate", "No out data # 1 found");
106 TH2D* mult = static_cast<TH2D*>(l->FindObject("mult"));
107 TH1D* vz = static_cast<TH1D*>(l->FindObject("vz"));
109 Warning("Terminate", "Either 'mult' (%p) or 'vz' (%p) or both not found",
114 TList* output = new TList; // Needed for new output from Terminate
115 output->SetName("Results"); // 1st output re-opened read-only
118 TH2D* out = static_cast<TH2D*>(mult->Clone("dndeta"));
119 out->SetTitle("dN_{ch}/d#eta from SPD tracklets per vertex bin");
120 out->SetZTitle("#frac{1}{N}#frac{dN_{ch}}{d#eta}");
121 out->SetDirectory(0); // Disassociate from file
122 Int_t nVz = mult->GetNbinsY();
123 Int_t nEta = mult->GetNbinsX();
124 for (Int_t iVz = 1; iVz <= nVz; iVz++) {
125 Double_t nEv = vz->GetBinContent(iVz);
126 Double_t e1 = vz->GetBinError(iVz);
127 Double_t sca = (nEv == 0 ? 0 : 1. / nEv);
128 for (Int_t iEta = 1; iEta <= nEta; iEta++) {
129 Double_t c = mult->GetBinContent(iEta,iVz);
130 Double_t e = mult->GetBinError(iEta,iVz);
131 Double_t ee = TMath::Sqrt(c*c * e1*e1 + nEv*nEv * e*e) * sca*sca;
132 out->SetBinContent(iEta, iVz, sca * c);
133 out->SetBinError(iEta, iVz, ee);
136 Double_t etaMin = mult->GetXaxis()->GetXmin();
137 Double_t etaMax = mult->GetXaxis()->GetXmax();
138 out->Scale(Double_t(nEta) / (etaMax-etaMin));
148 ClassDef(MyAnalysis, 1);