94a3377f3aac38f5c5102e939394b8a0f5f6dd1a
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisTaskHadEt.cxx
1 //_________________________________________________________________________
2 //  Utility Class for transverse energy studies; charged hadrons
3 //  Task for analysis
4 //  - reconstruction and MC output
5 // implementation file
6 //
7 //Created by Christine Nattrass, Rebecca Scott, Irakli Martashvili
8 //University of Tennessee at Knoxville
9 //_________________________________________________________________________
10
11 #include "TChain.h"
12 #include "TList.h"
13 #include "TH2F.h"
14
15 #include "AliESDEvent.h"
16 #include "AliMCEvent.h"
17 #include "AliESDtrackCuts.h"
18
19 #include "AliAnalysisTaskHadEt.h"
20 #include "AliAnalysisHadEtReconstructed.h"
21 #include "AliAnalysisHadEtMonteCarlo.h"
22
23 #include <iostream>
24
25 using namespace std;
26
27 ClassImp(AliAnalysisTaskHadEt)
28
29
30
31 //________________________________________________________________________
32 AliAnalysisTaskHadEt::AliAnalysisTaskHadEt(const char *name) :
33         AliAnalysisTaskSE(name)
34         ,fOutputList(0)
35         ,fRecAnalysis(0)
36         ,fMCAnalysis(0)
37         ,fHistEtRecvsEtMC(0)
38         ,fEsdtrackCutsITSTPC(0)
39         ,fEsdtrackCutsTPC(0)
40         ,fEsdtrackCutsITS(0)
41 {
42     // Constructor
43
44     fRecAnalysis = new AliAnalysisHadEtReconstructed();
45     fRecAnalysis->Init();
46     fMCAnalysis = new AliAnalysisHadEtMonteCarlo();
47     fMCAnalysis->Init();
48
49     // Define input and output slots here
50     // Input slot #0 works with a TChain
51     DefineInput(0, TChain::Class());
52     // Output slot #1 writes into a TH1 container
53
54     DefineOutput(1, TList::Class());
55
56 }
57
58
59 //________________________________________________________________________
60 void AliAnalysisTaskHadEt::UserCreateOutputObjects()
61 {
62     // Create histograms
63     // Called once
64   fOutputList = new TList;
65   fMCAnalysis->SetHistoList(fOutputList);
66   fRecAnalysis->SetHistoList(fOutputList);
67   fMCAnalysis->CreateHistograms();
68   fRecAnalysis->CreateHistograms();
69   fRecAnalysis->FillOutputList();
70   fMCAnalysis->FillOutputList();
71
72
73     Bool_t selectPrimaries=kTRUE;
74     fEsdtrackCutsITSTPC = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selectPrimaries);
75     fEsdtrackCutsITSTPC->SetName("fEsdTrackCuts");
76     fEsdtrackCutsTPC = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
77     fEsdtrackCutsTPC->SetName("fEsdTrackCutsTPCOnly");
78     //ITS stand alone cuts - similar to 2009 cuts but with only ITS hits required
79     fEsdtrackCutsITS =  AliESDtrackCuts::GetStandardITSPureSATrackCuts2009(kTRUE,kFALSE);//we do want primaries but we do not want to require PID info
80     fEsdtrackCutsITS->SetName("fEsdTrackCutsITS");
81
82     fOutputList->Add(fEsdtrackCutsITSTPC);
83     fOutputList->Add(fEsdtrackCutsTPC);
84     fOutputList->Add(fEsdtrackCutsITS);
85     if(fEsdtrackCutsITSTPC && fEsdtrackCutsTPC){
86       fRecAnalysis->SetITSTrackCuts( GetITSTrackCuts());
87       fMCAnalysis->SetITSTrackCuts( GetITSTrackCuts());
88       fRecAnalysis->SetTPCITSTrackCuts( GetTPCITSTrackCuts());
89       fMCAnalysis->SetTPCITSTrackCuts( GetTPCITSTrackCuts());
90       fRecAnalysis->SetTPCOnlyTrackCuts( GetTPCOnlyTrackCuts());
91       fMCAnalysis->SetTPCOnlyTrackCuts( GetTPCOnlyTrackCuts());
92       //add ITS stuff!
93     }
94     else{
95       Printf("Error: no track cuts!");
96     }
97
98 }
99
100 //________________________________________________________________________
101 void AliAnalysisTaskHadEt::UserExec(Option_t *)
102 { // execute method
103   AliESDEvent *event = dynamic_cast<AliESDEvent*>(InputEvent());
104 if (!event) {
105   Printf("ERROR: Could not retrieve event");
106   return;
107  }
108
109 fRecAnalysis->AnalyseEvent(event);
110
111 AliMCEvent* mcEvent = MCEvent();
112 if (mcEvent)
113   {
114     ((AliAnalysisHadEtMonteCarlo*)fMCAnalysis)->AnalyseEvent((AliVEvent*)mcEvent,(AliVEvent*)event);
115   }
116
117 // Post output data.
118 PostData(1, fOutputList);
119  
120 }
121
122 //________________________________________________________________________
123 void AliAnalysisTaskHadEt::Terminate(Option_t *)
124 {
125     // Draw result to the screen
126     // Called once at the end of the query
127
128     fOutputList = dynamic_cast<TList*> (GetOutputData(1));
129     if (!fOutputList) {
130         printf("ERROR: Output list not available\n");
131         return;
132     }
133 }
134
135