]>
Commit | Line | Data |
---|---|---|
1c5acb87 | 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 | ||
268934f9 | 25 | #include <cstdlib> |
fbeaf916 | 26 | |
27 | // --- Root --- | |
1c5acb87 | 28 | #include <TROOT.h> |
1c5acb87 | 29 | #include <TInterpreter.h> |
1cd71065 | 30 | #include <TClonesArray.h> |
1c5acb87 | 31 | //#include <Riostream.h> |
1cd71065 | 32 | //#include <TObjectTable.h> |
1c5acb87 | 33 | |
fbeaf916 | 34 | // --- Analysis --- |
1c5acb87 | 35 | #include "AliAnalysisTaskParticleCorrelation.h" |
1c5acb87 | 36 | #include "AliAnaPartCorrMaker.h" |
37 | #include "AliCaloTrackReader.h" | |
7175a03a | 38 | #include "AliPDG.h" |
42dc8e7d | 39 | #include "AliAnalysisManager.h" |
66580b85 | 40 | #include "AliInputEventHandler.h" |
1c5acb87 | 41 | |
42 | ClassImp(AliAnalysisTaskParticleCorrelation) | |
43 | ||
44 | //////////////////////////////////////////////////////////////////////// | |
fbeaf916 | 45 | AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(): |
46 | AliAnalysisTaskSE(), | |
47 | fAna(0x0), | |
48 | fOutputContainer(0x0), | |
0c1383b5 | 49 | fConfigName(""), fCuts(0x0) |
1c5acb87 | 50 | { |
51 | // Default constructor | |
52 | } | |
53 | ||
54 | //_____________________________________________________ | |
55 | AliAnalysisTaskParticleCorrelation::AliAnalysisTaskParticleCorrelation(const char* name): | |
477d6cee | 56 | AliAnalysisTaskSE(name), |
57 | fAna(0x0), | |
58 | fOutputContainer(0x0), | |
0c1383b5 | 59 | fConfigName(""), fCuts(0x0) |
1c5acb87 | 60 | { |
61 | // Default constructor | |
477d6cee | 62 | |
1c5acb87 | 63 | DefineOutput(1, TList::Class()); |
0c1383b5 | 64 | DefineOutput(2, TList::Class()); // will contain cuts or local params |
1c5acb87 | 65 | } |
66 | ||
67 | //_____________________________________________________ | |
68 | AliAnalysisTaskParticleCorrelation::~AliAnalysisTaskParticleCorrelation() | |
69 | { | |
70 | // Remove all pointers | |
be9d1d38 | 71 | if (fOutputContainer && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { |
72 | fOutputContainer->Clear() ; | |
73 | delete fOutputContainer ; | |
74 | } | |
75 | if (fAna && ! AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fAna; | |
1c5acb87 | 76 | } |
77 | ||
78 | //_____________________________________________________ | |
79 | void AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() | |
80 | { | |
477d6cee | 81 | // Create the output container |
fbeaf916 | 82 | if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - Begin\n"); |
477d6cee | 83 | |
84 | //Get list of aod arrays, add each aod array to analysis frame | |
1cd71065 | 85 | TClonesArray *array = 0; |
f37fa8d2 | 86 | TList * list = fAna->FillAndGetAODBranchList(); //Loop the analysis and create the list of branches |
87 | if (DebugLevel() >= 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - n AOD branches %d\n",list->GetEntries()); | |
88 | ||
89 | //Put the delta AODs in output file, std or delta | |
90 | if((fAna->GetReader())->WriteDeltaAODToFile()){ | |
91 | TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName(); | |
92 | for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++){ | |
93 | array = (TClonesArray*) list->At(iaod); | |
94 | if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file | |
95 | else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file | |
96 | } | |
97 | } | |
98 | ||
477d6cee | 99 | //Histograms container |
100 | OpenFile(1); | |
101 | fOutputContainer = fAna->GetOutputContainer(); | |
f37fa8d2 | 102 | |
103 | if (DebugLevel() >= 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - n histograms %d\n",fOutputContainer->GetEntries()); | |
104 | ||
4a745797 | 105 | fOutputContainer->SetOwner(kTRUE); |
f37fa8d2 | 106 | |
fbeaf916 | 107 | if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserCreateOutputObjects() - End\n"); |
609de1b2 | 108 | |
109 | PostData(1,fOutputContainer); | |
138f531a | 110 | |
1c5acb87 | 111 | } |
0c1383b5 | 112 | //_____________________________________________________ |
113 | void AliAnalysisTaskParticleCorrelation::LocalInit() | |
114 | { | |
115 | // Local Initialization | |
116 | ||
37c0bcde | 117 | //Call the Init to initialize the configuration of the analysis |
118 | Init(); | |
119 | ||
0c1383b5 | 120 | // Create cuts/param objects and publish to slot |
0c1383b5 | 121 | fCuts = fAna->GetListOfAnalysisCuts(); |
138f531a | 122 | fCuts ->SetOwner(kTRUE); |
0c1383b5 | 123 | // Post Data |
37c0bcde | 124 | PostData(2, fCuts); |
0c1383b5 | 125 | |
0c1383b5 | 126 | } |
1c5acb87 | 127 | |
128 | //_____________________________________________________ | |
129 | void AliAnalysisTaskParticleCorrelation::Init() | |
130 | { | |
131 | // Initialization | |
fbeaf916 | 132 | |
133 | if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - Begin\n"); | |
477d6cee | 134 | |
135 | // Call configuration file if specified | |
136 | ||
137 | if (fConfigName.Length()) { | |
fbeaf916 | 138 | printf("AliAnalysisTaskParticleCorrelation::Init() - ### Configuration file is %s.C ###\n", fConfigName.Data()); |
477d6cee | 139 | gROOT->LoadMacro(fConfigName+".C"); |
140 | fAna = (AliAnaPartCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()"); | |
1c5acb87 | 141 | } |
1c5acb87 | 142 | |
fbeaf916 | 143 | if(!fAna) { |
ee7d35e1 | 144 | printf("AliAnalysisTaskParticleCorrelation::Init() - Analysis maker pointer not initialized, no analysis specified, STOP !\n"); |
fbeaf916 | 145 | abort(); |
477d6cee | 146 | } |
1c5acb87 | 147 | |
7175a03a | 148 | // Add different generator particles to PDG Data Base |
149 | // to avoid problems when reading MC generator particles | |
150 | AliPDG::AddParticlesToPdgDataBase(); | |
151 | ||
486258c9 | 152 | //Set in the reader the name of the task in case is needed |
153 | (fAna->GetReader())->SetTaskName(GetName()); | |
154 | ||
1c5acb87 | 155 | // Initialise analysis |
156 | fAna->Init(); | |
42dc8e7d | 157 | |
158 | //Delta AOD | |
159 | if((fAna->GetReader())->GetDeltaAODFileName()!="") | |
160 | AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName()); | |
161 | ||
fbeaf916 | 162 | if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::Init() - End\n"); |
1c5acb87 | 163 | |
164 | } | |
165 | ||
166 | ||
167 | //_____________________________________________________ | |
168 | void AliAnalysisTaskParticleCorrelation::UserExec(Option_t */*option*/) | |
169 | { | |
170 | // Execute analysis for current event | |
171 | // | |
fbeaf916 | 172 | if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - Begin\n"); |
1c5acb87 | 173 | |
fbeaf916 | 174 | //Get the type of data, check if type is correct |
1c5acb87 | 175 | Int_t datatype = fAna->GetReader()->GetDataType(); |
176 | if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD && | |
177 | datatype != AliCaloTrackReader::kMC){ | |
fbeaf916 | 178 | printf("AliAnalysisTaskParticleCorrelation::UserExec() - Wrong type of data\n"); |
1c5acb87 | 179 | return ; |
180 | } | |
1cd71065 | 181 | |
477d6cee | 182 | fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent()); |
1c5acb87 | 183 | |
184 | //Process event | |
a79a2424 | 185 | fAna->ProcessEvent((Int_t) Entry(), CurrentFileName()); |
186 | //printf("AliAnalysisTaskParticleCorrelation::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName()); | |
fbeaf916 | 187 | if (DebugLevel() > 1) printf("AliAnalysisTaskParticleCorrelation::UserExec() - End\n"); |
1cd71065 | 188 | |
1c5acb87 | 189 | PostData(1, fOutputContainer); |
1cd71065 | 190 | |
191 | //gObjectTable->Print(); | |
192 | ||
1c5acb87 | 193 | |
194 | } | |
195 | ||
196 | //_____________________________________________________ | |
197 | void AliAnalysisTaskParticleCorrelation::Terminate(Option_t */*option*/) | |
198 | { | |
199 | // Terminate analysis | |
6639984f | 200 | // Do some plots |
6639984f | 201 | |
a5cc4f03 | 202 | // Get merged histograms from the output container |
a5cc4f03 | 203 | // Propagate histagrams to maker |
1cd71065 | 204 | fAna->Terminate((TList*)GetOutputData(1)); |
a5cc4f03 | 205 | |
1c5acb87 | 206 | } |
207 | ||
66580b85 | 208 | //_____________________________________________________ |
209 | void AliAnalysisTaskParticleCorrelation::FinishTaskOutput(){ | |
210 | // Put in the output some event summary histograms | |
211 | AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager(); | |
212 | AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler()); | |
213 | if (!inputH) return; | |
214 | TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics()); | |
215 | TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0")); | |
216 | ||
49b5c49b | 217 | if(histStat)fOutputContainer->Add(histStat); |
218 | else if(DebugLevel()>0) | |
219 | printf("AliAnalysisTaskParticleCorrelation::FinishTaskOutput() - Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists \n"); | |
4b892846 | 220 | if(histBin0)fOutputContainer->Add(histBin0); |
66580b85 | 221 | |
222 | } | |
223 |