]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/dNdPt/AlidNdPtTask.cxx
Corrected compilation error with gcc 4.4
[u/mrichter/AliRoot.git] / PWG0 / dNdPt / AlidNdPtTask.cxx
1 /**************************************************************************\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
3 *                                                                        *\r
4 * Author: The ALICE Off-line Project.                                    *\r
5 * Contributors are mentioned in the code where appropriate.              *\r
6 *                                                                        *\r
7 * Permission to use, copy, modify and distribute this software and its   *\r
8 * documentation strictly for non-commercial purposes is hereby granted   *\r
9 * without fee, provided that the above copyright notice appears in all   *\r
10 * copies and that both the copyright notice and this permission notice   *\r
11 * appear in the supporting documentation. The authors make no claims     *\r
12 * about the suitability of this software for any purpose. It is          *\r
13 * provided "as is" without express or implied warranty.                  *\r
14 **************************************************************************/\r
15 \r
16 #include "iostream"\r
17 \r
18 #include "TChain.h"\r
19 #include "TTree.h"\r
20 #include "TH1F.h"\r
21 #include "TCanvas.h"\r
22 #include "TList.h"\r
23 #include "TFile.h"\r
24 \r
25 #include "AliAnalysisTask.h"\r
26 #include "AliAnalysisManager.h"\r
27 #include "AliESDEvent.h"\r
28 #include "AliESDInputHandler.h"\r
29 #include "AliESDVertex.h"\r
30 #include "AliTracker.h"\r
31 #include "AliGeomManager.h"\r
32 \r
33 #include "AliESDtrackCuts.h"\r
34 #include "AliMCEventHandler.h"\r
35 #include "dNdPt/AlidNdPt.h"\r
36 #include "dNdPt/AlidNdPtEventCuts.h"\r
37 #include "dNdPt/AlidNdPtAcceptanceCuts.h"\r
38 \r
39 #include "dNdPt/AlidNdPtTask.h"\r
40 \r
41 using namespace std;\r
42 \r
43 ClassImp(AlidNdPtTask)\r
44 \r
45 //_____________________________________________________________________________\r
46 AlidNdPtTask::AlidNdPtTask(const char *name) \r
47   : AliAnalysisTask(name, "dNdPt analysis")\r
48   , fESD(0)\r
49   , fMC(0)\r
50   , fOutput(0)\r
51   , fPitList(0)\r
52   , fCompList(0)\r
53   , fUseMCInfo(kFALSE)\r
54 {\r
55   // Constructor\r
56 \r
57   // Define input and output slots here\r
58   DefineInput(0, TChain::Class());\r
59   DefineOutput(0, TList::Class());\r
60 \r
61   // create the list for comparison objects\r
62   fCompList = new TList;\r
63 }\r
64 \r
65 //_____________________________________________________________________________\r
66 AlidNdPtTask::~AlidNdPtTask()\r
67 {\r
68   if(fOutput) delete fOutput;  fOutput =0; \r
69 }\r
70 \r
71 //____________________________________________________________________________\r
72 Bool_t AlidNdPtTask::Notify()\r
73 {\r
74   static Int_t count = 0;\r
75   count++;\r
76   Printf("Processing %d. file", count);\r
77 \r
78 return kTRUE;\r
79 }\r
80 \r
81 //_____________________________________________________________________________\r
82 void AlidNdPtTask::ConnectInputData(Option_t *) \r
83 {\r
84 // connect input data \r
85 // called once\r
86 \r
87   TTree *tree = dynamic_cast<TTree*> (GetInputData(0));\r
88   if (!tree) {\r
89     Printf("ERROR: Could not read chain from input slot 0");\r
90     return;\r
91   }\r
92 \r
93   AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
94 \r
95   if (!esdH) {\r
96     Printf("ERROR: Could not get ESDInputHandler");\r
97     return;\r
98   } else {\r
99     fESD = esdH->GetEvent();\r
100 \r
101     // Enable only the needed branches\r
102     //esdH->SetActiveBranches("AliESDHeader Vertex Tracks");\r
103   }\r
104 \r
105   if (fUseMCInfo) {\r
106     AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());\r
107     if (!eventHandler) {\r
108       Printf("ERROR: Could not retrieve MC event handler");\r
109       return;\r
110     } else { \r
111       fMC = eventHandler->MCEvent();\r
112     }\r
113   }\r
114 }\r
115 \r
116 //_____________________________________________________________________________\r
117 Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj) \r
118 {\r
119   // add analysis object to the list\r
120   if(pObj == 0) {\r
121     Printf("ERROR: Could not add comparison object");\r
122     return kFALSE;\r
123   }\r
124 \r
125   // add object to the list\r
126   fCompList->AddLast(pObj);\r
127        \r
128 return kTRUE;\r
129 }\r
130 \r
131 //_____________________________________________________________________________\r
132 void AlidNdPtTask::CreateOutputObjects()\r
133 {\r
134   // Create histograms\r
135   // Called once\r
136 \r
137   OpenFile(0, "RECREATE");\r
138 \r
139   //\r
140   // create output list\r
141   //\r
142   fOutput = new TList;\r
143   fOutput->SetOwner();\r
144   fPitList = fOutput->MakeIterator();\r
145 \r
146   // add dNdPt analysis objects to the output\r
147   AlidNdPt *pObj=0;\r
148   Int_t count=0;\r
149   TIterator *pitCompList = fCompList->MakeIterator();\r
150   pitCompList->Reset();\r
151   while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) {\r
152     fOutput->Add(pObj);\r
153     count++;\r
154   }\r
155   Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r
156 }\r
157 \r
158 //_____________________________________________________________________________\r
159 void AlidNdPtTask::Exec(Option_t *) \r
160 {\r
161   // Called for each event\r
162   if (!fESD) {\r
163     Printf("ERROR: ESD event not available");\r
164     return;\r
165   }\r
166 \r
167   // Process analysis\r
168   AlidNdPt *pObj = 0;\r
169   fPitList->Reset();\r
170   while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) {\r
171     pObj->Process(fESD,fMC);\r
172   }\r
173 \r
174   // Post output data.\r
175   PostData(0, fOutput);\r
176 }\r
177 \r
178 //_____________________________________________________________________________\r
179 void AlidNdPtTask::Terminate(Option_t *) \r
180 {\r
181   // Called one at the end \r
182   \r
183   // check output data\r
184   fOutput = dynamic_cast<TList*> (GetOutputData(0));\r
185   if (!fOutput) {\r
186     Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
187     return;\r
188   }\r
189 }\r