]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/totEt/AliAnalysisTaskTransverseEnergy.cxx
- Adding initialisation of detector variable - Adding functions to get hadronic contr...
[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)
29 ,fEsdtrackCutsITSTPC(0)
30 ,fEsdtrackCutsTPC(0)
31 ,fEsdtrackCutsITS(0)
32 ,fOutputList(0)
33 ,fPhysSelTaskName("selctionTask")
34 ,fCentSelTaskName("centralityTask")
35 ,fIsMc(isMc)
36 ,fUsingDefaultSelection(true)
a7ae9b24 37 ,fCurrentRunNum(-1)
e97ddc0e 38 ,fSelectionHandler(0)
39{
40 // Constructor
41 LoadPhysicsSelection("physicsSelections.root");
42}
43
44AliAnalysisTaskTransverseEnergy::~AliAnalysisTaskTransverseEnergy()
ea331c5d 45{ // destructor
46 delete fHistEtRecvsEtMC;
47 delete fEsdtrackCutsITSTPC;
48 delete fEsdtrackCutsTPC;
49 delete fEsdtrackCutsITS;
50 delete fOutputList;
51 delete fSelectionHandler;
e97ddc0e 52}
53
54Int_t AliAnalysisTaskTransverseEnergy::CheckPhysicsSelection(Int_t runNumber)
55{
56 // Check if the physics selection is valid, if not load a new one
a7ae9b24 57 if (runNumber == fCurrentRunNum || fIsMc)
e97ddc0e 58 {
59 return 0;
60 }
61 else
62 {
63 AliPhysicsSelection *selection = 0;
0f6416f3 64 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
65 if(!mgr){
66 AliError("Error: no analysis manager");
67 return -1;
68 }
69 AliPhysicsSelectionTask *physSelTask = dynamic_cast<AliPhysicsSelectionTask*>(mgr->GetTask("AliPhysicsSelectionTask"));
e97ddc0e 70 if (physSelTask)
71 {
72
73 if ((selection = fSelectionHandler->GetPhysicsSelection(runNumber)))
74 {
75 }
76 else if ((selection = fSelectionHandler->GetDefaultPhysicsSelection()))
77 {
78 fUsingDefaultSelection = true;
79 }
80 else if ((selection = new AliPhysicsSelection()))
81 {
82 fUsingDefaultSelection = true;
83 }
84 else
85 {
86 AliError("Something went very wrong, not able to load/create new physics selection");
87 return -1;
88 }
89 }
90 else
91 {
92 AliError("Could not get physics selection task from manager, undefined or no selection will be used");
93 return -1;
94 }
95 AliInfo("Changing the physics selection");
0f6416f3 96 AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (mgr->GetInputEventHandler());
e97ddc0e 97 // 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 98 if(!handler){
6a0df78a 99 AliError("Analysis manager does not exist!");
100 return -1;
101 }
e97ddc0e 102 physSelTask->SetPhysicsSelection(selection);
103 handler->SetEventSelection(selection);
a7ae9b24 104 fCurrentRunNum = runNumber;
e97ddc0e 105
106 }
107
108 return 1;
109}
110
111Bool_t AliAnalysisTaskTransverseEnergy::IsPhysicsSelected() const
112{
113 // See header file for class documentation
114 if(fIsMc) return true;
115 if(!fUsingDefaultSelection) return (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kUserDefined);
116 return (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
117}
118
119Int_t AliAnalysisTaskTransverseEnergy::LoadPhysicsSelection(TString name)
120{
121 // See header file for class documentation
122 if(fIsMc) return 0;
123 fSelectionHandler = new AliAnalysisEtSelectionHandler(name);
124 if (!fSelectionHandler) return -1;
125 return 0;
126}
127
b6dd6ad2 128AliCentrality* AliAnalysisTaskTransverseEnergy::GetCentralityObject()
e97ddc0e 129{
130 // See header file for class documentation
131 if (fESDEvent)return fESDEvent->GetCentrality();
132 else return 0;
133}
134
135