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