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