]>
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> |
a864479b | 28 | #include <AliESDpid.h> |
29 | ||
66ab8ab2 | 30 | #include "AliAnalysisTaskPIDResponse.h" |
31 | ||
66ab8ab2 | 32 | ClassImp(AliAnalysisTaskPIDResponse) |
33 | ||
34 | //______________________________________________________________________________ | |
35 | AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(): | |
36 | AliAnalysisTaskSE(), | |
37 | fIsMC(kFALSE), | |
00a38d07 | 38 | fCachePID(kTRUE), |
67ad8680 | 39 | fOADBPath(), |
66ab8ab2 | 40 | fPIDResponse(0x0), |
66ab8ab2 | 41 | fRun(0), |
42 | fOldRun(0), | |
539a5a59 | 43 | fRecoPass(0), |
44 | fIsTunedOnData(kFALSE), | |
45 | fRecoPassTuned(0) | |
66ab8ab2 | 46 | { |
47 | // | |
48 | // Dummy constructor | |
49 | // | |
50 | } | |
51 | ||
52 | //______________________________________________________________________________ | |
53 | AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name): | |
54 | AliAnalysisTaskSE(name), | |
55 | fIsMC(kFALSE), | |
00a38d07 | 56 | fCachePID(kTRUE), |
67ad8680 | 57 | fOADBPath(), |
66ab8ab2 | 58 | fPIDResponse(0x0), |
66ab8ab2 | 59 | fRun(0), |
60 | fOldRun(0), | |
539a5a59 | 61 | fRecoPass(0), |
62 | fIsTunedOnData(kFALSE), | |
63 | fRecoPassTuned(0) | |
66ab8ab2 | 64 | { |
65 | // | |
66 | // Default constructor | |
67 | // | |
68 | DefineInput(0,TChain::Class()); | |
66ab8ab2 | 69 | } |
70 | ||
71 | //______________________________________________________________________________ | |
72 | AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse() | |
73 | { | |
74 | // | |
75 | // Destructor | |
76 | // | |
66ab8ab2 | 77 | } |
78 | ||
79 | //______________________________________________________________________________ | |
80 | void AliAnalysisTaskPIDResponse::UserCreateOutputObjects() | |
81 | { | |
82 | // | |
83 | // Create the output QA objects | |
84 | // | |
00a38d07 | 85 | |
66ab8ab2 | 86 | AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10); |
00a38d07 | 87 | |
66ab8ab2 | 88 | //input hander |
89 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); | |
90 | AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler()); | |
91 | if (!inputHandler) AliFatal("Input handler needed"); | |
6a45d03f | 92 | |
66ab8ab2 | 93 | //pid response object |
94 | inputHandler->CreatePIDResponse(fIsMC); | |
95 | fPIDResponse=inputHandler->GetPIDResponse(); | |
87977cf5 | 96 | if (!fPIDResponse) AliFatal("PIDResponse object was not created"); |
66ab8ab2 | 97 | |
6a45d03f | 98 | fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath()); |
67ad8680 | 99 | if (!fOADBPath.IsNull()) fPIDResponse->SetOADBPath(fOADBPath.Data()); |
539a5a59 | 100 | |
101 | if(fIsTunedOnData) fPIDResponse->SetTunedOnData(kTRUE,fRecoPassTuned); | |
66ab8ab2 | 102 | } |
103 | ||
66ab8ab2 | 104 | //______________________________________________________________________________ |
105 | void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/) | |
106 | { | |
66ab8ab2 | 107 | // Setup the PID response functions and fill the QA histograms |
108 | // | |
66ab8ab2 | 109 | AliVEvent *event=InputEvent(); |
110 | if (!event) return; | |
111 | fRun=event->GetRunNumber(); | |
6a45d03f | 112 | |
66ab8ab2 | 113 | if (fRun!=fOldRun){ |
6a45d03f | 114 | SetRecoInfo(); |
66ab8ab2 | 115 | fOldRun=fRun; |
116 | } | |
117 | ||
6a45d03f | 118 | fPIDResponse->InitialiseEvent(event,fRecoPass); |
a864479b | 119 | AliESDpid *pidresp = dynamic_cast<AliESDpid*>(fPIDResponse); |
120 | if(pidresp && AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()){ | |
121 | pidresp->SetEventHandler(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); | |
122 | } | |
00a38d07 | 123 | //create and attach transient PID object |
124 | if (fCachePID) { | |
125 | fPIDResponse->FillTrackDetectorPID(); | |
126 | } | |
66ab8ab2 | 127 | } |
128 | ||
66ab8ab2 | 129 | //______________________________________________________________________________ |
130 | void AliAnalysisTaskPIDResponse::SetRecoInfo() | |
131 | { | |
132 | // | |
133 | // Set reconstruction information | |
134 | // | |
135 | ||
136 | //reset information | |
137 | fRecoPass=0; | |
66ab8ab2 | 138 | |
139 | //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... ) | |
140 | AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); | |
141 | AliVEventHandler *inputHandler=mgr->GetInputEventHandler(); | |
142 | if (!inputHandler) return; | |
143 | ||
144 | TTree *tree= (TTree*)inputHandler->GetTree(); | |
145 | TFile *file= (TFile*)tree->GetCurrentFile(); | |
146 | ||
147 | if (!file) { | |
148 | AliError("Current file not found, cannot set reconstruction information"); | |
149 | return; | |
150 | } | |
66ab8ab2 | 151 | |
152 | //find pass from file name (UGLY, but not stored in ESD... ) | |
153 | TString fileName(file->GetName()); | |
5a0aa7cb | 154 | if (fileName.Contains("pass1") ) { |
66ab8ab2 | 155 | fRecoPass=1; |
5a0aa7cb | 156 | } else if (fileName.Contains("pass2") ) { |
66ab8ab2 | 157 | fRecoPass=2; |
5a0aa7cb | 158 | } else if (fileName.Contains("pass3") ) { |
66ab8ab2 | 159 | fRecoPass=3; |
6ca0da23 | 160 | } else if (fileName.Contains("pass4") ) { |
161 | fRecoPass=4; | |
162 | } else if (fileName.Contains("pass5") ) { | |
163 | fRecoPass=5; | |
66ab8ab2 | 164 | } |
67ad8680 | 165 | |
ab4db4eb | 166 | fPIDResponse->SetCurrentFile(fileName.Data()); |
66ab8ab2 | 167 | } |