From c865cb1d84619ba175d24843ce1c63d27a82d5b0 Mon Sep 17 00:00:00 2001 From: pulvir Date: Wed, 6 Apr 2011 13:07:54 +0000 Subject: [PATCH] Implementation of all needed changes in the package in order to speed-up the execution and generalize analysis work-flow. Taking advantage of this work, several improvements have been developed for givin the possibility to all users to customize better the package to their needs. Example macros are already provided in the 'macros/train' directory. Documentation of the classes is available in comments to each of them. --- PWG2/CMakelibPWG2resonances.pkg | 69 +- PWG2/PWG2resonancesLinkDef.h | 41 +- PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx | 794 ------------------ PWG2/RESONANCES/AliRsnAnalysisEffSE.h | 81 -- PWG2/RESONANCES/AliRsnAnalysisManager.cxx | 330 -------- PWG2/RESONANCES/AliRsnAnalysisManager.h | 45 - PWG2/RESONANCES/AliRsnAnalysisMonitorTask.cxx | 339 -------- PWG2/RESONANCES/AliRsnAnalysisMonitorTask.h | 77 -- PWG2/RESONANCES/AliRsnAnalysisSE.cxx | 164 ---- PWG2/RESONANCES/AliRsnAnalysisSE.h | 54 -- PWG2/RESONANCES/AliRsnAnalysisTask.cxx | 302 ++++--- PWG2/RESONANCES/AliRsnAnalysisTask.h | 69 +- PWG2/RESONANCES/AliRsnAnalysisTaskEff.cxx | 293 ------- PWG2/RESONANCES/AliRsnAnalysisTaskEff.h | 70 -- .../AliRsnAnalysisTaskEffMonitor.cxx | 242 ------ .../RESONANCES/AliRsnAnalysisTaskEffMonitor.h | 39 - PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.cxx | 372 -------- PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.h | 43 - PWG2/RESONANCES/AliRsnCutESD2010.cxx | 353 -------- PWG2/RESONANCES/AliRsnCutESD2010.h | 155 ---- PWG2/RESONANCES/AliRsnCutManager.h | 23 + PWG2/RESONANCES/AliRsnCutPIDITS.cxx | 50 +- PWG2/RESONANCES/AliRsnCutPIDITS.h | 30 +- PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx | 193 +++++ PWG2/RESONANCES/AliRsnCutPIDNSigma.h | 108 +++ PWG2/RESONANCES/AliRsnCutPIDTOF.cxx | 53 +- PWG2/RESONANCES/AliRsnCutPIDTOF.h | 15 +- PWG2/RESONANCES/AliRsnCutPIDTPC.cxx | 78 +- PWG2/RESONANCES/AliRsnCutPIDTPC.h | 52 +- PWG2/RESONANCES/AliRsnCutTrackQuality.cxx | 6 + PWG2/RESONANCES/AliRsnCutValue.cxx | 24 +- PWG2/RESONANCES/AliRsnCutValue.h | 12 +- PWG2/RESONANCES/AliRsnDaughter.h | 6 +- PWG2/RESONANCES/AliRsnDaughterDef.cxx | 10 +- PWG2/RESONANCES/AliRsnDaughterDef.h | 44 +- PWG2/RESONANCES/AliRsnDaughterSelector.cxx | 286 +++++++ PWG2/RESONANCES/AliRsnDaughterSelector.h | 43 + PWG2/RESONANCES/AliRsnEvent.cxx | 83 +- PWG2/RESONANCES/AliRsnEvent.h | 28 +- PWG2/RESONANCES/AliRsnExpression.cxx | 5 - PWG2/RESONANCES/AliRsnFunction.cxx | 316 ------- PWG2/RESONANCES/AliRsnFunction.h | 70 -- PWG2/RESONANCES/AliRsnInputHandler.cxx | 133 +++ PWG2/RESONANCES/AliRsnInputHandler.h | 49 ++ PWG2/RESONANCES/AliRsnListOutput.cxx | 378 +++++++++ PWG2/RESONANCES/AliRsnListOutput.h | 70 ++ PWG2/RESONANCES/AliRsnLoop.cxx | 142 ++++ PWG2/RESONANCES/AliRsnLoop.h | 56 ++ PWG2/RESONANCES/AliRsnLoopDaughter.cxx | 139 +++ PWG2/RESONANCES/AliRsnLoopDaughter.h | 44 + PWG2/RESONANCES/AliRsnLoopEff.cxx | 121 +++ PWG2/RESONANCES/AliRsnLoopEff.h | 44 + PWG2/RESONANCES/AliRsnLoopEffDaughter.cxx | 190 +++++ PWG2/RESONANCES/AliRsnLoopEffDaughter.h | 43 + PWG2/RESONANCES/AliRsnLoopEffPair.cxx | 218 +++++ PWG2/RESONANCES/AliRsnLoopEffPair.h | 43 + PWG2/RESONANCES/AliRsnLoopEvent.cxx | 96 +++ PWG2/RESONANCES/AliRsnLoopEvent.h | 28 + PWG2/RESONANCES/AliRsnLoopPair.cxx | 253 ++++++ PWG2/RESONANCES/AliRsnLoopPair.h | 57 ++ PWG2/RESONANCES/AliRsnMonitor.cxx | 132 --- PWG2/RESONANCES/AliRsnMonitor.h | 60 -- PWG2/RESONANCES/AliRsnMonitorFunctions.cxx | 145 ---- PWG2/RESONANCES/AliRsnMonitorFunctions.h | 38 - PWG2/RESONANCES/AliRsnMonitorNtuple.cxx | 173 ---- PWG2/RESONANCES/AliRsnMonitorNtuple.h | 40 - PWG2/RESONANCES/AliRsnMonitorTrack.cxx | 167 ---- PWG2/RESONANCES/AliRsnMonitorTrack.h | 125 --- PWG2/RESONANCES/AliRsnPIDManager.cxx | 120 +++ PWG2/RESONANCES/AliRsnPIDManager.h | 40 + PWG2/RESONANCES/AliRsnPair.cxx | 181 ---- PWG2/RESONANCES/AliRsnPair.h | 74 -- PWG2/RESONANCES/AliRsnPairDef.cxx | 55 +- PWG2/RESONANCES/AliRsnPairDef.h | 56 +- PWG2/RESONANCES/AliRsnPairFunctions.cxx | 124 --- PWG2/RESONANCES/AliRsnPairFunctions.h | 46 - PWG2/RESONANCES/AliRsnPairNtuple.cxx | 157 ---- PWG2/RESONANCES/AliRsnPairNtuple.h | 39 - PWG2/RESONANCES/AliRsnTarget.h | 2 +- PWG2/RESONANCES/AliRsnVATProcessInfo.cxx | 198 ----- PWG2/RESONANCES/AliRsnVATProcessInfo.h | 53 -- PWG2/RESONANCES/AliRsnVAnalysisTask.cxx | 424 ---------- PWG2/RESONANCES/AliRsnVAnalysisTask.h | 87 -- PWG2/RESONANCES/AliRsnVAnalysisTaskSE.cxx | 290 ------- PWG2/RESONANCES/AliRsnVAnalysisTaskSE.h | 79 -- PWG2/RESONANCES/AliRsnValue.cxx | 570 +------------ PWG2/RESONANCES/AliRsnValue.h | 91 +- PWG2/RESONANCES/AliRsnValuePID.cxx | 223 +++++ PWG2/RESONANCES/AliRsnValuePID.h | 56 ++ PWG2/RESONANCES/AliRsnValueStd.cxx | 727 ++++++++++++++++ PWG2/RESONANCES/AliRsnValueStd.h | 92 ++ .../extra/AddAnalysisTaskResonanceQA.C | 17 + .../extra/AliAnalysisTaskResonanceQA.cxx | 394 +++++++++ .../extra/AliAnalysisTaskResonanceQA.h | 84 ++ .../extra/AliRsnAnalysisPhi7TeV.cxx | 1 - 95 files changed, 5061 insertions(+), 7670 deletions(-) delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisEffSE.h delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisManager.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisManager.h delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisMonitorTask.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisMonitorTask.h delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisSE.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisSE.h delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisTaskEff.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisTaskEff.h delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.h delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.cxx delete mode 100644 PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.h delete mode 100644 PWG2/RESONANCES/AliRsnCutESD2010.cxx delete mode 100644 PWG2/RESONANCES/AliRsnCutESD2010.h create mode 100644 PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx create mode 100644 PWG2/RESONANCES/AliRsnCutPIDNSigma.h create mode 100644 PWG2/RESONANCES/AliRsnDaughterSelector.cxx create mode 100644 PWG2/RESONANCES/AliRsnDaughterSelector.h delete mode 100644 PWG2/RESONANCES/AliRsnFunction.cxx delete mode 100644 PWG2/RESONANCES/AliRsnFunction.h create mode 100644 PWG2/RESONANCES/AliRsnInputHandler.cxx create mode 100644 PWG2/RESONANCES/AliRsnInputHandler.h create mode 100644 PWG2/RESONANCES/AliRsnListOutput.cxx create mode 100644 PWG2/RESONANCES/AliRsnListOutput.h create mode 100644 PWG2/RESONANCES/AliRsnLoop.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoop.h create mode 100644 PWG2/RESONANCES/AliRsnLoopDaughter.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoopDaughter.h create mode 100644 PWG2/RESONANCES/AliRsnLoopEff.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoopEff.h create mode 100644 PWG2/RESONANCES/AliRsnLoopEffDaughter.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoopEffDaughter.h create mode 100644 PWG2/RESONANCES/AliRsnLoopEffPair.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoopEffPair.h create mode 100644 PWG2/RESONANCES/AliRsnLoopEvent.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoopEvent.h create mode 100644 PWG2/RESONANCES/AliRsnLoopPair.cxx create mode 100644 PWG2/RESONANCES/AliRsnLoopPair.h delete mode 100644 PWG2/RESONANCES/AliRsnMonitor.cxx delete mode 100644 PWG2/RESONANCES/AliRsnMonitor.h delete mode 100644 PWG2/RESONANCES/AliRsnMonitorFunctions.cxx delete mode 100644 PWG2/RESONANCES/AliRsnMonitorFunctions.h delete mode 100644 PWG2/RESONANCES/AliRsnMonitorNtuple.cxx delete mode 100644 PWG2/RESONANCES/AliRsnMonitorNtuple.h delete mode 100644 PWG2/RESONANCES/AliRsnMonitorTrack.cxx delete mode 100644 PWG2/RESONANCES/AliRsnMonitorTrack.h create mode 100644 PWG2/RESONANCES/AliRsnPIDManager.cxx create mode 100644 PWG2/RESONANCES/AliRsnPIDManager.h delete mode 100644 PWG2/RESONANCES/AliRsnPair.cxx delete mode 100644 PWG2/RESONANCES/AliRsnPair.h delete mode 100644 PWG2/RESONANCES/AliRsnPairFunctions.cxx delete mode 100644 PWG2/RESONANCES/AliRsnPairFunctions.h delete mode 100644 PWG2/RESONANCES/AliRsnPairNtuple.cxx delete mode 100644 PWG2/RESONANCES/AliRsnPairNtuple.h delete mode 100644 PWG2/RESONANCES/AliRsnVATProcessInfo.cxx delete mode 100644 PWG2/RESONANCES/AliRsnVATProcessInfo.h delete mode 100644 PWG2/RESONANCES/AliRsnVAnalysisTask.cxx delete mode 100644 PWG2/RESONANCES/AliRsnVAnalysisTask.h delete mode 100644 PWG2/RESONANCES/AliRsnVAnalysisTaskSE.cxx delete mode 100644 PWG2/RESONANCES/AliRsnVAnalysisTaskSE.h create mode 100644 PWG2/RESONANCES/AliRsnValuePID.cxx create mode 100644 PWG2/RESONANCES/AliRsnValuePID.h create mode 100644 PWG2/RESONANCES/AliRsnValueStd.cxx create mode 100644 PWG2/RESONANCES/AliRsnValueStd.h create mode 100644 PWG2/RESONANCES/extra/AddAnalysisTaskResonanceQA.C create mode 100644 PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.cxx create mode 100644 PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.h diff --git a/PWG2/CMakelibPWG2resonances.pkg b/PWG2/CMakelibPWG2resonances.pkg index 6cebb947d0d..9839f30560f 100644 --- a/PWG2/CMakelibPWG2resonances.pkg +++ b/PWG2/CMakelibPWG2resonances.pkg @@ -26,45 +26,38 @@ #--------------------------------------------------------------------------------# set ( SRCS RESONANCES/AliRsnDaughter.cxx - RESONANCES/AliRsnMother.cxx + RESONANCES/AliRsnMother.cxx + RESONANCES/AliRsnEvent.cxx RESONANCES/AliRsnDaughterDef.cxx - RESONANCES/AliRsnPairDef.cxx - RESONANCES/AliRsnEvent.cxx - RESONANCES/AliRsnTarget.cxx - RESONANCES/AliRsnValue.cxx - RESONANCES/AliRsnCut.cxx - RESONANCES/AliRsnCutValue.cxx - RESONANCES/AliRsnCutPrimaryVertex.cxx - RESONANCES/AliRsnCutESD2010.cxx - RESONANCES/AliRsnCutTrackQuality.cxx - RESONANCES/AliRsnCutPID.cxx - RESONANCES/AliRsnCutPIDITS.cxx - RESONANCES/AliRsnCutPIDTPC.cxx - RESONANCES/AliRsnCutPIDTOF.cxx - RESONANCES/AliRsnCutMomentumComparison.cxx - RESONANCES/AliRsnCutSet.cxx - RESONANCES/AliRsnExpression.cxx - RESONANCES/AliRsnVariableExpression.cxx - RESONANCES/AliRsnCutManager.cxx - RESONANCES/AliRsnFunction.cxx - RESONANCES/AliRsnMonitor.cxx - RESONANCES/AliRsnMonitorFunctions.cxx - RESONANCES/AliRsnMonitorNtuple.cxx - RESONANCES/AliRsnPair.cxx - RESONANCES/AliRsnPairFunctions.cxx - RESONANCES/AliRsnPairNtuple.cxx - RESONANCES/AliRsnAnalysisManager.cxx - RESONANCES/AliRsnVATProcessInfo.cxx - RESONANCES/AliRsnVAnalysisTaskSE.cxx - RESONANCES/AliRsnAnalysisSE.cxx - RESONANCES/AliRsnAnalysisEffSE.cxx - RESONANCES/AliRsnVAnalysisTask.cxx - RESONANCES/AliRsnAnalysisTask.cxx - RESONANCES/AliRsnAnalysisTaskEff.cxx - RESONANCES/AliRsnAnalysisTaskEffMonitor.cxx - RESONANCES/AliRsnAnalysisTaskEffPair.cxx - RESONANCES/AliRsnMonitorTrack.cxx - RESONANCES/AliRsnAnalysisMonitorTask.cxx ) + RESONANCES/AliRsnPairDef.cxx + RESONANCES/AliRsnTarget.cxx + RESONANCES/AliRsnValue.cxx + RESONANCES/AliRsnCut.cxx + RESONANCES/AliRsnValueStd.cxx + RESONANCES/AliRsnValuePID.cxx + RESONANCES/AliRsnCutPrimaryVertex.cxx + RESONANCES/AliRsnCutTrackQuality.cxx + RESONANCES/AliRsnCutValue.cxx + RESONANCES/AliRsnCutPID.cxx + RESONANCES/AliRsnCutPIDITS.cxx + RESONANCES/AliRsnCutPIDTPC.cxx + RESONANCES/AliRsnCutPIDTOF.cxx + RESONANCES/AliRsnCutPIDNSigma.cxx + RESONANCES/AliRsnCutMomentumComparison.cxx + RESONANCES/AliRsnCutSet.cxx + RESONANCES/AliRsnExpression.cxx + RESONANCES/AliRsnVariableExpression.cxx + RESONANCES/AliRsnCutManager.cxx + RESONANCES/AliRsnListOutput.cxx + RESONANCES/AliRsnLoop.cxx + RESONANCES/AliRsnLoopDaughter.cxx + RESONANCES/AliRsnLoopPair.cxx + RESONANCES/AliRsnLoopEvent.cxx + RESONANCES/AliRsnLoopEff.cxx + RESONANCES/AliRsnLoopEffPair.cxx + RESONANCES/AliRsnDaughterSelector.cxx + RESONANCES/AliRsnInputHandler.cxx + RESONANCES/AliRsnAnalysisTask.cxx ) string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" ) diff --git a/PWG2/PWG2resonancesLinkDef.h b/PWG2/PWG2resonancesLinkDef.h index 0871710d06a..ef0efc30868 100644 --- a/PWG2/PWG2resonancesLinkDef.h +++ b/PWG2/PWG2resonancesLinkDef.h @@ -2,22 +2,26 @@ #pragma link C++ class AliRsnDaughter+; #pragma link C++ class AliRsnMother+; +#pragma link C++ class AliRsnEvent+; + #pragma link C++ class AliRsnDaughterDef+; #pragma link C++ class AliRsnPairDef+; -#pragma link C++ class AliRsnEvent+; #pragma link C++ class AliRsnTarget+; #pragma link C++ class AliRsnValue+; #pragma link C++ class AliRsnCut+; -#pragma link C++ class AliRsnCutValue+; +#pragma link C++ class AliRsnValueStd+; +#pragma link C++ class AliRsnValuePID+; + #pragma link C++ class AliRsnCutPrimaryVertex+; -#pragma link C++ class AliRsnCutESD2010+; #pragma link C++ class AliRsnCutTrackQuality+; +#pragma link C++ class AliRsnCutValue+; #pragma link C++ class AliRsnCutPID+; #pragma link C++ class AliRsnCutPIDITS+; #pragma link C++ class AliRsnCutPIDTPC+; #pragma link C++ class AliRsnCutPIDTOF+; +#pragma link C++ class AliRsnCutPIDNSigma+; #pragma link C++ class AliRsnCutMomentumComparison+; #pragma link C++ class AliRsnCutSet+; @@ -25,29 +29,16 @@ #pragma link C++ class AliRsnVariableExpression+; #pragma link C++ class AliRsnCutManager+; -#pragma link C++ class AliRsnFunction+; -#pragma link C++ class AliRsnMonitor+; -#pragma link C++ class AliRsnMonitorFunctions+; -#pragma link C++ class AliRsnMonitorNtuple+; -#pragma link C++ class AliRsnPair+; -#pragma link C++ class AliRsnPairFunctions+; -#pragma link C++ class AliRsnPairNtuple+; - -#pragma link C++ class AliRsnAnalysisManager+; - -#pragma link C++ class AliRsnVATProcessInfo+; -#pragma link C++ class AliRsnVAnalysisTaskSE+; +#pragma link C++ class AliRsnListOutput+; +#pragma link C++ class AliRsnLoop+; +#pragma link C++ class AliRsnLoopDaughter+; +#pragma link C++ class AliRsnLoopPair+; +#pragma link C++ class AliRsnLoopEvent+; +#pragma link C++ class AliRsnLoopEff+; +#pragma link C++ class AliRsnLoopEffPair+; -#pragma link C++ class AliRsnAnalysisSE+; -#pragma link C++ class AliRsnAnalysisEffSE+; - -#pragma link C++ class AliRsnVAnalysisTask+; +#pragma link C++ class AliRsnDaughterSelector+; +#pragma link C++ class AliRsnInputHandler+; #pragma link C++ class AliRsnAnalysisTask+; -#pragma link C++ class AliRsnAnalysisTaskEff+; -#pragma link C++ class AliRsnAnalysisTaskEffMonitor+; -#pragma link C++ class AliRsnAnalysisTaskEffPair+; - -#pragma link C++ class AliRsnMonitorTrack+; -#pragma link C++ class AliRsnAnalysisMonitorTask+; #endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx b/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx deleted file mode 100644 index 1ce4456071e..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisEffSE.cxx +++ /dev/null @@ -1,794 +0,0 @@ -// -// Class AliRsnAnalysisEffSE -// -// TODO -// TODO -// -// authors: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// Martin Vala (martin.vala@cern.ch) -// -#include -#include "AliStack.h" -#include "AliESDEvent.h" -#include "AliAODEvent.h" -#include "AliMCEvent.h" - -#include "AliCFContainer.h" -#include "AliRsnCutManager.h" -#include "AliRsnValue.h" -#include "AliRsnAnalysisEffSE.h" -#include "AliRsnPairDef.h" -#include "AliRsnCutSet.h" - -ClassImp(AliRsnAnalysisEffSE) - -//_____________________________________________________________________________ -AliRsnAnalysisEffSE::AliRsnAnalysisEffSE(const char *name) : - AliRsnVAnalysisTaskSE(name), - fUseITSSA(kTRUE), - fUseGlobal(kTRUE), - fStepListMC(0), - fStepListESD(0), - fAxisList("AliRsnValue", 0), - fPairDefList(0), - fContainerList(0x0), - fOutList(0x0), - fVar(0), - fPair(), - fEventCuts("eventCuts", AliRsnCut::kEvent) -{ -// -// Default constructor. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - DefineOutput(2, TList::Class()); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -AliRsnAnalysisEffSE::AliRsnAnalysisEffSE(const AliRsnAnalysisEffSE& copy) : - AliRsnVAnalysisTaskSE(copy), - fUseITSSA(copy.fUseITSSA), - fUseGlobal(copy.fUseGlobal), - fStepListMC(copy.fStepListMC), - fStepListESD(copy.fStepListESD), - fAxisList(copy.fAxisList), - fPairDefList(copy.fPairDefList), - fContainerList(copy.fContainerList), - fOutList(0x0), - fVar(0), - fPair(), - fEventCuts(copy.fEventCuts) -{ -// -// Copy constrtuctor -// -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::AddStepMC(AliRsnCutManager *mgr) -{ -// -// Add a step on montecarlo -// - - fStepListMC.AddLast(mgr); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::AddStepESD(AliRsnCutManager *mgr) -{ -// -// Add a step on ESD -// - - fStepListESD.AddLast(mgr); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::AddAxis(AliRsnValue *axis) -{ -// -// Add a new axis -// - - Int_t n = fAxisList.GetEntries(); - new(fAxisList[n]) AliRsnValue(*axis); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::RsnUserCreateOutputObjects() -{ -// -// Creation of output objects. -// These are created through the utility methods in the analysis manager, -// which produces a list of histograms for each specified set of pairs. -// Each of these lists is added to the main list of this task. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - // get number of steps and axes - Int_t iaxis = 0; - Int_t nAxes = fAxisList.GetEntries(); - Int_t nSteps = (Int_t)fStepListMC.GetEntries() + (Int_t)fStepListESD.GetEntries(); - - if (!nSteps) { - AliError("No steps defined"); - return; - } - if (!nAxes) { - AliError("No axes defined"); - return; - } - - // initialize variable list - fVar.Set(nAxes); - - // retrieve number of bins for each axis - Int_t *nBins = new Int_t[nAxes]; - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis); - nBins[iaxis] = fcnAxis->GetArray().GetSize() - 1; - } - - // create ouput list of containers - fContainerList = new TList; - fContainerList->SetOwner(); - fContainerList->SetName(Form("%s_containers", GetName())); - - // initialize output list - OpenFile(2); - fOutList = new TList(); - fOutList->SetOwner(); - - // create the containers - Int_t i = 0, nDef = (Int_t)fPairDefList.GetEntries(); - for (i = 0; i < nDef; i++) { - AliRsnPairDef *def = (AliRsnPairDef*)fPairDefList[i]; - AliCFContainer *cont = new AliCFContainer(Form("%s", def->GetPairName()), "", nSteps, nAxes, nBins); - // set the bin limits for each axis - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis); - cont->SetBinLimits(iaxis, fcnAxis->GetArray().GetArray()); - } - // add the container to output list - fContainerList->Add(cont); - } - - fOutList->Add(fContainerList); - fOutList->Print(); - - PostData(2, fOutList); - - // clear heap - delete [] nBins; - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::RsnUserExec(Option_t*) -{ -// -// Execution of the analysis task. -// Recovers the input event and processes it with all included pair objects. -// In this case, we NEED to have ESD and MC, otherwise we cannod do anything. -// - - // process first MC steps and then ESD steps - AliRsnPairDef *pairDef = 0; - TObjArrayIter iter(&fPairDefList); - while ((pairDef = (AliRsnPairDef*)iter.Next())) { - if (fRsnEvent.IsESD()) ProcessEventESD(pairDef); - if (fRsnEvent.IsAOD()) ProcessEventAOD(pairDef); - } - - // Post the data - PostData(2, fOutList); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::ProcessEventESD(AliRsnPairDef *pairDef) -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliStack *stack = fRsnEvent.GetRefMCESD()->Stack(); - AliESDEvent *esd = fRsnEvent.GetRefESD(); - AliMCEvent *mc = fRsnEvent.GetRefMCESD(); - AliMCParticle *mother; - - if (!pairDef) return; - AliCFContainer *cont = (AliCFContainer*)fContainerList->FindObject(pairDef->GetPairName()); - if (!cont) return; - - // get informations from pairDef - Int_t pdgM = 0; - Int_t pdgD[2] = {0, 0}; - Short_t chargeD[2] = {0, 0}; - pdgM = pairDef->GetMotherPDG(); - pdgD [0] = AliPID::ParticleCode(pairDef->GetPID(0)); - pdgD [1] = AliPID::ParticleCode(pairDef->GetPID(1)); - chargeD[0] = pairDef->GetChargeS(0); - chargeD[1] = pairDef->GetChargeS(1); - - // other utility variables - Int_t first, j, ipart; - Int_t label[2] = { -1, -1}; - Short_t charge[2] = {0, 0}; - Short_t pairDefMatch[2] = { -1, -1}; - Int_t esdIndex[2] = { -1, -1}; - TParticle *part[2] = {0, 0}; - - // in this case, we first take the resonance from MC - // and then we find its daughters and compute cuts on them - for (ipart = 0; ipart < stack->GetNprimary(); ipart++) { - // take a track from the MC event - mother = (AliMCParticle*) fMCEvent->GetTrack(ipart); - - // check that it is a binary decay and the PDG code matches - if (mother->Particle()->GetNDaughters() != 2) continue; - if (mother->Particle()->GetPdgCode() != pdgM) continue; - - // store the labels of the two daughters - label[0] = mother->Particle()->GetFirstDaughter(); - label[1] = mother->Particle()->GetLastDaughter(); - - // retrieve the particles and other stuff - // check if they match the order in the pairDef - for (j = 0; j < 2; j++) { - if (label[j] < 0) continue; - part[j] = stack->Particle(label[j]); - pdgD[j] = TMath::Abs(part[j]->GetPdgCode()); - charge[j] = (Short_t)(part[j]->GetPDG()->Charge() / 3); - if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(0)) && charge[j] == pairDef->GetChargeS(0)) - pairDefMatch[j] = 0; - else if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(1)) && charge[j] == pairDef->GetChargeS(1)) - pairDefMatch[j] = 1; - else - pairDefMatch[j] = -1; - - // find corresponding ESD particle: first try rejecting fakes, - // and in case of failure, try accepting fakes - esdIndex[j] = FindESDtrack(label[j], esd, kTRUE); - //TArrayI idx = FindESDtracks(label[j], esd); - //for (Int_t kk = 0; kk < idx.GetSize(); kk++) cout << "DAUGHTER " << j << " --> FOUND INDEX: " << idx[kk] << endl; - if (esdIndex[j] < 0) esdIndex[j] = FindESDtrack(label[j], esd, kFALSE); - //cout << "DAUGHTER " << j << " SINGLE FOUND INDEX = " << esdIndex[j] << endl; - } - - // since each candidate good resonance is taken once, we must check - // that it matches the pair definition in any order, and reject in case - // in none of them the pair is OK - // anyway, we must associate the correct daughter to the correct data member - if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1) { - // 1st track --> 1st member of PairDef - fDaughter[0].SetRef(mc->GetTrack(label[0])); - fDaughter[0].SetRefMC((AliMCParticle*)mc->GetTrack(label[0])); - fDaughter[0].SetGood(); - // 2nd track --> 2nd member of PairDef - fDaughter[1].SetRef(mc->GetTrack(label[1])); - fDaughter[1].SetRefMC((AliMCParticle*)mc->GetTrack(label[1])); - fDaughter[1].SetGood(); - } else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0)) { - // 1st track --> 2nd member of PairDef - fDaughter[0].SetRef(mc->GetTrack(label[1])); - fDaughter[0].SetRefMC((AliMCParticle*)mc->GetTrack(label[1])); - fDaughter[0].SetGood(); - // 2nd track --> 1st member of PairDef - fDaughter[1].SetRef(mc->GetTrack(label[0])); - fDaughter[1].SetRefMC((AliMCParticle*)mc->GetTrack(label[0])); - fDaughter[1].SetGood(); - } else { - fDaughter[0].SetBad(); - fDaughter[1].SetBad(); - } - - // reject the pair if the matching was unsuccessful - if (!fDaughter[0].IsOK() || !fDaughter[1].IsOK()) continue; - - // first, we set the internal AliRsnMother object to - // the MC particles and then operate the selections on MC - fPair.SetDaughter(0, &fDaughter[0]); - fPair.SetDaughter(1, &fDaughter[1]); - fPair.ComputeSum(pairDef->GetMass1(), pairDef->GetMass2()); - FillContainer(cont, &fStepListMC, pairDef, 0); - - // then, if both particles found a good match in the ESD - // reassociate the ESD tracks to the pair and fill ESD containers - if (esdIndex[0] < 0 || esdIndex[1] < 0) continue; - if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1) { - // 1st track --> 1st member of PairDef - fDaughter[0].SetRef(esd->GetTrack(esdIndex[0])); - // 2nd track --> 2nd member of PairDef - fDaughter[1].SetRef(esd->GetTrack(esdIndex[1])); - //cout << "****** MATCHING SCHEME 1" << endl; - } else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0)) { - // 1st track --> 2nd member of PairDef - fDaughter[0].SetRef(esd->GetTrack(esdIndex[1])); - // 2nd track --> 1st member of PairDef - fDaughter[1].SetRef(esd->GetTrack(esdIndex[0])); - //cout << "****** MATCHING SCHEME 2" << endl; - } - //cout << "****** IDs = " << fDaughter[0].GetID() << ' ' << fDaughter[1].GetID() << endl; - // here we must remember how many steps were already filled - first = (Int_t)fStepListMC.GetEntries(); - FillContainer(cont, &fStepListESD, pairDef, first); - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::ProcessEventAOD(AliRsnPairDef *pairDef) -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliAODEvent *aod = fRsnEvent.GetRefAOD(); - AliAODMCParticle *mother; - TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); - if (!mcArray) return; - - if (!pairDef) return; - AliCFContainer *cont = (AliCFContainer*)fContainerList->FindObject(pairDef->GetPairName()); - if (!cont) return; - - // get informations from pairDef - Int_t pdgM = 0; - Int_t pdgD[2] = {0, 0}; - Short_t chargeD[2] = {0, 0}; - pdgM = pairDef->GetMotherPDG(); - pdgD [0] = AliPID::ParticleCode(pairDef->GetPID(0)); - pdgD [1] = AliPID::ParticleCode(pairDef->GetPID(1)); - chargeD[0] = pairDef->GetChargeS(0); - chargeD[1] = pairDef->GetChargeS(1); - - // other utility variables - Int_t first, j; - Int_t label [2] = { -1, -1}; - Short_t charge[2] = {0, 0}; - Short_t pairDefMatch[2] = { -1, -1}; - Int_t aodIndex[2] = { -1, -1}; - AliAODMCParticle *part[2] = {0, 0}; - - // loop on MC particles - TObjArrayIter next(mcArray); - while ((mother = (AliAODMCParticle*)next())) { - // check that it is a binary decay and the PDG code matches - if (mother->GetNDaughters() != 2) continue; - if (mother->GetPdgCode() != pdgM) continue; - - // store the labels of the two daughters - label[0] = mother->GetDaughter(0); - label[1] = mother->GetDaughter(1); - - // retrieve the particles and other stuff - // check if they match the order in the pairDef - for (j = 0; j < 2; j++) { - if (label[j] < 0) continue; - part[j] = (AliAODMCParticle*)mcArray->At(label[j]); - pdgD[j] = TMath::Abs(part[j]->GetPdgCode()); - charge[j] = (Short_t)(part[j]->Charge()); - if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(0)) && charge[j] == pairDef->GetChargeS(0)) - pairDefMatch[j] = 0; - else if (pdgD[j] == AliPID::ParticleCode(pairDef->GetPID(1)) && charge[j] == pairDef->GetChargeS(1)) - pairDefMatch[j] = 1; - else - pairDefMatch[j] = -1; - - // find corresponding ESD particle: first try rejecting fakes, - // and in case of failure, try accepting fakes - aodIndex[j] = FindAODtrack(label[j], aod, kTRUE); - if (aodIndex[j] < 0) aodIndex[j] = FindAODtrack(label[j], aod, kFALSE); - } - - // since each candidate good resonance is taken once, we must check - // that it matches the pair definition in any order, and reject in case - // in none of them the pair is OK - // anyway, we must associate the correct daughter to the correct data member - if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1) { - // 1st track --> 1st member of PairDef - fDaughter[0].SetRef((AliAODMCParticle*)mcArray->At(label[0])); - fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[0])); - fDaughter[0].SetGood(); - // 2nd track --> 2nd member of PairDef - fDaughter[1].SetRef((AliAODMCParticle*)mcArray->At(label[1])); - fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[1])); - fDaughter[1].SetGood(); - } else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0)) { - // 1st track --> 2nd member of PairDef - fDaughter[0].SetRef((AliAODMCParticle*)mcArray->At(label[1])); - fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[1])); - fDaughter[0].SetGood(); - // 2nd track --> 1st member of PairDef - fDaughter[1].SetRef((AliAODMCParticle*)mcArray->At(label[0])); - fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[0])); - fDaughter[1].SetGood(); - } else { - fDaughter[0].SetBad(); - fDaughter[1].SetBad(); - } - - // reject the pair if the matching was unsuccessful - if (!fDaughter[0].IsOK() || !fDaughter[1].IsOK()) continue; - - // first, we set the internal AliRsnMother object to - // the MC particles and then operate the selections on MC - fPair.SetDaughter(0, &fDaughter[0]); - fPair.SetDaughter(1, &fDaughter[1]); - fPair.ComputeSum(pairDef->GetMass1(), pairDef->GetMass2()); - FillContainer(cont, &fStepListMC, pairDef, 0); - - // then, if both particles found a good match in the AOD - // reassociate the AOD tracks to the pair and fill AOD containers - if (aodIndex[0] < 0 || aodIndex[1] < 0) continue; - if (pairDefMatch[0] == 0 && pairDefMatch[1] == 1) { - // 1st track --> 1st member of PairDef - fDaughter[0].SetRef(aod->GetTrack(aodIndex[0])); - // 2nd track --> 2nd member of PairDef - fDaughter[1].SetRef(aod->GetTrack(aodIndex[1])); - //cout << "****** MATCHING SCHEME 1" << endl; - } else if ((pairDefMatch[0] == 1 && pairDefMatch[1] == 0)) { - // 1st track --> 2nd member of PairDef - fDaughter[0].SetRef(aod->GetTrack(aodIndex[1])); - // 2nd track --> 1st member of PairDef - fDaughter[1].SetRef(aod->GetTrack(aodIndex[0])); - //cout << "****** MATCHING SCHEME 2" << endl; - } - //cout << "****** IDs = " << fDaughter[0].GetID() << ' ' << fDaughter[1].GetID() << endl; - // here we must remember how many steps were already filled - first = (Int_t)fStepListMC.GetEntries(); - FillContainer(cont, &fStepListESD, pairDef, first); - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::FillContainer(AliCFContainer *cont, const TObjArray *stepList, AliRsnPairDef *pd, Int_t firstOutStep) -{ -// -// Fill the containers -// - - Int_t iaxis, nAxes = fAxisList.GetEntries(); - Int_t istep, nSteps = stepList->GetEntries(); - Bool_t computeOK; - - // set daughters to pair - fPair.SetDaughter(0, &fDaughter[0]); - fPair.SetDaughter(1, &fDaughter[1]); - fPair.ComputeSum(pd->GetMass1(), pd->GetMass2()); - - // compute values for all axes - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxisList.At(iaxis); - fVar[iaxis] = -1E10; - switch (fcnAxis->GetTargetType()) { - case AliRsnTarget::kMother: - fcnAxis->SetSupportObject(pd); - computeOK = fcnAxis->Eval(&fPair); - break; - case AliRsnTarget::kEvent: - computeOK = fcnAxis->Eval(&fRsnEvent); - break; - default: - AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName())); - computeOK = kFALSE; - } - if (computeOK) fVar[iaxis] = ((Float_t)fcnAxis->GetComputedValue()); - } - - // fill all steps - for (istep = 0; istep < nSteps; istep++) { - AliRsnCutManager *cutMgr = (AliRsnCutManager*)stepList->At(istep); - if (!cutMgr->PassCommonDaughterCuts(&fDaughter[0])) break; - if (!cutMgr->PassCommonDaughterCuts(&fDaughter[1])) break; - if (!cutMgr->PassDaughter1Cuts(&fDaughter[0])) break; - if (!cutMgr->PassDaughter2Cuts(&fDaughter[1])) break; - if (!cutMgr->PassMotherCuts(&fPair)) break; - //cout << "**************************************** FILLING STEP " << istep << endl; - cont->Fill(fVar.GetArray(), istep + firstOutStep); - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::RsnTerminate(Option_t*) -{ -// -// Termination. -// Could be added some monitor histograms here. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisEffSE::AddPairDef(AliRsnPairDef* pairDef) -{ -// -// Adds pair definition -// - fPairDefList.AddLast(pairDef); -} - -//_____________________________________________________________________________ -Int_t AliRsnAnalysisEffSE::FindESDtrack(Int_t label, AliESDEvent *esd, Bool_t rejectFakes) -{ -// -// Finds in the ESD a track whose label corresponds to that in argument. -// When global tracks are enabled, tries first to find a global track -// satisfying that requirement. -// If no global tracks are found, if ITS-SA are enable, tries to search among them -// otherwise return a negative number. -// If global tracks are disabled, search only among ITS SA -// - - Int_t i = 0; - Int_t ntracks = esd->GetNumberOfTracks(); - ULong_t status; - Bool_t isTPC; - Bool_t isITSSA; - - // loop for global tracks - if (fUseGlobal) { - for (i = 0; i < ntracks; i++) { - AliESDtrack *track = esd->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isTPC = ((status & AliESDtrack::kTPCin) != 0); - if (!isTPC) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - // if required, reject fakes - if (rejectFakes && track->GetLabel() < 0) continue; - - // if all checks are passed and we are searching among global - // this means that thie track is a global one with the right label - // then, the return value is set to this, and returned - return i; - } - } - - // loop for ITS-SA tracks (this happens only if no global tracks were found - // or searching among globals is disabled) - if (fUseITSSA) { - for (i = 0; i < ntracks; i++) { - AliESDtrack *track = esd->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0); - if (!isITSSA) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - // if required, reject fakes - if (rejectFakes && track->GetLabel() < 0) continue; - - // if all checks are passed and we are searching among global - // this means that thie track is a global one with the right label - // then, the return value is set to this, and returned - return i; - } - } - - // if we reach this point, no match were found - return -1; -} - -//_____________________________________________________________________________ -TArrayI AliRsnAnalysisEffSE::FindESDtracks(Int_t label, AliESDEvent *esd) -{ -// -// Finds in the ESD a track whose label corresponds to that in argument. -// When global tracks are enabled, tries first to find a global track -// satisfying that requirement. -// If no global tracks are found, if ITS-SA are enable, tries to search among them -// otherwise return a negative number. -// If global tracks are disabled, search only among ITS SA -// - - Int_t i = 0; - Int_t ntracks = esd->GetNumberOfTracks(); - ULong_t status; - Bool_t isTPC; - Bool_t isITSSA; - TArrayI array(100); - Int_t nfound = 0; - - // loop for global tracks - if (fUseGlobal) { - for (i = 0; i < ntracks; i++) { - AliESDtrack *track = esd->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isTPC = ((status & AliESDtrack::kTPCin) != 0); - if (!isTPC) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - array[nfound++] = i; - } - } - - // loop for ITS-SA tracks (this happens only if no global tracks were found - // or searching among globals is disabled) - if (fUseITSSA) { - for (i = 0; i < ntracks; i++) { - AliESDtrack *track = esd->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0); - if (!isITSSA) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - array[nfound++] = i; - } - } - - array.Set(nfound); - return array; -} - -//_____________________________________________________________________________ -Int_t AliRsnAnalysisEffSE::FindAODtrack(Int_t label, AliAODEvent *aod, Bool_t rejectFakes) -{ -// -// Finds in the ESD a track whose label corresponds to that in argument. -// When global tracks are enabled, tries first to find a global track -// satisfying that requirement. -// If no global tracks are found, if ITS-SA are enable, tries to search among them -// otherwise return a negative number. -// If global tracks are disabled, search only among ITS SA -// - - Int_t i = 0; - Int_t ntracks = aod->GetNumberOfTracks(); - ULong_t status; - Bool_t isTPC; - Bool_t isITSSA; - - // loop for global tracks - if (fUseGlobal) { - for (i = 0; i < ntracks; i++) { - AliAODTrack *track = aod->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isTPC = ((status & AliESDtrack::kTPCin) != 0); - if (!isTPC) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - // if required, reject fakes - if (rejectFakes && track->GetLabel() < 0) continue; - - // if all checks are passed and we are searching among global - // this means that thie track is a global one with the right label - // then, the return value is set to this, and returned - return i; - } - } - - // loop for ITS-SA tracks (this happens only if no global tracks were found - // or searching among globals is disabled) - if (fUseITSSA) { - for (i = 0; i < ntracks; i++) { - AliAODTrack *track = aod->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0); - if (!isITSSA) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - // if required, reject fakes - if (rejectFakes && track->GetLabel() < 0) continue; - - // if all checks are passed and we are searching among global - // this means that thie track is a global one with the right label - // then, the return value is set to this, and returned - return i; - } - } - - // if we reach this point, no match were found - return -1; -} - -//_____________________________________________________________________________ -TArrayI AliRsnAnalysisEffSE::FindAODtracks(Int_t label, AliAODEvent *aod) -{ -// -// Finds in the ESD a track whose label corresponds to that in argument. -// When global tracks are enabled, tries first to find a global track -// satisfying that requirement. -// If no global tracks are found, if ITS-SA are enable, tries to search among them -// otherwise return a negative number. -// If global tracks are disabled, search only among ITS SA -// - - Int_t i = 0; - Int_t ntracks = aod->GetNumberOfTracks(); - ULong_t status; - Bool_t isTPC; - Bool_t isITSSA; - TArrayI array(100); - Int_t nfound = 0; - - // loop for global tracks - if (fUseGlobal) { - for (i = 0; i < ntracks; i++) { - AliAODTrack *track = aod->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isTPC = ((status & AliESDtrack::kTPCin) != 0); - if (!isTPC) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - array[nfound++] = i; - } - } - - // loop for ITS-SA tracks (this happens only if no global tracks were found - // or searching among globals is disabled) - if (fUseITSSA) { - for (i = 0; i < ntracks; i++) { - AliAODTrack *track = aod->GetTrack(i); - status = (ULong_t)track->GetStatus(); - isITSSA = ((status & AliESDtrack::kTPCin) == 0 && (status & AliESDtrack::kITSrefit) != 0 && (status & AliESDtrack::kITSpureSA) == 0 && (status & AliESDtrack::kITSpid) != 0); - if (!isITSSA) continue; - - // check that label match - if (TMath::Abs(track->GetLabel()) != label) continue; - - array[nfound++] = i; - } - } - - array.Set(nfound); - return array; -} - -//______________________________________________________________________________ -Bool_t AliRsnAnalysisEffSE::EventProcess() -{ -// -// Customized event pre-processing. -// First checks if the current event passes all cuts, -// and if it does, updates the informations and then -// call the operations which are already defined in the -// omonyme function in mother class -// - - // initially, an event is expected to be bad - fTaskInfo.SetEventUsed(kFALSE); - - // check the event cuts and update the info data accordingly - // events not passing the cuts must be rejected - if (!fEventCuts.IsSelected(&fRsnEvent)) { - fTaskInfo.SetEventUsed(kFALSE); - return kFALSE; - } - - // if we reach this point, cuts were passed; - // then additional operations can be done - - // find leading particle (without any PID/momentum restriction) - fRsnEvent.SelectLeadingParticle(0); - - // final return value is positive - // but call the mother class method which updates info object - fTaskInfo.SetEventUsed(kTRUE); - return AliRsnVAnalysisTaskSE::EventProcess(); -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisEffSE.h b/PWG2/RESONANCES/AliRsnAnalysisEffSE.h deleted file mode 100644 index d0d86c5e32e..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisEffSE.h +++ /dev/null @@ -1,81 +0,0 @@ -// -// Class AliRsnAnalysisEffSE -// -// Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// -#ifndef ALIRSNANALYSISEFFSE_H -#define ALIRSNANALYSISEFFSE_H - -#include -#include -#include - -#include "AliRsnVAnalysisTaskSE.h" -#include "AliRsnEvent.h" -#include "AliRsnMother.h" -#include "AliRsnDaughter.h" - -class AliPID; - -class AliCFContainer; - -class AliRsnPairDef; -class AliRsnPIDIndex; -class AliRsnPIDDefESD; -class AliRsnCutSet; -class AliRsnCutManager; -class AliRsnValue; - -class AliRsnAnalysisManager; -class AliRsnAnalysisEffSE : public AliRsnVAnalysisTaskSE { - -public: - AliRsnAnalysisEffSE(const char *name = "AliRsnAnalysisTaskEffSE"); - AliRsnAnalysisEffSE(const AliRsnAnalysisEffSE& copy); - virtual ~AliRsnAnalysisEffSE() {;}; - - // Implement this - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnTerminate(Option_t*); - virtual Bool_t EventProcess(); - - // settings - AliRsnCutSet* GetEventCuts() {return &fEventCuts;} - void AddPairDef(AliRsnPairDef *pairDef); - void AddStepMC(AliRsnCutManager *mgr); - void AddStepESD(AliRsnCutManager *mgr); - void AddAxis(AliRsnValue *axis); - -private: - - AliRsnAnalysisEffSE& operator=(const AliRsnAnalysisEffSE& /*copy*/) {return *this;} - void ProcessEventESD(AliRsnPairDef *pairDef); - void ProcessEventAOD(AliRsnPairDef *pairDef); - void FillContainer(AliCFContainer *cont, const TObjArray *stepList, AliRsnPairDef *pd, Int_t firstOutStep); - Int_t FindESDtrack(Int_t label, AliESDEvent *esd, Bool_t rejectFakes); - TArrayI FindESDtracks(Int_t label, AliESDEvent *esd); - Int_t FindAODtrack(Int_t label, AliAODEvent *aod, Bool_t rejectFakes); - TArrayI FindAODtracks(Int_t label, AliAODEvent *aod); - - Bool_t fUseITSSA; // switch to use ITS standalone tracks - Bool_t fUseGlobal; // switch to use global tracks - TObjArray fStepListMC; // list of cut managers for all steps with MC - TObjArray fStepListESD; // list of cut managers for all steps with ESD - TClonesArray fAxisList; // list of axes of efficiency plots - TObjArray fPairDefList; // decay channels - TList *fContainerList; // list of CF containers - TList *fOutList; // global output list - TArrayD fVar; // list of variables of the container - AliRsnMother fPair; // interface to pair - AliRsnDaughter fDaughter[2]; // interface to tracks - AliRsnCutSet fEventCuts; // event cuts - - ClassDef(AliRsnAnalysisEffSE, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisManager.cxx b/PWG2/RESONANCES/AliRsnAnalysisManager.cxx deleted file mode 100644 index 92d5c6e6844..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisManager.cxx +++ /dev/null @@ -1,330 +0,0 @@ -/************************************************************************** - * 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. * - **************************************************************************/ - -//////////////////////////////////////////////////////////////////////////////// -// -// This is the uppermost level in the analysis task and is built as a -// separate object since up to this level the execution of the analysis -// is not directly related to the real analysis task structure. -// An analysis task for resonances will just configure and initialize an -// instance of this class, which will do all the work, and will share with it -// the TList containing all the outputs. -// -// This object collects all AliRsnPair and AliRsnMonitor objects which do -// the computations and fill histograms, each properly initialized with -// outputs (histos, ntuples) and cuts on whatever is needed. -// -// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it) -// M. Vala (martin.vala@cern.ch) -// -//////////////////////////////////////////////////////////////////////////////// - -#include -#include -#include - -#include "AliLog.h" -#include "AliStack.h" -#include "AliVEvent.h" -#include "AliMCEvent.h" -#include "AliRsnEvent.h" -#include "AliRsnPairFunctions.h" -#include "AliRsnPairNtuple.h" -#include "AliRsnMonitorFunctions.h" -#include "AliRsnMonitorNtuple.h" - -#include "AliRsnAnalysisManager.h" - - -ClassImp(AliRsnAnalysisManager) - -//_____________________________________________________________________________ -AliRsnAnalysisManager::AliRsnAnalysisManager(const char *name) : - TNamed(name, ""), - fAddUsageHist(kFALSE), - fList(0x0), - fPairs(0), - fMonitors(0) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisManager::AliRsnAnalysisManager(const AliRsnAnalysisManager& copy) : - TNamed(copy), - fAddUsageHist(copy.fAddUsageHist), - fList(copy.fList), - fPairs(copy.fPairs), - fMonitors(copy.fMonitors) -{ -// -// Copy constructor -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisManager& AliRsnAnalysisManager::operator=(const AliRsnAnalysisManager& copy) -{ -// -// Assignment operator -// - - TNamed::operator=(copy); - - fAddUsageHist = copy.fAddUsageHist; - fList = copy.fList; - fPairs = copy.fPairs; - fMonitors = copy.fMonitors; - - return (*this); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisManager::Add(AliRsnPair *pair) -{ -// -// Adds a new pair to the list. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - if (!pair) { - AliWarning(Form("AliRsnPairManager is %p. Skipping ...", pair)); - return; - } - - AliDebug(AliLog::kDebug + 1, Form("Adding %s [%d]...", pair->GetName(), fPairs.GetEntries())); - fPairs.Add(pair); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisManager::Add(AliRsnMonitor *monitor) -{ -// -// Adds a new monitor to the list. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - if (!monitor) { - AliWarning(Form("AliRsnPairManager is %p. Skipping ...", monitor)); - return; - } - - AliDebug(AliLog::kDebug + 1, Form("Adding %s [%d]...", monitor->GetName(), fMonitors.GetEntries())); - fMonitors.Add(monitor); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisManager::Print(Option_t* /*dummy*/) const -{ -// -// Overload of the TObject::Print() method -// - - AliInfo(Form("\t======== Analysis Manager %s ========", GetName())); - PrintArray(); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisManager::PrintArray() const -{ -// -// Calls the "Print" method of all included pair managers -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - AliRsnPair *pair = 0; - TObjArrayIter nextPair(&fPairs); - while ((pair = (AliRsnPair*)nextPair())) pair->Print(); - - AliRsnMonitor *monitor = 0; - TObjArrayIter nextMonitor(&fMonitors); - while ((monitor = (AliRsnMonitor*)nextMonitor())) monitor->Print(); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisManager::InitAllPairs(TList *list) -{ -// -// Initialize all pair managers, and put all the TList of histograms -// generated by each one into a unique final output TList -// - - Int_t i = 0; - - // pairs - AliRsnPair *pair = 0; - TObjArrayIter nextPair(&fPairs); - while ((pair = (AliRsnPair*)nextPair())) { - AliDebug(AliLog::kDebug + 1, Form("InitAllPairs of the PairManager(%s) [%d] ...", pair->GetName(), i++)); - pair->Init(GetName(), list); - - // add a counter for used/unused events for each pair - if (fAddUsageHist) { - TH1I *hPairUsed = new TH1I(Form("%s_%s_USED", GetName(), pair->GetName()), "Used events for pair", 2, 0, 2); - list->Add(hPairUsed); - } - } - - // monitors - i = 0; - AliRsnMonitor *monitor = 0; - TObjArrayIter nextMonitor(&fMonitors); - while ((monitor = (AliRsnMonitor*)nextMonitor())) { - AliDebug(AliLog::kDebug + 1, Form("InitAllPairs of the PairManager(%s) [%d] ...", monitor->GetName(), i++)); - monitor->Init(GetName(), list); - } - - // set list pointer - fList = list; - fList->Print(); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisManager::ProcessAll(AliRsnEvent *ev0, AliRsnEvent *ev1, Bool_t pureMC) -{ -// -// Loop on all pairs/monitors stored here -// and process all candidate daughters. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - // don't do anything if the output list isn't initialized - if (!fList) return; - - // if second event is NULL, we assume that analysis is on single event - Bool_t sameEvent = kFALSE; - if (!ev1) { - ev1 = ev0; - sameEvent = kTRUE; - } - - // if MC reference is absent, cannot process pure MC - if (pureMC && (!ev0->GetRefMC() || !ev1->GetRefMC())) { - AliError("Cannot process a pure MC analysis without MC references!"); - return; - } - - // count total number of candidates per event - // (sum of tracks, V0s and cascades) - Int_t nTot[2]; - if (pureMC) { - nTot[0] = ev0->GetRefMC()->GetNumberOfTracks(); - nTot[1] = ev1->GetRefMC()->GetNumberOfTracks(); - } else { - nTot[0] = ev0->GetAbsoluteSum(); - nTot[1] = ev1->GetAbsoluteSum(); - } - - // if there are only monitors and no pairs - // disable the inner loop by settin counter to zero - if (fPairs.IsEmpty()) nTot[1] = 0; - - // variables - Int_t i0, i1, i; - AliRsnDaughter daughter0, daughter1; - AliRsnPair *pair = 0x0; - AliRsnMonitor *monitor = 0x0; - TObjArrayIter nextPair(&fPairs); - TObjArrayIter nextMonitor(&fMonitors); - - // reset all counters which tell us - // how many entries were added now - while ((pair = (AliRsnPair*)nextPair())) { - pair->ResetCount(); - pair->GetMother()->SetRefEvent(daughter0.GetOwnerEvent()); - } - - // external loop - for (i0 = 0; i0 < nTot[0]; i0++) { - - // try to assign first track - // and check global cuts - // in case of ESD pure MC, skip not physical primaries - if (pureMC) { - if (ev0->IsESD()) if (!ev0->GetRefMCESD()->Stack()->IsPhysicalPrimary(i0)) continue; - if (!ev0->SetDaughterMC(daughter0, i0)) continue; - } else { - if (!ev0->SetDaughterAbs(daughter0, i0)) continue; - } - // when the assigment is unsuccessful, this i known in internal status flag - if (!daughter0.IsOK() || !daughter0.GetRef()) continue; - - // process all single-track monitors - nextMonitor.Reset(); - while ((monitor = (AliRsnMonitor*)nextMonitor())) - if (monitor->Fill(&daughter0)) - monitor->Compute(); - - // internal loop - // starts from next track or first, depending if not mixing or yes - for (i1 = (sameEvent ? i0 + 1 : 0); i1 < nTot[1]; i1++) { - - // try to assign first track - // and check global cuts - // in case of ESD pure MC, skip not physical primaries - if (pureMC) { - if (ev1->IsESD()) if (!ev1->GetRefMCESD()->Stack()->IsPhysicalPrimary(i1)) continue; - if (!ev1->SetDaughterMC(daughter1, i1)) continue; - } else { - if (!ev1->SetDaughterAbs(daughter1, i1)) continue; - } - // when the assigment is unsuccessful, this i known in internal status flag - if (!daughter1.IsOK() || !daughter1.GetRef()) continue; - - // loop over all pairs and make computations - i = 0; - nextPair.Reset(); - while ((pair = (AliRsnPair*)nextPair())) { - - // debug message - AliDebug(AliLog::kDebug + 1, Form("ProcessAllPairs of the AnalysisManager(%s) [%d] ...", pair->GetName(), i++)); - - // process the two tracks - // the Fill() method returns kTRUE if the two daughters - // do match the pair definition of each AliRsnPait object, - // and the pair is processed only in this case - if (pair->Fill(&daughter0, &daughter1, kTRUE)) { - pair->Compute(); - } else if (pair->Fill(&daughter1, &daughter0, kFALSE)) { - pair->Compute(); - } - } - } - } - - // update all count histograms counters - if (fAddUsageHist) { - nextPair.Reset(); - while ((pair = (AliRsnPair*)nextPair())) { - TH1I *hist = (TH1I*)fList->FindObject(Form("%s_%s_USED", GetName(), pair->GetName())); - if (!hist) continue; - if (pair->GetCount() > 0) hist->Fill(1); else hist->Fill(0); - } - } - - AliDebug(AliLog::kDebug + 2, "->"); -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisManager.h b/PWG2/RESONANCES/AliRsnAnalysisManager.h deleted file mode 100644 index bf4652765c2..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisManager.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef ALIRSNANALYSISMANAGER_H -#define ALIRSNANALYSISMANAGER_H - -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -//////////////////////////////////////////////////////////////////////////////// -// -// Manager for resonance analysis. -// -//////////////////////////////////////////////////////////////////////////////// - -#include - -class TList; -class AliRsnPair; -class AliRsnMonitor; - -class AliRsnAnalysisManager : public TNamed { -public: - - AliRsnAnalysisManager(const char *name = "RSN"); - AliRsnAnalysisManager(const AliRsnAnalysisManager& copy); - AliRsnAnalysisManager& operator=(const AliRsnAnalysisManager& copy); - virtual ~AliRsnAnalysisManager() { } - - virtual void Add(AliRsnPair *pair); - virtual void Add(AliRsnMonitor *monitor); - virtual void PrintArray() const; - virtual void Print(Option_t *option = "") const; - - void InitAllPairs(TList *list); - void ProcessAll(AliRsnEvent *ev0, AliRsnEvent *ev1, Bool_t pureMC = kFALSE); - -private: - - Bool_t fAddUsageHist; // flag to switch on the production of usage histograms - TList *fList; //! container for output histograms (external object) - TObjArray fPairs; // collection of pair objects for the different outputs - TObjArray fMonitors; // collection of monitor objects for the different outputs - - ClassDef(AliRsnAnalysisManager, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisMonitorTask.cxx b/PWG2/RESONANCES/AliRsnAnalysisMonitorTask.cxx deleted file mode 100644 index ad5f843eee0..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisMonitorTask.cxx +++ /dev/null @@ -1,339 +0,0 @@ -// -// Implementation file for implementation of data analysis aft 900 GeV -// -// Author: A. Pulvirenti -// - -#include "Riostream.h" -#include - -#include "TH1.h" -#include "TTree.h" -#include "TParticle.h" -#include "TRandom.h" -#include "TLorentzVector.h" - -#include "AliLog.h" -#include "AliESDpid.h" -#include "AliESDEvent.h" -#include "AliESDVertex.h" -#include "AliESDtrack.h" -#include "AliStack.h" -#include "AliMCEvent.h" -#include "AliTOFT0maker.h" -#include "AliTOFcalib.h" -#include "AliCDBManager.h" -#include "AliITSPIDResponse.h" -#include "AliRsnMonitorTrack.h" -#include "AliRsnDaughter.h" -#include "AliRsnEvent.h" - -#include "AliRsnAnalysisMonitorTask.h" - -ClassImp(AliRsnAnalysisMonitorTask) - -//__________________________________________________________________________________________________ -AliRsnAnalysisMonitorTask::AliRsnAnalysisMonitorTask(const char *name) : - AliAnalysisTaskSE(name), - fOut(0x0), - fTrack(0x0), - fESDpid(0x0), - fTOFmaker(0x0), - fTOFcalib(0x0), - fTOFcalibrateESD(kFALSE), - fTOFcorrectTExp(kFALSE), - fTOFuseT0(kFALSE), - fTOFtuneMC(kFALSE), - fTOFresolution(0.0), - fEventCuts("eventCuts", AliRsnCut::kEvent), - fTrackCuts("trackCuts", AliRsnCut::kDaughter) - -{ -// -// Constructor -// - - DefineOutput(1, TTree::Class()); -} - -//__________________________________________________________________________________________________ -AliRsnAnalysisMonitorTask::AliRsnAnalysisMonitorTask(const AliRsnAnalysisMonitorTask& copy) : - AliAnalysisTaskSE(copy), - fOut(0x0), - fTrack(0x0), - fESDpid(0x0), - fTOFmaker(0x0), - fTOFcalib(0x0), - fTOFcalibrateESD(kFALSE), - fTOFcorrectTExp(kFALSE), - fTOFuseT0(kFALSE), - fTOFtuneMC(kFALSE), - fTOFresolution(0.0), - fEventCuts(copy.fEventCuts), - fTrackCuts(copy.fTrackCuts) -{ -// -// Copy constructor -// -} - -//__________________________________________________________________________________________________ -AliRsnAnalysisMonitorTask& AliRsnAnalysisMonitorTask::operator=(const AliRsnAnalysisMonitorTask& copy) -{ -// -// Assignment operator -// - - fTOFcalibrateESD = copy.fTOFcalibrateESD; - fTOFcorrectTExp = copy.fTOFcorrectTExp; - fTOFuseT0 = copy.fTOFuseT0; - fTOFtuneMC = copy.fTOFtuneMC; - fTOFresolution = copy.fTOFresolution; - - return (*this); -} - -//__________________________________________________________________________________________________ -AliRsnAnalysisMonitorTask::~AliRsnAnalysisMonitorTask() -{ -// -// Destructor -// - - if (fOut) delete fOut; - if (fESDpid) delete fESDpid; - if (fTrack) delete fTrack; -} - -//__________________________________________________________________________________________________ -void AliRsnAnalysisMonitorTask::UserCreateOutputObjects() -{ -// -// Create the output data container -// - - // setup TPC response - fESDpid = new AliESDpid; - fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0], fTPCpar[1], fTPCpar[2], fTPCpar[3], fTPCpar[4]); - - // setup TOF maker & calibration - fTOFcalib = new AliTOFcalib; - fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib); - fTOFmaker->SetTimeResolution(fTOFresolution); - - // create output branch object - fTrack = new AliRsnMonitorTrack; - - // create output tree - OpenFile(1); - fOut = new TTree("rsnMonitor", "Informations on single tracks for cut checking"); - fOut->Branch("tracks", "AliRsnMonitorTrack", &fTrack); -} - -//__________________________________________________________________________________________________ -void AliRsnAnalysisMonitorTask::UserExec(Option_t *) -{ -// -// Main execution function. -// Fills the fHEvents data member with the following legenda: -// 0 -- event OK, prim vertex with tracks -// 1 -- event OK, prim vertex with SPD -// 2 -- event OK but vz large -// 3 -- event bad -// - - // retrieve ESD event and related stack (if available) - AliESDEvent *esd = dynamic_cast(fInputEvent); - AliStack *stack = 0x0; - - // skip NULL events - if (!esd) return; - if (fMCEvent) stack = fMCEvent->Stack(); - - // create interface objects to AliRsnEvent to check event cuts - AliRsnEvent event; - event.SetRef(esd); - event.SetRefMC(fMCEvent); - if (!fEventCuts.IsSelected(&event)) return; - - // check the event - Int_t type = EventEval(esd); - - // if processable, then process it - if (type == 0) ProcessESD(esd, esd->GetPrimaryVertexTracks(), stack); - else if (type == 1) ProcessESD(esd, esd->GetPrimaryVertexSPD() , stack); - else return; - - // update histogram container - PostData(1, fOut); -} - -//__________________________________________________________________________________________________ -void AliRsnAnalysisMonitorTask::Terminate(Option_t *) -{ -// -// Terminate -// -} - -//__________________________________________________________________________________________________ -Int_t AliRsnAnalysisMonitorTask::EventEval(AliESDEvent *esd) -{ -// -// Checks if the event is good for analysis. -// Returns: -// ---> 0 if a good primary vertex with tracks was found, -// ---> 1 if a good SPD primary vertex was found -// ---> 2 otherwise (event to be rejected) -// In any case, adds an entry to the TTree, to keep trace of all events. -// - - // get the best primary vertex: - // first try that with tracks, then the SPD one - const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks(); - const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD(); - if (vTrk->GetNContributors() > 0) { - return 0; - } else if (vSPD->GetNContributors() > 0) { - return 1; - } else { - return 2; - } -} - -//__________________________________________________________________________________________________ -void AliRsnAnalysisMonitorTask::ProcessESD -(AliESDEvent *esd, const AliESDVertex *v, AliStack *stack) -{ -// -// Process the ESD container, to read all tracks and copy their useful values. -// All info are stored into an AliRsnMonitorTrack object and saved into the -// TClonesArray which is one of the branches of the output TTree. -// - - // create interfacr objects - AliRsnEvent event; - AliRsnDaughter daughter; - event.SetRef(esd); - event.SetRefMC(fMCEvent); - - // ITS stuff #1 - // create the response function and initialize it to MC or not - // depending if the AliStack object is there or not - Bool_t isMC = (stack != 0x0); - AliITSPIDResponse itsrsp(isMC); - - // TOF stuff #1: init OCDB - Int_t run = esd->GetRunNumber(); - AliCDBManager *cdb = AliCDBManager::Instance(); - cdb->SetDefaultStorage("raw://"); - cdb->SetRun(run); - // TOF stuff #2: init calibration - fTOFcalib->SetCorrectTExp(fTOFcorrectTExp); - fTOFcalib->Init(); - // TOF stuff #3: calibrate - if (fTOFcalibrateESD) fTOFcalib->CalibrateESD(esd); - if (fTOFtuneMC) fTOFmaker->TuneForMC(esd); - if (fTOFuseT0) { - fTOFmaker->ComputeT0TOF(esd); - fTOFmaker->ApplyT0TOF(esd); - fESDpid->MakePID(esd, kFALSE, 0.); - } - - // loop on all tracks - Int_t i, k, nITS, ntracks = esd->GetNumberOfTracks();; - Bool_t isTPC, isITSSA, isTOF; - Float_t b[2], bCov[3]; - Double_t time[10]; - - for (i = 0; i < ntracks; i++) { - AliESDtrack *track = esd->GetTrack(i); - event.SetDaughter(daughter, i, AliRsnDaughter::kTrack); - - // reset the output object - // 'usable' flag will need to be set to 'ok' - fTrack->Reset(); - - // check cuts - fTrack->CutsPassed() = fTrackCuts.IsSelected(&daughter); - - // skip NULL pointers, kink daughters and tracks which - // cannot be propagated to primary vertex - if (!track) continue; - if ((Int_t)track->GetKinkIndex(0) > 0) continue; - if (!track->RelateToVertex(v, esd->GetMagneticField(), kVeryBig)) continue; - - // get MC info if possible - if (stack) fTrack->AdoptMC(TMath::Abs(track->GetLabel()), stack); - - // copy general info - fTrack->Status() = (UInt_t)track->GetStatus(); - fTrack->Length() = (Double_t)track->GetIntegratedLength(); - fTrack->Charge() = (Int_t)track->Charge(); - fTrack->PrecX() = (Double_t)track->Px(); - fTrack->PrecY() = (Double_t)track->Py(); - fTrack->PrecZ() = (Double_t)track->Pz(); - - // evaluate some flags from the status to decide what to do next in some points - isTPC = ((fTrack->Status() & AliESDtrack::kTPCin) != 0); - isITSSA = ((fTrack->Status() & AliESDtrack::kTPCin) == 0 && (fTrack->Status() & AliESDtrack::kITSrefit) != 0 && (fTrack->Status() & AliESDtrack::kITSpureSA) == 0 && (fTrack->Status() & AliESDtrack::kITSpid) != 0); - isTOF = ((fTrack->Status() & AliESDtrack::kTOFout) != 0 && (fTrack->Status() & AliESDtrack::kTIME) != 0); - - // accept only tracks which are TPC+ITS or ITS standalone - if (isITSSA) { - fTrack->ITSsa() = kTRUE; - fTrack->TOFok() = kFALSE; - } else if (isTPC) { - fTrack->ITSsa() = kFALSE; - fTrack->TOFok() = isTOF; - } else - continue; - - // get DCA to primary vertex - track->GetImpactParameters(b, bCov); - fTrack->DCAr() = (Double_t)b[0]; - fTrack->DCAz() = (Double_t)b[1]; - - // get ITS info - for (k = 0; k < 6; k++) { - fTrack->ITSmap(k) = track->HasPointOnITSLayer(k); - } - if (isITSSA) { - fTrack->ITSchi2() = track->GetITSchi2(); - fTrack->ITSsignal() = track->GetITSsignal(); - nITS = fTrack->SSDcount() + fTrack->SDDcount(); - for (k = 0; k < AliPID::kSPECIES; k++) { - fTrack->ITSnsigma(k) = itsrsp.GetNumberOfSigmas(fTrack->Prec(), fTrack->ITSsignal(), (AliPID::EParticleType)k, nITS, kTRUE); - } - } - - // get TPC info - if (isTPC) { - fTrack->TPCcount() = (Int_t)track->GetTPCclusters(0); - fTrack->TPCchi2() = (Double_t)track->GetTPCchi2(); - fTrack->TPCsignal() = (Double_t)track->GetTPCsignal(); - fTrack->PtpcX() = fTrack->PtpcY() = fTrack->PtpcZ() = 1E10; - if (track->GetInnerParam()) { - fTrack->PtpcX() = track->GetInnerParam()->Px(); - fTrack->PtpcY() = track->GetInnerParam()->Py(); - fTrack->PtpcZ() = track->GetInnerParam()->Pz(); - for (k = 0; k < AliPID::kSPECIES; k++) { - fTrack->TPCnsigma(k) = fESDpid->NumberOfSigmasTPC(track, (AliPID::EParticleType)k); - } - } - } - - // get TOF info - if (isTOF) { - track->GetIntegratedTimes(time); - fTrack->TOFsignal() = (Double_t)track->GetTOFsignal(); - for (k = 0; k < AliPID::kSPECIES; k++) { - fTrack->TOFref(k) = time[k]; - fTrack->TOFsigma(k) = (Double_t)fTOFmaker->GetExpectedSigma(fTrack->Prec(), time[k], AliPID::ParticleMass(k)); - } - } - - // add entry to TTree - fOut->Fill(); - } -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisMonitorTask.h b/PWG2/RESONANCES/AliRsnAnalysisMonitorTask.h deleted file mode 100644 index 642293b047a..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisMonitorTask.h +++ /dev/null @@ -1,77 +0,0 @@ -// -// Header file for implementation of data analysis aft 900 GeV -// -// Author: A. Pulvirenti -// - -#ifndef ALIRSNANALYSISMONITORTASK_H -#define ALIRSNANALYSISMONITORTASK_H - -#include "AliAnalysisTaskSE.h" -#include "AliRsnCutSet.h" - -class TH1I; -class TH1F; -class TTree; - -class AliStack; -class AliESDEvent; -class AliESDVertex; -class AliESDpid; -class AliTOFT0maker; -class AliTOFcalib; - -class AliRsnAnalysisMonitorTask : public AliAnalysisTaskSE { -public: - - AliRsnAnalysisMonitorTask(const char *name = "Phi7TeV"); - AliRsnAnalysisMonitorTask(const AliRsnAnalysisMonitorTask& copy); - AliRsnAnalysisMonitorTask& operator=(const AliRsnAnalysisMonitorTask& copy); - virtual ~AliRsnAnalysisMonitorTask(); - - void SetTPCpar(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4) - {fTPCpar[0] = p0; fTPCpar[1] = p1; fTPCpar[2] = p2; fTPCpar[3] = p3; fTPCpar[4] = p4;} - - void SetTOFcalibrateESD(Bool_t yn = kTRUE) {fTOFcalibrateESD = yn;} - void SetTOFcorrectTExp(Bool_t yn = kTRUE) {fTOFcorrectTExp = yn;} - void SetTOFuseT0(Bool_t yn = kTRUE) {fTOFuseT0 = yn;} - void SetTOFtuneMC(Bool_t yn = kTRUE) {fTOFtuneMC = yn;} - void SetTOFresolution(Double_t v = 100.0) {fTOFresolution = v;} - - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t *option = ""); - virtual void Terminate(Option_t *option = ""); - - Int_t EventEval(AliESDEvent *esd); - Bool_t IsTPCtrack(AliESDtrack *track); - Bool_t IsITSSAtrack(AliESDtrack *track); - void ProcessESD(AliESDEvent *esd, const AliESDVertex *v, AliStack *stack); - - AliRsnCutSet* GetEventCuts() {return &fEventCuts;} - AliRsnCutSet* GetTrackCuts() {return &fTrackCuts;} - -private: - - TTree *fOut; // output TTree - AliRsnMonitorTrack *fTrack; // branch object for output TTree - - Double_t fTPCpar[5]; // parameters for TPC bethe-Bloch - - AliESDpid *fESDpid; //! PID manager - - AliTOFT0maker *fTOFmaker; //! TOF time0 computator - AliTOFcalib *fTOFcalib; //! TOF calibration - Bool_t fTOFcalibrateESD; // TOF settings - Bool_t fTOFcorrectTExp; // TOF settings - Bool_t fTOFuseT0; // TOF settings - Bool_t fTOFtuneMC; // TOF settings - Double_t fTOFresolution; // TOF settings - - AliRsnCutSet fEventCuts; // event cuts - AliRsnCutSet fTrackCuts; // track cuts - - // ROOT dictionary - ClassDef(AliRsnAnalysisMonitorTask, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisSE.cxx b/PWG2/RESONANCES/AliRsnAnalysisSE.cxx deleted file mode 100644 index 060fe96a65e..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisSE.cxx +++ /dev/null @@ -1,164 +0,0 @@ -// -// Class AliRsnAnalysisSE -// -// Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include -#include -#include "AliESDEvent.h" -#include "AliMCEvent.h" -#include "AliAODEvent.h" - -#include "AliRsnCutSet.h" -#include "AliRsnVATProcessInfo.h" -#include "AliRsnAnalysisSE.h" - -ClassImp(AliRsnAnalysisSE) - -//_____________________________________________________________________________ -AliRsnAnalysisSE::AliRsnAnalysisSE(const char *name, Bool_t useKine) : - AliRsnVAnalysisTaskSE(name, useKine), - fRsnAnalysisManager(), - fEventCuts("eventCuts", AliRsnCut::kEvent), - fOutList(0x0), - fZeroEventPercentWarning(100), - fUseZeroEventWarning(kTRUE) -{ -// -// Default constructor. -// Defines another output slot for histograms/ntuples -// - - DefineOutput(2, TList::Class()); -} - -//_____________________________________________________________________________ -AliRsnAnalysisSE::AliRsnAnalysisSE(const AliRsnAnalysisSE& copy) : - AliRsnVAnalysisTaskSE(copy), - fRsnAnalysisManager(copy.fRsnAnalysisManager), - fEventCuts(copy.fEventCuts), - fOutList(0x0), - fZeroEventPercentWarning(copy.fZeroEventPercentWarning), - fUseZeroEventWarning(copy.fUseZeroEventWarning) -{ -// -// Copy constructor. -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisSE& AliRsnAnalysisSE::operator=(const AliRsnAnalysisSE& copy) -{ -// -// Assigment operator. -// - - AliRsnVAnalysisTaskSE::operator=(copy); - - fRsnAnalysisManager = copy.fRsnAnalysisManager; - fEventCuts = copy.fEventCuts; - if (fOutList) fOutList->Clear(); - fZeroEventPercentWarning = copy.fZeroEventPercentWarning; - fUseZeroEventWarning = copy.fUseZeroEventWarning; - - return (*this); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisSE::RsnUserCreateOutputObjects() -{ -// -// Creation of output objects. -// These are created through the utility methods in the analysis manager, -// which asks all the AliRsnPair objects to initialize their output which -// is then linked to the TList data member of this, which will contain all the output. -// - - if (!fOutList) fOutList = new TList; - fOutList->Clear(); - - fRsnAnalysisManager.InitAllPairs(fOutList); - - PostData(2, fOutList); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisSE::RsnUserExec(Option_t*) -{ -// -// Execution of the analysis task. -// Recovers the input event and processes it with all included pair objects, -// using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag. -// - - fRsnAnalysisManager.ProcessAll(&fRsnEvent, &fRsnEvent, fMCOnly); - - PostData(2, fOutList); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisSE::RsnTerminate(Option_t*) -{ -// -// Termination. -// Could be added some monitor histograms here. -// -} - -//______________________________________________________________________________ -Bool_t AliRsnAnalysisSE::EventProcess() -{ -// -// Customized event pre-processing. -// First checks if the current event passes all cuts, -// and if it does, updates the informations and then -// call the operations which are already defined in the -// omonyme function in mother class -// - - // initially, an event is expected to be bad - fTaskInfo.SetEventUsed(kFALSE); - - // check #1: number of tracks in event (reject empty events) - Int_t ntracks = fRsnEvent.GetMultiplicityFromTracks(); - Double_t zeroEventPercent = 0.0; - if (ntracks < 1) { - // if using the checker for amount of empty events, update it - if (fUseZeroEventWarning) { - TH1I *hist = (TH1I*)fInfoList->FindObject(fTaskInfo.GetEventHistogramName()); - if (hist) { - if (hist->Integral() > 1) zeroEventPercent = (Double_t)hist->GetBinContent(1) / hist->Integral() * 100; - if ((zeroEventPercent > fZeroEventPercentWarning) && (fEntry > 100)) - AliWarning(Form("%3.2f%% Events are with zero tracks (CurrentEvent=%d)!!!", zeroEventPercent, fEntry)); - } - } - - // empty events are rejected by default - fTaskInfo.SetEventUsed(kFALSE); - AliDebug(AliLog::kDebug, "Empty event. Skipping..."); - return kFALSE; - } - - // check the event cuts and update the info data accordingly - // events not passing the cuts must be rejected - if (!fEventCuts.IsSelected(&fRsnEvent)) { - fTaskInfo.SetEventUsed(kFALSE); - return kFALSE; - } - - // if we reach this point, cuts were passed; - // then additional operations can be done - - // find leading particle (without any PID/momentum restriction) - fRsnEvent.SelectLeadingParticle(0); - - // final return value is positive - // but call the mother class method which updates info object - fTaskInfo.SetEventUsed(kTRUE); - return AliRsnVAnalysisTaskSE::EventProcess(); -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisSE.h b/PWG2/RESONANCES/AliRsnAnalysisSE.h deleted file mode 100644 index 9493c4683b9..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisSE.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// Class AliRsnAnalysisSE -// -// Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// -#ifndef ALIRSNANALYSISSE_H -#define ALIRSNANALYSISSE_H - -#include "AliPID.h" -#include "AliRsnVAnalysisTaskSE.h" -#include "AliRsnAnalysisManager.h" -#include "AliRsnEvent.h" -#include "AliRsnCutSet.h" - -class AliRsnPIDDefESD; - -class AliRsnAnalysisSE : public AliRsnVAnalysisTaskSE { -public: - - AliRsnAnalysisSE(const char *name = "AliRsnAnalysisSE", Bool_t useKine = kFALSE); - AliRsnAnalysisSE(const AliRsnAnalysisSE& copy); - AliRsnAnalysisSE& operator=(const AliRsnAnalysisSE& copy); - virtual ~AliRsnAnalysisSE() {} - - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnTerminate(Option_t*); - virtual Bool_t EventProcess(); - - AliRsnCutSet* GetEventCuts() {return &fEventCuts;} - AliRsnAnalysisManager* GetAnalysisManager() {return &fRsnAnalysisManager;} - void SetAnalysisManagerName(const char *name) {fRsnAnalysisManager.SetName(name);} - - Double_t GetZeroEventPercentWarning() const {return fZeroEventPercentWarning;} - void SetZeroEventPercentWarning(Double_t val = 50) {fZeroEventPercentWarning = val;} - void UseZeroEventWarning(Bool_t b = kTRUE) {fUseZeroEventWarning = b;} - -private: - - AliRsnAnalysisManager fRsnAnalysisManager; // analysis main engine - AliRsnCutSet fEventCuts; // event cuts - TList *fOutList; // list of output events - - Double_t fZeroEventPercentWarning; // Percent Number for Zero Event Warning - Bool_t fUseZeroEventWarning; // flag if Zero Event Warning is used (default is true) - - ClassDef(AliRsnAnalysisSE, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisTask.cxx b/PWG2/RESONANCES/AliRsnAnalysisTask.cxx index 8f8f57b142a..95315e0b158 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisTask.cxx +++ b/PWG2/RESONANCES/AliRsnAnalysisTask.cxx @@ -1,190 +1,236 @@ -// -// Class AliRsnAnalysisTask -// -// Virtual Class derivated from AliRsnVAnalysisTask which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// +#include -#include -#include -#include +#include "AliLog.h" +#include "AliAnalysisManager.h" +#include "AliMultiInputEventHandler.h" +#include "AliMixInputEventHandler.h" +#include "AliMCEventHandler.h" -#include "AliESDEvent.h" -#include "AliMCEvent.h" -#include "AliAODEvent.h" +#include "AliRsnEvent.h" +#include "AliRsnLoop.h" +#include "AliRsnInputHandler.h" -#include "AliRsnCutSet.h" -#include "AliRsnVATProcessInfo.h" #include "AliRsnAnalysisTask.h" ClassImp(AliRsnAnalysisTask) -//_____________________________________________________________________________ -AliRsnAnalysisTask::AliRsnAnalysisTask(const char *name, Bool_t useKine) : - AliRsnVAnalysisTask(name, useKine), - fRsnAnalysisManager(), - fEventCuts("eventCuts", AliRsnCut::kEvent), - fOutList(0x0), - fZeroEventPercentWarning(100), - fUseZeroEventWarning(kTRUE) +//__________________________________________________________________________________________________ +AliRsnAnalysisTask::AliRsnAnalysisTask() : + AliAnalysisTaskSE(), + fOutput(0), + fRsnObjects(0), + fInputEHMain(0), + fInputEHMix(0) +{ +// +// Dummy constructor ALWAYS needed for I/O. +// +} + +//__________________________________________________________________________________________________ +AliRsnAnalysisTask::AliRsnAnalysisTask(const char *name) : + AliAnalysisTaskSE(name), + fOutput(0), + fRsnObjects(0), + fInputEHMain(0), + fInputEHMix(0) { // // Default constructor. -// Defines another output slot for histograms/ntuples +// Define input and output slots here (never in the dummy constructor) +// Input slot #0 works with a TChain - it is connected to the default input container +// Output slot #1 writes into a TH1 container // - DefineOutput(2, TList::Class()); + DefineOutput(1, TList::Class()); } -//_____________________________________________________________________________ +//__________________________________________________________________________________________________ AliRsnAnalysisTask::AliRsnAnalysisTask(const AliRsnAnalysisTask& copy) : - AliRsnVAnalysisTask(copy), - fRsnAnalysisManager(copy.fRsnAnalysisManager), - fEventCuts(copy.fEventCuts), - fOutList(0x0), - fZeroEventPercentWarning(copy.fZeroEventPercentWarning), - fUseZeroEventWarning(copy.fUseZeroEventWarning) + AliAnalysisTaskSE(copy), + fOutput(0), + fRsnObjects(copy.fRsnObjects), + fInputEHMain(copy.fInputEHMain), + fInputEHMix(copy.fInputEHMix) { // // Copy constructor. +// Implemented as requested by C++ standards. +// Can be used in PROOF and by plugins. // } -//_____________________________________________________________________________ +//__________________________________________________________________________________________________ AliRsnAnalysisTask& AliRsnAnalysisTask::operator=(const AliRsnAnalysisTask& copy) { // -// Assigment operator. +// Assignment operator. +// Implemented as requested by C++ standards. +// Can be used in PROOF and by plugins. // - - AliRsnVAnalysisTask::operator=(copy); - - fRsnAnalysisManager = copy.fRsnAnalysisManager; - fEventCuts = copy.fEventCuts; - if (fOutList) fOutList->Clear(); - fZeroEventPercentWarning = copy.fZeroEventPercentWarning; - fUseZeroEventWarning = copy.fUseZeroEventWarning; - + AliAnalysisTaskSE::operator=(copy); + fRsnObjects = copy.fRsnObjects; + fInputEHMain = copy.fInputEHMain; + fInputEHMix = copy.fInputEHMix; + return (*this); } -//_____________________________________________________________________________ -void AliRsnAnalysisTask::RsnUserCreateOutputObjects() +//__________________________________________________________________________________________________ +AliRsnAnalysisTask::~AliRsnAnalysisTask() { // -// Creation of output objects. -// These are created through the utility methods in the analysis manager, -// which asks all the AliRsnPair objects to initialize their output which -// is then linked to the TList data member of this, which will contain all the output. +// Destructor. +// Clean-up the output list, but not the histograms that are put inside +// (the list is owner and will clean-up these histograms). Protect in PROOF case. // - // initialize the list - if (!fOutList) fOutList = new TList; - fOutList->Clear(); - fOutList->SetOwner(kTRUE); - - // initialize all pairs - fRsnAnalysisManager.InitAllPairs(fOutList); - - PostData(2, fOutList); + if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { + delete fOutput; + } } -//_____________________________________________________________________________ -void AliRsnAnalysisTask::RsnUserExec(Option_t*) +//__________________________________________________________________________________________________ +void AliRsnAnalysisTask::Add(AliRsnLoop *obj) { // -// Execution of the analysis task. -// Recovers the input event and processes it with all included pair objects, -// using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag. +// Add new computation object // - if (IsMixing()) return; - - fRsnAnalysisManager.ProcessAll(&fRsnEvent[0], 0x0, fMCOnly); - - PostData(2, fOutList); + fRsnObjects.Add(obj); } -//_____________________________________________________________________________ -void AliRsnAnalysisTask::RsnUserExecMix(Option_t* /*opt*/) +//__________________________________________________________________________________________________ +void AliRsnAnalysisTask::UserCreateOutputObjects() { // -// Execution of the analysis task with event mixing. -// Recovers the input event and processes it with all included pair objects, -// using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag. +// Initialization of outputs. +// This is called once per worker node. // - if (!IsMixing()) return; - AliDebug(AliLog::kDebug, Form("RSN Mixing %lld %d [%lld,%lld] %d", fMixedEH->CurrentEntry(), fMixedEH->NumberMixed(), fMixedEH->CurrentEntryMain(), fMixedEH->CurrentEntryMix(), fMixedEH->CurrentBinIndex())); + // sets all Inuput Handler pointers + InitInputHandlers(); - // the virtual class has already sorted tracks in the PID index - // so we need here just to call the execution of analysis - fRsnAnalysisManager.ProcessAll(&fRsnEvent[0], &fRsnEvent[1], fMCOnly); + // create list and set it as owner of its content (MANDATORY) + fOutput = new TList(); + fOutput->SetOwner(); + + // loop on computators and initialize all their outputs + TObjArrayIter next(&fRsnObjects); + AliRsnLoop *obj = 0x0; + while ( (obj = (AliRsnLoop*)next()) ) { + obj->Init(GetName(), fOutput); + } + + // post data for ALL output slots >0 here, to get at least an empty histogram + PostData(1, fOutput); } -//_____________________________________________________________________________ -void AliRsnAnalysisTask::RsnTerminate(Option_t*) +//__________________________________________________________________________________________________ +void AliRsnAnalysisTask::UserExec(Option_t *) { // -// Termination. -// Could be added some monitor histograms here. +// Main loop for single-event computations. +// It is called for each event and executes the 'DoLoop' +// function of all AliRsnLoop instances stored here. // + + AliRsnEvent *evMain = 0x0; + AliRsnInputHandler *rsnIH = 0x0; + + if (fInputEHMain) { + TObjArrayIter next(fInputEHMain->InputEventHandlers()); + TObject *obj = 0x0; + while ( (obj = next()) ) { + if (obj->IsA() == AliRsnInputHandler::Class()) { + rsnIH = (AliRsnInputHandler*)obj; + //AliInfo(Form("Found object '%s' which is RSN input handler", obj->GetName())); + evMain = rsnIH->GetRsnEvent(); + break; + } + } + } + + if (!evMain) return; + + TObjArrayIter next(&fRsnObjects); + AliRsnLoop *obj = 0x0; + while ( (obj = (AliRsnLoop*)next()) ) { + if (obj->IsMixed()) continue; + obj->DoLoop(evMain, rsnIH->GetSelector()); + } + + PostData(1, fOutput); } -//______________________________________________________________________________ -Bool_t AliRsnAnalysisTask::RsnEventProcess() +//__________________________________________________________________________________________________ +void AliRsnAnalysisTask::UserExecMix(Option_t*) { // -// Customized event pre-processing. -// First checks if the current event passes all cuts, -// and if it does, updates the informations and then -// call the operations which are already defined in the -// omonyme function in mother class -// - - // initially, an event is expected to be bad - fTaskInfo.SetEventUsed(kFALSE); - - if (!AliRsnVAnalysisTask::RsnEventProcess()) return kFALSE; - - // check #1: number of tracks in event (reject empty events) - Int_t ntracks = fRsnEvent[0].GetMultiplicityFromTracks(); - Double_t zeroEventPercent = 0.0; - if (ntracks < 1) { - // if using the checker for amount of empty events, update it - if (fUseZeroEventWarning) { - TH1I *hist = (TH1I*)fInfoList->FindObject(fTaskInfo.GetEventHistogramName()); - if (hist) { - if (hist->Integral() > 1) zeroEventPercent = (Double_t)hist->GetBinContent(1) / hist->Integral() * 100; - if ((zeroEventPercent > fZeroEventPercentWarning) && (fEntry > 100)) - AliWarning(Form("%3.2f%% Events are with zero tracks (CurrentEvent=%d)!!!", zeroEventPercent, fEntry)); +// Main loop for event-mixing computations +// It is called for each pair of matched events +// and executes the 'DoLoop' function of all AliRsnLoop instances stored here. +// + + AliRsnEvent *evMain = 0x0; + AliRsnEvent *evMix = 0x0; + Int_t id = -1; + AliRsnInputHandler *rsnIH = 0x0, *rsnMixIH = 0x0; + + if (fInputEHMain) { + TObjArrayIter next(fInputEHMain->InputEventHandlers()); + TObject *obj = 0x0; + while ( (obj = next()) ) { + if (obj->IsA() == AliRsnInputHandler::Class()) { + rsnIH = (AliRsnInputHandler*)obj; + //AliInfo(Form("Found object '%s' which is RSN input handler", obj->GetName())); + evMain = rsnIH->GetRsnEvent(); + id = fInputEHMain->InputEventHandlers()->IndexOf(obj); + break; } } - - // empty events are rejected by default - fTaskInfo.SetEventUsed(kFALSE); - AliDebug(AliLog::kDebug, "Empty event. Skipping..."); - return kFALSE; } - - // check the event cuts and update the info data accordingly - // events not passing the cuts must be rejected - if (!fEventCuts.IsSelected(&fRsnEvent[0])) { - fTaskInfo.SetEventUsed(kFALSE); - return kFALSE; + + if (!evMain) return; + + // gets first input handler form mixing buffer + AliMultiInputEventHandler *ihMultiMix = dynamic_cast(fInputEHMix->InputEventHandler(0)); + rsnMixIH = dynamic_cast(ihMultiMix->InputEventHandler(id)); + evMix = rsnMixIH->GetRsnEvent(); + + if (!evMix) return; + + TObjArrayIter next(&fRsnObjects); + AliRsnLoop *obj = 0x0; + while ( (obj = (AliRsnLoop*)next()) ) { + if (!obj->IsMixed()) continue; + obj->DoLoop(evMain, rsnIH->GetSelector(), evMix, rsnMixIH->GetSelector()); } - // if we reach this point, cuts were passed; - // then additional operations can be done + PostData(1, fOutput); +} + +//________________________________________________________________________ +void AliRsnAnalysisTask::Terminate(Option_t *) +{ +// +// Draw result to screen, or perform fitting, normalizations +// Called once at the end of the query +// - // find leading particle (without any PID/momentum restriction) - fRsnEvent[0].SelectLeadingParticle(0); + fOutput = dynamic_cast(GetOutputData(1)); + if (!fOutput) { AliError("Could not retrieve TList fOutput"); return; } +} - // final return value is positive - // but call the mother class method which updates info object - fTaskInfo.SetEventUsed(kTRUE); - return kTRUE; +//_____________________________________________________________________________ +void AliRsnAnalysisTask::InitInputHandlers() +{ +// +// Sets needed input handlers +// + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + fInputEHMain = dynamic_cast(mgr->GetInputEventHandler()); + if (fInputEHMain) { + fInputEHMix = dynamic_cast(fInputEHMain->GetFirstMultiInputHandler()); + } } diff --git a/PWG2/RESONANCES/AliRsnAnalysisTask.h b/PWG2/RESONANCES/AliRsnAnalysisTask.h index 9cc8c60f526..ad06a9a2695 100644 --- a/PWG2/RESONANCES/AliRsnAnalysisTask.h +++ b/PWG2/RESONANCES/AliRsnAnalysisTask.h @@ -1,54 +1,45 @@ -// -// Class AliRsnAnalysisTask -// -// Virtual Class derivated from AliRsnVAnalysisTask which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// #ifndef ALIRSNANALYSISTASK_H #define ALIRSNANALYSISTASK_H -#include "AliRsnVAnalysisTask.h" -#include "AliRsnAnalysisManager.h" - -#include "AliRsnCutSet.h" - -class AliRsnPIDDefESD; - -class AliRsnAnalysisTask : public AliRsnVAnalysisTask { -public: +#ifndef ALIANALYSISTASKSE_H +#include "AliAnalysisTaskSE.h" +#endif - AliRsnAnalysisTask(const char *name = "AliRsnAnalysisTask", Bool_t useKine = kFALSE); - AliRsnAnalysisTask(const AliRsnAnalysisTask& copy); - AliRsnAnalysisTask& operator=(const AliRsnAnalysisTask& copy); - virtual ~AliRsnAnalysisTask() {} +#include - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnUserExecMix(Option_t*); - virtual void RsnTerminate(Option_t*); - virtual Bool_t RsnEventProcess(); +class TList; +class AliMixInputEventHandler; +class AliMultiInputEventHandler; +class AliRsnLoop; - AliRsnCutSet* GetEventCuts() {return &fEventCuts;} - AliRsnAnalysisManager* GetAnalysisManager() {return &fRsnAnalysisManager;} - void SetAnalysisManagerName(const char *name) {fRsnAnalysisManager.SetName(name);} +class AliRsnAnalysisTask : public AliAnalysisTaskSE { - Double_t GetZeroEventPercentWarning() const {return fZeroEventPercentWarning;} - void SetZeroEventPercentWarning(Double_t val = 50) {fZeroEventPercentWarning = val;} - void UseZeroEventWarning(Bool_t b = kTRUE) {fUseZeroEventWarning = b;} +public: + AliRsnAnalysisTask(); + AliRsnAnalysisTask(const char *name); + AliRsnAnalysisTask(const AliRsnAnalysisTask&); + AliRsnAnalysisTask& operator=(const AliRsnAnalysisTask&); + virtual ~AliRsnAnalysisTask(); + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void UserExecMix(Option_t*); + virtual void Terminate(Option_t *); + + virtual void Add(AliRsnLoop *object); + void InitInputHandlers(); + private: - AliRsnAnalysisManager fRsnAnalysisManager; // analysis main engine - AliRsnCutSet fEventCuts; // event cuts - TList *fOutList; // list of output events + TList *fOutput; // output list + TObjArray fRsnObjects; // list of computation objects - Double_t fZeroEventPercentWarning; // Percent Number for Zero Event Warning - Bool_t fUseZeroEventWarning; // flag if Zero Event Warning is used (default is true) + AliMultiInputEventHandler *fInputEHMain; //! input multi handler + AliMixInputEventHandler *fInputEHMix; //! mix input handler - ClassDef(AliRsnAnalysisTask, 1) + ClassDef(AliRsnAnalysisTask, 1); // AliRsnAnalysisTask }; #endif + diff --git a/PWG2/RESONANCES/AliRsnAnalysisTaskEff.cxx b/PWG2/RESONANCES/AliRsnAnalysisTaskEff.cxx deleted file mode 100644 index cd2fd9f49ca..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisTaskEff.cxx +++ /dev/null @@ -1,293 +0,0 @@ -// -// Class AliRsnAnalysisTaskEff -// -// Base class for efficiency computation tasks -// which should be inherited by different efficiency computators -// -// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include "AliVEvent.h" - -#include "AliRsnEvent.h" -#include "AliRsnCutSet.h" - -#include "AliRsnAnalysisTaskEff.h" - -ClassImp(AliRsnAnalysisTaskEff) - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEff::AliRsnAnalysisTaskEff(const char *name) : - AliRsnVAnalysisTask(name), - fDefs(0), - fStepsMC(0), - fStepsRec(0), - fAxes("AliRsnValue", 0), - fOutList(0x0), - fEventCuts("eventCuts", AliRsnCut::kEvent), - fVar(0) -{ -// -// Default constructor. -// - - DefineOutput(2, TList::Class()); -} - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEff::AliRsnAnalysisTaskEff(const AliRsnAnalysisTaskEff& copy) : - AliRsnVAnalysisTask(copy), - fDefs(copy.fDefs), - fStepsMC(copy.fStepsMC), - fStepsRec(copy.fStepsRec), - fAxes(copy.fAxes), - fOutList(0x0), - fEventCuts(copy.fEventCuts), - fVar(0) -{ -// -// Copy constrtuctor -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEff& AliRsnAnalysisTaskEff::operator=(const AliRsnAnalysisTaskEff& copy) -{ -// -// Assignment operator -// - - AliRsnVAnalysisTask::operator=(copy); - - fDefs = copy.fDefs; - fStepsMC = copy.fStepsMC; - fStepsRec = copy.fStepsRec; - fAxes = copy.fAxes; - fEventCuts = copy.fEventCuts; - - return (*this); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::AddDef(TObject* def) -{ -// -// Adds pair definition -// - fDefs.AddLast(def); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::AddAxis(AliRsnValue *axis) -{ -// -// Add a new axis -// - - Int_t n = fAxes.GetEntries(); - new (fAxes[n]) AliRsnValue(*axis); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::AddStepMC(TObject *cuts) -{ -// -// Add a step on montecarlo -// - - fStepsMC.AddLast(cuts); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::AddStepRec(TObject *cuts) -{ -// -// Add a step on ESD -// - - fStepsRec.AddLast(cuts); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::RsnUserCreateOutputObjects() -{ -// -// Creation of output objects. -// These are created through the utility methods in the analysis manager, -// which produces a list of histograms for each specified set of pairs. -// Each of these lists is added to the main list of this task. -// - - // get number of steps and axes - Int_t iaxis = 0; - Int_t nAxes = fAxes.GetEntries(); - Int_t nSteps = (Int_t)fStepsMC.GetEntries() + (Int_t)fStepsRec.GetEntries(); - - if (!nSteps) { - AliError("No steps defined"); - return; - } - if (!nAxes) { - AliError("No axes defined"); - return; - } - - // initialize variable list - fVar.Set(nAxes); - - // retrieve number of bins for each axis - Int_t *nBins = new Int_t[nAxes]; - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxes.At(iaxis); - nBins[iaxis] = fcnAxis->GetArray().GetSize() - 1; - } - - // initialize output list - OpenFile(2); - fOutList = new TList(); - fOutList->SetOwner(); - - // create the containers - Int_t i, nDef = (Int_t)fDefs.GetEntries(); - for (i = 0; i < nDef; i++) { - // instantiate a new container - AliCFContainer *cont = new AliCFContainer(fDefs[i]->GetName(), "", nSteps, nAxes, nBins); - // set the bin limits for each axis - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxes.At(iaxis); - cont->SetBinLimits(iaxis, fcnAxis->GetArray().GetArray()); - } - // add the container to output list - fOutList->Add(cont); - } - - PostData(2, fOutList); - - // clear heap - delete [] nBins; -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::RsnUserExec(Option_t*) -{ -// -// Execution of the analysis task. -// Recovers the input event and processes it with all included pair objects. -// In this case, we NEED to have reconstruction and MC, otherwise we cannot do anything. -// - - if (fRsnEvent[0].IsESD()) ProcessEventESD(); - if (fRsnEvent[0].IsAOD()) ProcessEventAOD(); - - PostData(2, fOutList); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::RsnTerminate(Option_t*) -{ -// -// Termination. -// Could be added some monitor histograms here. -// -} - -//______________________________________________________________________________ -Bool_t AliRsnAnalysisTaskEff::RsnEventProcess() -{ -// -// Customized event pre-processing. -// First checks if the current event passes all cuts, -// and if it does, updates the informations and then -// call the operations which are already defined in the -// omonyme function in mother class -// - - // initially, an event is expected to be bad - fTaskInfo.SetEventUsed(kFALSE); - - // check the event cuts and update the info data accordingly - // events not passing the cuts must be rejected - if (!fEventCuts.IsSelected(&fRsnEvent[0])) { - fTaskInfo.SetEventUsed(kFALSE); - return kFALSE; - } - - // if we reach this point, cuts were passed; - // then additional operations can be done - - // find leading particle (without any PID/momentum restriction) - fRsnEvent[0].SelectLeadingParticle(0); - - // final return value is positive - // but call the mother class method which updates info object - fTaskInfo.SetEventUsed(kTRUE); - return AliRsnVAnalysisTask::RsnEventProcess(); -} - -//_____________________________________________________________________________ -TArrayI AliRsnAnalysisTaskEff::FindTracks(Int_t label, AliVEvent *event) -{ -// -// Loops an event and find all tracks which have a label -// equal to that passed as first argument. -// - - Int_t i = 0, nfound = 0; - Int_t ntracks = event->GetNumberOfTracks(); - TArrayI array(100); - - for (i = 0; i < ntracks; i++) { - AliVParticle *track = event->GetTrack(i); - if (TMath::Abs(track->GetLabel()) != label) continue; - array[nfound++] = i; - } - - array.Set(nfound); - return array; -} - -//_____________________________________________________________________________ -Int_t AliRsnAnalysisTaskEff::NGoodSteps() -{ -// -// Tells the maximum step where cuts for the checked objects are passed -// - - AliInfo("Must be overloaded in inheriting tasks"); - - return 0; -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::ProcessEventESD() -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliInfo("Must be overloaded in inheriting tasks"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::ProcessEventAOD() -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliInfo("Must be overloaded in inheriting tasks"); -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEff::FillContainer(Bool_t, TObject*) -{ -// -// Fill the containers -// - - AliInfo("Must be overloaded in inheriting tasks"); -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisTaskEff.h b/PWG2/RESONANCES/AliRsnAnalysisTaskEff.h deleted file mode 100644 index e5c71d6bc2b..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisTaskEff.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// Class AliRsnAnalysisTaskEff -// -// Base class for efficiency computation tasks -// which should be inherited by different efficiency computators -// -// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#ifndef ALIRSNANALYSISTASKEFF_H -#define ALIRSNANALYSISTASKEFF_H - -#include -#include -#include -#include - -#include "AliCFContainer.h" - -#include "AliRsnValue.h" -#include "AliRsnCutSet.h" -#include "AliRsnVAnalysisTask.h" - -class TList; -class AliVEvent; - -class AliRsnAnalysisTaskEff : public AliRsnVAnalysisTask { - -public: - - AliRsnAnalysisTaskEff(const char *name = "AliRsnAnalysisTasEff"); - AliRsnAnalysisTaskEff(const AliRsnAnalysisTaskEff& copy); - AliRsnAnalysisTaskEff& operator=(const AliRsnAnalysisTaskEff& copy); - virtual ~AliRsnAnalysisTaskEff() {;}; - - // work-flow - AliRsnCutSet* GetEventCuts() {return &fEventCuts;} - void AddDef(TObject *def); - void AddAxis(AliRsnValue *axis); - void AddStepMC(TObject *set); - void AddStepRec(TObject *set); - - // inherited - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnTerminate(Option_t*); - virtual Bool_t RsnEventProcess(); - -protected: - - TArrayI FindTracks(Int_t label, AliVEvent *esd); - virtual void ProcessEventESD(); - virtual void ProcessEventAOD(); - virtual Int_t NGoodSteps(); - virtual void FillContainer(Bool_t mcList, TObject *def); - - TObjArray fDefs; // list of definitions - TObjArray fStepsMC; // list of cuts for all steps with MC tracks - TObjArray fStepsRec; // list of cuts for all steps with reconstructed tracks - TClonesArray fAxes; // list of axes of efficiency plots - - TList *fOutList; // global output list - AliRsnCutSet fEventCuts; // event cuts - - TArrayD fVar; //! list of variables of the container (temporary) - - ClassDef(AliRsnAnalysisTaskEff, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.cxx b/PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.cxx deleted file mode 100644 index e5a18683485..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.cxx +++ /dev/null @@ -1,242 +0,0 @@ -// -// Class AliRsnAnalysisTaskEffMonitor -// -// Inherits from basic AliRsnAnalysisTaskEff for efficiency, -// and computed efficiencies for single-tracks -// -// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include "AliStack.h" -#include "AliMCEvent.h" -#include "AliESDEvent.h" -#include "AliAODEvent.h" - -#include "AliRsnDaughterDef.h" -#include "AliRsnAnalysisTaskEffMonitor.h" - -ClassImp(AliRsnAnalysisTaskEffMonitor) - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEffMonitor::AliRsnAnalysisTaskEffMonitor(const char *name) : - AliRsnAnalysisTaskEff(name), - fDaughter() -{ -// -// Default constructor. -// Do not repeat 'DefineOutput' since it is done in base class and we don't add new ones. -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEffMonitor::AliRsnAnalysisTaskEffMonitor(const AliRsnAnalysisTaskEffMonitor& copy) : - AliRsnAnalysisTaskEff(copy), - fDaughter() -{ -// -// Copy constrtuctor. -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEffMonitor& AliRsnAnalysisTaskEffMonitor::operator=(const AliRsnAnalysisTaskEffMonitor& copy) -{ -// -// Assignment operator. -// Owned data members are meaningless for this operator. -// - - AliRsnAnalysisTaskEff::operator=(copy); - return (*this); -} - -//_____________________________________________________________________________ -Int_t AliRsnAnalysisTaskEffMonitor::NGoodSteps() -{ -// -// Checks how many 'reconstruction' steps are passed by current daughter -// - - Int_t istep, count = 0; - Int_t nSteps = fStepsRec.GetEntries(); - - for (istep = 0; istep < nSteps; istep++) { - AliRsnCutSet *cutSet = (AliRsnCutSet*)fStepsRec[istep]; - if (!cutSet->IsSelected(&fDaughter)) break; - count++; - } - - return count; -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEffMonitor::ProcessEventESD() -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliESDEvent *esd = fRsnEvent[0].GetRefESD(); - AliMCEvent *mc = fRsnEvent[0].GetRefMCESD(); - AliStack *stack = mc->Stack(); - TArrayI indexes; - Int_t imax, istep, icheck, itrack, ipart; - - // loop on definitions - AliRsnDaughterDef *def = 0x0; - TObjArrayIter nextDef(&fDefs); - while ( (def = (AliRsnDaughterDef*)nextDef()) ) { - - // loop on the MC list of particles - for (ipart = 0; ipart < stack->GetNprimary(); ipart++) { - - // MC particle - fDaughter.SetRefMC((AliMCParticle*)mc->GetTrack(ipart)); - - // search for reconstructed track - // if no tracks are found with that label, rec ref is set to zero - // if more than one tracks are found we use the one which passes - // most cut steps - indexes = FindTracks(ipart, esd); - if (indexes.GetSize() < 1) - fDaughter.SetRef(0x0); - else if (indexes.GetSize() == 1) - fDaughter.SetRef(esd->GetTrack(indexes[0])); - else { - imax = istep = itrack = 0; - for (icheck = 0; icheck < indexes.GetSize(); icheck++) { - fDaughter.SetRef(esd->GetTrack(indexes[icheck])); - fDaughter.SetMass(def->GetMass()); - istep = NGoodSteps(); - if (istep > imax) itrack = icheck; - } - fDaughter.SetRef(esd->GetTrack(indexes[itrack])); - } - - // compute 4-momenta - fDaughter.SetMass(def->GetMass()); - - // fill MC container - FillContainer(kTRUE, def); - if (fDaughter.GetRef()) FillContainer(kFALSE, def); - } - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEffMonitor::ProcessEventAOD() -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliAODEvent *aod = fRsnEvent[0].GetRefAOD(); - TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); - if (!mcArray) return; - TArrayI indexes; - Int_t imax, istep, icheck, itrack, ipart; - - // loop on definitions - AliRsnDaughterDef *def = 0x0; - TObjArrayIter nextDef(&fDefs); - while ( (def = (AliRsnDaughterDef*)nextDef()) ) { - - // loop on the MC list of particles - TObjArrayIter next(mcArray); - AliAODMCParticle *particle; - while ((particle = (AliAODMCParticle*)next())) { - - // MC particle - fDaughter.SetRefMC(particle); - - // search for reconstructed track - // if no tracks are found with that label, rec ref is set to zero - // if more than one tracks are found we use the one which passes - // most cut steps - ipart = particle->GetLabel(); - indexes = FindTracks(ipart, aod); - if (indexes.GetSize() < 1) - fDaughter.SetRef(0x0); - else if (indexes.GetSize() == 1) - fDaughter.SetRef(aod->GetTrack(indexes[0])); - else { - imax = istep = itrack = 0; - for (icheck = 0; icheck < indexes.GetSize(); icheck++) { - fDaughter.SetRef(aod->GetTrack(indexes[icheck])); - fDaughter.SetMass(def->GetMass()); - istep = NGoodSteps(); - if (istep > imax) { - itrack = icheck; - imax = istep; - } - } - fDaughter.SetRef(aod->GetTrack(indexes[itrack])); - } - - // compute 4-momenta - fDaughter.SetMass(def->GetMass()); - - // fill MC container - FillContainer(kTRUE, def); - if (fDaughter.GetRef()) FillContainer(kFALSE, def); - } - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEffMonitor::FillContainer(Bool_t mcList, TObject *defObj) -{ -// -// Fill the container corresponding to current definition. -// - - // cast the object into the def - if (!defObj->InheritsFrom(AliRsnDaughterDef::Class())) { - AliError("Def object does not inherit from AliRsnDaughterDef!"); - return; - } - AliRsnDaughterDef *def = static_cast(defObj); - - // retrieve container - AliCFContainer *cont = (AliCFContainer*)fOutList->FindObject(def->GetName()); - if (!cont) return; - - TObjArray &stepList = (mcList ? fStepsMC : fStepsRec); - Int_t firstStep = (mcList ? 0 : ((Int_t)fStepsMC.GetEntries())); - Int_t iaxis, nAxes = fAxes.GetEntries(); - Int_t istep, nSteps = stepList.GetEntries(); - Bool_t computeOK; - - // compute values for all axes - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxes.At(iaxis); - fVar[iaxis] = -1E10; - switch (fcnAxis->GetTargetType()) { - case AliRsnTarget::kDaughter: - fcnAxis->SetSupportObject(def); - computeOK = fcnAxis->Eval(&fDaughter, mcList); - break; - case AliRsnTarget::kEvent: - computeOK = fcnAxis->Eval(&fRsnEvent[0]); - break; - default: - AliError(Form("Allowed targets are daughters and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName())); - computeOK = kFALSE; - } - if (computeOK) fVar[iaxis] = ((Float_t)fcnAxis->GetComputedValue()); - } - - // fill all successful steps - for (istep = 0; istep < nSteps; istep++) { - AliRsnCutSet *cutSet = (AliRsnCutSet*)stepList[istep]; - - if (!cutSet->IsSelected(&fDaughter)) break; - - AliDebug(AliLog::kDebug + 2, Form("DEF: %s --> filling step %d", def->GetName(), istep)); - cont->Fill(fVar.GetArray(), istep + firstStep); - } -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.h b/PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.h deleted file mode 100644 index f308b4c1344..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisTaskEffMonitor.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Class AliRsnAnalysisTaskEffMonitor -// -// Inherits from basic AliRsnAnalysisTaskEff for efficiency, -// and computed efficiencies for single-tracks -// -// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#ifndef ALIRSNANALYSISEFFMONITOR_H -#define ALIRSNANALYSISEFFMONITOR_H - -#include "AliRsnDaughter.h" -#include "AliRsnAnalysisTaskEff.h" - -class AliRsnDaughterDef; - -class AliRsnAnalysisTaskEffMonitor : public AliRsnAnalysisTaskEff { - -public: - - AliRsnAnalysisTaskEffMonitor(const char *name = "AliRsnAnalysisTaskMonitorEffSE"); - AliRsnAnalysisTaskEffMonitor(const AliRsnAnalysisTaskEffMonitor& copy); - AliRsnAnalysisTaskEffMonitor& operator=(const AliRsnAnalysisTaskEffMonitor& copy); - virtual ~AliRsnAnalysisTaskEffMonitor() {;}; - -protected: - - virtual void ProcessEventESD(); - virtual void ProcessEventAOD(); - virtual Int_t NGoodSteps(); - virtual void FillContainer(Bool_t mcList, TObject *def); - - AliRsnDaughter fDaughter; //! current track - - ClassDef(AliRsnAnalysisTaskEffMonitor, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.cxx b/PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.cxx deleted file mode 100644 index a7baf847bb6..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.cxx +++ /dev/null @@ -1,372 +0,0 @@ -// -// Class AliRsnAnalysisTaskEffPair -// -// Inherits from basic AliRsnAnalysisTaskEff for efficiency, -// and computed efficiencies for pairs -// -// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include "AliStack.h" -#include "AliMCEvent.h" -#include "AliESDEvent.h" -#include "AliAODEvent.h" - -#include "AliRsnPairDef.h" -#include "AliRsnCutManager.h" -#include "AliRsnAnalysisTaskEffPair.h" - -ClassImp(AliRsnAnalysisTaskEffPair) - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEffPair::AliRsnAnalysisTaskEffPair(const char *name) : - AliRsnAnalysisTaskEff(name), - fMother() -{ -// -// Default constructor. -// Do not repeat 'DefineOutput' since it is done in base class and we don't add new ones. -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEffPair::AliRsnAnalysisTaskEffPair(const AliRsnAnalysisTaskEffPair& copy) : - AliRsnAnalysisTaskEff(copy), - fMother() -{ -// -// Copy constrtuctor. -// -} - -//_____________________________________________________________________________ -AliRsnAnalysisTaskEffPair& AliRsnAnalysisTaskEffPair::operator=(const AliRsnAnalysisTaskEffPair& copy) -{ -// -// Assignment operator. -// Owned data members are meaningless for this operator. -// - - AliRsnAnalysisTaskEff::operator=(copy); - return (*this); -} - -//_____________________________________________________________________________ -Bool_t AliRsnAnalysisTaskEffPair::RsnEventProcess() -{ -// -// Preprocessing to the event -// Calls the same function in base class plus somethin specific -// - - if (!AliRsnAnalysisTaskEff::RsnEventProcess()) return kFALSE; - - // assign this event to the mother reference - fMother.SetRefEvent(&fRsnEvent[0]); - fDaughter[0].SetOwnerEvent(&fRsnEvent[0]); - fDaughter[1].SetOwnerEvent(&fRsnEvent[0]); - - return kTRUE; -} - -//_____________________________________________________________________________ -Int_t AliRsnAnalysisTaskEffPair::NGoodSteps() -{ -// -// Checks how many 'reconstruction' steps are passed by current daughter -// - - Int_t istep, count = 0; - Int_t nSteps = fStepsRec.GetEntries(); - - for (istep = 0; istep < nSteps; istep++) { - AliRsnCutManager *cutMgr = (AliRsnCutManager*)fStepsRec[istep]; - - if (!cutMgr->PassCommonDaughterCuts(&fDaughter[0])) break; - if (!cutMgr->PassCommonDaughterCuts(&fDaughter[1])) break; - if (!cutMgr->PassDaughter1Cuts(&fDaughter[0])) break; - if (!cutMgr->PassDaughter2Cuts(&fDaughter[1])) break; - if (!cutMgr->PassMotherCuts(&fMother)) break; - - count++; - } - - return count; -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEffPair::ProcessEventESD() -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliESDEvent *esd = fRsnEvent[0].GetRefESD(); - AliMCEvent *mc = fRsnEvent[0].GetRefMCESD(); - AliStack *stack = mc->Stack(); - TArrayI indexes[2]; - Int_t i, j, istep, imax, icheck, itrack[2], ipart; - Int_t pdg, label[2]; - Short_t charge, pairDefMatch[2]; - TParticle *part = 0x0; - AliMCParticle *mother = 0x0; - - // set pointers - fMother.SetDaughter(0, &fDaughter[0]); - fMother.SetDaughter(1, &fDaughter[1]); - - // loop on definitions - AliRsnPairDef *def = 0x0; - TObjArrayIter nextDef(&fDefs); - while ( (def = (AliRsnPairDef*)nextDef()) ) { - - // loop on the MC list of particles - for (ipart = 0; ipart < stack->GetNprimary(); ipart++) { - - // reset daughters - fDaughter[0].Reset(); - fDaughter[1].Reset(); - - // taks MC particle - mother = (AliMCParticle*)mc->GetTrack(ipart); - - // check that it is a binary decay and the PDG code matches - if (mother->Particle()->GetNDaughters() != 2) continue; - if (mother->Particle()->GetPdgCode() != def->GetMotherPDG()) continue; - - // store the labels of the two daughters - // and check that they are in the stack - label[0] = mother->Particle()->GetFirstDaughter(); - label[1] = mother->Particle()->GetLastDaughter(); - if (label[0] < 0 || label[0] > stack->GetNtrack()) continue; - if (label[1] < 0 || label[1] > stack->GetNtrack()) continue; - - // for each daughter, check what slot in the pair definition it matches - // or if it does not match any of them - for (i = 0; i < 2; i++) { - pairDefMatch[i] = -1; - part = stack->Particle(label[i]); - if (part) { - pdg = TMath::Abs(part->GetPdgCode()); - charge = (Short_t)(part->GetPDG()->Charge() / 3); - if (def->GetDef1()->MatchesPDG(pdg) && def->GetDef1()->MatchesCharge(charge)) pairDefMatch[i] = 0; - if (def->GetDef2()->MatchesPDG(pdg) && def->GetDef2()->MatchesCharge(charge)) pairDefMatch[i] = 1; - } - } - - // if the two label match the two definitions for the pair - // and if they are in the wrong order, swap them, - // otherwise, if they don't match the definition in any order, skip - if (pairDefMatch[0] == 1 && pairDefMatch[1] == 0) { - icheck = label[0]; - label[0] = label[1]; - label[1] = icheck; - } - else if (pairDefMatch[0] < 0 || pairDefMatch[1] < 0) continue; - - // from now on, we are sure that label[0] refers to the particle - // that matches definitions of first daughter, and label[1] to - // the particle that matches definitions of second daughter - fDaughter[0].SetRefMC(mc->GetTrack(label[0])); - fDaughter[1].SetRefMC(mc->GetTrack(label[1])); - - // assign masses and fill the MC steps, - // where reconstruction is not taken into account - fMother.ComputeSum(def->GetMass1(), def->GetMass2()); - FillContainer(kTRUE, def); - - // search for all reconstructed tracks which have these labels - for (i = 0; i < 2; i++) indexes[i] = FindTracks(label[i], esd); - - // if not both tracks have been reconstructed, stop here - if (indexes[0].GetSize() < 1 || indexes[1].GetSize() < 1) continue; - - // if both daughters were reconstructed - // search for the best combination of indexes for this pair - imax = itrack[0] = itrack[1] = 0; - for (i = 0; i < indexes[0].GetSize(); i++) { - for (j = 0; j < indexes[1].GetSize(); j++) { - fDaughter[0].SetRef(esd->GetTrack(indexes[0][i])); - fDaughter[1].SetRef(esd->GetTrack(indexes[1][j])); - fMother.ComputeSum(def->GetMass1(), def->GetMass2()); - istep = NGoodSteps(); - if (istep > imax) { - itrack[0] = indexes[0][i]; - itrack[1] = indexes[1][j]; - imax = istep; - } - } - } - - // then assign definitely the best combination and fill rec container - fDaughter[0].SetRef(esd->GetTrack(itrack[0])); - fDaughter[1].SetRef(esd->GetTrack(itrack[1])); - fMother.ComputeSum(def->GetMass1(), def->GetMass2()); - FillContainer(kFALSE, def); - } - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEffPair::ProcessEventAOD() -{ -// -// Process current event with the definitions of the specified step in MC list -// and store results in the container slot defined in second argument. -// It is associated with the AliCFContainer with the name of the pair. -// - - AliAODEvent *aod = fRsnEvent[0].GetRefAOD(); - TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); - if (!mcArray) return; - - TArrayI indexes[2]; - Int_t i, j, pdg, imax, istep, icheck, itrack[2], label[2]; - AliAODMCParticle *part = 0x0, *mother = 0x0; - Short_t charge = 0, pairDefMatch[2]; - - // set pointers - fMother.SetDaughter(0, &fDaughter[0]); - fMother.SetDaughter(1, &fDaughter[1]); - - // loop on definitions - AliRsnPairDef *def = 0x0; - TObjArrayIter nextDef(&fDefs); - while ( (def = (AliRsnPairDef*)nextDef()) ) { - - // loop on the MC list of particles - TObjArrayIter next(mcArray); - while ((mother = (AliAODMCParticle*)next())) { - - // check that it is a binary decay and the PDG code matches - if (mother->GetNDaughters() != 2) continue; - if (mother->GetPdgCode() != def->GetMotherPDG()) continue; - - // store the labels of the two daughters - label[0] = mother->GetDaughter(0); - label[1] = mother->GetDaughter(1); - - // for each daughter, check what slot in the pair definition it matches - // or if it does not match any of them - for (i = 0; i < 2; i++) { - pairDefMatch[i] = -1; - part = (AliAODMCParticle*)mcArray->At(label[i]); - if (part) { - pdg = TMath::Abs(part->GetPdgCode()); - charge = (Short_t)part->Charge(); - if (def->GetDef1()->MatchesPDG(pdg) && def->GetDef1()->MatchesCharge(charge)) pairDefMatch[i] = 0; - if (def->GetDef2()->MatchesPDG(pdg) && def->GetDef2()->MatchesCharge(charge)) pairDefMatch[i] = 1; - } - } - - // if the two label match the two definitions for the pair - // and if they are in the wrong order, swap them, - // otherwise, if they don't match the definition in any order, skip - if (pairDefMatch[0] == 1 && pairDefMatch[1] == 0) { - icheck = label[0]; - label[0] = label[1]; - label[1] = icheck; - } - else if (pairDefMatch[0] < 0 || pairDefMatch[1] < 0) continue; - - // from now on, we are sure that label[0] refers to the particle - // that matches definitions of first daughter, and label[1] to - // the particle that matches definitions of second daughter - fDaughter[0].SetRefMC((AliAODMCParticle*)mcArray->At(label[0])); - fDaughter[1].SetRefMC((AliAODMCParticle*)mcArray->At(label[1])); - - // assign masses and fill the MC steps, - // where reconstruction is not taken into account - fMother.ComputeSum(def->GetMass1(), def->GetMass2()); - FillContainer(kTRUE, def); - - // search for all reconstructed tracks which have these labels - for (i = 0; i < 2; i++) indexes[i] = FindTracks(label[i], aod); - - // if not both tracks have been reconstructed, stop here - if (indexes[0].GetSize() < 1 || indexes[1].GetSize() < 1) continue; - - // if both daughters were reconstructed - // search for the best combination of indexes for this pair - imax = itrack[0] = itrack[1] = 0; - for (i = 0; i < indexes[0].GetSize(); i++) { - for (j = 0; j < indexes[1].GetSize(); j++) { - fDaughter[0].SetRef(aod->GetTrack(indexes[0][i])); - fDaughter[1].SetRef(aod->GetTrack(indexes[1][j])); - fMother.ComputeSum(def->GetMass1(), def->GetMass2()); - istep = NGoodSteps(); - if (istep > imax) { - itrack[0] = indexes[0][i]; - itrack[1] = indexes[1][j]; - } - } - } - - // then assign definitely the best combination and fill rec container - fDaughter[0].SetRef(aod->GetTrack(itrack[0])); - fDaughter[1].SetRef(aod->GetTrack(itrack[1])); - fMother.ComputeSum(def->GetMass1(), def->GetMass2()); - FillContainer(kFALSE, def); - } - } -} - -//_____________________________________________________________________________ -void AliRsnAnalysisTaskEffPair::FillContainer(Bool_t mcList, TObject *defObj) -{ -// -// Fill the container corresponding to current definition. -// - - // cast the object into the def - if (!defObj->InheritsFrom(AliRsnPairDef::Class())) { - AliError("Def object does not inherit from AliRsnPairDef!"); - return; - } - AliRsnPairDef *def = static_cast(defObj); - - // retrieve container - AliCFContainer *cont = (AliCFContainer*)fOutList->FindObject(def->GetName()); - if (!cont) return; - - TObjArray &stepList = (mcList ? fStepsMC : fStepsRec); - Int_t firstStep = (mcList ? 0 : ((Int_t)fStepsMC.GetEntries())); - Int_t iaxis, nAxes = fAxes.GetEntries(); - Int_t istep, nSteps = stepList.GetEntries(); - Bool_t computeOK; - - // compute values for all axes - for (iaxis = 0; iaxis < nAxes; iaxis++) { - AliRsnValue *fcnAxis = (AliRsnValue*)fAxes.At(iaxis); - fVar[iaxis] = -1E10; - switch (fcnAxis->GetTargetType()) { - case AliRsnTarget::kMother: - fcnAxis->SetSupportObject(def); - computeOK = fcnAxis->Eval(&fMother, mcList); - break; - case AliRsnTarget::kEvent: - computeOK = fcnAxis->Eval(&fRsnEvent[0]); - break; - default: - AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", fcnAxis->GetName(), fcnAxis->GetTargetTypeName())); - computeOK = kFALSE; - } - if (computeOK) fVar[iaxis] = ((Float_t)fcnAxis->GetComputedValue()); - } - - // fill all successful steps - for (istep = 0; istep < nSteps; istep++) { - AliRsnCutManager *cutMgr = (AliRsnCutManager*)stepList[istep]; - - if (!cutMgr->PassCommonDaughterCuts(&fDaughter[0])) break; - if (!cutMgr->PassCommonDaughterCuts(&fDaughter[1])) break; - if (!cutMgr->PassDaughter1Cuts(&fDaughter[0])) break; - if (!cutMgr->PassDaughter2Cuts(&fDaughter[1])) break; - if (!cutMgr->PassMotherCuts(&fMother)) break; - - AliDebug(AliLog::kDebug + 2, Form("DEF: %s --> filling step %d", def->GetName(), istep)); - cont->Fill(fVar.GetArray(), istep + firstStep); - } -} diff --git a/PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.h b/PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.h deleted file mode 100644 index cdc97a11c37..00000000000 --- a/PWG2/RESONANCES/AliRsnAnalysisTaskEffPair.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// Class AliRsnAnalysisTaskEffPair -// -// Inherits from basic AliRsnAnalysisTaskEff for efficiency, -// and computed efficiencies for pairs -// -// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#ifndef ALIRSNANALYSISEFFPAIR_H -#define ALIRSNANALYSISEFFPAIR_H - -#include "AliRsnDaughter.h" -#include "AliRsnMother.h" -#include "AliRsnAnalysisTaskEff.h" - -class AliRsnPairDef; - -class AliRsnAnalysisTaskEffPair : public AliRsnAnalysisTaskEff { - -public: - - AliRsnAnalysisTaskEffPair(const char *name = "AliRsnAnalysisTaskMonitorEffSE"); - AliRsnAnalysisTaskEffPair(const AliRsnAnalysisTaskEffPair& copy); - AliRsnAnalysisTaskEffPair& operator=(const AliRsnAnalysisTaskEffPair& copy); - virtual ~AliRsnAnalysisTaskEffPair() {;}; - - virtual Bool_t RsnEventProcess(); - -protected: - - virtual void ProcessEventESD(); - virtual void ProcessEventAOD(); - virtual Int_t NGoodSteps(); - virtual void FillContainer(Bool_t mcList, TObject*def); - - AliRsnDaughter fDaughter[2]; //! current tracks - AliRsnMother fMother; //! current mother - - ClassDef(AliRsnAnalysisTaskEffPair, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnCutESD2010.cxx b/PWG2/RESONANCES/AliRsnCutESD2010.cxx deleted file mode 100644 index 131d2913c74..00000000000 --- a/PWG2/RESONANCES/AliRsnCutESD2010.cxx +++ /dev/null @@ -1,353 +0,0 @@ -// -// Class AliRsnCutESD2010 -// -// General implementation of a single cut strategy, which can be: -// - a value contained in a given interval [--> IsBetween() ] -// - a value equal to a given reference [--> MatchesValue()] -// -// In all cases, the reference value(s) is (are) given as data members -// and each kind of cut requires a given value type (Int, UInt, Double), -// but the cut check procedure is then automatized and chosen thanks to -// an enumeration of the implemented cut types. -// At the end, the user (or any other point which uses this object) has -// to use the method IsSelected() to check if this cut has been passed. -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include - -#include "AliESDpid.h" -#include "AliITSPIDResponse.h" - -#include "AliRsnEvent.h" -#include "AliRsnDaughter.h" -#include "AliRsnCutESD2010.h" - -ClassImp(AliRsnCutESD2010) - -//_________________________________________________________________________________________________ -AliRsnCutESD2010::AliRsnCutESD2010 -(const char *name, Bool_t isMC) : - AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0), - fIsMC(isMC), - fCheckITS(kTRUE), - fCheckTPC(kTRUE), - fCheckTOF(kTRUE), - fUseITSTPC(kTRUE), - fUseITSSA(kTRUE), - fPID(AliPID::kKaon), - fMaxITSPIDmom(0.0), - fMaxITSband(3.0), - fTPCpLimit(0.35), - fMinTPCband(3.0), - fMaxTPCband(5.0), - fESDpid(), - fESDtrackCutsTPC(), - fESDtrackCutsITS(), - fMinTOF(-3.0), - fMaxTOF(3.0) -{ -// -// Main constructor. -// - - SetMC(isMC); - - for (Int_t i = 0; i < 5; i++) fTPCpar[i] = 0.0; -} - -//_________________________________________________________________________________________________ -AliRsnCutESD2010::AliRsnCutESD2010 -(const AliRsnCutESD2010& copy) : - AliRsnCut(copy), - fIsMC(copy.fIsMC), - fCheckITS(copy.fCheckITS), - fCheckTPC(copy.fCheckTPC), - fCheckTOF(copy.fCheckTOF), - fUseITSTPC(copy.fUseITSTPC), - fUseITSSA(copy.fUseITSSA), - fPID(copy.fPID), - fMaxITSPIDmom(copy.fMaxITSPIDmom), - fMaxITSband(copy.fMaxITSband), - fTPCpLimit(copy.fTPCpLimit), - fMinTPCband(copy.fMinTPCband), - fMaxTPCband(copy.fMaxTPCband), - fESDpid(copy.fESDpid), - fESDtrackCutsTPC(copy.fESDtrackCutsTPC), - fESDtrackCutsITS(copy.fESDtrackCutsITS), - fMinTOF(copy.fMinTOF), - fMaxTOF(copy.fMaxTOF) -{ -// -// Copy constructor. -// - - SetMC(copy.fIsMC); - - Int_t i = 0; - for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i]; -} - -//_________________________________________________________________________________________________ -AliRsnCutESD2010& AliRsnCutESD2010::operator=(const AliRsnCutESD2010& copy) -{ -// -// Assignment operator -// - - AliRsnCut::operator=(copy); - - SetMC(copy.fIsMC); - - fCheckITS = copy.fCheckITS; - fCheckTPC = copy.fCheckTPC; - fCheckTOF = copy.fCheckTOF; - fUseITSTPC = copy.fUseITSTPC; - fUseITSSA = copy.fUseITSSA; - fPID = copy.fPID; - fMaxITSPIDmom = copy.fMaxITSPIDmom; - fMaxITSband = copy.fMaxITSband; - fTPCpLimit = copy.fTPCpLimit; - fMinTPCband = copy.fMinTPCband; - fMaxTPCband = copy.fMaxTPCband; - fMinTOF = copy.fMinTOF; - fMaxTOF = copy.fMaxTOF; - fESDpid = copy.fESDpid; - - Int_t i = 0; - for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i]; - - - fESDtrackCutsTPC = copy.fESDtrackCutsTPC; - fESDtrackCutsITS = copy.fESDtrackCutsITS; - - return (*this); -} - -//_________________________________________________________________________________________________ -void AliRsnCutESD2010::SetMC(Bool_t isMC) -{ -// -// Sets some aspects of cuts depending on the fact that runs on MC or not -// - - fIsMC = isMC; - - AliITSPIDResponse itsresponse(fIsMC); - fESDpid.GetITSResponse() = itsresponse; -} - -//_________________________________________________________________________________________________ -Bool_t AliRsnCutESD2010::IsSelected(TObject *object) -{ -// -// Cut checker. -// - - // coherence check: require an ESD track - if (!TargetOK(object)) return kFALSE; - AliESDtrack *track = fDaughter->GetRefESDtrack(); - if (!track) return kFALSE; - - // if no reference event, skip - AliRsnEvent *rsn = fEvent; - if (!rsn) return kFALSE; - fESDpid.SetTOFResponse(rsn->GetRefESD(), AliESDpid::kTOF_T0); - - // check quality and track type and reject tracks not passing this step - if (!OkQuality(track)) { - AliDebug(AliLog::kDebug + 2, "Failed quality cut"); - return kFALSE; - } - - // ITS PID can be checked always - // if PID is not required, the flag is sed as - // if the cut was alsways passed - Bool_t okITSpid = OkITSPID(track); - if (!fCheckITS) okITSpid = kTRUE; - - // TPC PID can be checked only for TPC+ITS tracks - // if PID is not required, the flag is sed as - // if the cut was alsways passed - Bool_t okTPCpid = kFALSE; - if (IsITSTPC(track)) okTPCpid = OkTPCPID(track); - if (!fCheckTPC) okTPCpid = kTRUE; - - // TOF PID can be checked only if TOF is matched - // if PID is not required, the flag is sed as - // if the cut was alsways passed - Bool_t okTOFpid = kFALSE; - if (IsITSTPC(track) && MatchTOF(track)) okTOFpid = OkTOFPID(track); - if (!fCheckTOF) okTOFpid = kTRUE; - - // now combine all outcomes according to the different possibilities: - // -- ITS standalone: - // --> only ITS PID, always - // -- ITS + TPC: - // --> ITS PID, only for momenta lower than 'fMaxITSPIDmom' and when the ITSpid flag is active - // --> TPC PID, always --> MASTER (first to be checked, if fails, track is rejected) - // --> TOF PID, only if matched - if (IsITSSA(track)) { - if (!okITSpid) { - AliDebug(AliLog::kDebug + 2, "ITS standalone track --> ITS PID failed"); - return kFALSE; - } - } else { // checking IsITSTPC() is redundant due to OkQuality() cut check - if (!okTPCpid) { - AliDebug(AliLog::kDebug + 2, "ITS+TPC track --> TPC PID failed"); - return kFALSE; - } else if (MatchTOF(track) && !okTOFpid) { - AliDebug(AliLog::kDebug + 2, "ITS+TPC track --> TOF matched but TOF PID failed"); - return kFALSE; - } else if (track->IsOn(AliESDtrack::kITSpid) && track->P() <= fMaxITSPIDmom && !okITSpid) { - AliDebug(AliLog::kDebug + 2, Form("ITS+TPC track --> Momentum lower than limit (%.2f) and ITS PID failed", fMaxITSPIDmom)); - return kFALSE; - } - } - - // arriving here, the track has survived all checks - return kTRUE; -} - -//______________________________________________________________________________ -Bool_t AliRsnCutESD2010::OkQuality(AliESDtrack *track) -{ -// -// Check track quality parameters. -// Rejects all tracks which are not either TPC+ITS nor ITS standalone. -// If tracks of any type are not flagged to be used, they are rejected anyway. -// - - if (IsITSTPC(track)) return (fUseITSTPC && fESDtrackCutsTPC.IsSelected(track)); - if (IsITSSA(track)) return (fUseITSSA && fESDtrackCutsITS.IsSelected(track)); - - return kFALSE; -} - -//______________________________________________________________________________ -Bool_t AliRsnCutESD2010::OkITSPID(AliESDtrack *track) -{ -// -// Check ITS particle identification with 3sigma cut -// - - // count PID layers and reject if they are too few - Int_t k, nITSpidLayers = 0; - UChar_t itsCluMap = track->GetITSClusterMap(); - for (k = 2; k < 6; k++) if (itsCluMap & (1 << k)) ++nITSpidLayers; - if (nITSpidLayers < 3) { - AliDebug(AliLog::kDebug + 2, "Rejecting track with too few ITS pid layers"); - return kFALSE; - } - - // check the track type (ITS+TPC or ITS standalone) - // and reject it if it is of none of the allowed types - Bool_t isSA = kFALSE; - if (IsITSTPC(track)) isSA = kFALSE; - else if (IsITSSA(track)) isSA = kTRUE; - else { - AliWarning("Track is neither ITS+TPC nor ITS standalone"); - return kFALSE; - } - - // create the PID response object and compute nsigma - AliITSPIDResponse &itsrsp = fESDpid.GetITSResponse(); - Double_t mom = track->P(); - Double_t nSigma = itsrsp.GetNumberOfSigmas(mom, track->GetITSsignal(), fPID, nITSpidLayers, isSA); - - // evaluate the cut - Bool_t ok = (TMath::Abs(nSigma) <= fMaxITSband); - - // debug message - AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", nSigma, fMaxITSband, (ok ? "passed" : "failed"))); - - // outcome - return ok; -} - -//______________________________________________________________________________ -Bool_t AliRsnCutESD2010::OkTPCPID(AliESDtrack *track) -{ -// -// Check TPC particle identification with {3|5}sigmacut, -// depending on the track total momentum. -// - - // setup TPC PID response - AliTPCPIDResponse &tpcrsp = fESDpid.GetTPCResponse(); - //tpcrsp.SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]); - - // get momentum and number of sigmas and choose the reference band - Double_t mom = track->GetInnerParam()->P(); - Double_t nSigma = tpcrsp.GetNumberOfSigmas(mom, track->GetTPCsignal(), track->GetTPCsignalN(), fPID); - Double_t maxNSigma = fMaxTPCband; - if (mom < fTPCpLimit) maxNSigma = fMinTPCband; - - // evaluate the cut - Bool_t ok = (TMath::Abs(nSigma) <= maxNSigma); - - // debug message - AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", nSigma, maxNSigma, (ok ? "passed" : "failed"))); - - // outcome - return ok; -} - -//______________________________________________________________________________ -Bool_t AliRsnCutESD2010::OkTOFPID(AliESDtrack *track) -{ -// -// Check TOF particle identification if matched there. -// - - // reject not TOF-matched tracks - if (!MatchTOF(track)) return kFALSE; - - // setup TOF PID response - AliTOFPIDResponse &tofrsp = fESDpid.GetTOFResponse(); - - // get info for computation - Double_t momentum = track->P(); - Double_t time = track->GetTOFsignal(); - Double_t timeint[AliPID::kSPECIES]; - tofrsp.GetStartTime(momentum); - track->GetIntegratedTimes(timeint); - - // check the cut - Double_t timeDiff = time - timeint[(Int_t)fPID]; - Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)fPID], AliPID::ParticleMass(fPID)); - Double_t nSigma = timeDiff / sigmaRef; - - // evaluate the cut - Bool_t ok = (nSigma >= fMinTOF && nSigma <= fMaxTOF); - - // debug message - AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f - %f -- cut %s", nSigma, fMinTOF, fMaxTOF, (ok ? "passed" : "failed"))); - - // outcome - return ok; -} - -//_________________________________________________________________________________________________ -void AliRsnCutESD2010::Print(const Option_t *) const -{ -// -// Print information on this cut -// - - AliInfo(Form("Cut name : %s", GetName())); - AliInfo(Form("Using MC settings : %s", (fIsMC ? "YES" : "NO"))); - AliInfo(Form("Using TPC+ITS tracks : %s", (fUseITSTPC ? "YES" : "NO"))); - AliInfo(Form("Using ITS SA tracks : %s", (fUseITSSA ? "YES" : "NO"))); - AliInfo(Form("Check ITS PID : %s", (fCheckITS ? "YES" : "NO"))); - AliInfo(Form("Check TPC PID : %s", (fCheckTPC ? "YES" : "NO"))); - AliInfo(Form("Check TOF PID : %s", (fCheckTOF ? "YES" : "NO"))); - AliInfo(Form("Reference particle : %s", AliPID::ParticleName(fPID))); - AliInfo(Form("ITS PID range (sigmas): %f", fMaxITSband)); - AliInfo(Form("ITS PID range (pt) : %f", fMaxITSPIDmom)); - AliInfo(Form("TPC PID ranges (sigmas): %f %f", fMinTPCband, fMaxTPCband)); - AliInfo(Form("TPC PID limit (p) : %f", fTPCpLimit)); - AliInfo(Form("TOF range (sigmas) : %f - %f", fMinTOF, fMaxTOF)); -} diff --git a/PWG2/RESONANCES/AliRsnCutESD2010.h b/PWG2/RESONANCES/AliRsnCutESD2010.h deleted file mode 100644 index 4cd7956e24b..00000000000 --- a/PWG2/RESONANCES/AliRsnCutESD2010.h +++ /dev/null @@ -1,155 +0,0 @@ -// -// *** Class AliRsnCutESD2010 *** -// -// This class implements all cuts which have to be used for the 2010 runs -// for phi and generic resonance analysis. -// It contains an AliESDtrackCuts object for track quality selection -// and some criteria for particle identification with ITS, TPC and TOF. -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#ifndef ALIRSNCUTESD2010_H -#define ALIRSNCUTESD2010_H - -#include "AliPID.h" -#include "AliESDtrack.h" -#include "AliESDtrackCuts.h" -#include "AliESDpid.h" -#include "AliRsnCut.h" - -class AliESDpid; - -class AliRsnCutESD2010 : public AliRsnCut { -public: - - AliRsnCutESD2010(const char *name = "cutESD2010", Bool_t isMC = kFALSE); - AliRsnCutESD2010(const AliRsnCutESD2010& copy); - AliRsnCutESD2010& operator=(const AliRsnCutESD2010& copy); - virtual ~AliRsnCutESD2010() {;}; - - AliESDpid* GetESDpid() {return &fESDpid;} - AliESDtrackCuts* GetCutsTPC() {return &fESDtrackCutsTPC;} - AliESDtrackCuts* GetCutsITS() {return &fESDtrackCutsITS;} - void CopyCutsTPC(const AliESDtrackCuts *cuts) {fESDtrackCutsTPC = (*cuts);} - void CopyCutsITS(const AliESDtrackCuts *cuts) {fESDtrackCutsITS = (*cuts);} - //void CopyCutsTPC(AliESDtrackCuts cuts) {fESDtrackCutsTPC = cuts;} - //void CopyCutsITS(AliESDtrackCuts cuts) {fESDtrackCutsITS = cuts;} - virtual Bool_t IsSelected(TObject *object); - virtual void Print(const Option_t *option = "") const; - - void SetMC(Bool_t yn = kTRUE); - void SetCheckITS(Bool_t yn = kTRUE) {fCheckITS = yn;} - void SetCheckTPC(Bool_t yn = kTRUE) {fCheckTPC = yn;} - void SetCheckTOF(Bool_t yn = kTRUE) {fCheckTOF = yn;} - void SetUseITSTPC(Bool_t yn = kTRUE) {fUseITSTPC = yn;} - void SetUseITSSA(Bool_t yn = kTRUE) {fUseITSSA = yn;} - void SetPID(AliPID::EParticleType t) {fPID = t;} - - void SetMaxITSPIDmom(Double_t v) {fMaxITSPIDmom = v;} - void SetITSband(Double_t v) {fMaxITSband = v;} - - void SetTPCpLimit(Double_t v) {fTPCpLimit = v;} - void SetTPCrange(Double_t min, Double_t max) {fMinTPCband = min; fMaxTPCband = max;} - void SetTPCpar(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4) - {fTPCpar[0] = p0; fTPCpar[1] = p1; fTPCpar[2] = p2; fTPCpar[3] = p3; fTPCpar[4] = p4;} - - void SetTOFrange(Double_t v1, Double_t v2) {fMinTOF = v1; fMaxTOF = v2;} - -protected: - - Bool_t OkQuality(AliESDtrack *d); // check track quality parameters and DCA - Bool_t OkITSPID(AliESDtrack *d); // check ITS PID - Bool_t OkTPCPID(AliESDtrack *d); // check TPC PID - Bool_t OkTOFPID(AliESDtrack *d); // check TOF PID - Bool_t IsITSTPC(AliESDtrack *d); // check that the track is TPC+ITS - Bool_t IsITSSA(AliESDtrack *d); // check that the track is ITS standalone - Bool_t MatchTOF(AliESDtrack *d); // check that the track matches the TOF - - Bool_t fIsMC; // switch for MC analysis - Bool_t fCheckITS; // switch for ITS dE/dx check - Bool_t fCheckTPC; // switch for TPC dE/dx check - Bool_t fCheckTOF; // switch for TOF time check - Bool_t fUseITSTPC; // switch to use TPC global tracks - Bool_t fUseITSSA; // switch to use ITS standalone tracks - AliPID::EParticleType fPID; // PID reference type used for checks - - Double_t fMaxITSPIDmom; // maximum momentum where ITS PID is used for TPC+ITS tracks - Double_t fMaxITSband; // range for ITS de/dx band - - Double_t fTPCpLimit; // limit to choose what band to apply - Double_t fTPCpar[5]; // parameters for TPC bethe-Bloch - Double_t fMinTPCband; // range for TPC de/dx band - min - Double_t fMaxTPCband; // range for TPC de/dx band - max - - AliESDpid fESDpid; // ESD PID object - AliESDtrackCuts fESDtrackCutsTPC; // ESD standard defined track cuts for TPC tracks - AliESDtrackCuts fESDtrackCutsITS; // ESD standard defined track cuts for ITS-SA tracks - Double_t fMinTOF; // range for TOF PID (min) - Double_t fMaxTOF; // range for TOF PID (max) - - ClassDef(AliRsnCutESD2010, 1) -}; - -inline Bool_t AliRsnCutESD2010::IsITSTPC(AliESDtrack *vtrack) -{ -// -// Checks if the track has the status flags required for a global track -// - - if (!vtrack) { - AliWarning("NULL argument: impossible to check status"); - return kFALSE; - } - - return vtrack->IsOn(AliESDtrack::kTPCin); - - return kTRUE; -} - -inline Bool_t AliRsnCutESD2010::IsITSSA(AliESDtrack *vtrack) -{ -// -// Checks if the track has the status flags required for an ITS standalone track -// - - if (!vtrack) { - AliWarning("NULL argument: impossible to check status"); - return kFALSE; - } - - Bool_t isTPCin = vtrack->IsOn(AliESDtrack::kTPCin); - Bool_t isITSrefit = vtrack->IsOn(AliESDtrack::kITSrefit); - Bool_t isITSpureSA = vtrack->IsOn(AliESDtrack::kITSpureSA); - Bool_t isITSpid = vtrack->IsOn(AliESDtrack::kITSpid); - - return ((!isTPCin) && isITSrefit && (!isITSpureSA) && isITSpid); - - return kTRUE; -} - - -inline Bool_t AliRsnCutESD2010::MatchTOF(AliESDtrack *vtrack) -{ -// -// Checks if the track has matched the TOF detector -// - - if (!vtrack) { - AliWarning("NULL argument: impossible to check status"); - return kFALSE; - } - - // require a minimum length to have meaningful match - if (vtrack->GetIntegratedLength() < 350.) return kFALSE; - - Bool_t isTOFout = vtrack->IsOn(AliESDtrack::kTOFout); - Bool_t isTIME = vtrack->IsOn(AliESDtrack::kTIME); - - return (isTOFout && isTIME); - - return kTRUE; -} - -#endif diff --git a/PWG2/RESONANCES/AliRsnCutManager.h b/PWG2/RESONANCES/AliRsnCutManager.h index b4829e6b49c..7bbf1de350b 100644 --- a/PWG2/RESONANCES/AliRsnCutManager.h +++ b/PWG2/RESONANCES/AliRsnCutManager.h @@ -42,6 +42,7 @@ public: AliRsnCutSet* GetDaughter2Cuts() {return &fDaughterCuts2;} AliRsnCutSet* GetMotherCuts() {return &fMotherCuts;} + Bool_t IsSelected(TObject *object); Bool_t PassCommonDaughterCuts(AliRsnDaughter *daughter) {return fDaughterCutsCommon.IsSelected(daughter);} Bool_t PassDaughter1Cuts(AliRsnDaughter *daughter) {return fDaughterCuts1.IsSelected(daughter);} Bool_t PassDaughter2Cuts(AliRsnDaughter *daughter) {return fDaughterCuts2.IsSelected(daughter);} @@ -59,4 +60,26 @@ private: ClassDef(AliRsnCutManager, 2) // dictionary }; +inline Bool_t AliRsnCutManager::IsSelected(TObject *object) +{ +// +// Check all selection cuts +// + + if (object->InheritsFrom(AliRsnDaughter::Class())) { + return PassCommonDaughterCuts((AliRsnDaughter*)object); + } else if (object->InheritsFrom(AliRsnMother::Class())) { + AliRsnMother *mother = (AliRsnMother*)object; + if (!PassCommonDaughterCuts(mother->GetDaughter(0))) return kFALSE; + if (!PassCommonDaughterCuts(mother->GetDaughter(1))) return kFALSE; + if (!PassDaughter1Cuts(mother->GetDaughter(0))) return kFALSE; + if (!PassDaughter2Cuts(mother->GetDaughter(1))) return kFALSE; + if (!PassMotherCuts(mother)) return kFALSE; + return kTRUE; + } else { + AliError("AliRsnCutManager can check only daughters and mothers"); + return kFALSE; + } +} + #endif diff --git a/PWG2/RESONANCES/AliRsnCutPIDITS.cxx b/PWG2/RESONANCES/AliRsnCutPIDITS.cxx index 1acd861fb07..f50cf1de0b2 100644 --- a/PWG2/RESONANCES/AliRsnCutPIDITS.cxx +++ b/PWG2/RESONANCES/AliRsnCutPIDITS.cxx @@ -27,7 +27,7 @@ ClassImp(AliRsnCutPIDITS) AliRsnCutPIDITS::AliRsnCutPIDITS (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectOutside) : AliRsnCut(name, AliRsnCut::kDaughter, min, max), - fInitialized(kFALSE), + fIsMC(kFALSE), fRejectOutside(rejectOutside), fMomMin(0.0), fMomMax(1E+20), @@ -44,7 +44,7 @@ AliRsnCutPIDITS::AliRsnCutPIDITS AliRsnCutPIDITS::AliRsnCutPIDITS (const AliRsnCutPIDITS& copy) : AliRsnCut(copy), - fInitialized(kFALSE), + fIsMC(copy.fIsMC), fRejectOutside(copy.fRejectOutside), fMomMin(copy.fMomMin), fMomMax(copy.fMomMax), @@ -66,7 +66,7 @@ AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy) AliRsnCut::operator=(copy); - fInitialized = kFALSE; + fIsMC = copy.fIsMC; fRejectOutside = copy.fRejectOutside; fMomMin = copy.fMomMin; fMomMax = copy.fMomMax; @@ -77,19 +77,6 @@ AliRsnCutPIDITS& AliRsnCutPIDITS::operator=(const AliRsnCutPIDITS& copy) return (*this); } -//_________________________________________________________________________________________________ -void AliRsnCutPIDITS::SetMC(Bool_t yn) -{ -// -// Properly set the PID response -// - - AliITSPIDResponse itsresponse(yn); - - fESDpid.GetITSResponse() = itsresponse; - fAODpid.GetITSResponse() = itsresponse; -} - //_________________________________________________________________________________________________ Bool_t AliRsnCutPIDITS::IsSelected(TObject *object) { @@ -97,9 +84,6 @@ Bool_t AliRsnCutPIDITS::IsSelected(TObject *object) // Cut checker. // - // initialize if needed - if (!fInitialized) Initialize(); - // coherence check if (!TargetOK(object)) return kFALSE; @@ -145,10 +129,13 @@ Bool_t AliRsnCutPIDITS::IsSelected(TObject *object) // assign PID nsigmas to default cut check value // since bad object types are rejected before, here we have an ESD track or AOD track - if (esdTrack) - fCutValueD = fESDpid.GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA); - else - fCutValueD = fAODpid.NumberOfSigmasITS(aodTrack, fRefType); + if (esdTrack) { + if (!fESDpid) fESDpid = new AliESDpid(fIsMC); + fCutValueD = fESDpid->GetITSResponse().GetNumberOfSigmas(mom, esdTrack->GetITSsignal(), fRefType, nITSpidLayers, isSA); + } else { + if (!fAODpid) fAODpid = new AliAODpidUtil(fIsMC); + fCutValueD = fAODpid->NumberOfSigmasITS(aodTrack, fRefType); + } // use AliRsnCut default method to check cut Bool_t cutCheck = OkRangeD(); @@ -179,20 +166,3 @@ void AliRsnCutPIDITS::Print(const Option_t *) const AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax)); AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted"))); } - -//_________________________________________________________________________________________________ -void AliRsnCutPIDITS::Initialize() -{ -// -// Initialize ESD pid object from global one -// - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliESDInputHandler *handler = dynamic_cast(mgr->GetInputEventHandler()); - if (handler) { - AliESDpid *pid = handler->GetESDpid(); - if (pid) fESDpid = (*pid); - } - - fInitialized = kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnCutPIDITS.h b/PWG2/RESONANCES/AliRsnCutPIDITS.h index 7b5ae5adf44..2bda631d9fe 100644 --- a/PWG2/RESONANCES/AliRsnCutPIDITS.h +++ b/PWG2/RESONANCES/AliRsnCutPIDITS.h @@ -37,10 +37,10 @@ public: AliRsnCutPIDITS& operator=(const AliRsnCutPIDITS& copy); virtual ~AliRsnCutPIDITS() { } - AliESDpid* ESDpid() {return &fESDpid;} - AliAODpidUtil* AODpid() {return &fAODpid;} + AliESDpid* ESDpid() {return fESDpid;} + AliAODpidUtil* AODpid() {return fAODpid;} - void SetMC(Bool_t mc = kTRUE); + void SetMC(Bool_t mc = kTRUE) {fIsMC = mc;} void SetRejectOutside(Bool_t yn = kTRUE) {fRejectOutside = yn;} void SetMomentumRange(Double_t min, Double_t max) {fMomMin = min; fMomMax = max;} void SetNSigmaRange(Double_t min, Double_t max) {fMinD = min; fMaxD = max;} @@ -53,15 +53,13 @@ public: private: - void Initialize(); - - Bool_t fInitialized; // a mono-usage flag which initializes the ESD pid object - Bool_t fRejectOutside; // choose if tracks outside momentum range are rejected or not - Double_t fMomMin; // min p in range where this cut is checked - Double_t fMomMax; // max p in range where this cut is checked - EPARTYPE fRefType; // particle type for which PID is checked - AliESDpid fESDpid; // ESD PID object - AliAODpidUtil fAODpid; // AOD PID object + Bool_t fIsMC; // needed to initialize the pid object + Bool_t fRejectOutside; // choose if tracks outside momentum range are rejected or not + Double_t fMomMin; // min p in range where this cut is checked + Double_t fMomMax; // max p in range where this cut is checked + EPARTYPE fRefType; // particle type for which PID is checked + AliESDpid *fESDpid; //! ESD PID object + AliAODpidUtil *fAODpid; //! AOD PID object ClassDef(AliRsnCutPIDITS, 1) }; @@ -77,13 +75,9 @@ inline Bool_t AliRsnCutPIDITS::IsTPC(AliVTrack *vtrack) return kFALSE; } - Bool_t isTPCin = ((vtrack->GetStatus() & AliESDtrack::kTPCin) != 0); - Bool_t isITSrefit = ((vtrack->GetStatus() & AliESDtrack::kITSrefit) != 0); - Bool_t isITSpid = ((vtrack->GetStatus() & AliESDtrack::kITSpid) != 0); - - return (isTPCin && isITSrefit && isITSpid); + Bool_t isTPCin = ((vtrack->GetStatus() & AliESDtrack::kTPCin) != 0); - return kTRUE; + return (isTPCin); } inline Bool_t AliRsnCutPIDITS::IsSA(AliVTrack *vtrack) diff --git a/PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx b/PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx new file mode 100644 index 00000000000..7e5bdde7151 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnCutPIDNSigma.cxx @@ -0,0 +1,193 @@ +// +// Class AliRsnCutPIDNSigma +// +// General implementation of a single cut strategy, which can be: +// - a value contained in a given interval [--> IsBetween() ] +// - a value equal to a given reference [--> MatchesValue()] +// +// In all cases, the reference value(s) is (are) given as data members +// and each kind of cut requires a given value type (Int, UInt, Double), +// but the cut check procedure is then automatized and chosen thanks to +// an enumeration of the implemented cut types. +// At the end, the user (or any other point which uses this object) has +// to use the method IsSelected() to check if this cut has been passed. +// +// authors: Martin Vala (martin.vala@cern.ch) +// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// + +#include "AliPIDResponse.h" +#include "AliAnalysisManager.h" +#include "AliInputEventHandler.h" +#include "AliMultiInputEventHandler.h" + +#include "AliRsnCutPIDNSigma.h" + +ClassImp(AliRsnCutPIDNSigma) + +//_________________________________________________________________________________________________ +AliRsnCutPIDNSigma::AliRsnCutPIDNSigma +(const char *name, AliPID::EParticleType species, EDetector det, Double_t nsigma) : + AliRsnCut(name, AliRsnCut::kDaughter, -nsigma, nsigma), + fSpecies(species), + fDetector(det), + fMomMin(0.0), + fMomMax(0.0), + fRejectOutside(kFALSE), + fRejectUnmatched(kFALSE) +{ +// +// Main constructor. +// +} + +//_________________________________________________________________________________________________ +AliRsnCutPIDNSigma::AliRsnCutPIDNSigma +(const AliRsnCutPIDNSigma& copy) : + AliRsnCut(copy), + fSpecies(copy.fSpecies), + fDetector(copy.fDetector), + fMomMin(copy.fMomMin), + fMomMax(copy.fMomMax), + fRejectOutside(copy.fRejectOutside), + fRejectUnmatched(copy.fRejectUnmatched) +{ +// +// Copy constructor. +// +} + +//_________________________________________________________________________________________________ +AliRsnCutPIDNSigma& AliRsnCutPIDNSigma::operator=(const AliRsnCutPIDNSigma& copy) +{ +// +// Assignment operator +// + + AliRsnCut::operator=(copy); + + fSpecies = copy.fSpecies; + fDetector = copy.fDetector; + fMomMin = copy.fMomMin; + fMomMax = copy.fMomMax; + fRejectOutside = copy.fRejectOutside; + fRejectUnmatched = copy.fRejectUnmatched; + + return (*this); +} + +//_________________________________________________________________________________________________ +Bool_t AliRsnCutPIDNSigma::IsSelected(TObject *object) +{ +// +// Cut checker. +// + + // coherence check + if (!TargetOK(object)) return kFALSE; + + // check initialization of PID object + AliPIDResponse *pid = fEvent->GetPIDResponse(); + if (!pid) { + AliFatal("NULL PID response"); + return kFALSE; + } + + // get reference momentum, for range cut + Double_t momentum = -1.0; + if (!fDaughter->GetRefVtrack()) { + AliDebugClass(2, "Referenced daughter is not a track"); + return kFALSE; + } + if (fDetector == kTPC) + momentum = fDaughter->GetRefVtrack()->GetTPCmomentum(); + else + momentum = fDaughter->GetRef()->P(); + + // check momentum range, if required + if (fRejectOutside) { + if (momentum < fMomMin || momentum > fMomMax) { + AliDebugClass(2, Form("Track momentum = %.5f, outside allowed range [%.2f - %.2f]", momentum, fMomMin, fMomMax)); + return kFALSE; + } + } + + // matching check, if required + if (fRejectUnmatched) { + switch (fDetector) { + case kITS: + if (!IsITS()) { + AliDebug(3, "Rejecting track not matched in ITS"); + return kFALSE; + } + break; + case kTPC: + if (!IsTPC()) { + AliDebug(3, "Rejecting track not matched in TPC"); + return kFALSE; + } + break; + case kTOF: + if (!IsTOF()) { + AliDebug(3, "Rejecting track not matched in TOF"); + return kFALSE; + } + break; + default: + AliWarning("Required to reject unmatched tracks, but no detector defined. Track rejected"); + return kFALSE; + } + } + + // check PID + // the number of sigmas is set as cut value, which is then checked + // using the basic functions available in AliRsnCut + switch (fDetector) { + case kITS: + fCutValueD = pid->NumberOfSigmasITS(fDaughter->GetRef(), fSpecies); + break; + case kTPC: + fCutValueD = pid->NumberOfSigmasTPC(fDaughter->GetRef(), fSpecies); + break; + case kTOF: + fCutValueD = pid->NumberOfSigmasTOF(fDaughter->GetRef(), fSpecies); + break; + default: + fCutValueD = 1E20; + return kFALSE; + } + + return OkRangeD(); +} + +//_________________________________________________________________________________________________ +void AliRsnCutPIDNSigma::Print(const Option_t *) const +{ +// +// Print information on this cut +// + + Char_t mom[100], det[10], match[100]; + + if (fRejectOutside) + sprintf(mom, "Tracks are accepted only in the momentum range %.2f --> %.2f", fMomMin, fMomMax); + else + sprintf(mom, "No check in momentum range"); + + if (fRejectUnmatched) + sprintf(match, "Unmatched tracks are rejected"); + else + sprintf(match, "No check on track matching"); + + switch (fDetector) { + case kITS: sprintf(det, "ITS"); break; + case kTPC: sprintf(det, "TPC"); break; + case kTOF: sprintf(det, "TOF"); break; + default : sprintf(det, "undefined"); + } + + AliInfo(Form("Cut name : %s", GetName())); + AliInfo(Form("--> PID detector : %s", det)); + AliInfo(Form("--> match criteria: %s", match)); + AliInfo(Form("--> momentum range: %s", mom)); +} diff --git a/PWG2/RESONANCES/AliRsnCutPIDNSigma.h b/PWG2/RESONANCES/AliRsnCutPIDNSigma.h new file mode 100644 index 00000000000..3d9ac637d48 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnCutPIDNSigma.h @@ -0,0 +1,108 @@ +#ifndef ALIRSNCUTPIDNSIGMA_H +#define ALIRSNCUTPIDNSIGMA_H + +// +// Class for generalized n-sigma PID cuts with detectors +// + +#include "AliPID.h" + +#include "AliRsnCut.h" + +class AliPIDResponse; + +class AliRsnCutPIDNSigma : public AliRsnCut { +public: + + enum EDetector { + kITS, + kTPC, + kTOF, + kDetectors + }; + + AliRsnCutPIDNSigma(const char *name = "cutPIDNsigma", AliPID::EParticleType species = AliPID::kUnknown, EDetector det = kDetectors, Double_t nsigma = 3.0); + AliRsnCutPIDNSigma(const AliRsnCutPIDNSigma& copy); + AliRsnCutPIDNSigma& operator=(const AliRsnCutPIDNSigma& copy); + virtual ~AliRsnCutPIDNSigma() { } + + void SetRejectOutside(Bool_t yn = kTRUE) {fRejectOutside = yn;} + void SetRejectUnmatched(Bool_t yn = kTRUE) {fRejectUnmatched = yn;} + void SetMomentumRange(Double_t min, Double_t max) {fMomMin = min; fMomMax = max;} + void SetNSigmaRange(Double_t min, Double_t max) {AliRsnCut::SetRangeD(min, max);} + void SetSpecies(AliPID::EParticleType type) {fSpecies = type;} + + Bool_t IsITS(); + Bool_t IsTPC(); + Bool_t IsTOF(); + + virtual Bool_t IsSelected(TObject *object); + virtual void Print(const Option_t *option = "") const; + +private: + + AliPID::EParticleType fSpecies; // particle species + EDetector fDetector; // detector used for PID + Double_t fMomMin; // momentum range (for ITS and TOF it is vertex momentum, for TPC it is inner wall) + Double_t fMomMax; // momentum range (for ITS and TOF it is vertex momentum, for TPC it is inner wall) + Bool_t fRejectOutside; // tracks outside momentum range do pass the cut? + Bool_t fRejectUnmatched; // tracks not matched to this detector do pass the cut? + + ClassDef(AliRsnCutPIDNSigma, 1) +}; + +inline Bool_t AliRsnCutPIDNSigma::IsITS() +{ +// +// Checks if the track has the status flags required for an ITS standalone track +// + + AliVTrack *vtrack = fDaughter->GetRefVtrack(); + + if (!vtrack) { + AliWarning("NULL argument: impossible to check status"); + return kFALSE; + } + + Bool_t isITSin = ((vtrack->GetStatus() & AliESDtrack::kTPCin) != 0); + Bool_t isITSpid = ((vtrack->GetStatus() & AliESDtrack::kITSpid) != 0); + + return (isITSin && isITSpid); +} + +inline Bool_t AliRsnCutPIDNSigma::IsTPC() +{ +// +// Checks if the track has the status flags required for a TPC track +// + + AliVTrack *vtrack = fDaughter->GetRefVtrack(); + + if (!vtrack) { + AliWarning("NULL argument: impossible to check status"); + return kFALSE; + } + + return ((vtrack->GetStatus() & AliESDtrack::kTPCin) != 0); +} + +inline Bool_t AliRsnCutPIDNSigma::IsTOF() +{ +// +// Checks if the track has the status flags required for an ITS standalone track +// + + AliVTrack *vtrack = fDaughter->GetRefVtrack(); + + if (!vtrack) { + AliWarning("NULL argument: impossible to check status"); + return kFALSE; + } + + Bool_t isTOFout = ((vtrack->GetStatus() & AliESDtrack::kTOFout) != 0); + Bool_t isTIME = ((vtrack->GetStatus() & AliESDtrack::kTIME) != 0); + + return (isTOFout && isTIME); +} + +#endif diff --git a/PWG2/RESONANCES/AliRsnCutPIDTOF.cxx b/PWG2/RESONANCES/AliRsnCutPIDTOF.cxx index caded4232b7..1e263f12c54 100644 --- a/PWG2/RESONANCES/AliRsnCutPIDTOF.cxx +++ b/PWG2/RESONANCES/AliRsnCutPIDTOF.cxx @@ -13,6 +13,10 @@ #include "AliAnalysisManager.h" #include "AliESDInputHandler.h" +#include "AliESDtrack.h" +#include "AliESDpid.h" +#include "AliAODTrack.h" +#include "AliAODpidUtil.h" #include "AliRsnCutPIDTOF.h" @@ -22,12 +26,11 @@ ClassImp(AliRsnCutPIDTOF) AliRsnCutPIDTOF::AliRsnCutPIDTOF (const char *name, AliPID::EParticleType ref, Double_t min, Double_t max, Bool_t rejectUnmatched) : AliRsnCut(name, AliRsnCut::kDaughter, min, max), - fInitialized(kFALSE), fRejectUnmatched(rejectUnmatched), fRefType(AliPID::kUnknown), fRefMass(0.0), - fESDpid(), - fAODpid() + fESDpid(0x0), + fAODpid(0x0) { // // Default constructor. @@ -41,7 +44,6 @@ AliRsnCutPIDTOF::AliRsnCutPIDTOF //_________________________________________________________________________________________________ AliRsnCutPIDTOF::AliRsnCutPIDTOF(const AliRsnCutPIDTOF& copy) : AliRsnCut(copy), - fInitialized(kFALSE), fRejectUnmatched(copy.fRejectUnmatched), fRefType(AliPID::kUnknown), fRefMass(0.0), @@ -66,7 +68,6 @@ AliRsnCutPIDTOF& AliRsnCutPIDTOF::operator=(const AliRsnCutPIDTOF& copy) // which sets the mass accordingly and coherently. // - fInitialized = kFALSE; fRejectUnmatched = copy.fRejectUnmatched; fESDpid = copy.fESDpid; fAODpid = copy.fAODpid; @@ -83,9 +84,6 @@ Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object) // Cut checker. // - // initialize if needed - if (!fInitialized) Initialize(); - // coherence check if (!TargetOK(object)) return kFALSE; @@ -103,7 +101,7 @@ Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object) // -- kFALSE --> all unmatched tracks are accepted (it is assumed that other PIDs are done) if (!IsMatched(vtrack)) { AliDebug(AliLog::kDebug + 2, "Track is not matched with TOF"); - return (!fRejectUnmatched); + if (fRejectUnmatched) return kFALSE; } // retrieve real object type and @@ -117,29 +115,26 @@ Bool_t AliRsnCutPIDTOF::IsSelected(TObject *object) if (esdTrack) { // setup the ESD PID object AliESDEvent *esd = 0x0; - if (fEvent) { - esd = fEvent->GetRefESD(); - if (!esd) { - AliError("Processing an ESD track, but target is not an ESD event"); - return kFALSE; - } - } else { - AliError("NULL event reference"); + if (fEvent) esd = fEvent->GetRefESD(); + if (!esd) { + AliError("Processing an ESD track, but target is not an ESD event"); return kFALSE; } - fESDpid.SetTOFResponse(esd, AliESDpid::kTOF_T0); + if (!fESDpid) fESDpid = new AliESDpid; + fESDpid->SetTOFResponse(esd, AliESDpid::kTOF_T0); // get time of flight, reference times and sigma esdTrack->GetIntegratedTimes(times); - tof = (Double_t)(esdTrack->GetTOFsignal() - fESDpid.GetTOFResponse().GetStartTime(esdTrack->P())); - sigma = (Double_t)fESDpid.GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass); + tof = (Double_t)(esdTrack->GetTOFsignal() - fESDpid->GetTOFResponse().GetStartTime(esdTrack->P())); + sigma = (Double_t)fESDpid->GetTOFResponse().GetExpectedSigma(esdTrack->P(), ref, fRefMass); // port values to standard AliRsnCut checker fCutValueD = (tof - ref) / sigma; return OkRangeD(); } else if (aodTrack) { // for AOD tracks, all operations are done by the AOD PID utility - fCutValueD = (Double_t)fAODpid.NumberOfSigmasTOF(aodTrack, fRefType); + if (!fAODpid) fAODpid = new AliAODpidUtil; + fCutValueD = (Double_t)fAODpid->NumberOfSigmasTOF(aodTrack, fRefType); return OkRangeD(); } else { AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName())); @@ -159,19 +154,3 @@ void AliRsnCutPIDTOF::Print(const Option_t *) const AliInfo(Form("Unmatched tracks are : %s", (fRejectUnmatched ? "rejected" : "accepted"))); } -//_________________________________________________________________________________________________ -void AliRsnCutPIDTOF::Initialize() -{ -// -// Initialize ESD pid object from global one -// - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliESDInputHandler *handler = dynamic_cast(mgr->GetInputEventHandler()); - if (handler) { - AliESDpid *pid = handler->GetESDpid(); - if (pid) fESDpid = (*pid); - } - - fInitialized = kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnCutPIDTOF.h b/PWG2/RESONANCES/AliRsnCutPIDTOF.h index 67dc986f54e..2811183384f 100644 --- a/PWG2/RESONANCES/AliRsnCutPIDTOF.h +++ b/PWG2/RESONANCES/AliRsnCutPIDTOF.h @@ -13,14 +13,8 @@ #define ALIRSNCUTPIDTOF_H #include "AliPID.h" - #include "AliVTrack.h" -#include "AliESDtrack.h" -#include "AliESDpid.h" -#include "AliAODTrack.h" -#include "AliAODpidUtil.h" -#include "AliRsnDaughter.h" #include "AliRsnCut.h" class AliRsnCutPIDTOF : public AliRsnCut { @@ -36,8 +30,8 @@ public: AliRsnCutPIDTOF& operator=(const AliRsnCutPIDTOF& copy); virtual ~AliRsnCutPIDTOF() { } - AliESDpid* ESDpid() {return &fESDpid;} - AliAODpidUtil* AODpid() {return &fAODpid;} + AliESDpid* ESDpid() {return fESDpid;} + AliAODpidUtil* AODpid() {return fAODpid;} void SetRejectUnmatched(Bool_t yn = kTRUE) {fRejectUnmatched = yn;} void SetNSigmaRange(Double_t min, Double_t max) {fMinD = min; fMaxD = max;} @@ -51,12 +45,11 @@ private: void Initialize(); - Bool_t fInitialized; // a mono-usage flag which initializes the ESD pid object Bool_t fRejectUnmatched; // decide if non TOF matched tracks pass the cut or not EPARTYPE fRefType; // particle type for which PID is checked Double_t fRefMass; // reference mass used for computations - AliESDpid fESDpid; // PID utility for ESD - AliAODpidUtil fAODpid; // PID utility for AOD + AliESDpid *fESDpid; //! PID utility for ESD + AliAODpidUtil *fAODpid; //! PID utility for AOD ClassDef(AliRsnCutPIDTOF, 1) }; diff --git a/PWG2/RESONANCES/AliRsnCutPIDTPC.cxx b/PWG2/RESONANCES/AliRsnCutPIDTPC.cxx index bac77175154..abcf06ee9dc 100644 --- a/PWG2/RESONANCES/AliRsnCutPIDTPC.cxx +++ b/PWG2/RESONANCES/AliRsnCutPIDTPC.cxx @@ -18,6 +18,9 @@ #include "AliAnalysisManager.h" #include "AliESDInputHandler.h" +#include "AliESDpid.h" +#include "AliAODpidUtil.h" + #include "AliRsnCutPIDTPC.h" ClassImp(AliRsnCutPIDTPC) @@ -26,13 +29,12 @@ ClassImp(AliRsnCutPIDTPC) AliRsnCutPIDTPC::AliRsnCutPIDTPC (const char *name, AliPID::EParticleType type, Double_t min, Double_t max, Bool_t rejectOutside) : AliRsnCut(name, AliRsnCut::kDaughter, min, max), - fInitialized(kFALSE), fRejectOutside(rejectOutside), fMomMin(0.0), fMomMax(1E+20), fRefType(type), - fESDpid(), - fAODpid() + fESDpid(0x0), + fAODpid(0x0) { // // Main constructor. @@ -43,7 +45,6 @@ AliRsnCutPIDTPC::AliRsnCutPIDTPC AliRsnCutPIDTPC::AliRsnCutPIDTPC (const AliRsnCutPIDTPC& copy) : AliRsnCut(copy), - fInitialized(kFALSE), fRejectOutside(copy.fRejectOutside), fMomMin(copy.fMomMin), fMomMax(copy.fMomMax), @@ -65,7 +66,6 @@ AliRsnCutPIDTPC& AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC& copy) AliRsnCut::operator=(copy); - fInitialized = kFALSE; fRejectOutside = copy.fRejectOutside; fMomMin = copy.fMomMin; fMomMax = copy.fMomMax; @@ -83,8 +83,11 @@ void AliRsnCutPIDTPC::SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t // Properly set the Bethe-Bloch parameters in all places where it is needed. // - fESDpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4); - fAODpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4); + fBB[0] = p0; + fBB[1] = p1; + fBB[2] = p2; + fBB[3] = p3; + fBB[4] = p4; } //_________________________________________________________________________________________________ @@ -94,41 +97,49 @@ Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object) // Cut checker. // - // initialize if needed - if (!fInitialized) Initialize(); - // coherence check if (!TargetOK(object)) return kFALSE; - // reject not TPC tracks - AliVTrack *vtrack = fDaughter->GetRefVtrack(); - if (!vtrack) return kFALSE; - if (!IsTPC(vtrack)) { - AliDebug(AliLog::kDebug + 2, "Track is not found in TPC"); - return kFALSE; - } - // common evaluation variables Double_t mom; AliESDtrack *esdTrack = fDaughter->GetRefESDtrack(); AliAODTrack *aodTrack = fDaughter->GetRefAODtrack(); // get inner momentum, needed for BB computation - if (esdTrack) + if (esdTrack) { + if (!esdTrack->GetInnerParam()) { + AliDebug(AliLog::kDebug + 2, "No inner param"); + return kFALSE; + } mom = esdTrack->GetInnerParam()->P(); - else if (aodTrack) + } else if (aodTrack) { + if (!aodTrack->GetDetPid()) { + AliDebug(AliLog::kDebug + 2, "No def-pid object"); + return kFALSE; + } mom = aodTrack->GetDetPid()->GetTPCmomentum(); - else { + if (mom < 1E-6) return kFALSE; + } else { AliDebug(AliLog::kDebug + 2, Form("Impossible to process an object of type '%s'. Cut applicable only to ESD/AOD tracks", fDaughter->GetRef()->ClassName())); return kFALSE; } // assign PID nsigmas to default cut check value // since bad object types are rejected before, here we have an ESD track or AOD track - if (esdTrack) - fCutValueD = fESDpid.GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType); - else - fCutValueD = fAODpid.NumberOfSigmasTPC(aodTrack, fRefType); + if (esdTrack) { + if (!fESDpid) { + fESDpid = new AliESDpid; + fESDpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]); + } + fCutValueD = fESDpid->GetTPCResponse().GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fRefType); + } else { + if (!fAODpid) { + fAODpid = new AliAODpidUtil; + fAODpid->GetTPCResponse().SetBetheBlochParameters(fBB[0], fBB[1], fBB[2], fBB[3], fBB[4]); + } + if (aodTrack->GetTPCsignalN() == 0) aodTrack->GetDetPid()->SetTPCsignalN(aodTrack->GetTPCNcls()); + fCutValueD = fAODpid->NumberOfSigmasTPC(aodTrack, fRefType); + } // use AliRsnCut default method to check cut Bool_t cutCheck = OkRangeD(); @@ -159,20 +170,3 @@ void AliRsnCutPIDTPC::Print(const Option_t *) const AliInfo(Form("--> momentum range : %.3f %.3f", fMomMin, fMomMax)); AliInfo(Form("--> tracks outside range are: %s", (fRejectOutside ? "rejected" : "accepted"))); } - -//_________________________________________________________________________________________________ -void AliRsnCutPIDTPC::Initialize() -{ -// -// Initialize ESD pid object from global one -// - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliESDInputHandler *handler = dynamic_cast(mgr->GetInputEventHandler()); - if (handler) { - AliESDpid *pid = handler->GetESDpid(); - if (pid) fESDpid = (*pid); - } - - fInitialized = kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnCutPIDTPC.h b/PWG2/RESONANCES/AliRsnCutPIDTPC.h index 1adf97064ae..395cd8f7016 100644 --- a/PWG2/RESONANCES/AliRsnCutPIDTPC.h +++ b/PWG2/RESONANCES/AliRsnCutPIDTPC.h @@ -15,15 +15,11 @@ #include "AliPID.h" -#include "AliESDtrack.h" -#include "AliESDtrackCuts.h" -#include "AliESDpid.h" - -#include "AliAODpidUtil.h" - -#include "AliRsnDaughter.h" #include "AliRsnCut.h" +class AliESDpid; +class AliAODpidUtil; + class AliRsnCutPIDTPC : public AliRsnCut { public: @@ -37,8 +33,8 @@ public: AliRsnCutPIDTPC& operator=(const AliRsnCutPIDTPC& copy); virtual ~AliRsnCutPIDTPC() { } - AliESDpid* ESDpid() {return &fESDpid;} - AliAODpidUtil* AODpid() {return &fAODpid;} + AliESDpid* ESDpid() {return fESDpid;} + AliAODpidUtil* AODpid() {return fAODpid;} void SetRejectOutside(Bool_t yn = kTRUE) {fRejectOutside = yn;} void SetMomentumRange(Double_t min, Double_t max) {fMomMin = min; fMomMax = max;} @@ -47,43 +43,21 @@ public: void SetBBParam(Double_t *p) {SetBBParam(p[0], p[1], p[2], p[3], p[4]);} void SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4); - Bool_t IsTPC(AliVTrack *vtrack); virtual Bool_t IsSelected(TObject *object); virtual void Print(const Option_t *option = "") const; private: - void Initialize(); - - Bool_t fInitialized; // a mono-usage flag which initializes the ESD pid object - Bool_t fRejectOutside; // choose if tracks outside momentum range are rejected or not - Double_t fMomMin; // min p in range where this cut is checked - Double_t fMomMax; // max p in range where this cut is checked - EPARTYPE fRefType; // particle type for which PID is checked - AliESDpid fESDpid; // ESD PID object - AliAODpidUtil fAODpid; // AOD PID object + Bool_t fRejectOutside; // choose if tracks outside momentum range are rejected or not + Double_t fMomMin; // min p in range where this cut is checked + Double_t fMomMax; // max p in range where this cut is checked + EPARTYPE fRefType; // particle type for which PID is checked + AliESDpid *fESDpid; //! ESD PID object + AliAODpidUtil *fAODpid; //! AOD PID object + Double_t fBB[5]; // Bethe-Bloch parameters + ClassDef(AliRsnCutPIDTPC, 1) }; -inline Bool_t AliRsnCutPIDTPC::IsTPC(AliVTrack *vtrack) -{ -// -// Checks if the track has the status flags required for a global track -// - - if (!vtrack) { - AliWarning("NULL argument: impossible to check status"); - return kFALSE; - } - - Bool_t isTPCin = ((vtrack->GetStatus() & AliESDtrack::kTPCin) != 0); - Bool_t isITSrefit = ((vtrack->GetStatus() & AliESDtrack::kITSrefit) != 0); - Bool_t isITSpid = ((vtrack->GetStatus() & AliESDtrack::kITSpid) != 0); - - return (isTPCin && isITSrefit && isITSpid); - - return kTRUE; -} - #endif diff --git a/PWG2/RESONANCES/AliRsnCutTrackQuality.cxx b/PWG2/RESONANCES/AliRsnCutTrackQuality.cxx index 7b0d6bef1f0..39ec86569a6 100644 --- a/PWG2/RESONANCES/AliRsnCutTrackQuality.cxx +++ b/PWG2/RESONANCES/AliRsnCutTrackQuality.cxx @@ -287,12 +287,17 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track) } // step #4: DCA cut (transverse) + // --> reject all tracks not ITS refitted Double_t b[2], cov[3]; vertex = aodEvent->GetPrimaryVertex(); if (!vertex) { AliDebug(AliLog::kDebug + 2, "NULL vertex"); return kFALSE; } + if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) { + AliDebug(AliLog::kDebug + 2, "Not ITS refitted"); + return kFALSE; + } if (!track->PropagateToDCA(vertex, aodEvent->GetMagneticField(), kVeryBig, b, cov)) { AliDebug(AliLog::kDebug + 2, "Failed propagation to vertex"); return kFALSE; @@ -336,6 +341,7 @@ Bool_t AliRsnCutTrackQuality::CheckAOD(AliAODTrack *track) } // if we are here, all cuts were passed and no exit point was got + AliDebug(AliLog::kDebug + 2, "============================= ACCEPTED TRACK ====================================================="); return kTRUE; } diff --git a/PWG2/RESONANCES/AliRsnCutValue.cxx b/PWG2/RESONANCES/AliRsnCutValue.cxx index a7d940001f1..8210ab1ce81 100644 --- a/PWG2/RESONANCES/AliRsnCutValue.cxx +++ b/PWG2/RESONANCES/AliRsnCutValue.cxx @@ -27,7 +27,8 @@ ClassImp(AliRsnCutValue) //_________________________________________________________________________________________________ AliRsnCutValue::AliRsnCutValue() : AliRsnCut(), - fValue() + fUseMC(kFALSE), + fValue(0x0) { // // Default constructor. @@ -36,9 +37,10 @@ AliRsnCutValue::AliRsnCutValue() : //_________________________________________________________________________________________________ AliRsnCutValue::AliRsnCutValue -(const char *name, AliRsnValue::EValueType type, Double_t min, Double_t max) : - AliRsnCut(name, AliRsnValue::TargetType(type), min, max), - fValue(Form("val_%s", name), type) +(const char *name, Double_t min, Double_t max, Bool_t useMC) : + AliRsnCut(name, AliRsnTarget::kTargetTypes, min, max), + fUseMC(useMC), + fValue(0x0) { // // Main constructor. @@ -51,6 +53,7 @@ AliRsnCutValue::AliRsnCutValue //_________________________________________________________________________________________________ AliRsnCutValue::AliRsnCutValue(const AliRsnCutValue& copy) : AliRsnCut(copy), + fUseMC(copy.fUseMC), fValue(copy.fValue) { // @@ -68,6 +71,7 @@ AliRsnCutValue& AliRsnCutValue::operator=(const AliRsnCutValue& copy) // AliRsnCut::operator=(copy); + fUseMC = copy.fUseMC; fValue = copy.fValue; return (*this); @@ -81,8 +85,14 @@ Bool_t AliRsnCutValue::IsSelected(TObject *object) // Calls the AliRsnValue::Eval() method and then checks its output. // + // skip cut if value is not initialized + if (!fValue) return kTRUE; + + // match target types + SetTargetType(fValue->GetTargetType()); + // try to compute values - Bool_t success = fValue.Eval(object); + Bool_t success = fValue->Eval(object, fUseMC); // check success if (!success) { @@ -91,7 +101,7 @@ Bool_t AliRsnCutValue::IsSelected(TObject *object) } // check in range - fCutValueD = fValue.GetComputedValue(); + fCutValueD = fValue->GetComputedValue(); return OkRangeD(); } @@ -103,6 +113,6 @@ void AliRsnCutValue::Print(const Option_t *) const // AliInfo(Form("Cut name : %s", GetName())); - AliInfo(Form("Cut value : %s", fValue.GetValueTypeName())); + AliInfo(Form("Cut value : %s", fValue->GetName())); AliInfo(Form("Cut range : %f - %f", fMinD, fMaxD)); } diff --git a/PWG2/RESONANCES/AliRsnCutValue.h b/PWG2/RESONANCES/AliRsnCutValue.h index 4a72f64771b..bdb388181fa 100644 --- a/PWG2/RESONANCES/AliRsnCutValue.h +++ b/PWG2/RESONANCES/AliRsnCutValue.h @@ -25,20 +25,24 @@ class AliRsnCutValue : public AliRsnCut { public: AliRsnCutValue(); - AliRsnCutValue(const char *name, AliRsnValue::EValueType type, Double_t min, Double_t max); + AliRsnCutValue(const char *name, Double_t min, Double_t max, Bool_t isMC); AliRsnCutValue(const AliRsnCutValue& copy); AliRsnCutValue& operator=(const AliRsnCutValue& copy); virtual ~AliRsnCutValue() { } - Double_t GetComputedValue() {return fValue.GetComputedValue();} - AliRsnValue* GetValueObj() {return &fValue;} + Double_t GetComputedValue() {if (fValue) return fValue->GetComputedValue(); return -1E20;} + AliRsnValue* GetValueObj() {return fValue;} + void SetValueObj(AliRsnValue *value) {fValue = value; SetTargetType(value->GetTargetType());} + Bool_t IsUsingMC() {return fUseMC;} + void UseMC(Bool_t yn = kTRUE) {fUseMC = yn;} virtual Bool_t IsSelected(TObject *object); virtual void Print(const Option_t *option = "") const; protected: - AliRsnValue fValue; + Bool_t fUseMC; + AliRsnValue *fValue; ClassDef(AliRsnCutValue, 1) }; diff --git a/PWG2/RESONANCES/AliRsnDaughter.h b/PWG2/RESONANCES/AliRsnDaughter.h index e66d228c1d4..a134ca16079 100644 --- a/PWG2/RESONANCES/AliRsnDaughter.h +++ b/PWG2/RESONANCES/AliRsnDaughter.h @@ -81,9 +81,9 @@ public: Int_t GetPDG(Bool_t abs = kTRUE); Int_t GetID(); Bool_t IsKinkDaughter(); - Bool_t IsPos() const {return (fRef->Charge() > 0);} - Bool_t IsNeg() const {return (fRef->Charge() < 0);} - Bool_t IsNeutral() const {return (!IsPos() && !IsNeg());} + Bool_t IsPos() const {if (fRef) return (fRef->Charge() > 0); return kFALSE;} + Bool_t IsNeg() const {if (fRef) return (fRef->Charge() < 0); return kFALSE;} + Bool_t IsNeutral() const {if (fRef) return (!IsPos() && !IsNeg()); return kFALSE;} Bool_t IsSign(Char_t sign) const {if (sign == '+') return IsPos(); else if (sign == '-') return IsNeg(); else return IsNeutral();} Short_t ChargeS() const {if (IsPos()) return 1 ; else if (IsNeg()) return -1 ; else return 0 ;} Char_t ChargeC() const {if (IsPos()) return '+'; else if (IsNeg()) return '-'; else return '0';} diff --git a/PWG2/RESONANCES/AliRsnDaughterDef.cxx b/PWG2/RESONANCES/AliRsnDaughterDef.cxx index d4edc8e3544..8bb83690cc3 100644 --- a/PWG2/RESONANCES/AliRsnDaughterDef.cxx +++ b/PWG2/RESONANCES/AliRsnDaughterDef.cxx @@ -40,6 +40,7 @@ ClassImp(AliRsnDaughterDef) //_____________________________________________________________________________ AliRsnDaughterDef::AliRsnDaughterDef() : + fOnlyTrue(kFALSE), fPID(AliRsnDaughter::kUnknown), fMass(0.0), fCharge(0), @@ -53,6 +54,7 @@ AliRsnDaughterDef::AliRsnDaughterDef() : //_____________________________________________________________________________ AliRsnDaughterDef::AliRsnDaughterDef(AliRsnDaughter::ESpecies type, Char_t sign) : + fOnlyTrue(kFALSE), fPID(type), fMass(AliRsnDaughter::SpeciesMass(type)), fCharge(sign), @@ -67,6 +69,7 @@ AliRsnDaughterDef::AliRsnDaughterDef(AliRsnDaughter::ESpecies type, Char_t sign) //_____________________________________________________________________________ AliRsnDaughterDef::AliRsnDaughterDef(EPARTYPE type, Char_t sign) : + fOnlyTrue(kFALSE), fPID(AliRsnDaughter::FromAliPID(type)), fMass(AliRsnDaughter::SpeciesMass(AliRsnDaughter::FromAliPID(type))), fCharge(sign), @@ -81,6 +84,7 @@ AliRsnDaughterDef::AliRsnDaughterDef(EPARTYPE type, Char_t sign) : //_____________________________________________________________________________ AliRsnDaughterDef::AliRsnDaughterDef(AliRsnDaughter::ERefType refType, Char_t sign) : + fOnlyTrue(kFALSE), fPID(AliRsnDaughter::kUnknown), fMass(0.0), fCharge(sign), @@ -100,6 +104,7 @@ AliRsnDaughterDef::AliRsnDaughterDef(AliRsnDaughter::ERefType refType, Char_t si //_____________________________________________________________________________ AliRsnDaughterDef::AliRsnDaughterDef(const AliRsnDaughterDef ©) : TObject(copy), + fOnlyTrue(copy.fOnlyTrue), fPID(copy.fPID), fMass(copy.fMass), fCharge(copy.fCharge), @@ -117,6 +122,7 @@ const AliRsnDaughterDef& AliRsnDaughterDef::operator=(const AliRsnDaughterDef &c // Assignment operator has standard behavior. // + fOnlyTrue = copy.fOnlyTrue; fMass = copy.fMass; fCharge = copy.fCharge; fPID = copy.fPID; @@ -126,7 +132,7 @@ const AliRsnDaughterDef& AliRsnDaughterDef::operator=(const AliRsnDaughterDef &c } //_____________________________________________________________________________ -Bool_t AliRsnDaughterDef::MatchesDaughter(AliRsnDaughter *checked, Bool_t truePID) +Bool_t AliRsnDaughterDef::MatchesDaughter(AliRsnDaughter *checked) { // // Checks if the argument matches the definitions, by combining the other @@ -138,7 +144,7 @@ Bool_t AliRsnDaughterDef::MatchesDaughter(AliRsnDaughter *checked, Bool_t truePI Bool_t chargeMatch = MatchesCharge(checked); Bool_t objMatch = MatchesRefType(checked); - Bool_t pidMatch = (truePID ? MatchesPID(checked) : kTRUE); + Bool_t pidMatch = (fOnlyTrue ? MatchesPID(checked) : kTRUE); // return the AND of all return (chargeMatch && objMatch && pidMatch); diff --git a/PWG2/RESONANCES/AliRsnDaughterDef.h b/PWG2/RESONANCES/AliRsnDaughterDef.h index 669bd1472ba..5fc9e8077d3 100644 --- a/PWG2/RESONANCES/AliRsnDaughterDef.h +++ b/PWG2/RESONANCES/AliRsnDaughterDef.h @@ -23,35 +23,35 @@ public: const AliRsnDaughterDef& operator= (const AliRsnDaughterDef ©); virtual ~AliRsnDaughterDef() { } - // getters - Double_t GetMass() const {return fMass;} - Char_t GetChargeC() const {return fCharge;} - Short_t GetChargeS() const {if (fCharge == '+') return 1; else if (fCharge == '-') return -1; else return 0;} - AliRsnDaughter::ESpecies GetPID() const {return fPID;} - AliRsnDaughter::ERefType GetRefType() const {return fRefType;} - virtual const char* GetName() const {return Form("%s%c", AliRsnDaughter::SpeciesName(fPID), fCharge);} - - // setters - void SetPID(AliRsnDaughter::ESpecies pid = AliRsnDaughter::kUnknown) {fPID = pid; fRefType = AliRsnDaughter::RefType(pid); fMass = AliRsnDaughter::SpeciesMass(pid);} - void SetCharge(Char_t charge = 0) {fCharge = charge;} - void SetRefType(AliRsnDaughter::ERefType type = AliRsnDaughter::kNoType) {fRefType = type;} + Bool_t IsOnlyTrue() const {return fOnlyTrue;} + AliRsnDaughter::ESpecies GetPID() const {return fPID;} + Double_t GetMass() const {return fMass;} + Char_t GetChargeC() const {return fCharge;} + Short_t GetChargeS() const {if (fCharge == '+') return 1; else if (fCharge == '-') return -1; else return 0;} + AliRsnDaughter::ERefType GetRefType() const {return fRefType;} + virtual const char* GetName() const {return Form("%s%c", AliRsnDaughter::SpeciesName(fPID), fCharge);} + Bool_t IsChargeDefined() const {return (fCharge == '+' || fCharge == '-' || fCharge == '0');} + + void SetOnlyTrue(Bool_t yn = kTRUE) {fOnlyTrue = yn;} + void SetPID(AliRsnDaughter::ESpecies pid) {fPID = pid; fRefType = AliRsnDaughter::RefType(pid); fMass = AliRsnDaughter::SpeciesMass(pid);} + void SetCharge(Char_t charge) {fCharge = charge;} + void SetRefType(AliRsnDaughter::ERefType type) {fRefType = type;} - // checker Bool_t MatchesPID(AliRsnDaughter *daughter); Bool_t MatchesCharge(AliRsnDaughter *daughter); Bool_t MatchesRefType(AliRsnDaughter *daughter); - Bool_t MatchesDaughter(AliRsnDaughter *daughter, Bool_t truePID = kFALSE); - - // external checker - Bool_t MatchesPDG(Int_t pdgCode) {return (AliRsnDaughter::SpeciesPDG(fPID) == pdgCode);} - Bool_t MatchesCharge(Short_t charge) {return (GetChargeS() == charge);} + Bool_t MatchesDaughter(AliRsnDaughter *daughter); + Bool_t MatchesPDG(Int_t pdgCode) {return (AliRsnDaughter::SpeciesPDG(fPID) == pdgCode);} + Bool_t MatchesChargeS(Short_t charge) {return (GetChargeS() == charge);} + Bool_t MatchesChargeC(Char_t charge) {return (GetChargeC() == charge);} private: - AliRsnDaughter::ESpecies fPID; // PID of particles - Double_t fMass; // mass of particles (subordinate to fPID) - Char_t fCharge; // charge of particles - AliRsnDaughter::ERefType fRefType; // object reference type (track/V0/cascade) + Bool_t fOnlyTrue; // fag to activate comparison of PID species + AliRsnDaughter::ESpecies fPID; // PID of particles + Double_t fMass; // mass of particles (subordinate to fPID) + Char_t fCharge; // charge of particles + AliRsnDaughter::ERefType fRefType; // object reference type (track/V0/cascade) // ROOT dictionary ClassDef(AliRsnDaughterDef, 1) diff --git a/PWG2/RESONANCES/AliRsnDaughterSelector.cxx b/PWG2/RESONANCES/AliRsnDaughterSelector.cxx new file mode 100644 index 00000000000..1f8808f7e50 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnDaughterSelector.cxx @@ -0,0 +1,286 @@ +#include +#include + +#include "AliLog.h" + +#include "AliRsnCutSet.h" +#include "AliRsnDaughterDef.h" + +#include "AliRsnDaughterSelector.h" + +ClassImp(AliRsnDaughterSelector) + +//__________________________________________________________________________________________________ +AliRsnDaughterSelector::AliRsnDaughterSelector(const char *name, const char *title) : + TNamed(name, title), + fCutSetsN("AliRsnCutSet", 0), + fCutSetsC("AliRsnCutSet", 0), + fEntryListsN("TEntryList", 0), + fEntryListsP("TEntryList", 0), + fEntryListsM("TEntryList", 0) +{ +// +// Default constructor. +// + + AliDebug(AliLog::kDebug + 10, "<-"); + AliDebug(AliLog::kDebug + 10, "->"); +} + +//__________________________________________________________________________________________________ +AliRsnDaughterSelector::AliRsnDaughterSelector(const AliRsnDaughterSelector& copy) : + TNamed(copy), + fCutSetsN(copy.fCutSetsN), + fCutSetsC(copy.fCutSetsC), + fEntryListsN(copy.fEntryListsN), + fEntryListsP(copy.fEntryListsP), + fEntryListsM(copy.fEntryListsM) +{ +// +// Copy constructor. +// + + AliDebug(AliLog::kDebug + 10, "<-"); + AliDebug(AliLog::kDebug + 10, "->"); +} + +//__________________________________________________________________________________________________ +AliRsnDaughterSelector& AliRsnDaughterSelector::operator=(const AliRsnDaughterSelector& copy) +{ +// +// Copy constructor. +// + + AliDebug(AliLog::kDebug + 10, "<-"); + + TNamed::operator=(copy); + + fCutSetsN = copy.fCutSetsN; + fCutSetsC = copy.fCutSetsC; + fEntryListsN = copy.fEntryListsN; + fEntryListsP = copy.fEntryListsP; + fEntryListsM = copy.fEntryListsM; + + AliDebug(AliLog::kDebug + 10, "->"); + + return (*this); +} + +//__________________________________________________________________________________________________ +AliRsnDaughterSelector::~AliRsnDaughterSelector() +{ +// +// Destructor +// + + AliDebug(AliLog::kDebug + 10, "<-"); + + fCutSetsN.Delete(); + fCutSetsC.Delete(); + fEntryListsN.Delete(); + fEntryListsP.Delete(); + fEntryListsM.Delete(); + + AliDebug(AliLog::kDebug + 10, "->"); +} + +//__________________________________________________________________________________________________ +void AliRsnDaughterSelector::Print(Option_t* option) const +{ +// +// Override TObject::Print() +// + + TNamed::Print(option); + + Int_t i, nSets; + AliRsnCutSet *set = 0x0; + TEntryList *list = 0x0; + + // neutral + nSets = fCutSetsN.GetEntries(); + for (i = 0; i < nSets; i++) { + set = (AliRsnCutSet*)fCutSetsN[i]; + list = (TEntryList*)fEntryListsN[i]; + AliInfo(Form("Neutral entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN())); + } + + // charged + nSets = fCutSetsC.GetEntries(); + for (i = 0; i < nSets; i++) { + set = (AliRsnCutSet*)fCutSetsC[i]; + list = (TEntryList*)fEntryListsP[i]; + AliInfo(Form("Positive entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN())); + list = (TEntryList*)fEntryListsM[i]; + AliInfo(Form("Negative entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN())); + } +} + +//__________________________________________________________________________________________________ +void AliRsnDaughterSelector::Init() +{ +// +// Initialize the arrays of entry lists to the same size +// of the corresponding arrays of cut sets. +// If they are not empty, they are cleared. +// + + Int_t i, nSets; + + // neutral + nSets = fCutSetsN.GetEntries(); + if (!fEntryListsN.IsEmpty()) fEntryListsN.Delete(); + for (i = 0; i < nSets; i++) { + AliRsnCutSet *set = (AliRsnCutSet*)fCutSetsN[i]; + new (fEntryListsN[i]) TEntryList; + AliInfo(Form("Adding 1 entry list for neutrals --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data())); + } + + // charged + nSets = fCutSetsC.GetEntries(); + if (!fEntryListsP.IsEmpty()) fEntryListsP.Delete(); + if (!fEntryListsM.IsEmpty()) fEntryListsM.Delete(); + for (i = 0; i < nSets; i++) { + AliRsnCutSet *set = (AliRsnCutSet*)fCutSetsC[i]; + new (fEntryListsP[i]) TEntryList; + new (fEntryListsM[i]) TEntryList; + AliInfo(Form("Adding 2 entry lists for charged --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data())); + } +} + +//__________________________________________________________________________________________________ +void AliRsnDaughterSelector::Reset() +{ + TEntryList *el; + Int_t i, nSets; + + // N + nSets = fCutSetsN.GetEntries(); + for (i = 0; i < nSets; i++) { + el = (TEntryList*)fEntryListsN.At(i); + el->Reset(); + } + + // charged + nSets = fCutSetsC.GetEntries(); + for (i = 0; i < nSets; i++) { + el = (TEntryList*)fEntryListsP.At(i); + el->Reset(); + el = (TEntryList*)fEntryListsM.At(i); + el->Reset(); + } +} + +//__________________________________________________________________________________________________ +Int_t AliRsnDaughterSelector::Add(AliRsnCutSet *cuts, Bool_t charged) +{ +// +// Add a new selection slot defined by a set of cuts and daughter definition +// + + Int_t n = 0; + + if (!charged) { + n = fCutSetsN.GetEntries(); + new (fCutSetsN[n]) AliRsnCutSet(*cuts); + } else { + n = fCutSetsC.GetEntries(); + new (fCutSetsC[n]) AliRsnCutSet(*cuts); + } + + return n; +} + +//__________________________________________________________________________________________________ +Int_t AliRsnDaughterSelector::GetID(const char *name, Bool_t charged) +{ +// +// Add a new selection slot defined by a set of cuts and daughter definition +// + + AliRsnCutSet *cuts; + + if (!charged) { + cuts = (AliRsnCutSet*)fCutSetsN.FindObject(name); + if (cuts) return fCutSetsN.IndexOf(cuts); + } else { + cuts = (AliRsnCutSet*)fCutSetsC.FindObject(name); + if (cuts) return fCutSetsC.IndexOf(cuts); + } + + return -1; +} + +//__________________________________________________________________________________________________ +TEntryList* AliRsnDaughterSelector::GetSelected(Int_t i, Char_t charge) +{ +// +// Retrieve a given entry list (needs charge specified as a char) +// + + if (charge == '+') + return (TEntryList*)fEntryListsP.At(i); + else if (charge == '-') + return (TEntryList*)fEntryListsM.At(i); + else + return (TEntryList*)fEntryListsN.At(i); +} + +//__________________________________________________________________________________________________ +TEntryList* AliRsnDaughterSelector::GetSelected(Int_t i, Short_t charge) +{ +// +// Retrieve a given entry list passing charge as short +// + + if (charge > 0) + return (TEntryList*)fEntryListsP.At(i); + else if (charge < 0) + return (TEntryList*)fEntryListsM.At(i); + else + return (TEntryList*)fEntryListsN.At(i); +} + +//__________________________________________________________________________________________________ +void AliRsnDaughterSelector::ScanEvent(AliRsnEvent* ev) +{ +// +// Loop over event and fill all entry lists +// + + Int_t id, is; + Int_t nSel, nTot = ev->GetAbsoluteSum(); + AliRsnDaughter check; + TClonesArray *cutsArray = 0x0, *entryArray = 0x0; + + for (id = 0; id < nTot; id++) { + ev->SetDaughterAbs(check, id); + if (!check.IsOK()) continue; + // set pointers according to charge + switch (check.ChargeS()) { + case 1: + cutsArray = &fCutSetsC; + entryArray = &fEntryListsP; + break; + case -1: + cutsArray = &fCutSetsC; + entryArray = &fEntryListsM; + break; + default: + cutsArray = &fCutSetsN; + entryArray = &fEntryListsN; + break; + } + // check with all cuts in that charge + nSel = cutsArray->GetEntriesFast(); + for (is = 0; is < nSel; is++) { + AliRsnCutSet *cuts = (AliRsnCutSet*)cutsArray->At(is); + if (cuts->IsSelected(&check)) { + TEntryList *el = (TEntryList*)entryArray->At(is); + el->Enter(id); + } + } + } + + //Print(); +} diff --git a/PWG2/RESONANCES/AliRsnDaughterSelector.h b/PWG2/RESONANCES/AliRsnDaughterSelector.h new file mode 100644 index 00000000000..e8cc8ad1a2e --- /dev/null +++ b/PWG2/RESONANCES/AliRsnDaughterSelector.h @@ -0,0 +1,43 @@ +#ifndef ALIRSNDAUGHTERSELECTOR_H +#define ALIRSNDAUGHTERSELECTOR_H + +#include +#include + +class TEntryList; + +class AliRsnCutSet; +class AliRsnEvent; + +class AliRsnDaughterSelector : public TNamed { + +public: + + AliRsnDaughterSelector(const char *name = "name", const char *title = "title"); + AliRsnDaughterSelector(const AliRsnDaughterSelector& copy); + AliRsnDaughterSelector &operator=(const AliRsnDaughterSelector ©); + virtual ~AliRsnDaughterSelector(); + + void Init(); + void Reset(); + Int_t Add(AliRsnCutSet *cuts, Bool_t charged); + Int_t GetID(const char *cutSetName, Bool_t charged); + TEntryList* GetSelected(Int_t i, Char_t charge); + TEntryList* GetSelected(Int_t i, Short_t charge); + void ScanEvent(AliRsnEvent *ev); + + virtual void Print(Option_t* option = "") const; + +private: + + TClonesArray fCutSetsN; // cuts for neutral daughters + TClonesArray fCutSetsC; // cuts for charged daughters (usually, the same) + + TClonesArray fEntryListsN; // entry lists for neutrals + TClonesArray fEntryListsP; // entry lists for charged (one per sign) + TClonesArray fEntryListsM; // entry lists for charged (one per sign) + + ClassDef(AliRsnDaughterSelector, 1) +}; + +#endif diff --git a/PWG2/RESONANCES/AliRsnEvent.cxx b/PWG2/RESONANCES/AliRsnEvent.cxx index 13092f8c0b4..8a86555b886 100644 --- a/PWG2/RESONANCES/AliRsnEvent.cxx +++ b/PWG2/RESONANCES/AliRsnEvent.cxx @@ -37,6 +37,7 @@ #include "AliGenEventHeader.h" #include "AliESDtrackCuts.h" #include "AliESDUtils.h" +#include "AliAODVertex.h" #include "AliMultiplicity.h" #include "AliRsnCutPID.h" #include "AliRsnEvent.h" @@ -48,7 +49,8 @@ AliRsnEvent::AliRsnEvent(AliVEvent *ref, AliVEvent *refMC) : fRef(ref), fRefMC(refMC), fLeading(-1), - fLocalID(-1) + fLocalID(-1), + fPID(0x0) { // // Default constructor. @@ -61,7 +63,8 @@ AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) : fRef(event.fRef), fRefMC(event.fRefMC), fLeading(event.fLeading), - fLocalID(event.fLocalID) + fLocalID(event.fLocalID), + fPID(event.fPID) { // // Copy constructor. @@ -80,6 +83,7 @@ AliRsnEvent& AliRsnEvent::operator= (const AliRsnEvent & event) fRefMC = event.fRefMC; fLeading = event.fLeading; fLocalID = event.fLocalID; + fPID = event.fPID; return (*this); } @@ -139,8 +143,9 @@ Bool_t AliRsnEvent::SetDaughterAbs(AliRsnDaughter &out, Int_t absIndex) out.SetRsnID(absIndex); - if (ConvertAbsoluteIndex(absIndex, index, type)) + if (ConvertAbsoluteIndex(absIndex, index, type)) { return SetDaughter(out, index, type); + } else { out.Reset(); return kFALSE; @@ -261,23 +266,6 @@ AliRsnDaughter AliRsnEvent::GetDaughterMC(Int_t i) return d; } -//_____________________________________________________________________________ -Int_t AliRsnEvent::GetAbsoluteSum() -{ -// -// Utility method that returns the sum of all daughter-like objects: -// tracks, V0s and cascades -// - - Int_t total = 0; - - total += fRef->GetNumberOfTracks(); - total += fRef->GetNumberOfV0s(); - total += fRef->GetNumberOfCascades(); - - return total; -} - //_____________________________________________________________________________ Bool_t AliRsnEvent::ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type) { @@ -639,12 +627,10 @@ Bool_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) out.SetRef(v0); out.SetGood(); out.SetLabel(-1); - - // this time, assigning label is not trivial, - // it is done only if MC is present and both - // daughters come from a true particle - AliAODTrack *tp = ev->GetTrack(v0->GetPosID()); - AliAODTrack *tn = ev->GetTrack(v0->GetNegID()); + + // retrieve the owner vertex and its daughters + AliAODTrack *tp = (AliAODTrack*)v0->GetDaughter(0); + AliAODTrack *tn = (AliAODTrack*)v0->GetDaughter(1); if (mcArray && tp && tn) { Int_t lp = TMath::Abs(tp->GetLabel()); Int_t ln = TMath::Abs(tn->GetLabel()); @@ -657,7 +643,8 @@ Bool_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) if (TMath::Abs(part->GetLabel()) == ln) pn = part; } // assign a MC reference and a label only to true V0s - if (pp->GetMother() == pn->GetMother() && pp->GetMother() >= 0) out.SetLabel(pp->GetMother()); + if (pp && pn) + if (pp->GetMother() == pn->GetMother() && pp->GetMother() >= 0) out.SetLabel(pp->GetMother()); } // assign MC info, if available @@ -665,7 +652,7 @@ Bool_t AliRsnEvent::SetDaughterAODv0(AliRsnDaughter &out, Int_t i) } //_____________________________________________________________________________ -Bool_t AliRsnEvent::SetDaughterESDcascade(AliRsnDaughter &, Int_t) +Bool_t AliRsnEvent::SetDaughterESDcascade(AliRsnDaughter &out, Int_t i) { // // Setup the first argument to the track identified by the index. @@ -674,11 +661,30 @@ Bool_t AliRsnEvent::SetDaughterESDcascade(AliRsnDaughter &, Int_t) // Version #3: ESD cascade // + // check 1: index in good range + if (i > fRef->GetNumberOfCascades()) { + out.SetBad(); + return 1; + } + + // check 2: not NULL object + AliESDEvent *ev = GetRefESD(); + AliESDcascade *casc = ev->GetCascade(i); + if (!casc) { + out.SetBad(); + return 2; + } + + // assign references of reconstructed track + out.SetRef(casc); + out.SetGood(); + out.SetLabel(-1); + return kTRUE; } //_____________________________________________________________________________ -Bool_t AliRsnEvent::SetDaughterAODcascade(AliRsnDaughter &, Int_t) +Bool_t AliRsnEvent::SetDaughterAODcascade(AliRsnDaughter &out, Int_t i) { // // Setup the first argument to the track identified by the index. @@ -687,6 +693,25 @@ Bool_t AliRsnEvent::SetDaughterAODcascade(AliRsnDaughter &, Int_t) // Version #4: AOD cascade // + // check 1: index in good range + if (i > fRef->GetNumberOfCascades()) { + out.SetBad(); + return kFALSE; + } + + // check 2: not NULL object + AliAODEvent *ev = GetRefAOD(); + AliAODv0 *casc = ev->GetCascade(i); + if (!casc) { + out.SetBad(); + return kFALSE; + } + + // assign references of reconstructed track + out.SetRef(casc); + out.SetGood(); + out.SetLabel(-1); + return kTRUE; } diff --git a/PWG2/RESONANCES/AliRsnEvent.h b/PWG2/RESONANCES/AliRsnEvent.h index 98d01f534ed..516cc24ef51 100644 --- a/PWG2/RESONANCES/AliRsnEvent.h +++ b/PWG2/RESONANCES/AliRsnEvent.h @@ -10,6 +10,7 @@ // //////////////////////////////////////////////////////////////////////////////// +#include "AliStack.h" #include "AliVEvent.h" #include "AliMCEvent.h" #include "AliESDEvent.h" @@ -19,6 +20,7 @@ class AliRsnCutPID; class AliESDtrackCuts; +class AliPIDResponse; class AliRsnEvent : public TObject { public: @@ -29,15 +31,17 @@ public: virtual ~AliRsnEvent(); // basic setters/getters - void SetRef(AliVEvent *ref) {fRef = ref;} - void SetRefMC(AliVEvent *refmc) {fRefMC = refmc;} - void SetLeadingIndex(Int_t i) {fLeading = i;} - void SetLocalID(Int_t i) {fLocalID = i;} - AliVEvent* GetRef() {return fRef;} - AliVEvent* GetRefMC() {return fRefMC;} - Int_t GetLeadingIndex() const {return fLeading;} - Int_t GetLeadingParticleID() const {return fLeading;} - Int_t GetLocalID() const {return fLocalID;} + void SetRef(AliVEvent *ref) {fRef = ref;} + void SetRefMC(AliVEvent *refmc) {fRefMC = refmc;} + void SetLeadingIndex(Int_t i) {fLeading = i;} + void SetLocalID(Int_t i) {fLocalID = i;} + void SetPIDResponse(AliPIDResponse *pid) {fPID = pid;} + AliVEvent* GetRef() {return fRef;} + AliVEvent* GetRefMC() {return fRefMC;} + Int_t GetLeadingIndex() const {return fLeading;} + Int_t GetLeadingParticleID() const {return fLeading;} + Int_t GetLocalID() const {return fLocalID;} + AliPIDResponse* GetPIDResponse() {return fPID;} // getters which convert into allowed input types AliESDEvent* GetRefESD() {if (classMatchRef (AliESDEvent::Class())) return static_cast(fRef) ; return 0x0;} @@ -61,7 +65,7 @@ public: AliRsnDaughter GetDaughterAbs(Int_t absoluteIndex); AliRsnDaughter GetDaughter(Int_t i, AliRsnDaughter::ERefType type = AliRsnDaughter::kTrack); AliRsnDaughter GetDaughterMC(Int_t i); - Int_t GetAbsoluteSum(); + Int_t GetAbsoluteSum() {if (fRef) return (fRef->GetNumberOfTracks() + fRef->GetNumberOfV0s() + fRef->GetNumberOfCascades()); return 0;} Bool_t ConvertAbsoluteIndex(Int_t index, Int_t &realIndex, AliRsnDaughter::ERefType &type); Int_t ConvertRealIndex(Int_t index, AliRsnDaughter::ERefType type); @@ -89,8 +93,10 @@ private: AliVEvent *fRefMC; // pointer to reference MC event (if any) Int_t fLeading; // index of leading track Int_t fLocalID; // identification number used locally + + AliPIDResponse *fPID; //! pointer to PID response - ClassDef(AliRsnEvent, 4); + ClassDef(AliRsnEvent, 5); }; #endif diff --git a/PWG2/RESONANCES/AliRsnExpression.cxx b/PWG2/RESONANCES/AliRsnExpression.cxx index 8c7e3345ebe..3d0d033b1d8 100644 --- a/PWG2/RESONANCES/AliRsnExpression.cxx +++ b/PWG2/RESONANCES/AliRsnExpression.cxx @@ -101,11 +101,6 @@ Bool_t AliRsnExpression::Value(TObjArray &vars) AliError("Expression undefined."); return kFALSE; } - if (!fArg2) { - AliError("Argument 2 is required."); - return kFALSE; - } - // AliDebug(AliLog::kDebug,Form("fOperator %d",fOperator)); diff --git a/PWG2/RESONANCES/AliRsnFunction.cxx b/PWG2/RESONANCES/AliRsnFunction.cxx deleted file mode 100644 index 99064783c6a..00000000000 --- a/PWG2/RESONANCES/AliRsnFunction.cxx +++ /dev/null @@ -1,316 +0,0 @@ -// -// Class AliRsnFunction -// -// This class defines a base classe to implement a function -// which uses the internal RSN package event format (AliRsnEvent). -// It contains some default flags which turn out to be useful: -// - a flag to select only the "true" pairs (tracks from same resonance) -// - a flag to know if the computation is done over two events (mixing) -// -// Any kind of analysis object should be implemented as inheriting from this -// because the AliRsnAnalyzer which executes the analysis will accept a collection -// of such objects, in order to have a unique format of processing method -// -// The user who implements a kind of computation type should inherit from -// this class and override the virtual functions defined in it, which -// initialize the final output histogram and define how to process data. -// -// -// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// - -#include -#include - -#include "AliLog.h" - -#include "AliRsnValue.h" - -#include "AliRsnFunction.h" - -ClassImp(AliRsnFunction) - -//________________________________________________________________________________________ -AliRsnFunction::AliRsnFunction(Bool_t useTH1) : - TObject(), - fAxisList("AliRsnValue", 0), - fUseTH1(useTH1), - fSize(0), - fH1(0x0), - fHSparse(0x0), - fValues(0) -{ -// -// Constructor. -// -} - -//________________________________________________________________________________________ -AliRsnFunction::AliRsnFunction(const AliRsnFunction ©) : - TObject(copy), - fAxisList(copy.fAxisList), - fUseTH1(copy.fUseTH1), - fSize(copy.fSize), - fH1(0x0), - fHSparse(0x0), - fValues(copy.fValues) -{ -// -// Copy constructor. -// -} - -//________________________________________________________________________________________ -const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& copy) -{ -// -// Assignment operator. -// - - fAxisList = copy.fAxisList; - fUseTH1 = copy.fUseTH1; - fSize = copy.fSize; - fValues = copy.fValues; - - if (fH1) delete fH1; - if (fHSparse) delete fHSparse; - - return (*this); -} - -//________________________________________________________________________________________ -const char* AliRsnFunction::GetName() const -{ -// -// Defines the name of this object according to -// the function type and binning -// - - TString name(""); - - TObjArrayIter next(&fAxisList); - AliRsnValue *axis = 0; - - while ((axis = (AliRsnValue*)next())) { - if (name.Length() > 1) name += '_'; - name += axis->GetName(); - } - - return name.Data(); -} - -//________________________________________________________________________________________ -Bool_t AliRsnFunction::AddAxis(AliRsnValue *const axis) -{ -// -// Try to add a new axis to this function. -// The operation succeeds only if the related value object -// has a target compatible with the function type: -// -- 'single' functions, for tracks/events: AliRsnDaughter or AliRsnEvent -// -- 'not single' functions, for pairs/events : AliRsnMother or AliRsnEvent -// otherwise the axis is not added. -// -// If more than 3 axes are added, switch to THnSparseF output. -// NOTE: this can cause large files and high memory occupancy. -// - - Int_t size = fAxisList.GetEntries(); - new (fAxisList[size]) AliRsnValue(*axis); - - if (fAxisList.GetEntries() > 3) { - AliWarning("Adding more than 3 axes will produce a THnSparseD output."); - fUseTH1 = kFALSE; - } - - return kTRUE; -} - -//________________________________________________________________________________________ -TH1* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTitle) -{ -// -// Creates and returns the histogram defined using -// arguments fo name and title, and the first histoDef for binning. -// Variable-sized histogram binning is always called, due to use of histoDef, -// even if the bins are equal, since they are defined in this class. -// Eventually present histoDef's in other slots of array (1, 2) are ignored. -// -// This version produces a THnSparseF. -// - - fSize = fAxisList.GetEntries(); - if (!fSize) { - AliError("No axes defined"); - return 0x0; - } else if (fSize > 3) { - AliError("Too many axes defined for a TH1 object"); - return 0x0; - } - - // initialize the size of values container - fValues.Set(fSize); - - // retrieve binnings for main and secondary axes - AliRsnValue *fcnAxis; - TArrayD array[3]; - for (Int_t i = 0; i < fSize; i++) { - fcnAxis = (AliRsnValue*)fAxisList.At(i); - if (!fcnAxis) { - AliError("Empty axis"); - array[i].Set(2); - array[i][0] = -1E5; - array[i][1] = -1E5; - continue; - } else { - array[i] = fcnAxis->GetArray(); - } - } - - // create histogram depending on the number of axes - switch (fSize) { - case 1: - fH1 = new TH1F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray()); - break; - case 2: - fH1 = new TH2F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray(), array[1].GetSize() - 1, array[1].GetArray()); - break; - case 3: - fH1 = new TH3F(histoName, histoTitle, array[0].GetSize() - 1, array[0].GetArray(), array[1].GetSize() - 1, array[1].GetArray(), array[2].GetSize() - 1, array[2].GetArray()); - break; - } - fH1->Sumw2(); - - return fH1; -} - -//________________________________________________________________________________________ -THnSparseF* AliRsnFunction::CreateHistogramSparse(const char *histoName, const char *histoTitle) -{ -// -// Creates and returns the histogram defined using -// arguments fo name and title, and the first histoDef for binning. -// Variable-sized histogram binning is always called, due to use of histoDef, -// even if the bins are equal, since they are defined in this class. -// Eventually present histoDef's in other slots of array (1, 2) are ignored. -// -// This version produces a THnSparseF. -// - - fSize = fAxisList.GetEntries(); - if (!fSize) { - AliError("No axes defined"); - return 0x0; - } - - // initialize the size of values container - fValues.Set(fSize); - - // initialize the array of number of bins for each axis - // taking it from the stored values, while for the bins - // they are set as summied and defined later - Int_t *nbins = new Int_t[fSize]; - AliRsnValue *fcnAxis = 0; - for (Int_t i = 0; i < fSize; i++) { - fcnAxis = (AliRsnValue*)fAxisList.At(i); - if (!fcnAxis) { - nbins[i] = 1; - AliError("Empty axis"); - continue; - } - nbins[i] = fcnAxis->GetArray().GetSize() - 1; - } - - // create histogram - fHSparse = new THnSparseF(histoName, histoTitle, fSize, nbins); - fHSparse->Sumw2(); - - // update the various axes using the definitions given in the array of axes here - for (Int_t i = 0; i < fSize; i++) { - fcnAxis = (AliRsnValue*)fAxisList.At(i); - if (!fcnAxis) { - AliError("Empty axis: doing unique bin betweeen -100000 and 100000"); - continue; - } - TAxis* axis = fHSparse->GetAxis(i); - axis->Set(nbins[i], fcnAxis->GetArray().GetArray()); - } - - delete [] nbins; - - return fHSparse; -} - - -//________________________________________________________________________________________ -Bool_t AliRsnFunction::Fill(TObject *object) -{ -// -// Fill function histogram using the passed object -// - - AliDebug(AliLog::kDebug + 2, "->"); - - // loop on axes and try to compute values - // using this object or, as an alternative - // its reference event - Int_t i; - Bool_t globalOK = kTRUE, computeOK; - AliRsnValue *fcnAxis = 0; - for (i = 0; i < fSize; i++) { - fValues[i] = 0.0; - computeOK = kFALSE; - fcnAxis = (AliRsnValue*)fAxisList.At(i); - if (fcnAxis) { - computeOK = fcnAxis->Eval(object); - if (computeOK) fValues[i] = ((Float_t)fcnAxis->GetComputedValue()); - } - if (!computeOK) globalOK = kFALSE; - } - - // if even one of the computations has failes, the histograms are not filled - if (!globalOK) return kFALSE; - - // fill histogram - if (fUseTH1) { - - // check presence of output histogram - if (!fH1) { - AliError("Required a TH1 which is not initialized"); - return kFALSE; - } - - // fill according to dimensions - switch (fSize) { - case 1: { - TH1F *h1 = (TH1F*)fH1; - h1->Fill(fValues[0]); - } - break; - case 2: { - TH2F *h2 = (TH2F*)fH1; - h2->Fill(fValues[0], fValues[1]); - } - break; - case 3: { - TH3F *h3 = (TH3F*)fH1; - h3->Fill(fValues[0], fValues[1], fValues[2]); - } - break; - default: - AliError(Form("Wrong size : %d", fSize)); - return kFALSE; - } - } else { - - // check presence of output histogram - if (!fHSparse) { - AliError("Required a THnSparseF which is not initialized"); - return kFALSE; - } - - fHSparse->Fill(fValues.GetArray()); - } - - AliDebug(AliLog::kDebug + 2, "->"); - return kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnFunction.h b/PWG2/RESONANCES/AliRsnFunction.h deleted file mode 100644 index f25bb5df32a..00000000000 --- a/PWG2/RESONANCES/AliRsnFunction.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// Class AliRsn Fcn -// -// This class defines a base classe to implement a typical computation -// which uses the internal RSN package event format (AliRsnEvent). -// It contains some default flags which turn out to be useful: -// - a flag to select only the "true" pairs (tracks from same resonance) -// - a flag to know if the computation is done over two events (mixing) -// -// Any kind of analysis object should be implemented as inheriting from this -// because the AliRsnAnalyzer which executes the analysis will accept a collection -// of such objects, in order to have a unique format of processing method -// -// The user who implements a kind of computation type should inherit from -// this class and override the virtual functions defined in it, which -// initialize the final output histogram and define how to process data. -// -// -// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// - -#ifndef ALIRSNFUNCTION_H -#define ALIRSNFUNCTION_H - -#include -#include -#include -#include -#include -#include - -class AliRsnValue; - -class AliRsnFunction : public TObject { - -public: - - AliRsnFunction(Bool_t useTH1 = kTRUE); - AliRsnFunction(const AliRsnFunction ©); - virtual ~AliRsnFunction() { delete fH1; delete fHSparse; } - const AliRsnFunction& operator=(const AliRsnFunction ©); - - virtual const char* GetName() const; - - Bool_t IsUsingTH1() {return fUseTH1;} - void UseTH1() {fUseTH1 = kTRUE;} - void UseSparse() {fUseTH1 = kFALSE;} - - Bool_t AddAxis(AliRsnValue* const axis); - Int_t GetNumberOfAxes() {return fAxisList.GetEntries();} - - TH1* CreateHistogram(const char *histoName, const char *histoTitle); - THnSparseF* CreateHistogramSparse(const char *histoName, const char *histoTitle); - - Bool_t Fill(TObject *object); - -protected: - - TClonesArray fAxisList; // list of axis - Bool_t fUseTH1; // use TH1 or not? - Int_t fSize; // number of dim of output histogram - TH1 *fH1; // output histogram (standard type) - THnSparseF *fHSparse; // output histogram (sparse type) - TArrayD fValues; //! computed values - - // ROOT dictionary - ClassDef(AliRsnFunction, 3) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnInputHandler.cxx b/PWG2/RESONANCES/AliRsnInputHandler.cxx new file mode 100644 index 00000000000..07379c7d840 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnInputHandler.cxx @@ -0,0 +1,133 @@ +#include "AliLog.h" + +#include "AliRsnEvent.h" +#include "AliMultiInputEventHandler.h" +#include "AliMixInputEventHandler.h" +#include "AliMCEventHandler.h" + +#include "AliRsnInputHandler.h" +ClassImp(AliRsnInputHandler) + +//_____________________________________________________________________________ +AliRsnInputHandler::AliRsnInputHandler(const char *name) : + AliInputEventHandler(name, name), + fRsnEvent(0), + fRsnSelector() +{ +// +// Default constructor. +// + AliDebug(AliLog::kDebug + 10, "<-"); + AliDebug(AliLog::kDebug + 10, "->"); +} + +//_____________________________________________________________________________ +AliRsnInputHandler::~AliRsnInputHandler() +{ +// +// Destructor +// + AliDebug(AliLog::kDebug + 10, "<-"); + delete fRsnEvent; + AliDebug(AliLog::kDebug + 10, "->"); +} + +//_____________________________________________________________________________ +Bool_t AliRsnInputHandler::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 AliRsnInputHandler::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)); + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} +//_____________________________________________________________________________ +Bool_t AliRsnInputHandler::Notify() +{ +// +// Notify() is called for all mix input handlers +// + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliRsnInputHandler::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 AliRsnInputHandler::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; + AliMultiInputEventHandler *multiIH = dynamic_cast(fParentHandler); + if (multiIH) { + ih = multiIH->GetFirstInputEventHandler(); + if (ih) { + if (!fRsnEvent) fRsnEvent = new AliRsnEvent(); + fRsnEvent->SetRef(ih->GetEvent()); + fRsnEvent->SetPIDResponse(ih->GetPIDResponse()); + if (fRsnEvent->GetRefESD()) { + AliMCEventHandler *mcH = multiIH->GetFirstMCEventHandler(); + if (mcH) fRsnEvent->SetRefMC(mcH->MCEvent()); + } else if (fRsnEvent->GetRefAOD()) { + // TODO AOD MC +// fRsnEvent->SetRefMC(mcH->MCEvent()); + } + if (fParentHandler->ParentHandler()) tmp = "MIX"; + // applying pid cuts + //fRsnPIDManager.Reset(); + + //fRsnPIDManager.ApplyCuts(fRsnEvent); + fRsnSelector.Reset(); + fRsnSelector.ScanEvent(fRsnEvent); + } + } + } + AliDebug(AliLog::kDebug + 5, "->"); + return kTRUE; +} + +Bool_t AliRsnInputHandler::GetEntry() +{ + AliDebug(AliLog::kDebug + 5, "<-"); + AliDebug(AliLog::kDebug + 5, "->"); + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliRsnInputHandler::FinishEvent() +{ + // + // FinishEvent() is called for all mix input handlers + // + AliDebug(AliLog::kDebug + 5, Form("<-")); + AliDebug(AliLog::kDebug + 5, Form("->")); + return kTRUE; +} diff --git a/PWG2/RESONANCES/AliRsnInputHandler.h b/PWG2/RESONANCES/AliRsnInputHandler.h new file mode 100644 index 00000000000..21d358ba572 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnInputHandler.h @@ -0,0 +1,49 @@ +// +// Class AliRsnInputHandler +// +// AliRsnInputHandler +// TODO example +// author: +// Martin Vala (martin.vala@cern.ch) +// + +#ifndef ALIRSNINPUTHANDLER_H +#define ALIRSNINPUTHANDLER_H + +#include "AliInputEventHandler.h" +//#include "AliRsnPIDManager.h" +#include "AliRsnDaughterSelector.h" + +class AliRsnEvent; +class AliRsnInputHandler : public AliInputEventHandler { + +public: + AliRsnInputHandler(const char *name = "rsnInputHandler"); + virtual ~AliRsnInputHandler(); + + // 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(); + + AliRsnEvent *GetRsnEvent() { return fRsnEvent; } + //AliRsnPIDManager *GetPIDManager() { return &fRsnPIDManager; } + AliRsnDaughterSelector *GetSelector() { return &fRsnSelector; } + +private: + + AliRsnEvent *fRsnEvent; //! + //AliRsnPIDManager fRsnPIDManager; + AliRsnDaughterSelector fRsnSelector; + + AliRsnInputHandler(const AliRsnInputHandler& handler); + AliRsnInputHandler &operator=(const AliRsnInputHandler &handler); + + ClassDef(AliRsnInputHandler, 1) +}; + +#endif diff --git a/PWG2/RESONANCES/AliRsnListOutput.cxx b/PWG2/RESONANCES/AliRsnListOutput.cxx new file mode 100644 index 00000000000..5ccec162356 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnListOutput.cxx @@ -0,0 +1,378 @@ +// +// Class AliRsnListOutput +// +// This class defines a base classe to implement a Output +// which uses the internal RSN package event format (AliRsnEvent). +// It contains some default flags which turn out to be useful: +// - a flag to select only the "true" pairs (tracks from same resonance) +// - a flag to know if the computation is done over two events (mixing) +// +// Any kind of analysis object should be implemented as inheriting from this +// because the AliRsnAnalyzer which executes the analysis will accept a collection +// of such objects, in order to have a unique format of processing method +// +// The user who implements a kind of computation type should inherit from +// this class and override the virtual Outputs defined in it, which +// initialize the final output histogram and define how to process data. +// +// +// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) +// + +#include + +#include "AliLog.h" + +#include "AliRsnValue.h" +#include "AliRsnLoop.h" + +#include "AliRsnListOutput.h" + +ClassImp(AliRsnListOutput) + +//________________________________________________________________________________________ +AliRsnListOutput::AliRsnListOutput(const char *name, AliRsnListOutput::EOut type) : + TNamed(name, ""), + fType(type), + fSteps(0), + fValues(0), + fNValues(0), + fList(0x0), + fIndex(-1), + fArray(0) +{ +// +// Constructor. +// Requires a name for this object (which will be used to name the output object) +// and the definition of the output type from the built-in enumeration. +// +} + +//________________________________________________________________________________________ +AliRsnListOutput::AliRsnListOutput(const AliRsnListOutput ©) : + TNamed(copy), + fType(copy.fType), + fSteps(copy.fSteps), + fValues(copy.fValues), + fNValues(copy.fNValues), + fList(copy.fList), + fIndex(copy.fIndex), + fArray(0) +{ +// +// Copy constructor. +// Since the pointer objects must be initialized in a second step, +// they are never copied, and then they are initialized to zero. +// +} + +//________________________________________________________________________________________ +const AliRsnListOutput& AliRsnListOutput::operator=(const AliRsnListOutput& copy) +{ +// +// Assignment operator. +// Same consideration as the copiy constructor. In this case, there is +// the possibility to have the output objects alreasy initialized, but +// they are anyway reset. +// + + TNamed::operator=(copy); + + fType = copy.fType; + fSteps = copy.fSteps; + fValues = copy.fValues; + fNValues = copy.fNValues; + fList = copy.fList; + fIndex = copy.fIndex; + fArray = copy.fArray; + + Reset(); + + return (*this); +} + +//__________________________________________________________________________________________________ +AliRsnListOutput::~AliRsnListOutput() +{ +// +// Destructor. +// Deletes the output objects. +// + + Reset(); +} + +//__________________________________________________________________________________________________ +void AliRsnListOutput::Reset() +{ +// +// Clear all output objects. In general, only one will be initialized at a time. +// + + fList = 0x0; +} + +//_____________________________________________________________________________ +void AliRsnListOutput::AddValue(AliRsnValue *value) +{ +// +// Adds a value computation object to the list. +// + + fValues.AddLast(value); +} + + +//________________________________________________________________________________________ +Bool_t AliRsnListOutput::Init(const char *prefix, TList *list) +{ +// +// Initializes the output for this object. +// What kind of output depends on the 'fType' data member, +// and in case it is a CF container, also on the 'fSteps'. +// The object is named with the following criterion: +// ___ +// + + Int_t i; + + // all output objects are cleared + Reset(); + + // count values and set dimension of arrays + // do also some checks for a good match between type and output + fNValues = fValues.GetEntries(); + if (fNValues < 1) { + AliError("Need at least 1 value"); + return kFALSE; + } + if (fType == kHistoDefault && fNValues > 3) { + AliInfo(Form("NValues = %d > 3 --> cannot use a normal histogram, need to use a sparse", fNValues)); + fType = kHistoSparse; + } + + // resize the output array + fArray.Set(fNValues); + + // create the name + TString name(Form("%s_%s", prefix, GetName())); + AliRsnValue *val = 0x0; + for (i = 0; i < fNValues; i++) { + val = GetValue(i); + if (!val) { + AliError(Form("Slot %d in value list is NULL", i)); + return kFALSE; + } + name += '_'; + name += val->GetName(); + } + + // allowed objects + TObject *object = 0x0; + + // initialize appropriate output object + // and, if successful, insert into the list + switch (fType) { + case kHistoDefault: + name.Append("_hist"); + object = CreateHistogram(name.Data()); + break; + case kHistoSparse: + name.Append("_hsparse"); + object = CreateHistogramSparse(name.Data()); + break; + case kCFContainer: + name.Append("_cf"); + object = CreateCFContainer(name.Data()); + break; + default: + AliWarning("Wrong type output or initialization failure"); + } + + if (object) { + //AliInfo(Form("[%s]: initializing output '%s' (obj name = '%s') with %d values and format %d [%s]", GetName(), name.Data(), object->GetName(), fNValues, fType, object->ClassName())); + fList = list; + fList->Add(object); + fIndex = fList->IndexOf(object); + return kTRUE; + } + + return kFALSE; +} + +//________________________________________________________________________________________ +TH1* AliRsnListOutput::CreateHistogram(const char *name) +{ +// +// Initialize the 'default' TH1 output object. +// In case one of the expected axes is NULL, the initialization fails. +// + + // we expect to have maximum 3 axes in this case + Int_t i, nbins[3] = {0, 0, 0}; + TArrayD array[3]; + for (i = 0; i < fNValues; i++) { + AliRsnValue *val = GetValue(i); + if (!val) { + AliError(Form("Expected axis %d is NULL", i)); + return 0x0; + } + nbins[i] = GetValue(i)->GetArray().GetSize() - 1; + array[i] = GetValue(i)->GetArray(); + } + + TH1 *hist = 0x0; + + // create histogram depending on the number of axes + switch (fNValues) { + case 1: + hist = new TH1F(name, "", nbins[0], array[0].GetArray()); + break; + case 2: + hist = new TH2F(name, "", nbins[0], array[0].GetArray(), nbins[1], array[1].GetArray()); + break; + case 3: + hist = new TH3F(name, "", nbins[0], array[0].GetArray(), nbins[1], array[1].GetArray(), nbins[2], array[2].GetArray()); + break; + default: + AliError(Form("Wrong number of dimensions: %d", fNValues)) + return 0x0; + } + + if (hist) hist->Sumw2(); + return hist; +} + +//________________________________________________________________________________________ +THnSparseF* AliRsnListOutput::CreateHistogramSparse(const char *name) +{ +// +// Initialize the THnSparse output object. +// In case one of the expected axes is NULL, the initialization fails. +// + + // retrieve binnings and sizes of all axes + // since the check for null values is done in Init(), + // we assume that here they must all be well defined + Int_t i, *nbins = new Int_t[fNValues]; + TArrayD *array = new TArrayD[fNValues]; + for (i = 0; i < fNValues; i++) { + nbins[i] = GetValue(i)->GetArray().GetSize() - 1; + array[i] = GetValue(i)->GetArray(); + } + + // create histogram + THnSparseF *hist = new THnSparseF(name, "", fNValues, nbins); + hist->Sumw2(); + + // update the various axes using the definitions given in the array of axes here + for (i = 0; i < fNValues; i++) { + hist->GetAxis(i)->Set(nbins[i], array[i].GetArray()); + } + + // clear heap + delete [] nbins; + delete [] array; + + return hist; +} + +//________________________________________________________________________________________ +AliCFContainer* AliRsnListOutput::CreateCFContainer(const char *name) +{ +// +// Initialize the AliCFContainer output object. +// In case one of the expected axes is NULL, the initialization fails. +// + + // retrieve binnings and sizes of all axes + // since the check for null values is done in Init(), + // we assume that here they must all be well defined + Int_t i, *nbins = new Int_t[fNValues]; + TArrayD *array = new TArrayD[fNValues]; + for (i = 0; i < fNValues; i++) { + nbins[i] = GetValue(i)->GetArray().GetSize() - 1; + array[i] = GetValue(i)->GetArray(); + } + + // create object + AliCFContainer *cont = new AliCFContainer(name, "", fSteps, fNValues, nbins); + + // set the bin limits for each axis + for (i = 0; i < fNValues; i++) { + cont->SetBinLimits(i, array[i].GetArray()); + } + + // clear heap + delete [] nbins; + delete [] array; + + return cont; +} + +//________________________________________________________________________________________ +Bool_t AliRsnListOutput::Fill(TObject *target, Int_t step) +{ +// +// Uses the passed argument to compute all values. +// If all computations were successful, fill the output +// Second argument (step) is needed only in case of CF containers. +// Return value is the AND of all computation successes. +// + + Int_t i; + + // do computations + Bool_t globalOK = kTRUE; + AliRsnValue *val = 0x0; + for (i = 0; i < fNValues; i++) { + val = GetValue(i); + if (!val) { + AliError("NULL value found"); + return kFALSE; + } + globalOK = globalOK && val->Eval(target); + fArray[i] = (Double_t)val->GetComputedValue(); + } + if (!globalOK) return kFALSE; + + // retrieve object + if (!fList || fIndex < 0) { + AliError("List not initialized"); + return kFALSE; + } + TObject *obj = fList->At(fIndex); + if (!obj) { + AliError("Null pointer"); + return kFALSE; + } + + // check + //AliInfo(Form("[%s] Object index, name, type = %d, %s (%s)", GetName(), fIndex, obj->GetName(), obj->ClassName())); + + // fill output + if (obj->IsA() == TH1F::Class()) { + TH1F *h = (TH1F*)obj; + h->Fill(fArray[0]); + return kTRUE; + } else if (obj->IsA() == TH2F::Class()) { + TH2F *h = (TH2F*)obj; + h->Fill(fArray[0], fArray[1]); + return kTRUE; + } else if (obj->IsA() == TH3F::Class()) { + TH3F *h = (TH3F*)obj; + h->Fill(fArray[0], fArray[1], fArray[2]); + return kTRUE; + } else if (obj->InheritsFrom(THnSparse::Class())) { + THnSparseF *h = (THnSparseF*)obj; + h->Fill(fArray.GetArray()); + return kTRUE; + } else if (obj->InheritsFrom(AliCFContainer::Class())) { + AliCFContainer *c = (AliCFContainer*)obj; + c->Fill(fArray.GetArray(), step); + return kTRUE; + } else { + AliError(Form("Not handled class '%s'", obj->ClassName())); + return kFALSE; + } +} diff --git a/PWG2/RESONANCES/AliRsnListOutput.h b/PWG2/RESONANCES/AliRsnListOutput.h new file mode 100644 index 00000000000..0a6d749eef6 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnListOutput.h @@ -0,0 +1,70 @@ +#ifndef ALIRSNLISTOUTPUT_H +#define ALIRSNLISTOUTPUT_H + +// +// General class for outputs which can stay into a TList +// + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "AliCFContainer.h" + +class AliRsnValue; + +class AliRsnListOutput : public TNamed { + +public: + + enum EOut { + kHistoDefault, + kHistoSparse, + kCFContainer + }; + + AliRsnListOutput(const char *name = "", EOut type = kHistoDefault); + AliRsnListOutput(const AliRsnListOutput ©); + const AliRsnListOutput& operator=(const AliRsnListOutput ©); + virtual ~AliRsnListOutput(); + + EOut GetType() {return fType;} + Int_t GetSteps() {return fSteps;} + TObjArray* GetValues() {return &fValues;} + Int_t GetNValues() {return (fNValues = fValues.GetEntries());} + AliRsnValue* GetValue(Int_t i) {return (AliRsnValue*)fValues[i];} + void SetType(EOut type) {fType = type;} + void SetSteps(Int_t n) {fSteps = n;} + + void AddValue(AliRsnValue *value); + + virtual void Reset(); + virtual Bool_t Init(const char *prefix, TList *list); + virtual Bool_t Fill(TObject *target, Int_t step = 0); + +private: + + TH1* CreateHistogram(const char *name); + THnSparseF* CreateHistogramSparse(const char *name); + AliCFContainer* CreateCFContainer(const char *name); + + EOut fType; // output format among allowed ones + Int_t fSteps; // number of steps (only for container) + TObjArray fValues; // container for all related values + Int_t fNValues; //! number of values (internal use) + TList *fList; //! list containing the output + Int_t fIndex; // index of object in the list + + TArrayD fArray; //! temp array of computed values + + ClassDef(AliRsnListOutput, 1) // AliRsnListOutput class +}; + +#endif diff --git a/PWG2/RESONANCES/AliRsnLoop.cxx b/PWG2/RESONANCES/AliRsnLoop.cxx new file mode 100644 index 00000000000..ac7740adf19 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoop.cxx @@ -0,0 +1,142 @@ +// +// Base class to implement any computation within the RSN package. +// It contains only an array of output objects which must derive +// from AliRsnOutput. +// Its core functions ar Init() and DoLoop() which must be +// overloaded by any class which inherits from this. +// + +#include +#include + +#include "AliLog.h" + +#include "AliRsnDaughterSelector.h" + +#include "AliRsnLoop.h" + +ClassImp(AliRsnLoop) + +//_____________________________________________________________________________ +AliRsnLoop::AliRsnLoop(const char *name, Bool_t isMixed) : + TNamed(name, ""), + fIsMixed(isMixed), + fEventCuts(0x0), + fOutputs("AliRsnListOutput", 0) +{ +// +// Default constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoop::AliRsnLoop(const AliRsnLoop& copy) : + TNamed(copy), + fIsMixed(copy.fIsMixed), + fEventCuts(copy.fEventCuts), + fOutputs(copy.fOutputs) +{ +// +// Default constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoop& AliRsnLoop::operator=(const AliRsnLoop& copy) +{ +// +// Assignment operator +// + + fIsMixed = copy.fIsMixed; + fEventCuts = copy.fEventCuts; + fOutputs = copy.fOutputs; + return (*this); +} + +//_____________________________________________________________________________ +AliRsnLoop::~AliRsnLoop() +{ +// +// Destructor +// +} + +//_____________________________________________________________________________ +void AliRsnLoop::AddOutput(TObject *object) +{ +// +// Adds an object to any of the collections. +// The target depends on the object type. +// Returns kFALSE if the addition failed. +// + + //fOutputs.AddLast(out); + AliRsnListOutput *out = (AliRsnListOutput*)object; + Int_t n = fOutputs.GetEntries(); + new (fOutputs[n]) AliRsnListOutput(*out); +} + +//_____________________________________________________________________________ +void AliRsnLoop::Print(Option_t*) const +{ +// +// Prints info about pair +// + + TObjArrayIter next(&fOutputs); + AliRsnListOutput *out = 0x0; + + while ( (out = (AliRsnListOutput*)next()) ) { + out->Print(); + } +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoop::OkEvent(AliRsnEvent *rsn) +{ +// +// If event cuts are defined, check event against them +// + + if (fEventCuts) + return fEventCuts->IsSelected(rsn); + else + return kTRUE; +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoop::Init(const char *prefix, TList *list) +{ +// +// Initialization function. +// Loops on all outputs, and initialize each of them. +// Returns kTRUE only if all initializations were successful. +// + + TObjArrayIter next(&fOutputs); + AliRsnListOutput *out; + Bool_t globalOK = kTRUE; + + while ( (out = (AliRsnListOutput*)next()) ) { + globalOK = globalOK && out->Init(prefix, list); + } + + AliInfo(Form("[%s] Object initialization: %s", GetName(), (globalOK ? "successful" : "failed"))); + return globalOK; +} + +//_____________________________________________________________________________ +Int_t AliRsnLoop::DoLoop +(AliRsnEvent *, AliRsnDaughterSelector *, AliRsnEvent *, AliRsnDaughterSelector *) +{ +// +// Main loop. +// Performs all the computations, looping on the passed event(s) and using the lists +// of selected daughters which are provided, for allowing the user to choose what to do +// with them. +// + + AliWarning("Implement this method in derived class"); + return 0; +} diff --git a/PWG2/RESONANCES/AliRsnLoop.h b/PWG2/RESONANCES/AliRsnLoop.h new file mode 100644 index 00000000000..50f311d1139 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoop.h @@ -0,0 +1,56 @@ +#ifndef ALIRSNLOOP_H +#define ALIRSNLOOP_H + +// +// Base class object for all computation devices. +// + +#include "TNamed.h" +#include "TObjArray.h" + +#include "AliRsnListOutput.h" +#include "AliRsnValue.h" +#include "AliRsnCutSet.h" + +class TList; +class AliRsnEvent; +class AliRsnListOutput; +class AliRsnDaughterSelector; + +class AliRsnLoop : public TNamed { +public: + + enum EOut { + kH1, + kHSparse, + kNtuple + }; + + AliRsnLoop(const char *name = "default", Bool_t isMixed = kFALSE); + AliRsnLoop(const AliRsnLoop ©); + AliRsnLoop& operator=(const AliRsnLoop&); + ~AliRsnLoop(); + + void SetMixed(Bool_t yn = kTRUE) {fIsMixed = yn;} + void SetEventCuts(AliRsnCutSet *set) {fEventCuts = set;} + Bool_t IsMixed() const {return fIsMixed;} + AliRsnCutSet* GetEventCuts() {return fEventCuts;} + Bool_t OkEvent(AliRsnEvent *rsn); + + virtual void AddOutput(TObject *output); + virtual void Print(Option_t *option = "") const; + virtual Bool_t Init(const char *prefix, TList *list); + virtual Int_t DoLoop(AliRsnEvent *main, AliRsnDaughterSelector *smain, AliRsnEvent *mix = 0, AliRsnDaughterSelector *smix = 0); + +protected: + + Bool_t fIsMixed; // flag to know if the loop works with event mixing + AliRsnCutSet *fEventCuts; // event cuts + TClonesArray fOutputs; // output object definitions + +private: + + ClassDef(AliRsnLoop, 1) +}; + +#endif diff --git a/PWG2/RESONANCES/AliRsnLoopDaughter.cxx b/PWG2/RESONANCES/AliRsnLoopDaughter.cxx new file mode 100644 index 00000000000..ff2408e6550 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopDaughter.cxx @@ -0,0 +1,139 @@ +// +// Computator for single daughters. +// Implements a simple loop on tracks from one of the entry lists +// filled by the task AliRsnInputHandler, adding a check on their +// definition specified in the daughter def. +// + +#include + +#include "AliLog.h" + +#include "AliRsnEvent.h" +#include "AliRsnDaughterDef.h" +#include "AliRsnDaughterSelector.h" + +#include "AliRsnLoopDaughter.h" + +ClassImp(AliRsnLoopDaughter) + +//_____________________________________________________________________________ +AliRsnLoopDaughter::AliRsnLoopDaughter(const char *name, Int_t listID, AliRsnDaughterDef *def) : + AliRsnLoop(name), + fListID(listID), + fDef(def), + fDaughter() +{ +// +// Default constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoopDaughter::AliRsnLoopDaughter(const AliRsnLoopDaughter& copy) : + AliRsnLoop(copy), + fListID(copy.fListID), + fDef(copy.fDef), + fDaughter(copy.fDaughter) +{ +// +// Copy constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoopDaughter& AliRsnLoopDaughter::operator=(const AliRsnLoopDaughter& copy) +{ +// +// Assignment operator +// + + AliRsnLoop::operator=(copy); + fListID = copy.fListID; + fDaughter = copy.fDaughter; + fDef = copy.fDef; + + return (*this); +} + +//_____________________________________________________________________________ +AliRsnLoopDaughter::~AliRsnLoopDaughter() +{ +// +// Destructor +// +} + +//_____________________________________________________________________________ +void AliRsnLoopDaughter::Print(Option_t* /*option*/) const +{ +// +// Prints info about pair +// +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopDaughter::Init(const char *prefix, TList *list) +{ +// +// Initialization function. +// Loops on all functions and eventual the ntuple, to initialize output objects. +// + + return AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list); +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopDaughter::DoLoop +(AliRsnEvent *evMain, AliRsnDaughterSelector *selMain, AliRsnEvent *, AliRsnDaughterSelector *) +{ +// +// Loop function. +// Computes what is needed from passed events. +// Returns the number of pairs successfully processed. +// + + if (!OkEvent(evMain)) return 0; + + Int_t i, il, nadd = 0, nlist = 0; + TEntryList *list[2] = {0, 0}; + + if (fDef->IsChargeDefined()) { + list[0] = selMain->GetSelected(fListID, fDef->GetChargeC()); + list[1] = 0x0; + nlist = 1; + } else { + list[0] = selMain->GetSelected(fListID, '+'); + if (list[0]) { + list[1] = selMain->GetSelected(fListID, '-'); + nlist = 2; + } else { + list[0] = selMain->GetSelected(fListID, '0'); + list[1] = 0x0; + nlist = 1; + } + } + + TObjArrayIter next(&fOutputs); + AliRsnListOutput *out = 0x0; + + for (il = 0; il < nlist; il++) { + if (!list[il]) { + AliError(Form("List #%d is null", il)); + continue; + } + for (i = 0; i < list[il]->GetN(); i++) { + evMain->SetDaughterAbs(fDaughter, (Int_t)list[il]->GetEntry(i)); + // check matching + if (!fDef->MatchesDaughter(&fDaughter)) continue; + // fill outputs + nadd++; + next.Reset(); + while ( (out = (AliRsnListOutput*)next()) ) { + out->Fill(&fDaughter); + } + } + } + + return nadd; +} diff --git a/PWG2/RESONANCES/AliRsnLoopDaughter.h b/PWG2/RESONANCES/AliRsnLoopDaughter.h new file mode 100644 index 00000000000..530d9e2a036 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopDaughter.h @@ -0,0 +1,44 @@ +#ifndef ALIRSNLOOPDAUGHTER_H +#define ALIRSNLOOPDAUGHTER_H + +// +// Class for computations on single daughters +// + +#include "AliRsnDaughter.h" +#include "AliRsnLoop.h" + +class AliRsnDaughterDef; + +class AliRsnLoopDaughter : public AliRsnLoop { +public: + + AliRsnLoopDaughter(const char *name = "default", Int_t listID = 0, AliRsnDaughterDef *def = 0); + AliRsnLoopDaughter(const AliRsnLoopDaughter ©); + AliRsnLoopDaughter& operator=(const AliRsnLoopDaughter&); + ~AliRsnLoopDaughter(); + + Int_t GetListID() {return fListID;} + AliRsnDaughterDef* GetDef() {return fDef;} + AliRsnDaughter* GetDaughter() {return &fDaughter;} + + void SetListID(Int_t i) {fListID = i;} + void SetDef(AliRsnDaughterDef *def) {fDef = def;} + + virtual void Print(Option_t *opt = "") const; + virtual Bool_t Init(const char *prefix, TList *list); + virtual Int_t DoLoop(AliRsnEvent *main, AliRsnDaughterSelector *smain, AliRsnEvent *mix = 0, AliRsnDaughterSelector *smix = 0); + +protected: + + Int_t fListID; // index of entry list to use + AliRsnDaughterDef *fDef; // definition for selection + AliRsnDaughter fDaughter; //! daughter temporary member + +private: + + ClassDef(AliRsnLoopDaughter, 3) +}; + +#endif + diff --git a/PWG2/RESONANCES/AliRsnLoopEff.cxx b/PWG2/RESONANCES/AliRsnLoopEff.cxx new file mode 100644 index 00000000000..ee6a4cf26c0 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEff.cxx @@ -0,0 +1,121 @@ +// +// *** Class AliRsnPair *** +// +// "Core" method for defining the work on a pari of particles. +// For one analysis, one must setup one of this for each pair he wants to analyze, +// adding to it all analysis which he desires to do. +// Here he defines the cuts, and the particle types and charges, and can add +// functions which do different operations on the same pair, and some binning +// with respect to some kinematic variables (eta, momentum) +// +// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) +// M. Vala (email: martin.vala@cern.ch) +// + +#include "AliRsnLoopEff.h" + +ClassImp(AliRsnLoopEff) + +//_____________________________________________________________________________ +AliRsnLoopEff::AliRsnLoopEff(const char *name, Int_t nSteps) : + AliRsnLoop(name), + fAddSteps(nSteps), + fSteps(0) +{ +// +// Default constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoopEff::AliRsnLoopEff(const AliRsnLoopEff& copy) : + AliRsnLoop(copy), + fAddSteps(copy.fAddSteps), + fSteps(copy.fSteps) +{ +// +// Copy constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoopEff& AliRsnLoopEff::operator=(const AliRsnLoopEff& copy) +{ + AliRsnLoop::operator=(copy); + + fAddSteps = copy.fAddSteps; + fSteps = copy.fSteps; + + return (*this); +} + +//_____________________________________________________________________________ +AliRsnLoopEff::~AliRsnLoopEff() +{ +// +// Destructor +// + + fSteps.Delete(); +} + +//_____________________________________________________________________________ +void AliRsnLoopEff::CreateOutput() +{ +// +// Create the unique output object of this loop +// + + if (!fOutputs.IsEmpty()) { + AliInfo("Clearing container of this efficiency loop."); + fOutputs.Delete(); + } + + AliRsnListOutput out(Form("%s_out", GetName()), AliRsnListOutput::kCFContainer); + out.SetSteps(NStepsAll()); + + AddOutput(&out); +} + +//_____________________________________________________________________________ +void AliRsnLoopEff::AddStep(TObject *cuts) +{ +// +// Add a step on reconstruction +// + + fSteps.AddLast(cuts); +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopEff::Init(const char *prefix, TList *list) +{ +// +// Initialization function. +// Loops on all functions and eventual the ntuple, to initialize output objects. +// + + CreateOutput(); + return AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list); +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopEff::FindTrack(Int_t label, AliVEvent *event) +{ +// +// Loops an event and find all tracks which have a label +// equal to that passed as first argument. +// + + Int_t i = 0; + Int_t ntracks = event->GetNumberOfTracks(); + TArrayI array(100); + + for (i = 0; i < ntracks; i++) { + AliVParticle *track = event->GetTrack(i); + if (TMath::Abs(track->GetLabel()) != label) continue; + return i; + } + + return -1; +} diff --git a/PWG2/RESONANCES/AliRsnLoopEff.h b/PWG2/RESONANCES/AliRsnLoopEff.h new file mode 100644 index 00000000000..7396cea123a --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEff.h @@ -0,0 +1,44 @@ +#ifndef ALIRSNLOOPEFF_H +#define ALIRSNLOOPEFF_H + +// +// Class to combine pairs of daughters. +// + +#include "AliLog.h" + +#include "AliRsnEvent.h" +#include "AliRsnLoop.h" + +class AliRsnLoopEff : public AliRsnLoop { +public: + + AliRsnLoopEff(const char *name = "default", Int_t nSteps = 0); + AliRsnLoopEff(const AliRsnLoopEff ©); + AliRsnLoopEff& operator=(const AliRsnLoopEff&); + ~AliRsnLoopEff(); + + AliRsnListOutput* GetOutput() {return (AliRsnListOutput*)fOutputs[0];} + void CreateOutput(); + + void AddStep(TObject *set); + Int_t NStepsArray() {return (Int_t)fSteps.GetEntries();} + Int_t NStepsAll() {return fAddSteps + NStepsArray();} + + virtual void AddOutput(TObject *) { AliWarning("In loops for efficiency it is not allowed to add outputs externally"); } + virtual Bool_t Init(const char *prefix, TList *list); + +protected: + + Int_t FindTrack(Int_t label, AliVEvent *event); + + Int_t fAddSteps; // number of additional steps + TObjArray fSteps; // list of cuts for all steps with MC tracks + +private: + + ClassDef(AliRsnLoopEff, 1) +}; + +#endif + diff --git a/PWG2/RESONANCES/AliRsnLoopEffDaughter.cxx b/PWG2/RESONANCES/AliRsnLoopEffDaughter.cxx new file mode 100644 index 00000000000..5c6dba5fc74 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEffDaughter.cxx @@ -0,0 +1,190 @@ +// +// Class AliRsnLoopEffDaughter +// +// Inherits from basic AliRsnLoopEff for efficiency, +// and computed efficiencies for single-tracks +// +// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// + +#include "AliStack.h" + +#include "AliRsnDaughterDef.h" +#include "AliRsnCutSet.h" + +#include "AliRsnLoopEffDaughter.h" + +ClassImp(AliRsnLoopEffDaughter) + +//_____________________________________________________________________________ +AliRsnLoopEffDaughter::AliRsnLoopEffDaughter(const char *name, AliRsnDaughterDef *def) : + AliRsnLoopEff(name), + fDef(def) +{ +// +// Default constructor. +// Do not repeat 'DefineOutput' since it is done in base class and we don't add new ones. +// +} + +//_____________________________________________________________________________ +AliRsnLoopEffDaughter::AliRsnLoopEffDaughter(const AliRsnLoopEffDaughter& copy) : + AliRsnLoopEff(copy), + fDef(copy.fDef) +{ +// +// Copy constrtuctor. +// +} + +//_____________________________________________________________________________ +AliRsnLoopEffDaughter& AliRsnLoopEffDaughter::operator=(const AliRsnLoopEffDaughter& copy) +{ +// +// Assignment operator. +// Owned data members are meaningless for this operator. +// + + AliRsnLoopEff::operator=(copy); + fDef = copy.fDef; + + return (*this); +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopEffDaughter::OkStepMC(TObject *target, Int_t istep) +{ +// +// Check step with MC +// + + AliRsnCutSet *cuts = (AliRsnCutSet*)fStepsMC[istep]; + return cuts->IsSelected(target); +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopEffDaughter::OkStepRec(TObject *target, Int_t istep) +{ +// +// Check step with MC +// + + AliRsnCutSet *cuts = (AliRsnCutSet*)fStepsRec[istep]; + return cuts->IsSelected(target); +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopEffDaughter::ProcessEventESD(AliRsnEvent *rsn) +{ +// +// Process current event with the definitions of the specified step in MC list +// and store results in the container slot defined in second argument. +// It is associated with the AliCFContainer with the name of the pair. +// + + AliESDEvent *esd = rsn->GetRefESD(); + AliMCEvent *mc = rsn->GetRefMCESD(); + TArrayI indexes; + Int_t imax, istep, icheck, itrack, ipart; + Int_t nsteps = NSteps(); + + static AliRsnDaughter daughter; + daughter.SetOwnerEvent(rsn); + + // loop on the MC list of particles + for (ipart = 0; ipart < stack->GetNprimary(); ipart++) { + + // MC particle + daughter.SetRefMC((AliMCParticle*)mc->GetTrack(ipart)); + + // search for reconstructed track + // if no tracks are found with that label, rec ref is set to zero + // if more than one tracks are found we use the one which passes + // most cut steps + indexes = FindTracks(ipart, esd); + if (indexes.GetSize() < 1) + daughter.SetRef(0x0); + else if (indexes.GetSize() == 1) + daughter.SetRef(esd->GetTrack(indexes[0])); + else { + imax = istep = itrack = 0; + for (icheck = 0; icheck < indexes.GetSize(); icheck++) { + daughter.SetRef(esd->GetTrack(indexes[icheck])); + daughter.SetMass(def->GetMass()); + istep = NGoodSteps(&daughter); + if (istep > imax) itrack = icheck; + } + daughter.SetRef(esd->GetTrack(indexes[itrack])); + } + + // compute 4-momenta + daughter.SetMass(def->GetMass()); + + // fill MC container + for (istep = 0; istep < nsteps; istep++) { + if (!OkStep(&daughter, istep)) break; + GetOutput()->Fill(&daughter, istep); + } + } +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopEffDaughter::ProcessEventAOD(AliRsnEvent *rsn) +{ +// +// Process current event with the definitions of the specified step in MC list +// and store results in the container slot defined in second argument. +// It is associated with the AliCFContainer with the name of the pair. +// + + AliAODEvent *aod = fRsnEvent[0].GetRefAOD(); + TClonesArray *mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName()); + if (!mcArray) return; + TArrayI indexes; + Int_t imax, istep, icheck, itrack, ipart; + + static AliRsnDaughter daughter; + daughter->SetOwnerEvent(rsn); + + // loop on the MC list of particles + TObjArrayIter next(mcArray); + AliAODMCParticle *particle; + while ((particle = (AliAODMCParticle*)next())) { + + // MC particle + daughter.SetRefMC(particle); + + // search for reconstructed track + // if no tracks are found with that label, rec ref is set to zero + // if more than one tracks are found we use the one which passes + // most cut steps + ipart = particle->GetLabel(); + indexes = FindTracks(ipart, aod); + if (indexes.GetSize() < 1) + daughter.SetRef(0x0); + else if (indexes.GetSize() == 1) + daughter.SetRef(aod->GetTrack(indexes[0])); + else { + imax = istep = itrack = 0; + for (icheck = 0; icheck < indexes.GetSize(); icheck++) { + daughter.SetRef(aod->GetTrack(indexes[icheck])); + daughter.SetMass(def->GetMass()); + istep = NGoodSteps(); + if (istep > imax) { + itrack = icheck; + imax = istep; + } + } + daughter.SetRef(aod->GetTrack(indexes[itrack])); + } + + // compute 4-momenta + daughter.SetMass(def->GetMass()); + + // fill MC container + for (istep = 0; istep < nsteps; istep++) { + if (!OkStep(&daughter, istep)) break; + GetOutput()->Fill(&daughter, istep); + } + } +} diff --git a/PWG2/RESONANCES/AliRsnLoopEffDaughter.h b/PWG2/RESONANCES/AliRsnLoopEffDaughter.h new file mode 100644 index 00000000000..f8be8bbcf95 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEffDaughter.h @@ -0,0 +1,43 @@ +// +// Class AliRsnLoopEffDaughter +// +// Inherits from basic AliRsnAnalysisTaskEff for efficiency, +// and computed efficiencies for single-tracks +// +// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// + +#ifndef ALIRSNLOOPEFFDAUGHTER_H +#define ALIRSNLOOPEFFDAUGHTER_H + +#include "AliRsnLoopEff.h" + +class AliRsnDaughterDef; + +class AliRsnLoopEffDaughter : public AliRsnLoopEff { + +public: + + AliRsnLoopEffDaughter(const char *name, AliRsnDaughterDef *def); + AliRsnLoopEffDaughter(const AliRsnLoopEffDaughter& copy); + AliRsnLoopEffDaughter& operator=(const AliRsnLoopEffDaughter& copy); + virtual ~AliRsnLoopEffDaughter() {;}; + + AliRsnDaughterDef* GetDef() {return fDef;} + void SetDef(AliRsnDaughterDef *def) {fDef = def;} + + virtual Bool_t OkStepMC(TObject *checked, Int_t step); + virtual Bool_t OkStepRec(TObject *checked, Int_t step); + +protected: + + virtual Int_t ProcessEventESD(AliRsnEvent *rsn); + virtual Int_t ProcessEventAOD(AliRsnEvent *rsn); + + AliRsnDaughterDef *fDef; // used daughter definition + + ClassDef(AliRsnLoopEffDaughter, 1) +}; + +#endif + diff --git a/PWG2/RESONANCES/AliRsnLoopEffPair.cxx b/PWG2/RESONANCES/AliRsnLoopEffPair.cxx new file mode 100644 index 00000000000..13b360be98c --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEffPair.cxx @@ -0,0 +1,218 @@ +// +// Class AliRsnLoopEffPair +// +// Inherits from basic AliRsnLoopEff for efficiency, +// and computed efficiencies for single-tracks +// +// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// + +#include "AliStack.h" + +#include "AliRsnCutManager.h" +#include "AliRsnDaughterDef.h" +#include "AliRsnPairDef.h" +#include "AliRsnLoopEffPair.h" + +ClassImp(AliRsnLoopEffPair) + +//_____________________________________________________________________________ +AliRsnLoopEffPair::AliRsnLoopEffPair(const char *name, AliRsnPairDef *def) : + AliRsnLoopEff(name, 2), + fDef(def), + fMother() +{ +// +// Default constructor. +// Do not repeat 'DefineOutput' since it is done in base class and we don't add new ones. +// +} + +//_____________________________________________________________________________ +AliRsnLoopEffPair::AliRsnLoopEffPair(const AliRsnLoopEffPair& copy) : + AliRsnLoopEff(copy), + fDef(copy.fDef), + fMother(copy.fMother) +{ +// +// Copy constrtuctor. +// +} + +//_____________________________________________________________________________ +AliRsnLoopEffPair& AliRsnLoopEffPair::operator=(const AliRsnLoopEffPair& copy) +{ +// +// Assignment operator. +// Owned data members are meaningless for this operator. +// + + AliRsnLoopEff::operator=(copy); + fDef = copy.fDef; + + return (*this); +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopEffPair::DoLoop(AliRsnEvent *rsn, AliRsnDaughterSelector*, AliRsnEvent*, AliRsnDaughterSelector*) +{ +// +// Loop on event and fill containers +// + + // check event cuts + if (!OkEvent(rsn)) return 0; + + // check presence of MC reference + if (!rsn->GetRefMC()) { + AliError("Need a MC to compute efficiency"); + return 0; + } + + // check event type: + // must be ESD or AOD, and then use a bool to know in the rest + if (!rsn->IsESD() && !rsn->IsAOD()) { + AliError("Need to process ESD or AOD input"); + return 0; + } + Bool_t isESD = rsn->IsESD(); + + // additional coherence checks + AliVEvent *mcEvent = 0x0; + AliStack *listESD = 0x0; + TClonesArray *listAOD = 0x0; + Int_t npart = 0; + if (isESD) { + mcEvent = rsn->GetRefMCESD(); + listESD = ((AliMCEvent*)mcEvent)->Stack(); + if (!listESD) { + AliError("Stack is not present"); + return 0; + } + npart = listESD->GetNprimary(); + } else { + mcEvent = rsn->GetRefMCAOD(); + listAOD = (TClonesArray*)((AliAODEvent*)mcEvent)->GetList()->FindObject(AliAODMCParticle::StdBranchName()); + if (!listAOD) { + AliError("Stack is not present"); + return 0; + } + npart = listAOD->GetEntries(); + } + + // check number of particles + if (!npart) { + AliInfo("Empty event"); + return 0; + } + + // by default, assign daughters to mother + // in the correct order (ref. pairDef) + fMother.SetDaughter(0, &fDaughter[0]); + fMother.SetDaughter(1, &fDaughter[1]); + fMother.SetRefEvent(rsn); + fDaughter[0].SetOwnerEvent(rsn); + fDaughter[1].SetOwnerEvent(rsn); + + // utility variables + Bool_t stop; + Int_t ipart, pdg, ndaughters, dindex[2], id, label, charge, imatch, index, istep, count = 0, nsteps = NStepsArray(); + AliVParticle *mother = 0x0, *daughter = 0x0; + AliMCParticle *motherESD = 0x0, *daughterESD = 0x0; + AliAODMCParticle *motherAOD = 0x0, *daughterAOD = 0x0; + + // loop over particles + for (ipart = 0; ipart < npart; ipart++) { + + // get next particle and take some quantities + // in different way from ESD and AOD MC + if (isESD) { + mother = mcEvent->GetTrack(ipart); + motherESD = static_cast(mother); + pdg = TMath::Abs(motherESD->Particle()->GetPdgCode()); + ndaughters = motherESD->Particle()->GetNDaughters(); + } else { + mother = (AliVParticle*)listAOD->At(ipart); + motherAOD = static_cast(mother); + pdg = TMath::Abs(motherAOD->GetPdgCode()); + ndaughters = motherAOD->GetNDaughters(); + } + + // skip particles with wrong PDG code, + if (pdg != fDef->GetMotherPDG()) continue; + + // fill first step + fMother.SumMC().SetXYZM(mother->Px(), mother->Py(), mother->Pz(), fDef->GetMotherMass()); + GetOutput()->Fill(&fMother, 0); + count++; + + // reject particles with more/less than 2 daughters + if (ndaughters != 2) continue; + + // retrieve daughters + // if one of them matches the definition for daughte #1 or #2 in pairDef, + // assign it to the corresponding AliRsnDaughter member, and set it to 'good' + // then, if both daughters are not 'good', skip the pair + fDaughter[0].Reset(); + fDaughter[1].Reset(); + if (isESD) { + dindex[0] = motherESD->Particle()->GetFirstDaughter(); + dindex[1] = motherESD->Particle()->GetLastDaughter(); + } else { + dindex[0] = motherAOD->GetDaughter(0); + dindex[1] = motherAOD->GetDaughter(1); + } + + // try to assign a daughter to each fDaughter[] data member + stop = kFALSE; + for (id = 0; id < 2; id++) { + // avoid overflows + if (dindex[id] < 0 || dindex[id] > npart) { + AliWarning(Form("Found a stack overflow in dindex[%d]: value = %d, max = %d", id, dindex[id], npart)); + stop = kTRUE; + break; + } + // retrieve daughter and copy some info + label = TMath::Abs(daughter->GetLabel()); + if (isESD) { + daughter = mcEvent->GetTrack(dindex[id]); + daughterESD = static_cast(daughter); + pdg = TMath::Abs(daughterESD->Particle()->GetPdgCode()); + charge = (Short_t)(daughterESD->Particle()->GetPDG()->Charge() / 3); + } else { + daughter = (AliAODMCParticle*)listAOD->At(dindex[id]); + daughterAOD = static_cast(daughter); + pdg = TMath::Abs(daughterAOD->GetPdgCode()); + charge = (Short_t)daughterAOD->Charge(); + } + // check if can be assigned + imatch = -1; + if ( fDef->GetDef1().MatchesPDG(pdg) && fDef->GetDef1().MatchesChargeS(charge) ) + imatch = 0; + else if ( fDef->GetDef2().MatchesPDG(pdg) && fDef->GetDef2().MatchesChargeS(charge) ) + imatch = 1; + if (imatch < 0 || imatch > 1) continue; + // assign + label = daughter->GetLabel(); + fDaughter[imatch].SetRefMC(daughter); + fDaughter[imatch].SetGood(); + index = FindTrack(label, mcEvent); + if (index > 0) { + fDaughter[imatch].SetRef(rsn->GetRef()->GetTrack(index)); + } + } + + // if both daughters were assigned, this means that the decay is correct + // and then we fill second step + if (fDaughter[0].IsOK() && fDaughter[1].IsOK()) { + GetOutput()->Fill(&fMother, 1); + for (istep = 0; istep < nsteps; istep++) { + AliRsnCutManager *cuts = (AliRsnCutManager*)fSteps[istep]; + if (!cuts->IsSelected(&fMother)) break; + GetOutput()->Fill(&fMother, 2 + istep); + } + } + } + + return count; +} diff --git a/PWG2/RESONANCES/AliRsnLoopEffPair.h b/PWG2/RESONANCES/AliRsnLoopEffPair.h new file mode 100644 index 00000000000..cc5a7693ab3 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEffPair.h @@ -0,0 +1,43 @@ +// +// Class AliRsnLoopEffPair +// +// Inherits from basic AliRsnAnalysisTaskEff for efficiency, +// and computed efficiencies for single-tracks +// +// author: Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) +// + +#ifndef ALIRSNLOOPEFFPAIR_H +#define ALIRSNLOOPEFFPAIR_H + +#include "AliRsnMother.h" +#include "AliRsnDaughter.h" +#include "AliRsnLoopEff.h" + +class AliRsnPairDef; + +class AliRsnLoopEffPair : public AliRsnLoopEff { + +public: + + AliRsnLoopEffPair(const char *name, AliRsnPairDef *def); + AliRsnLoopEffPair(const AliRsnLoopEffPair& copy); + AliRsnLoopEffPair& operator=(const AliRsnLoopEffPair& copy); + virtual ~AliRsnLoopEffPair() {;} + + AliRsnPairDef* GetDef() {return fDef;} + void SetDef(AliRsnPairDef *def) {fDef = def;} + virtual Int_t DoLoop(AliRsnEvent *main, AliRsnDaughterSelector *smain = 0, AliRsnEvent *mix = 0, AliRsnDaughterSelector *smix = 0); + +protected: + + AliRsnPairDef *fDef; // used pair definition + AliRsnMother fMother; //! check object (mother) + AliRsnDaughter fDaughter[2]; //! check object (daughter) + + ClassDef(AliRsnLoopEffPair, 1) +}; + +#endif + + diff --git a/PWG2/RESONANCES/AliRsnLoopEvent.cxx b/PWG2/RESONANCES/AliRsnLoopEvent.cxx new file mode 100644 index 00000000000..79e2e6cf4e6 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEvent.cxx @@ -0,0 +1,96 @@ +// +// Computator for single daughters. +// Implements a simple loop on tracks from one of the entry lists +// filled by the task AliRsnInputHandler, adding a check on their +// definition specified in the daughter def. +// + +#include "AliLog.h" + +#include "AliRsnEvent.h" + +#include "AliRsnLoopEvent.h" + +ClassImp(AliRsnLoopEvent) + +//_____________________________________________________________________________ +AliRsnLoopEvent::AliRsnLoopEvent(const char *name) : + AliRsnLoop(name) +{ +// +// Default constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoopEvent::AliRsnLoopEvent(const AliRsnLoopEvent& copy) : + AliRsnLoop(copy) +{ +// +// Copy constructor +// +} + +//_____________________________________________________________________________ +AliRsnLoopEvent& AliRsnLoopEvent::operator=(const AliRsnLoopEvent& copy) +{ +// +// Assignment operator +// + + AliRsnLoop::operator=(copy); + + return (*this); +} + +//_____________________________________________________________________________ +AliRsnLoopEvent::~AliRsnLoopEvent() +{ +// +// Destructor +// +} + +//_____________________________________________________________________________ +void AliRsnLoopEvent::Print(Option_t* /*option*/) const +{ +// +// Prints info about pair +// + + AliRsnLoop::Print(); +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopEvent::Init(const char *prefix, TList *list) +{ +// +// Initialization function. +// Loops on all functions and eventual the ntuple, to initialize output objects. +// + + return AliRsnLoop::Init(Form("%s_%s", prefix, GetName()), list); +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopEvent::DoLoop +(AliRsnEvent *evMain, AliRsnDaughterSelector *, AliRsnEvent *, AliRsnDaughterSelector *) +{ +// +// Loop function. +// Computes what is needed from passed events. +// Returns the number of pairs successfully processed. +// + + TObjArrayIter next(&fOutputs); + AliRsnListOutput *out = 0x0; + + // check cuts + if (!OkEvent(evMain)) return 0; + + while ( (out = (AliRsnListOutput*)next()) ) { + out->Fill(evMain); + } + + return 1; +} diff --git a/PWG2/RESONANCES/AliRsnLoopEvent.h b/PWG2/RESONANCES/AliRsnLoopEvent.h new file mode 100644 index 00000000000..46d577082a2 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopEvent.h @@ -0,0 +1,28 @@ +#ifndef ALIRSNLOOPEVENT_H +#define ALIRSNLOOPEVENT_H + +// +// Class for computations on events +// + +#include "AliRsnLoop.h" + +class AliRsnLoopEvent : public AliRsnLoop { +public: + + AliRsnLoopEvent(const char *name = "default"); + AliRsnLoopEvent(const AliRsnLoopEvent ©); + AliRsnLoopEvent& operator=(const AliRsnLoopEvent&); + ~AliRsnLoopEvent(); + + virtual void Print(Option_t *opt = "") const; + virtual Bool_t Init(const char *prefix, TList *list); + virtual Int_t DoLoop(AliRsnEvent *main, AliRsnDaughterSelector *smain = 0, AliRsnEvent *mix = 0, AliRsnDaughterSelector *smix = 0); + +private: + + ClassDef(AliRsnLoopEvent, 1) +}; + +#endif + diff --git a/PWG2/RESONANCES/AliRsnLoopPair.cxx b/PWG2/RESONANCES/AliRsnLoopPair.cxx new file mode 100644 index 00000000000..e94ebd92994 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopPair.cxx @@ -0,0 +1,253 @@ +// +// *** Class AliRsnLoopPair *** +// +// "Core" method for defining the work on a pari of particles. +// For one analysis, one must setup one of this for each pair he wants to analyze, +// adding to it all analysis which he desires to do. +// Here he defines the cuts, and the particle types and charges, and can add +// functions which do different operations on the same pair, and some binning +// with respect to some kinematic variables (eta, momentum) +// +// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) +// M. Vala (email: martin.vala@cern.ch) +// + +#include +#include + +#include "AliLog.h" + +#include "AliRsnMother.h" +#include "AliRsnCutSet.h" +#include "AliRsnDaughterSelector.h" + +#include "AliRsnLoopPair.h" + +ClassImp(AliRsnLoopPair) + +//_____________________________________________________________________________ +AliRsnLoopPair::AliRsnLoopPair(const char *name, AliRsnPairDef *def, Bool_t isMixed) : + AliRsnLoop(name, isMixed), + fOnlyTrue(kFALSE), + fCheckDecay(kFALSE), + fPairDef(def), + fPairCuts(0x0), + fMother() +{ +// +// Default constructor +// + + fListID[0] = -1; + fListID[1] = -1; +} + +//_____________________________________________________________________________ +AliRsnLoopPair::AliRsnLoopPair(const AliRsnLoopPair& copy) : + AliRsnLoop(copy), + fOnlyTrue(copy.fOnlyTrue), + fCheckDecay(copy.fCheckDecay), + fPairDef(copy.fPairDef), + fPairCuts(copy.fPairCuts), + fMother(copy.fMother) +{ +// +// Copy constructor +// + + fListID[0] = copy.fListID[0]; + fListID[1] = copy.fListID[1]; +} + +//_____________________________________________________________________________ +AliRsnLoopPair& AliRsnLoopPair::operator=(const AliRsnLoopPair& copy) +{ + AliRsnLoop::operator=(copy); + + fOnlyTrue = copy.fOnlyTrue; + fCheckDecay = copy.fCheckDecay; + fPairDef = copy.fPairDef; + fPairCuts = copy.fPairCuts; + fMother = copy.fMother; + fListID[0] = copy.fListID[0]; + fListID[1] = copy.fListID[1]; + + return (*this); +} + +//_____________________________________________________________________________ +AliRsnLoopPair::~AliRsnLoopPair() +{ +// +// Destructor +// +} + +//_____________________________________________________________________________ +void AliRsnLoopPair::Print(Option_t* /*option*/) const +{ +// +// Prints info about pair +// + + AliRsnLoop::Print(); +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopPair::Init(const char *prefix, TList *list) +{ +// +// Initialization function. +// Loops on all functions and eventual the ntuple, to initialize output objects. +// + + // assign data members relations + fMother.SetDaughter(0, &fDaughter[0]); + fMother.SetDaughter(1, &fDaughter[1]); + AliInfo(Form("[%s] Initialization", GetName())); + + TString name(prefix); + name += '_'; + name += GetName(); + if (IsMixed()) name.Prepend("mix_"); + + return AliRsnLoop::Init(name.Data(), list); +} + +//_____________________________________________________________________________ +Int_t AliRsnLoopPair::DoLoop +(AliRsnEvent *evMain, AliRsnDaughterSelector *selMain, AliRsnEvent *evMix, AliRsnDaughterSelector *selMix) +{ +// +// Loop function. +// Computes what is needed from passed events. +// Returns the number of pairs successfully processed. +// + + if (fIsMixed) { + AliDebugClass(1, Form("[%s]: event-mixing loop", GetName())); + if (!evMix || !selMix) { + AliError(Form("[%s] NULL mixed event when mixing is required: cannot process", GetName())); + return 0; + } + } else { + AliDebugClass(1, Form("[%s]: single-event loop", GetName())); + evMix = evMain; + selMix = selMain; + } + fMother.SetRefEvent(evMain); + + // check cuts + if (!OkEvent(evMain)) { + AliDebugClass(1, Form("[%s]: main event not accepted", GetName())); + return 0; + } + if (!OkEvent(evMix)) { + AliDebugClass(1, Form("[%s]: mixed event not accepted", GetName())); + return 0; + } + + Int_t i0, i1, start, npairs = 0; + + TEntryList *list0 = selMain->GetSelected(fListID[0], fPairDef->GetDef1().GetChargeC()); + TEntryList *list1 = selMix ->GetSelected(fListID[1], fPairDef->GetDef2().GetChargeC()); + if (!list0 || !list1) { + AliError("Can't process NULL lists"); + return 0; + } + AliDebugClass(2, Form("[%s]: list counts: %d, %d", GetName(), (Int_t)list0->GetN(), (Int_t)list1->GetN())); + if (!list0->GetN() || !list1->GetN()) { + AliDebugClass(2, Form("[%s]: at least one list is empty", GetName())); + return 0; + } + + TObjArrayIter next(&fOutputs); + AliRsnListOutput *out = 0x0; + + for (i0 = 0; i0 < list0->GetN(); i0++) { + evMain->SetDaughterAbs(fDaughter[0], (Int_t)list0->GetEntry(i0)); + start = 0; + if (!fDaughter[0].GetRef()) { + AliDebugClass(3, Form("[%s]: daughte #1 has NULL ref", GetName())); + continue; + } + if (!fDaughter[0].IsOK()) { + AliDebugClass(3, Form("[%s]: daughte #1 is BAD", GetName())); + continue; + } + if (!fIsMixed && list0 == list1) start = i0 + 1; + for (i1 = start; i1 < list1->GetN(); i1++) { + evMix->SetDaughterAbs(fDaughter[1], (Int_t)list1->GetEntry(i1)); + if (!fDaughter[1].GetRef()) { + AliDebugClass(3, Form("[%s]: daughte #2 has NULL ref", GetName())); + continue; + } + if (!fDaughter[1].IsOK()) { + AliDebugClass(3, Form("[%s]: daughte #2 is BAD", GetName())); + continue; + } + // check mother + if (!MotherOK()) { + AliDebugClass(2, Form("[%s]: candidate mother didn't pass the cuts", GetName())); + continue; + } + // fill outputs + next.Reset(); + while ( (out = (AliRsnListOutput*)next()) ) { + if (out->Fill(&fMother)) npairs++; + else AliDebugClass(3, Form("[%s]: failed computation", GetName())); + } + } + } + + return npairs; +} + +//_____________________________________________________________________________ +Bool_t AliRsnLoopPair::MotherOK() +{ +// +// Checks that first argument matches definitions for first daughter +// and the same for second argument, where the order is defined by +// the AliRsnPairDef data member. +// If the matching is successful, the AliRsnMother data member is +// initialized using the mass hypotheses defined here and the momenta +// in the passed daughters. +// The third argument is necessary to choose which one of the possible two +// events owning the two daughter will be used as reference. +// + + // check matching and exit if one of them fails + // if true pair is required, this is taken into account: + // if both true pairs and correct decay tree is required, + // then we must be sure that also the true PID of daughters matches, + // instead if correct decay tree is not required this additional check is not done + fPairDef->GetDef1().SetOnlyTrue(fOnlyTrue && fCheckDecay); + fPairDef->GetDef2().SetOnlyTrue(fOnlyTrue && fCheckDecay); + if (!fPairDef->GetDef1().MatchesDaughter(&fDaughter[0])) return kFALSE; + if (!fPairDef->GetDef2().MatchesDaughter(&fDaughter[1])) return kFALSE; + + // if matching is successful + // compute 4-momenta of daughters and mother + fMother.ComputeSum(fPairDef->GetDef1().GetMass(), fPairDef->GetDef2().GetMass()); + + // if required a true pair, check this here and eventually return a fail message + // this is done using the method AliRsnMother::CommonMother with 2 arguments + // passed by reference, where the real GEANT label of the particle is stored + // and one can check if these tracks are both really secondaries (ID >= 0) + if (fOnlyTrue) { + Int_t m0, m1, common; + common = fMother.CommonMother(m0, m1); + if (m0 < 0 || m1 < 0) return kFALSE; + if (common != fPairDef->GetMotherPDG()) return kFALSE; + } + + // point to first event as reference + // and checks the pair cuts, + // (done first because it is more likely + // that it is not passed and execution is faster) + if (fPairCuts) + return fPairCuts->IsSelected(&fMother); + else + return kTRUE; +} diff --git a/PWG2/RESONANCES/AliRsnLoopPair.h b/PWG2/RESONANCES/AliRsnLoopPair.h new file mode 100644 index 00000000000..29cf54027f0 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnLoopPair.h @@ -0,0 +1,57 @@ +#ifndef ALIRSNLOOPPAIR_H +#define ALIRSNLOOPPAIR_H + +// +// Class to combine pairs of daughters. +// + +#include "AliRsnPairDef.h" +#include "AliRsnLoop.h" + +class TList; + +class AliRsnLoopPair : public AliRsnLoop { +public: + + AliRsnLoopPair(const char *name = "default", AliRsnPairDef *def = 0, Bool_t isMixed = kFALSE); + AliRsnLoopPair(const AliRsnLoopPair ©); + AliRsnLoopPair& operator=(const AliRsnLoopPair&); + ~AliRsnLoopPair(); + + // getters + Bool_t IsOnlyTrue() const {return fOnlyTrue;} + Bool_t IsCheckDecay() const {return fCheckDecay;} + AliRsnPairDef* GetPairDef() {return fPairDef;} + AliRsnCutSet* GetPairCuts() {return fPairCuts;} + AliRsnMother* GetMother() {return &fMother;} + + // setters (not for all members) + void SetPairCuts(AliRsnCutSet *cuts) {fPairCuts = cuts;} + void SetOnlyTrue(Bool_t onlyTrue = kTRUE) {fOnlyTrue = onlyTrue;} + void SetCheckDecay(Bool_t check = kTRUE) {fCheckDecay = check;} + void SetListID(Int_t i, Int_t val) {if (i==0||i==1) fListID[i] = val;} + + // methods + Bool_t MotherOK(); + virtual void Print(Option_t *opt = "") const; + virtual Bool_t Init(const char *prefix, TList *list); + virtual Int_t DoLoop(AliRsnEvent *main, AliRsnDaughterSelector *smain, AliRsnEvent *mix = 0, AliRsnDaughterSelector *smix = 0); + +protected: + + Bool_t fOnlyTrue; // select true pairs only? + Bool_t fCheckDecay; // is the decay channel correct in a true pair? + Int_t fListID[2]; // indexes of the two entry lists to be used + + AliRsnPairDef *fPairDef; // pair definition + AliRsnCutSet *fPairCuts; // collection of all cuts + AliRsnMother fMother; //! mother candidate (to avoid creating it continuously) + AliRsnDaughter fDaughter[2]; //! daughter candidates + +private: + + ClassDef(AliRsnLoopPair, 2) +}; + +#endif + diff --git a/PWG2/RESONANCES/AliRsnMonitor.cxx b/PWG2/RESONANCES/AliRsnMonitor.cxx deleted file mode 100644 index 2f1ab8e0083..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitor.cxx +++ /dev/null @@ -1,132 +0,0 @@ -// -// *** Class AliRsnMonitor *** -// -// "Core" method for defining the work on a pari of particles. -// For one analysis, one must setup one of this for each pair he wants to analyze, -// adding to it all analysis which he desires to do. -// Here he defines the cuts, and the particle types and charges, and can add -// functions which do different operations on the same pair, and some binning -// with respect to some kinematic variables (eta, momentum) -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include "AliLog.h" - -#include "AliRsnTarget.h" -#include "AliRsnEvent.h" -#include "AliRsnValue.h" - -#include "AliRsnMonitor.h" - -ClassImp(AliRsnMonitor) - -//_____________________________________________________________________________ -AliRsnMonitor::AliRsnMonitor(const char *name, AliRsnDaughterDef *def) : - TNamed(name, ""), - fOnlyTrue(kFALSE), - fCount(0), - fDaughterDef(def), - fCuts(Form("cuts_%s", name), AliRsnTarget::kDaughter), - fDaughter(0) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnMonitor::AliRsnMonitor(const AliRsnMonitor& copy) : - TNamed(copy), - fOnlyTrue(copy.fOnlyTrue), - fCount(copy.fCount), - fDaughterDef(copy.fDaughterDef), - fCuts(copy.fCuts), - fDaughter(copy.fDaughter) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnMonitor& AliRsnMonitor::operator=(const AliRsnMonitor& copy) -{ - fOnlyTrue = copy.fOnlyTrue; - fCount = copy.fCount; - fCuts = copy.fCuts; - fDaughter = copy.fDaughter; - fDaughterDef = copy.fDaughterDef; - - return (*this); -} - -//_____________________________________________________________________________ -AliRsnMonitor::~AliRsnMonitor() -{ -// -// Destructor -// -} - -//_____________________________________________________________________________ -void AliRsnMonitor::Print(Option_t* /*option*/) const -{ -// -// Prints info about pair -// -} - -//_____________________________________________________________________________ -Bool_t AliRsnMonitor::Fill(AliRsnDaughter *daughter) -{ -// -// Sets the two passed daughters to the AliRsnMother data member of this object -// which is used to perform all computations to fill the value list. -// This operation is done successfully only when the first passed object matches -// the required object type (track/V0) and the required charge for first element in pair def, -// and the second passed object does the same w.r. to the second element in pair def. -// Moreover, all cuts are checked and the operation fails if a cut check is unsuccessful. -// Finally, if a true pair is required, this is checked at the end. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - // check match with prototype - // include check on true PID if required - if (!fDaughterDef->MatchesDaughter(daughter, fOnlyTrue)) return kFALSE; - - // if matching is successful - // update track data member and assigh default mass - fDaughter = daughter; - fDaughter->SetMass(fDaughterDef->GetMass()); - - // check the cuts - if (!fCuts.IsSelected(daughter)) return kFALSE; - - // if track is accepted increment counter - ++fCount; - - return kTRUE; -} - -//_____________________________________________________________________________ -void AliRsnMonitor::Compute() -{ -// -// Virtual method to compute pair quantities of interest -// - - AliWarning("Implement this method in derived classes"); -} - -//_____________________________________________________________________________ -void AliRsnMonitor::Init(const char* /*prefix*/, TList* /*list*/) -{ -// -// Virtual method to compute pair quantities of interest -// - - AliWarning("Implement this method in derived classes"); -} diff --git a/PWG2/RESONANCES/AliRsnMonitor.h b/PWG2/RESONANCES/AliRsnMonitor.h deleted file mode 100644 index 6b366c9a53c..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitor.h +++ /dev/null @@ -1,60 +0,0 @@ -// -// *** Class AliRsnMonitor *** -// -// TODO -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef ALIRSNMonitor_H -#define ALIRSNMonitor_H - -#include "TNamed.h" - -#include "AliRsnDaughter.h" -#include "AliRsnDaughterDef.h" -#include "AliRsnCutSet.h" - -class AliRsnMonitor : public TNamed { -public: - - AliRsnMonitor(const char *name = "default", AliRsnDaughterDef *def = 0); - AliRsnMonitor(const AliRsnMonitor ©); - AliRsnMonitor& operator=(const AliRsnMonitor&); - ~AliRsnMonitor(); - - // getters - Bool_t IsOnlyTrue() const {return fOnlyTrue;} - Int_t GetCount() const {return fCount;} - AliRsnDaughterDef* GetDaughterDef() {return fDaughterDef;} - AliRsnCutSet* GetCuts() {return &fCuts;} - AliRsnDaughter* GetDaughter() {return fDaughter;} - - // setters (not for all members) - void SetOnlyTrue(Bool_t onlyTrue = kTRUE) {fOnlyTrue = onlyTrue;} - void SetCount(Int_t count) {fCount = count;} - void ResetCount() {fCount = 0;} - - // methods - Bool_t Fill(AliRsnDaughter *d); - virtual void Print(Option_t *option = "") const; - virtual void Compute(); - virtual void Init(const char *prefix, TList *list); - -protected: - - Bool_t fOnlyTrue; // select true Monitors only? - Int_t fCount; // counter incremented for each added Monitor - - AliRsnDaughterDef *fDaughterDef; // Monitor definition (particles, charges) - AliRsnCutSet fCuts; // collection of all cuts - AliRsnDaughter *fDaughter; //! pointer to daughter - -private: - - ClassDef(AliRsnMonitor, 2) -}; - -#endif - diff --git a/PWG2/RESONANCES/AliRsnMonitorFunctions.cxx b/PWG2/RESONANCES/AliRsnMonitorFunctions.cxx deleted file mode 100644 index 5d49aef157a..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitorFunctions.cxx +++ /dev/null @@ -1,145 +0,0 @@ -// -// *** Class AliRsnMonitorFunctions *** -// -// "Core" method for defining the work on a pari of particles. -// For one analysis, one must setup one of this for each pair he wants to analyze, -// adding to it all analysis which he desires to do. -// Here he defines the cuts, and the particle types and charges, and can add -// functions which do different operations on the same pair, and some binning -// with respect to some kinematic variables (eta, momentum) -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include - -#include "AliLog.h" - -#include "AliRsnMother.h" -#include "AliRsnEvent.h" -#include "AliRsnFunction.h" -#include "AliRsnCutSet.h" -#include "AliRsnValue.h" - -#include "AliRsnMonitorFunctions.h" - -ClassImp(AliRsnMonitorFunctions) - -//_____________________________________________________________________________ -AliRsnMonitorFunctions::AliRsnMonitorFunctions(const char *name, AliRsnDaughterDef *def) : - AliRsnMonitor(name, def), - fFunctions("AliRsnFunction", 0) -{ -// -// Default constructor -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -AliRsnMonitorFunctions::AliRsnMonitorFunctions(const AliRsnMonitorFunctions& copy) : - AliRsnMonitor(copy), - fFunctions(copy.fFunctions) -{ -// -// Default constructor -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -AliRsnMonitorFunctions& AliRsnMonitorFunctions::operator=(const AliRsnMonitorFunctions& copy) -{ - AliRsnMonitor::operator=(copy); - - Int_t i, n = copy.fFunctions.GetEntries(); - for (i = 0; i < n; i++) { - AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i]; - if (fcn) AddFunction(fcn); - } - - return (*this); -} - -//_____________________________________________________________________________ -AliRsnMonitorFunctions::~AliRsnMonitorFunctions() -{ -// -// Destructor -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnMonitorFunctions::Compute() -{ -// -// Makes computations using the two passed daughter objects. -// Checks all cuts and then computes the corresponding pair object -// and then fill the list of required values using it. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - TObjArrayIter nextFcn(&fFunctions); - AliRsnFunction *fcn = 0x0; - - while ((fcn = (AliRsnFunction*)nextFcn())) { - fcn->Fill(fDaughter); - } - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnMonitorFunctions::Init(const char *prefix, TList *list) -{ -// -// Generates needed histograms, giving them a name based on -// the flags defined here, on the pair definition, and attaches -// a prefix to it, according to the argument. -// -// All generated histograms are stored into the output TList. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - Int_t i; - TString hName(""); - AliRsnFunction *fcn = 0; - for (i = 0; i < fFunctions.GetEntries(); i++) { - fcn = (AliRsnFunction*)fFunctions.At(i); - hName = prefix; - hName += '_'; - hName += GetName(); - hName += '_'; - hName += fcn->GetName(); - if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), "")); - else list->Add(fcn->CreateHistogramSparse(hName.Data(), "")); - } - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnMonitorFunctions::AddFunction(AliRsnFunction *const fcn) -{ -// -// Adds a new computing function -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - Int_t size = fFunctions.GetEntries(); - new(fFunctions[size]) AliRsnFunction(*fcn); - fFunctions.Print(); - - AliDebug(AliLog::kDebug + 2, "->"); -} diff --git a/PWG2/RESONANCES/AliRsnMonitorFunctions.h b/PWG2/RESONANCES/AliRsnMonitorFunctions.h deleted file mode 100644 index eaedcddab05..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitorFunctions.h +++ /dev/null @@ -1,38 +0,0 @@ -// -// *** Class AliRsnMonitorFunctions *** -// -// TODO -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef AliRsnMonitorFunctions_H -#define AliRsnMonitorFunctions_H - -#include "AliRsnMonitor.h" - -class AliRsnFunction; - -class AliRsnMonitorFunctions : public AliRsnMonitor { -public: - - AliRsnMonitorFunctions(const char *name = "default", AliRsnDaughterDef *def = 0); - AliRsnMonitorFunctions(const AliRsnMonitorFunctions ©); - AliRsnMonitorFunctions& operator=(const AliRsnMonitorFunctions&); - ~AliRsnMonitorFunctions(); - - void AddFunction(AliRsnFunction* const fcn); - TList* GenerateHistograms(const char *prefix = "", TList *list = 0); - virtual void Compute(); - virtual void Init(const char *prefix, TList *list); - -protected: - - TClonesArray fFunctions; // a list of functions which generate histograms - - ClassDef(AliRsnMonitorFunctions, 1) -}; - -#endif - diff --git a/PWG2/RESONANCES/AliRsnMonitorNtuple.cxx b/PWG2/RESONANCES/AliRsnMonitorNtuple.cxx deleted file mode 100644 index 84d27df7954..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitorNtuple.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// -// *** Class AliRsnMonitorNtuple *** -// -// "Core" method for defining the work on a pari of particles. -// For one analysis, one must setup one of this for each pair he wants to analyze, -// adding to it all analysis which he desires to do. -// Here he defines the cuts, and the particle types and charges, and can add -// functions which do different operations on the same pair, and some binning -// with respect to some kinematic variables (eta, momentum) -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include -#include - -#include "AliLog.h" - -#include "AliRsnMother.h" -#include "AliRsnEvent.h" -#include "AliRsnFunction.h" -#include "AliRsnCutSet.h" -#include "AliRsnValue.h" - -#include "AliRsnMonitorNtuple.h" - -ClassImp(AliRsnMonitorNtuple) - -//_____________________________________________________________________________ -AliRsnMonitorNtuple::AliRsnMonitorNtuple(const char *name, AliRsnDaughterDef *def) : - AliRsnMonitor(name, def), - fValues("AliRsnValue", 0), - fNtuple(0x0) -{ -// -// Default constructor -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -AliRsnMonitorNtuple::AliRsnMonitorNtuple(const AliRsnMonitorNtuple& copy) : - AliRsnMonitor(copy), - fValues(copy.fValues), - fNtuple(copy.fNtuple) -{ -// -// Default constructor -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -AliRsnMonitorNtuple& AliRsnMonitorNtuple::operator=(const AliRsnMonitorNtuple& copy) -{ - AliRsnMonitor::operator=(copy); - - Int_t i, n = copy.fValues.GetEntries(); - for (i = 0; i < n; i++) { - AliRsnValue *fcn = (AliRsnValue*)copy.fValues[i]; - if (fcn) AddValue(fcn); - } - - fNtuple = copy.fNtuple; - - return (*this); -} - -//_____________________________________________________________________________ -AliRsnMonitorNtuple::~AliRsnMonitorNtuple() -{ -// -// Destructor -// - - AliDebug(AliLog::kDebug + 2, "<-"); - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnMonitorNtuple::Compute() -{ -// -// Makes computations using the two passed daughter objects. -// Checks all cuts and then computes the corresponding pair object -// and then fill the list of required values using it. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - // compute all values - Int_t i, n = fValues.GetEntries(); - TArrayF values(n); - AliRsnValue *value = 0x0; - Bool_t computeOK = kFALSE, globalOK = kTRUE; - for (i = 0; i < n; i++) { - values[i] = -1E10; - value = (AliRsnValue*)fValues[i]; - switch (value->GetTargetType()) { - case AliRsnTarget::kDaughter: - computeOK = value->Eval(fDaughter); - break; - case AliRsnTarget::kEvent: - computeOK = value->Eval(fDaughter->GetOwnerEvent()); - break; - default: - AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", value->GetName(), value->GetTargetTypeName())); - computeOK = kFALSE; - } - if (computeOK) - values[i] = ((Float_t)value->GetComputedValue()); - else - globalOK = kFALSE; - } - - if (globalOK) fNtuple->Fill(values.GetArray()); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnMonitorNtuple::Init(const char *prefix, TList *list) -{ -// -// Generates needed histograms, giving them a name based on -// the flags defined here, on the pair definition, and attaches -// a prefix to it, according to the argument. -// -// All generated histograms are stored into the output TList. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - TString nameList(""); - - Int_t i, n = fValues.GetEntries(); - AliRsnValue *val = 0; - for (i = 0; i < n; i++) { - val = (AliRsnValue*)fValues.At(i); - nameList += val->GetName(); - if (i < n - 1) nameList += ':'; - } - - if (fNtuple) delete fNtuple; - fNtuple = new TNtuple(Form("%sntp%s", prefix, GetName()), "", nameList.Data()); - if (list) list->Add(fNtuple); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -Bool_t AliRsnMonitorNtuple::AddValue(AliRsnValue *const val) -{ -// -// Adds a new computing function. -// - - RSNTARGET target = val->GetTargetType(); - if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) { - AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", val->GetName(), val->GetTargetTypeName())); - return kFALSE; - } - - Int_t size = fValues.GetEntries(); - new(fValues[size]) AliRsnValue(*val); - - return kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnMonitorNtuple.h b/PWG2/RESONANCES/AliRsnMonitorNtuple.h deleted file mode 100644 index eb6afb9d80c..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitorNtuple.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// *** Class AliRsnMonitorNtuple *** -// -// TODO -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef AliRsnMonitorNtuple_H -#define AliRsnMonitorNtuple_H - -#include "AliRsnMonitor.h" - -class TList; -class TNtuple; - -class AliRsnMonitorNtuple : public AliRsnMonitor { -public: - - AliRsnMonitorNtuple(const char *name = "default", AliRsnDaughterDef *def = 0); - AliRsnMonitorNtuple(const AliRsnMonitorNtuple ©); - AliRsnMonitorNtuple& operator=(const AliRsnMonitorNtuple&); - ~AliRsnMonitorNtuple(); - - Bool_t AddValue(AliRsnValue*const val); - void GenerateNtuple(const char *prefix = "", TList *list = 0); - virtual void Compute(); - virtual void Init(const char *prefix, TList *list); - -private: - - TClonesArray fValues; // single values computed from analyzed objects - TNtuple *fNtuple; // ntuple computed with values - - ClassDef(AliRsnMonitorNtuple, 2) -}; - -#endif - diff --git a/PWG2/RESONANCES/AliRsnMonitorTrack.cxx b/PWG2/RESONANCES/AliRsnMonitorTrack.cxx deleted file mode 100644 index 067bdfa7a2b..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitorTrack.cxx +++ /dev/null @@ -1,167 +0,0 @@ -#include - -#include "AliLog.h" -#include "AliStack.h" -#include "AliESDtrack.h" -#include "AliTOFT0maker.h" - -#include "AliRsnMonitorTrack.h" - -ClassImp(AliRsnMonitorTrack) - -AliRsnMonitorTrack::AliRsnMonitorTrack() : - fCutsPassed(kFALSE), - fPrim(kFALSE), - fPDG(0), - fPDGM(0), - fMother(-1), - fStatus(0), - fLength(0.0), - fCharge(0), - fITSsa(kFALSE), - fTOFok(kFALSE), - fITSchi2(1E10), - fITSsignal(0.0), - fTPCcount(0), - fTPCchi2(1E10), - fTPCsignal(1E10), - fTOFsignal(0.0) -{ -// -// Unique constructor -// - - Int_t k; - - for (k = 0; k < 2; k++) fDCA[k] = 0.0; - for (k = 0; k < 6; k++) fITSmap[k] = 0; - for (k = 0; k < AliPID::kSPECIES; k++) { - fITSnsigma[k] = 0.0; - fTPCnsigma[k] = 0.0; - fTOFref [k] = 0.0; - fTOFsigma [k] = 0.0; - } - for (k = 0; k < 3; k++) { - fPsim[k] = 0.0; - fPrec[k] = 0.0; - fPtpc[k] = 0.0; - } -} - -AliRsnMonitorTrack::AliRsnMonitorTrack(const AliRsnMonitorTrack& copy) : - TObject(copy), - fCutsPassed(copy.fCutsPassed), - fPrim(copy.fPrim), - fPDG(copy.fPDG), - fPDGM(copy.fPDGM), - fMother(copy.fMother), - fStatus(copy.fStatus), - fLength(copy.fLength), - fCharge(copy.fCharge), - fITSsa(copy.fITSsa), - fTOFok(copy.fTOFok), - fITSchi2(copy.fITSchi2), - fITSsignal(copy.fITSsignal), - fTPCcount(copy.fTPCcount), - fTPCchi2(copy.fTPCchi2), - fTPCsignal(copy.fTPCsignal), - fTOFsignal(copy.fTOFsignal) -{ -// -// Copy constructor -// - - Int_t k; - - for (k = 0; k < 2; k++) fDCA[k] = copy.fDCA[k]; - for (k = 0; k < 6; k++) fITSmap[k] = copy.fITSmap[k]; - for (k = 0; k < AliPID::kSPECIES; k++) { - fITSnsigma[k] = copy.fITSnsigma[k]; - fTPCnsigma[k] = copy.fTPCnsigma[k]; - fTOFref [k] = copy.fTOFref [k]; - fTOFsigma [k] = copy.fTOFsigma [k]; - } - for (k = 0; k < 3; k++) { - fPsim[k] = copy.fPsim[k]; - fPrec[k] = copy.fPrec[k]; - fPtpc[k] = copy.fPtpc[k]; - } -} - -//_____________________________________________________________________________________________ -void AliRsnMonitorTrack::Reset() -{ -// -// Generic reset method, to set all fields to meaningless values -// - - Int_t k; - - fCutsPassed = kFALSE; - fITSsa = kFALSE; - fTOFok = kFALSE; - fPrim = kFALSE; - fPDG = 0; - fMother = -1; - fPDGM = 0; - fStatus = 0; - fLength = 0.0; - fCharge = 0; - - for (k = 0; k < 2; k++) fDCA[k] = 1E10; - - for (k = 0; k < 6; k++) fITSmap[k] = kFALSE; - fITSchi2 = 1E10; - fITSsignal = 0.0; - - fTPCchi2 = 1E10; - fTPCsignal = 1E10; - fTPCcount = 0; - - fTOFsignal = 1E10; - - for (k = 0; k < AliPID::kSPECIES; k++) { - fITSnsigma[k] = 1E10; - fTPCnsigma[k] = 1E10; - fTOFref [k] = 1E10; - fTOFsigma [k] = 1E10; - } - - for (k = 0; k < 3; k++) fPsim[k] = fPrec[k] = fPtpc[k] = 0.0; -} - -//__________________________________________________________________________________________________ -Bool_t AliRsnMonitorTrack::AdoptMC(Int_t label, AliStack *stack) -{ -// -// Get info from MC for a given track in the stack -// - - if (!stack) return kFALSE; - - Int_t nPart = stack->GetNtrack(); - if (label < 0 || label > nPart) { - AliError(Form("Label = %d -- MAX = %d", label, nPart)); - return kFALSE; - } - - TParticle *mc = stack->Particle(label); - if (!mc) return kFALSE; - - // 'direct' data - fPDG = (Int_t)mc->GetPdgCode(); - fMother = (Int_t)mc->GetFirstMother(); - fPrim = (Bool_t)stack->IsPhysicalPrimary(label); - fPDGM = 0; - fPsim[0] = mc->Px(); - fPsim[1] = mc->Py(); - fPsim[2] = mc->Pz(); - - // assign mother (if any) - if (fMother >= 0 && fMother < nPart) { - TParticle *m = stack->Particle(fMother); - if (m) fPDGM = (Int_t)TMath::Abs(m->GetPdgCode()); - } - - return kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnMonitorTrack.h b/PWG2/RESONANCES/AliRsnMonitorTrack.h deleted file mode 100644 index 9d4c62a140d..00000000000 --- a/PWG2/RESONANCES/AliRsnMonitorTrack.h +++ /dev/null @@ -1,125 +0,0 @@ -// -// Class AliRsnMonitorTrack -// -// Monitor object used -// for storing info ina TTree -// and studying cut values and variables. -// -// author: A. Pulvirenti -// - -#ifndef ALIRSNMONITORTRACK_H -#define ALIRSNMONITORTRACK_H - -#include "AliPID.h" - -class AliESDtrack; -class AliTOFT0maker; -class AliStack; - -class AliRsnMonitorTrack : public TObject { -public: - - AliRsnMonitorTrack(); - AliRsnMonitorTrack(const AliRsnMonitorTrack& copy); - //AliRsnMonitorTrack& operator=(const AliRsnMonitorTrack& copy) {MakeCopy(copy); return (*this);} - virtual ~AliRsnMonitorTrack() { /*nothing*/ } - - void Reset(); - Bool_t AdoptMC(Int_t label, AliStack *stack); - - Bool_t& CutsPassed() {return fCutsPassed;} - - Double_t& PsimX() {return fPsim[0];} - Double_t& PrecX() {return fPrec[0];} - Double_t& PtpcX() {return fPtpc[0];} - - Double_t& PsimY() {return fPsim[1];} - Double_t& PrecY() {return fPrec[1];} - Double_t& PtpcY() {return fPtpc[1];} - - Double_t& PsimZ() {return fPsim[2];} - Double_t& PrecZ() {return fPrec[2];} - Double_t& PtpcZ() {return fPtpc[2];} - - Double_t PsimT() {return TMath::Sqrt(fPsim[0] * fPsim[0] + fPsim[1] * fPsim[1]);} - Double_t PrecT() {return TMath::Sqrt(fPrec[0] * fPrec[0] + fPrec[1] * fPrec[1]);} - Double_t PtpcT() {return TMath::Sqrt(fPtpc[0] * fPtpc[0] + fPtpc[1] * fPtpc[1]);} - - Double_t Psim() {return TMath::Sqrt(PsimT() * PsimT() + fPsim[2] * fPsim[2]);} - Double_t Prec() {return TMath::Sqrt(PrecT() * PrecT() + fPrec[2] * fPrec[2]);} - Double_t Ptpc() {return TMath::Sqrt(PtpcT() * PtpcT() + fPtpc[2] * fPtpc[2]);} - - Bool_t& Prim() {return fPrim;} - Int_t& PDG() {return fPDG;} - Int_t& PDGM() {return fPDGM;} - Int_t& Mother() {return fMother;} - - Bool_t OkFlag(UInt_t f) {return ((fStatus & f) != 0);} - UInt_t& Status() {return fStatus;} - Double_t& Length() {return fLength;} - Int_t& Charge() {return fCharge;} - Double_t& DCAr() {return fDCA[0];} - Double_t& DCAz() {return fDCA[1];} - - Bool_t& ITSsa() {return fITSsa;} - Bool_t& TOFok() {return fTOFok;} - - Bool_t& ITSmap(Int_t i) {if (i >= 0 && i < 6) return fITSmap[i]; else return fITSmap[0];} - Int_t ITScount() {return (SPDcount() + SDDcount() + SSDcount());} - Int_t SPDcount() {Int_t count = 0; if (fITSmap[0]) count++; if (fITSmap[1]) count++; return count;} - Int_t SDDcount() {Int_t count = 0; if (fITSmap[2]) count++; if (fITSmap[3]) count++; return count;} - Int_t SSDcount() {Int_t count = 0; if (fITSmap[4]) count++; if (fITSmap[5]) count++; return count;} - Double_t& ITSchi2() {return fITSchi2;} - Double_t& ITSsignal() {return fITSsignal;} - Double_t& ITSnsigma(Int_t i) {if (i >= 0 && i < AliPID::kSPECIES) return fITSnsigma[i]; else return fITSnsigma[0];} - - Int_t& TPCcount() {return fTPCcount;} - Double_t& TPCchi2() {return fTPCchi2;} - Double_t& TPCsignal() {return fTPCsignal;} - Double_t& TPCnsigma(Int_t i) {if (i >= 0 && i < AliPID::kSPECIES) return fTPCnsigma[i]; else return fTPCnsigma[0];} - - Double_t& TOFsignal() {return fTOFsignal;} - Double_t& TOFsigma(Int_t i) {if (i >= 0 && i < AliPID::kSPECIES) return fTOFsigma[i]; else return fTOFsigma[0];} - Double_t& TOFref(Int_t i) {if (i >= 0 && i < AliPID::kSPECIES) return fTOFref[i]; else return fTOFref[0];} - Double_t TOFnsigma(Int_t i) {if (i >= 0 && i < AliPID::kSPECIES) return ((fTOFsignal - fTOFref[i]) / fTOFsigma[i]); return 1E6;} - -private: - - Bool_t fCutsPassed; // did it pass all defined cuts? - - Bool_t fPrim; // is physical primary? - Int_t fPDG; // true PDG code - Int_t fPDGM; // PDG code of mother (if any) - Int_t fMother; // label of mother (if any) - - UInt_t fStatus; // 'status' flag of track in ESD (0 = none) - Double_t fLength; // integrated length - Int_t fCharge; // track charge - Double_t fDCA[2]; // DCA ([0] = xy, [1] = z) - - Bool_t fITSsa; // to know if its is ITS standalone (otherwise it is TPC) - Bool_t fTOFok; // to know if track has a TOF match - - Bool_t fITSmap[6]; // ITS cluster map - Double_t fITSchi2; // chi2 in ITS - Double_t fITSsignal; // ITS signal used for PID - Double_t fITSnsigma[AliPID::kSPECIES]; // number of sigmas ITS - - Int_t fTPCcount; // # TPC clusters - Double_t fTPCchi2; // TPC chi 2 - Double_t fTPCsignal; // TPC dEdx signal - Double_t fTPCnsigma[AliPID::kSPECIES]; // number of sigmas TPC for: e, mu, pi, K, p - - Double_t fTOFsignal; // TOF signal - Double_t fTOFsigma[AliPID::kSPECIES]; // TOF sigma for: e, mu, pi, K, p - Double_t fTOFref[AliPID::kSPECIES]; // expected times for: e, mu, pi, K, p - - Double_t fPsim[3]; // simulated momentum - Double_t fPrec[3]; // reconstructed momentum - Double_t fPtpc[3]; // reconstructed momentum at the TPC inner wall - - ClassDef(AliRsnMonitorTrack, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnPIDManager.cxx b/PWG2/RESONANCES/AliRsnPIDManager.cxx new file mode 100644 index 00000000000..9d817cf6963 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnPIDManager.cxx @@ -0,0 +1,120 @@ +#include + +#include "AliLog.h" +#include "AliPID.h" + +#include "AliRsnCutSet.h" + +#include "AliRsnPIDManager.h" + +ClassImp(AliRsnPIDManager) + +//_____________________________________________________________________________ +AliRsnPIDManager::AliRsnPIDManager(const char *name, const char *title) : TNamed(name, title) +{ +// +// Default constructor. +// + AliDebug(AliLog::kDebug + 10, "<-"); + AliDebug(AliLog::kDebug + 10, "->"); +} + +//_____________________________________________________________________________ +AliRsnPIDManager::~AliRsnPIDManager() +{ + // + // Destructor + // + AliDebug(AliLog::kDebug + 10, "<-"); + for (Int_t iCharge = 0; iCharge < 2; iCharge++) fIdParticles[iCharge].Delete(); + AliDebug(AliLog::kDebug + 10, "->"); +} + +void AliRsnPIDManager::Print(Option_t* option) const +{ + TNamed::Print(option); + + TEntryList *el; + AliRsnCutSet *cut; + for (Int_t iCharge = 0; iCharge < 2; iCharge++) { + for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) { + cut = (AliRsnCutSet*) fCuts.At(iParticle); + if (!cut) continue; + el = (TEntryList*)fIdParticles[iCharge].At(iParticle); + if (el) AliInfo(Form("%d %d %lld %s", iCharge, iParticle, el->GetN(), cut->GetName())); + } + } +} + +void AliRsnPIDManager::Init() +{ + for (Int_t iCharge = 0; iCharge < 2; iCharge++) { + for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) { + fIdParticles[iCharge].Add(new TEntryList()); +// fCuts.Add(new AliRsnCutSet("", AliRsnTarget::kDaughter)); + } + } +} + + +void AliRsnPIDManager::Reset() +{ + TEntryList *el; + for (Int_t iCharge = 0; iCharge < 2; iCharge++) { + for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) { + el = (TEntryList*)fIdParticles[iCharge].At(iParticle); + el->Reset(); + } + } +} + + +TEntryList* AliRsnPIDManager::GetParticles(const Int_t& charge, const Int_t& pidId) +{ + return (TEntryList*)fIdParticles[charge].At(pidId); +} + +void AliRsnPIDManager::SetCut(AliRsnCutSet*cut, const Int_t& pidId) +{ + if (!cut) return; + if (!fCuts.GetEntriesFast()) Init(); + fCuts.AddAt(cut, pidId); +} + +void AliRsnPIDManager::ApplyCuts(AliRsnEvent* ev) +{ + + // Loop over event and add entruies to entry list + Int_t numTracks = ev->GetRefESD()->GetNumberOfTracks(); + Int_t iTrack; + AliRsnDaughter daughter; + for (iTrack = 0; iTrack < numTracks; iTrack++) { + ev->SetDaughter(daughter, iTrack, AliRsnDaughter::kTrack); + daughter.SetRsnID(iTrack); + CheckTrack(&daughter, iTrack); + } + +} + +void AliRsnPIDManager::CheckTrack(AliRsnDaughter* d, const Int_t & id) +{ + TEntryList *el; + AliRsnCutSet *cut; + TString cutName; + for (Int_t iParticle = 0; iParticle < AliPID::kSPECIES; iParticle++) { + + cut = (AliRsnCutSet*) fCuts.At(iParticle); + if (!cut) continue; + cutName = cut->GetName(); + if (!cutName.IsNull()) { + if (!cut->IsSelected(d)) continue; + if (d->IsPos()) { + el = (TEntryList*)fIdParticles[0].At(iParticle); + el->Enter(id); + } else if (d->IsNeg()) { + el = (TEntryList*)fIdParticles[1].At(iParticle); + el->Enter(id); + } + } + } +} diff --git a/PWG2/RESONANCES/AliRsnPIDManager.h b/PWG2/RESONANCES/AliRsnPIDManager.h new file mode 100644 index 00000000000..2936ad00331 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnPIDManager.h @@ -0,0 +1,40 @@ +#ifndef ALIRSNPIDMANAGER_H +#define ALIRSNPIDMANAGER_H + +#include "TNamed.h" +#include + +class AliRsnDaughter; +class AliRsnCutSet; +class TEntryList; +class AliRsnEvent; +class AliRsnPIDManager : public TNamed { + +public: + AliRsnPIDManager(const char *name = "name", const char *title = "title"); + virtual ~AliRsnPIDManager(); + + virtual void Print(Option_t* option = "") const; + void Init(); + void Reset(); + + void SetCut(AliRsnCutSet* cut, const Int_t& pidId); + TEntryList *GetParticles(const Int_t &charge, const Int_t &pidId); + + void ApplyCuts(AliRsnEvent*ev); + +private: + + TObjArray fIdParticles[2]; + TObjArray fCuts; + + + void CheckTrack(AliRsnDaughter* d, const Int_t& id); + + AliRsnPIDManager(const AliRsnPIDManager& copy); + AliRsnPIDManager &operator=(const AliRsnPIDManager ©); + + ClassDef(AliRsnPIDManager, 1) +}; + +#endif diff --git a/PWG2/RESONANCES/AliRsnPair.cxx b/PWG2/RESONANCES/AliRsnPair.cxx deleted file mode 100644 index cbaf2b00b03..00000000000 --- a/PWG2/RESONANCES/AliRsnPair.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// -// *** Class AliRsnPair *** -// -// "Core" method for defining the work on a pari of particles. -// For one analysis, one must setup one of this for each pair he wants to analyze, -// adding to it all analysis which he desires to do. -// Here he defines the cuts, and the particle types and charges, and can add -// functions which do different operations on the same pair, and some binning -// with respect to some kinematic variables (eta, momentum) -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include - -#include "AliLog.h" - -#include "AliRsnMother.h" -#include "AliRsnCutSet.h" - -#include "AliRsnPair.h" - -ClassImp(AliRsnPair) - -//_____________________________________________________________________________ -AliRsnPair::AliRsnPair(const char *name, AliRsnPairDef *def) : - TNamed(name, ""), - fOnlyTrue(kFALSE), - fCheckDecay(kFALSE), - fIsMixed(kFALSE), - fCount(0), - fPairDef(def), - fCutManager(Form("cutMgr_%s", name)), - fMother() -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnPair::AliRsnPair(const AliRsnPair& copy) : - TNamed(copy), - fOnlyTrue(copy.fOnlyTrue), - fCheckDecay(copy.fCheckDecay), - fIsMixed(copy.fIsMixed), - fCount(copy.fCount), - fPairDef(copy.fPairDef), - fCutManager(copy.fCutManager), - fMother(copy.fMother) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnPair& AliRsnPair::operator=(const AliRsnPair& copy) -{ - fOnlyTrue = copy.fOnlyTrue; - fCheckDecay = copy.fCheckDecay; - fIsMixed = copy.fIsMixed; - fCount = copy.fCount; - fPairDef = copy.fPairDef; - fMother = copy.fMother; - fCutManager = copy.fCutManager; - - return (*this); -} - -//_____________________________________________________________________________ -AliRsnPair::~AliRsnPair() -{ -// -// Destructor -// -} - -//_____________________________________________________________________________ -void AliRsnPair::Print(Option_t* /*option*/) const -{ -// -// Prints info about pair -// -} - -//_____________________________________________________________________________ -Bool_t AliRsnPair::Fill -(AliRsnDaughter *daughter1, AliRsnDaughter *daughter2, Bool_t refFirst) -{ -// -// Checks that first argument matches definitions for first daughter -// and the same for second argument, where the order is defined by -// the AliRsnPairDef data member. -// If the matching is successful, the AliRsnMother data member is -// initialized using the mass hypotheses defined here and the momenta -// in the passed daughters. -// The third argument is necessary to choose which one of the possible two -// events owning the two daughter will be used as reference. -// - - // check matching and exit if one of them fails - // if true pair is required, this is taken into account: - // if both true pairs and correct decay tree is required, - // then we must be sure that also the true PID of daughters matches, - // instead if correct decay tree is not required this additional check is not done - if (!fPairDef->GetDef1()->MatchesDaughter(daughter1, fOnlyTrue && fCheckDecay)) return kFALSE; - if (!fPairDef->GetDef2()->MatchesDaughter(daughter2, fOnlyTrue && fCheckDecay)) return kFALSE; - - // if matching is successful - // compute 4-momenta of daughters and mother - fMother.SetDaughter(0, daughter1); - fMother.SetDaughter(1, daughter2); - fMother.ComputeSum(fPairDef->GetMass1(), fPairDef->GetMass2()); - - // assign reference event - if (refFirst) fMother.SetRefEvent(daughter1->GetOwnerEvent()); else fMother.SetRefEvent(daughter2->GetOwnerEvent()); - - // if required a true pair, check this here and eventually return a fail message - // this is done using the method AliRsnMother::CommonMother with 2 arguments - // passed by reference, where the real GEANT label of the particle is stored - // and one can check if these tracks are both really secondaries (ID >= 0) - if (fOnlyTrue) { - Int_t m0, m1, common; - common = fMother.CommonMother(m0, m1); - if (m0 < 0 || m1 < 0) return kFALSE; - if (common != fPairDef->GetMotherPDG()) return kFALSE; - } - - // point to first event as reference - // and checks the pair cuts, - // (done first because it is more likely - // that it is not passed and execution is faster) - if (!fCutManager.PassMotherCuts(&fMother)) return kFALSE; - - // cuts on track #1 & common - if (!fCutManager.PassDaughter1Cuts(daughter1)) { - AliDebug(AliLog::kDebug + 2, "Specific cuts for track #1 not passed"); - return kFALSE; - } - if (!fCutManager.PassCommonDaughterCuts(daughter1)) { - AliDebug(AliLog::kDebug + 2, "Common cuts for track #1 not passed"); - return kFALSE; - } - - // cuts on track #2 & common - if (!fCutManager.PassDaughter2Cuts(daughter2)) { - AliDebug(AliLog::kDebug + 2, "Specific cuts for track #2 not passed"); - return kFALSE; - } - if (!fCutManager.PassCommonDaughterCuts(daughter2)) { - AliDebug(AliLog::kDebug + 2, "Common cuts for track #2 not passed"); - return kFALSE; - } - - // if pair is accepted, increment counter - ++fCount; - - return kTRUE; -} - -//_____________________________________________________________________________ -void AliRsnPair::Compute() -{ -// -// Virtual method to compute pair quantities of interest -// - - AliWarning("Implement this method in derived classes"); -} - -//_____________________________________________________________________________ -void AliRsnPair::Init(const char* /*prefix*/, TList* /*list*/) -{ -// -// Virtual method to compute pair quantities of interest -// - - AliWarning("Implement this method in derived classes"); -} diff --git a/PWG2/RESONANCES/AliRsnPair.h b/PWG2/RESONANCES/AliRsnPair.h deleted file mode 100644 index 926d7465fff..00000000000 --- a/PWG2/RESONANCES/AliRsnPair.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// *** Class AliRsnPair *** -// -// TODO -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef ALIRSNPAIR_H -#define ALIRSNPAIR_H - -#include "TNamed.h" - -#include "AliRsnPairDef.h" -#include "AliRsnCutManager.h" -#include "AliRsnMother.h" - -class TList; - -class AliRsnPair : public TNamed { -public: - - AliRsnPair(const char *name = "default", AliRsnPairDef *def = 0); - AliRsnPair(const AliRsnPair ©); - AliRsnPair& operator=(const AliRsnPair&); - ~AliRsnPair(); - - // getters - Bool_t IsOnlyTrue() const {return fOnlyTrue;} - Bool_t IsCheckDecay() const {return fCheckDecay;} - Bool_t IsMixed() const {return fIsMixed;} - Int_t GetCount() const {return fCount;} - AliRsnPairDef* GetPairDef() {return fPairDef;} - AliRsnCutManager* GetCutManager() {return &fCutManager;} - AliRsnMother* GetMother() {return &fMother;} - - // shortcuts to data-member getters - AliRsnCutSet* GetCommonDaughterCuts() {return fCutManager.GetCommonDaughterCuts();} - AliRsnCutSet* GetDaughter1Cuts() {return fCutManager.GetDaughter1Cuts();} - AliRsnCutSet* GetDaughter2Cuts() {return fCutManager.GetDaughter2Cuts();} - AliRsnCutSet* GetMotherCuts() {return fCutManager.GetMotherCuts();} - - // setters (not for all members) - void SetOnlyTrue(Bool_t onlyTrue = kTRUE) {fOnlyTrue = onlyTrue;} - void SetCheckDecay(Bool_t check = kTRUE) {fCheckDecay = check;} - void SetMixed(Bool_t doit = kTRUE) {fIsMixed = doit;} - void SetCount(Int_t count) {fCount = count;} - void ResetCount() {fCount = 0;} - - // methods - Bool_t Fill(AliRsnDaughter *d0, AliRsnDaughter *d1, Bool_t refFirst = kTRUE); - virtual void Print(Option_t *option = "") const; - virtual void Compute(); - virtual void Init(const char *prefix, TList *list); - -protected: - - Bool_t fOnlyTrue; // select true pairs only? - Bool_t fCheckDecay; // is the decay channel correct in a true pair? - Bool_t fIsMixed; // is this an event-mixing? - Int_t fCount; // counter incremented for each added pair - - AliRsnPairDef *fPairDef; // pair definition (particles, charges) - AliRsnCutManager fCutManager; // collection of all cuts - AliRsnMother fMother; // mother candidate (to avoid creating it continuously) - -private: - - ClassDef(AliRsnPair, 2) -}; - -#endif - diff --git a/PWG2/RESONANCES/AliRsnPairDef.cxx b/PWG2/RESONANCES/AliRsnPairDef.cxx index 24a666f8f3e..1eb34aa8a42 100644 --- a/PWG2/RESONANCES/AliRsnPairDef.cxx +++ b/PWG2/RESONANCES/AliRsnPairDef.cxx @@ -40,46 +40,46 @@ ClassImp(AliRsnPairDef) //_____________________________________________________________________________ -AliRsnPairDef::AliRsnPairDef() : fMotherMass(0.0), fMotherPDG(0), fDef1(), fDef2() +AliRsnPairDef::AliRsnPairDef() : + fMotherMass(0.0), + fMotherPDG(0), + fDef1(), + fDef2() { // -// Empty constructor. -// Initializes the data members to default values: -// - no definition of particles in the pair; -// - histogram binning undefined. -// When using this constructor, all analysis elements (particles, histogram) -// must be defined before starting event processing. +// Constructor. +// If the two pointers are well initialized, they are used to init the members. // } //_____________________________________________________________________________ AliRsnPairDef::AliRsnPairDef -(EPARTYPE type1, Char_t sign1, EPARTYPE type2, Char_t sign2, Int_t motherPDG, Double_t motherMass) : - fMotherMass(motherMass), - fMotherPDG(motherPDG), - fDef1(AliRsnDaughter::FromAliPID(type1), sign1), - fDef2(AliRsnDaughter::FromAliPID(type2), sign2) +(EPARTYPE type1, Char_t ch1, EPARTYPE type2, Char_t ch2, Int_t pdg, Double_t mass) : + fMotherMass(mass), + fMotherPDG(pdg), + fDef1(type1, ch1), + fDef2(type2, ch2) { // -// Constructor with arguments. -// This constructor allows to define all the working parameters. +// Constructor. +// If the two pointers are well initialized, they are used to init the members. // } //_____________________________________________________________________________ AliRsnPairDef::AliRsnPairDef -(AliRsnDaughter::ESpecies type1, Char_t sign1, AliRsnDaughter::ESpecies type2, Char_t sign2, Int_t motherPDG, Double_t motherMass) : - fMotherMass(motherMass), - fMotherPDG(motherPDG), - fDef1(type1, sign1), - fDef2(type2, sign2) +(AliRsnDaughter::ESpecies type1, Char_t ch1, AliRsnDaughter::ESpecies type2, Char_t ch2, Int_t pdg, Double_t mass) : + fMotherMass(mass), + fMotherPDG(pdg), + fDef1(type1, ch1), + fDef2(type2, ch2) { // -// Constructor with arguments. -// This constructor allows to define all the working parameters. +// Constructor. +// If the two pointers are well initialized, they are used to init the members. // } - + //_____________________________________________________________________________ AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef ©) : TObject(copy), @@ -107,14 +107,3 @@ const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef ©) return (*this); } - -//_____________________________________________________________________________ -const char* AliRsnPairDef::GetPairName() const -{ -// -// Returns a compact string with the name of the pair, -// to be used for naming objects related to it. -// - - return Form("%s%s", fDef1.GetName(), fDef2.GetName()); -} diff --git a/PWG2/RESONANCES/AliRsnPairDef.h b/PWG2/RESONANCES/AliRsnPairDef.h index ad2945f7f51..c3ba2db2956 100644 --- a/PWG2/RESONANCES/AliRsnPairDef.h +++ b/PWG2/RESONANCES/AliRsnPairDef.h @@ -17,53 +17,27 @@ class AliRsnPairDef : public TObject { public: AliRsnPairDef(); - AliRsnPairDef(EPARTYPE type1, Char_t sign1, EPARTYPE type2, Char_t sign2, Int_t motherPDG = 0, Double_t motherMass = 0.0); - AliRsnPairDef(AliRsnDaughter::ESpecies type1, Char_t sign1, AliRsnDaughter::ESpecies type2, Char_t sign2, Int_t motherPDG = 0, Double_t motherMass = 0.0); + AliRsnPairDef(EPARTYPE type1, Char_t ch1, EPARTYPE type2, Char_t ch2, Int_t motherPDG = 0, Double_t motherMass = 0.0); + AliRsnPairDef(AliRsnDaughter::ESpecies type1, Char_t ch1, AliRsnDaughter::ESpecies type2, Char_t ch2, Int_t motherPDG = 0, Double_t motherMass = 0.0); AliRsnPairDef(const AliRsnPairDef ©); const AliRsnPairDef& operator= (const AliRsnPairDef ©); virtual ~AliRsnPairDef() { } - // getters + virtual const char* GetName() const {return Form("%s_%s", fDef1.GetName(), fDef2.GetName());} Int_t GetMotherPDG() const {return fMotherPDG;} Double_t GetMotherMass() const {return fMotherMass;} - const char* GetPairName() const; - virtual const char* GetName() const {return GetPairName();} - - AliRsnDaughterDef* GetDef1() {return &fDef1;} - Double_t GetMass1() const {return fDef1.GetMass();} - Char_t GetChargeC1() const {return fDef1.GetChargeC();} - Short_t GetChargeS1() const {return fDef1.GetChargeS();} - AliRsnDaughter::ESpecies GetPID1() const {return fDef1.GetPID();} - AliRsnDaughter::ERefType GetRefType1() const {return fDef1.GetRefType();} - - AliRsnDaughterDef* GetDef2() {return &fDef2;} - Double_t GetMass2() const {return fDef2.GetMass();} - Char_t GetChargeC2() const {return fDef2.GetChargeC();} - Short_t GetChargeS2() const {return fDef2.GetChargeS();} - AliRsnDaughter::ESpecies GetPID2() const {return fDef2.GetPID();} - AliRsnDaughter::ERefType GetRefType2() const {return fDef2.GetRefType();} - - AliRsnDaughterDef* GetDef(Int_t i) {if (i<1) return GetDef1(); else return GetDef2();} - Double_t GetMass(Int_t i) const {if (i<1) return GetMass1(); else return GetMass2();} - Char_t GetChargeC(Int_t i) const {if (i<1) return GetChargeC1(); else return GetChargeS2();} - Short_t GetChargeS(Int_t i) const {if (i<1) return GetChargeS1(); else return GetChargeS2();} - AliRsnDaughter::ESpecies GetPID(Int_t i) const {if (i<1) return GetPID1(); else return GetPID2();} - AliRsnDaughter::ERefType GetRefType(Int_t i) const {if (i<1) return GetRefType1(); else return GetRefType2();} - - // setters - void SetMotherPDG(Int_t pdg) {fMotherPDG = pdg;} - void SetMotherMass(Double_t mass) {fMotherMass = mass;} - void SetDef1(EPARTYPE pid, Char_t charge) {fDef1.SetCharge(charge); fDef1.SetPID(AliRsnDaughter::FromAliPID(pid));} - void SetDef2(EPARTYPE pid, Char_t charge) {fDef2.SetCharge(charge); fDef2.SetPID(AliRsnDaughter::FromAliPID(pid));} - void SetDef1(AliRsnDaughter::ESpecies pid, Char_t charge) {fDef1.SetCharge(charge); fDef1.SetPID(pid);} - void SetDef2(AliRsnDaughter::ESpecies pid, Char_t charge) {fDef2.SetCharge(charge); fDef2.SetPID(pid);} - - void SetDefs(EPARTYPE pid1, Char_t ch1, AliPID::EParticleType pid2, Char_t ch2) {SetDef1(pid1, ch1); SetDef2(pid2, ch2);} - void SetDefs(AliRsnDaughter::ESpecies pid1, Char_t ch1, AliPID::EParticleType pid2, Char_t ch2) {SetDef1(pid1, ch1); SetDef2(pid2, ch2);} - - // checkers - Bool_t IsLikeSign() const {return (GetChargeC1() == GetChargeC2());} - Bool_t HasEqualPID() const {return (GetPID1() == GetPID2());} + AliRsnDaughterDef& GetDef1() {return fDef1;} + AliRsnDaughterDef& GetDef2() {return fDef2;} + AliRsnDaughterDef& GetDef(Int_t i) {if (i<1) return GetDef1(); else return GetDef2();} + + void SetMotherPDG(Int_t pdg) {fMotherPDG = pdg;} + void SetMotherMass(Double_t mass) {fMotherMass = mass;} + void SetDef1(AliRsnDaughterDef *def) {if (def) fDef1 = (*def);} + void SetDef2(AliRsnDaughterDef *def) {if (def) fDef2 = (*def);} + void SetDef(Int_t i, AliRsnDaughterDef *def) {if (!def) return; if (i<1) fDef1 = (*def); else fDef2 = (*def);} + + Bool_t IsLikeSign() const {return (fDef1.GetChargeC() == fDef2.GetChargeC());} + Bool_t HasEqualPID() const {return (fDef1.GetPID() == fDef2.GetPID());} private: diff --git a/PWG2/RESONANCES/AliRsnPairFunctions.cxx b/PWG2/RESONANCES/AliRsnPairFunctions.cxx deleted file mode 100644 index 3aca1cbef04..00000000000 --- a/PWG2/RESONANCES/AliRsnPairFunctions.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// -// *** Class AliRsnPairFunctions *** -// -// "Core" method for defining the work on a pari of particles. -// For one analysis, one must setup one of this for each pair he wants to analyze, -// adding to it all analysis which he desires to do. -// Here he defines the cuts, and the particle types and charges, and can add -// functions which do different operations on the same pair, and some binning -// with respect to some kinematic variables (eta, momentum) -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include - -#include "AliLog.h" - -#include "AliRsnMother.h" -#include "AliRsnEvent.h" -#include "AliRsnFunction.h" -#include "AliRsnCutSet.h" -#include "AliRsnValue.h" - -#include "AliRsnPairFunctions.h" - -ClassImp(AliRsnPairFunctions) - -//_____________________________________________________________________________ -AliRsnPairFunctions::AliRsnPairFunctions(const char *name, AliRsnPairDef *def) : - AliRsnPair(name, def), - fFunctions("AliRsnFunction", 0) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnPairFunctions::AliRsnPairFunctions(const AliRsnPairFunctions& copy) : - AliRsnPair(copy), - fFunctions(copy.fFunctions) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnPairFunctions& AliRsnPairFunctions::operator=(const AliRsnPairFunctions& copy) -{ - AliRsnPair::operator=(copy); - - Int_t i, n = copy.fFunctions.GetEntries(); - for (i = 0; i < n; i++) { - AliRsnFunction *fcn = (AliRsnFunction*)copy.fFunctions[i]; - if (fcn) AddFunction(fcn); - } - - return (*this); -} - -//_____________________________________________________________________________ -AliRsnPairFunctions::~AliRsnPairFunctions() -{ -// -// Destructor -// -} - -//_____________________________________________________________________________ -void AliRsnPairFunctions::Compute() -{ -// -// Makes computations using the two passed daughter objects. -// Checks all cuts and then computes the corresponding pair object -// and then fill the list of required values using it. -// - - TObjArrayIter nextFcn(&fFunctions); - AliRsnFunction *fcn = 0x0; - - while ((fcn = (AliRsnFunction*)nextFcn())) { - fcn->Fill(&fMother); - } -} - -//_____________________________________________________________________________ -void AliRsnPairFunctions::Init(const char *prefix, TList *list) -{ -// -// Generates needed histograms, giving them a name based on -// the flags defined here, on the pair definition, and attaches -// a prefix to it, according to the argument. -// -// All generated histograms are stored into the output TList. -// - - Int_t i; - TString hName(""); - AliRsnFunction *fcn = 0; - for (i = 0; i < fFunctions.GetEntries(); i++) { - fcn = (AliRsnFunction*)fFunctions.At(i); - hName = prefix; - hName += '_'; - hName += GetName(); - hName += '_'; - hName += fcn->GetName(); - if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), "")); - else list->Add(fcn->CreateHistogramSparse(hName.Data(), "")); - } -} - -//_____________________________________________________________________________ -void AliRsnPairFunctions::AddFunction(AliRsnFunction *const fcn) -{ -// -// Adds a new computing function -// - - Int_t size = fFunctions.GetEntries(); - new (fFunctions[size]) AliRsnFunction(*fcn); - fFunctions.Print(); -} diff --git a/PWG2/RESONANCES/AliRsnPairFunctions.h b/PWG2/RESONANCES/AliRsnPairFunctions.h deleted file mode 100644 index cd94787ec1c..00000000000 --- a/PWG2/RESONANCES/AliRsnPairFunctions.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// *** Class AliRsnPairFunctions *** -// -// TODO -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef AliRsnPairFunctions_H -#define AliRsnPairFunctions_H - -#include "AliRsnPair.h" - -class TH1; -class TH2; -class TList; -class TArrayI; - -class AliRsnEvent; -class AliRsnCutSet; -class AliRsnFunction; -class AliRsnValue; - -class AliRsnPairFunctions : public AliRsnPair { -public: - - AliRsnPairFunctions(const char *name = "default", AliRsnPairDef *def = 0); - AliRsnPairFunctions(const AliRsnPairFunctions ©); - AliRsnPairFunctions& operator=(const AliRsnPairFunctions&); - ~AliRsnPairFunctions(); - - void AddFunction(AliRsnFunction*const fcn); - TList* GenerateHistograms(const char *prefix = "", TList *list = 0); - virtual void Compute(); - virtual void Init(const char *prefix, TList *list); - -protected: - - TClonesArray fFunctions; // a list of functions which generate histograms - - ClassDef(AliRsnPairFunctions, 2) -}; - -#endif - diff --git a/PWG2/RESONANCES/AliRsnPairNtuple.cxx b/PWG2/RESONANCES/AliRsnPairNtuple.cxx deleted file mode 100644 index 68daf652a3d..00000000000 --- a/PWG2/RESONANCES/AliRsnPairNtuple.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// -// *** Class AliRsnPairNtuple *** -// -// "Core" method for defining the work on a pari of particles. -// For one analysis, one must setup one of this for each pair he wants to analyze, -// adding to it all analysis which he desires to do. -// Here he defines the cuts, and the particle types and charges, and can add -// functions which do different operations on the same pair, and some binning -// with respect to some kinematic variables (eta, momentum) -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include -#include - -#include "AliLog.h" - -#include "AliRsnMother.h" -#include "AliRsnEvent.h" -#include "AliRsnFunction.h" -#include "AliRsnCutSet.h" -#include "AliRsnValue.h" - -#include "AliRsnPairNtuple.h" - -ClassImp(AliRsnPairNtuple) - -//_____________________________________________________________________________ -AliRsnPairNtuple::AliRsnPairNtuple(const char *name, AliRsnPairDef *def) : - AliRsnPair(name, def), - fValues("AliRsnValue", 0), - fNtuple(0x0) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnPairNtuple::AliRsnPairNtuple(const AliRsnPairNtuple& copy) : - AliRsnPair(copy), - fValues(copy.fValues), - fNtuple(copy.fNtuple) -{ -// -// Default constructor -// -} - -//_____________________________________________________________________________ -AliRsnPairNtuple& AliRsnPairNtuple::operator=(const AliRsnPairNtuple& copy) -{ - AliRsnPair::operator=(copy); - - Int_t i, n = copy.fValues.GetEntries(); - for (i = 0; i < n; i++) { - AliRsnValue *fcn = (AliRsnValue*)copy.fValues[i]; - if (fcn) AddValue(fcn); - } - - fNtuple = copy.fNtuple; - - return (*this); -} - -//_____________________________________________________________________________ -AliRsnPairNtuple::~AliRsnPairNtuple() -{ -// -// Destructor -// -} - -//_____________________________________________________________________________ -void AliRsnPairNtuple::Compute() -{ -// -// Makes computations using the two passed daughter objects. -// Checks all cuts and then computes the corresponding pair object -// and then fill the list of required values using it. -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - // compute all values - Int_t i, n = fValues.GetEntries(); - TArrayF values(n); - AliRsnValue *value = 0x0; - Bool_t computeOK = kFALSE; - for (i = 0; i < n; i++) { - values[i] = -1E10; - value = (AliRsnValue*)fValues[i]; - switch (value->GetTargetType()) { - case AliRsnTarget::kMother: - value->SetSupportObject(fPairDef); - computeOK = value->Eval(&fMother); - break; - case AliRsnTarget::kEvent: - computeOK = value->Eval(fMother.GetRefEvent()); - break; - default: - computeOK = kFALSE; - } - if (computeOK) values[i] = ((Float_t)value->GetComputedValue()); - } - - fNtuple->Fill(values.GetArray()); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnPairNtuple::Init(const char *prefix, TList *list) -{ -// -// Generates needed histograms, giving them a name based on -// the flags defined here, on the pair definition, and attaches -// a prefix to it, according to the argument. -// -// All generated histograms are stored into the output TList. -// - - TString nameList(""); - - Int_t i, n = fValues.GetEntries(); - AliRsnValue *val = 0; - for (i = 0; i < n; i++) { - val = (AliRsnValue*)fValues.At(i); - nameList += val->GetName(); - if (i < n - 1) nameList += ':'; - } - - if (fNtuple) delete fNtuple; - fNtuple = new TNtuple(Form("%sntp%s", prefix, GetName()), "", nameList.Data()); - if (list) list->Add(fNtuple); -} - -//_____________________________________________________________________________ -Bool_t AliRsnPairNtuple::AddValue(AliRsnValue* const val) -{ -// -// Adds a new computing function. -// - - RSNTARGET target = val->GetTargetType(); - if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) { - AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", val->GetName(), val->GetTargetTypeName())); - return kFALSE; - } - - Int_t size = fValues.GetEntries(); - new (fValues[size]) AliRsnValue(*val); - - return kTRUE; -} diff --git a/PWG2/RESONANCES/AliRsnPairNtuple.h b/PWG2/RESONANCES/AliRsnPairNtuple.h deleted file mode 100644 index 9a5a5e65c89..00000000000 --- a/PWG2/RESONANCES/AliRsnPairNtuple.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// *** Class AliRsnPairNtuple *** -// -// TODO -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef AliRsnPairNtuple_H -#define AliRsnPairNtuple_H - -#include "AliRsnPair.h" - -class TNtuple; - -class AliRsnPairNtuple : public AliRsnPair { -public: - - AliRsnPairNtuple(const char *name = "default", AliRsnPairDef *def = 0); - AliRsnPairNtuple(const AliRsnPairNtuple ©); - AliRsnPairNtuple& operator=(const AliRsnPairNtuple&); - ~AliRsnPairNtuple(); - - Bool_t AddValue(AliRsnValue* const val); - void GenerateNtuple(const char *prefix = "", TList *list = 0); - virtual void Compute(); - virtual void Init(const char *prefix, TList *list); - -private: - - TClonesArray fValues; // single values computed from analyzed objects - TNtuple *fNtuple; // ntuple computed with values - - ClassDef(AliRsnPairNtuple, 2) -}; - -#endif - diff --git a/PWG2/RESONANCES/AliRsnTarget.h b/PWG2/RESONANCES/AliRsnTarget.h index c5f33228a7a..bd9d524fb3e 100644 --- a/PWG2/RESONANCES/AliRsnTarget.h +++ b/PWG2/RESONANCES/AliRsnTarget.h @@ -28,7 +28,7 @@ public: }; AliRsnTarget() : fTargetType(kTargetTypes), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } - AliRsnTarget(const char *name, ETargetType type) : TNamed(name, ""), fTargetType(type), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } + AliRsnTarget(const char *name, ETargetType type = kTargetTypes) : TNamed(name, ""), fTargetType(type), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } AliRsnTarget(const AliRsnTarget& copy) : TNamed(copy), fTargetType(copy.fTargetType), fDaughter(0x0), fMother(0x0), fEvent(0x0) { /*nothing*/ } AliRsnTarget& operator=(const AliRsnTarget& copy) { TNamed::operator=(copy); fTargetType = copy.fTargetType; return (*this); } virtual ~AliRsnTarget() { /*nothing*/ } diff --git a/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx b/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx deleted file mode 100644 index f75a4e0fe6c..00000000000 --- a/PWG2/RESONANCES/AliRsnVATProcessInfo.cxx +++ /dev/null @@ -1,198 +0,0 @@ -// -// *** Class AliRsnVATProcessInfo *** -// -// Virtual class which makes computations at the event level, -// in order to return a list of histograms useful to have a look -// of the characteristics of used events. -// If can be inherited and customized for the needs of the analysis. -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#include -#include - -#include "AliLog.h" - -#include "AliRsnEvent.h" -#include "AliRsnFunction.h" -#include "AliRsnVATProcessInfo.h" - -ClassImp(AliRsnVATProcessInfo) - -//______________________________________________________________________________ -AliRsnVATProcessInfo::AliRsnVATProcessInfo(const char *name) : - TNamed(name, name), - fHistUsedEvents(0x0), - fEventUsed(kFALSE), - fEventFunctions("AliRsnFunction", 0), - fPrintInfoNumber(1000) -{ -// -// Constructor. -// Does nothing more than initialization of data members. -// - - AliDebug(AliLog::kDebug + 2, "Entering"); - AliDebug(AliLog::kDebug + 2, "Exiting"); -} - -//______________________________________________________________________________ -AliRsnVATProcessInfo::AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy) : - TNamed(copy), - fHistUsedEvents(0x0), - fEventUsed(copy.fEventUsed), - fEventFunctions(copy.fEventFunctions), - fPrintInfoNumber(copy.fPrintInfoNumber) -{ -// -// Copy constructor. -// Clones the histogram and copies the values of other data members -// - - AliDebug(AliLog::kDebug + 2, "Entering"); - - fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone(); - - AliDebug(AliLog::kDebug + 2, "Exiting"); -} - -//______________________________________________________________________________ -AliRsnVATProcessInfo& AliRsnVATProcessInfo::operator= -(const AliRsnVATProcessInfo& copy) -{ -// -// Assignment operator. -// Clones the histogram and copies the values of other data members. -// - - AliDebug(AliLog::kDebug + 2, "Entering"); - - fHistUsedEvents = (TH1I*)copy.fHistUsedEvents->Clone(); - fEventUsed = copy.fEventUsed; - fPrintInfoNumber = copy.fPrintInfoNumber; - fEventFunctions = copy.fEventFunctions; - - AliDebug(AliLog::kDebug + 2, "Exiting"); - - return (*this); -} - -//______________________________________________________________________________ -AliRsnVATProcessInfo::~AliRsnVATProcessInfo() -{ -// -// Destructor. -// Does nothing, since the histogram it creates is usually owned -// by another object (TList output of AnalysisTask's), but sets -// the data member pointers to NULL. -// - - AliDebug(AliLog::kDebug + 2, "Entering"); - - fHistUsedEvents = 0x0; - fEventUsed = 0; - fPrintInfoNumber = 0; - - AliDebug(AliLog::kDebug + 2, "Exiting"); -} - -//______________________________________________________________________________ -void AliRsnVATProcessInfo::GenerateInfoList(TList *list) -{ -// -// Allocate in memory the histograms created in this class and store them -// inside the TList object passed as argument, which usually belongs to -// an AnalysisTask object, and represents one of its outputs. -// If the histogram was already initialized, it is deleted and recreated. -// - - AliDebug(AliLog::kDebug + 2, "Entering"); - - // delete existing allocation of stored objects - if (fHistUsedEvents) delete fHistUsedEvents; - - // create stored objects - fHistUsedEvents = new TH1I(GetEventHistogramName(), "Skipped/used events", 2, 0, 2); - - // ad objects to list - list->Add(fHistUsedEvents); - - // add all other functions - Int_t i; - TString hName(""); - AliRsnFunction *fcn = 0; - for (i = 0; i < fEventFunctions.GetEntries(); i++) { - fcn = (AliRsnFunction*)fEventFunctions.At(i); - hName += GetName(); - hName += '_'; - hName += fcn->GetName(); - if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName.Data(), "")); - else list->Add(fcn->CreateHistogramSparse(hName.Data(), "")); - } - - AliDebug(AliLog::kDebug + 2, "Exiting"); -} - -//______________________________________________________________________________ -void AliRsnVATProcessInfo::FillInfo(AliRsnEvent *event) -{ -// -// This method defines how the information histograms must be filled. -// The structure of this class is auto-consistent, but in case of inheritance -// this method must be modified accordingly. -// Current implementation uses the 'fEventUsed' flag to choose if the event -// has been used or not, and increments the corresponding bin in the related -// histogram (bin '0' = skipped, bin '1' = used). -// - - fHistUsedEvents->Fill(fEventUsed); - - if (!fEventUsed) return; - - Int_t i; - AliRsnFunction *fcn = 0; - for (i = 0; i < fEventFunctions.GetEntries(); i++) { - fcn = (AliRsnFunction*)fEventFunctions.At(i); - fcn->Fill(event); - } -} - -//______________________________________________________________________________ -void AliRsnVATProcessInfo::PrintInfo(const Long64_t &num) -{ -// -// This method is used in some cases -// to inform about number of events processed -// - - if ((num + 1) % fPrintInfoNumber == 0) AliInfo(Form("Events processed %lld", num + 1)); -} - -//______________________________________________________________________________ -Long64_t AliRsnVATProcessInfo::GetNumerOfEventsProcessed() -{ -// -// returns number of events from histogram -// - - if (fHistUsedEvents) return (Long64_t)fHistUsedEvents->GetEntries(); - return 0; -} - -//_____________________________________________________________________________ -void AliRsnVATProcessInfo::AddEventFunction(AliRsnFunction * fcn) -{ -// -// Adds a new computing function -// - - AliDebug(AliLog::kDebug + 2, "<-"); - - fEventFunctions.Print(); - Int_t size = fEventFunctions.GetEntries(); - new(fEventFunctions[size]) AliRsnFunction(*fcn); - - AliDebug(AliLog::kDebug + 2, "->"); -} diff --git a/PWG2/RESONANCES/AliRsnVATProcessInfo.h b/PWG2/RESONANCES/AliRsnVATProcessInfo.h deleted file mode 100644 index 93b05e176b3..00000000000 --- a/PWG2/RESONANCES/AliRsnVATProcessInfo.h +++ /dev/null @@ -1,53 +0,0 @@ -// -// *** Class AliRsnVATProcessInfo *** -// -// Virtual class which makes computations at the event level, -// in order to return a list of histograms useful to have a look -// of the characteristics of used events. -// If can be inherited and customized for the needs of the analysis. -// -// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) -// M. Vala (email: martin.vala@cern.ch) -// - -#ifndef ALIRSNVATPROCESSINFO_H -#define ALIRSNVATPROCESSINFO_H - -#include -#include - -class TH1I; -class AliRsnFunction; -class AliRsnEvent; - -class AliRsnVATProcessInfo : public TNamed { -public: - AliRsnVATProcessInfo(const char *name = "RSNInfo"); - AliRsnVATProcessInfo(const AliRsnVATProcessInfo& copy); - AliRsnVATProcessInfo& operator= (const AliRsnVATProcessInfo& copy); - ~AliRsnVATProcessInfo(); - - void GenerateInfoList(TList* list); - virtual void FillInfo(AliRsnEvent *event); - virtual void PrintInfo(const Long64_t &num); - - const char* GetEventHistogramName() { return Form("hEventsUsed_%s", GetName()); }; - Long64_t GetNumerOfEventsProcessed(); - void SetEventUsed(Int_t flag) { fEventUsed = flag; } - Int_t IsEventUsed() const { return fEventUsed; }; - void AddEventFunction(AliRsnFunction *fcn); - - void SetPrintInfoNumber(const Long64_t &num = 1) { fPrintInfoNumber = num; } - -private: - - TH1I *fHistUsedEvents; // hist of used events - Int_t fEventUsed; // number of used events - TClonesArray fEventFunctions; // collection of functions computed on event - - Long64_t fPrintInfoNumber; // print info number - - ClassDef(AliRsnVATProcessInfo, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnVAnalysisTask.cxx b/PWG2/RESONANCES/AliRsnVAnalysisTask.cxx deleted file mode 100644 index 32934b13479..00000000000 --- a/PWG2/RESONANCES/AliRsnVAnalysisTask.cxx +++ /dev/null @@ -1,424 +0,0 @@ -// -// Class AliRsnVAnalysisTask -// -// Virtual Class derivated from AliAnalysisTaskSE which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include - -#include "AliESDEvent.h" -#include "AliMCEvent.h" -#include "AliAODEvent.h" -#include "AliAnalysisManager.h" -#include "AliMCEventHandler.h" -#include "AliMultiInputEventHandler.h" -#include "AliMixInputEventHandler.h" - - -#include "AliRsnEvent.h" -#include "AliRsnTarget.h" - -#include "AliRsnVAnalysisTask.h" - -ClassImp(AliRsnVAnalysisTask) - -//_____________________________________________________________________________ -AliRsnVAnalysisTask::AliRsnVAnalysisTask -(const char *name, Bool_t mcOnly) : - AliAnalysisTaskSE(name), - fLogType(AliLog::kInfo), - fLogClassesString(""), - fIsMixing(kFALSE), - fMCOnly(mcOnly), - fInfoList(0x0), - fTaskInfo(name), - fMixedEH(0), - fUseMixingRange(kTRUE) -{ -// -// Default constructor. -// Define the output slot for histograms. -// - - DefineOutput(1, TList::Class()); - DefineOutput(2, TList::Class()); - - for (Int_t i = 0; i < 2; i++) { - fESDEvent[i] = 0; - fMCEvent[i] = 0; - fAODEventIn[i] = 0; - fAODEventOut[i] = 0; - } -} - -//_____________________________________________________________________________ -AliRsnVAnalysisTask::AliRsnVAnalysisTask(const AliRsnVAnalysisTask& copy) : - AliAnalysisTaskSE(copy), - fLogType(copy.fLogType), - fLogClassesString(copy.fLogClassesString), - fIsMixing(copy.fIsMixing), - fMCOnly(copy.fMCOnly), - fInfoList(0x0), - fTaskInfo(copy.fTaskInfo), - fMixedEH(copy.fMixedEH), - fUseMixingRange(copy.fUseMixingRange) -{ -// -// Copy constructor. -// Defined for coding conventions compliance but never used. -// - AliDebug(AliLog::kDebug + 2, "<-"); - - for (Int_t i = 0; i < 2; i++) { - fESDEvent[i] = copy.fESDEvent[i]; - fMCEvent[i] = copy.fMCEvent[i]; - fAODEventIn[i] = copy.fAODEventIn[i]; - fAODEventOut[i] = copy.fAODEventOut[i]; - fRsnEvent[i] = copy.fRsnEvent[i]; - } - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::LocalInit() -{ -// -// Local initialization. -// Defines the debug message level and calls the mother class LocalInit(). -// - - AliAnalysisTaskSE::LocalInit(); - SetDebugForAllClasses(); -} - -//_____________________________________________________________________________ -Bool_t AliRsnVAnalysisTask::UserNotify() -{ -// -// Calls the mother class Notify() -// - - return AliAnalysisTaskSE::UserNotify(); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::ConnectInputData(Option_t *opt) -{ -// -// Connect input data, which consist in initializing properly -// the pointer to the input event, which is dynamically casted -// to all available types, and this allows to know its type. -// Calls also the mother class omonyme method. -// - - AliAnalysisTaskSE::ConnectInputData(opt); - - // get AliESDEvent and, if successful - // retrieve the corresponding MC if exists - fESDEvent[0] = dynamic_cast(fInputEvent); - if (fESDEvent[0]) { - fMCEvent[0] = (AliMCEvent*) MCEvent(); - AliInfo(Form("Input event is of type ESD (%p)", fESDEvent[0])); - if (fMCEvent[0]) AliInfo(Form("Input has an associated MC (%p)", fMCEvent[0])); - } - - // get AliAODEvent from input and, if successful - // it will contain both the reconstructed and MC informations - fAODEventIn[0] = dynamic_cast(fInputEvent); - if (fAODEventIn[0]) { - AliInfo(Form("Input event if of type native AOD (%p)", fAODEventIn[0])); - } - - // get AliAODEvent from output of previous task - fAODEventOut[0] = dynamic_cast(AODEvent()); - if (fAODEventOut[0]) { - AliInfo(Form("Input event if of type produced AOD from previous step (%p)", fAODEventOut[0])); - } -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::UserCreateOutputObjects() -{ -// -// Creates and links to task all output objects. -// Does explicitly the initialization for the event info class, -// and then calls the customized function which must be overloaded -// in the applications of this base class. -// - - SetDebugForAllClasses(); - - // set event info outputs - fInfoList = new TList(); - fInfoList->SetOwner(); - fTaskInfo.GenerateInfoList(fInfoList); - - // create customized outputs - RsnUserCreateOutputObjects(); - - PostData(1, fInfoList); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::UserExec(Option_t* opt) -{ -// -// Prepares for execution, setting the correct pointers of the -// RSN package event interface, which will point to the not NULL -// objects obtained from dynamic-casts called in ConnectInputData(). -// - - if (!IsMixing()) { - - if (fMCOnly && fMCEvent[0]) { - fRsnEvent[0].SetRef(fMCEvent[0]); - fRsnEvent[0].SetRefMC(fMCEvent[0]); - } else if (fESDEvent[0]) { - fRsnEvent[0].SetRef(fESDEvent[0]); - fRsnEvent[0].SetRefMC(fMCEvent[0]); - } else if (fAODEventOut[0]) { - fRsnEvent[0].SetRef(fAODEventOut[0]); - fRsnEvent[0].SetRefMC(fAODEventOut[0]); - } else if (fAODEventIn[0]) { - fRsnEvent[0].SetRef(fAODEventIn[0]); - fRsnEvent[0].SetRefMC(fAODEventIn[0]); - } else { - AliError("Unknown input event format. Skipping"); - return; - } - - // call event preprocessing... - Bool_t preCheck = RsnEventProcess(); - // ...then fill the information object and print informations... - fTaskInfo.FillInfo(&fRsnEvent[0]); - fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed()); - // ...and return if event did not pass selections - if (!preCheck) { - AliDebug(AliLog::kDebug, "Event preprocessing has failed. Skipping event"); - return; - } - - // call customized implementation for execution - RsnUserExec(opt); - } - - // post outputs for the info object - // (eventually others are done in the derived classes) - PostData(1, fInfoList); -} - -void AliRsnVAnalysisTask::UserExecMix(Option_t* option) -{ - AliDebug(AliLog::kDebug + 2, "<-"); - - - if (!IsMixing()) return; - - SetupMixingEvents(); - - if (!fMixedEH) return; - - if (fMCOnly && fMCEvent[0]) { - fRsnEvent[0].SetRef(fMCEvent[0]); - fRsnEvent[0].SetRefMC(fMCEvent[0]); - fRsnEvent[1].SetRef(fMCEvent[1]); - fRsnEvent[1].SetRefMC(fMCEvent[1]); - } else if (fESDEvent[0]) { - fRsnEvent[0].SetRef(fESDEvent[0]); - fRsnEvent[0].SetRefMC(fMCEvent[0]); - fRsnEvent[1].SetRef(fESDEvent[1]); - fRsnEvent[1].SetRefMC(fMCEvent[1]); - } else if (fAODEventOut) { - fRsnEvent[0].SetRef(fAODEventOut[0]); - fRsnEvent[0].SetRefMC(fAODEventOut[0]); - fRsnEvent[1].SetRef(fAODEventOut[1]); - fRsnEvent[1].SetRefMC(fAODEventOut[1]); - } else if (fAODEventIn) { - fRsnEvent[0].SetRef(fAODEventIn[0]); - fRsnEvent[0].SetRefMC(fAODEventIn[0]); - fRsnEvent[1].SetRef(fAODEventIn[1]); - fRsnEvent[1].SetRefMC(fAODEventIn[1]); - } else { - AliError("NO ESD or AOD object!!! Skipping ..."); - return; - } - - // call event preprocessing... - Bool_t preCheck = RsnEventProcess(); - // ...then fill the information object and print informations... - fTaskInfo.FillInfo(&fRsnEvent[0]); - fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed()); - // ...and return if event did not pass selections - if (!preCheck) { - AliDebug(AliLog::kDebug, "Event preprocessing has failed. Skipping event"); - return; - } - - RsnUserExecMix(option); - AliDebug(AliLog::kDebug + 2, "->"); -} - - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::Terminate(Option_t* opt) -{ -// -// Termination routines. -// Stores all histograms (after checking they exist) -// and includes to the TList all task informations. -// - - AliAnalysisTask::Terminate(); - - TList* list = dynamic_cast(GetOutputData(1)); - if (!list) { - AliError(Form("At end of analysis, fOutList is %p", list)); - return; - } - - RsnTerminate(opt); - - TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName()); - if (!hEventInfo) { - AliError(Form("hEventInfo is %p", hEventInfo)); - return; - } - AliInfo(Form("=== %s ==================", GetName())); - AliInfo(Form("Number Of Events Processed : %10lld", (Long64_t)hEventInfo->Integral())); - AliInfo(Form("Number Of Events Accepted : %10lld", (Long64_t)hEventInfo->GetBinContent(2))); - AliInfo(Form("Number Of Events Skipped : %10lld", (Long64_t)hEventInfo->GetBinContent(1))); - AliInfo(Form("=== end %s ==============", GetName())); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::RsnUserCreateOutputObjects() -{ -// -// Define here all instructions to create output objects. -// This method will be called inside the "UserCreateOutputObjects" -// in the used task. -// - - AliWarning("Implement this in derived classes"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::RsnUserExec(Option_t*) -{ -// -// -// - - AliWarning("Implement this in derived classes"); -} - -void AliRsnVAnalysisTask::RsnUserExecMix(Option_t*) -{ - // - // - // - - AliWarning("Implement this in derived classes"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::RsnTerminate(Option_t*) -{ -// -// Overload this to add additional termination operations -// - - AliWarning("Implement this in derived classes"); -} - -//_____________________________________________________________________________ -Bool_t AliRsnVAnalysisTask::RsnEventProcess() -{ -// -// Performs some pre-processing of current event, -// which is useful for all the operations which -// need to be done only once for each event. -// - - // if not using mixing cuts return kTRUE - if (!IsMixing() || !IsUsingMixingRange()) return kTRUE; - - // cut if event was in range of mixing cuts - AliVEventHandler *inh = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler(); - if (inh->InheritsFrom(AliMultiInputEventHandler::Class())) { - AliMultiInputEventHandler *inEvHMain = dynamic_cast(inh); - if (inEvHMain) { - fMixedEH = dynamic_cast(inEvHMain->GetFirstMultiInputHandler()); - if (fMixedEH) { - if (fMixedEH->CurrentBinIndex() < 0) return kFALSE; - } - } - } - - // in this case, return always a success - return kTRUE; -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::SetupMixingEvents() -{ -// -// Setup the pointers to the mixed event. -// This requires to retrieve them from the mixed event handler -// - - AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); - AliMultiInputEventHandler *inEvHMain = dynamic_cast(mgr->GetInputEventHandler()); - if (inEvHMain) { - fMixedEH = dynamic_cast(inEvHMain->GetFirstMultiInputHandler()); - if (fMixedEH) { - AliMultiInputEventHandler *inEvHMainTmpMix = dynamic_cast(fMixedEH->InputEventHandler(0)); - if (!inEvHMainTmpMix) return; - AliInputEventHandler *inEvHMixTmp = dynamic_cast(inEvHMainTmpMix->GetFirstInputEventHandler()); - AliMCEventHandler *inEvHMCMixTmp = dynamic_cast(inEvHMainTmpMix->GetFirstMCEventHandler()); - if (!inEvHMixTmp) return; - fESDEvent[1] = dynamic_cast(inEvHMixTmp->GetEvent()); - if (fESDEvent[1]) AliDebug(AliLog::kDebug, Form("Input is ESD (%p) MIXED", fESDEvent[1])); - // getting AliAODEvent from input - fAODEventIn[1] = dynamic_cast(inEvHMixTmp->GetEvent()); - if (fAODEventIn[1]) AliDebug(AliLog::kDebug, Form("Input is AOD (%p) MIXED", fAODEventIn[1])); - // getting AliAODEvent if it is output from previous task (not supported) - fAODEventOut[1] = 0; - - if (inEvHMCMixTmp) { - fMCEvent[1] = inEvHMCMixTmp->MCEvent(); - if (fMCEvent[1]) AliDebug(AliLog::kDebug, Form("Input is ESDMC (%p) MIXED", fMCEvent[1])); - } - - } - - } -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTask::SetDebugForAllClasses() -{ -// -// Set debug level for all classes for which it is required -// - - TObjArray *array = fLogClassesString.Tokenize(":"); - TObjString *objStr; - TString str; - Int_t i, n = array->GetEntriesFast(); - - for (i = 0; i < n; i++) { - objStr = (TObjString*)array->At(i); - str = objStr->GetString(); - AliLog::SetClassDebugLevel(str.Data(), fLogType); - AliInfo(Form("Setting Debug to %s", str.Data())); - } -} - diff --git a/PWG2/RESONANCES/AliRsnVAnalysisTask.h b/PWG2/RESONANCES/AliRsnVAnalysisTask.h deleted file mode 100644 index d35a0e243b0..00000000000 --- a/PWG2/RESONANCES/AliRsnVAnalysisTask.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef ALIRSNVANALYSISTASK_H -#define ALIRSNVANALYSISTASK_H - -// -// Class AliRsnVAnalysisTask -// -// Virtual Class derivated from AliAnalysisTaskSE which will be base class -// for all RSN Multi tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include "AliAnalysisTaskSE.h" -#include "AliMixInputEventHandler.h" - -#include "AliRsnEvent.h" -#include "AliRsnVATProcessInfo.h" - -class AliESDEvent; -class AliAODEvent; -class AliMCEvent; - -class AliRsnVAnalysisTask : public AliAnalysisTaskSE { -public: - - AliRsnVAnalysisTask(const char *name = "AliRsnVAnalysisTask", Bool_t mcOnly = kFALSE); - AliRsnVAnalysisTask(const AliRsnVAnalysisTask& copy); - AliRsnVAnalysisTask& operator= (const AliRsnVAnalysisTask& /*copy*/) { return *this; } - virtual ~AliRsnVAnalysisTask() {/* Does nothing*/;} - - // basic interface methods - virtual void LocalInit(); - virtual Bool_t UserNotify(); - virtual void ConnectInputData(Option_t *opt); - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t* opt); - virtual void UserExecMix(Option_t* option = ""); - virtual void Terminate(Option_t* opt); - - // customized methods (to be implemented in derived classes) - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnUserExecMix(Option_t*); - virtual void RsnTerminate(Option_t*); - virtual Bool_t RsnEventProcess(); - - // getters - AliRsnEvent* GetRsnEvent(Int_t i = 0) {return &fRsnEvent[i];} - AliRsnVATProcessInfo* GetInfo() {return &fTaskInfo;} - Bool_t IsMixing() {return fIsMixing;} - Bool_t IsUsingMixingRange() {return fUseMixingRange;} - - // setters - void SetMCOnly(Bool_t mcOnly = kTRUE) {fMCOnly = mcOnly;} - void SetLogType(AliLog::EType_t type, const char *classes = "") {fLogType = type; fLogClassesString = classes;} - void SetPrintInfoNumber(const Long64_t &num = 100) {fTaskInfo.SetPrintInfoNumber(num);} - void SetMixing(Bool_t doMix = kTRUE) {fIsMixing = doMix;} - void UseMixingRange(Bool_t useMixRange = kTRUE) {fUseMixingRange = useMixRange;} - -protected: - - AliLog::EType_t fLogType; // log type - TString fLogClassesString; // all classes string divided with ":" - - AliESDEvent *fESDEvent[2]; // ESD event - AliMCEvent *fMCEvent[2]; // MC event - AliAODEvent *fAODEventIn[2]; // AOD event from input - AliAODEvent *fAODEventOut[2]; // AOD event from output from previous taks - - Bool_t fIsMixing; // flag is using mixing - Bool_t fMCOnly; // use only MC information - AliRsnEvent fRsnEvent[2]; // interface to event for RSN package - - TList *fInfoList; //! output list for informations - AliRsnVATProcessInfo fTaskInfo; // task info - - AliMixInputEventHandler *fMixedEH; //! mixed event hadnler - Bool_t fUseMixingRange; // flag - - void SetupMixingEvents(); - void SetDebugForAllClasses(); - - ClassDef(AliRsnVAnalysisTask, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnVAnalysisTaskSE.cxx b/PWG2/RESONANCES/AliRsnVAnalysisTaskSE.cxx deleted file mode 100644 index 5868383185d..00000000000 --- a/PWG2/RESONANCES/AliRsnVAnalysisTaskSE.cxx +++ /dev/null @@ -1,290 +0,0 @@ -// -// Class AliRsnVAnalysisTaskSE -// -// Virtual Class derivated from AliAnalysisTaskSE which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#include - -#include "AliESDEvent.h" -#include "AliMCEvent.h" -#include "AliAODEvent.h" -#include "AliRsnEvent.h" -#include "AliRsnTarget.h" - -#include "AliRsnVAnalysisTaskSE.h" - -ClassImp(AliRsnVAnalysisTaskSE) - -//_____________________________________________________________________________ -AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE -(const char *name, Bool_t mcOnly) : - AliAnalysisTaskSE(name), - fLogType(AliLog::kInfo), - fLogClassesString(""), - fESDEvent(0x0), - fMCEvent(0x0), - fAODEventIn(0x0), - fAODEventOut(0x0), - fMCOnly(mcOnly), - fRsnEvent(), - fInfoList(0x0), - fTaskInfo(name) -{ -// -// Default constructor. -// Define the output slot for histograms. -// - - DefineOutput(1, TList::Class()); - DefineOutput(2, TList::Class()); -} - -//_____________________________________________________________________________ -AliRsnVAnalysisTaskSE::AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy) : - AliAnalysisTaskSE(copy), - fLogType(copy.fLogType), - fLogClassesString(copy.fLogClassesString), - fESDEvent(copy.fESDEvent), - fMCEvent(copy.fMCEvent), - fAODEventIn(copy.fAODEventIn), - fAODEventOut(copy.fAODEventOut), - fMCOnly(copy.fMCOnly), - fRsnEvent(), - fInfoList(0x0), - fTaskInfo(copy.fTaskInfo) -{ -// -// Copy constructor. -// Defined for coding conventions compliance but never used. -// -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::LocalInit() -{ -// -// Local initialization. -// Defines the debug message level and calls the mother class LocalInit(). -// - - AliAnalysisTaskSE::LocalInit(); - SetDebugForAllClasses(); -} - -//_____________________________________________________________________________ -Bool_t AliRsnVAnalysisTaskSE::UserNotify() -{ -// -// Calls the mother class Notify() -// - - return AliAnalysisTaskSE::UserNotify(); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::ConnectInputData(Option_t *opt) -{ -// -// Connect input data, which consist in initializing properly -// the pointer to the input event, which is dynamically casted -// to all available types, and this allows to know its type. -// Calls also the mother class omonyme method. -// - - AliAnalysisTaskSE::ConnectInputData(opt); - - // get AliESDEvent and, if successful - // retrieve the corresponding MC if exists - fESDEvent = dynamic_cast(fInputEvent); - if (fESDEvent) { - fMCEvent = (AliMCEvent*) MCEvent(); - AliInfo(Form("Input event is of type ESD (%p)", fESDEvent)); - if (fMCEvent) AliInfo(Form("Input has an associated MC (%p)", fMCEvent)); - } - - // get AliAODEvent from input and, if successful - // it will contain both the reconstructed and MC informations - fAODEventIn = dynamic_cast(fInputEvent); - if (fAODEventIn) { - AliInfo(Form("Input event if of type native AOD (%p)", fAODEventIn)); - } - - // get AliAODEvent from output of previous task - fAODEventOut = dynamic_cast(AODEvent()); - if (fAODEventOut) { - AliInfo(Form("Input event if of type produced AOD from previous step (%p)", fAODEventOut)); - } -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::UserCreateOutputObjects() -{ -// -// Creates and links to task all output objects. -// Does explicitly the initialization for the event info class, -// and then calls the customized function which must be overloaded -// in the applications of this base class. -// - - SetDebugForAllClasses(); - - // set event info outputs - fInfoList = new TList(); - fInfoList->SetOwner(); - fTaskInfo.GenerateInfoList(fInfoList); - - // create customized outputs - RsnUserCreateOutputObjects(); - - PostData(1, fInfoList); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::UserExec(Option_t* opt) -{ -// -// Prepares for execution, setting the correct pointers of the -// RSN package event interface, which will point to the not NULL -// objects obtained from dynamic-casts called in ConnectInputData(). -// - - if (fMCOnly && fMCEvent) { - fRsnEvent.SetRef(fMCEvent); - fRsnEvent.SetRefMC(fMCEvent); - } else if (fESDEvent) { - fRsnEvent.SetRef(fESDEvent); - fRsnEvent.SetRefMC(fMCEvent); - } else if (fAODEventOut) { - fRsnEvent.SetRef(fAODEventOut); - fRsnEvent.SetRefMC(fAODEventOut); - } else if (fAODEventIn) { - fRsnEvent.SetRef(fAODEventIn); - fRsnEvent.SetRefMC(fAODEventIn); - } else { - AliError("Unknown input event format. Skipping"); - return; - } - - // call event preprocessing... - Bool_t preCheck = EventProcess(); - // ...then fill the information object and print informations... - fTaskInfo.FillInfo(&fRsnEvent); - fTaskInfo.PrintInfo(fTaskInfo.GetNumerOfEventsProcessed()); - // ...and return if event did not pass selections - if (!preCheck) { - AliDebug(AliLog::kDebug, "Event preprocessing has failed. Skipping event"); - return; - } - - - // call customized implementation for execution - RsnUserExec(opt); - - // post outputs for the info object - // (eventually others are done in the derived classes) - PostData(1, fInfoList); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::Terminate(Option_t* opt) -{ -// -// Termination routines. -// Stores all histograms (after checking they exist) -// and includes to the TList all task informations. -// - - AliAnalysisTask::Terminate(); - - TList* list = dynamic_cast(GetOutputData(1)); - if (!list) { - AliError(Form("At end of analysis, fOutList is %p", list)); - return; - } - - RsnTerminate(opt); - - TH1I *hEventInfo = (TH1I*) list->FindObject(fTaskInfo.GetEventHistogramName()); - if (!hEventInfo) { - AliError(Form("hEventInfo is %p", hEventInfo)); - return; - } - AliInfo(Form("=== %s ==================", GetName())); - AliInfo(Form("Number Of Events Processed : %10lld", (Long64_t)hEventInfo->Integral())); - AliInfo(Form("Number Of Events Accepted : %10lld", (Long64_t)hEventInfo->GetBinContent(2))); - AliInfo(Form("Number Of Events Skipped : %10lld", (Long64_t)hEventInfo->GetBinContent(1))); - AliInfo(Form("=== end %s ==============", GetName())); - - AliDebug(AliLog::kDebug + 2, "->"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::RsnUserCreateOutputObjects() -{ -// -// Define here all instructions to create output objects. -// This method will be called inside the "UserCreateOutputObjects" -// in the used task. -// - - AliWarning("Implement this in derived classes"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::RsnUserExec(Option_t*) -{ -// -// -// - - AliWarning("Implement this in derived classes"); -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::RsnTerminate(Option_t*) -{ -// -// Overload this to add additional termination operations -// - - AliWarning("Implement this in derived classes"); -} - -//_____________________________________________________________________________ -Bool_t AliRsnVAnalysisTaskSE::EventProcess() -{ -// -// Performs some pre-processing of current event, -// which is useful for all the operations which -// need to be done only once for each event. -// - - // in this case, return always a success - return kTRUE; -} - -//_____________________________________________________________________________ -void AliRsnVAnalysisTaskSE::SetDebugForAllClasses() -{ -// -// Set debug level for all classes for which it is required -// - - TObjArray *array = fLogClassesString.Tokenize(":"); - TObjString *objStr; - TString str; - Int_t i, n = array->GetEntriesFast(); - - for (i = 0; i < n; i++) { - objStr = (TObjString*)array->At(i); - str = objStr->GetString(); - AliLog::SetClassDebugLevel(str.Data(), fLogType); - AliInfo(Form("Setting Debug to %s", str.Data())); - } -} - diff --git a/PWG2/RESONANCES/AliRsnVAnalysisTaskSE.h b/PWG2/RESONANCES/AliRsnVAnalysisTaskSE.h deleted file mode 100644 index d34df73bec2..00000000000 --- a/PWG2/RESONANCES/AliRsnVAnalysisTaskSE.h +++ /dev/null @@ -1,79 +0,0 @@ -// -// Class AliRsnVAnalysisTaskSE -// -// Virtual Class derivated from AliAnalysisTaskSE which will be base class -// for all RSN SE tasks -// -// authors: Martin Vala (martin.vala@cern.ch) -// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) -// - -#ifndef ALIRSNVANALYSISTASKSE_H -#define ALIRSNVANALYSISTASKSE_H - -#include - -#include "AliAnalysisTaskSE.h" - -#include "AliRsnEvent.h" -#include "AliRsnVATProcessInfo.h" - -class AliESDEvent; -class AliAODEvent; -class AliMCEvent; - -class AliRsnVAnalysisTaskSE : public AliAnalysisTaskSE { -public: - - AliRsnVAnalysisTaskSE(const char *name = "AliRsnVAnalysisTaskSE", Bool_t mcOnly = kFALSE); - AliRsnVAnalysisTaskSE(const AliRsnVAnalysisTaskSE& copy); - AliRsnVAnalysisTaskSE& operator= (const AliRsnVAnalysisTaskSE& /*copy*/) { return *this; } - virtual ~AliRsnVAnalysisTaskSE() {/* Does nothing*/;} - - // basic interface methods - virtual void LocalInit(); - virtual Bool_t UserNotify(); - virtual void ConnectInputData(Option_t *opt); - virtual void UserCreateOutputObjects(); - virtual void UserExec(Option_t* opt); - virtual void Terminate(Option_t* opt); - - // customized methods (to be implemented in derived classes) - virtual void RsnUserCreateOutputObjects(); - virtual void RsnUserExec(Option_t*); - virtual void RsnTerminate(Option_t*); - - // event pre-processing functions - virtual Bool_t EventProcess(); - - // getters - AliRsnEvent* GetRsnEvent() {return &fRsnEvent;} - AliRsnVATProcessInfo* GetInfo() {return &fTaskInfo;} - - // setters - void SetMCOnly(Bool_t mcOnly = kTRUE) {fMCOnly = mcOnly;} - void SetLogType(AliLog::EType_t type, const char *classes = "") {fLogType = type; fLogClassesString = classes;} - void SetPrintInfoNumber(const Long64_t &num = 100) {fTaskInfo.SetPrintInfoNumber(num);} - -protected: - - AliLog::EType_t fLogType; // log type - TString fLogClassesString; // all classes string divided with ":" - - AliESDEvent *fESDEvent; // ESD event - AliMCEvent *fMCEvent; // MC event - AliAODEvent *fAODEventIn; // AOD event from input - AliAODEvent *fAODEventOut; // AOD event from output from previous taks - - Bool_t fMCOnly; // use only MC information - AliRsnEvent fRsnEvent; // interface to event for RSN package - - TList *fInfoList; //! output list for informations - AliRsnVATProcessInfo fTaskInfo; // task info - - void SetDebugForAllClasses(); - - ClassDef(AliRsnVAnalysisTaskSE, 1) -}; - -#endif diff --git a/PWG2/RESONANCES/AliRsnValue.cxx b/PWG2/RESONANCES/AliRsnValue.cxx index cca64f8a8ea..bbd91ca28c7 100644 --- a/PWG2/RESONANCES/AliRsnValue.cxx +++ b/PWG2/RESONANCES/AliRsnValue.cxx @@ -56,9 +56,7 @@ ClassImp(AliRsnValue) AliRsnValue::AliRsnValue() : AliRsnTarget(), fComputedValue(0), - fValueType(kValueTypes), - fBinArray(0), - fSupportObject(0x0) + fBinArray(0) { // // Default constructor without arguments. @@ -70,12 +68,10 @@ AliRsnValue::AliRsnValue() : //_____________________________________________________________________________ AliRsnValue::AliRsnValue -(const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) : - AliRsnTarget(name, TargetType(type)), +(const char *name, Int_t nbins, Double_t min, Double_t max) : + AliRsnTarget(name), fComputedValue(0.0), - fValueType(type), - fBinArray(0), - fSupportObject(0x0) + fBinArray(0) { // // Main constructor (version 1). @@ -94,12 +90,10 @@ AliRsnValue::AliRsnValue //_____________________________________________________________________________ AliRsnValue::AliRsnValue -(const char *name, EValueType type, Double_t min, Double_t max, Double_t step) : - AliRsnTarget(name, TargetType(type)), +(const char *name, Double_t min, Double_t max, Double_t step) : + AliRsnTarget(name), fComputedValue(0.0), - fValueType(type), - fBinArray(0), - fSupportObject(0x0) + fBinArray(0) { // // Main constructor (version 2). @@ -113,12 +107,10 @@ AliRsnValue::AliRsnValue //_____________________________________________________________________________ AliRsnValue::AliRsnValue -(const char *name, EValueType type, Int_t nbins, Double_t *array) : - AliRsnTarget(name, TargetType(type)), +(const char *name, Int_t nbins, Double_t *array) : + AliRsnTarget(name), fComputedValue(0.0), - fValueType(type), - fBinArray(0), - fSupportObject(0x0) + fBinArray(0) { // // Main constructor (version 3). @@ -133,9 +125,7 @@ AliRsnValue::AliRsnValue AliRsnValue::AliRsnValue(const AliRsnValue& copy) : AliRsnTarget(copy), fComputedValue(copy.fComputedValue), - fValueType(copy.fValueType), - fBinArray(copy.fBinArray), - fSupportObject(copy.fSupportObject) + fBinArray(copy.fBinArray) { // // Copy constructor. @@ -155,8 +145,6 @@ AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy) fComputedValue = copy.fComputedValue; fBinArray = copy.fBinArray; - fSupportObject = copy.fSupportObject; - fValueType = copy.fValueType; return (*this); } @@ -219,62 +207,7 @@ void AliRsnValue::SetBins(Int_t nbins, Double_t *array) } //_____________________________________________________________________________ -const char* AliRsnValue::GetValueTypeName() const -{ -// -// This method returns a string to give a name to each possible -// computation value. -// - - switch (fValueType) { - case kTrackP: return "SingleTrackPtot"; - case kTrackPt: return "SingleTrackPt"; - case kTrackPtpc: return "SingleTrackPtpc"; - case kTrackEta: return "SingleTrackEta"; - case kTrackY: return "SingleTrackRapidity"; - case kTrackITSsignal: return "SingleTrackITSsignal"; - case kTrackTPCsignal: return "SingleTrackTPCsignal"; - case kTrackTOFsignal: return "SingleTrackTOFsignal"; - case kTrackTOFbeta: return "SingleTrackTOFbeta"; - case kTrackLength: return "SingleTrackLength"; - - case kPairP1: return "PairPtotDaughter1"; - case kPairP2: return "PairPtotDaughter2"; - case kPairP1t: return "PairPtDaughter1"; - case kPairP2t: return "PairPtDaughter2"; - case kPairP1z: return "PairPzDaughter1"; - case kPairP2z: return "PairPzDaughter2"; - case kPairInvMass: return "PairInvMass"; - case kPairInvMassMC: return "PairInvMassMC"; - case kPairInvMassRes: return "PairInvMassResolution"; - case kPairPt: return "PairPt"; - case kPairPz: return "PairPz"; - case kPairEta: return "PairEta"; - case kPairMt: return "PairMt"; - case kPairY: return "PairY"; - case kPairPhi: return "PairPhi"; - case kPairPhiMC: return "PairPhiMC"; - case kPairPtRatio: return "PairPtRatio"; - case kPairDipAngle: return "PairDipAngle"; - case kPairCosThetaStar: return "PairCosThetaStar"; - case kPairQInv: return "PairQInv"; - case kPairAngleToLeading: return "PairAngleToLeading"; - - case kEventLeadingPt: return "EventLeadingPt"; - case kEventMult: return "EventMult"; - case kEventMultMC: return "EventMultMC"; - case kEventMultESDCuts: return "EventMultESDCuts"; - case kEventMultSPD: return "EventMultSPD"; - case kEventVz: return "EventVz"; - case kEventCentralityV0: return "EventCentralityV0"; - case kEventCentralityTrack: return "EventCentralityTrack"; - case kEventCentralityCL1: return "EventCentralityCL1"; - default: return "Undefined"; - } -} - -//_____________________________________________________________________________ -Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) +Bool_t AliRsnValue::Eval(TObject *, Bool_t) { // // Evaluation of the required value. @@ -284,458 +217,12 @@ Bool_t AliRsnValue::Eval(TObject *object, Bool_t useMC) // and the values must be taken with GetValue(). // - // utility variables - Bool_t success; - const Double_t fgkVeryBig = 1E20; - Double_t time; - Int_t leadingID = -1; - ULong_t status = 0x0; - - // coherence check, which also casts object - // to AliRsnTarget data members and returns kFALSE - // in case the object is NULL - if (!TargetOK(object)) return kFALSE; - - // these variables are initialized - // from the target object, once it - // is casted to one of the expected - // types (daughter/mother/event) - // -- not all are initialized always - TLorentzVector pRec; // 4-momentum for single track or pair sum (reco) - TLorentzVector pSim; // 4-momentum for single track or pair sum (MC) - TLorentzVector pRec0; // 4-momentum of first daughter (reco) - TLorentzVector pSim0; // 4-momentum of first daughter (MC) - TLorentzVector pRec1; // 4-momentum of second daughter (reco) - TLorentzVector pSim1; // 4-momentum of second daughter (MC) - AliESDEvent *esdev = 0x0; // reference ESD event - AliESDtrack *esdt = 0x0; // reference ESD track - AliAODTrack *aodt = 0x0; // reference AOD track - AliAODPid *pidObj = 0x0; // reference AOD PID object - - // initialize the above 4-vectors according to the - // expected target type (which has been checked above) - // in particular, the 'fEvent' data member of base AliRsnTarget - // will be *always* well initialized if the TargetOK() returns kTRUE - switch (fTargetType) { - case AliRsnTarget::kDaughter: - pRec = fDaughter->Prec(); - pSim = fDaughter->Psim(); - esdt = fDaughter->GetRefESDtrack(); - aodt = fDaughter->GetRefAODtrack(); - if (aodt) pidObj = aodt->GetDetPid(); - break; - case AliRsnTarget::kMother: - pRec = fMother->Sum(); - pSim = fMother->SumMC(); - pRec0 = fMother->GetDaughter(0)->Prec(); - pRec1 = fMother->GetDaughter(1)->Prec(); - pSim0 = fMother->GetDaughter(0)->Psim(); - pSim1 = fMother->GetDaughter(1)->Psim(); - break; - case AliRsnTarget::kEvent: - break; - default: - AliError(Form("[%s] Wrong type", GetName())); - return kFALSE; - } - leadingID = fEvent->GetLeadingParticleID(); - esdev = fEvent->GetRefESD(); - - if (esdt) status = esdt->GetStatus(); - if (aodt) status = aodt->GetStatus(); - - // these objects are all types of supports - // which could be needed for some values - AliRsnPairDef *pairDef = 0x0; - AliRsnDaughterDef *daughterDef = 0x0; - AliESDpid *esdPID = 0x0; - if (fSupportObject) { - if (fSupportObject->InheritsFrom(AliRsnPairDef ::Class())) pairDef = static_cast(fSupportObject); - if (fSupportObject->InheritsFrom(AliRsnDaughterDef::Class())) daughterDef = static_cast(fSupportObject); - if (fSupportObject->InheritsFrom(AliESDpid ::Class())) esdPID = static_cast(fSupportObject); - } - - // compute value depending on types in the enumeration - // if the type does not match any available choice, or if - // the computation is not doable due to any problem - // (not initialized support object, wrong values, risk of floating point errors) - // the method returng kFALSE and sets the computed value to a meaningless number - switch (fValueType) { - case kTrackP: - // single track: - // total momentum - fComputedValue = useMC ? pSim.Vect().Mag() : pRec.Vect().Mag(); - return kTRUE; - case kTrackPt: - // single track: - // transverse momentum - fComputedValue = useMC ? pSim.Perp() : pRec.Perp(); - return kTRUE; - case kTrackPtpc: - // single track: - // transverse momentum - if (esdt) { - if (esdt->GetInnerParam()) { - fComputedValue = esdt->GetInnerParam()->P(); - return kTRUE; - } else { - AliError(Form("[%s] TPC inner param is not initialized", GetName())); - return kFALSE; - } - } - else if (aodt && pidObj) { - fComputedValue = pidObj->GetTPCmomentum(); - return kTRUE; - } else { - AliError(Form("[%s] Cannot retrieve TPC momentum", GetName())); - return kFALSE; - } - case kTrackEta: - // single track: - // pseudo-rapidity - fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); - return kTRUE; - case kTrackY: - // single track: - // rapidity (requires an AliRsnDaughterDef support) - if (daughterDef) { - pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), daughterDef->GetMass()); - pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), daughterDef->GetMass()); - fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity(); - return kTRUE; - } - else { - AliError(Form("[%s] Required a correctly initialized AliRsnDaughterDef support object to compute this value", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kTrackITSsignal: - // single track: - // ITS signal (successful only for tracks) - // works only if the status is OK - if ((status & AliESDtrack::kITSin) == 0) { - AliDebug(AliLog::kDebug + 2, "Rejecting non-ITS track"); - return kFALSE; - } - if (esdt) { - fComputedValue = esdt->GetITSsignal(); - return kTRUE; - } - else if (aodt && pidObj) { - fComputedValue = pidObj->GetITSsignal(); - return kTRUE; - } - else { - AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kTrackTPCsignal: - // single track: - // TPC signal (successful only for tracks) - // works only if the status is OK - if ((status & AliESDtrack::kTPCin) == 0) { - AliDebug(AliLog::kDebug + 2, "Rejecting non-TPC track"); - return kFALSE; - } - if (esdt) { - fComputedValue = esdt->GetTPCsignal(); - return kTRUE; - } - else if (aodt && pidObj) { - fComputedValue = pidObj->GetTPCsignal(); - return kTRUE; - } - else { - AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kTrackTOFsignal: - // single track: - // TOF signal (successful only for tracks, for ESD requires an AliESDpid support) - // works only if the status is OK - if ((status & AliESDtrack::kTOFout) == 0 || (status & AliESDtrack::kTIME) == 0) { - AliDebug(AliLog::kDebug + 2, "Rejecting non-TOF track"); - return kFALSE; - } - if (esdt) { - if (!esdPID || !esdev) { - AliError(Form("[%s] Required a correctly initialized AliRsnEvent and AliESDpid support object to compute this value with ESDs", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - else { - esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0); - fComputedValue = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P())); - return kTRUE; - } - } - else if (aodt && pidObj) { - fComputedValue = pidObj->GetTOFsignal(); - return kTRUE; - } - else { - AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kTrackTOFbeta: - // single track: - // TOF beta (successful only for tracks, for ESD requires an AliESDpid support) - if (esdt) { - if (!esdPID) { - AliError(Form("[%s] Required a correctly initialized AliESDpid support object to compute this value with ESDs", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - else if (!esdev) { - AliError(Form("[%s] Required a correctly initialized AliESDEvent to compute this value with ESDs", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - else { - esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0); - fComputedValue = esdt->GetIntegratedLength(); - time = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P())); - if (time > 0.0) { - fComputedValue /= time; - fComputedValue /= 2.99792458E-2; - return kTRUE; - } else { - fComputedValue = fgkVeryBig; - return kFALSE; - } - } - } - else { - AliError(Form("[%s] Length information not available in AODs", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kTrackLength: - // single tracks: - // integrated length (computed only on ESDs) - if (esdt) { - fComputedValue = esdt->GetIntegratedLength(); - return kTRUE; - } - else { - AliError(Form("[%s] Length information not available in AODs", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - //--------------------------------------------------------------------------------------------------------------------- - case kPairP1: - // pair: - // momentum of first daughter (which matches definition #1 in pairDef) - fComputedValue = useMC ? pSim0.Mag() : pRec0.Mag(); - return kTRUE; - case kPairP2: - // pair: - // momentum of second daughter (which matches definition #2 in pairDef) - fComputedValue = useMC ? pSim1.Mag() : pRec1.Mag(); - return kTRUE; - case kPairP1t: - // pair: - // transverse momentum of first daughter - fComputedValue = useMC ? pSim0.Perp() : pRec0.Perp(); - return kTRUE; - case kPairP2t: - // pair: - // transverse momentum of second daughter - fComputedValue = useMC ? pSim1.Perp() : pRec1.Perp(); - return kTRUE; - case kPairP1z: - // pair: - // longitudinal momentum of first daughter - fComputedValue = useMC ? pSim0.Z() : pRec0.Z(); - return kTRUE; - case kPairP2z: - // pair: - // longitudinal momentum of second daughter - fComputedValue = useMC ? pSim1.Z() : pRec1.Z(); - return kTRUE; - case kPairInvMass: - // pair: - // invariant mass - fComputedValue = useMC ? pSim.M() : pRec.M(); - return kTRUE; - case kPairInvMassRes: - // pair: - // invariant mass resolution (requires MC) - if (TMath::Abs(pSim.M()) > 0.0) { - fComputedValue = (pSim.M() - pRec.M()) / pSim.M(); - return kTRUE; - } - else { - AliError(Form("[%s] Caught a null MC mass", GetName())); - return kFALSE; - } - case kPairPt: - // pair: - // total transverse momentum - fComputedValue = useMC ? pSim.Perp() : pRec.Perp(); - return kTRUE; - case kPairEta: - // pair: - // pseudo-rapidiry - fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); - return kTRUE; - case kPairMt: - // pair: - // transverse mass (requires an AliRsnPairDef to get mass hypothesis) - if (pairDef) { - pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); - pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass()); - fComputedValue = useMC ? pSim.Mt() : pRec.Mt(); - return kTRUE; - } - else { - AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kPairY: - // pair: - // rapidity (requires an AliRsnPairDef to get mass hypothesis) - if (pairDef) { - pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); - pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass()); - fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity(); - return kTRUE; - } - else { - AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName())); - fComputedValue = fgkVeryBig; - return kFALSE; - } - case kPairPhi: - // pair: - // phi angle of total momentum - fComputedValue = useMC ? pSim.Phi() : pRec.Phi(); - return kTRUE; - case kPairPtRatio: - // pair: - // ratio of relative sum and difference of daughter transverse momenta - if (useMC) { - fComputedValue = TMath::Abs(pSim0.Perp() - pSim1.Perp()); - fComputedValue /= TMath::Abs(pSim0.Perp() + pSim1.Perp()); - } else { - fComputedValue = TMath::Abs(pRec0.Perp() - pRec1.Perp()); - fComputedValue /= TMath::Abs(pRec0.Perp() + pRec1.Perp()); - } - return kTRUE; - case kPairDipAngle: - // pair: - // dip-angle in the transverse-Z plane - // (used to check conversion electrons) - if (useMC) { - fComputedValue = pSim0.Perp() * pSim1.Perp() + pSim0.Z() * pSim1.Z(); - fComputedValue /= pSim0.Mag() * pSim1.Mag(); - } else { - fComputedValue = pRec0.Perp() * pRec1.Perp() + pRec0.Z() * pRec1.Z(); - fComputedValue /= pRec0.Mag() * pRec1.Mag(); - } - fComputedValue = TMath::Abs(TMath::ACos(fComputedValue)); - return kTRUE; - case kPairCosThetaStar: - // pair: - // cosine of theta star angle - // (= angle of first daughter to the total momentum, in resonance rest frame) - fComputedValue = fMother->CosThetaStar(useMC); - return kTRUE; - case kPairQInv: - // pair: - // Q-invariant - pSim0 -= pSim1; - pRec0 -= pRec1; - fComputedValue = useMC ? pSim0.M() : pRec0.M(); - return kTRUE; - case kPairAngleToLeading: - // pair: - // angle w.r. to leading particle (if any) - fComputedValue = fMother->AngleToLeading(success); - return success; - //--------------------------------------------------------------------------------------------------------------------- - case kEventMult: - // event: - // multiplicity of tracks - fComputedValue = (Double_t)fEvent->GetMultiplicityFromTracks(); - return (fComputedValue >= 0); - case kEventMultMC: - // event: - // multiplicity of MC tracks - fComputedValue = (Double_t)fEvent->GetMultiplicityFromMC(); - return (fComputedValue >= 0); - case kEventMultESDCuts: - // event: - // multiplicity of good quality tracks - fComputedValue = fEvent->GetMultiplicityFromESDCuts(); - return (fComputedValue >= 0); - case kEventMultSPD: - // event: - // multiplicity of good quality tracks - fComputedValue = fEvent->GetMultiplicityFromSPD(); - return (fComputedValue >= 0); - case kEventLeadingPt: - // event: - // transverse momentum of leading particle - if (leadingID >= 0) { - AliRsnDaughter leadingPart = fEvent->GetDaughter(leadingID); - AliVParticle *ref = leadingPart.GetRef(); - fComputedValue = ref->Pt(); - return kTRUE; - } else { - AliError(Form("[%s] Leading ID has bad value (%d)", GetName(), leadingID)); - return kFALSE; - } - case kEventVz: - // event: - // Z position of primary vertex - fComputedValue = fEvent->GetRef()->GetPrimaryVertex()->GetZ(); - return kTRUE; - case kEventCentralityV0: - // event: - // centrality using V0 method - if (esdev) { - AliCentrality *centrality = esdev->GetCentrality(); - fComputedValue = centrality->GetCentralityPercentile("V0M"); - return kTRUE; - } else { - AliError(Form("[%s] Centrality computation is implemented for ESDs only up to now", GetName())); - return kFALSE; - } - case kEventCentralityTrack: - // event: - // centrality using tracks method - if (esdev) { - AliCentrality *centrality = esdev->GetCentrality(); - fComputedValue = centrality->GetCentralityPercentile("TRK"); - return kTRUE; - } else { - AliError(Form("[%s] Centrality computation is implemented for ESDs only up to now", GetName())); - return kFALSE; - } - case kEventCentralityCL1: - // event: - // centrality using CL1 method - if (esdev) { - AliCentrality *centrality = esdev->GetCentrality(); - fComputedValue = centrality->GetCentralityPercentile("CL1"); - return kTRUE; - } else { - AliError(Form("[%s] Centrality computation is implemented for ESDs only up to now", GetName())); - return kFALSE; - } - default: - AliError(Form("[%s] Invalid value type for this computation", GetName())); - return kFALSE; - } + AliWarning("This method must be overridden by derived classes"); + return kTRUE; } //_____________________________________________________________________________ -void AliRsnValue::Print(Option_t * /*option */) const +void AliRsnValue::Print(Option_t *option) const { // // Print informations about this object @@ -743,28 +230,11 @@ void AliRsnValue::Print(Option_t * /*option */) const AliInfo("=== VALUE INFO ================================================="); AliInfo(Form(" Name : %s", GetName())); - AliInfo(Form(" Type : %s", GetValueTypeName())); AliInfo(Form(" Current computed value: %f", fComputedValue)); - Int_t i; - for (i = 0; i < fBinArray.GetSize(); i++) { - AliInfo(Form(" Bin limit #%03d = %f", i, fBinArray[i])); + if (!strcmp(option, "BINS")) { + Int_t i; + for (i = 0; i < fBinArray.GetSize(); i++) { + AliInfo(Form(" Bin limit #%03d = %f", i, fBinArray[i])); + } } - AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT"))); - AliInfo("=== END VALUE INFO ============================================="); -} - -//_____________________________________________________________________________ -RSNTARGET AliRsnValue::TargetType(EValueType type) -{ -// -// This method assigns the target to be expected by this object -// in the computation, depending on its type chosen in the enum. -// - - if (type < kTrackValues) - return AliRsnTarget::kDaughter; - else if (type < kPairValues) - return AliRsnTarget::kMother; - else - return AliRsnTarget::kEvent; } diff --git a/PWG2/RESONANCES/AliRsnValue.h b/PWG2/RESONANCES/AliRsnValue.h index b3246fe2275..e6eb18b6f8e 100644 --- a/PWG2/RESONANCES/AliRsnValue.h +++ b/PWG2/RESONANCES/AliRsnValue.h @@ -11,96 +11,37 @@ //////////////////////////////////////////////////////////////////////////////// #include "TArrayD.h" + #include "AliRsnTarget.h" class AliRsnValue : public AliRsnTarget { public: - enum EValueType { - kTrackP, // single track total momentum - kTrackPt, // single track transverse momentum - kTrackPtpc, // single track total momentum in the TPC inner wall - kTrackEta, // single track pseudo-rapidity - kTrackY, // single track rapidity - kTrackITSsignal, // single track ITS signal - kTrackTPCsignal, // single track TPC signal - kTrackTOFsignal, // single track TOF signal - kTrackTOFbeta, // single track beta from TOF - kTrackLength, // single track integrated length - kTrackValues, // --- limita for track values ---------------------------------------- - - kPairP1, // total momentum of 1st daughter of a pair - kPairP2, // total momentum of 2nd daughter of a pair - kPairP1t, // transverse momentum of 1st daughter of a pair - kPairP2t, // transverse momentum of 2nd daughter of a pair - kPairP1z, // longitudinal momentum of 1st daughter of a pair - kPairP2z, // longitudinal momentum of 2nd daughter of a pair - kPairInvMass, // pair invariant mass (with reconstructed momenta) - kPairInvMassMC, // pair invariant mass (with MC momenta) - kPairInvMassRes, // pair invariant mass resolution - kPairPt, // pair transverse momentum - kPairPz, // pair longitudinal momentum - kPairEta, // pair pseudo-rapidity - kPairMt, // pair transverse mass (need a reference mass) - kPairY, // pair rapidity (need a reference mass) - kPairPhi, // pair azimuthal angle (with reconstructed momenta) - kPairPhiMC, // pair azimuthal angle (with MC momenta) - kPairPtRatio, // ratio |pt1 - pt2|/(pt1 + pt2) of daughter transverse momenta - kPairDipAngle, // inverse cosine of the angle between daughter vector momenta - kPairCosThetaStar, // polarization angle - kPairQInv, // invariant relative momentum of the two daughters - kPairAngleToLeading, // angle between pair momentum and leading particle - kPairValues, // --- limit for pair values ------------------------------------------ - - kEventLeadingPt, // transverse momentum of the event leading particle - kEventMult, // multiplicity computed as the number of tracks - kEventMultMC, // multiplicity from MC - kEventMultESDCuts, // multiplicity of good quality tracks - kEventMultSPD, // multiplicity from SPD - kEventVz, // Z position of event primary vertex - kEventCentralityV0, // event centrality (V0 method) - kEventCentralityTrack, // event centrality (tracks method) - kEventCentralityCL1, // event centrality (CL1 method) - kValueTypes // --- limit for event values (and global) ---------------------------- - }; - AliRsnValue(); - AliRsnValue(const char *name, EValueType type, Int_t nbins = 0, Double_t min = 0.0, Double_t max = 0.0); - AliRsnValue(const char *name, EValueType type, Double_t min, Double_t max, Double_t step); - AliRsnValue(const char *name, EValueType type, Int_t nbins, Double_t *array); + AliRsnValue(const char *name, Int_t nbins = 0, Double_t min = 0.0, Double_t max = 0.0); + AliRsnValue(const char *name, Double_t min, Double_t max, Double_t step); + AliRsnValue(const char *name, Int_t nbins, Double_t *array); AliRsnValue(const AliRsnValue& copy); AliRsnValue& operator=(const AliRsnValue& copy); - virtual ~AliRsnValue() { /*does nothing, since pointers are not owned by this object*/ } - - TArrayD GetArray() const {return fBinArray;} - Double_t GetComputedValue() const {return fComputedValue;} - EValueType GetValueType() const {return fValueType;} - const char* GetValueTypeName() const; - TObject* GetSupportObject() {return fSupportObject;} - void SetSupportObject(TObject *obj) {fSupportObject = obj;} - void SetValueType(EValueType type) {fValueType = type; fTargetType = TargetType(type);} + virtual ~AliRsnValue() { } - void SetBins(Int_t n, Double_t min, Double_t max); - void SetBins(Int_t n, Double_t *array); - void SetBins(Double_t min, Double_t max, Double_t step); + TArrayD GetArray() const {return fBinArray;} + const Double_t* GetArrayValues() const {return fBinArray.GetArray();} + Double_t GetComputedValue() const {return fComputedValue;} - void Set(EValueType type, Int_t n, Double_t min, Double_t max) {SetValueType(type); SetBins(n, min, max);} - void Set(EValueType type, Int_t n, Double_t *array) {SetValueType(type); SetBins(n, array);} - void Set(EValueType type, Double_t min, Double_t max, Double_t step) {SetValueType(type); SetBins(min, max, step);} + void SetBins(Int_t n, Double_t min, Double_t max); + void SetBins(Int_t n, Double_t *array); + void SetBins(Double_t min, Double_t max, Double_t step); - virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); - virtual void Print(Option_t *option = "") const; - static RSNTARGET TargetType(EValueType type); + virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); + virtual void Print(Option_t *option = "") const; protected: - Double_t fComputedValue; // computed value - EValueType fValueType; // value type - TArrayD fBinArray; // array of bins (when used for a histogram axis) - TObject *fSupportObject; // support object needed for computing some of the values + Double_t fComputedValue; // computed value + TArrayD fBinArray; // array of bins (when used for a histogram axis) - // ROOT dictionary - ClassDef(AliRsnValue, 2) + ClassDef(AliRsnValue, 3) // AliRsnValue base class }; #endif diff --git a/PWG2/RESONANCES/AliRsnValuePID.cxx b/PWG2/RESONANCES/AliRsnValuePID.cxx new file mode 100644 index 00000000000..fa7b7b0f338 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnValuePID.cxx @@ -0,0 +1,223 @@ +#include + +#include "AliVTrack.h" +#include "AliESDtrack.h" +#include "AliAODTrack.h" + +#include "AliPIDResponse.h" +#include "AliAnalysisManager.h" +#include "AliInputEventHandler.h" + + +#include "AliRsnValuePID.h" + +ClassImp(AliRsnValuePID) + +//__________________________________________________________________________________________________ +AliRsnValuePID::AliRsnValuePID() : + AliRsnValue(), + fSpecies(AliPID::kUnknown), + fValuePID(kValues), + fPID(0x0) +{ +// +// Dummy constructor +// + + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0; + + SetTargetType(AliRsnTarget::kDaughter); +} + +//__________________________________________________________________________________________________ +AliRsnValuePID::AliRsnValuePID +(const char *name, EValuePID type, AliPID::EParticleType species, Int_t nbins, Double_t min, Double_t max) : + AliRsnValue(name, nbins, min, max), + fSpecies(species), + fValuePID(type), + fPID(0x0) +{ +// +// Constructor 1 (fixed bins with number of bins, or no bins) +// + + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0; + + SetTargetType(AliRsnTarget::kDaughter); +} + +//__________________________________________________________________________________________________ +AliRsnValuePID::AliRsnValuePID +(const char *name, EValuePID type, AliPID::EParticleType species, Double_t min, Double_t max, Double_t step) : + AliRsnValue(name, min, max, step), + fSpecies(species), + fValuePID(type), + fPID(0x0) +{ +// +// Constructor 2 (fixed bins with step) +// + + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0; + + SetTargetType(AliRsnTarget::kDaughter); +} + +//__________________________________________________________________________________________________ +AliRsnValuePID::AliRsnValuePID +(const char *name, EValuePID type, AliPID::EParticleType species, Int_t nbins, Double_t *array) : + AliRsnValue(name, nbins, array), + fSpecies(species), + fValuePID(type), + fPID(0x0) +{ +// +// Constructor 3 (variable bins) +// + + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0; + + SetTargetType(AliRsnTarget::kDaughter); +} + +//__________________________________________________________________________________________________ +AliRsnValuePID::AliRsnValuePID(const AliRsnValuePID& copy) : + AliRsnValue(copy), + fSpecies(copy.fSpecies), + fValuePID(copy.fValuePID), + fPID(copy.fPID) +{ +// +// Copy constructor +// + + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0; +} + +//__________________________________________________________________________________________________ +AliRsnValuePID& AliRsnValuePID::operator=(const AliRsnValuePID& copy) +{ +// +// Assignment operator +// + + AliRsnValue::operator=(copy); + + fValuePID = copy.fValuePID; + fSpecies = copy.fSpecies; + fPID = copy.fPID; + + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0; + + return (*this); +} + +//__________________________________________________________________________________________________ +Bool_t AliRsnValuePID::Eval(TObject *object, Bool_t) +{ +// +// Evaluation function +// + + if (fValuePID != kITSsignal && fValuePID != kTPCsignal && !fPID) InitializePID(); + if (!fPID) { + AliError("PID not correctly initialized"); + fComputedValue = 0.0; + return kFALSE; + } + if (!TargetOK(object)) return kFALSE; + + AliVTrack *vtrack = fDaughter->GetRefVtrack(); + + switch (fValuePID) { + case kITSsignal: + fComputedValue = vtrack->GetITSsignal(); + return kTRUE; + case kITSnsigma: + fComputedValue = fPID->NumberOfSigmasITS(vtrack, fSpecies); + return kTRUE; + case kTPCsignal: + fComputedValue = vtrack->GetTPCsignal(); + return kTRUE; + case kTPCnsigma: + fComputedValue = fPID->NumberOfSigmasTPC(vtrack, fSpecies); + return kTRUE; + case kTOFsignal: + if (!TOFComputations(vtrack)) return kFALSE; + fComputedValue = (vtrack->GetTOFsignal() - fPID->GetTOFResponse().GetStartTime(vtrack->P())); + return kTRUE; + case kTOFnsigma: + if (!TOFComputations(vtrack)) return kFALSE; + fComputedValue = fPID->NumberOfSigmasTOF(vtrack, fSpecies); + return kTRUE; + case kTOFtime: + if (!TOFComputations(vtrack)) return kFALSE; + fComputedValue = fTOFtimes[(Int_t)fSpecies]; + return kTRUE; + case kTOFsigma: + if (!TOFComputations(vtrack)) return kFALSE; + fComputedValue = fTOFsigma[(Int_t)fSpecies]; + return kTRUE; + default: + AliError("Unrecognized option"); + fComputedValue = 0.0; + return kFALSE; + } +} + +//__________________________________________________________________________________________________ +void AliRsnValuePID::Print(Option_t *) const +{ +// +// Printout +// + + AliRsnValue::Print(); +} + +//__________________________________________________________________________________________________ +void AliRsnValuePID::InitializePID() +{ +// +// Initialize PID object +// + + AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager(); + AliInputEventHandler *inh = (AliInputEventHandler*)man->GetInputEventHandler(); + + fPID = inh->GetPIDResponse(); +} + +//__________________________________________________________________________________________________ +Bool_t AliRsnValuePID::TOFComputations(AliVTrack *vtrack) +{ +// +// Make TOF computations +// + + if (vtrack->InheritsFrom(AliESDtrack::Class())) { + AliESDtrack *track = (AliESDtrack*)vtrack; + track->GetIntegratedTimes(fTOFtimes); + Int_t i; + for (i = 0; i < AliPID::kSPECIES; i++) { + fTOFsigma[i] = fPID->GetTOFResponse().GetExpectedSigma(track->GetP(), fTOFtimes[i], AliPID::ParticleMass(i)); + } + return kTRUE; + } else if (vtrack->InheritsFrom(AliAODTrack::Class())) { + AliAODTrack *track = (AliAODTrack*)vtrack; + AliAODPid *pidObj = track->GetDetPid(); + if (!pidObj) return kFALSE; + pidObj->GetIntegratedTimes(fTOFtimes); + pidObj->GetTOFpidResolution(fTOFsigma); + return kTRUE; + } else { + return kFALSE; + } +} + diff --git a/PWG2/RESONANCES/AliRsnValuePID.h b/PWG2/RESONANCES/AliRsnValuePID.h new file mode 100644 index 00000000000..e8e96cadf47 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnValuePID.h @@ -0,0 +1,56 @@ +#ifndef ALIRSNVALUEPID_H +#define ALIRSNVALUEPID_H + +#include "AliPID.h" +#include "AliRsnValue.h" + +class AliVTrack; +class AliPIDResponse; + +class AliRsnValuePID : public AliRsnValue { + +public: + + enum EValuePID { + kITSsignal, + kITSnsigma, + kTPCsignal, + kTPCnsigma, + kTOFsignal, + kTOFnsigma, + kTOFtime, + kTOFsigma, + kValues + }; + + AliRsnValuePID(); + AliRsnValuePID(const char *name, EValuePID type, AliPID::EParticleType species, Int_t nbins = 0, Double_t min = 0.0, Double_t max = 0.0); + AliRsnValuePID(const char *name, EValuePID type, AliPID::EParticleType species, Double_t min, Double_t max, Double_t step); + AliRsnValuePID(const char *name, EValuePID type, AliPID::EParticleType species, Int_t nbins, Double_t *array); + AliRsnValuePID(const AliRsnValuePID& copy); + AliRsnValuePID& operator=(const AliRsnValuePID& copy); + + virtual ~AliRsnValuePID() { } + + void SetValuePID(EValuePID type) {fValuePID = type;} + EValuePID GetValuePID() {return fValuePID;} + + virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); + virtual void Print(Option_t *option = "") const; + +protected: + + void InitializePID(); + Bool_t TOFComputations(AliVTrack *track); + + AliPID::EParticleType fSpecies; // particle species + EValuePID fValuePID; // output object + AliPIDResponse *fPID; // PID response object + Double_t fTOFtimes[AliPID::kSPECIES]; //! TOF times + Double_t fTOFsigma[AliPID::kSPECIES]; //! TOF sigma + + ClassDef(AliRsnValuePID,1) // AliRsnValuePID class + +}; + +#endif diff --git a/PWG2/RESONANCES/AliRsnValueStd.cxx b/PWG2/RESONANCES/AliRsnValueStd.cxx new file mode 100644 index 00000000000..b9877c31672 --- /dev/null +++ b/PWG2/RESONANCES/AliRsnValueStd.cxx @@ -0,0 +1,727 @@ +/************************************************************************** + * 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. * + **************************************************************************/ + +//////////////////////////////////////////////////////////////////////////////// +// +// This class contains all code which is used to compute any of the values +// which can be of interest within a resonance analysis. Besides the obvious +// invariant mass, it allows to compute other utility values on all possible +// targets, in order to allow a wide spectrum of binning and checks. +// When needed, this object can also define a binning in the variable which +// it is required to compute, which is used for initializing axes of output +// histograms (see AliRsnFunction). +// The value computation requires this object to be passed the object whose +// informations will be used. This object can be of any allowed input type +// (track, pair, event), then this class must inherit from AliRsnTarget. +// Then, when value computation is attempted, a check on target type is done +// and computation is successful only if expected target matches that of the +// passed object. +// In some cases, the value computation can require a support external object, +// which must then be passed to this class. It can be of any type inheriting +// from TObject. +// +// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it) +// M. Vala (martin.vala@cern.ch) +// +//////////////////////////////////////////////////////////////////////////////// + +#include "AliESDtrackCuts.h" +#include "AliESDpid.h" +#include "AliAODPid.h" +#include "AliCentrality.h" + +#include "AliRsnEvent.h" +#include "AliRsnDaughter.h" +#include "AliRsnMother.h" +#include "AliRsnPairDef.h" +#include "AliRsnDaughterDef.h" + +#include "AliRsnValueStd.h" + +ClassImp(AliRsnValueStd) + +//_____________________________________________________________________________ +AliRsnValueStd::AliRsnValueStd() : + AliRsnValue(), + fValueType(kValueTypes), + fSupportObject(0x0) +{ +// +// Default constructor without arguments. +// Initialize data members to meaningless values. +// This method is provided for ROOT streaming, +// but should never be used directly by a user. +// +} + +//_____________________________________________________________________________ +AliRsnValueStd::AliRsnValueStd +(const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) : + AliRsnValue(name), + fValueType(type), + fSupportObject(0x0) +{ +// +// Main constructor (version 1). +// This constructor defines in meaningful way all data members, +// and defined a fixed binnings, subdividing the specified interval +// into that many bins as specified in the integer argument. +// --- +// This method is also the entry point for all instances +// of this class which don't need to do binning (e.g.: TNtuple inputs), +// since arguments 3 to 5 have default values which don't create any +// binning array, in order not to allocate memory when this is useless. +// + + SetTargetType(TargetType(type)); + SetBins(nbins, min, max); +} + +//_____________________________________________________________________________ +AliRsnValueStd::AliRsnValueStd +(const char *name, EValueType type, Double_t min, Double_t max, Double_t step) : + AliRsnValue(name), + fValueType(type), + fSupportObject(0x0) +{ +// +// Main constructor (version 2). +// This constructor defines in meaningful way all data members +// and creates enough equal bins of the specified size to cover +// the required interval. +// + + SetTargetType(TargetType(type)); + SetBins(min, max, step); +} + +//_____________________________________________________________________________ +AliRsnValueStd::AliRsnValueStd +(const char *name, EValueType type, Int_t nbins, Double_t *array) : + AliRsnValue(name), + fValueType(type), + fSupportObject(0x0) +{ +// +// Main constructor (version 3). +// This constructor defines in meaningful way all data members +// and creates a set of variable bins delimited by the passed array. +// + + SetTargetType(TargetType(type)); + SetBins(nbins, array); +} + +//_____________________________________________________________________________ +AliRsnValueStd::AliRsnValueStd(const AliRsnValueStd& copy) : + AliRsnValue(copy), + fValueType(copy.fValueType), + fSupportObject(copy.fSupportObject) +{ +// +// Copy constructor. +// Duplicates the binning array and copies all settings. +// +} + +//_____________________________________________________________________________ +AliRsnValueStd& AliRsnValueStd::operator=(const AliRsnValueStd& copy) +{ +// +// Assignment operator. +// Works like copy constructor. +// + + AliRsnValue::operator=(copy); + + fSupportObject = copy.fSupportObject; + fValueType = copy.fValueType; + + return (*this); +} + +//_____________________________________________________________________________ +const char* AliRsnValueStd::GetValueTypeName() const +{ +// +// This method returns a string to give a name to each possible +// computation value. +// + + switch (fValueType) { + case kTrackP: return "SingleTrackPtot"; + case kTrackPt: return "SingleTrackPt"; + case kTrackPtpc: return "SingleTrackPtpc"; + case kTrackEta: return "SingleTrackEta"; + case kTrackY: return "SingleTrackRapidity"; + case kTrackITSsignal: return "SingleTrackITSsignal"; + case kTrackTPCsignal: return "SingleTrackTPCsignal"; + case kTrackTOFsignal: return "SingleTrackTOFsignal"; + case kTrackTOFbeta: return "SingleTrackTOFbeta"; + case kTrackLength: return "SingleTrackLength"; + + case kPairP1: return "PairPtotDaughter1"; + case kPairP2: return "PairPtotDaughter2"; + case kPairP1t: return "PairPtDaughter1"; + case kPairP2t: return "PairPtDaughter2"; + case kPairP1z: return "PairPzDaughter1"; + case kPairP2z: return "PairPzDaughter2"; + case kPairInvMass: return "PairInvMass"; + case kPairInvMassMC: return "PairInvMassMC"; + case kPairInvMassRes: return "PairInvMassResolution"; + case kPairPt: return "PairPt"; + case kPairPz: return "PairPz"; + case kPairEta: return "PairEta"; + case kPairMt: return "PairMt"; + case kPairY: return "PairY"; + case kPairPhi: return "PairPhi"; + case kPairPhiMC: return "PairPhiMC"; + case kPairPtRatio: return "PairPtRatio"; + case kPairDipAngle: return "PairDipAngle"; + case kPairCosThetaStar: return "PairCosThetaStar"; + case kPairQInv: return "PairQInv"; + case kPairAngleToLeading: return "PairAngleToLeading"; + + case kEventLeadingPt: return "EventLeadingPt"; + case kEventMult: return "EventMult"; + case kEventMultMC: return "EventMultMC"; + case kEventMultESDCuts: return "EventMultESDCuts"; + case kEventMultSPD: return "EventMultSPD"; + case kEventVz: return "EventVz"; + case kEventCentralityV0: return "EventCentralityV0"; + case kEventCentralityTrack: return "EventCentralityTrack"; + case kEventCentralityCL1: return "EventCentralityCL1"; + default: return "Undefined"; + } +} + +//_____________________________________________________________________________ +Bool_t AliRsnValueStd::Eval(TObject *object, Bool_t useMC) +{ +// +// Evaluation of the required value. +// Checks that the passed object is of the right type +// and if this check is successful, computes the required value. +// The output of the function tells if computing was successful, +// and the values must be taken with GetValue(). +// + + // utility variables + Bool_t success; + const Double_t fgkVeryBig = 1E20; + Double_t time; + Int_t leadingID = -1; + ULong_t status = 0x0; + + // coherence check, which also casts object + // to AliRsnTarget data members and returns kFALSE + // in case the object is NULL + if (!TargetOK(object)) return kFALSE; + + // these variables are initialized + // from the target object, once it + // is casted to one of the expected + // types (daughter/mother/event) + // -- not all are initialized always + TLorentzVector pRec; // 4-momentum for single track or pair sum (reco) + TLorentzVector pSim; // 4-momentum for single track or pair sum (MC) + TLorentzVector pRec0; // 4-momentum of first daughter (reco) + TLorentzVector pSim0; // 4-momentum of first daughter (MC) + TLorentzVector pRec1; // 4-momentum of second daughter (reco) + TLorentzVector pSim1; // 4-momentum of second daughter (MC) + AliESDEvent *esdev = 0x0; // reference ESD event + AliAODEvent *aodev = 0x0; // reference AOD event + AliESDtrack *esdt = 0x0; // reference ESD track + AliAODTrack *aodt = 0x0; // reference AOD track + AliAODPid *pidObj = 0x0; // reference AOD PID object + + // initialize the above 4-vectors according to the + // expected target type (which has been checked above) + // in particular, the 'fEvent' data member of base AliRsnTarget + // will be *always* well initialized if the TargetOK() returns kTRUE + switch (fTargetType) { + case AliRsnTarget::kDaughter: + pRec = fDaughter->Prec(); + pSim = fDaughter->Psim(); + esdt = fDaughter->GetRefESDtrack(); + aodt = fDaughter->GetRefAODtrack(); + if (aodt) pidObj = aodt->GetDetPid(); + break; + case AliRsnTarget::kMother: + pRec = fMother->Sum(); + pSim = fMother->SumMC(); + pRec0 = fMother->GetDaughter(0)->Prec(); + pRec1 = fMother->GetDaughter(1)->Prec(); + pSim0 = fMother->GetDaughter(0)->Psim(); + pSim1 = fMother->GetDaughter(1)->Psim(); + break; + case AliRsnTarget::kEvent: + break; + default: + AliError(Form("[%s] Wrong type", GetName())); + return kFALSE; + } + leadingID = fEvent->GetLeadingParticleID(); + esdev = fEvent->GetRefESD(); + aodev = fEvent->GetRefAOD(); + + // if leading index is negative, assume that leading particle was not searched + // and then searches for it + if (leadingID < 0) { + fEvent->SelectLeadingParticle(); + leadingID = fEvent->GetLeadingParticleID(); + } + + if (esdt) status = esdt->GetStatus(); + if (aodt) status = aodt->GetStatus(); + + // these objects are all types of supports + // which could be needed for some values + AliRsnPairDef *pairDef = 0x0; + AliRsnDaughterDef *daughterDef = 0x0; + AliESDpid *esdPID = 0x0; + if (fSupportObject) { + if (fSupportObject->InheritsFrom(AliRsnPairDef ::Class())) pairDef = static_cast(fSupportObject); + if (fSupportObject->InheritsFrom(AliRsnDaughterDef::Class())) daughterDef = static_cast(fSupportObject); + if (fSupportObject->InheritsFrom(AliESDpid ::Class())) esdPID = static_cast(fSupportObject); + } + + // compute value depending on types in the enumeration + // if the type does not match any available choice, or if + // the computation is not doable due to any problem + // (not initialized support object, wrong values, risk of floating point errors) + // the method returng kFALSE and sets the computed value to a meaningless number + switch (fValueType) { + case kTrackP: + // single track: + // total momentum + fComputedValue = useMC ? pSim.Vect().Mag() : pRec.Vect().Mag(); + return kTRUE; + case kTrackPt: + // single track: + // transverse momentum + fComputedValue = useMC ? pSim.Perp() : pRec.Perp(); + return kTRUE; + case kTrackPtpc: + // single track: + // transverse momentum + if (esdt) { + if (esdt->GetInnerParam()) { + fComputedValue = esdt->GetInnerParam()->P(); + return kTRUE; + } else { + AliError(Form("[%s] TPC inner param is not initialized", GetName())); + return kFALSE; + } + } + else if (aodt && pidObj) { + fComputedValue = pidObj->GetTPCmomentum(); + return kTRUE; + } else { + AliError(Form("[%s] Cannot retrieve TPC momentum", GetName())); + return kFALSE; + } + case kTrackEta: + // single track: + // pseudo-rapidity + fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); + return kTRUE; + case kTrackY: + // single track: + // rapidity (requires an AliRsnDaughterDef support) + if (daughterDef) { + pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), daughterDef->GetMass()); + pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), daughterDef->GetMass()); + fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity(); + return kTRUE; + } + else { + AliError(Form("[%s] Required a correctly initialized AliRsnDaughterDef support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kTrackITSsignal: + // single track: + // ITS signal (successful only for tracks) + // works only if the status is OK + if ((status & AliESDtrack::kITSin) == 0) { + AliDebug(AliLog::kDebug + 2, "Rejecting non-ITS track"); + return kFALSE; + } + if (esdt) { + fComputedValue = esdt->GetITSsignal(); + return kTRUE; + } + else if (aodt && pidObj) { + fComputedValue = pidObj->GetITSsignal(); + return kTRUE; + } + else { + AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kTrackTPCsignal: + // single track: + // TPC signal (successful only for tracks) + // works only if the status is OK + if ((status & AliESDtrack::kTPCin) == 0) { + AliDebug(AliLog::kDebug + 2, "Rejecting non-TPC track"); + return kFALSE; + } + if (esdt) { + fComputedValue = esdt->GetTPCsignal(); + return kTRUE; + } + else if (aodt && pidObj) { + fComputedValue = pidObj->GetTPCsignal(); + return kTRUE; + } + else { + AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kTrackTOFsignal: + // single track: + // TOF signal (successful only for tracks, for ESD requires an AliESDpid support) + // works only if the status is OK + if ((status & AliESDtrack::kTOFout) == 0 || (status & AliESDtrack::kTIME) == 0) { + AliDebug(AliLog::kDebug + 2, "Rejecting non-TOF track"); + return kFALSE; + } + if (esdt) { + if (!esdPID || !esdev) { + AliError(Form("[%s] Required a correctly initialized AliRsnEvent and AliESDpid support object to compute this value with ESDs", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + else { + esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0); + fComputedValue = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P())); + return kTRUE; + } + } + else if (aodt && pidObj) { + fComputedValue = pidObj->GetTOFsignal(); + return kTRUE; + } + else { + AliError(Form("[%s] Detector signals can be computed only on reconstructed tracks", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kTrackTOFbeta: + // single track: + // TOF beta (successful only for tracks, for ESD requires an AliESDpid support) + if (esdt) { + if (!esdPID) { + AliError(Form("[%s] Required a correctly initialized AliESDpid support object to compute this value with ESDs", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + else if (!esdev) { + AliError(Form("[%s] Required a correctly initialized AliESDEvent to compute this value with ESDs", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + else { + esdPID->SetTOFResponse(esdev, AliESDpid::kTOF_T0); + fComputedValue = esdt->GetIntegratedLength(); + time = (esdt->GetTOFsignal() - esdPID->GetTOFResponse().GetStartTime(esdt->P())); + if (time > 0.0) { + fComputedValue /= time; + fComputedValue /= 2.99792458E-2; + return kTRUE; + } else { + fComputedValue = fgkVeryBig; + return kFALSE; + } + } + } + else { + AliError(Form("[%s] Length information not available in AODs", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kTrackLength: + // single tracks: + // integrated length (computed only on ESDs) + if (esdt) { + fComputedValue = esdt->GetIntegratedLength(); + return kTRUE; + } + else { + AliError(Form("[%s] Length information not available in AODs", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + //--------------------------------------------------------------------------------------------------------------------- + case kPairP1: + // pair: + // momentum of first daughter (which matches definition #1 in pairDef) + fComputedValue = useMC ? pSim0.Mag() : pRec0.Mag(); + return kTRUE; + case kPairP2: + // pair: + // momentum of second daughter (which matches definition #2 in pairDef) + fComputedValue = useMC ? pSim1.Mag() : pRec1.Mag(); + return kTRUE; + case kPairP1t: + // pair: + // transverse momentum of first daughter + fComputedValue = useMC ? pSim0.Perp() : pRec0.Perp(); + return kTRUE; + case kPairP2t: + // pair: + // transverse momentum of second daughter + fComputedValue = useMC ? pSim1.Perp() : pRec1.Perp(); + return kTRUE; + case kPairP1z: + // pair: + // longitudinal momentum of first daughter + fComputedValue = useMC ? pSim0.Z() : pRec0.Z(); + return kTRUE; + case kPairP2z: + // pair: + // longitudinal momentum of second daughter + fComputedValue = useMC ? pSim1.Z() : pRec1.Z(); + return kTRUE; + case kPairInvMass: + // pair: + // invariant mass + fComputedValue = useMC ? pSim.M() : pRec.M(); + return kTRUE; + case kPairInvMassRes: + // pair: + // invariant mass resolution (requires MC) + if (TMath::Abs(pSim.M()) > 0.0) { + fComputedValue = (pSim.M() - pRec.M()) / pSim.M(); + return kTRUE; + } + else { + AliError(Form("[%s] Caught a null MC mass", GetName())); + return kFALSE; + } + case kPairPt: + // pair: + // total transverse momentum + fComputedValue = useMC ? pSim.Perp() : pRec.Perp(); + return kTRUE; + case kPairEta: + // pair: + // pseudo-rapidiry + fComputedValue = useMC ? pSim.Eta() : pRec.Eta(); + return kTRUE; + case kPairMt: + // pair: + // transverse mass (requires an AliRsnPairDef to get mass hypothesis) + if (pairDef) { + pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); + pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass()); + fComputedValue = useMC ? pSim.Mt() : pRec.Mt(); + return kTRUE; + } + else { + AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kPairY: + // pair: + // rapidity (requires an AliRsnPairDef to get mass hypothesis) + if (pairDef) { + pRec.SetXYZM(pRec.X(), pRec.Y(), pRec.Z(), pairDef->GetMotherMass()); + pSim.SetXYZM(pSim.X(), pSim.Y(), pSim.Z(), pairDef->GetMotherMass()); + fComputedValue = useMC ? pSim.Rapidity() : pRec.Rapidity(); + return kTRUE; + } + else { + AliError(Form("[%s] Required a correctly initialized AliRsnPairDef support object to compute this value", GetName())); + fComputedValue = fgkVeryBig; + return kFALSE; + } + case kPairPhi: + // pair: + // phi angle of total momentum + fComputedValue = useMC ? pSim.Phi() : pRec.Phi(); + return kTRUE; + case kPairPtRatio: + // pair: + // ratio of relative sum and difference of daughter transverse momenta + if (useMC) { + fComputedValue = TMath::Abs(pSim0.Perp() - pSim1.Perp()); + fComputedValue /= TMath::Abs(pSim0.Perp() + pSim1.Perp()); + } else { + fComputedValue = TMath::Abs(pRec0.Perp() - pRec1.Perp()); + fComputedValue /= TMath::Abs(pRec0.Perp() + pRec1.Perp()); + } + return kTRUE; + case kPairDipAngle: + // pair: + // dip-angle in the transverse-Z plane + // (used to check conversion electrons) + if (useMC) { + fComputedValue = pSim0.Perp() * pSim1.Perp() + pSim0.Z() * pSim1.Z(); + fComputedValue /= pSim0.Mag() * pSim1.Mag(); + } else { + fComputedValue = pRec0.Perp() * pRec1.Perp() + pRec0.Z() * pRec1.Z(); + fComputedValue /= pRec0.Mag() * pRec1.Mag(); + } + fComputedValue = TMath::Abs(TMath::ACos(fComputedValue)); + return kTRUE; + case kPairCosThetaStar: + // pair: + // cosine of theta star angle + // (= angle of first daughter to the total momentum, in resonance rest frame) + fComputedValue = fMother->CosThetaStar(useMC); + return kTRUE; + case kPairQInv: + // pair: + // Q-invariant + pSim0 -= pSim1; + pRec0 -= pRec1; + fComputedValue = useMC ? pSim0.M() : pRec0.M(); + return kTRUE; + case kPairAngleToLeading: + // pair: + // angle w.r. to leading particle (if any) + fComputedValue = fMother->AngleToLeading(success); + return success; + //--------------------------------------------------------------------------------------------------------------------- + case kEventMult: + // event: + // multiplicity of tracks + fComputedValue = (Double_t)fEvent->GetMultiplicityFromTracks(); + return (fComputedValue >= 0); + case kEventMultMC: + // event: + // multiplicity of MC tracks + fComputedValue = (Double_t)fEvent->GetMultiplicityFromMC(); + return (fComputedValue >= 0); + case kEventMultESDCuts: + // event: + // multiplicity of good quality tracks + fComputedValue = fEvent->GetMultiplicityFromESDCuts(); + return (fComputedValue >= 0); + case kEventMultSPD: + // event: + // multiplicity of good quality tracks + fComputedValue = fEvent->GetMultiplicityFromSPD(); + return (fComputedValue >= 0); + case kEventLeadingPt: + // event: + // transverse momentum of leading particle + if (leadingID >= 0) { + AliRsnDaughter leadingPart = fEvent->GetDaughter(leadingID); + AliVParticle *ref = leadingPart.GetRef(); + fComputedValue = ref->Pt(); + return kTRUE; + } else { + AliError(Form("[%s] Leading ID has bad value (%d)", GetName(), leadingID)); + return kFALSE; + } + case kEventVz: + // event: + // Z position of primary vertex + fComputedValue = fEvent->GetRef()->GetPrimaryVertex()->GetZ(); + return kTRUE; + case kEventCentralityV0: + // event: + // centrality using V0 method + if (esdev) { + AliCentrality *centrality = esdev->GetCentrality(); + fComputedValue = centrality->GetCentralityPercentile("V0M"); + return kTRUE; + } else if (aodev) { + AliCentrality *centrality = aodev->GetCentrality(); + fComputedValue = centrality->GetCentralityPercentile("V0M"); + return kTRUE; + } else { + AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName())); + return kFALSE; + } + case kEventCentralityTrack: + // event: + // centrality using tracks method + if (esdev) { + AliCentrality *centrality = esdev->GetCentrality(); + fComputedValue = centrality->GetCentralityPercentile("TRK"); + return kTRUE; + } else if (aodev) { + AliCentrality *centrality = aodev->GetCentrality(); + fComputedValue = centrality->GetCentralityPercentile("TRK"); + return kTRUE; + } else { + AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName())); + return kFALSE; + } + case kEventCentralityCL1: + // event: + // centrality using CL1 method + if (esdev) { + AliCentrality *centrality = esdev->GetCentrality(); + fComputedValue = centrality->GetCentralityPercentile("CL1"); + return kTRUE; + } else if (aodev) { + AliCentrality *centrality = aodev->GetCentrality(); + fComputedValue = centrality->GetCentralityPercentile("CL1"); + return kTRUE; + } else { + AliError(Form("[%s] Neither the ESD nor the AOD events are initialized", GetName())); + return kFALSE; + } + default: + AliError(Form("[%s] Invalid value type for this computation", GetName())); + return kFALSE; + } +} + +//_____________________________________________________________________________ +void AliRsnValueStd::Print(Option_t *option) const +{ +// +// Print informations about this object +// + + AliInfo("=== VALUE INFO ================================================="); + AliInfo(Form(" Name : %s", GetName())); + AliInfo(Form(" Type : %s", GetValueTypeName())); + AliInfo(Form(" Current computed value: %f", fComputedValue)); + if (!strcmp(option, "BINS")) { + Int_t i; + for (i = 0; i < fBinArray.GetSize(); i++) { + AliInfo(Form(" Bin limit #%03d = %f", i, fBinArray[i])); + } + } + AliInfo(Form(" Support object : %s", (fSupportObject ? fSupportObject->ClassName() : " NO SUPPORT"))); + AliInfo("=== END VALUE INFO ============================================="); +} + +//_____________________________________________________________________________ +RSNTARGET AliRsnValueStd::TargetType(EValueType type) +{ +// +// This method assigns the target to be expected by this object +// in the computation, depending on its type chosen in the enum. +// + + if (type < kTrackValues) + return AliRsnTarget::kDaughter; + else if (type < kPairValues) + return AliRsnTarget::kMother; + else + return AliRsnTarget::kEvent; +} diff --git a/PWG2/RESONANCES/AliRsnValueStd.h b/PWG2/RESONANCES/AliRsnValueStd.h new file mode 100644 index 00000000000..fccbbf8825f --- /dev/null +++ b/PWG2/RESONANCES/AliRsnValueStd.h @@ -0,0 +1,92 @@ +#ifndef ALIRSNVALUESTD_H +#define ALIRSNVALUESTD_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//////////////////////////////////////////////////////////////////////////////// +// +// Collection of all values which can be computed within the package +// +//////////////////////////////////////////////////////////////////////////////// + +#include "AliRsnValue.h" + +class AliRsnValueStd : public AliRsnValue { +public: + + enum EValueType { + kTrackP, // single track total momentum + kTrackPt, // single track transverse momentum + kTrackPtpc, // single track total momentum in the TPC inner wall + kTrackEta, // single track pseudo-rapidity + kTrackY, // single track rapidity + kTrackITSsignal, // single track ITS signal + kTrackTPCsignal, // single track TPC signal + kTrackTOFsignal, // single track TOF signal + kTrackTOFbeta, // single track beta from TOF + kTrackLength, // single track integrated length + kTrackValues, // --- limit for track values ----------------------------------------- + + kPairP1, // total momentum of 1st daughter of a pair + kPairP2, // total momentum of 2nd daughter of a pair + kPairP1t, // transverse momentum of 1st daughter of a pair + kPairP2t, // transverse momentum of 2nd daughter of a pair + kPairP1z, // longitudinal momentum of 1st daughter of a pair + kPairP2z, // longitudinal momentum of 2nd daughter of a pair + kPairInvMass, // pair invariant mass (with reconstructed momenta) + kPairInvMassMC, // pair invariant mass (with MC momenta) + kPairInvMassRes, // pair invariant mass resolution + kPairPt, // pair transverse momentum + kPairPz, // pair longitudinal momentum + kPairEta, // pair pseudo-rapidity + kPairMt, // pair transverse mass (need a reference mass) + kPairY, // pair rapidity (need a reference mass) + kPairPhi, // pair azimuthal angle (with reconstructed momenta) + kPairPhiMC, // pair azimuthal angle (with MC momenta) + kPairPtRatio, // ratio |pt1 - pt2|/(pt1 + pt2) of daughter transverse momenta + kPairDipAngle, // inverse cosine of the angle between daughter vector momenta + kPairCosThetaStar, // polarization angle + kPairQInv, // invariant relative momentum of the two daughters + kPairAngleToLeading, // angle between pair momentum and leading particle + kPairValues, // --- limit for pair values ------------------------------------------ + + kEventLeadingPt, // transverse momentum of the event leading particle + kEventMult, // multiplicity computed as the number of tracks + kEventMultMC, // multiplicity from MC + kEventMultESDCuts, // multiplicity of good quality tracks + kEventMultSPD, // multiplicity from SPD + kEventVz, // Z position of event primary vertex + kEventCentralityV0, // event centrality (V0 method) + kEventCentralityTrack, // event centrality (tracks method) + kEventCentralityCL1, // event centrality (CL1 method) + kValueTypes // --- limit for event values (and global) ---------------------------- + }; + + AliRsnValueStd(); + AliRsnValueStd(const char *name, EValueType type, Int_t nbins = 0, Double_t min = 0.0, Double_t max = 0.0); + AliRsnValueStd(const char *name, EValueType type, Double_t min, Double_t max, Double_t step); + AliRsnValueStd(const char *name, EValueType type, Int_t nbins, Double_t *array); + AliRsnValueStd(const AliRsnValueStd& copy); + AliRsnValueStd& operator=(const AliRsnValueStd& copy); + virtual ~AliRsnValueStd() { /*does nothing, since pointers are not owned by this object*/ } + + EValueType GetValueType() const {return fValueType;} + const char* GetValueTypeName() const; + TObject* GetSupportObject() {return fSupportObject;} + void SetSupportObject(TObject *obj) {fSupportObject = obj;} + void SetValueType(EValueType type) {fValueType = type; fTargetType = TargetType(type);} + + virtual Bool_t Eval(TObject *object, Bool_t useMC = kFALSE); + virtual void Print(Option_t *option = "") const; + static RSNTARGET TargetType(EValueType type); + +protected: + + EValueType fValueType; // value type + TObject *fSupportObject; // support object needed for computing some of the values + + ClassDef(AliRsnValueStd, 1) // AliRsnValueStd class +}; + +#endif diff --git a/PWG2/RESONANCES/extra/AddAnalysisTaskResonanceQA.C b/PWG2/RESONANCES/extra/AddAnalysisTaskResonanceQA.C new file mode 100644 index 00000000000..225d4970361 --- /dev/null +++ b/PWG2/RESONANCES/extra/AddAnalysisTaskResonanceQA.C @@ -0,0 +1,17 @@ +Bool_t AddAnalysisTaskResonanceQA() +{ + // retrieve analysis manager + AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); + AliAnalysisTaskResonanceQA *task = new AliAnalysisTaskResonanceQA("test"); + + // initialize containers + AliAnalysisDataContainer *out = mgr->CreateContainer("out", TList::Class(), AliAnalysisManager::kOutputContainer, mgr->GetCommonFileName()); + + // connect containers to AnalysisManager + mgr->AddTask(task); + mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer()); + mgr->ConnectOutput(task, 1, out); + + return kTRUE; +} + diff --git a/PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.cxx b/PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.cxx new file mode 100644 index 00000000000..7b6208e3d86 --- /dev/null +++ b/PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.cxx @@ -0,0 +1,394 @@ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "AliESDpid.h" +#include "AliESDtrack.h" +#include "AliESDEvent.h" +#include "AliESDVertex.h" +#include "AliESDtrackCuts.h" + +#include "AliPID.h" +#include "AliAnalysisTask.h" +#include "AliAnalysisManager.h" +#include "AliInputEventHandler.h" + +#include "AliMCEvent.h" +#include "AliStack.h" +#include "AliMCParticle.h" +#include "AliGenEventHeader.h" + +#include "AliAnalysisTaskResonanceQA.h" + +// analysis task creating basic QA plots for resonance particles +// Author: Ayben Karasu Uysal + + +ClassImp(AliAnalysisTaskResonanceQA) + +//________________________________________________________________________ +AliAnalysisTaskResonanceQA::AliAnalysisTaskResonanceQA(const char *name) : + AliAnalysisTaskSE(name), + fT0(AliESDpid::kTOF_T0), + fPrimaryThr(1E-6), + fOutputList(0), + fSelectedEvts(0), + fdEdxTPC(0), + fdEdxITS(0), + fTOFpid(0), + fDCAXYvsPtBeforeCuts(0), + fDCAZvsPtBeforeCuts(0), + fNClusterPtBeforeCuts(0), + fNFindableClusterPtBeforeCuts(0), + fNCrossedRowsTPCPtBeforeCuts(0), + fProducedParticles(0), + fESD(0), + fESDpid(0), + fTrackCuts(0) +{ +// +// Constructor +// + + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + + // Output slot #0 id reserved by the base class for AOD + // Output slot #1 writes into a TH1 container + DefineOutput(1, TList::Class()); + + // setup to NULL all remaining histos + Int_t i; + for (i = 0; i < kResonances; i++) fRsnYPt[0][i] = fRsnYPt[1][i] = 0; +} + +//________________________________________________________________________ +const char* AliAnalysisTaskResonanceQA::RsnName(ERsn type) +{ +// +// Return a short string with name of resonance +// + + switch(type) { + case kPhi : return "Phi"; + case kKStar0 : return "KStar0"; + case kRho : return "Rho"; + case kLambdaStar: return "LambdaStar"; + case kXiStar0 : return "XiStar0"; + case kXiStarM : return "XiStarM"; + case kSigmaStarP: return "SigmaStarP"; + case kSigmaStar0: return "SigmaStar0"; + case kSigmaStarM: return "SigmaStarM"; + case kDeltaPP : return "DeltaPP"; + default : return "Unknown"; + } +} + +//________________________________________________________________________ +const char* AliAnalysisTaskResonanceQA::RsnSymbol(ERsn type) +{ +// +// Return a short string with name of resonance +// + + switch(type) { + case kPhi : return "#phi"; + case kKStar0 : return "K^{*0}"; + case kRho : return "#rho"; + case kLambdaStar: return "#Lambda^{*}"; + case kXiStar0 : return "#Xi^{*0}"; + case kXiStarM : return "#Xi^{*-}"; + case kSigmaStarP: return "#Sigma^{*+}"; + case kSigmaStar0: return "#Sigma^{*0}"; + case kSigmaStarM: return "#Sigma^{*-}"; + case kDeltaPP : return "#Delta^{++}"; + default : return "Unknown"; + } +} + +//________________________________________________________________________ +Int_t AliAnalysisTaskResonanceQA::RsnPDG(ERsn type) +{ +// +// Return PDG code of resonance +// + + switch(type) { + case kPhi : return 333; + case kKStar0 : return 313; + case kRho : return 113; + case kLambdaStar: return 3124; + case kXiStar0 : return 3324; + case kXiStarM : return 3314; + case kSigmaStarP: return 3224; + case kSigmaStar0: return 3214; + case kSigmaStarM: return 3114; + case kDeltaPP : return 2224; + default : return 0; + } +} + +//________________________________________________________________________ +void AliAnalysisTaskResonanceQA::UserCreateOutputObjects() +{ +// +// Create histograms (called once) +// + + Int_t i; + Int_t ESDdEdxBin = 1000; Double_t ESDdEdxMin = 0; Double_t ESDdEdxMax = 1000; + Int_t ESDQPBin = 900; Double_t ESDQPMin = -4.5; Double_t ESDQPMax = 4.5; + Int_t PtBin = 500; Double_t PtMin = 0.; Double_t PtMax = 10.; + Int_t YBin = 600; Double_t YMin = -15.; Double_t YMax = 15.; + + // standard objects + fESDpid = new AliESDpid(); + fTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE); + fTrackCuts->SetPtRange(0.1, 1E20); + fTrackCuts->SetEtaRange(-0.9, 0.9); + + // create output list + fOutputList = new TList(); + fOutputList->SetOwner(); + + // output histograms for PID signal + fSelectedEvts = new TH1I("fSelectedEvts", "fSelectedEvts;fSelectedEvts", 3, 0, 3); + fdEdxTPC = new TH2F("fdEdxTPC", "dEdxTPC, After all cuts;chargexmomentum p (GeV/c); TPC signal (a.u.)", ESDQPBin, ESDQPMin, ESDQPMax, ESDdEdxBin, ESDdEdxMin, ESDdEdxMax); + fdEdxITS = new TH2F("fdEdxITS", "dEdxITS, After all cuts;chargexmomentum p (GeV/c); TPC signal (a.u.)", ESDQPBin, ESDQPMin, ESDQPMax, ESDdEdxBin, ESDdEdxMin, ESDdEdxMax); + fTOFpid = new TH2F("fTOFpid", "TOF PID;p (GeV/c);#beta;", ESDQPBin, ESDQPMin, ESDQPMax, 300, 0.1, 1.2); + + // output histograms for track quality + fDCAXYvsPtBeforeCuts = new TH2F("DCAXYvsPtBeforeCuts", "DCAXYvsPtBeforeCuts;p_{t} (GeV/c);DCAXY", PtBin, PtMin, PtMax, 500, -10.0, 10.0); + fDCAZvsPtBeforeCuts = new TH2F("DCAZvsPtBeforeCuts", "DCAZvsPtBeforeCuts;p_{t} (GeV/c);DCAZ", PtBin, PtMin, PtMax, 500, -10.0, 10.0); + fNClusterPtBeforeCuts = new TH2F("NClusterPtBeforeCuts", "NClusterPtBeforeCuts;p_{t} (GeV/c);NClusters", PtBin, PtMin, PtMax, 180, 0., 180.); + fNFindableClusterPtBeforeCuts = new TH2F("NFindableClusterPtBeforeCuts", "NFindableClusterPtBeforeCuts;p_{t} (GeV/c);NClusters", PtBin, PtMin, PtMax, 180, 0., 180.); + fNCrossedRowsTPCPtBeforeCuts = new TH2F("NCrossedRowsTPCPtBeforeCuts", "NCrossedRowsTPCPtBeforeCuts;p_{t} (GeV/c);NCrossedRowsTPC", PtBin, PtMin, PtMax, 180, 0., 180.); + + // output histograms for resonances + fProducedParticles = new TH1I("ProducedParticles", "ProducedParticles;Produced Particles", kResonances, 0, kResonances); + for (i = 0; i < kResonances; i++) { + fRsnYPt[0][i] = new TH2F(Form("%s_all", RsnName(i)), Form("%s -- ALL;p_{t} (GeV/c);Rapidity", RsnName(i)), PtBin, PtMin, PtMax, YBin, YMin, YMax); + fRsnYPt[1][i] = new TH2F(Form("%s_prim", RsnName(i)), Form("%s -- PRIMARY;p_{t} (GeV/c);Rapidity", RsnName(i)), PtBin, PtMin, PtMax, YBin, YMin, YMax); + fProducedParticles->GetXaxis()->SetBinLabel(i + 1, RsnSymbol(i)); + } + + // add histogram to list + fOutputList->Add(fSelectedEvts); + fOutputList->Add(fdEdxTPC); + fOutputList->Add(fdEdxITS); + fOutputList->Add(fTOFpid); + fOutputList->Add(fDCAXYvsPtBeforeCuts); + fOutputList->Add(fDCAZvsPtBeforeCuts); + fOutputList->Add(fNClusterPtBeforeCuts); + fOutputList->Add(fNFindableClusterPtBeforeCuts); + fOutputList->Add(fNCrossedRowsTPCPtBeforeCuts); + fOutputList->Add(fProducedParticles); + for (i = 0; i < kResonances; i++) { + fOutputList->Add(fRsnYPt[0][i]); + fOutputList->Add(fRsnYPt[1][i]); + } + + PostData(1, fOutputList); +} + +//________________________________________________________________________ +void AliAnalysisTaskResonanceQA::UserExec(Option_t *) +{ +// +// Execute computations +// + + // first bin of this histogram counts processed events + // second bin counts events passing physics selection + // all events not passing physics selections are skipped + fSelectedEvts->Fill(0.1); + Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB); + if (!isSelected) return; + + // count selected events + fSelectedEvts->Fill(1.1); + + // loop on MC, if MC event and stack are available + AliMCEvent *mcEvent = MCEvent(); + if (mcEvent) { + // MC primary vertex + TArrayF mcVertex(3); + AliGenEventHeader *genEH = mcEvent->GenEventHeader(); + genEH->PrimaryVertex(mcVertex); + // loop on particles + AliStack *stack = mcEvent->Stack(); + if (stack) { + Int_t iTrack, irsn, pdg, mother, motherPDG, nTracks = stack->GetNtrack(); + Double_t dx, dy, dz, dist; + TLorentzVector vprod; + for (iTrack = 0; iTrack < nTracks; iTrack++) { + + // get particle + TParticle *part = stack->Particle(iTrack); + if (!part) { + AliError(Form("Could not receive track %d", iTrack)); + continue; + } + + // get PDG code of particle and check physical primary + pdg = part->GetPdgCode(); + mother = part->GetFirstMother(); + motherPDG = 0; + + // loop over possible resonances + for (irsn = 0; irsn < kResonances; irsn++) { + if (TMath::Abs(pdg) == RsnPDG(irsn)) { + // debug check + if (mother >= 0) { + TParticle *p = stack->Particle(mother); + motherPDG = p->GetPdgCode(); + } + part->ProductionVertex(vprod); + dx = mcVertex[0] - vprod.X(); + dy = mcVertex[1] - vprod.Y(); + dz = mcVertex[2] - vprod.Z(); + dist = TMath::Sqrt(dx*dx + dy*dy + dz*dz); + AliDebugClass(1, Form("PDG = %d -- mother ID = %d, pdg = %d -- dist. from MC vertex = %f -- prod. time = %f", pdg, mother, motherPDG, dist, vprod.T())); + // global counter is always filled + fRsnYPt[0][irsn]->Fill(part->Pt(), part->Y()); + // counter for primaries is filled only if mother is less than 0 (primary) + if (dist < fPrimaryThr) fRsnYPt[1][irsn]->Fill(part->Pt(), part->Y()); + // fill the global histogram + fProducedParticles->Fill(irsn + 1); + // if one PDG match was found, no need to continue loop + break; + } + } + } + } + } + + // try to cast input event to ESD and loop on tracks + fESD = dynamic_cast(InputEvent()); + if (fESD) { + // check primary vertex: + // we accept only tracks/SPD with at least 1 contributor + const AliESDVertex *v0 = fESD->GetPrimaryVertexTracks(); + if (!v0) return; + if (v0->GetNContributors() < 1) { + v0 = fESD->GetPrimaryVertexSPD(); + if (!v0) return; + if (v0->GetNContributors() < 1) return; + } + if (!v0) return; + if (TMath::Abs(v0->GetZv()) > 10) return; + + // settings for TOF time zero + if (fESD->GetTOFHeader()) + fESDpid->SetTOFResponse(fESD, AliESDpid::kTOF_T0); + else { + Float_t t0spread[10]; + Float_t intrinsicTOFres = 100; + for (Int_t i = 0; i < 10; i++) t0spread[i] = (TMath::Sqrt(fESD->GetSigma2DiamondZ())) / 0.03; //0.03 to convert from cm to ps + fESDpid->GetTOFResponse().SetT0resolution(t0spread); + fESDpid->GetTOFResponse().SetTimeResolution(intrinsicTOFres); + fESDpid->SetTOFResponse(fESD, fT0); + } + fESDpid->MakePID(fESD, kFALSE, 0.); + + // use some variables to store useful info + /*MISC */ Int_t iTrack, nTracks = fESD->GetNumberOfTracks(); + /*MISC */ Double_t pt; + /*QUALITY*/ Float_t impactXY, impactZ, nCrossedRowsTPC; + /*ITS */ Double_t itsSignal = 0; + /*TPC */ Double_t ptotSE = 0, tpcSignal, signSE; + /*TOF */ Double_t momentum, length, time, beta; //, times[AliPID::kSPECIES], tzeroTrack = 0; + + // loop on tracks + for (iTrack = 0; iTrack < nTracks; iTrack++) { + + // get track + AliESDtrack* track = fESD->GetTrack(iTrack); + if (!track) continue; + + // get transverse momentum (used for quality histograms) + pt = track->Pt(); + + // get charge and reject neutrals + signSE = track->GetSign(); + if (signSE == 0) continue; + + // get DCA and TPC-related quality params + track->GetImpactParameters(impactXY, impactZ); + nCrossedRowsTPC = track->GetTPCClusterInfo(2, 1); + + // fill quality histograms when status flags are OK for TPC in+refit and ITS refit + if (track->IsOn(AliESDtrack::kTPCin) && track->IsOn(AliESDtrack::kTPCrefit) && track->IsOn(AliESDtrack::kITSrefit)) { + fNClusterPtBeforeCuts ->Fill(pt, track->GetTPCNcls()); + fNFindableClusterPtBeforeCuts->Fill(pt, track->GetTPCNclsF()); + fNCrossedRowsTPCPtBeforeCuts ->Fill(pt, nCrossedRowsTPC); + fDCAXYvsPtBeforeCuts ->Fill(pt, impactXY); + fDCAZvsPtBeforeCuts ->Fill(pt, impactZ); + } + + // from now on, work only with tracks passing standard cuts for 2010 + if (!fTrackCuts->AcceptTrack(track)) continue; + + // get momentum (used for PID histograms) + momentum = track->P(); + + // ITS + itsSignal = track->GetITSsignal(); + fdEdxITS->Fill(signSE * momentum, itsSignal); + + // TPC + if (track->GetInnerParam()) { + AliExternalTrackParam trackIn1(*track->GetInnerParam()); + ptotSE = trackIn1.GetP(); + tpcSignal = track->GetTPCsignal(); + fdEdxTPC->Fill(signSE * ptotSE, tpcSignal); + } // end TPC + + // TOF (requires checking some more status flags + if (track->IsOn(AliESDtrack::kTOFpid) && track->IsOn(AliESDtrack::kTOFout) && track->IsOn(AliESDtrack::kTIME) && !track->IsOn(AliESDtrack::kTOFmismatch)) { + length = track->GetIntegratedLength(); + + // reject suspiciously small lengths/times + if (track->GetIntegratedLength() < 350.) continue; + if (track->GetTOFsignal() < 1E-6) continue; + + // thhese are maybe not needed + // track->GetIntegratedTimes(times); + // tzeroTrack = fESDpid->GetTOFResponse().GetStartTime(track->P()); + + // get TOF measured time and compute beta + time = track->GetTOFsignal() - fESDpid->GetTOFResponse().GetStartTime(momentum); + beta = length / (2.99792457999999984e-02 * time); + fTOFpid->Fill(signSE * momentum, beta); + } // end TOF + } // end track loop + } // end ESD check + + // if we arrive here, the event was processed successfully + // then we fill last bin in first histogram + fSelectedEvts->Fill(2.1); + + PostData(1, fOutputList); +} + +//________________________________________________________________________ +void AliAnalysisTaskResonanceQA::Terminate(Option_t *) +{ +// +// Termination +// Quickly check that the output list is there +// + + fOutputList = dynamic_cast(GetOutputData(1)); + if (!fOutputList) { + AliError("Output list not found!!!"); + return; + } +} diff --git a/PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.h b/PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.h new file mode 100644 index 00000000000..81d4ba4c7d8 --- /dev/null +++ b/PWG2/RESONANCES/extra/AliAnalysisTaskResonanceQA.h @@ -0,0 +1,84 @@ +#ifndef ALIANALYSISTASTRESONANCEQA_H +#define ALIANALYSISTASTRESONANCEQA_H + +// analysis task creating basic QA plots for resonance particles +// Author: Ayben Karasu Uysal + +class TH1I; +class TH1F; +class TH2F; + +class AliESDpid; +class AliESDEvent; +class AliESDtrackCuts; + +#include "AliAnalysisTaskSE.h" + +class AliAnalysisTaskResonanceQA : public AliAnalysisTaskSE { +public: + + enum ERsn { + kPhi = 0, + kKStar0, + kRho, + kLambdaStar, + kXiStar0, + kXiStarM, + kSigmaStarP, + kSigmaStar0, + kSigmaStarM, + kDeltaPP, + + // this must be last and counter + kResonances + }; + + AliAnalysisTaskResonanceQA(const char *name = "RsnQA"); + virtual ~AliAnalysisTaskResonanceQA() {} + + virtual void UserCreateOutputObjects(); + virtual void UserExec(Option_t *option); + virtual void Terminate(Option_t *); + + void SetT0(AliESDpid::EStartTimeType_t ftype) {fT0 = ftype;} + void SetPrimaryThr(Double_t d) {fPrimaryThr = d;} + + const char* RsnName (Int_t type) {return RsnName ((ERsn)type);} + const char* RsnSymbol(Int_t type) {return RsnSymbol((ERsn)type);} + Int_t RsnPDG (Int_t type) {return RsnPDG ((ERsn)type);} + const char* RsnName (ERsn type); + const char* RsnSymbol(ERsn type); + Int_t RsnPDG (ERsn type); + +private: + + AliESDpid::EStartTimeType_t fT0; + Double_t fPrimaryThr; + + TList *fOutputList; + + TH1I *fSelectedEvts; + TH2F *fdEdxTPC; + TH2F *fdEdxITS; + TH2F *fTOFpid; + TH2F *fDCAXYvsPtBeforeCuts; + TH2F *fDCAZvsPtBeforeCuts; + TH2F *fNClusterPtBeforeCuts; + TH2F *fNFindableClusterPtBeforeCuts; + TH2F *fNCrossedRowsTPCPtBeforeCuts; + TH2F *fRsnYPt[2][kResonances]; + TH1I *fProducedParticles; + + AliESDEvent *fESD; + AliESDpid *fESDpid; + AliESDtrackCuts *fTrackCuts; + + AliAnalysisTaskResonanceQA(const AliAnalysisTaskResonanceQA&); + AliAnalysisTaskResonanceQA& operator=(const AliAnalysisTaskResonanceQA&); + + ClassDef(AliAnalysisTaskResonanceQA, 1); +}; + +#endif + + diff --git a/PWG2/RESONANCES/extra/AliRsnAnalysisPhi7TeV.cxx b/PWG2/RESONANCES/extra/AliRsnAnalysisPhi7TeV.cxx index c7026ab3bdc..6dc19eb3f8c 100644 --- a/PWG2/RESONANCES/extra/AliRsnAnalysisPhi7TeV.cxx +++ b/PWG2/RESONANCES/extra/AliRsnAnalysisPhi7TeV.cxx @@ -37,7 +37,6 @@ #include "AliRsnEvent.h" #include "AliRsnTarget.h" #include "AliRsnDaughter.h" -#include "AliRsnCutESD2010.h" #include "AliRsnAnalysisPhi7TeV.h" -- 2.39.3