1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //_________________________________________________________________________
17 // Analysis task that executes the analysis classes
18 // that depend on the CaloTrackCorr frame, frame for Particle identification
19 // with calorimeters and tracks 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
24 // -- Author: Gustavo Conesa (INFN-LNF, LPSC-Grenoble)
30 #include <TInterpreter.h>
31 #include <TClonesArray.h>
32 //#include <Riostream.h>
33 //#include <TObjectTable.h>
36 #include "AliAnalysisTaskCaloTrackCorrelationM.h"
37 #include "AliAnaCaloTrackCorrMaker.h"
38 #include "AliCaloTrackReader.h"
40 #include "AliAnalysisManager.h"
41 #include "AliMultiEventInputHandler.h"
42 #include "AliMixedEvent.h"
43 #include "AliAODEvent.h"
44 #include "AliESDEvent.h"
45 #include "AliAnalysisDataSlot.h"
48 ClassImp(AliAnalysisTaskCaloTrackCorrelationM)
50 //__________________________________________________________________________
51 AliAnalysisTaskCaloTrackCorrelationM::AliAnalysisTaskCaloTrackCorrelationM() :
54 fOutputContainer(0x0),
59 // Default constructor
62 //__________________________________________________________________________________________
63 AliAnalysisTaskCaloTrackCorrelationM::AliAnalysisTaskCaloTrackCorrelationM(const char* name) :
64 AliAnalysisTaskME(name),
66 fOutputContainer(0x0),
71 // Default constructor
73 DefineOutput(1, TList::Class());
74 DefineOutput(2, TList::Class()); // will contain cuts or local params
77 //___________________________________________________________________________
78 AliAnalysisTaskCaloTrackCorrelationM::~AliAnalysisTaskCaloTrackCorrelationM()
80 // Remove all pointers
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 ;
93 //__________________________________________________________________
94 void AliAnalysisTaskCaloTrackCorrelationM::UserCreateOutputObjects()
96 // Create the output container
99 //Get list of aod arrays, add each aod array to analysis frame
100 TClonesArray *array = 0;
101 TList * list = fAna->FillAndGetAODBranchList();
103 AliDebug(1,Form("n AOD branches %d",list->GetEntries()));
105 //Put the delta AODs in output file, std or delta
106 if((fAna->GetReader())->WriteDeltaAODToFile())
108 TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
109 for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++)
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
117 //Histograms container
119 fOutputContainer = fAna->GetOutputContainer();
121 AliDebug(1,Form("n histograms %d",fOutputContainer->GetEntries()));
123 fOutputContainer->SetOwner(kTRUE);
127 PostData(1,fOutputContainer);
131 //____________________________________________________
132 void AliAnalysisTaskCaloTrackCorrelationM::LocalInit()
134 // Local Initialization
136 //Call the Init to initialize the configuration of the analysis
141 //_______________________________________________
142 void AliAnalysisTaskCaloTrackCorrelationM::Init()
148 fInputEvent = new AliMixedEvent() ;
150 // Call configuration file if specified
152 if (fConfigName.Length())
154 AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
155 gROOT->LoadMacro(fConfigName+".C");
156 fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
161 AliFatal("Analysis maker pointer not initialized, no analysis specified, STOP!");
165 // Add different generator particles to PDG Data Base
166 // to avoid problems when reading MC generator particles
167 AliPDG::AddParticlesToPdgDataBase();
169 //Set in the reader the name of the task in case is needed
170 (fAna->GetReader())->SetTaskName(GetName());
172 // Initialise analysis
176 if((fAna->GetReader())->GetDeltaAODFileName()!="")
177 AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
184 //_______________________________________________________________________
185 void AliAnalysisTaskCaloTrackCorrelationM::UserExec(Option_t */*option*/)
187 // Execute analysis for current event
191 //Get the type of data, check if type is correct
192 Int_t datatype = fAna->GetReader()->GetDataType();
193 if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
194 datatype != AliCaloTrackReader::kMC)
196 AliError("Wrong type of data");
200 Int_t nev = fInputHandler->GetBufferSize();
201 fInputEvent->Reset();
203 for (Int_t iev = 0; iev < nev; iev++)
205 if (datatype == AliCaloTrackReader::kESD)
207 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(GetEvent(iev));
208 fInputEvent->AddEvent(esd);
209 } else if (datatype == AliCaloTrackReader::kAOD)
211 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(GetEvent(iev));
212 fInputEvent->AddEvent(aod);
215 AliFatal("need to implement mixed event for MC") ;
221 fAna->GetReader()->SetInputOutputMCEvent(fInputEvent, AODEvent(), MCEvent());
224 fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
226 PostData(1, fOutputContainer);
228 AliAnalysisDataSlot *out0 = GetOutputSlot(0);
229 if (out0 && out0->IsConnected()) PostData(0, fTreeA);
233 //gObjectTable->Print();
237 //________________________________________________________________________
238 void AliAnalysisTaskCaloTrackCorrelationM::Terminate(Option_t */*option*/)
240 // Terminate analysis
243 // Get merged histograms from the output container
244 // Propagate histagrams to maker
245 fAna->Terminate((TList*)GetOutputData(1));
247 // Create cuts/param objects and publish to slot
248 fCuts = fAna->GetListOfAnalysisCuts();
249 fCuts ->SetOwner(kTRUE);