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