AliPhysics  56f1704 (56f1704)
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 "AliAODInputHandler.h"
33 #include "AliLog.h"
34 
38 
39 //________________________________________________________________________
41 //________________________________________________________________________
44  fAna(0x0),
45  fOutputContainer(0x0),
46  fConfigName(""),
47  fCuts(0x0),
48  fFirstEvent(0),
49  fLastEvent(0),
50  fStoreEventSummary(0)
51 {
52 }
53 
54 //________________________________________________________________________________________
56 //________________________________________________________________________________________
58  AliAnalysisTaskSE(name),
59  fAna(0x0),
60  fOutputContainer(0x0),
61  fConfigName(""),
62  fCuts(0x0),
63  fFirstEvent(0),
64  fLastEvent(0),
66 {
67  DefineOutput(1, TList::Class());
68  DefineOutput(2, TList::Class()); // will contain cuts or local params
69 }
70 
71 //_________________________________________________________________________
73 //_________________________________________________________________________
75 {
76  if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
77 
78  if (fOutputContainer)
79  {
80  fOutputContainer->Clear() ;
81  delete fOutputContainer ;
82  }
83 
84  if (fAna) delete fAna;
85 }
86 
87 //_________________________________________________________________
90 //_________________________________________________________________
92 {
93  AliDebug(1,"Begin");
94 
95  // Get list of aod arrays, add each aod array to analysis frame
96  TList * list = fAna->FillAndGetAODBranchList(); //Loop the analysis and create the list of branches
97 
98  AliDebug(1,Form("n AOD branches %d",list->GetEntries()));
99 
100  // Put the delta AODs in output file, std or delta
101  if((fAna->GetReader())->WriteDeltaAODToFile())
102  {
103  TString deltaAODName = (fAna->GetReader())->GetDeltaAODFileName();
104  for(Int_t iaod = 0; iaod < list->GetEntries(); iaod++)
105  {
106  TClonesArray * array = (TClonesArray*) list->At(iaod);
107  if(deltaAODName!="") AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
108  else AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
109  }
110  }
111 
112  // Histograms container
113  OpenFile(1);
115 
116  AliDebug(1,Form("n histograms %d",fOutputContainer->GetEntries()));
117 
118  fOutputContainer->SetOwner(kTRUE);
119 
120  AliDebug(1,"End");
121 
122  PostData(1,fOutputContainer);
123 }
124 
125 //___________________________________________________
128 //___________________________________________________
130 {
131  Init();
132 }
133 
134 //______________________________________________
136 //______________________________________________
138 {
139  AliDebug(1,"Begin");
140 
141  if( fDebug >= 0 )
142  (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
143 
144  // Call configuration file if specified
145 
146  if (fConfigName.Length())
147  {
148  AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
149  gROOT->LoadMacro(fConfigName+".C");
150  fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
151  }
152 
153  if(!fAna)
154  {
155  AliFatal("Analysis maker pointer not initialized, no analysis specified, STOP!");
156  return; // coverity
157  }
158 
159  // Add different generator particles to PDG Data Base
160  // to avoid problems when reading MC generator particles
161  AliPDG::AddParticlesToPdgDataBase();
162 
163  // Set in the reader the name of the task in case is needed
164  (fAna->GetReader())->SetTaskName(GetName());
165 
166  // Initialise analysis
167  fAna->Init();
168 
169  // Delta AOD
170  if((fAna->GetReader())->GetDeltaAODFileName()!="")
171  AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
172 
173  // Selected Trigger
174  if(fAna->GetReader()->IsEventTriggerAtSEOn()) fAna->GetReader()->SetEventTriggerMask(GetCollisionCandidates());
175 
176  AliDebug(1,"End");
177 }
178 
179 //______________________________________________________________________
181 //______________________________________________________________________
183 {
184  if ( !fAna->IsEventProcessed() ) return;
185 
186  Int_t eventN = Entry();
187 
188  // Entry() does not work for AODs
189  if ( eventN <= 0 )
190  {
191  AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>
192  ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
193 
194  if ( aodIH ) eventN = aodIH->GetReadEntry();
195  }
196 
197  if ( (fLastEvent > 0 && eventN > fLastEvent ) ||
198  (fFirstEvent > 0 && eventN < fFirstEvent) ) return ;
199 
200  AliDebug(1,Form("Begin: Event %d - Entry %d - (First,Last)=(%d,%d)",
201  eventN, (Int_t) Entry(), fFirstEvent, fLastEvent));
202 
203  //printf("AliAnalysisTaskCaloTrackCorrelation::UserExec() - Event %d - Entry %d - (First,Last)=(%d,%d) \n",
204  // eventN, (Int_t) Entry(), fFirstEvent, fLastEvent);
205 
206  // Get the type of data, check if type is correct
207  Int_t datatype = fAna->GetReader()->GetDataType();
208  if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
209  datatype != AliCaloTrackReader::kMC)
210  {
211  AliError("Wrong type of data");
212  return ;
213  }
214 
215  fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
216 
217  // Process event
218  fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
219 
220  PostData(1, fOutputContainer);
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 
244 //__________________________________________________________
246 //__________________________________________________________
248 {
249  if ( !fStoreEventSummary ) return ;
250 
251  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
252 
253  AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
254 
255  if (!inputH) return;
256 
257  TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics());
258  TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));
259 
260  if ( histStat )
261  {
262  if ( histStat == histBin0 ) histBin0 = 0 ;
263 
264  histStat = (TH2F*) histStat->Clone(Form("%s_%s",histStat->GetName(),"CaloTrackCorr"));
265 
266  fOutputContainer->Add(histStat);
267  }
268 
269  if ( histBin0 )
270  {
271  histBin0 = (TH2F*) histBin0->Clone(Form("%s_%s",histBin0->GetName(),"CaloTrackCorr"));
272 
273  fOutputContainer->Add(histBin0);
274  }
275 }
276 
Definition: External.C:236
Int_t fFirstEvent
! Analyze all the events from this one, for testing.
virtual void SetInputOutputMCEvent(AliVEvent *, AliAODEvent *, AliMCEvent *)
Bool_t fStoreEventSummary
Store in output histograms list 2 histograms with event summary, off by default.
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).
int Int_t
Definition: External.C:63
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
const char Option_t
Definition: External.C:48
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.
TList * OpenFile(const char *fname)
Definition: DrawAnaELoss.C:65
Steering class of package CaloTrackCorrelartions.