]>
Commit | Line | Data |
---|---|---|
0aaa8b91 | 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 | |
a8ac5525 | 74 | /*\r |
0aaa8b91 | 75 | static Int_t count = 0;\r |
76 | count++;\r | |
77 | Printf("Processing %d. file", count);\r | |
78 | \r | |
a8ac5525 | 79 | TChain *chain = (TChain*)GetInputData(0);\r |
80 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
81 | if (!esdH) {\r | |
82 | Printf("ERROR: Could not get ESDInputHandler");\r | |
83 | return kFALSE;\r | |
84 | } else {\r | |
85 | //Printf("esdH->Notify() %s", esdH->Notify());\r | |
86 | //Printf("fTree->GetCurrentFile()->GetName() %s", fTree->GetCurrentFile()->GetName());\r | |
87 | if(chain)\r | |
88 | Printf("chain->GetCurrentFile()->GetName() %s %s", chain->GetCurrentFile()->GetName(), );\r | |
89 | }\r | |
90 | */\r | |
91 | \r | |
0aaa8b91 | 92 | return kTRUE;\r |
93 | }\r | |
94 | \r | |
95 | //_____________________________________________________________________________\r | |
96 | void AlidNdPtTask::ConnectInputData(Option_t *) \r | |
97 | {\r | |
98 | // connect input data \r | |
99 | // called once\r | |
100 | \r | |
101 | TTree *tree = dynamic_cast<TTree*> (GetInputData(0));\r | |
102 | if (!tree) {\r | |
103 | Printf("ERROR: Could not read chain from input slot 0");\r | |
104 | return;\r | |
105 | }\r | |
106 | \r | |
107 | AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r | |
108 | \r | |
109 | if (!esdH) {\r | |
110 | Printf("ERROR: Could not get ESDInputHandler");\r | |
111 | return;\r | |
112 | } else {\r | |
113 | fESD = esdH->GetEvent();\r | |
114 | \r | |
115 | // Enable only the needed branches\r | |
116 | //esdH->SetActiveBranches("AliESDHeader Vertex Tracks");\r | |
117 | }\r | |
118 | \r | |
119 | if (fUseMCInfo) {\r | |
120 | AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());\r | |
121 | if (!eventHandler) {\r | |
122 | Printf("ERROR: Could not retrieve MC event handler");\r | |
123 | return;\r | |
124 | } else { \r | |
125 | fMC = eventHandler->MCEvent();\r | |
126 | }\r | |
127 | }\r | |
128 | }\r | |
129 | \r | |
130 | //_____________________________________________________________________________\r | |
131 | Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj) \r | |
132 | {\r | |
133 | // add analysis object to the list\r | |
134 | if(pObj == 0) {\r | |
135 | Printf("ERROR: Could not add comparison object");\r | |
136 | return kFALSE;\r | |
137 | }\r | |
138 | \r | |
139 | // add object to the list\r | |
140 | fCompList->AddLast(pObj);\r | |
141 | \r | |
142 | return kTRUE;\r | |
143 | }\r | |
144 | \r | |
145 | //_____________________________________________________________________________\r | |
146 | void AlidNdPtTask::CreateOutputObjects()\r | |
147 | {\r | |
148 | // Create histograms\r | |
149 | // Called once\r | |
150 | \r | |
151 | OpenFile(0, "RECREATE");\r | |
152 | \r | |
153 | //\r | |
154 | // create output list\r | |
155 | //\r | |
156 | fOutput = new TList;\r | |
157 | fOutput->SetOwner();\r | |
158 | fPitList = fOutput->MakeIterator();\r | |
159 | \r | |
160 | // add dNdPt analysis objects to the output\r | |
161 | AlidNdPt *pObj=0;\r | |
162 | Int_t count=0;\r | |
163 | TIterator *pitCompList = fCompList->MakeIterator();\r | |
164 | pitCompList->Reset();\r | |
165 | while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) {\r | |
166 | fOutput->Add(pObj);\r | |
167 | count++;\r | |
168 | }\r | |
169 | Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);\r | |
170 | }\r | |
171 | \r | |
172 | //_____________________________________________________________________________\r | |
173 | void AlidNdPtTask::Exec(Option_t *) \r | |
174 | {\r | |
175 | // Called for each event\r | |
176 | if (!fESD) {\r | |
177 | Printf("ERROR: ESD event not available");\r | |
178 | return;\r | |
179 | }\r | |
180 | \r | |
181 | // Process analysis\r | |
182 | AlidNdPt *pObj = 0;\r | |
183 | fPitList->Reset();\r | |
184 | while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) {\r | |
185 | pObj->Process(fESD,fMC);\r | |
186 | }\r | |
187 | \r | |
188 | // Post output data.\r | |
189 | PostData(0, fOutput);\r | |
190 | }\r | |
191 | \r | |
192 | //_____________________________________________________________________________\r | |
193 | void AlidNdPtTask::Terminate(Option_t *) \r | |
194 | {\r | |
195 | // Called one at the end \r | |
196 | \r | |
197 | // check output data\r | |
198 | fOutput = dynamic_cast<TList*> (GetOutputData(0));\r | |
199 | if (!fOutput) {\r | |
200 | Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r | |
201 | return;\r | |
202 | }\r | |
203 | }\r |