]>
Commit | Line | Data |
---|---|---|
79ab56b9 | 1 | #include "AlidNdEtaCorrectionSelector.h" |
539b6cb4 | 2 | |
3 | #include <TStyle.h> | |
4 | #include <TSystem.h> | |
5 | #include <TCanvas.h> | |
6 | #include <TParticle.h> | |
7 | #include <TParticlePDG.h> | |
8 | ||
9 | #include <AliLog.h> | |
79ab56b9 | 10 | #include <AliGenEventHeader.h> |
539b6cb4 | 11 | #include <AliTracker.h> |
12 | ||
79ab56b9 | 13 | #include "../esdTrackCuts/AliESDtrackCuts.h" |
14 | #include "dNdEtaCorrection.h" | |
539b6cb4 | 15 | |
79ab56b9 | 16 | ClassImp(AlidNdEtaCorrectionSelector) |
539b6cb4 | 17 | |
79ab56b9 | 18 | AlidNdEtaCorrectionSelector::AlidNdEtaCorrectionSelector(TTree *) : |
539b6cb4 | 19 | AliSelector(), |
20 | fEsdTrackCuts(0), | |
75e130df | 21 | fdNdEtaCorrection(0), |
22 | fdNdEtaCorrectionFinal(0) | |
539b6cb4 | 23 | { |
79ab56b9 | 24 | // |
539b6cb4 | 25 | // Constructor. Initialization of pointers |
79ab56b9 | 26 | // |
539b6cb4 | 27 | } |
28 | ||
79ab56b9 | 29 | AlidNdEtaCorrectionSelector::~AlidNdEtaCorrectionSelector() |
539b6cb4 | 30 | { |
79ab56b9 | 31 | // |
32 | // Destructor | |
33 | // | |
539b6cb4 | 34 | |
35 | // histograms are in the output list and deleted when the output | |
36 | // list is deleted by the TSelector dtor | |
37 | } | |
38 | ||
79ab56b9 | 39 | void AlidNdEtaCorrectionSelector::Begin(TTree * tree) |
539b6cb4 | 40 | { |
41 | // The Begin() function is called at the start of the query. | |
42 | // When running with PROOF Begin() is only called on the client. | |
43 | // The tree argument is deprecated (on PROOF 0 is passed). | |
44 | ||
45 | AliSelector::Begin(tree); | |
539b6cb4 | 46 | } |
47 | ||
79ab56b9 | 48 | void AlidNdEtaCorrectionSelector::SlaveBegin(TTree * tree) |
539b6cb4 | 49 | { |
50 | // The SlaveBegin() function is called after the Begin() function. | |
51 | // When running with PROOF SlaveBegin() is called on each slave server. | |
52 | // The tree argument is deprecated (on PROOF 0 is passed). | |
53 | ||
54 | AliSelector::SlaveBegin(tree); | |
55 | ||
79ab56b9 | 56 | fdNdEtaCorrection = new dNdEtaCorrection(); |
539b6cb4 | 57 | |
79ab56b9 | 58 | if (fChain) |
59 | fEsdTrackCuts = dynamic_cast<AliESDtrackCuts*> (fChain->GetUserInfo()->FindObject("AliESDtrackCuts")); | |
539b6cb4 | 60 | |
79ab56b9 | 61 | if (!fEsdTrackCuts) |
b8e8168f | 62 | AliDebug(AliLog::kError, "ERROR: Could not read EsdTrackCuts from user info"); |
539b6cb4 | 63 | } |
64 | ||
79ab56b9 | 65 | Bool_t AlidNdEtaCorrectionSelector::Notify() |
539b6cb4 | 66 | { |
67 | // The Notify() function is called when a new file is opened. This | |
68 | // can be either for a new TTree in a TChain or when when a new TTree | |
69 | // is started when using PROOF. Typically here the branch pointers | |
70 | // will be retrieved. It is normaly not necessary to make changes | |
71 | // to the generated code, but the routine can be extended by the | |
72 | // user if needed. | |
73 | ||
74 | if (AliSelector::Notify() == kFALSE) | |
75 | return kFALSE; | |
76 | ||
539b6cb4 | 77 | return kTRUE; |
78 | } | |
79 | ||
79ab56b9 | 80 | Bool_t AlidNdEtaCorrectionSelector::Process(Long64_t entry) |
539b6cb4 | 81 | { |
82 | // The Process() function is called for each entry in the tree (or possibly | |
83 | // keyed object in the case of PROOF) to be processed. The entry argument | |
84 | // specifies which entry in the currently loaded tree is to be processed. | |
85 | // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() | |
86 | // to read either all or the required parts of the data. When processing | |
87 | // keyed objects with PROOF, the object is already loaded and is available | |
88 | // via the fObject pointer. | |
89 | // | |
90 | // This function should contain the "body" of the analysis. It can contain | |
91 | // simple or elaborate selection criteria, run algorithms on the data | |
92 | // of the event and typically fill histograms. | |
93 | ||
94 | // WARNING when a selector is used with a TChain, you must use | |
95 | // the pointer to the current TTree to call GetEntry(entry). | |
96 | // The entry is always the local entry number in the current tree. | |
97 | // Assuming that fChain is the pointer to the TChain being processed, | |
98 | // use fChain->GetTree()->GetEntry(entry). | |
99 | ||
100 | if (AliSelector::Process(entry) == kFALSE) | |
101 | return kFALSE; | |
102 | ||
b8e8168f | 103 | // check prerequesites |
104 | if (!fESD) | |
105 | { | |
106 | AliDebug(AliLog::kError, "ESD branch not available"); | |
107 | return kFALSE; | |
108 | } | |
109 | ||
110 | if (!fHeader) | |
111 | { | |
112 | AliDebug(AliLog::kError, "Header branch not available"); | |
113 | return kFALSE; | |
114 | } | |
115 | ||
116 | if (!fEsdTrackCuts) | |
117 | { | |
118 | AliDebug(AliLog::kError, "fESDTrackCuts not available"); | |
539b6cb4 | 119 | return kFALSE; |
b8e8168f | 120 | } |
539b6cb4 | 121 | |
122 | // ######################################################## | |
123 | // get the EDS vertex | |
124 | const AliESDVertex* vtxESD = fESD->GetVertex(); | |
125 | ||
79ab56b9 | 126 | // the vertex should be reconstructed |
127 | if (strcmp(vtxESD->GetName(),"default")==0) | |
128 | return kTRUE; | |
539b6cb4 | 129 | |
79ab56b9 | 130 | Double_t vtx_res[3]; |
539b6cb4 | 131 | vtx_res[0] = vtxESD->GetXRes(); |
132 | vtx_res[1] = vtxESD->GetYRes(); | |
133 | vtx_res[2] = vtxESD->GetZRes(); | |
134 | ||
539b6cb4 | 135 | // the resolution should be reasonable??? |
136 | if (vtx_res[2]==0 || vtx_res[2]>0.1) | |
137 | return kTRUE; | |
138 | ||
139 | // ######################################################## | |
140 | // get the MC vertex | |
79ab56b9 | 141 | AliGenEventHeader* genHeader = fHeader->GenEventHeader(); |
539b6cb4 | 142 | |
143 | TArrayF vtxMC(3); | |
144 | genHeader->PrimaryVertex(vtxMC); | |
539b6cb4 | 145 | |
146 | // ######################################################## | |
147 | // loop over mc particles | |
148 | TTree* particleTree = GetKinematics(); | |
149 | TParticle* particle = 0; | |
150 | particleTree->SetBranchAddress("Particles", &particle); | |
151 | ||
152 | Int_t nPrim = fHeader->GetNprimary(); | |
153 | Int_t nTotal = fHeader->GetNtrack(); | |
154 | ||
155 | for (Int_t i_mc = nTotal - nPrim; i_mc < nTotal; ++i_mc) | |
156 | { | |
157 | particleTree->GetEntry(i_mc); | |
158 | ||
159 | if (!particle) | |
160 | continue; | |
161 | ||
4dd2ad81 | 162 | if (IsPrimaryCharged(particle, nPrim) == kFALSE) |
539b6cb4 | 163 | continue; |
164 | ||
79ab56b9 | 165 | fdNdEtaCorrection->FillGene(vtxMC[2], particle->Eta()); |
539b6cb4 | 166 | }// end of mc particle |
167 | ||
168 | // ######################################################## | |
169 | // loop over esd tracks | |
170 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
171 | for (Int_t t=0; t<nTracks; t++) | |
172 | { | |
173 | AliESDtrack* esdTrack = fESD->GetTrack(t); | |
174 | ||
175 | // cut the esd track? | |
176 | if (!fEsdTrackCuts->AcceptTrack(esdTrack)) | |
177 | continue; | |
178 | ||
539b6cb4 | 179 | // using the eta of the mc particle |
180 | Int_t label = TMath::Abs(esdTrack->GetLabel()); | |
79ab56b9 | 181 | if (label == 0) |
539b6cb4 | 182 | { |
b8e8168f | 183 | AliDebug(AliLog::kWarning, Form("WARNING: cannot find corresponding mc part for track %d.", t)); |
539b6cb4 | 184 | continue; |
185 | } | |
186 | particleTree->GetEntry(nTotal - nPrim + label); | |
187 | ||
79ab56b9 | 188 | fdNdEtaCorrection->FillMeas(vtxMC[2], particle->Eta()); |
539b6cb4 | 189 | |
190 | } // end of track loop | |
191 | ||
192 | return kTRUE; | |
193 | } | |
194 | ||
79ab56b9 | 195 | void AlidNdEtaCorrectionSelector::SlaveTerminate() |
539b6cb4 | 196 | { |
197 | // The SlaveTerminate() function is called after all entries or objects | |
198 | // have been processed. When running with PROOF SlaveTerminate() is called | |
199 | // on each slave server. | |
200 | ||
201 | AliSelector::SlaveTerminate(); | |
202 | ||
203 | // Add the histograms to the output on each slave server | |
204 | if (!fOutput) | |
205 | { | |
b8e8168f | 206 | AliDebug(AliLog::kError, "ERROR: Output list not initialized"); |
539b6cb4 | 207 | return; |
208 | } | |
79ab56b9 | 209 | |
210 | fOutput->Add(fdNdEtaCorrection->GetGeneratedHistogram()); | |
211 | fOutput->Add(fdNdEtaCorrection->GetMeasuredHistogram()); | |
539b6cb4 | 212 | } |
213 | ||
79ab56b9 | 214 | void AlidNdEtaCorrectionSelector::Terminate() |
539b6cb4 | 215 | { |
216 | // The Terminate() function is the last function to be called during | |
217 | // a query. It always runs on the client, it can be used to present | |
218 | // the results graphically or save the results to file. | |
219 | ||
220 | AliSelector::Terminate(); | |
221 | ||
79ab56b9 | 222 | fdNdEtaCorrectionFinal = new dNdEtaCorrection(); |
223 | TH2F* measuredHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("etaVsVtx_meas")); | |
224 | TH2F* generatedHistogram = dynamic_cast<TH2F*> (fOutput->FindObject("etaVsVtx_gene")); | |
225 | if (!measuredHistogram || !generatedHistogram) | |
226 | { | |
b8e8168f | 227 | AliDebug(AliLog::kError, Form("ERROR: Histograms not available %p %p", (void*) generatedHistogram, (void*) measuredHistogram)); |
79ab56b9 | 228 | return; |
229 | } | |
230 | fdNdEtaCorrectionFinal->SetGeneratedHistogram(generatedHistogram); | |
231 | fdNdEtaCorrectionFinal->SetMeasuredHistogram(measuredHistogram); | |
232 | ||
233 | fdNdEtaCorrectionFinal->Finish(); | |
539b6cb4 | 234 | |
235 | TFile* fout = new TFile("correction_map.root","RECREATE"); | |
236 | ||
237 | fEsdTrackCuts->SaveHistograms("esd_track_cuts"); | |
79ab56b9 | 238 | fdNdEtaCorrectionFinal->SaveHistograms(); |
539b6cb4 | 239 | |
240 | fout->Write(); | |
241 | fout->Close(); | |
242 | ||
79ab56b9 | 243 | fdNdEtaCorrectionFinal->DrawHistograms(); |
539b6cb4 | 244 | } |