Correcting coding violations in HadEt classes, adding container class for hadronic...
[u/mrichter/AliRoot.git] / PWG4 / totEt / AliAnalysisTaskHadEt.cxx
1 //Create by Christine Nattrass, Rebecca Scott, Irakli Martashvili
2 //University of Tennessee at Knoxville
3 #include "TChain.h"
4 #include "TTree.h"
5 #include "TH1F.h"
6 #include "TH2F.h"
7 #include "TNtuple.h"
8 #include "TCanvas.h"
9 #include "TMath.h"
10 #include "TObjArray.h"
11
12 #include "AliAnalysisTask.h"
13 #include "AliAnalysisManager.h"
14
15 #include "AliESDEvent.h"
16 #include "AliAODEvent.h"
17 #include "AliVEvent.h"
18 #include "AliVTrack.h"
19 #include "AliVParticle.h"
20 #include "AliESDtrack.h"
21 #include "AliESDInputHandler.h"
22 #include "AliMCEvent.h"
23 #include "AliMCParticle.h"
24 #include "TDatabasePDG.h"
25 #include "AliAnalysisTaskHadEt.h"
26
27 #include <iostream>
28 #include "AliStack.h"
29
30 using namespace std;
31
32 ClassImp(AliAnalysisTaskHadEt)
33
34
35
36 //________________________________________________________________________
37 AliAnalysisTaskHadEt::AliAnalysisTaskHadEt(const char *name) :
38         AliAnalysisTaskSE(name)
39         ,fESD(0)
40         ,fOutputList(0)
41         ,fRecAnalysis(0)
42         ,fMCAnalysis(0)
43         ,fHistEtRecvsEtMC(0)
44         ,fTriggerSelection(false)
45         ,fCount(0)
46         ,fkPhotonPdg(22)
47         ,fkProtonMass(.938)
48         ,fPdgDB(0)
49         ,fRecEventVars(0)
50         ,fSimEventVars(0)
51         ,ffesdtrackCutsITSTPC(0)
52         ,fesdtrackCutsTPC(0)
53         ,fesdtrackCutsITS(0)
54 {
55     // Constructor
56
57     fRecAnalysis = new AliAnalysisHadEtReconstructed();
58     fRecAnalysis->Init();
59     fMCAnalysis = new AliAnalysisHadEtMonteCarlo();
60     fMCAnalysis->Init();
61     if(!fPdgDB) fPdgDB = new TDatabasePDG();
62
63     fTriggerSelection = false;
64     fCount = 0;
65
66     // Define input and output slots here
67     // Input slot #0 works with a TChain
68     DefineInput(0, TChain::Class());
69     // Output slot #1 writes into a TH1 container
70
71     DefineOutput(1, TList::Class());
72
73 }
74
75
76 //________________________________________________________________________
77 void AliAnalysisTaskHadEt::UserCreateOutputObjects()
78 {
79     // Create histograms
80     // Called once
81   fOutputList = new TList;
82   fMCAnalysis->SetHistoList(fOutputList);
83   fRecAnalysis->SetHistoList(fOutputList);
84   fMCAnalysis->CreateHistograms();
85   fRecAnalysis->CreateHistograms();
86   fRecAnalysis->FillOutputList();
87   fMCAnalysis->FillOutputList();
88
89
90     Bool_t selectPrimaries=kTRUE;
91     ffesdtrackCutsITSTPC = AliESDtrackCuts::GetStandardITSTPCTrackCuts2009(selectPrimaries);
92     ffesdtrackCutsITSTPC->SetName("fEsdTrackCuts");
93     fesdtrackCutsTPC = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
94     fesdtrackCutsTPC->SetName("fEsdTrackCutsTPCOnly");
95     //ITS stand alone cuts - similar to 2009 cuts but with only ITS hits required
96     fesdtrackCutsITS =  new AliESDtrackCuts;
97     fesdtrackCutsITS->SetName("fEsdTrackCutsITS");
98     fesdtrackCutsITS->SetRequireITSRefit(kTRUE);
99     fesdtrackCutsITS->SetRequireITSStandAlone(kTRUE);
100     fesdtrackCutsITS->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
101     fesdtrackCutsITS->SetMaxDCAToVertexXYPtDep("0.0350+0.0420/pt^0.9");
102     fesdtrackCutsITS->SetMaxDCAToVertexZ(1.e6);
103     fesdtrackCutsITS->SetDCAToVertex2D(kFALSE);
104     fesdtrackCutsITS->SetRequireSigmaToVertex(kFALSE);
105     fesdtrackCutsITS->SetAcceptKinkDaughters(kFALSE);
106
107     fOutputList->Add(ffesdtrackCutsITSTPC);
108     fOutputList->Add(fesdtrackCutsTPC);
109     fOutputList->Add(fesdtrackCutsITS);
110     if(ffesdtrackCutsITSTPC && fesdtrackCutsTPC){
111       fRecAnalysis->SetITSTrackCuts( GetITSTrackCuts());
112       fMCAnalysis->SetITSTrackCuts( GetITSTrackCuts());
113       fRecAnalysis->SetTPCITSTrackCuts( GetTPCITSTrackCuts());
114       fMCAnalysis->SetTPCITSTrackCuts( GetTPCITSTrackCuts());
115       fRecAnalysis->SetTPCOnlyTrackCuts( GetTPCOnlyTrackCuts());
116       fMCAnalysis->SetTPCOnlyTrackCuts( GetTPCOnlyTrackCuts());
117       //add ITS stuff!
118     }
119     else{
120       Printf("Error: no track cuts!");
121     }
122
123 }
124
125 //________________________________________________________________________
126 void AliAnalysisTaskHadEt::UserExec(Option_t *)
127 {
128   AliESDEvent *event = dynamic_cast<AliESDEvent*>(InputEvent());
129 if (!event) {
130   Printf("ERROR: Could not retrieve event");
131   return;
132  }
133
134 fRecAnalysis->AnalyseEvent(event);
135
136 AliMCEvent* mcEvent = MCEvent();
137 if (mcEvent)
138   {
139     ((AliAnalysisHadEtMonteCarlo*)fMCAnalysis)->AnalyseEvent((AliVEvent*)mcEvent,(AliVEvent*)event);
140   }
141
142 // Post output data.
143 PostData(1, fOutputList);
144  
145 }
146
147 //________________________________________________________________________
148 void AliAnalysisTaskHadEt::Terminate(Option_t *)
149 {
150     // Draw result to the screen
151     // Called once at the end of the query
152
153     fOutputList = dynamic_cast<TList*> (GetOutputData(1));
154     if (!fOutputList) {
155         printf("ERROR: Output list not available\n");
156         return;
157     }
158 }
159
160