]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/dNdPt/AlidNdPtTask.cxx
Adding absolute paths to macros, fitting DCA with 3 components (primaries + fakes...
[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   : AliAnalysisTaskSE(name)\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   DefineOutput(1, TList::Class());\r
59 \r
60   // create the list for comparison objects\r
61   fCompList = new TList;\r
62 }\r
63 \r
64 //_____________________________________________________________________________\r
65 AlidNdPtTask::~AlidNdPtTask()\r
66 {\r
67   if(fOutput) delete fOutput;  fOutput =0; \r
68   if(fCompList) delete fCompList;  fCompList =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: %s", count, ((TTree*) GetInputData(0))->GetCurrentFile()->GetName());\r
77   TTree *chain = (TChain*)GetInputData(0);\r
78   if(chain)\r
79     Printf("Processing %d. file: %s", count, chain->GetCurrentFile()->GetName());\r
80 \r
81   /*\r
82   TChain *chain = (TChain*)GetInputData(0);\r
83   AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
84   if (!esdH) {\r
85     Printf("ERROR: Could not get ESDInputHandler");\r
86     return kFALSE;\r
87   } else {\r
88     if(chain)\r
89     Printf("chain->GetCurrentFile()->GetName() %s", chain->GetCurrentFile()->GetName());\r
90   }\r
91   */\r
92 \r
93 return kTRUE;\r
94 }\r
95 \r
96 //_____________________________________________________________________________\r
97 Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj) \r
98 {\r
99   // add analysis object to the list\r
100   if(pObj == 0) {\r
101     Printf("ERROR: Could not add comparison object");\r
102     return kFALSE;\r
103   }\r
104 \r
105   // add object to the list\r
106   fCompList->AddLast(pObj);\r
107        \r
108 return kTRUE;\r
109 }\r
110 \r
111 //_____________________________________________________________________________\r
112 void AlidNdPtTask::UserCreateOutputObjects()\r
113 {\r
114   // Create histograms\r
115   // Called once\r
116 \r
117   OpenFile(1, "RECREATE");\r
118 \r
119   //\r
120   // create output list\r
121   //\r
122   fOutput = new TList;\r
123   fOutput->SetOwner();\r
124   fPitList = fOutput->MakeIterator();\r
125 \r
126   // add dNdPt analysis objects to the output\r
127   AlidNdPt *pObj=0;\r
128   Int_t count=0;\r
129   TIterator *pitCompList = fCompList->MakeIterator();\r
130   pitCompList->Reset();\r
131   while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) {\r
132     fOutput->Add(pObj);\r
133     count++;\r
134   }\r
135   Printf("UserCreateOutputObjects(): Number of output objects: %d \n", count);\r
136 }\r
137 \r
138 //_____________________________________________________________________________\r
139 void AlidNdPtTask::UserExec(Option_t *) \r
140 {\r
141   //\r
142   // Called for each event\r
143   //\r
144 \r
145   // ESD event\r
146   fESD = (AliESDEvent*) (InputEvent());\r
147   if (!fESD) {\r
148     Printf("ERROR: ESD event not available");\r
149     return;\r
150   }\r
151 \r
152   // MC event\r
153   if(fUseMCInfo) {\r
154     fMC = MCEvent();\r
155     if (!fMC) {\r
156       Printf("ERROR: MC event not available");\r
157       return;\r
158     }\r
159   }\r
160 \r
161   // Process analysis\r
162   AlidNdPt *pObj = 0;\r
163   fPitList->Reset();\r
164   while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) {\r
165     pObj->Process(fESD,fMC);\r
166   }\r
167 \r
168   // Post output data.\r
169   PostData(1, fOutput);\r
170 }\r
171 \r
172 //_____________________________________________________________________________\r
173 void AlidNdPtTask::Terminate(Option_t *) \r
174 {\r
175   // Called one at the end \r
176   \r
177   // check output data\r
178   fOutput = dynamic_cast<TList*> (GetOutputData(1));\r
179   if (!fOutput) {\r
180     Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );\r
181     return;\r
182   }\r
183 }\r