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
16 //------------------------------------------------------------------------------
\r
17 // Implementation of the AliComparisonTask class. It compares properties of the
\r
18 // reconstructed and MC particle tracks under several conditions.
\r
19 // As the input it requires the tree with AliRecInfo and AliMCInfo branches. Such
\r
20 // tree can be prepared in advance by runing AliGenInfoMaker and then AliRecInfoMaker
\r
21 // (details in description of these classes).
\r
23 // The comparison output objects deriving from AliComparisonObject
\r
24 // (e.g. AliComparisonRes, AliComparisonEff, AliComparisonDEdxA, AliComparisonDCA ...)
\r
25 // are stored in the output file (details in description of these classes).
\r
27 // Author: J.Otwinowski 04/02/2008
\r
28 //------------------------------------------------------------------------------
\r
35 #include "TCanvas.h"
\r
39 #include "AliAnalysisTask.h"
\r
40 #include "AliAnalysisManager.h"
\r
41 #include "AliESDEvent.h"
\r
42 #include "AliESDInputHandler.h"
\r
43 #include "AliESDVertex.h"
\r
44 #include "AliMagF.h"
\r
45 #include "AliTracker.h"
\r
46 #include "AliGeomManager.h"
\r
48 #include "AliMCInfo.h"
\r
49 #include "AliESDRecInfo.h"
\r
50 #include "AliMCInfoCuts.h"
\r
51 #include "AliRecInfoCuts.h"
\r
52 #include "AliComparisonRes.h"
\r
53 #include "AliComparisonEff.h"
\r
54 #include "AliComparisonDEdx.h"
\r
55 #include "AliComparisonDCA.h"
\r
56 #include "AliComparisonObject.h"
\r
57 #include "AliComparisonTask.h"
\r
59 using namespace std;
\r
61 ClassImp(AliComparisonTask)
\r
63 Int_t AliComparisonTask::fEvtNumber = 0;
\r
65 //_____________________________________________________________________________
\r
66 AliComparisonTask::AliComparisonTask(const char *name)
\r
67 : AliAnalysisTask(name, "")
\r
77 // Define input and output slots here
\r
78 DefineInput(0, TChain::Class());
\r
79 DefineOutput(0, TList::Class());
\r
81 // create the list for comparison objects
\r
82 fCompList = new TList;
\r
85 //_____________________________________________________________________________
\r
86 AliComparisonTask::~AliComparisonTask()
\r
88 if(fOutput) delete fOutput; fOutput =0;
\r
89 if(fCompList) delete fCompList; fCompList =0;
\r
92 //_____________________________________________________________________________
\r
93 void AliComparisonTask::ConnectInputData(Option_t *)
\r
95 // Connect input data
\r
98 fTree = dynamic_cast<TTree*> (GetInputData(0));
\r
100 Printf("ERROR: Could not read chain from input slot 0");
\r
102 fTree->SetBranchStatus("*",1);
\r
105 if(fTree->GetBranch("MC") && fTree->GetBranch("RC")) {
\r
106 fTree->GetBranch("MC")->SetAddress(&fInfoMC);
\r
107 fTree->GetBranch("RC")->SetAddress(&fInfoRC);
\r
109 Printf("ERROR: Could not get MC and RC branches");
\r
113 //_____________________________________________________________________________
\r
114 Bool_t AliComparisonTask::AddComparisonObject(AliComparisonObject *pObj)
\r
116 // add comparison object to the list
\r
118 Printf("ERROR: Could not add comparison object");
\r
122 // add object to the list
\r
123 fCompList->AddLast(pObj);
\r
128 //_____________________________________________________________________________
\r
129 void AliComparisonTask::CreateOutputObjects()
\r
131 // Create histograms
\r
134 // create output list
\r
135 fOutput = new TList;
\r
136 fOutput->SetOwner();
\r
137 fPitList = fOutput->MakeIterator();
\r
139 AliComparisonObject *pObj=0;
\r
142 // add comparison objects to the output
\r
143 TIterator *pitCompList = fCompList->MakeIterator();
\r
144 pitCompList->Reset();
\r
145 while(( pObj = (AliComparisonObject *)pitCompList->Next()) != NULL) {
\r
146 fOutput->Add(pObj);
\r
149 Printf("CreateOutputObjects(): Number of output comparison objects: %d \n", count);
\r
152 //_____________________________________________________________________________
\r
153 Bool_t AliComparisonTask::ReadEntry(Int_t evt)
\r
155 // Read entry from the tree
\r
156 Long64_t centry = fTree->LoadTree(evt);
\r
157 if(centry < 0) return kFALSE;
\r
159 if(fTree->GetBranch("MC") && fTree->GetBranch("RC")) {
\r
160 fTree->GetBranch("MC")->SetAddress(&fInfoMC);
\r
161 fTree->GetBranch("RC")->SetAddress(&fInfoRC);
\r
163 Printf("ERROR: Could not get MC and RC branches");
\r
166 fTree->GetEntry(evt);
\r
170 //_____________________________________________________________________________
\r
171 void AliComparisonTask::Exec(Option_t *)
\r
174 // Called for each event
\r
176 AliComparisonObject *pObj=0;
\r
178 if (!fInfoMC && !fInfoRC) {
\r
179 Printf("ERROR: fInfoMC && fInfoRC not available");
\r
183 // Process comparison
\r
184 Bool_t status = ReadEntry(fEvtNumber);
\r
185 if(status == kTRUE)
\r
188 while(( pObj = (AliComparisonObject *)fPitList->Next()) != NULL) {
\r
189 pObj->Exec(fInfoMC,fInfoRC);
\r
193 if( !( fEvtNumber % 10000) ) {
\r
194 cout << fEvtNumber << endl;
\r
198 // Post output data.
\r
199 PostData(0, fOutput);
\r
202 //_____________________________________________________________________________
\r
203 void AliComparisonTask::Terminate(Option_t *)
\r
205 // Called one at the end
\r
207 // check output data
\r
208 fOutput = dynamic_cast<TList*> (GetOutputData(0));
\r
210 Printf("ERROR: AliComparisonTask::Terminate(): Output data not avaiable GetOutputData(0)==0x0 ..." );
\r