1 /**************************************************************************
\r
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
\r
4 * Author: The ALICE Off-line Project. *
\r
5 * Contributors are mentioned in the code where appropriate. *
\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
21 #include "TCanvas.h"
\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
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
39 #include "dNdPt/AlidNdPtTask.h"
\r
41 using namespace std;
\r
43 ClassImp(AlidNdPtTask)
\r
45 //_____________________________________________________________________________
\r
46 AlidNdPtTask::AlidNdPtTask(const char *name)
\r
47 : AliAnalysisTask(name, "dNdPt analysis")
\r
53 , fUseMCInfo(kFALSE)
\r
57 // Define input and output slots here
\r
58 DefineInput(0, TChain::Class());
\r
59 DefineOutput(0, TList::Class());
\r
61 // create the list for comparison objects
\r
62 fCompList = new TList;
\r
65 //_____________________________________________________________________________
\r
66 AlidNdPtTask::~AlidNdPtTask()
\r
68 if(fOutput) delete fOutput; fOutput =0;
\r
71 //____________________________________________________________________________
\r
72 Bool_t AlidNdPtTask::Notify()
\r
74 static Int_t count = 0;
\r
76 Printf("Processing %d. file", count);
\r
78 TChain *chain = (TChain*)GetInputData(0);
\r
79 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
\r
81 Printf("ERROR: Could not get ESDInputHandler");
\r
85 Printf("chain->GetCurrentFile()->GetName() %s", chain->GetCurrentFile()->GetName());
\r
91 //_____________________________________________________________________________
\r
92 void AlidNdPtTask::ConnectInputData(Option_t *)
\r
94 // connect input data
\r
97 TTree *tree = dynamic_cast<TTree*> (GetInputData(0));
\r
99 Printf("ERROR: Could not read chain from input slot 0");
\r
103 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
\r
106 Printf("ERROR: Could not get ESDInputHandler");
\r
109 fESD = esdH->GetEvent();
\r
111 // Enable only the needed branches
\r
112 //esdH->SetActiveBranches("AliESDHeader Vertex Tracks");
\r
116 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
\r
117 if (!eventHandler) {
\r
118 Printf("ERROR: Could not retrieve MC event handler");
\r
121 fMC = eventHandler->MCEvent();
\r
126 //_____________________________________________________________________________
\r
127 Bool_t AlidNdPtTask::AddAnalysisObject(AlidNdPt *pObj)
\r
129 // add analysis object to the list
\r
131 Printf("ERROR: Could not add comparison object");
\r
135 // add object to the list
\r
136 fCompList->AddLast(pObj);
\r
141 //_____________________________________________________________________________
\r
142 void AlidNdPtTask::CreateOutputObjects()
\r
144 // Create histograms
\r
147 OpenFile(0, "RECREATE");
\r
150 // create output list
\r
152 fOutput = new TList;
\r
153 fOutput->SetOwner();
\r
154 fPitList = fOutput->MakeIterator();
\r
156 // add dNdPt analysis objects to the output
\r
159 TIterator *pitCompList = fCompList->MakeIterator();
\r
160 pitCompList->Reset();
\r
161 while(( pObj = (AlidNdPt *)pitCompList->Next()) != NULL) {
\r
162 fOutput->Add(pObj);
\r
165 Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);
\r
168 //_____________________________________________________________________________
\r
169 void AlidNdPtTask::Exec(Option_t *)
\r
171 // Called for each event
\r
173 Printf("ERROR: ESD event not available");
\r
177 // Process analysis
\r
178 AlidNdPt *pObj = 0;
\r
180 while((pObj = (AlidNdPt *)fPitList->Next()) != NULL) {
\r
181 pObj->Process(fESD,fMC);
\r
184 // Post output data.
\r
185 PostData(0, fOutput);
\r
188 //_____________________________________________________________________________
\r
189 void AlidNdPtTask::Terminate(Option_t *)
\r
191 // Called one at the end
\r
193 // check output data
\r
194 fOutput = dynamic_cast<TList*> (GetOutputData(0));
\r
196 Printf("ERROR: AlidNdPtTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );
\r