AliPhysics  251aa1e (251aa1e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskCaloTrackCorrelationM.cxx
Go to the documentation of this file.
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 
16 #include <cstdlib>
17 
18 // --- Root ---
19 #include <TROOT.h>
20 #include <TInterpreter.h>
21 #include <TClonesArray.h>
22 //#include <Riostream.h>
23 //#include <TObjectTable.h>
24 
25 // --- Analysis ---
28 #include "AliCaloTrackReader.h"
29 #include "AliPDG.h"
30 #include "AliAnalysisManager.h"
31 #include "AliMultiEventInputHandler.h"
32 #include "AliMixedEvent.h"
33 #include "AliAODEvent.h"
34 #include "AliESDEvent.h"
35 #include "AliAnalysisDataSlot.h"
36 #include "AliLog.h"
37 
41 
42 //__________________________________________________________________________
44 //__________________________________________________________________________
46  AliAnalysisTaskME(),
47  fAna(0x0),
48  fOutputContainer(0x0),
49  fConfigName(""),
50  fCuts(0x0),
51  fInputEvent(NULL)
52 {
53 }
54 
55 //__________________________________________________________________________________________
57 //__________________________________________________________________________________________
59  AliAnalysisTaskME(name),
60  fAna(0x0),
61  fOutputContainer(0x0),
62  fConfigName(""),
63  fCuts(0x0),
64  fInputEvent(NULL)
65 {
66  DefineOutput(1, TList::Class());
67  DefineOutput(2, TList::Class()); // will contain cuts or local params
68 }
69 
70 //_________________________________________________________________________
72 //_________________________________________________________________________
74 {
75  // if(fOutputContainer && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
76  // fOutputContainer->Clear() ;
77  // delete fOutputContainer ;
78  // }
79 
80  delete fInputEvent ;
81 
82  if(fAna) delete fAna;
83 }
84 
85 //_________________________________________________________________
88 //_________________________________________________________________
90 {
91  AliDebug(1,"Begin");
92 
93  //Get list of aod arrays, add each aod array to analysis frame
94  TClonesArray *array = 0;
96 
97  AliDebug(1,Form("n AOD branches %d",list->GetEntries()));
98 
99  //Put the delta AODs in output file, std or delta
100  if((fAna->GetReader())->WriteDeltaAODToFile())
101  {
102  TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
103  for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++)
104  {
105  array = (TClonesArray*) list->At(iaod);
106  if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
107  else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
108  }
109  }
110 
111  //Histograms container
112  OpenFile(1);
114 
115  AliDebug(1,Form("n histograms %d",fOutputContainer->GetEntries()));
116 
117  fOutputContainer->SetOwner(kTRUE);
118 
119  AliDebug(1,"End");
120 
121  PostData(1,fOutputContainer);
122 
123 }
124 
125 //___________________________________________________
128 //___________________________________________________
130 {
131  Init();
132 }
133 
134 //______________________________________________
136 //______________________________________________
138 {
139  AliDebug(1,"Begin");
140 
141  fInputEvent = new AliMixedEvent() ;
142 
143  // Call configuration file if specified
144 
145  if (fConfigName.Length())
146  {
147  AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
148  gROOT->LoadMacro(fConfigName+".C");
149  fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
150  }
151 
152  if(!fAna)
153  {
154  AliFatal("Analysis maker pointer not initialized, no analysis specified, STOP!");
155  return; // coverity
156  }
157 
158  // Add different generator particles to PDG Data Base
159  // to avoid problems when reading MC generator particles
160  AliPDG::AddParticlesToPdgDataBase();
161 
162  //Set in the reader the name of the task in case is needed
163  (fAna->GetReader())->SetTaskName(GetName());
164 
165  // Initialise analysis
166  fAna->Init();
167 
168  //Delta AOD
169  if((fAna->GetReader())->GetDeltaAODFileName()!="")
170  AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
171 
172  AliDebug(1,"End");
173 }
174 
175 //_______________________________________________________________________
177 //_______________________________________________________________________
179 {
180  AliDebug(1,"Begin");
181 
182  //Get the type of data, check if type is correct
183  Int_t datatype = fAna->GetReader()->GetDataType();
184  if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
185  datatype != AliCaloTrackReader::kMC)
186  {
187  AliError("Wrong type of data");
188  return ;
189  }
190 
191  Int_t nev = fInputHandler->GetBufferSize();
192  fInputEvent->Reset();
193 
194  for (Int_t iev = 0; iev < nev; iev++)
195  {
196  if (datatype == AliCaloTrackReader::kESD)
197  {
198  AliESDEvent* esd = dynamic_cast<AliESDEvent*>(GetEvent(iev));
199  fInputEvent->AddEvent(esd);
200  } else if (datatype == AliCaloTrackReader::kAOD)
201  {
202  AliAODEvent* aod = dynamic_cast<AliAODEvent*>(GetEvent(iev));
203  fInputEvent->AddEvent(aod);
204  } else
205  {
206  AliFatal("need to implement mixed event for MC") ;
207  }
208  }
209 
210  fInputEvent->Init();
211 
213 
214  //Process event
215  fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
216 
217  PostData(1, fOutputContainer);
218 
219  AliAnalysisDataSlot *out0 = GetOutputSlot(0);
220  if (out0 && out0->IsConnected()) PostData(0, fTreeA);
221 
222  AliDebug(1,"End");
223 
224  //gObjectTable->Print();
225 }
226 
227 //________________________________________________________________________
229 //________________________________________________________________________
231 {
232  // Get merged histograms from the output container
233  // Propagate histagrams to maker
234  fAna->Terminate((TList*)GetOutputData(1));
235 
236  // Create cuts/param objects and publish to slot
238  fCuts ->SetOwner(kTRUE);
239 
240  // Post Data
241  PostData(2, fCuts);
242 }
243 
AliAnaCaloTrackCorrMaker * fAna
Pointer to the manager class.
virtual void SetInputOutputMCEvent(AliVEvent *, AliAODEvent *, AliMCEvent *)
TList * list
virtual void Terminate(Option_t *option)
Terminate analysis. Do some plots (plotting not used so far).
AliMixedEvent * fInputEvent
Mixed event access pointer.
Main class conecting the CaloTrackCorrelations package and Analysis Mixing Frame. ...
int Int_t
Definition: External.C:63
virtual void UserExec(Option_t *option)
Execute analysis for current event.
void ProcessEvent(Int_t iEntry, const char *currentFileName)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
const char Option_t
Definition: External.C:48
virtual Int_t GetDataType() const
AliCaloTrackReader * GetReader()
TList * OpenFile(const char *fname)
Definition: DrawAnaELoss.C:65
Steering class of package CaloTrackCorrelartions.
virtual void Init()
Analysis configuration, if provided, and initialization.