AliPhysics  vAN-20150427 (e6e7aad)
 All Classes Namespaces Files Functions Variables 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  fLastEvent(0)
48 {
49 }
50 
51 //________________________________________________________________________________________
53 //________________________________________________________________________________________
55  AliAnalysisTaskSE(name),
56  fAna(0x0),
57  fOutputContainer(0x0),
58  fConfigName(""),
59  fCuts(0x0),
60  fLastEvent(0)
61 {
62  DefineOutput(1, TList::Class());
63  DefineOutput(2, TList::Class()); // will contain cuts or local params
64 }
65 
66 //_________________________________________________________________________
68 //_________________________________________________________________________
70 {
71  if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
72 
73  if (fOutputContainer)
74  {
75  fOutputContainer->Clear() ;
76  delete fOutputContainer ;
77  }
78 
79  if (fAna) delete fAna;
80 }
81 
82 //_________________________________________________________________
85 //_________________________________________________________________
87 {
88  AliDebug(1,"Begin");
89 
90  // Get list of aod arrays, add each aod array to analysis frame
91  TList * list = fAna->FillAndGetAODBranchList(); //Loop the analysis and create the list of branches
92 
93  AliDebug(1,Form("n AOD branches %d",list->GetEntries()));
94 
95  // Put the delta AODs in output file, std or delta
96  if((fAna->GetReader())->WriteDeltaAODToFile())
97  {
98  TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
99  for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++)
100  {
101  TClonesArray * array = (TClonesArray*) list->At(iaod);
102  if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
103  else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
104  }
105  }
106 
107  // Histograms container
108  OpenFile(1);
110 
111  AliDebug(1,Form("n histograms %d",fOutputContainer->GetEntries()));
112 
113  fOutputContainer->SetOwner(kTRUE);
114 
115  AliDebug(1,"End");
116 
117  PostData(1,fOutputContainer);
118 }
119 
120 //___________________________________________________
123 //___________________________________________________
125 {
126  Init();
127 }
128 
129 //______________________________________________
131 //______________________________________________
133 {
134 
135  AliDebug(1,"Begin");
136 
137  if( fDebug >= 0 )
138  (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
139 
140  // Call configuration file if specified
141 
142  if (fConfigName.Length())
143  {
144  AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
145  gROOT->LoadMacro(fConfigName+".C");
146  fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
147  }
148 
149  if(!fAna)
150  {
151  AliFatal("Analysis maker pointer not initialized, no analysis specified, STOP!");
152  return; // coverity
153  }
154 
155  // Add different generator particles to PDG Data Base
156  // to avoid problems when reading MC generator particles
157  AliPDG::AddParticlesToPdgDataBase();
158 
159  // Set in the reader the name of the task in case is needed
160  (fAna->GetReader())->SetTaskName(GetName());
161 
162  // Initialise analysis
163  fAna->Init();
164 
165  // Delta AOD
166  if((fAna->GetReader())->GetDeltaAODFileName()!="")
167  AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
168 
169  // Selected Trigger
170  if(fAna->GetReader()->IsEventTriggerAtSEOn()) fAna->GetReader()->SetEventTriggerMask(GetCollisionCandidates());
171 
172  AliDebug(1,"End");
173 }
174 
175 //______________________________________________________________________
177 //______________________________________________________________________
179 {
180  if ( fLastEvent > 0 && Entry() > fLastEvent ) return ;
181 
182  AliDebug(1,"Begin");
183 
184  //Get the type of data, check if type is correct
185  Int_t datatype = fAna->GetReader()->GetDataType();
186  if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
187  datatype != AliCaloTrackReader::kMC)
188  {
189  AliError("Wrong type of data");
190  return ;
191  }
192 
193  fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
194 
195  //Process event
196  fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
197 
198  PostData(1, fOutputContainer);
199 
200  AliDebug(1,"End");
201 
202  //gObjectTable->Print();
203 }
204 
205 //_______________________________________________________________________
207 //_______________________________________________________________________
209 {
210  // Get merged histograms from the output container
211  // Propagate histagrams to maker
212  fAna->Terminate((TList*)GetOutputData(1));
213 
214  // Create cuts/param objects and publish to slot
216  fCuts ->SetOwner(kTRUE);
217 
218  // Post Data
219  PostData(2, fCuts);
220 }
221 
222 //__________________________________________________________
224 //__________________________________________________________
226 {
227  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
228 
229  AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
230 
231  if (!inputH) return;
232 
233  TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics());
234  TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));
235 
236  if(histStat)fOutputContainer->Add(histStat);
237  else AliDebug(0,"Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists");
238 
239  if(histBin0)fOutputContainer->Add(histBin0);
240 }
241 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
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.