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