]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliAnalysisTaskJets.cxx
Replace printf by AliInfo
[u/mrichter/AliRoot.git] / JETAN / AliAnalysisTaskJets.cxx
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 /* $Id$ */
17  
18 #include <TROOT.h>
19 #include <TSystem.h>
20 #include <TInterpreter.h>
21 #include <TChain.h>
22 #include <TFile.h>
23 #include <TList.h>
24
25 #include "AliAnalysisTaskJets.h"
26 #include "AliAnalysisManager.h"
27 #include "AliJetFinder.h"
28 #include "AliJetHistos.h"
29 #include "AliESDEvent.h"
30 #include "AliESD.h"
31 #include "AliAODEvent.h"
32 #include "AliAODHandler.h"
33 #include "AliMCEventHandler.h"
34 #include "AliESDInputHandler.h"
35 #include "AliMCEvent.h"
36 #include "AliStack.h"
37
38
39 ClassImp(AliAnalysisTaskJets)
40
41 ////////////////////////////////////////////////////////////////////////
42
43 AliAnalysisTaskJets::AliAnalysisTaskJets():
44     AliAnalysisTaskSE(),
45   fConfigFile("ConfigJetAnalysis.C"),  
46   fNonStdBranch(""),  
47   fJetFinder(0x0),
48   fHistos(0x0),
49   fListOfHistos(0x0)
50 {
51   // Default constructor
52 }
53
54 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
55     AliAnalysisTaskSE(name),
56     fConfigFile("ConfigJetAnalysis.C"),  
57     fNonStdBranch(""),  
58     fJetFinder(0x0),
59     fHistos(0x0),
60     fListOfHistos(0x0)
61 {
62   // Default constructor
63     DefineOutput(1, TList::Class());
64 }
65
66 void AliAnalysisTaskJets::UserCreateOutputObjects()
67 {
68 // Create the output container
69 //
70     if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
71
72
73     if(fNonStdBranch.Length()==0){
74       //  Connec default AOD to jet finder
75       fJetFinder->ConnectAOD(AODEvent());
76     }
77     else{
78       // Create a new branch for jets...
79       // how is this is reset cleared in the UserExec....
80       // Can this be handled by the framework?
81       TClonesArray *tca = new TClonesArray("AliAODJet", 0);
82       tca->SetName(fNonStdBranch);
83       AddAODBranch("TClonesArray",&tca);
84       fJetFinder->ConnectAODNonStd(AODEvent(),fNonStdBranch.Data());
85     }
86     //  Histograms
87     OpenFile(1);
88     fListOfHistos = new TList();
89     fHistos       = new AliJetHistos();
90     fHistos->AddHistosToList(fListOfHistos);
91     
92 }
93
94 void AliAnalysisTaskJets::Init()
95 {
96     // Initialization
97     if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
98
99     // Call configuration file
100     gROOT->LoadMacro(fConfigFile);
101     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
102     // Initialise Jet Analysis
103     fJetFinder->Init();
104     // Write header information to local file
105     fJetFinder->WriteHeaders();
106 }
107
108     
109
110
111
112 void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
113 {
114   // Execute analysis for current event
115   //
116
117
118   // Fill control histos
119   TClonesArray* jarray = 0;
120   if(fNonStdBranch.Length()==0){
121     jarray = AODEvent()->GetJets();
122   }
123   else{
124     jarray =  dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fNonStdBranch.Data()));
125     jarray->Delete();    // this is our responsibility, clear before filling again
126   }
127
128   fJetFinder->GetReader()->SetInputEvent(InputEvent(), AODEvent(), MCEvent());
129   fJetFinder->ProcessEvent();
130
131   fHistos->FillHistos(jarray);
132   // Post the data
133   PostData(1, fListOfHistos);
134 }
135
136 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
137 {
138 // Terminate analysis
139 //
140     if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
141 //    if (fJetFinder) fJetFinder->FinishRun();
142 }
143