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