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