]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.cxx
Access to the file analyzed available now in analysis classes through the reader...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnalysisTaskParticleCorrelation.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15 /* $Id: $ */
16
17 //_________________________________________________________________________
18 // Analysis task that executes the analysis classes
19 // that depend on the PartCorr frame, frame for Particle identification and correlations.
20 // Specially designed for calorimeters but also can be used for charged tracks
21 // Input of this task is a configuration file that contains all the settings of the analyis
22 //
23 // -- Author: Gustavo Conesa (INFN-LNF)
24
25 #include <cstdlib>
26
27 // --- Root ---
28 #include <TROOT.h>
29 #include <TInterpreter.h>
30 //#include <Riostream.h>
31
32 // --- Analysis ---
33 #include "AliAnalysisTaskParticleCorrelation.h"
34 #include "AliAnaPartCorrMaker.h"
35 #include "AliCaloTrackReader.h"
36 #include "AliPDG.h"
37
38 ClassImp(AliAnalysisTaskParticleCorrelation)
39
40 ////////////////////////////////////////////////////////////////////////
41 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation():
42   AliAnalysisTaskSE(),
43   fAna(0x0),
44   fOutputContainer(0x0),
45   fConfigName(0)
46 {
47   // Default constructor
48 }
49
50 //_____________________________________________________
51 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(const char* name):
52   AliAnalysisTaskSE(name),
53   fAna(0x0),
54   fOutputContainer(0x0),
55   fConfigName("")
56 {
57   // Default constructor
58   
59   DefineOutput(1, TList::Class());
60   
61 }
62
63 //_____________________________________________________
64 AliAnalysisTaskParticleCorrelation::~AliAnalysisTaskParticleCorrelation() 
65 {
66   // Remove all pointers
67   
68   if(fOutputContainer){
69     fOutputContainer->Clear() ; 
70     delete fOutputContainer ;
71   }
72
73 }
74
75 //_____________________________________________________
76 void AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects()
77 {
78   // Create the output container
79   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - Begin\n");
80   
81   //Get list of aod arrays, add each aod array to analysis frame 
82   TClonesArray * array = 0;
83   TList * list = fAna->GetAODBranchList();
84   for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++){
85     array = (TClonesArray*) list->At(iaod);
86     AddAODBranch("TClonesArray", &array);
87   } 
88   
89   //Histograms container
90   OpenFile(1);
91   fOutputContainer = fAna->GetOutputContainer();
92   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - End\n");
93 }
94
95 //_____________________________________________________
96 void AliAnalysisTaskParticleCorrelation::Init()
97 {
98   // Initialization
99  
100   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - Begin\n");
101   
102   // Call configuration file if specified
103   
104   if (fConfigName.Length()) {
105     printf("AliAnalysisTaskParticleCorrelation::Init() - ### Configuration file is %s.C ###\n", fConfigName.Data());
106         gROOT->LoadMacro(fConfigName+".C");
107         fAna = (AliAnaPartCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
108   }
109   
110   if(!fAna) {
111         printf("AliAnalysisTaskParticleCorrelation::Init() - Analysis maker pointer not initialized, no analysis specified, STOP!\n");
112         abort();
113   }
114   
115   // Add different generator particles to PDG Data Base 
116   // to avoid problems when reading MC generator particles
117   AliPDG::AddParticlesToPdgDataBase();
118
119   // Initialise analysis
120   fAna->Init();
121   
122   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - End\n");
123   
124 }
125
126
127 //_____________________________________________________
128 void AliAnalysisTaskParticleCorrelation::UserExec(Option_t */*option*/)
129 {
130   // Execute analysis for current event
131   //
132   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - Begin\n");
133
134    //Get the type of data, check if type is correct
135   Int_t  datatype = fAna->GetReader()->GetDataType();
136   if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
137      datatype != AliCaloTrackReader::kMC){
138     printf("AliAnalysisTaskParticleCorrelation::UserExec() - Wrong type of data\n");
139     return ;
140   }
141   
142   fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
143
144   //Process event
145   fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
146   //printf("AliAnalysisTaskParticleCorrelation::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName());
147   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - End\n");
148   
149   PostData(1, fOutputContainer);
150   
151 }
152
153 //_____________________________________________________
154 void AliAnalysisTaskParticleCorrelation::Terminate(Option_t */*option*/)
155 {
156   // Terminate analysis
157   // Do some plots
158
159   // Get merged histograms from the output container
160   TList *outputList = (TList*)GetOutputData(1);
161   // Propagate histagrams to maker
162   fAna->Terminate(outputList);
163         
164 }
165