1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliPIDResponseInputHandler 46193 2010-12-21 09:00:14Z wiechula $ */
18 //-----------------------------------------------------------------
19 // Handler to set up the PID response object and
20 // initialise it correctly for each event
23 // Jens Wiechula (jens.wiechula@cern.ch)
24 // Martin Vala (martin.vala@cern.ch)
26 //-----------------------------------------------------------------
33 #include <AliVEvent.h>
34 #include "AliAnalysisManager.h"
35 #include "AliMultiInputEventHandler.h"
36 #include "AliPIDResponse.h"
38 #include "AliPIDResponseInputHandler.h"
41 ClassImp(AliPIDResponseInputHandler)
43 //_____________________________________________________________________________
44 AliPIDResponseInputHandler::AliPIDResponseInputHandler(const char *name) :
45 AliInputEventHandler(name, name),
54 // Default constructor.
56 AliDebug(AliLog::kDebug + 10, "<-");
57 AliDebug(AliLog::kDebug + 10, "->");
60 //_____________________________________________________________________________
61 AliPIDResponseInputHandler::~AliPIDResponseInputHandler()
66 AliDebug(AliLog::kDebug + 10, "<-");
67 // delete fArrPidResponseMaster;
68 AliDebug(AliLog::kDebug + 10, "->");
71 //_____________________________________________________________________________
72 Bool_t AliPIDResponseInputHandler::Init(Option_t *opt)
75 // Init() is called for all mix input handlers.
77 AliDebug(AliLog::kDebug + 5, Form("<- opt=%s", opt));
79 AliDebug(AliLog::kDebug + 5, Form("->"));
82 //_____________________________________________________________________________
83 Bool_t AliPIDResponseInputHandler::Init(TTree *tree, Option_t *opt)
86 // Init(const char*path) is called for all mix input handlers.
87 // Create event pool if needed
89 AliDebug(AliLog::kDebug + 5, Form("<- %p %s opt=%s", (void *) tree, tree->GetName(), opt));
93 AliInputEventHandler *ih = 0;
94 fMCurrentMutliIH = dynamic_cast<AliMultiInputEventHandler*>(fParentHandler);
95 if (fMCurrentMutliIH) {
96 ih = fMCurrentMutliIH->GetFirstInputEventHandler();
99 ih->CreatePIDResponse(fIsMC);
100 fPIDResponse = ih->GetPIDResponse();
101 if (!fPIDResponse) AliFatal("PIDResponse object was not created");
106 AliDebug(AliLog::kDebug + 5, Form("->"));
109 //_____________________________________________________________________________
110 Bool_t AliPIDResponseInputHandler::Notify()
113 // Notify() is called for all mix input handlers
115 AliDebug(AliLog::kDebug + 5, Form("<-"));
116 AliDebug(AliLog::kDebug + 5, Form("->"));
120 //_____________________________________________________________________________
121 Bool_t AliPIDResponseInputHandler::Notify(const char *path)
124 // Notify(const char*path) is called for all mix input handlers
126 AliDebug(AliLog::kDebug + 5, Form("<- %s", path));
127 AliDebug(AliLog::kDebug + 5, "->");
130 //_____________________________________________________________________________
131 Bool_t AliPIDResponseInputHandler::BeginEvent(Long64_t entry)
134 // BeginEvent(Long64_t entry) is called for all mix input handlers
136 AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry));
138 if (fParentHandler) {
140 AliInputEventHandler *ih = 0;
141 fMCurrentMutliIH = dynamic_cast<AliMultiInputEventHandler*>(fParentHandler);
142 if (fMCurrentMutliIH) {
143 ih = fMCurrentMutliIH->GetFirstInputEventHandler();
145 //pid response object
146 ih->CreatePIDResponse(fIsMC);
147 fPIDResponse = ih->GetPIDResponse();
148 if (!fPIDResponse) AliFatal("PIDResponse object was not created");
150 AliVEvent *event = ih->GetEvent();
151 if (!event) return kFALSE;
152 fRun = event->GetRunNumber();
154 if (fRun != fOldRun) {
158 fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath());
159 fPIDResponse->InitialiseEvent(event,fRecoPass);
163 AliDebug(AliLog::kDebug + 5, "->");
167 //_____________________________________________________________________________
168 Bool_t AliPIDResponseInputHandler::GetEntry()
170 AliDebug(AliLog::kDebug + 5, "<-");
171 AliDebug(AliLog::kDebug + 5, "->");
175 //_____________________________________________________________________________
176 Bool_t AliPIDResponseInputHandler::FinishEvent()
179 // FinishEvent() is called for all mix input handlers
181 AliDebug(AliLog::kDebug + 5, Form("<-"));
182 AliDebug(AliLog::kDebug + 5, Form("->"));
186 //_____________________________________________________________________________
187 void AliPIDResponseInputHandler::SetRecoInfo()
190 // Set reconstruction information
196 //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... )
197 // AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager();
198 AliVEventHandler *inputHandler=fMCurrentMutliIH->GetFirstInputEventHandler();
199 if (!inputHandler) return;
201 TTree *tree= (TTree*)inputHandler->GetTree();
202 TFile *file= (TFile*)tree->GetCurrentFile();
205 AliError("Current file not found, cannot set reconstruction information");
209 //find pass from file name (UGLY, but not stored in ESD... )
210 TString fileName(file->GetName());
211 if (fileName.Contains("/pass1") || fileName.Contains(".pass1")) {
213 } else if (fileName.Contains("/pass2") || fileName.Contains(".pass2")) {
215 } else if (fileName.Contains("/pass3") || fileName.Contains(".pass3")) {
219 fPIDResponse->SetCurrentFile(fileName.Data());