]>
Commit | Line | Data |
---|---|---|
6214ec0c | 1 | /************************************************************************* |
2 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // ----------------------------------------------------------------------- | |
17 | // In this analysis task we compare multiple AOD filtermasks. | |
18 | // ----------------------------------------------------------------------- | |
19 | // Author: Misha Veldhoen (misha.veldhoen@cern.ch) | |
20 | ||
21 | #include <iostream> | |
22 | ||
23 | // Basic Includes | |
24 | #include "TH1F.h" | |
25 | #include "TH2F.h" | |
26 | #include "TH3F.h" | |
27 | #include "TFile.h" | |
28 | #include "TFormula.h" | |
29 | #include "TChain.h" | |
30 | #include "TObject.h" | |
31 | #include "TRandom3.h" | |
32 | ||
33 | // Analysis Includes | |
34 | #include "AliAnalysisManager.h" | |
35 | #include "AliAnalysisTaskSE.h" | |
36 | #include "AliInputEventHandler.h" | |
37 | ||
38 | // PID includes. | |
39 | #include "AliPIDResponse.h" | |
40 | ||
41 | // AOD includes. | |
42 | #include "AliAODEvent.h" | |
43 | #include "AliAODTrack.h" | |
44 | #include "AliAODHandler.h" | |
45 | #include "AliAODVertex.h" | |
46 | #include "AliAODInputHandler.h" | |
47 | #include "AliAODMCParticle.h" | |
48 | #include "AliAODMCHeader.h" | |
49 | ||
50 | // Includes from own library | |
51 | #include "AliTrackDiHadronPID.h" | |
52 | #include "AliAODTrackCutsDiHadronPID.h" | |
53 | #include "AliAODEventCutsDiHadronPID.h" | |
54 | ||
55 | // AnalysisTask Header | |
56 | #include "AliAnalysisTaskCompareAODTrackCuts.h" | |
57 | ||
58 | using namespace std; | |
59 | ||
60 | ClassImp(AliAnalysisTaskCompareAODTrackCuts); | |
61 | ||
62 | // ----------------------------------------------------------------------- | |
63 | AliAnalysisTaskCompareAODTrackCuts::AliAnalysisTaskCompareAODTrackCuts(): | |
64 | AliAnalysisTaskSE(), | |
65 | fPIDResponse(0x0), | |
66 | fOutputList(0x0), | |
67 | fIsMC(kFALSE), | |
68 | fVerbose(kFALSE), | |
69 | fCalculateTOFMismatch(kFALSE), | |
28161374 | 70 | fUseMismatchFileFromHomeDir(kTRUE), |
71 | fUseNSigmaOnPIDAxes(kFALSE), | |
6214ec0c | 72 | fEventCuts(0x0), |
73 | fTrackCuts(0x0), | |
74 | fInclusiveTimes(0x0), | |
6214ec0c | 75 | fT0Fill(0x0), |
76 | fLvsEta(0x0), | |
a5422983 | 77 | fGlobalPtvsTPCPt(0x0), |
69868b6b | 78 | fLvsEtaProjections(0x0), |
6214ec0c | 79 | fCurrentAODEvent(0x0), |
80 | fCurrentAODTrack(0x0), | |
81 | fCurrentDiHadronPIDTrack(0x0), | |
82 | fGlobalTracksArray(0x0) | |
83 | ||
84 | { | |
85 | ||
86 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
87 | ||
6214ec0c | 88 | } |
89 | ||
90 | // ----------------------------------------------------------------------- | |
91 | AliAnalysisTaskCompareAODTrackCuts::AliAnalysisTaskCompareAODTrackCuts(const char* name): | |
92 | AliAnalysisTaskSE(name), | |
93 | fPIDResponse(0x0), | |
94 | fOutputList(0x0), | |
95 | fIsMC(kFALSE), | |
96 | fVerbose(kFALSE), | |
97 | fCalculateTOFMismatch(kFALSE), | |
a5422983 | 98 | fUseMismatchFileFromHomeDir(kTRUE), |
28161374 | 99 | fUseNSigmaOnPIDAxes(kFALSE), |
6214ec0c | 100 | fEventCuts(0x0), |
101 | fTrackCuts(0x0), | |
102 | fInclusiveTimes(0x0), | |
6214ec0c | 103 | fT0Fill(0x0), |
104 | fLvsEta(0x0), | |
a5422983 | 105 | fGlobalPtvsTPCPt(0x0), |
69868b6b | 106 | fLvsEtaProjections(0x0), |
6214ec0c | 107 | fCurrentAODEvent(0x0), |
108 | fCurrentAODTrack(0x0), | |
109 | fCurrentDiHadronPIDTrack(0x0), | |
110 | fGlobalTracksArray(0x0) | |
111 | ||
112 | { | |
113 | ||
114 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
115 | ||
116 | // Named Constructor. | |
117 | fTrackCuts = new TObjArray(); | |
118 | fTrackCuts->SetName("fTrackCuts"); | |
119 | ||
6214ec0c | 120 | DefineInput(0,TChain::Class()); |
121 | DefineOutput(1, TList::Class()); | |
122 | ||
123 | } | |
124 | ||
125 | // ----------------------------------------------------------------------- | |
126 | AliAnalysisTaskCompareAODTrackCuts::~AliAnalysisTaskCompareAODTrackCuts() { | |
127 | ||
128 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
129 | ||
130 | } | |
131 | ||
132 | // ----------------------------------------------------------------------- | |
133 | void AliAnalysisTaskCompareAODTrackCuts::UserCreateOutputObjects() { | |
134 | ||
135 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
136 | ||
137 | // Getting a pointer to the analysis manager and input handler. | |
138 | AliAnalysisManager* manager = AliAnalysisManager::GetAnalysisManager(); | |
69868b6b | 139 | if (!manager) {AliFatal("Could not obtain analysis manager.");} |
6214ec0c | 140 | AliInputEventHandler* inputHandler = dynamic_cast<AliInputEventHandler*> (manager->GetInputEventHandler()); |
b4a7e39a | 141 | if (!inputHandler) {AliFatal("Could not obtain input handler."); return;} |
69868b6b | 142 | |
6214ec0c | 143 | // Getting the pointer to the PID response object. |
144 | fPIDResponse = inputHandler->GetPIDResponse(); | |
b4a7e39a | 145 | if (!fPIDResponse) {AliFatal("Could not obtain PID response."); return;} |
6214ec0c | 146 | |
147 | // Create the output list. | |
148 | fOutputList = new TList(); | |
149 | fOutputList->SetOwner(kTRUE); | |
150 | ||
151 | // Adding Event Cuts to the output. | |
152 | fEventCuts->CreateHistos(); // Generating all requested histograms. | |
153 | fOutputList->Add(fEventCuts); | |
154 | ||
155 | // Adding Track Cuts to the output. | |
156 | for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) { | |
157 | AliAODTrackCutsDiHadronPID* currentcuts = (AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts); | |
158 | currentcuts->CreateHistos(); // Generating all requested histograms. | |
159 | fOutputList->Add(currentcuts); | |
160 | } | |
161 | ||
162 | // Creating inclusive times histogram. | |
163 | fInclusiveTimes = new TH2F("fInclusiveTimes","Inclusive Times;#eta;t (ps)",100,0,1.,1500,10000.,25000.); | |
164 | fOutputList->Add(fInclusiveTimes); | |
165 | ||
a5422983 | 166 | // Create the diagram correlating TPC and Global transverse momenta. |
167 | fGlobalPtvsTPCPt = new TH2F("fGlobalPtvsTPCPt","Global p_{T} vs TPC p_{T}; Global p_{T}; TPC p_{T}",100,0,10,100,0,10); | |
168 | fOutputList->Add(fGlobalPtvsTPCPt); | |
169 | ||
6214ec0c | 170 | // Creating Global Tracks Array |
171 | fGlobalTracksArray = new TObjArray(); | |
172 | ||
173 | // Loading the appropriate external mismatch histograms. | |
a5422983 | 174 | if (fCalculateTOFMismatch) LoadExternalMismatchHistos(); |
6214ec0c | 175 | |
176 | PostData(1,fOutputList); | |
177 | ||
178 | } | |
179 | ||
180 | // ----------------------------------------------------------------------- | |
181 | void AliAnalysisTaskCompareAODTrackCuts::FillGlobalTracksArray() { | |
182 | ||
183 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
184 | ||
185 | // Initialize the mapping for corresponding PID tracks. | |
186 | // See AliAnalysisTaskESDFilter.cxx for explanation about the mapping | |
187 | // between TPC-Only and Global tracks | |
188 | ||
189 | // Create TObjArray for Global Tracks. | |
190 | ||
191 | //cout<<"Global Tracks Array: "<<fGlobalTracksArray<<endl; | |
192 | ||
193 | // Clear previous tracks... | |
194 | fGlobalTracksArray->Clear(); | |
195 | ||
196 | //if (fGlobalTracksArray) delete fGlobalTracksArray; | |
197 | //fGlobalTracksArray = new TObjArray(); | |
198 | ||
199 | AliAODTrack* track = 0x0; | |
200 | ||
201 | for (Int_t iTrack = 0; iTrack < fCurrentAODEvent->GetNumberOfTracks(); iTrack++) { | |
202 | ||
203 | track = fCurrentAODEvent->GetTrack(iTrack); | |
204 | if (track->GetID()>-1) fGlobalTracksArray->AddAtAndExpand(track,track->GetID()); | |
205 | } | |
206 | ||
207 | } | |
208 | ||
209 | // ----------------------------------------------------------------------- | |
210 | AliAODTrack* AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack(AliAODTrack* track) { | |
211 | ||
212 | // Returns Global Track corresponding to a TPC-Only Track. | |
213 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
214 | ||
215 | if (track->GetID() >= 0) { | |
216 | cout<<"AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack -> Input Track is not TPC-Only."<<endl; | |
217 | return 0x0; | |
218 | } | |
219 | ||
220 | if (!fGlobalTracksArray) { | |
221 | cout<<"AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack -> Global Tracks Array Does not Exist."<<endl; | |
222 | return 0x0; | |
223 | } | |
224 | ||
225 | AliAODTrack* globaltrack = (AliAODTrack*)(fGlobalTracksArray->At(-track->GetID()-1)); | |
226 | if (!globaltrack) { | |
227 | cout<<"AliAnalysisTaskCompareAODTrackCuts::GetGlobalTrack -> No Global Track Found."<<endl; | |
228 | return 0x0; | |
229 | } | |
230 | ||
231 | return globaltrack; | |
232 | ||
233 | } | |
234 | ||
235 | // ----------------------------------------------------------------------- | |
236 | void AliAnalysisTaskCompareAODTrackCuts::UserExec(Option_t*) { | |
237 | ||
238 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
a5422983 | 239 | Int_t nmismatched = 0; |
240 | Int_t nmatched = 0; | |
241 | Int_t nnotof = 0; | |
6214ec0c | 242 | // Input Current Event. |
243 | fCurrentAODEvent = dynamic_cast<AliAODEvent*>(InputEvent()); | |
244 | if (!fCurrentAODEvent) { | |
245 | cout<<"AliAnalysisTaskCompareAODTrackCuts::UserExec -> AOD Event not found."<<endl; | |
246 | return; | |
247 | } | |
248 | ||
249 | // Check Event Cuts Object. | |
250 | if (!fEventCuts) AliFatal("No Event Cuts Object Found!"); | |
251 | ||
252 | // Perform Event Cuts. | |
253 | if (!fEventCuts->IsSelected(fCurrentAODEvent)) {return;} | |
254 | ||
255 | // Check Track Cuts Array. | |
256 | if (!fTrackCuts) AliFatal("No Track Cuts Array Found!"); | |
257 | if (fTrackCuts->GetEntries() == 0) AliFatal("Track Cuts Array is Empty!"); | |
258 | ||
259 | // If MC, then fill MC reconstructed QA histograms. | |
260 | TClonesArray* mcArray = 0x0; | |
261 | TObjArray* mcArrayLabel = 0x0; | |
262 | if (fIsMC) { | |
263 | ||
264 | mcArray = dynamic_cast<TClonesArray*>(fCurrentAODEvent->FindListObject(AliAODMCParticle::StdBranchName())); | |
265 | if (!mcArray) { | |
266 | AliFatal("No MC array found in the AOD."); | |
267 | return; | |
268 | } | |
269 | ||
270 | mcArrayLabel = new TObjArray(10000); | |
271 | ||
272 | // Loop over MC particles. | |
273 | for (Int_t iParticle = 0; iParticle < mcArray->GetEntriesFast(); iParticle++) { | |
274 | ||
275 | // Put the MC Particle in the Label array. | |
276 | AliAODMCParticle* CurrentAODMCParticle = (AliAODMCParticle*) mcArray->At(iParticle); | |
a5422983 | 277 | //cout << "PR: " << CurrentAODMCParticle->IsPhysicalPrimary() << " SW: " << CurrentAODMCParticle->IsSecondaryFromWeakDecay() << " SM: " << CurrentAODMCParticle->IsSecondaryFromMaterial() << endl; |
6214ec0c | 278 | mcArrayLabel->AddAtAndExpand(CurrentAODMCParticle,CurrentAODMCParticle->Label()); |
279 | //cout<<"Index: "<<iParticle<<" Label: "<<CurrentAODMCParticle->Label()<<endl; | |
280 | ||
281 | //if (CurrentAODMCParticle->Label()!=iParticle) cout<<"Index unequal to particle's label!"<<endl; | |
282 | ||
283 | // Loop over all Track Cuts. | |
284 | for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) { | |
285 | ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->IsSelectedGeneratedMC(CurrentAODMCParticle); | |
286 | } | |
287 | } | |
288 | } | |
289 | ||
290 | //for (Int_t ii=0; ii<200; ii++) cout<<fLvsEtaProj[ii]<<endl; | |
291 | ||
292 | // Create mapping to Global Tracks. | |
293 | FillGlobalTracksArray(); | |
294 | ||
295 | // Tell the track cuts object that a new event has started. | |
296 | for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) { | |
297 | AliAODTrackCutsDiHadronPID* currentcuts = (AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts); | |
298 | if (fVerbose) AliInfo(Form("Starting new event for cuts: %s",currentcuts->GetName())); | |
299 | currentcuts->StartNewEvent(); | |
300 | } | |
301 | ||
302 | // Loop over all reconstructed tracks. | |
303 | for (Int_t iTrack = 0; iTrack < fCurrentAODEvent->GetNumberOfTracks(); iTrack++) { | |
304 | ||
305 | // Get the Current Track. | |
306 | fCurrentAODTrack = (AliAODTrack*)fCurrentAODEvent->GetTrack(iTrack); | |
307 | if (!fCurrentAODTrack) { | |
308 | cout<<"AliAnalysisTaskCompareAODTrackCuts::UserExec -> AOD Track not found."<<endl; | |
309 | continue; | |
310 | } | |
311 | ||
312 | // Ignore muon tracks. | |
313 | if (fCurrentAODTrack->IsMuonTrack()) {continue;} | |
314 | ||
315 | // Copy Track info into AliTrackDiHadronPID object. | |
316 | fCurrentDiHadronPIDTrack = 0x0; | |
317 | ||
318 | // Check if we can indeed find a MC particle corresponding to the reconstructed track. | |
319 | /* | |
320 | AliAODMCParticle* MCparticleCheck = (AliAODMCParticle*)mcArrayLabel->At(TMath::Abs(fCurrentAODTrack->GetLabel())); | |
321 | Double_t MCPt1 = -999.; | |
322 | if (MCparticleCheck) MCPt1 = MCparticleCheck->Pt(); | |
323 | AliAODMCParticle* MCparticleCheck2 = (AliAODMCParticle*)mcArray->At(TMath::Abs(fCurrentAODTrack->GetLabel())); | |
324 | Double_t MCPt2 = -999.; | |
325 | if (MCparticleCheck2) MCPt2 = MCparticleCheck2->Pt(); | |
326 | ||
327 | cout<<"AOD track abs label: "<<TMath::Abs(fCurrentAODTrack->GetLabel())<<" MC particle with same label found: "<<(Bool_t)MCparticleCheck<<" and with same index: "<<(Bool_t)MCparticleCheck2<<endl; | |
328 | cout<<"AOD track pt: "<<fCurrentAODTrack->Pt()<<" same label pt: "<<MCPt1<<" same index pt: "<<MCPt2<<endl; | |
329 | //if (!MCparticleCheck) cout<<"MC Particle for a reconstructed track not found."<<endl; | |
330 | */ | |
331 | // Check if it's a TPC-Only or Global Track. | |
332 | if (fCurrentAODTrack->GetID() < 0) { | |
333 | // Q: Do we really need to create the arraylabel object or is the original MC array already nicely ordered. (NOTE THAT WE TAKE THE MC PARTICLES FROM THE mcArray) | |
334 | if (fIsMC) fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,GetGlobalTrack(fCurrentAODTrack),(AliAODMCParticle*)mcArray->At(TMath::Abs(fCurrentAODTrack->GetLabel())),fPIDResponse); | |
335 | else fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,GetGlobalTrack(fCurrentAODTrack),0x0,fPIDResponse); | |
a5422983 | 336 | |
337 | // Fill histogram of Global p_T vs TPC-only p_T | |
338 | fGlobalPtvsTPCPt->Fill(GetGlobalTrack(fCurrentAODTrack)->Pt(), fCurrentAODTrack->Pt()); | |
339 | ||
6214ec0c | 340 | } else { |
341 | if (fIsMC) fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,0x0,(AliAODMCParticle*)mcArray->At(TMath::Abs(fCurrentAODTrack->GetLabel())),fPIDResponse); | |
342 | else fCurrentDiHadronPIDTrack = new AliTrackDiHadronPID(fCurrentAODTrack,0x0,0x0,fPIDResponse); | |
343 | } | |
344 | ||
345 | if (!fCurrentDiHadronPIDTrack) { | |
346 | cout<<"AliAnalysisTaskCompareAODTrackCuts::UserExec -> Copying to DiHadronPIDTrack failed."<<endl; | |
347 | continue; | |
348 | } | |
349 | ||
350 | // Filling random times histogram: | |
351 | ULong_t requestedflags = (UInt_t)(AliAODTrack::kTOFout)|(UInt_t)(AliAODTrack::kTIME); | |
352 | ULong_t trackflags = fCurrentDiHadronPIDTrack->GetFlags(); | |
353 | if (requestedflags&trackflags) {fInclusiveTimes->Fill(TMath::Abs(fCurrentDiHadronPIDTrack->Eta()),fCurrentDiHadronPIDTrack->GetTOFsignal());} | |
354 | ||
355 | Double_t rndhittime = -1.e21; | |
a5422983 | 356 | if (fCalculateTOFMismatch) rndhittime = GenerateRandomHit(fCurrentDiHadronPIDTrack->Eta()); |
6214ec0c | 357 | |
358 | // Loop over all Track Cuts. | |
359 | for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) { | |
360 | if (fIsMC) ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->IsSelectedReconstructedMC(fCurrentDiHadronPIDTrack); | |
361 | else ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->IsSelectedData(fCurrentDiHadronPIDTrack,rndhittime); | |
362 | } | |
363 | ||
a5422983 | 364 | Int_t tofmatchstat = fCurrentDiHadronPIDTrack->GetTOFMatchingStatus(); |
365 | if (tofmatchstat==0) {nmatched++;} | |
366 | if (tofmatchstat==1) {nmismatched++;} | |
367 | if (tofmatchstat==2) {nnotof++;} | |
368 | ||
6214ec0c | 369 | // Delete Current DiHadronPIDTrack. |
370 | delete fCurrentDiHadronPIDTrack; | |
371 | fCurrentDiHadronPIDTrack = 0x0; | |
372 | ||
373 | } | |
374 | ||
375 | // Tell the track cuts object that the event has been processed. | |
376 | for (Int_t iCuts = 0; iCuts < fTrackCuts->GetEntries(); iCuts++) { | |
377 | ((AliAODTrackCutsDiHadronPID*)fTrackCuts->At(iCuts))->EventIsDone(fIsMC); | |
378 | } | |
379 | ||
28161374 | 380 | //cout << "Matched: "<<nmatched<<" Mismatched: "<<nmismatched<<" No TOF hit: "<<nnotof<<endl; |
a5422983 | 381 | |
6214ec0c | 382 | PostData(1,fOutputList); |
383 | ||
384 | } | |
385 | ||
386 | // ----------------------------------------------------------------------- | |
a5422983 | 387 | Bool_t AliAnalysisTaskCompareAODTrackCuts::LoadExternalMismatchHistos() { |
6214ec0c | 388 | |
69868b6b | 389 | // |
390 | // Attempting to load a root file containing information needed | |
391 | // to generate random TOF hits. | |
392 | // | |
6214ec0c | 393 | |
69868b6b | 394 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} |
6214ec0c | 395 | |
69868b6b | 396 | // Opening external TOF file. |
69868b6b | 397 | TFile* fin = 0x0; |
a5422983 | 398 | |
399 | // The default is that the file TOFmismatchHistos.root is taken from the /rootfiles/ directory, | |
400 | // and this works fine when running on the train. When the user submits the jobs himself, he can | |
401 | // choose to not take the file from the home dir, but upload one along with the source code. | |
402 | // If in this case the file is not found, the program tries to get the file from the root directory | |
403 | // anyway. | |
404 | if (fUseMismatchFileFromHomeDir == kFALSE) { | |
405 | fin = TFile::Open("TOFmismatchHistos.root"); | |
406 | if (!fin) {AliWarning("Tried to open uploaded TOFmismatchHistos.root, but failed");} | |
407 | } | |
408 | ||
409 | if (!fin) {fin = TFile::Open("alien:///alice/cern.ch/user/m/mveldhoe/rootfiles/TOFmismatchHistos.root");} | |
410 | ||
69868b6b | 411 | if (!fin) { |
a5422983 | 412 | AliWarning("Couln't open TOFmismatchHistos.root, will not calculate mismatches..."); |
69868b6b | 413 | fCalculateTOFMismatch = kFALSE; |
414 | return kFALSE; | |
a5422983 | 415 | } else { |
416 | AliInfo("Sucessfully loaded TOFmismatchHistos.root"); | |
6214ec0c | 417 | } |
418 | ||
69868b6b | 419 | // Check if the required histograms are present. |
420 | TH1F* tmp1 = (TH1F*)fin->Get("hNewT0Fill"); | |
421 | if (!tmp1) { | |
422 | AliWarning("Couln't find hNewT0Fill, will not calculate mismatches..."); | |
423 | fCalculateTOFMismatch = kFALSE; | |
424 | return kFALSE; | |
425 | } | |
426 | TH2F* tmp2 = (TH2F*)fin->Get("hLvsEta"); | |
427 | if (!tmp2) { | |
428 | AliWarning("Couln't find hLvsEta, will not calculate mismatches..."); | |
429 | fCalculateTOFMismatch = kFALSE; | |
430 | return kFALSE; | |
431 | } | |
432 | ||
433 | // Make a deep copy of the files in the histogram. | |
434 | fT0Fill = (TH1F*)tmp1->Clone("fT0Fill"); | |
435 | fLvsEta = (TH2F*)tmp2->Clone("fLvsEta"); | |
436 | ||
437 | // Close the external file. | |
438 | AliInfo("Closing external file."); | |
439 | fin->Close(); | |
440 | ||
441 | // Creating a TObjArray for LvsEta projections. | |
442 | const Int_t nbinseta = fLvsEta->GetNbinsX(); | |
443 | fLvsEtaProjections = new TObjArray(nbinseta); | |
444 | fLvsEtaProjections->SetOwner(kTRUE); | |
445 | ||
446 | // Making the projections needed (excluding underflow/ overflow). | |
447 | for (Int_t iEtaBin = 1; iEtaBin < (nbinseta + 1); iEtaBin++) { | |
448 | TH1F* tmp = (TH1F*)fLvsEta->ProjectionY(Form("LvsEtaProjection_%i",iEtaBin),iEtaBin,iEtaBin); | |
449 | tmp->SetDirectory(0); | |
450 | fLvsEtaProjections->AddAt(tmp,iEtaBin - 1); | |
6214ec0c | 451 | } |
452 | ||
69868b6b | 453 | return kTRUE; |
6214ec0c | 454 | |
455 | } | |
456 | ||
457 | // ----------------------------------------------------------------------- | |
a5422983 | 458 | Double_t AliAnalysisTaskCompareAODTrackCuts::GenerateRandomHit(Double_t eta) { |
6214ec0c | 459 | |
69868b6b | 460 | // |
461 | // Returns a random TOF time. | |
462 | // | |
6214ec0c | 463 | |
464 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
465 | ||
69868b6b | 466 | // Default (error) value: |
6214ec0c | 467 | Double_t rndhittime = -1.e21; |
468 | ||
69868b6b | 469 | // TOF mismatch flag is not turned on. |
470 | if (!fCalculateTOFMismatch) { | |
471 | AliFatal("Called GenerateRandomHit() method, but flag fCalculateTOFMismatch not set."); | |
472 | return rndhittime; | |
473 | } | |
6214ec0c | 474 | |
69868b6b | 475 | // TOF doesn't extend much further than 0.8. |
476 | if (TMath::Abs(eta) > 0.8) { | |
477 | if (fDebug) {AliInfo("Tried to get a random hit for a track with eta > 0.8.");} | |
478 | return rndhittime; | |
479 | } | |
6214ec0c | 480 | |
69868b6b | 481 | // Finding the bin of the eta. |
482 | TAxis* etaAxis = fLvsEta->GetXaxis(); | |
483 | Int_t etaBin = etaAxis->FindBin(eta); | |
484 | if (etaBin == 0 || (etaBin == etaAxis->GetNbins() + 1)) {return rndhittime;} | |
6214ec0c | 485 | |
69868b6b | 486 | const TH1F* lengthDistribution = (const TH1F*)fLvsEtaProjections->At(etaBin - 1); |
6214ec0c | 487 | |
69868b6b | 488 | if (!lengthDistribution) { |
489 | AliFatal("length Distribution not found."); | |
490 | return rndhittime; | |
6214ec0c | 491 | } |
492 | ||
69868b6b | 493 | Double_t currentRndLength = lengthDistribution->GetRandom(); // in cm. |
494 | ||
495 | // Similar to Roberto's code. | |
496 | Double_t currentRndTime = currentRndLength / (TMath::C() * 1.e2 / 1.e12); | |
497 | Double_t t0fill = -1.26416e+04; | |
498 | rndhittime = fT0Fill->GetRandom() - t0fill + currentRndTime; | |
6214ec0c | 499 | |
500 | return rndhittime; | |
501 | ||
502 | } | |
503 | ||
28161374 | 504 | // ----------------------------------------------------------------------- |
505 | void AliAnalysisTaskCompareAODTrackCuts::SetUseNSigmaOnPIDAxes(const Bool_t UseNSigma) { | |
506 | ||
507 | // Will use NSigma on all PID axes. Will also change all track cuts objects | |
508 | // owned by this task. | |
509 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
510 | ||
511 | fUseNSigmaOnPIDAxes = UseNSigma; | |
512 | ||
513 | if (fTrackCuts) { | |
514 | for (Int_t iCut = 0; iCut < fTrackCuts->GetSize(); ++iCut) { | |
515 | AliAODTrackCutsDiHadronPID* cutstmp = (AliAODTrackCutsDiHadronPID*)(fTrackCuts->At(iCut)); | |
516 | if (cutstmp) {cutstmp->SetUseNSigmaOnPIDAxes(UseNSigma);} | |
517 | else {cout << Form("%s -> WARNING: Found an empty spot in the track cuts array...",__func__) << endl;} | |
518 | } | |
519 | } | |
520 | } | |
521 | ||
522 | // ----------------------------------------------------------------------- | |
523 | void AliAnalysisTaskCompareAODTrackCuts::SetEventCuts(AliAODEventCutsDiHadronPID* eventcuts) { | |
524 | ||
525 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
526 | if (!eventcuts) {cout << Form("%s -> ERROR: No Event Cuts Object provided.",__func__) << endl; return;} | |
527 | ||
528 | fEventCuts = eventcuts; | |
529 | ||
530 | } | |
531 | ||
532 | // ----------------------------------------------------------------------- | |
533 | void AliAnalysisTaskCompareAODTrackCuts::AddTrackCuts(AliAODTrackCutsDiHadronPID* trackcuts) { | |
534 | ||
535 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
536 | if (!trackcuts) {cout << Form("%s -> ERROR: No Track Cuts Object provided.",__func__) << endl; return;} | |
537 | if (!fTrackCuts) {cout << Form("%s -> ERROR: No Track Cuts array available.",__func__) << endl; return;} | |
538 | ||
539 | // The setting of the task propagates to the imported track cuts object. | |
540 | trackcuts->SetUseNSigmaOnPIDAxes(fUseNSigmaOnPIDAxes); | |
541 | ||
542 | fTrackCuts->AddLast(trackcuts); | |
543 | ||
544 | } | |
545 | ||
a5422983 | 546 | // ----------------------------------------------------------------------- |
547 | void AliAnalysisTaskCompareAODTrackCuts::SetDebugLevel(const Int_t debuglvl) { | |
548 | ||
549 | // Sets debug level to a certain value, as well as the debug level of the | |
550 | // track cuts objects and event cut object. | |
551 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
552 | ||
553 | fDebug = debuglvl; | |
554 | ||
555 | if (fEventCuts) {fEventCuts->SetDebugLevel(debuglvl);} | |
556 | ||
557 | if (fTrackCuts) { | |
558 | for (Int_t iTrackCutObj = 0; iTrackCutObj < fTrackCuts->GetEntriesFast(); ++iTrackCutObj) { | |
559 | ((AliTrackDiHadronPID*)fTrackCuts->At(iTrackCutObj))->SetDebugLevel(debuglvl); | |
560 | } | |
561 | } | |
562 | ||
563 | } | |
564 | ||
6214ec0c | 565 | // ----------------------------------------------------------------------- |
566 | void AliAnalysisTaskCompareAODTrackCuts::Terminate(Option_t*) { | |
567 | ||
568 | if (fDebug > 0) {cout << Form("File: %s, Line: %i, Function: %s",__FILE__,__LINE__,__func__) << endl;} | |
569 | ||
69868b6b | 570 | if (fCalculateTOFMismatch) { |
571 | delete fT0Fill; | |
572 | fT0Fill = 0x0; | |
573 | delete fLvsEta; | |
574 | fLvsEta = 0x0; | |
575 | delete fLvsEtaProjections; | |
576 | fLvsEtaProjections = 0x0; | |
577 | } | |
6214ec0c | 578 | |
579 | } | |
580 | ||
a6ddcd76 | 581 | // ----------------------------------------------------------------------- |