]>
Commit | Line | Data |
---|---|---|
dc740de4 | 1 | /* $Id$ */ |
2 | ||
3 | #include "AlidNdEtaAnalysisESDSelector.h" | |
4 | ||
5 | #include <TStyle.h> | |
6 | #include <TSystem.h> | |
7 | #include <TCanvas.h> | |
8 | #include <TVector3.h> | |
7029240a | 9 | #include <TChain.h> |
dc740de4 | 10 | |
11 | #include <AliLog.h> | |
fcf2fb36 | 12 | #include <AliESDVertex.h> |
13 | #include <AliESD.h> | |
dc740de4 | 14 | |
15 | #include "esdTrackCuts/AliESDtrackCuts.h" | |
16 | #include "dNdEtaCorrection.h" | |
17 | #include "dNdEtaAnalysis.h" | |
18 | ||
19 | ClassImp(AlidNdEtaAnalysisESDSelector) | |
20 | ||
21 | AlidNdEtaAnalysisESDSelector::AlidNdEtaAnalysisESDSelector() : | |
22 | AlidNdEtaAnalysisSelector(), | |
fcf2fb36 | 23 | fEsdTrackCuts(0) |
dc740de4 | 24 | { |
25 | // | |
26 | // Constructor. Initialization of pointers | |
27 | // | |
28 | } | |
29 | ||
30 | AlidNdEtaAnalysisESDSelector::~AlidNdEtaAnalysisESDSelector() | |
31 | { | |
32 | // | |
33 | // Destructor | |
34 | // | |
35 | ||
36 | // histograms are in the output list and deleted when the output | |
37 | // list is deleted by the TSelector dtor | |
38 | } | |
39 | ||
40 | void AlidNdEtaAnalysisESDSelector::SlaveBegin(TTree * tree) | |
41 | { | |
42 | // The SlaveBegin() function is called after the Begin() function. | |
43 | // When running with PROOF SlaveBegin() is called on each slave server. | |
44 | // The tree argument is deprecated (on PROOF 0 is passed). | |
45 | ||
46 | AlidNdEtaAnalysisSelector::SlaveBegin(tree); | |
47 | ||
48 | if (fChain) | |
49 | { | |
50 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fChain->GetUserInfo()->FindObject("AliESDtrackCuts")); | |
fcf2fb36 | 51 | fdNdEtaCorrection = dynamic_cast<dNdEtaCorrection*> (fChain->GetUserInfo()->FindObject("dndeta_correction")); |
dc740de4 | 52 | } |
53 | ||
54 | if (!fEsdTrackCuts) | |
55 | AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from user info."); | |
56 | ||
fcf2fb36 | 57 | if (!fdNdEtaCorrection) |
dc740de4 | 58 | AliDebug(AliLog::kError, "ERROR: Could not read dNdEtaCorrection from user info."); |
59 | } | |
60 | ||
61 | Bool_t AlidNdEtaAnalysisESDSelector::Process(Long64_t entry) | |
62 | { | |
63 | // The Process() function is called for each entry in the tree (or possibly | |
64 | // keyed object in the case of PROOF) to be processed. The entry argument | |
65 | // specifies which entry in the currently loaded tree is to be processed. | |
66 | // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() | |
67 | // to read either all or the required parts of the data. When processing | |
68 | // keyed objects with PROOF, the object is already loaded and is available | |
69 | // via the fObject pointer. | |
70 | // | |
71 | // This function should contain the "body" of the analysis. It can contain | |
72 | // simple or elaborate selection criteria, run algorithms on the data | |
73 | // of the event and typically fill histograms. | |
74 | ||
75 | // WARNING when a selector is used with a TChain, you must use | |
76 | // the pointer to the current TTree to call GetEntry(entry). | |
77 | // The entry is always the local entry number in the current tree. | |
78 | // Assuming that fChain is the pointer to the TChain being processed, | |
79 | // use fChain->GetTree()->GetEntry(entry). | |
80 | ||
81 | if (AlidNdEtaAnalysisSelector::Process(entry) == kFALSE) | |
82 | return kFALSE; | |
83 | ||
84 | // Check prerequisites | |
85 | if (!fESD) | |
86 | { | |
87 | AliDebug(AliLog::kError, "ESD branch not available"); | |
88 | return kFALSE; | |
89 | } | |
90 | ||
91 | if (!fEsdTrackCuts) | |
92 | { | |
93 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
94 | return kFALSE; | |
95 | } | |
96 | ||
fcf2fb36 | 97 | if (!fdNdEtaCorrection) |
98 | { | |
99 | AliDebug(AliLog::kError, "fdNdEtaCorrection not available"); | |
100 | return kFALSE; | |
101 | } | |
102 | ||
dc740de4 | 103 | // ######################################################## |
104 | // get the EDS vertex | |
105 | const AliESDVertex* vtxESD = fESD->GetVertex(); | |
106 | ||
107 | // the vertex should be reconstructed | |
108 | if (strcmp(vtxESD->GetName(),"default")==0) | |
109 | return kTRUE; | |
110 | ||
111 | Double_t vtx_res[3]; | |
112 | vtx_res[0] = vtxESD->GetXRes(); | |
113 | vtx_res[1] = vtxESD->GetYRes(); | |
114 | vtx_res[2] = vtxESD->GetZRes(); | |
115 | ||
116 | // the resolution should be reasonable??? | |
117 | if (vtx_res[2]==0 || vtx_res[2]>0.1) | |
118 | return kTRUE; | |
119 | ||
120 | Double_t vtx[3]; | |
121 | vtxESD->GetXYZ(vtx); | |
122 | ||
123 | // ######################################################## | |
124 | // loop over esd tracks | |
125 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
126 | for (Int_t t=0; t<nTracks; t++) | |
127 | { | |
128 | AliESDtrack* esdTrack = fESD->GetTrack(t); | |
129 | if (!esdTrack) | |
130 | { | |
131 | AliDebug(AliLog::kError, Form("ERROR: Could not retrieve track %d.", t)); | |
132 | continue; | |
133 | } | |
134 | ||
135 | // cut the esd track? | |
136 | if (!fEsdTrackCuts->AcceptTrack(esdTrack)) | |
137 | continue; | |
138 | ||
139 | Double_t p[3]; | |
140 | esdTrack->GetConstrainedPxPyPz(p); // ### TODO or GetInnerPxPyPy / GetOuterPxPyPy | |
141 | TVector3 vector(p); | |
142 | ||
143 | Float_t theta = vector.Theta(); | |
144 | Float_t eta = -TMath::Log(TMath::Tan(theta/2.)); | |
145 | ||
146 | Float_t correction = fdNdEtaCorrection->GetCorrection(vtx[2], eta); | |
147 | ||
148 | fdNdEtaAnalysis->FillTrack(vtx[2], eta, correction); | |
149 | ||
150 | } // end of track loop | |
151 | ||
152 | // for event count per vertex | |
153 | fdNdEtaAnalysis->FillEvent(vtx[2]); | |
154 | ||
155 | return kTRUE; | |
156 | } | |
157 | ||
158 | void AlidNdEtaAnalysisESDSelector::WriteObjects() | |
159 | { | |
160 | AlidNdEtaAnalysisSelector::WriteObjects(); | |
161 | ||
162 | if (fEsdTrackCuts) | |
163 | fEsdTrackCuts->SaveHistograms("esd_tracks_cuts"); | |
164 | ||
165 | if (fdNdEtaCorrection) | |
166 | fdNdEtaCorrection->SaveHistograms(); | |
167 | } |