Line data Source code
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: AliPIDResponseInputHandler 46193 2010-12-21 09:00:14Z wiechula $ */
17 :
18 : //-----------------------------------------------------------------
19 : // Handler to set up the PID response object and
20 : // initialise it correctly for each event
21 : //
22 : // Origin:
23 : // Jens Wiechula (jens.wiechula@cern.ch)
24 : // Martin Vala (martin.vala@cern.ch)
25 :
26 : //-----------------------------------------------------------------
27 :
28 :
29 : #include <TFile.h>
30 : #include <TPRegexp.h>
31 :
32 : #include <AliLog.h>
33 : #include <AliVEvent.h>
34 : #include "AliAnalysisManager.h"
35 : #include "AliMultiInputEventHandler.h"
36 : #include "AliPIDResponse.h"
37 :
38 : #include "AliPIDResponseInputHandler.h"
39 :
40 :
41 170 : ClassImp(AliPIDResponseInputHandler)
42 :
43 : //_____________________________________________________________________________
44 : AliPIDResponseInputHandler::AliPIDResponseInputHandler(const char *name) :
45 0 : AliInputEventHandler(name, name),
46 0 : fIsMC(kFALSE),
47 0 : fPIDResponse(0x0),
48 0 : fRun(0),
49 0 : fOldRun(0),
50 0 : fRecoPass(0),
51 0 : fMCurrentMutliIH(0)
52 0 : {
53 : //
54 : // Default constructor.
55 : //
56 0 : AliDebug(AliLog::kDebug + 10, "<-");
57 0 : AliDebug(AliLog::kDebug + 10, "->");
58 0 : }
59 :
60 : //_____________________________________________________________________________
61 : AliPIDResponseInputHandler::~AliPIDResponseInputHandler()
62 0 : {
63 : //
64 : // Destructor
65 : //
66 0 : AliDebug(AliLog::kDebug + 10, "<-");
67 : // delete fArrPidResponseMaster;
68 0 : AliDebug(AliLog::kDebug + 10, "->");
69 0 : }
70 :
71 : //_____________________________________________________________________________
72 : Bool_t AliPIDResponseInputHandler::Init(Option_t *opt)
73 : {
74 : //
75 : // Init() is called for all mix input handlers.
76 : //
77 0 : AliDebug(AliLog::kDebug + 5, Form("<- opt=%s", opt));
78 :
79 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
80 0 : return kTRUE;
81 : }
82 : //_____________________________________________________________________________
83 : Bool_t AliPIDResponseInputHandler::Init(TTree *tree, Option_t *opt)
84 : {
85 : //
86 : // Init(const char*path) is called for all mix input handlers.
87 : // Create event pool if needed
88 : //
89 0 : AliDebug(AliLog::kDebug + 5, Form("<- %p %s opt=%s", (void *) tree, tree->GetName(), opt));
90 :
91 0 : if (fParentHandler) {
92 0 : TString tmp = "";
93 : AliInputEventHandler *ih = 0;
94 0 : fMCurrentMutliIH = dynamic_cast<AliMultiInputEventHandler*>(fParentHandler);
95 0 : if (fMCurrentMutliIH) {
96 0 : ih = fMCurrentMutliIH->GetFirstInputEventHandler();
97 0 : if (ih) {
98 : //pid response object
99 0 : ih->CreatePIDResponse(fIsMC);
100 0 : fPIDResponse = ih->GetPIDResponse();
101 0 : if (!fPIDResponse) AliFatal("PIDResponse object was not created");
102 : }
103 : }
104 0 : }
105 :
106 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
107 0 : return kTRUE;
108 0 : }
109 : //_____________________________________________________________________________
110 : Bool_t AliPIDResponseInputHandler::Notify()
111 : {
112 : //
113 : // Notify() is called for all mix input handlers
114 : //
115 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
116 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
117 0 : return kTRUE;
118 : }
119 :
120 : //_____________________________________________________________________________
121 : Bool_t AliPIDResponseInputHandler::Notify(const char *path)
122 : {
123 : //
124 : // Notify(const char*path) is called for all mix input handlers
125 : //
126 0 : AliDebug(AliLog::kDebug + 5, Form("<- %s", path));
127 0 : AliDebug(AliLog::kDebug + 5, "->");
128 0 : return kTRUE;
129 : }
130 : //_____________________________________________________________________________
131 : Bool_t AliPIDResponseInputHandler::BeginEvent(Long64_t entry)
132 : {
133 : //
134 : // BeginEvent(Long64_t entry) is called for all mix input handlers
135 : //
136 0 : AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry));
137 :
138 0 : if (fParentHandler) {
139 0 : TString tmp = "";
140 : AliInputEventHandler *ih = 0;
141 0 : fMCurrentMutliIH = dynamic_cast<AliMultiInputEventHandler*>(fParentHandler);
142 0 : if (fMCurrentMutliIH) {
143 0 : ih = fMCurrentMutliIH->GetFirstInputEventHandler();
144 0 : if (ih) {
145 : //pid response object
146 0 : ih->CreatePIDResponse(fIsMC);
147 0 : fPIDResponse = ih->GetPIDResponse();
148 0 : if (!fPIDResponse) AliFatal("PIDResponse object was not created");
149 :
150 0 : AliVEvent *event = ih->GetEvent();
151 0 : if (!event) return kFALSE;
152 0 : fRun = event->GetRunNumber();
153 :
154 0 : if (fRun != fOldRun) {
155 0 : SetRecoInfo();
156 0 : fOldRun = fRun;
157 0 : }
158 0 : fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
159 0 : fPIDResponse->InitialiseEvent(event,fRecoPass);
160 0 : }
161 : }
162 0 : }
163 0 : AliDebug(AliLog::kDebug + 5, "->");
164 0 : return kTRUE;
165 0 : }
166 :
167 : //_____________________________________________________________________________
168 : Bool_t AliPIDResponseInputHandler::GetEntry()
169 : {
170 0 : AliDebug(AliLog::kDebug + 5, "<-");
171 0 : AliDebug(AliLog::kDebug + 5, "->");
172 0 : return kTRUE;
173 : }
174 :
175 : //_____________________________________________________________________________
176 : Bool_t AliPIDResponseInputHandler::FinishEvent()
177 : {
178 : //
179 : // FinishEvent() is called for all mix input handlers
180 : //
181 0 : AliDebug(AliLog::kDebug + 5, Form("<-"));
182 0 : AliDebug(AliLog::kDebug + 5, Form("->"));
183 0 : return kTRUE;
184 : }
185 :
186 : //_____________________________________________________________________________
187 : void AliPIDResponseInputHandler::SetRecoInfo()
188 : {
189 : //
190 : // Set reconstruction information
191 : //
192 :
193 : //reset information
194 0 : fRecoPass=0;
195 :
196 : //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... )
197 : // AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
198 0 : AliVEventHandler *inputHandler=fMCurrentMutliIH->GetFirstInputEventHandler();
199 0 : if (!inputHandler) return;
200 :
201 0 : TTree *tree= (TTree*)inputHandler->GetTree();
202 0 : TFile *file= (TFile*)tree->GetCurrentFile();
203 :
204 0 : if (!file) {
205 0 : AliError("Current file not found, cannot set reconstruction information");
206 0 : return;
207 : }
208 :
209 : //find pass from file name (UGLY, but not stored in ESD... )
210 0 : TString fileName(file->GetName());
211 0 : if (fileName.Contains("/pass1") || fileName.Contains(".pass1")) {
212 0 : fRecoPass=1;
213 0 : } else if (fileName.Contains("/pass2") || fileName.Contains(".pass2")) {
214 0 : fRecoPass=2;
215 0 : } else if (fileName.Contains("/pass3") || fileName.Contains(".pass3")) {
216 0 : fRecoPass=3;
217 0 : }
218 :
219 0 : fPIDResponse->SetCurrentFile(fileName.Data());
220 0 : }
|