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