]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliAnalysisTaskParticleCorrelation.cxx
If not needed do not create the histograms in the neutral meson selection task
[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 <TClonesArray.h>
31 //#include <Riostream.h>
32 //#include <TObjectTable.h>
33
34 // --- Analysis ---
35 #include "AliAnalysisTaskParticleCorrelation.h"
36 #include "AliAnaPartCorrMaker.h"
37 #include "AliCaloTrackReader.h"
38 #include "AliPDG.h"
39 #include "AliAnalysisManager.h"
40
41 ClassImp(AliAnalysisTaskParticleCorrelation)
42
43 ////////////////////////////////////////////////////////////////////////
44 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation():
45   AliAnalysisTaskSE(),
46   fAna(0x0),
47   fOutputContainer(0x0),
48   fConfigName(""), fCuts(0x0)
49 {
50   // Default constructor
51 }
52
53 //_____________________________________________________
54 AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(const char* name):
55   AliAnalysisTaskSE(name),
56   fAna(0x0),
57   fOutputContainer(0x0),
58   fConfigName(""), fCuts(0x0)
59 {
60   // Default constructor
61   
62   DefineOutput(1, TList::Class());
63   DefineOutput(2, TList::Class());  // will contain cuts or local params
64 }
65
66 //_____________________________________________________
67 AliAnalysisTaskParticleCorrelation::~AliAnalysisTaskParticleCorrelation() 
68 {
69   // Remove all pointers
70         
71 //      printf("********** Delete Task\n");
72 //  // Do not delete it here, already done somewhere else, need to understand where.
73 //  if(fOutputContainer){
74 //    fOutputContainer->Clear() ; 
75 //    delete fOutputContainer ;
76 //  }
77
78   if(fAna) delete fAna;
79
80 //  printf("********** Task deleted \n");
81 }
82
83 //_____________________________________________________
84 void AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects()
85 {
86   // Create the output container
87   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - Begin\n");
88   
89   //Get list of aod arrays, add each aod array to analysis frame 
90   TClonesArray *array = 0;
91   TList * list = fAna->GetAODBranchList();
92   TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
93   for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++){
94     array = (TClonesArray*) list->At(iaod);
95         if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
96         else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
97   } 
98         
99   //Histograms container
100   OpenFile(1);
101   fOutputContainer = fAna->GetOutputContainer();
102   fOutputContainer->SetOwner(kTRUE);
103   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - End\n");
104  
105   PostData(1,fOutputContainer);
106         
107 }
108 //_____________________________________________________
109 void AliAnalysisTaskParticleCorrelation::LocalInit()
110 {
111         // Local Initialization
112         
113         //Call the Init to initialize the configuration of the analysis
114         Init();
115         
116         // Create cuts/param objects and publish to slot
117         fCuts = fAna->GetListOfAnalysisCuts();
118         
119         // Post Data
120         PostData(2, fCuts);
121         
122 }
123
124 //_____________________________________________________
125 void AliAnalysisTaskParticleCorrelation::Init()
126 {
127   // Initialization
128  
129   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - Begin\n");
130   
131   // Call configuration file if specified
132   
133   if (fConfigName.Length()) {
134     printf("AliAnalysisTaskParticleCorrelation::Init() - ### Configuration file is %s.C ###\n", fConfigName.Data());
135         gROOT->LoadMacro(fConfigName+".C");
136         fAna = (AliAnaPartCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
137   }
138   
139   if(!fAna) {
140         printf("AliAnalysisTaskParticleCorrelation::Init() - Analysis maker pointer not initialized, no analysis specified, STOP !\n");
141         abort();
142   }
143   
144   // Add different generator particles to PDG Data Base 
145   // to avoid problems when reading MC generator particles
146   AliPDG::AddParticlesToPdgDataBase();
147
148   //Set in the reader the name of the task in case is needed
149   (fAna->GetReader())->SetTaskName(GetName());
150         
151   // Initialise analysis
152   fAna->Init();
153
154   //Delta AOD
155   if((fAna->GetReader())->GetDeltaAODFileName()!="")
156           AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
157
158   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - End\n");
159   
160 }
161
162
163 //_____________________________________________________
164 void AliAnalysisTaskParticleCorrelation::UserExec(Option_t */*option*/)
165 {
166   // Execute analysis for current event
167   //
168   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - Begin\n");
169
170    //Get the type of data, check if type is correct
171   Int_t  datatype = fAna->GetReader()->GetDataType();
172   if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
173      datatype != AliCaloTrackReader::kMC){
174     printf("AliAnalysisTaskParticleCorrelation::UserExec() - Wrong type of data\n");
175     return ;
176   }
177
178   fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
179
180   //Process event
181   fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
182   //printf("AliAnalysisTaskParticleCorrelation::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName());
183   if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - End\n");
184         
185   PostData(1, fOutputContainer);
186         
187   //gObjectTable->Print();
188
189   
190 }
191
192 //_____________________________________________________
193 void AliAnalysisTaskParticleCorrelation::Terminate(Option_t */*option*/)
194 {
195   // Terminate analysis
196   // Do some plots
197
198   // Get merged histograms from the output container
199   // Propagate histagrams to maker
200   fAna->Terminate((TList*)GetOutputData(1));
201         
202 }
203