]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/totEt/AliAnalysisTaskTransverseEnergy.cxx
Korrektion for
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisTaskTransverseEnergy.cxx
CommitLineData
e97ddc0e 1#include "AliAnalysisTaskTransverseEnergy.h"
2#include "AliAnalysisEtSelectionHandler.h"
3#include "AliAnalysisManager.h"
4#include "AliInputEventHandler.h"
5#include "AliPhysicsSelectionTask.h"
6#include "AliPhysicsSelection.h"
b6dd6ad2 7#include "AliCentrality.h"
e97ddc0e 8#include "AliESDEvent.h"
a7ae9b24 9//_________________________________________________________________________
10// Utility Class for transverse energy studies
11// Base class for Et tasks
12// - reconstruction and MonteCarlo output
13//
14//*-- Authors: Oystein Djuvsland (Bergen)
15//_________________________________________________________________________//
16#include "AliESDtrackCuts.h"
e97ddc0e 17#include "AliLog.h"
ea331c5d 18#include "TH2F.h"
e97ddc0e 19#include <iostream>
20
21ClassImp(AliAnalysisTaskTransverseEnergy)
22
23AliAnalysisTaskTransverseEnergy::AliAnalysisTaskTransverseEnergy(const char* name, Bool_t isMc) :
24 AliAnalysisTaskSE(name)
25 ,fESDEvent(0)
26 ,fMCConfigFile("ConfigEtMonteCarlo.C")
27 ,fRecoConfigFile("ConfigEtReconstructed.C")
28 ,fHistEtRecvsEtMC(0)
a403aff5 29 ,fHistEtRecOverEtMC(0)
476828ae 30 ,fHistDiffEtRecEtMCOverEtMC(0)
e97ddc0e 31 ,fEsdtrackCutsITSTPC(0)
32 ,fEsdtrackCutsTPC(0)
33 ,fEsdtrackCutsITS(0)
34 ,fOutputList(0)
35 ,fPhysSelTaskName("selctionTask")
36 ,fCentSelTaskName("centralityTask")
37 ,fIsMc(isMc)
38 ,fUsingDefaultSelection(true)
a7ae9b24 39 ,fCurrentRunNum(-1)
e97ddc0e 40 ,fSelectionHandler(0)
41{
42 // Constructor
43 LoadPhysicsSelection("physicsSelections.root");
44}
45
46AliAnalysisTaskTransverseEnergy::~AliAnalysisTaskTransverseEnergy()
ea331c5d 47{ // destructor
48 delete fHistEtRecvsEtMC;
a403aff5 49 delete fHistEtRecOverEtMC;
ea331c5d 50 delete fEsdtrackCutsITSTPC;
51 delete fEsdtrackCutsTPC;
52 delete fEsdtrackCutsITS;
53 delete fOutputList;
54 delete fSelectionHandler;
e97ddc0e 55}
56
57Int_t AliAnalysisTaskTransverseEnergy::CheckPhysicsSelection(Int_t runNumber)
58{
59 // Check if the physics selection is valid, if not load a new one
a403aff5 60
a7ae9b24 61 if (runNumber == fCurrentRunNum || fIsMc)
e97ddc0e 62 {
63 return 0;
64 }
65 else
66 {
67 AliPhysicsSelection *selection = 0;
0f6416f3 68 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
69 if(!mgr){
70 AliError("Error: no analysis manager");
71 return -1;
72 }
73 AliPhysicsSelectionTask *physSelTask = dynamic_cast<AliPhysicsSelectionTask*>(mgr->GetTask("AliPhysicsSelectionTask"));
e97ddc0e 74 if (physSelTask)
75 {
76
77 if ((selection = fSelectionHandler->GetPhysicsSelection(runNumber)))
78 {
79 }
80 else if ((selection = fSelectionHandler->GetDefaultPhysicsSelection()))
81 {
82 fUsingDefaultSelection = true;
83 }
84 else if ((selection = new AliPhysicsSelection()))
85 {
86 fUsingDefaultSelection = true;
87 }
88 else
89 {
90 AliError("Something went very wrong, not able to load/create new physics selection");
91 return -1;
92 }
93 }
94 else
95 {
96 AliError("Could not get physics selection task from manager, undefined or no selection will be used");
97 return -1;
98 }
99 AliInfo("Changing the physics selection");
0f6416f3 100 AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (mgr->GetInputEventHandler());
e97ddc0e 101 // The physics selection task has a bit weird implementation, setting the the physics selection will not update the handler, so we do it manually
0f6416f3 102 if(!handler){
6a0df78a 103 AliError("Analysis manager does not exist!");
104 return -1;
105 }
e97ddc0e 106 physSelTask->SetPhysicsSelection(selection);
107 handler->SetEventSelection(selection);
a7ae9b24 108 fCurrentRunNum = runNumber;
e97ddc0e 109
110 }
111
112 return 1;
113}
114
115Bool_t AliAnalysisTaskTransverseEnergy::IsPhysicsSelected() const
116{
117 // See header file for class documentation
118 if(fIsMc) return true;
119 if(!fUsingDefaultSelection) return (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kUserDefined);
120 return (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
121}
122
123Int_t AliAnalysisTaskTransverseEnergy::LoadPhysicsSelection(TString name)
124{
125 // See header file for class documentation
126 if(fIsMc) return 0;
127 fSelectionHandler = new AliAnalysisEtSelectionHandler(name);
128 if (!fSelectionHandler) return -1;
129 return 0;
130}
131
b6dd6ad2 132AliCentrality* AliAnalysisTaskTransverseEnergy::GetCentralityObject()
e97ddc0e 133{
134 // See header file for class documentation
135 if (fESDEvent)return fESDEvent->GetCentrality();
136 else return 0;
137}
138
139