From 6a45d03fbb4a92bf85a100e40ad9d1dbf33723bb Mon Sep 17 00:00:00 2001 From: wiechula Date: Sun, 10 Apr 2011 17:42:07 +0000 Subject: [PATCH] o Add pid response handler needed for managing the AliPIDResponse setup in case of the Multi input handler (Martin Vala) o Decoulple QA histograms from funcionality to setup the AliPIDResponse in AliAnalysisTaskPIDResponse o Modify code to use the new setup functionality in AliPIDResponse to do the loading of the response functions from the OADB o Modify AddTask macro to automatically detect the analysis mode (single input handler VS multi input handler) and take the proper action --- ANALYSIS/ANALYSISaliceLinkDef.h | 1 + ANALYSIS/AliAnalysisTaskPIDResponse.cxx | 568 +----------------------- ANALYSIS/AliAnalysisTaskPIDResponse.h | 51 +-- ANALYSIS/AliPIDResponseInputHandler.cxx | 218 +++++++++ ANALYSIS/AliPIDResponseInputHandler.h | 56 +++ ANALYSIS/CMakelibANALYSISalice.pkg | 2 +- ANALYSIS/macros/AddTaskPIDResponse.C | 38 +- 7 files changed, 320 insertions(+), 614 deletions(-) create mode 100644 ANALYSIS/AliPIDResponseInputHandler.cxx create mode 100644 ANALYSIS/AliPIDResponseInputHandler.h diff --git a/ANALYSIS/ANALYSISaliceLinkDef.h b/ANALYSIS/ANALYSISaliceLinkDef.h index b0d64d6ae9a..bd4b8e0dfad 100644 --- a/ANALYSIS/ANALYSISaliceLinkDef.h +++ b/ANALYSIS/ANALYSISaliceLinkDef.h @@ -39,6 +39,7 @@ #pragma link C++ class AliAnalysisTaskStat+; #pragma link C++ class AliMultiInputEventHandler+; #pragma link C++ class AliAnalysisTaskPIDResponse+; +#pragma link C++ class AliPIDResponseInputHandler+; #ifdef WITHXML #pragma link C++ class AliTagAnalysis+; diff --git a/ANALYSIS/AliAnalysisTaskPIDResponse.cxx b/ANALYSIS/AliAnalysisTaskPIDResponse.cxx index f6a452b3e89..8e613d48844 100644 --- a/ANALYSIS/AliAnalysisTaskPIDResponse.cxx +++ b/ANALYSIS/AliAnalysisTaskPIDResponse.cxx @@ -14,12 +14,7 @@ **************************************************************************/ /* $Id: AliAnalysisTaskPIDResponse.cxx 43811 2010-09-23 14:13:31Z wiechula $ */ -#include -#include -#include -#include #include -#include #include #include @@ -29,38 +24,20 @@ #include #include #include -#include #include -#include -#include -#include -#include #include "AliAnalysisTaskPIDResponse.h" - ClassImp(AliAnalysisTaskPIDResponse) //______________________________________________________________________________ AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(): AliAnalysisTaskSE(), fIsMC(kFALSE), -fTOFTimeZeroTypeUser(-1), -fTOFTimeZeroType(AliPIDResponse::kBest_T0), -fTOFres(100.), fPIDResponse(0x0), -fListQA(0x0), -fListQAits(0x0), -fListQAtpc(0x0), -fListQAtrd(0x0), -fListQAtof(0x0), -fBeamType("PP"), -fLHCperiod(), -fMCperiodTPC(), -fRecoPass(0), fRun(0), fOldRun(0), -fArrPidResponseMaster(0x0) +fRecoPass(0) { // // Dummy constructor @@ -71,28 +48,15 @@ fArrPidResponseMaster(0x0) AliAnalysisTaskPIDResponse::AliAnalysisTaskPIDResponse(const char* name): AliAnalysisTaskSE(name), fIsMC(kFALSE), -fTOFTimeZeroTypeUser(-1), -fTOFTimeZeroType(AliPIDResponse::kBest_T0), -fTOFres(100.), fPIDResponse(0x0), -fListQA(0x0), -fListQAits(0x0), -fListQAtpc(0x0), -fListQAtrd(0x0), -fListQAtof(0x0), -fBeamType("PP"), -fLHCperiod(), -fMCperiodTPC(), -fRecoPass(0), fRun(0), fOldRun(0), -fArrPidResponseMaster(0x0) +fRecoPass(0) { // // Default constructor // DefineInput(0,TChain::Class()); - DefineOutput(1,TList::Class()); } //______________________________________________________________________________ @@ -101,25 +65,6 @@ AliAnalysisTaskPIDResponse::~AliAnalysisTaskPIDResponse() // // Destructor // - - delete fArrPidResponseMaster; -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::ExecNewRun() -{ - // - // Things to Execute upon a new run - // - - SetRecoInfo(); - - SetITSParametrisation(); - - SetTPCPidResponseMaster(); - SetTPCParametrisation(); - - fPIDResponse->GetTOFResponse().SetTimeResolution(fTOFres); } //______________________________________________________________________________ @@ -128,81 +73,40 @@ void AliAnalysisTaskPIDResponse::UserCreateOutputObjects() // // Create the output QA objects // - + AliLog::SetClassDebugLevel("AliAnalysisTaskPIDResponse",10); - + //input hander AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); AliInputEventHandler *inputHandler=dynamic_cast(man->GetInputEventHandler()); if (!inputHandler) AliFatal("Input handler needed"); - + //pid response object inputHandler->CreatePIDResponse(fIsMC); fPIDResponse=inputHandler->GetPIDResponse(); if (!fPIDResponse) AliFatal("PIDResponse object was not created"); - - // - fListQA=new TList; - fListQA->SetOwner(); - - fListQAits=new TList; - fListQAits->SetOwner(); - fListQAits->SetName("ITS"); - - fListQAtpc=new TList; - fListQAtpc->SetOwner(); - fListQAtpc->SetName("TPC"); - - fListQAtrd=new TList; - fListQAtrd->SetOwner(); - fListQAtrd->SetName("TRD"); - - fListQAtof=new TList; - fListQAtof->SetOwner(); - fListQAtof->SetName("TOF"); - - fListQA->Add(fListQAits); - fListQA->Add(fListQAtpc); - fListQA->Add(fListQAtrd); - fListQA->Add(fListQAtof); - - SetupTTSqa(); - SetupTPCqa(); - SetupTRDqa(); - SetupTOFqa(); - PostData(1,fListQA); + fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath()); } - //______________________________________________________________________________ void AliAnalysisTaskPIDResponse::UserExec(Option_t */*option*/) { // // Setup the PID response functions and fill the QA histograms // - AliVEvent *event=InputEvent(); if (!event) return; fRun=event->GetRunNumber(); - + if (fRun!=fOldRun){ - ExecNewRun(); + SetRecoInfo(); fOldRun=fRun; } - Double_t timeZeroType=fTOFTimeZeroTypeUser; - if (timeZeroType<0) timeZeroType=fTOFTimeZeroType; - fPIDResponse->SetTOFResponse(event, (AliPIDResponse::EStartTimeType_t)timeZeroType); - - FillITSqa(); - FillTPCqa(); - FillTOFqa(); - - PostData(1,fListQA); + fPIDResponse->InitialiseEvent(event,fRecoPass); } - //______________________________________________________________________________ void AliAnalysisTaskPIDResponse::SetRecoInfo() { @@ -212,10 +116,6 @@ void AliAnalysisTaskPIDResponse::SetRecoInfo() //reset information fRecoPass=0; - fLHCperiod=""; - fMCperiodTPC=""; - - fBeamType=""; //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... ) AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); @@ -229,18 +129,6 @@ void AliAnalysisTaskPIDResponse::SetRecoInfo() AliError("Current file not found, cannot set reconstruction information"); return; } - - fBeamType="PP"; - - //find the period by run number (UGLY, but not stored in ESD and AOD... ) - if (fRun>=114737&&fRun<=117223) { fLHCperiod="LHC10B"; fMCperiodTPC="LHC10D1"; } - else if (fRun>=118503&&fRun<=121040) { fLHCperiod="LHC10C"; fMCperiodTPC="LHC10D1"; } - else if (fRun>=122195&&fRun<=126437) { fLHCperiod="LHC10D"; fMCperiodTPC="LHC10F6A"; } - else if (fRun>=127719&&fRun<=130850) { fLHCperiod="LHC10E"; fMCperiodTPC="LHC10F6A"; } - else if (fRun>=133004&&fRun<=135029) { fLHCperiod="LHC10F"; fMCperiodTPC="LHC10F6A"; } - else if (fRun>=135654&&fRun<=136377) { fLHCperiod="LHC10G"; fMCperiodTPC="LHC10F6A"; } - else if (fRun>=136851&&fRun<=139517) { fLHCperiod="LHC10H"; fMCperiodTPC="LHC10H8"; fBeamType="PBPB"; } - else if (fRun>=139699) { fLHCperiod="LHC11A"; fMCperiodTPC="LHC10F6A"; } //find pass from file name (UGLY, but not stored in ESD... ) TString fileName(file->GetName()); @@ -253,441 +141,3 @@ void AliAnalysisTaskPIDResponse::SetRecoInfo() } } - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetITSParametrisation() -{ - // - // Set the ITS parametrisation - // -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetTPCPidResponseMaster() -{ - // - // Load the TPC pid response functions from the OADB - // - - //reset the PID response functions - delete fArrPidResponseMaster; - fArrPidResponseMaster=0x0; - - TString fileName(Form("%s/COMMON/PID/data/TPCPIDResponse.root", AliAnalysisManager::GetOADBPath())); - - TFile f(fileName.Data()); - if (f.IsOpen() && !f.IsZombie()){ - fArrPidResponseMaster=dynamic_cast(f.Get("TPCPIDResponse")); - f.Close(); - } - - if (!fArrPidResponseMaster){ - AliFatal("Could not retrieve the TPC pid response"); - return; - } - fArrPidResponseMaster->SetOwner(); -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetTPCParametrisation() -{ - // - // Change BB parametrisation for current run - // - - if (fLHCperiod.IsNull()) { - AliFatal("No period set, not changing parametrisation"); - return; - } - - // - // Set default parametrisations for data and MC - // - - //data type - TString datatype="DATA"; - //in case of mc fRecoPass is per default 1 - if (fIsMC) { - datatype="MC"; - fRecoPass=1; - } - - // - //set the PID splines - // - TString period=fLHCperiod; - if (fArrPidResponseMaster){ - TObject *grAll=0x0; - //for MC don't use period information -// if (fIsMC) period="[A-Z0-9]*"; - //for MC use MC period information - if (fIsMC) period=fMCperiodTPC; -//pattern for the default entry (valid for all particles) - TPRegexp reg(Form("TSPLINE3_%s_([A-Z]*)_%s_PASS%d_%s_MEAN",datatype.Data(),period.Data(),fRecoPass,fBeamType.Data())); - - //loop over entries and filter them - for (Int_t iresp=0; irespGetEntriesFast();++iresp){ - TObject *responseFunction=fArrPidResponseMaster->At(iresp); - if (responseFunction==0x0) continue; - TString responseName=responseFunction->GetName(); - - if (!reg.MatchB(responseName)) continue; - - TObjArray *arr=reg.MatchS(responseName); - TString particleName=arr->At(1)->GetName(); - delete arr; - if (particleName.IsNull()) continue; - if (particleName=="ALL") grAll=responseFunction; - else { - //find particle id - for (Int_t ispec=0; ispec(fPIDResponse->GetTPCResponse().GetResponseFunction((AliPID::EParticleType)ispec)); - if (old) delete old; - fPIDResponse->GetTPCResponse().SetResponseFunction((AliPID::EParticleType)ispec,responseFunction); - fPIDResponse->GetTPCResponse().SetUseDatabase(kTRUE); - AliInfo(Form("Adding graph: %d - %s",ispec,responseFunction->GetName())); - break; - } - } - } - } - - //set default response function to all particles which don't have a specific one - if (grAll){ - for (Int_t ispec=0; ispecGetTPCResponse().GetResponseFunction((AliPID::EParticleType)ispec)){ - fPIDResponse->GetTPCResponse().SetResponseFunction((AliPID::EParticleType)ispec,grAll); - AliInfo(Form("Adding graph: %d - %s",ispec,grAll->GetName())); - } - } - } - } - - // - // Setup resolution parametrisation - // - - //default - fPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04); - - if (fRun>=122195){ - fPIDResponse->GetTPCResponse().SetSigma(2.30176e-02, 5.60422e+02); - } -// if ( fBeamType == "PBPB" ){ -// Double_t corrSigma=GetMultiplicityCorrectionSigma(GetTPCMultiplicityBin()); -// fPIDResponse->GetTPCResponse().SetSigma(3.79301e-03*corrSigma, 2.21280e+04); -// } - -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::FillITSqa() -{ - AliVEvent *event=InputEvent(); - - Int_t ntracks=event->GetNumberOfTracks(); - for(Int_t itrack = 0; itrack < ntracks; itrack++){ - AliVTrack *track=(AliVTrack*)event->GetTrack(itrack); - ULong_t status=track->GetStatus(); - // not that nice. status bits not in virtual interface - // ITS refit + ITS pid - if (!( (status&0x0004==0x0004) && (status&0x0008==0x0008) )) return; - Double_t mom=track->P(); - - for (Int_t ispecie=0; ispecieAt(ispecie); - if (!h) continue; - Double_t nSigma=fPIDResponse->NumberOfSigmasITS(track, (AliPID::EParticleType)ispecie); - h->Fill(mom,nSigma); - } - - TH2 *h=(TH2*)fListQAits->At(AliPID::kSPECIES); - if (h) { - Double_t sig=track->GetITSsignal(); - h->Fill(mom,sig); - } - - } -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::FillTPCqa() -{ - AliVEvent *event=InputEvent(); - - Int_t ntracks=event->GetNumberOfTracks(); - for(Int_t itrack = 0; itrack < ntracks; itrack++){ - AliVTrack *track=(AliVTrack*)event->GetTrack(itrack); - - // - //basic track cuts - // - ULong_t status=track->GetStatus(); - // not that nice. status bits not in virtual interface - // TPC refit + ITS refit + TPC pid - if (!(status&0x0040==0x0040) || !(status&0x0004==0x0004) || !(status&0x0080==0x0080) ) return; - - Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1); - Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0; - if (track->GetTPCNclsF()>0) { - ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF(); - } - - if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue; - - Double_t mom=track->GetTPCmomentum(); - - for (Int_t ispecie=0; ispecieAt(ispecie); - if (!h) continue; - Double_t nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie); - h->Fill(mom,nSigma); - } - - TH2 *h=(TH2*)fListQAtpc->At(AliPID::kSPECIES); - if (h) { - Double_t sig=track->GetTPCsignal(); - h->Fill(mom,sig); - } - - TH2 *hPt=(TH2*)fListQAtpc->At(AliPID::kSPECIES+1); - if (hPt) { - Double_t sig=track->GetTPCsignal(); - hPt->Fill(sig); - } - - TH2 *hMom=(TH2*)fListQAtpc->At(AliPID::kSPECIES+2); - if (hMom) { - Double_t sig=track->GetTPCmomentum(); - hMom->Fill(sig); - } - - } -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::FillTOFqa() -{ - AliVEvent *event=InputEvent(); - - Int_t ntracks=event->GetNumberOfTracks(); - for(Int_t itrack = 0; itrack < ntracks; itrack++){ - AliVTrack *track=(AliVTrack*)event->GetTrack(itrack); - - // - //basic track cuts - // - ULong_t status=track->GetStatus(); - // not that nice. status bits not in virtual interface - // TPC refit + ITS refit + - // TOF out + TOFpid + - // kTIME - if (!(status&0x0040==0x0040) || !(status&0x0004==0x0004) - || !(status&0x2000==0x2000) || !(status&0x8000==0x8000) - || !(status&0x80000000==0x80000000) ) return; - - Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1); - Float_t ratioCrossedRowsOverFindableClustersTPC = 1.0; - if (track->GetTPCNclsF()>0) { - ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF(); - } - - if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue; - - - Double_t mom=track->P(); - - for (Int_t ispecie=0; ispecieAt(ispecie); - if (!h) continue; - Double_t nSigma=fPIDResponse->NumberOfSigmasTOF(track, (AliPID::EParticleType)ispecie); - h->Fill(mom,nSigma); - } - - TH2 *h=(TH2*)fListQAtof->At(AliPID::kSPECIES); - if (h) { - Double_t sig=track->GetTOFsignal(); - h->Fill(mom,sig); - } - - } -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetupTTSqa() -{ - // - // Create the ITS qa objects - // - - TVectorD *vX=MakeLogBinning(200,.1,30); - - for (Int_t ispecie=0; ispecieGetNrows()-1,vX->GetMatrixArray(), - 200,-10,10); - fListQAits->Add(hNsigmaP); - } - - - TH2F *hSig = new TH2F("hSigP_ITS", - "ITS signal vs. p;p [GeV]; ITS signal [arb. units]", - vX->GetNrows()-1,vX->GetMatrixArray(), - 300,0,300); - - fListQAits->Add(hSig); - -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetupTPCqa() -{ - // - // Create the TPC qa objects - // - - TVectorD *vX=MakeLogBinning(200,.1,30); - - for (Int_t ispecie=0; ispecieGetNrows()-1,vX->GetMatrixArray(), - 200,-10,10); - fListQAtpc->Add(hNsigmaP); - } - - - TH2F *hSig = new TH2F("hSigP_TPC", - "TPC signal vs. p;p [GeV]; TPC signal [arb. units]", - vX->GetNrows()-1,vX->GetMatrixArray(), - 300,0,300); - - fListQAtpc->Add(hSig); - - TH1F *hPt = new TH1F("hPt","Pt_TPC",100,0,300); - fListQAtpc->Add(hPt); - - TH1F *hMom = new TH1F("hMom","Mom_TPC",100,0,20); - fListQAtpc->Add(hMom); - -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetupTRDqa() -{ - // - // Create the TRD qa objects - // - -} - -//______________________________________________________________________________ -void AliAnalysisTaskPIDResponse::SetupTOFqa() -{ - // - // Create the TOF qa objects - // - - TVectorD *vX=MakeLogBinning(200,.1,30); - - for (Int_t ispecie=0; ispecieGetNrows()-1,vX->GetMatrixArray(), - 200,-10,10); - fListQAtof->Add(hNsigmaP); - } - - - TH2F *hSig = new TH2F("hSigP_TOF", - "TOF signal vs. p;p [GeV]; TOF signal [arb. units]", - vX->GetNrows()-1,vX->GetMatrixArray(), - 300,0,300); - - fListQAtof->Add(hSig); - -} - -//______________________________________________________________________________ -TVectorD* AliAnalysisTaskPIDResponse::MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax) -{ - // - // Make logarithmic binning - // the user has to delete the array afterwards!!! - // - - //check limits - if (xmin<1e-20 || xmax<1e-20){ - AliError("For Log binning xmin and xmax must be > 1e-20. Using linear binning instead!"); - return MakeLinBinning(nbinsX, xmin, xmax); - } - if (xmaxGetEntries(); - if (nLimits<2){ - AliError("Need at leas 2 bin limits, cannot add the variable"); - delete arr; - return 0x0; - } - - TVectorD *binLimits=new TVectorD(nLimits); - for (Int_t iLim=0; iLim(arr->At(iLim)))->GetString().Atof(); - } - - delete arr; - return binLimits; -} diff --git a/ANALYSIS/AliAnalysisTaskPIDResponse.h b/ANALYSIS/AliAnalysisTaskPIDResponse.h index e0c028bf54d..b6bd92270f5 100644 --- a/ANALYSIS/AliAnalysisTaskPIDResponse.h +++ b/ANALYSIS/AliAnalysisTaskPIDResponse.h @@ -21,7 +21,7 @@ #endif class AliPIDResponse; -class TList; +class AliVEvent; class AliAnalysisTaskPIDResponse : public AliAnalysisTaskSE { @@ -37,63 +37,18 @@ public: virtual void UserExec(Option_t */*option*/); - void SetTOFTimeZeroType(Int_t type) { fTOFTimeZeroTypeUser=type; } - void SetTOFres(Float_t res) { fTOFres=res; } private: Bool_t fIsMC; // If we run on MC data - - Int_t fTOFTimeZeroTypeUser; // start time type for tof (ESD) - Int_t fTOFTimeZeroType; //! default start time type for tof (ESD) - Float_t fTOFres; // TOF resolution AliPIDResponse *fPIDResponse; //! PID response Handler - TList *fListQA; //! list with all QA objects - TList *fListQAits; //! List with ITS QA objects - TList *fListQAtpc; //! List with TPC QA objects - TList *fListQAtrd; //! List with TRD QA objects - TList *fListQAtof; //! List with TOF QA objects - - TString fBeamType; //! beam type (PP) or (PBPB) - TString fLHCperiod; //! LHC period - TString fMCperiodTPC; //! corresponding MC period to use for the TPC splines - Int_t fRecoPass; //! reconstruction pass Int_t fRun; //! current run number Int_t fOldRun; //! current run number + Int_t fRecoPass; //! reconstruction pass - TObjArray *fArrPidResponseMaster; // TPC pid splines - - void ExecNewRun(); - - //qa object initialisation - void SetupTTSqa(); - void SetupTPCqa(); - void SetupTRDqa(); - void SetupTOFqa(); - - // - void FillITSqa(); - void FillTPCqa(); - void FillTOFqa(); - - // - //setup parametrisations - // - void SetITSParametrisation(); - - //TPC - void SetTPCPidResponseMaster(); - void SetTPCParametrisation(); - // void SetRecoInfo(); - - //helper functions - TVectorD* MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax); - TVectorD* MakeLinBinning(Int_t nbinsX, Double_t xmin, Double_t xmax); - TVectorD* MakeArbitraryBinning(const char* bins); - - + AliAnalysisTaskPIDResponse(const AliAnalysisTaskPIDResponse &other); AliAnalysisTaskPIDResponse& operator=(const AliAnalysisTaskPIDResponse &other); diff --git a/ANALYSIS/AliPIDResponseInputHandler.cxx b/ANALYSIS/AliPIDResponseInputHandler.cxx new file mode 100644 index 00000000000..dd9e6de62d6 --- /dev/null +++ b/ANALYSIS/AliPIDResponseInputHandler.cxx @@ -0,0 +1,218 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id: AliPIDResponseInputHandler 46193 2010-12-21 09:00:14Z wiechula $ */ + +//----------------------------------------------------------------- +// Handler to set up the PID response object and +// initialise it correctly for each event +// +// Origin: +// Jens Wiechula (jens.wiechula@cern.ch) +// Martin Vala (martin.vala@cern.ch) + +//----------------------------------------------------------------- + + +#include +#include + +#include +#include +#include "AliAnalysisManager.h" +#include "AliMultiInputEventHandler.h" +#include "AliPIDResponse.h" + +#include "AliPIDResponseInputHandler.h" + + +ClassImp(AliPIDResponseInputHandler) + +//_____________________________________________________________________________ +AliPIDResponseInputHandler::AliPIDResponseInputHandler(const char *name) : + AliInputEventHandler(name, name), + fIsMC(kFALSE), + fPIDResponse(0x0), + fRun(0), + fOldRun(0), + fRecoPass(0), + fMCurrentMutliIH(0) +{ +// +// Default constructor. +// + AliDebug(AliLog::kDebug + 10, "<-"); + AliDebug(AliLog::kDebug + 10, "->"); +} + +//_____________________________________________________________________________ +AliPIDResponseInputHandler::~AliPIDResponseInputHandler() +{ +// +// Destructor +// + AliDebug(AliLog::kDebug + 10, "<-"); +// delete fArrPidResponseMaster; + AliDebug(AliLog::kDebug + 10, "->"); +} + +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::Init(Option_t *opt) +{ +// +// Init() is called for all mix input handlers. +// + AliDebug(AliLog::kDebug + 5, Form("<- opt=%s", opt)); + + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::Init(TTree *tree, Option_t *opt) +{ +// +// Init(const char*path) is called for all mix input handlers. +// Create event pool if needed +// + AliDebug(AliLog::kDebug + 5, Form("<- %p %s opt=%s", (void *) tree, tree->GetName(), opt)); + + if (fParentHandler) { + TString tmp = ""; + AliInputEventHandler *ih = 0; + fMCurrentMutliIH = dynamic_cast(fParentHandler); + if (fMCurrentMutliIH) { + ih = fMCurrentMutliIH->GetFirstInputEventHandler(); + if (ih) { + //pid response object + ih->CreatePIDResponse(fIsMC); + fPIDResponse = ih->GetPIDResponse(); + if (!fPIDResponse) AliFatal("PIDResponse object was not created"); + } + } + } + + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::Notify() +{ +// +// Notify() is called for all mix input handlers +// + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::Notify(const char *path) +{ +// +// Notify(const char*path) is called for all mix input handlers +// + AliDebug(AliLog::kDebug + 5, Form("<- %s", path)); + AliDebug(AliLog::kDebug + 5, "->"); + return kTRUE; +} +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::BeginEvent(Long64_t entry) +{ +// +// BeginEvent(Long64_t entry) is called for all mix input handlers +// + AliDebug(AliLog::kDebug + 5, Form("<- %lld", entry)); + + if (fParentHandler) { + TString tmp = ""; + AliInputEventHandler *ih = 0; + fMCurrentMutliIH = dynamic_cast(fParentHandler); + if (fMCurrentMutliIH) { + ih = fMCurrentMutliIH->GetFirstInputEventHandler(); + if (ih) { + //pid response object + ih->CreatePIDResponse(fIsMC); + fPIDResponse = ih->GetPIDResponse(); + if (!fPIDResponse) AliFatal("PIDResponse object was not created"); + + AliVEvent *event = ih->GetEvent(); + if (!event) return kFALSE; + fRun = event->GetRunNumber(); + + if (fRun != fOldRun) { + SetRecoInfo(); + fOldRun = fRun; + } + fPIDResponse->SetOADBPath(AliAnalysisManager::GetOADBPath()); + fPIDResponse->InitialiseEvent(event,fRecoPass); + } + } + } + AliDebug(AliLog::kDebug + 5, "->"); + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::GetEntry() +{ + AliDebug(AliLog::kDebug + 5, "<-"); + AliDebug(AliLog::kDebug + 5, "->"); + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliPIDResponseInputHandler::FinishEvent() +{ + // + // FinishEvent() is called for all mix input handlers + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} + +//_____________________________________________________________________________ +void AliPIDResponseInputHandler::SetRecoInfo() +{ + // + // Set reconstruction information + // + + //reset information + fRecoPass=0; + + //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... ) +// AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); + AliVEventHandler *inputHandler=fMCurrentMutliIH->GetFirstInputEventHandler(); + if (!inputHandler) return; + + TTree *tree= (TTree*)inputHandler->GetTree(); + TFile *file= (TFile*)tree->GetCurrentFile(); + + if (!file) { + AliError("Current file not found, cannot set reconstruction information"); + return; + } + + //find pass from file name (UGLY, but not stored in ESD... ) + TString fileName(file->GetName()); + if (fileName.Contains("/pass1")) { + fRecoPass=1; + } else if (fileName.Contains("/pass2")) { + fRecoPass=2; + } else if (fileName.Contains("/pass3")) { + fRecoPass=3; + } +} diff --git a/ANALYSIS/AliPIDResponseInputHandler.h b/ANALYSIS/AliPIDResponseInputHandler.h new file mode 100644 index 00000000000..106abbae7ea --- /dev/null +++ b/ANALYSIS/AliPIDResponseInputHandler.h @@ -0,0 +1,56 @@ +// +// Class AliPIDResponseInputHandler +// +// AliPIDResponseInputHandler +// TODO example +// authors: +// Jens Wiechula (jens.wiechula@cern.ch) +// Martin Vala (martin.vala@cern.ch) +// + +#ifndef ALIPIDRESPONSEINPUTHANDLER_H +#define ALIPIDRESPONSEINPUTHANDLER_H + +#include "AliInputEventHandler.h" +class AliPIDResponse; +class AliMultiInputEventHandler; + +class AliPIDResponseInputHandler : public AliInputEventHandler { + +public: + AliPIDResponseInputHandler(const char *name = "PIDResoponseIH"); + virtual ~AliPIDResponseInputHandler(); + + // From the interface + virtual Bool_t Init(Option_t *opt); + virtual Bool_t Init(TTree *tree, Option_t *opt); + virtual Bool_t BeginEvent(Long64_t entry); + virtual Bool_t FinishEvent(); + virtual Bool_t Notify(); + virtual Bool_t Notify(const char *path); + virtual Bool_t GetEntry(); + + void SetIsMC(Bool_t isMC=kTRUE) { fIsMC=isMC; } +private: + + Bool_t fIsMC; // If we run on MC data + + AliPIDResponse *fPIDResponse; //! PID response Handler + Int_t fRun; //! current run number + Int_t fOldRun; //! current run number + Int_t fRecoPass; //! reconstruction pass + + AliMultiInputEventHandler *fMCurrentMutliIH; //! input handler + + // + void SetRecoInfo(); + + + AliPIDResponseInputHandler(const AliPIDResponseInputHandler& handler); + AliPIDResponseInputHandler &operator=(const AliPIDResponseInputHandler &handler); + + ClassDef(AliPIDResponseInputHandler, 1) + +}; + +#endif diff --git a/ANALYSIS/CMakelibANALYSISalice.pkg b/ANALYSIS/CMakelibANALYSISalice.pkg index 4776c0415c8..42d072c2d9c 100644 --- a/ANALYSIS/CMakelibANALYSISalice.pkg +++ b/ANALYSIS/CMakelibANALYSISalice.pkg @@ -25,7 +25,7 @@ # SHLIBS - Shared Libraries and objects for linking (Executables only) # #--------------------------------------------------------------------------------# -set ( SRCS AliAnalysisTaskSE.cxx AliAnalysisTaskME.cxx AliAnalysisTaskESDfilter.cxx AliAnalysisTaskMCParticleFilter.cxx AliKineTrackCuts.cxx AliESDtrackCuts.cxx AliESDpidCuts.cxx AliESDv0Cuts.cxx AliEventPoolOTF.cxx AliEventPoolLoop.cxx AliEventPoolSparse.cxx AliAnalysisTaskTagCreator.cxx AliMultiEventInputHandler.cxx AliTriggerAnalysis.cxx AliPhysicsSelection.cxx AliBackgroundSelection.cxx AliPhysicsSelectionTask.cxx AliAnalysisFilter.cxx AliAnalysisCuts.cxx AliCollisionNormalization.cxx AliCollisionNormalizationTask.cxx AliCentralitySelectionTask.cxx AliAnalysisTaskAODCentralityMaker.cxx AliEPSelectionTask.cxx AliAnalysisTaskStat.cxx AliMultiInputEventHandler.cxx AliESDv0KineCuts.cxx AliAnalysisTaskPIDResponse.cxx) +set ( SRCS AliAnalysisTaskSE.cxx AliAnalysisTaskME.cxx AliAnalysisTaskESDfilter.cxx AliAnalysisTaskMCParticleFilter.cxx AliKineTrackCuts.cxx AliESDtrackCuts.cxx AliESDpidCuts.cxx AliESDv0Cuts.cxx AliEventPoolOTF.cxx AliEventPoolLoop.cxx AliEventPoolSparse.cxx AliAnalysisTaskTagCreator.cxx AliMultiEventInputHandler.cxx AliTriggerAnalysis.cxx AliPhysicsSelection.cxx AliBackgroundSelection.cxx AliPhysicsSelectionTask.cxx AliAnalysisFilter.cxx AliAnalysisCuts.cxx AliCollisionNormalization.cxx AliCollisionNormalizationTask.cxx AliCentralitySelectionTask.cxx AliAnalysisTaskAODCentralityMaker.cxx AliEPSelectionTask.cxx AliAnalysisTaskStat.cxx AliMultiInputEventHandler.cxx AliESDv0KineCuts.cxx AliAnalysisTaskPIDResponse.cxx AliPIDResponseInputHandler.cxx) if( ROOTHASALIEN STREQUAL "yes") diff --git a/ANALYSIS/macros/AddTaskPIDResponse.C b/ANALYSIS/macros/AddTaskPIDResponse.C index 831ac1ace87..cd621502d41 100644 --- a/ANALYSIS/macros/AddTaskPIDResponse.C +++ b/ANALYSIS/macros/AddTaskPIDResponse.C @@ -7,21 +7,47 @@ AliAnalysisTask *AddTaskPIDResponse(Bool_t isMC=kFALSE, Bool_t autoMCesd=kTRUE) return 0x0; } - if ( autoMCesd && (mgr->GetInputEventHandler()->IsA() == AliESDInputHandler::Class()) ) { - isMC=mgr->GetMCtruthEventHandler()!=0x0; + AliVEventHandler *inputHandler=mgr->GetInputEventHandler(); + + //case of multi input event handler (needed for mixing) + if (inputHandler->IsA() == AliMultiInputEventHandler::Class()) { + printf("========================================================================================\n"); + printf("PIDResponse: AliMultiInputEventHandler detected, initialising AliPIDResponseInputHandler\n"); + printf("========================================================================================\n"); + AliMultiInputEventHandler *multiInputHandler=(AliMultiInputEventHandler*)inputHandler; + + AliPIDResponseInputHandler *pidResponseIH = new AliPIDResponseInputHandler(); + multiInputHandler->AddInputEventHandler(pidResponseIH); + + if (autoMCesd && + multiInputHandler->GetFirstInputEventHandler()->IsA()==AliESDInputHandler::Class() && + multiInputHandler->GetFirstMCEventHandler() + ) isMC=kTRUE; + pidResponseIH->SetIsMC(isMC); + + return 0x0; } + + // standard with task + printf("========================================================================================\n"); + printf("PIDResponse: Initialising AliAnalysisTaskPIDResponse\n"); + printf("========================================================================================\n"); + if ( autoMCesd && (inputHandler->IsA() == AliESDInputHandler::Class()) ) { + isMC=mgr->GetMCtruthEventHandler()!=0x0; + } + AliAnalysisTaskPIDResponse *pidTask = new AliAnalysisTaskPIDResponse("PIDResponseTask"); // pidTask->SelectCollisionCandidates(AliVEvent::kMB); pidTask->SetIsMC(isMC); mgr->AddTask(pidTask); - AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("PIDResponseQA", - TList::Class(), AliAnalysisManager::kOutputContainer, - "PIDResponseQA.root"); +// AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("PIDResponseQA", +// TList::Class(), AliAnalysisManager::kOutputContainer, +// "PIDResponseQA.root"); mgr->ConnectInput(pidTask, 0, mgr->GetCommonInputContainer()); - mgr->ConnectOutput(pidTask,1,coutput1); +// mgr->ConnectOutput(pidTask,1,coutput1); return pidTask; } -- 2.43.0