AliPhysics  2c6b7ad (2c6b7ad)
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 //________________________________________________________________________
43  fAna(0x0),
44  fOutputContainer(0x0),
45  fConfigName(""),
46  fCuts(0x0),
47  fFirstEvent(0),
48  fLastEvent(0),
49  fStoreEventSummary(0)
50 {
51 }
52 
53 //________________________________________________________________________________________
55 //________________________________________________________________________________________
57  AliAnalysisTaskSE(name),
58  fAna(0x0),
59  fOutputContainer(0x0),
60  fConfigName(""),
61  fCuts(0x0),
62  fFirstEvent(0),
63  fLastEvent(0),
65 {
66  DefineOutput(1, TList::Class());
67  DefineOutput(2, TList::Class()); // will contain cuts or local params
68 }
69 
70 //_________________________________________________________________________
72 //_________________________________________________________________________
74 {
75  if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;
76 
77  if (fOutputContainer)
78  {
79  fOutputContainer->Clear() ;
80  delete fOutputContainer ;
81  }
82 
83  if (fAna) delete fAna;
84 }
85 
86 //_________________________________________________________________
89 //_________________________________________________________________
91 {
92  AliDebug(1,"Begin");
93 
94  // Get list of aod arrays, add each aod array to analysis frame
95  TList * list = fAna->FillAndGetAODBranchList(); //Loop the analysis and create the list of branches
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  TClonesArray * array = (TClonesArray*) list->At(iaod);
106  if ( !array ) continue;
107 
108  if ( deltaAODName!="" )
109  AddAODBranch("TClonesArray", &array, deltaAODName);//Put it in DeltaAOD file
110  else
111  AddAODBranch("TClonesArray", &array);//Put it in standard AOD file
112  }
113  }
114 
115  // Histograms container
116  OpenFile(1);
118 
119  AliDebug(1,Form("n histograms %d",fOutputContainer->GetEntries()));
120 
121  fOutputContainer->SetOwner(kTRUE);
122 
123  AliDebug(1,"End");
124 
125  PostData(1,fOutputContainer);
126 
127 }
128 
129 //___________________________________________________
132 //___________________________________________________
134 {
135  Init();
136 }
137 
138 //______________________________________________
140 //______________________________________________
142 {
143  AliDebug(1,"Begin");
144 
145  if( fDebug >= 0 )
146  (AliAnalysisManager::GetAnalysisManager())->AddClassDebug(this->ClassName(),fDebug);
147 
148  // Call configuration file if specified
149 
150  if (fConfigName.Length())
151  {
152  AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
153  gROOT->LoadMacro(fConfigName+".C");
154  fAna = (AliAnaCaloTrackCorrMaker*) gInterpreter->ProcessLine("ConfigAnalysis()");
155  }
156 
157  if(!fAna)
158  {
159  AliFatal("Analysis maker pointer not initialized, no analysis specified, STOP!");
160  return; // coverity
161  }
162 
163  // Add different generator particles to PDG Data Base
164  // to avoid problems when reading MC generator particles
165  AliPDG::AddParticlesToPdgDataBase();
166 
167  // Set in the reader the name of the task in case is needed
168  (fAna->GetReader())->SetTaskName(GetName());
169 
170  // Initialise analysis
171  fAna->Init();
172 
173  // Delta AOD
174  if((fAna->GetReader())->GetDeltaAODFileName()!="")
175  AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile((fAna->GetReader())->GetDeltaAODFileName());
176 
177  // Selected Trigger
178  if(fAna->GetReader()->IsEventTriggerAtSEOn()) fAna->GetReader()->SetEventTriggerMask(GetCollisionCandidates());
179 
180  AliDebug(1,"End");
181 }
182 
183 //______________________________________________________________________
185 //______________________________________________________________________
187 {
188  if ( !fAna->IsEventProcessed() ) return;
189 
190  Int_t eventN = Entry();
191 
192  // Entry() does not work for AODs
193  if ( eventN <= 0 )
194  {
195  if ( (AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler() )
196  eventN = ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler()->GetReadEntry());
197  }
198 
199  if ( (fLastEvent > 0 && eventN > fLastEvent ) ||
200  (fFirstEvent > 0 && eventN < fFirstEvent) ) return ;
201 
202  AliDebug(1,Form("Begin: Event %d - Entry %d - (First,Last)=(%d,%d)",
203  eventN, (Int_t) Entry(), fFirstEvent, fLastEvent));
204 
205  //printf("AliAnalysisTaskCaloTrackCorrelation::UserExec() - Event %d - Entry %d - (First,Last)=(%d,%d) \n",
206  // eventN, (Int_t) Entry(), fFirstEvent, fLastEvent);
207 
208  // Get the type of data, check if type is correct
209  Int_t datatype = fAna->GetReader()->GetDataType();
210  if(datatype != AliCaloTrackReader::kESD && datatype != AliCaloTrackReader::kAOD &&
211  datatype != AliCaloTrackReader::kMC)
212  {
213  AliError("Wrong type of data");
214  return ;
215  }
216 
217  fAna->GetReader()->SetInputOutputMCEvent(InputEvent(), AODEvent(), MCEvent());
218 
219  // Process event
220  fAna->ProcessEvent((Int_t) Entry(), CurrentFileName());
221 
222  PostData(1, fOutputContainer);
223 
224  AliDebug(1,"End");
225 
226  //gObjectTable->Print();
227 }
228 
229 //_______________________________________________________________________
231 //_______________________________________________________________________
233 {
234  // Get merged histograms from the output container
235  // Propagate histagrams to maker
236  fAna->Terminate((TList*)GetOutputData(1));
237 
238  // Create cuts/param objects and publish to slot
240  fCuts ->SetOwner(kTRUE);
241 
242  // Post Data
243  PostData(2, fCuts);
244 }
245 
246 //__________________________________________________________
248 //__________________________________________________________
250 {
251  if ( !fStoreEventSummary ) return ;
252 
253  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
254 
255  AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
256 
257  if (!inputH) return;
258 
259  TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics());
260  TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));
261 
262  if ( histStat )
263  {
264  if ( histStat == histBin0 ) histBin0 = 0 ;
265 
266  histStat = (TH2F*) histStat->Clone(Form("%s_%s",histStat->GetName(),"CaloTrackCorr"));
267 
268  fOutputContainer->Add(histStat);
269  }
270 
271  if ( histBin0 )
272  {
273  histBin0 = (TH2F*) histBin0->Clone(Form("%s_%s",histBin0->GetName(),"CaloTrackCorr"));
274 
275  fOutputContainer->Add(histBin0);
276  }
277 }
278 
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.