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