]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliAnalysisTaskJets.cxx
Updates on Lambda_c decays (S. Masciocchi)
[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 #include <TROOT.h>
17 #include <TSystem.h>
18 #include <TInterpreter.h>
19 #include <TChain.h>
20 #include <TFile.h>
21 #include <TH1.h>
22
23 #include "AliAnalysisTaskJets.h"
24 #include "AliAnalysisManager.h"
25 #include "AliJetFinder.h"
26 #include "AliESD.h"
27 #include "AliAODEvent.h"
28 #include "AliAODHandler.h"
29
30
31 ClassImp(AliAnalysisTaskJets)
32
33 ////////////////////////////////////////////////////////////////////////
34
35 AliAnalysisTaskJets::AliAnalysisTaskJets():
36     fDebug(0),
37     fJetFinder(0x0),
38     fChain(0x0),
39     fESD(0x0),
40     fAOD(0x0),
41     fTreeA(0x0),
42     fHisto(0x0)
43 {
44   // Default constructor
45 }
46
47 AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
48     AliAnalysisTask(name, "AnalysisTaskJets"),
49     fDebug(0),
50     fJetFinder(0x0),
51     fChain(0x0),
52     fESD(0x0),
53     fAOD(0x0),
54     fTreeA(0x0),
55     fHisto(0x0)
56 {
57   // Default constructor
58     DefineInput (0, TChain::Class());
59     DefineOutput(0, TTree::Class());
60     DefineOutput(1, TH1F::Class());
61 }
62
63 void AliAnalysisTaskJets::CreateOutputObjects()
64 {
65 // Create the output container
66 //
67 //  Default AOD
68     AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetEventHandler());
69     fAOD   = handler->GetAOD();
70     fTreeA = handler->GetTree();
71     fJetFinder->ConnectAOD(fAOD);
72 //
73 //  Histogram
74     OpenFile(1);
75     fHisto = new TH1F("fHisto", "Jet Et", 100, 0., 100.);
76 }
77
78 void AliAnalysisTaskJets::Init()
79 {
80     // Initialization
81     if (fDebug > 1) printf("AnalysisTaskJets::Init() \n");
82
83     // Call configuration file
84     gROOT->LoadMacro("ConfigJetAnalysis.C");
85     fJetFinder = (AliJetFinder*) gInterpreter->ProcessLine("ConfigJetAnalysis()");
86     // Initialise Jet Analysis
87     fJetFinder->Init();
88     // Write header information to local file
89     fJetFinder->WriteHeaders();
90 }
91
92 void AliAnalysisTaskJets::ConnectInputData(Option_t */*option*/)
93 {
94 // Connect the input data
95 //
96     if (fDebug > 1) printf("AnalysisTaskJets::ConnectInputData() \n");
97     fChain = (TChain*)GetInputData(0);
98
99     char ** address = (char **)GetBranchAddress(0, "ESD");
100     if (address)     {
101         
102 // Branch has been already connected
103         fESD = (AliESD*)(*address);
104     }
105     else     {
106 // First task taking the branch enables it
107         fESD = new AliESD();
108         SetBranchAddress(0, "ESD", &fESD);
109     }
110     
111     fJetFinder->ConnectTree(fChain, fESD);
112 }
113
114 void AliAnalysisTaskJets::Exec(Option_t */*option*/)
115 {
116 // Execute analysis for current event
117 //
118     Long64_t ientry = fChain->GetReadEntry();
119     if (fDebug > 1) printf("Analysing event # %5d\n", (Int_t) ientry);
120     fJetFinder->ProcessEvent(ientry);
121     PostData(0, fTreeA);
122     PostData(1, fHisto);
123 }
124
125 void AliAnalysisTaskJets::Terminate(Option_t */*option*/)
126 {
127 // Terminate analysis
128 //
129     if (fDebug > 1) printf("AnalysisJets: Terminate() \n");
130     // if (fJetFinder) fJetFinder->FinishRun();
131 }
132