]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/totEt/AliAnalysisTaskTransverseEnergy.cxx
Korrektion for
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisTaskTransverseEnergy.cxx
1 #include "AliAnalysisTaskTransverseEnergy.h"
2 #include "AliAnalysisEtSelectionHandler.h"
3 #include "AliAnalysisManager.h"
4 #include "AliInputEventHandler.h"
5 #include "AliPhysicsSelectionTask.h"
6 #include "AliPhysicsSelection.h"
7 #include "AliCentrality.h"
8 #include "AliESDEvent.h"
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"
17 #include "AliLog.h"
18 #include "TH2F.h"
19 #include <iostream>
20
21 ClassImp(AliAnalysisTaskTransverseEnergy)
22
23 AliAnalysisTaskTransverseEnergy::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         ,fHistEtRecOverEtMC(0)
30         ,fHistDiffEtRecEtMCOverEtMC(0)
31         ,fEsdtrackCutsITSTPC(0)
32         ,fEsdtrackCutsTPC(0)
33         ,fEsdtrackCutsITS(0)
34         ,fOutputList(0)
35         ,fPhysSelTaskName("selctionTask")
36         ,fCentSelTaskName("centralityTask")
37         ,fIsMc(isMc)
38         ,fUsingDefaultSelection(true)
39         ,fCurrentRunNum(-1)
40         ,fSelectionHandler(0)
41 {
42   // Constructor
43     LoadPhysicsSelection("physicsSelections.root");
44 }
45
46 AliAnalysisTaskTransverseEnergy::~AliAnalysisTaskTransverseEnergy()
47 {    // destructor
48   delete fHistEtRecvsEtMC;
49   delete fHistEtRecOverEtMC;
50   delete fEsdtrackCutsITSTPC;
51   delete fEsdtrackCutsTPC;
52   delete fEsdtrackCutsITS;
53   delete fOutputList;
54   delete fSelectionHandler;
55 }
56
57 Int_t AliAnalysisTaskTransverseEnergy::CheckPhysicsSelection(Int_t runNumber)
58 {
59   // Check if the physics selection is valid, if not load a new one
60   
61     if (runNumber == fCurrentRunNum || fIsMc)
62     {
63         return 0;
64     }
65     else
66     {
67         AliPhysicsSelection *selection = 0;
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"));
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");
100         AliInputEventHandler* handler = dynamic_cast<AliInputEventHandler*> (mgr->GetInputEventHandler());
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
102         if(!handler){
103             AliError("Analysis manager does not exist!");
104             return -1;
105         }
106         physSelTask->SetPhysicsSelection(selection);
107         handler->SetEventSelection(selection);
108         fCurrentRunNum = runNumber;
109
110     }
111
112     return 1;
113 }
114
115 Bool_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
123 Int_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
132 AliCentrality* AliAnalysisTaskTransverseEnergy::GetCentralityObject()
133 {
134   // See header file for class documentation
135     if (fESDEvent)return fESDEvent->GetCentrality();
136     else return 0;
137 }
138
139