]>
Commit | Line | Data |
---|---|---|
c8fe2783 | 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 | **************************************************************************/ | |
c8fe2783 | 15 | |
16 | //_________________________________________________________________________ | |
17 | // Analysis task that executes the analysis classes | |
f15155ed | 18 | // that depend on the CaloTrackCorr frame, frame for Particle identification |
19 | // with calorimeters and tracks and correlations. | |
c8fe2783 | 20 | // Specially designed for calorimeters but also can be used for charged tracks |
f15155ed | 21 | // Input of this task is a configuration file that contains all the settings |
22 | // of the analysis | |
c8fe2783 | 23 | // |
f15155ed | 24 | // -- Author: Gustavo Conesa (INFN-LNF, LPSC-Grenoble) |
c8fe2783 | 25 | |
26 | #include <cstdlib> | |
27 | ||
28 | // --- Root --- | |
29 | #include <TROOT.h> | |
30 | #include <TInterpreter.h> | |
31 | #include <TClonesArray.h> | |
32 | //#include <Riostream.h> | |
33 | //#include <TObjectTable.h> | |
34 | ||
35 | // --- Analysis --- | |
f15155ed | 36 | #include "AliAnalysisTaskCaloTrackCorrelationM.h" |
37 | #include "AliAnaCaloTrackCorrMaker.h" | |
c8fe2783 | 38 | #include "AliCaloTrackReader.h" |
39 | #include "AliPDG.h" | |
40 | #include "AliAnalysisManager.h" | |
41 | #include "AliMultiEventInputHandler.h" | |
42 | #include "AliMixedEvent.h" | |
43 | #include "AliAODEvent.h" | |
44 | #include "AliESDEvent.h" | |
f2ccb5b8 | 45 | #include "AliAnalysisDataSlot.h" |
c8fe2783 | 46 | |
f15155ed | 47 | ClassImp(AliAnalysisTaskCaloTrackCorrelationM) |
c8fe2783 | 48 | |
f15155ed | 49 | //__________________________________________________________________________ |
50 | AliAnalysisTaskCaloTrackCorrelationM::AliAnalysisTaskCaloTrackCorrelationM() : | |
c8fe2783 | 51 | AliAnalysisTaskME(), |
52 | fAna(0x0), | |
53 | fOutputContainer(0x0), | |
f15155ed | 54 | fConfigName(""), |
55 | fCuts(0x0), | |
56 | fInputEvent(NULL) | |
c8fe2783 | 57 | { |
58 | // Default constructor | |
59 | } | |
60 | ||
f15155ed | 61 | //__________________________________________________________________________________________ |
62 | AliAnalysisTaskCaloTrackCorrelationM::AliAnalysisTaskCaloTrackCorrelationM(const char* name) : | |
c8fe2783 | 63 | AliAnalysisTaskME(name), |
64 | fAna(0x0), | |
65 | fOutputContainer(0x0), | |
f15155ed | 66 | fConfigName(""), |
67 | fCuts(0x0), | |
68 | fInputEvent(NULL) | |
c8fe2783 | 69 | { |
70 | // Default constructor | |
71 | ||
72 | DefineOutput(1, TList::Class()); | |
73 | DefineOutput(2, TList::Class()); // will contain cuts or local params | |
74 | } | |
75 | ||
f15155ed | 76 | //___________________________________________________________________________ |
77 | AliAnalysisTaskCaloTrackCorrelationM::~AliAnalysisTaskCaloTrackCorrelationM() | |
c8fe2783 | 78 | { |
79 | // Remove all pointers | |
80 | ||
f15155ed | 81 | // // Do not delete it here, already done somewhere else, need to understand where. |
82 | // if(fOutputContainer && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){ | |
83 | // fOutputContainer->Clear() ; | |
84 | // delete fOutputContainer ; | |
85 | // } | |
86 | ||
c8fe2783 | 87 | delete fInputEvent ; |
88 | if(fAna) delete fAna; | |
f15155ed | 89 | |
c8fe2783 | 90 | } |
91 | ||
f15155ed | 92 | //__________________________________________________________________ |
93 | void AliAnalysisTaskCaloTrackCorrelationM::UserCreateOutputObjects() | |
c8fe2783 | 94 | { |
95 | // Create the output container | |
f15155ed | 96 | if (DebugLevel() > 1) printf("AliAnalysisTaskCaloTrackCorrelationM::UserCreateOutputObjects() - Begin\n"); |
c8fe2783 | 97 | |
98 | //Get list of aod arrays, add each aod array to analysis frame | |
99 | TClonesArray *array = 0; | |
f37fa8d2 | 100 | TList * list = fAna->FillAndGetAODBranchList(); |
f15155ed | 101 | if (DebugLevel() >= 1) printf("AliAnalysisTaskCaloTrackCorrelationM::UserCreateOutputObjects() - n AOD branches %d\n",list->GetEntries()); |
102 | ||
f37fa8d2 | 103 | //Put the delta AODs in output file, std or delta |
accd903d | 104 | if((fAna->GetReader())->WriteDeltaAODToFile()) |
105 | { | |
f37fa8d2 | 106 | TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName(); |
accd903d | 107 | for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++) |
108 | { | |
f37fa8d2 | 109 | array = (TClonesArray*) list->At(iaod); |
110 | if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file | |
111 | else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file | |
112 | } | |
113 | } | |
c8fe2783 | 114 | |
115 | //Histograms container | |
116 | OpenFile(1); | |
117 | fOutputContainer = fAna->GetOutputContainer(); | |
f37fa8d2 | 118 | |
f15155ed | 119 | if (DebugLevel() >= 1) printf("AliAnalysisTaskCaloTrackCorrelationM::UserCreateOutputObjects() - n histograms %d\n",fOutputContainer->GetEntries()); |
f37fa8d2 | 120 | |
c8fe2783 | 121 | fOutputContainer->SetOwner(kTRUE); |
f37fa8d2 | 122 | |
f15155ed | 123 | if (DebugLevel() > 1) printf("AliAnalysisTaskCaloTrackCorrelationM::UserCreateOutputObjects() - End\n"); |
124 | ||
c8fe2783 | 125 | PostData(1,fOutputContainer); |
126 | ||
127 | } | |
f15155ed | 128 | |
129 | //____________________________________________________ | |
130 | void AliAnalysisTaskCaloTrackCorrelationM::LocalInit() | |
c8fe2783 | 131 | { |
132 | // Local Initialization | |
133 | ||
134 | //Call the Init to initialize the configuration of the analysis | |
135 | Init(); | |
136 | ||
c8fe2783 | 137 | } |
138 | ||
f15155ed | 139 | //_______________________________________________ |
140 | void AliAnalysisTaskCaloTrackCorrelationM::Init() | |
c8fe2783 | 141 | { |
142 | // Initialization | |
f15155ed | 143 | |
144 | if (DebugLevel() > 1) printf("AliAnalysisTaskCaloTrackCorrelationM::Init() - Begin\n"); | |
c8fe2783 | 145 | |
146 | fInputEvent = new AliMixedEvent() ; | |
147 | ||
148 | // Call configuration file if specified | |
149 | ||
accd903d | 150 | if (fConfigName.Length()) |
151 | { | |
f15155ed | 152 | printf("AliAnalysisTaskCaloTrackCorrelationM::Init() - ### Configuration file is %s.C ###\n", fConfigName.Data()); |
153 | gROOT->LoadMacro(fConfigName+".C"); | |
154 | fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()"); | |
c8fe2783 | 155 | } |
156 | ||
accd903d | 157 | if(!fAna) |
158 | { | |
f15155ed | 159 | printf("AliAnalysisTaskCaloTrackCorrelationM::Init() - Analysis maker pointer not initialized, no analysis specified, STOP !\n"); |
160 | abort(); | |
c8fe2783 | 161 | } |
162 | ||
163 | // Add different generator particles to PDG Data Base | |
164 | // to avoid problems when reading MC generator particles | |
165 | AliPDG::AddParticlesToPdgDataBase(); | |
f15155ed | 166 | |
c8fe2783 | 167 | //Set in the reader the name of the task in case is needed |
168 | (fAna->GetReader())->SetTaskName(GetName()); | |
169 | ||
170 | // Initialise analysis | |
171 | fAna->Init(); | |
f15155ed | 172 | |
c8fe2783 | 173 | //Delta AOD |
174 | if((fAna->GetReader())->GetDeltaAODFileName()!="") | |
175 | AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName()); | |
f15155ed | 176 | |
177 | if (DebugLevel() > 1) printf("AliAnalysisTaskCaloTrackCorrelationM::Init() - End\n"); | |
c8fe2783 | 178 | |
179 | } | |
180 | ||
181 | ||
f15155ed | 182 | //_______________________________________________________________________ |
183 | void AliAnalysisTaskCaloTrackCorrelationM::UserExec(Option_t */*option*/) | |
c8fe2783 | 184 | { |
185 | // Execute analysis for current event | |
f15155ed | 186 | |
187 | if (DebugLevel() > 1) printf("AliAnalysisTaskCaloTrackCorrelationM::UserExec() - Begin\n"); | |
188 | ||
189 | //Get the type of data, check if type is correct | |
c8fe2783 | 190 | Int_t datatype = fAna->GetReader()->GetDataType(); |
191 | if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD && | |
192 | datatype != AliCaloTrackReader::kMC){ | |
f15155ed | 193 | printf("AliAnalysisTaskCaloTrackCorrelationM::UserExec() - Wrong type of data\n"); |
c8fe2783 | 194 | return ; |
195 | } | |
f15155ed | 196 | |
c8fe2783 | 197 | Int_t nev = fInputHandler->GetBufferSize(); |
198 | fInputEvent->Reset(); | |
199 | ||
accd903d | 200 | for (Int_t iev = 0; iev < nev; iev++) |
201 | { | |
202 | if (datatype == AliCaloTrackReader::kESD) | |
203 | { | |
c8fe2783 | 204 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(GetEvent(iev)); |
205 | fInputEvent->AddEvent(esd); | |
accd903d | 206 | } else if (datatype == AliCaloTrackReader::kAOD) |
207 | { | |
c8fe2783 | 208 | AliAODEvent* aod = dynamic_cast<AliAODEvent*>(GetEvent(iev)); |
209 | fInputEvent->AddEvent(aod); | |
accd903d | 210 | } else |
211 | { | |
c8fe2783 | 212 | AliFatal("need to implement mixed event for MC") ; |
213 | } | |
f15155ed | 214 | } |
215 | ||
c8fe2783 | 216 | fInputEvent->Init(); |
f15155ed | 217 | |
c8fe2783 | 218 | fAna->GetReader()->SetInputOutputMCEvent(fInputEvent, AODEvent(), MCEvent()); |
f15155ed | 219 | |
c8fe2783 | 220 | //Process event |
221 | fAna->ProcessEvent((Int_t) Entry(), CurrentFileName()); | |
f15155ed | 222 | |
223 | //printf("AliAnalysisTaskCaloTrackCorrelationM::Current Event %d; Current File Name : %s\n",(Int_t) Entry(), CurrentFileName()); | |
224 | if (DebugLevel() > 1) printf("AliAnalysisTaskCaloTrackCorrelationM::UserExec() - End\n"); | |
225 | ||
c8fe2783 | 226 | PostData(1, fOutputContainer); |
227 | ||
f2ccb5b8 | 228 | AliAnalysisDataSlot *out0 = GetOutputSlot(0); |
229 | if (out0 && out0->IsConnected()) PostData(0, fTreeA); | |
230 | ||
c8fe2783 | 231 | //gObjectTable->Print(); |
f15155ed | 232 | |
c8fe2783 | 233 | } |
234 | ||
f15155ed | 235 | //________________________________________________________________________ |
236 | void AliAnalysisTaskCaloTrackCorrelationM::Terminate(Option_t */*option*/) | |
c8fe2783 | 237 | { |
238 | // Terminate analysis | |
239 | // Do some plots | |
f15155ed | 240 | |
c8fe2783 | 241 | // Get merged histograms from the output container |
242 | // Propagate histagrams to maker | |
243 | fAna->Terminate((TList*)GetOutputData(1)); | |
accd903d | 244 | |
245 | // Create cuts/param objects and publish to slot | |
246 | fCuts = fAna->GetListOfAnalysisCuts(); | |
247 | fCuts ->SetOwner(kTRUE); | |
248 | ||
249 | // Post Data | |
250 | PostData(2, fCuts); | |
251 | ||
c8fe2783 | 252 | } |
253 |