]>
Commit | Line | Data |
---|---|---|
66ab8ab2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | /* $Id: AliAnalysisTaskPIDResponse.cxx 43811 2010-09-23 14:13:31Z wiechula $ */ | |
66ab8ab2 | 17 | #include <TFile.h> |
66ab8ab2 | 18 | #include <TChain.h> |
19 | ||
20 | #include <AliAnalysisManager.h> | |
21 | #include <AliInputEventHandler.h> | |
22 | #include <AliVEventHandler.h> | |
23 | #include <AliVEvent.h> | |
24 | #include <AliVParticle.h> | |
25 | #include <AliVTrack.h> | |
26 | #include <AliLog.h> | |
66ab8ab2 | 27 | #include <AliPIDResponse.h> |
66ab8ab2 | 28 | |
29 | #include "AliAnalysisTaskPIDResponse.h" | |
30 | ||
66ab8ab2 | 31 | ClassImp(AliAnalysisTaskPIDResponse) |
32 | ||
33 | //______________________________________________________________________________ | |
34 | AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(): | |
35 | AliAnalysisTaskSE(), | |
36 | fIsMC(kFALSE), | |
66ab8ab2 | 37 | fPIDResponse(0x0), |
66ab8ab2 | 38 | fRun(0), |
39 | fOldRun(0), | |
6a45d03f | 40 | fRecoPass(0) |
66ab8ab2 | 41 | { |
42 | // | |
43 | // Dummy constructor | |
44 | // | |
45 | } | |
46 | ||
47 | //______________________________________________________________________________ | |
48 | AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name): | |
49 | AliAnalysisTaskSE(name), | |
50 | fIsMC(kFALSE), | |
66ab8ab2 | 51 | fPIDResponse(0x0), |
66ab8ab2 | 52 | fRun(0), |
53 | fOldRun(0), | |
6a45d03f | 54 | fRecoPass(0) |
66ab8ab2 | 55 | { |
56 | // | |
57 | // Default constructor | |
58 | // | |
59 | DefineInput(0,TChain::Class()); | |
66ab8ab2 | 60 | } |
61 | ||
62 | //______________________________________________________________________________ | |
63 | AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse() | |
64 | { | |
65 | // | |
66 | // Destructor | |
67 | // | |
66ab8ab2 | 68 | } |
69 | ||
70 | //______________________________________________________________________________ | |
71 | void AliAnalysisTaskPIDResponse::UserCreateOutputObjects() | |
72 | { | |
73 | // | |
74 | // Create the output QA objects | |
75 | // | |
6a45d03f | 76 | |
66ab8ab2 | 77 | AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10); |
6a45d03f | 78 | |
66ab8ab2 | 79 | //input hander |
80 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); | |
81 | AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler()); | |
82 | if (!inputHandler) AliFatal("Input handler needed"); | |
6a45d03f | 83 | |
66ab8ab2 | 84 | //pid response object |
85 | inputHandler->CreatePIDResponse(fIsMC); | |
86 | fPIDResponse=inputHandler->GetPIDResponse(); | |
87977cf5 | 87 | if (!fPIDResponse) AliFatal("PIDResponse object was not created"); |
66ab8ab2 | 88 | |
6a45d03f | 89 | fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath()); |
66ab8ab2 | 90 | } |
91 | ||
66ab8ab2 | 92 | //______________________________________________________________________________ |
93 | void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/) | |
94 | { | |
95 | // | |
96 | // Setup the PID response functions and fill the QA histograms | |
97 | // | |
66ab8ab2 | 98 | AliVEvent *event=InputEvent(); |
99 | if (!event) return; | |
100 | fRun=event->GetRunNumber(); | |
6a45d03f | 101 | |
66ab8ab2 | 102 | if (fRun!=fOldRun){ |
6a45d03f | 103 | SetRecoInfo(); |
66ab8ab2 | 104 | fOldRun=fRun; |
105 | } | |
106 | ||
6a45d03f | 107 | fPIDResponse->InitialiseEvent(event,fRecoPass); |
66ab8ab2 | 108 | } |
109 | ||
66ab8ab2 | 110 | //______________________________________________________________________________ |
111 | void AliAnalysisTaskPIDResponse::SetRecoInfo() | |
112 | { | |
113 | // | |
114 | // Set reconstruction information | |
115 | // | |
116 | ||
117 | //reset information | |
118 | fRecoPass=0; | |
66ab8ab2 | 119 | |
120 | //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... ) | |
121 | AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); | |
122 | AliVEventHandler *inputHandler=mgr->GetInputEventHandler(); | |
123 | if (!inputHandler) return; | |
124 | ||
125 | TTree *tree= (TTree*)inputHandler->GetTree(); | |
126 | TFile *file= (TFile*)tree->GetCurrentFile(); | |
127 | ||
128 | if (!file) { | |
129 | AliError("Current file not found, cannot set reconstruction information"); | |
130 | return; | |
131 | } | |
66ab8ab2 | 132 | |
133 | //find pass from file name (UGLY, but not stored in ESD... ) | |
134 | TString fileName(file->GetName()); | |
135 | if (fileName.Contains("/pass1")) { | |
136 | fRecoPass=1; | |
137 | } else if (fileName.Contains("/pass2")) { | |
138 | fRecoPass=2; | |
139 | } else if (fileName.Contains("/pass3")) { | |
140 | fRecoPass=3; | |
141 | } | |
142 | ||
143 | } |