AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliAnalysisTaskCaloTrackCorrelation.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 "AliInputEventHandler.h"
32 #include "AliLog.h"
33 
37 
38 //________________________________________________________________________
40 //________________________________________________________________________
42  AliAnalysisTaskSE(),
43  fAna(0x0),
44  fOutputContainer(0x0),
45  fConfigName(""),
46  fCuts(0x0),
47  fFirstEvent(0),
48  fLastEvent(0)
49 {
50 }
51 
52 //________________________________________________________________________________________
54 //________________________________________________________________________________________
56  AliAnalysisTaskSE(name),
57  fAna(0x0),
58  fOutputContainer(0x0),
59  fConfigName(""),
60  fCuts(0x0),
61  fFirstEvent(0),
62  fLastEvent(0)
63 {
64  DefineOutput(1, TList::Class());
65  DefineOutput(2, TList::Class()); // will contain cuts or local params
66 }
67 
68 //_________________________________________________________________________
70 //_________________________________________________________________________
72 {
73  if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
74 
75  if (fOutputContainer)
76  {
77  fOutputContainer->Clear() ;
78  delete fOutputContainer ;
79  }
80 
81  if (fAna) delete fAna;
82 }
83 
84 //_________________________________________________________________
87 //_________________________________________________________________
89 {
90  AliDebug(1,"Begin");
91 
92  // Get list of aod arrays, add each aod array to analysis frame
93  TList * list = fAna->FillAndGetAODBranchList(); //Loop the analysis and create the list of branches
94 
95  AliDebug(1,Form("n AOD branches %d",list->GetEntries()));
96 
97  // Put the delta AODs in output file, std or delta
98  if((fAna->GetReader())->WriteDeltaAODToFile())
99  {
100  TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
101  for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++)
102  {
103  TClonesArray * array = (TClonesArray*) list->At(iaod);
104  if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
105  else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
106  }
107  }
108 
109  // Histograms container
110  OpenFile(1);
112 
113  AliDebug(1,Form("n histograms %d",fOutputContainer->GetEntries()));
114 
115  fOutputContainer->SetOwner(kTRUE);
116 
117  AliDebug(1,"End");
118 
119  PostData(1,fOutputContainer);
120 }
121 
122 //___________________________________________________
125 //___________________________________________________
127 {
128  Init();
129 }
130 
131 //______________________________________________
133 //______________________________________________
135 {
136 
137  AliDebug(1,"Begin");
138 
139  if( fDebug >= 0 )
140  (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
141 
142  // Call configuration file if specified
143 
144  if (fConfigName.Length())
145  {
146  AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
147  gROOT->LoadMacro(fConfigName+".C");
148  fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
149  }
150 
151  if(!fAna)
152  {
153  AliFatal("Analysis maker pointer not initialized, no analysis specified, STOP!");
154  return; // coverity
155  }
156 
157  // Add different generator particles to PDG Data Base
158  // to avoid problems when reading MC generator particles
159  AliPDG::AddParticlesToPdgDataBase();
160 
161  // Set in the reader the name of the task in case is needed
162  (fAna->GetReader())->SetTaskName(GetName());
163 
164  // Initialise analysis
165  fAna->Init();
166 
167  // Delta AOD
168  if((fAna->GetReader())->GetDeltaAODFileName()!="")
169  AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
170 
171  // Selected Trigger
172  if(fAna->GetReader()->IsEventTriggerAtSEOn()) fAna->GetReader()->SetEventTriggerMask(GetCollisionCandidates());
173 
174  AliDebug(1,"End");
175 }
176 
177 //______________________________________________________________________
179 //______________________________________________________________________
181 {
182  if ( (fLastEvent > 0 && Entry() > fLastEvent ) ||
183  (fFirstEvent > 0 && Entry() < fFirstEvent) ) return ;
184 
185  AliDebug(1,Form("Begin event %d", (Int_t) Entry()));
186 
187  //Get the type of data, check if type is correct
188  Int_t datatype = fAna->GetReader()->GetDataType();
189  if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
190  datatype != AliCaloTrackReader::kMC)
191  {
192  AliError("Wrong type of data");
193  return ;
194  }
195 
196  fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
197 
198  //Process event
199  fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
200 
201  PostData(1, fOutputContainer);
202 
203  AliDebug(1,"End");
204 
205  //gObjectTable->Print();
206 }
207 
208 //_______________________________________________________________________
210 //_______________________________________________________________________
212 {
213  // Get merged histograms from the output container
214  // Propagate histagrams to maker
215  fAna->Terminate((TList*)GetOutputData(1));
216 
217  // Create cuts/param objects and publish to slot
219  fCuts ->SetOwner(kTRUE);
220 
221  // Post Data
222  PostData(2, fCuts);
223 }
224 
225 //__________________________________________________________
227 //__________________________________________________________
229 {
230  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
231 
232  AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
233 
234  if (!inputH) return;
235 
236  TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics());
237  TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));
238 
239  if(histStat)fOutputContainer->Add(histStat);
240  else AliDebug(0,"Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists");
241 
242  if(histBin0)fOutputContainer->Add(histBin0);
243 }
244 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Int_t fFirstEvent
! Analyze all the events from this one, for testing.
virtual void SetInputOutputMCEvent(AliVEvent *, AliAODEvent *, AliMCEvent *)
TList * list
virtual void Init()
Analysis configuration, if provided, and initialization.
virtual void UserExec(Option_t *option)
Execute analysis for current event.
void SetEventTriggerMask(UInt_t evtTrig=AliVEvent::kAny)
virtual void Terminate(Option_t *option)
Terminate analysis. Do some plots (plotting not used so far).
void ProcessEvent(Int_t iEntry, const char *currentFileName)
virtual void FinishTaskOutput()
Put in the output some standard event summary histograms.
Main class conecting the CaloTrackCorrelations package and Analysis Frame.
Bool_t IsEventTriggerAtSEOn() const
virtual Int_t GetDataType() const
AliCaloTrackReader * GetReader()
Int_t fLastEvent
! Analyze all the events until this one, for testing.
AliAnaCaloTrackCorrMaker * fAna
Pointer to the manager class.
Steering class of package CaloTrackCorrelartions.