]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/AliAnalysisTaskGamma.cxx
Merging THbtp and HBTP in one library. Comiplation on Windows/Cygwin
[u/mrichter/AliRoot.git] / PWG4 / AliAnalysisTaskGamma.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 // root
17 #include <TROOT.h>
18 #include <TSystem.h>
19 #include <TInterpreter.h>
20 #include <TChain.h>
21 #include <TFile.h>
22 #include <Riostream.h>
23
24 // analysis
25 #include "AliAnalysisTaskGamma.h"
26 #include "AliAnalysisManager.h"
27 #include "AliESDInputHandler.h"
28 #include "AliMCEventHandler.h"
29 #include "AliMCEvent.h"
30 #include "AliAnaGamma.h"
31 #include "AliGammaReader.h"
32 #include "AliESDEvent.h"
33 #include "AliAODEvent.h"
34 #include "AliAODHandler.h"
35 #include "AliStack.h"
36 #include "AliLog.h"
37
38 ClassImp(AliAnalysisTaskGamma)
39
40 ////////////////////////////////////////////////////////////////////////
41
42   AliAnalysisTaskGamma::AliAnalysisTaskGamma():
43     AliAnalysisTaskSE(),
44     fAna(0x0),
45     fOutputContainer(0x0),
46     fConfigName(0)
47 {
48   // Default constructor
49 }
50
51 //_____________________________________________________
52 AliAnalysisTaskGamma::AliAnalysisTaskGamma(const char* name):
53     AliAnalysisTaskSE(name),
54     fAna(0x0),
55     fOutputContainer(0x0),
56     fConfigName("ConfigGammaAnalysis")
57 {
58   // Default constructor
59
60   DefineOutput(1, TList::Class());
61
62 }
63
64 //_____________________________________________________
65 AliAnalysisTaskGamma::~AliAnalysisTaskGamma() 
66 {
67   // Remove all pointers
68  
69   if(fOutputContainer){
70     fOutputContainer->Clear() ; 
71     delete fOutputContainer ;
72   }
73
74 }
75
76 //_____________________________________________________
77 void AliAnalysisTaskGamma::UserCreateOutputObjects()
78 {
79   // Create the output container
80   
81   //AODs
82
83   fAna->ConnectAOD(AODEvent());
84
85   //Histograms container
86   OpenFile(1);
87   fOutputContainer = fAna->GetOutputContainer();
88   
89 }
90
91 //_____________________________________________________
92 void AliAnalysisTaskGamma::Init()
93 {
94   // Initialization
95   AliDebug(1,"Begin");
96   
97   // Call configuration file
98
99   if(fConfigName == ""){
100     fConfigName="ConfigGammaAnalysis";
101   }
102  
103   AliInfo(Form("### Configuration file is %s.C ###", fConfigName.Data()));
104   gROOT->LoadMacro(fConfigName+".C");
105   fAna = (AliAnaGamma*) gInterpreter->ProcessLine("ConfigGammaAnalysis()");
106   
107   if(!fAna)
108     AliFatal("Analysis pointer not initialized, abort analysis!");
109   
110   // Initialise Gamma Analysis
111   fAna->Init();
112   
113   AliDebug(1,"End");
114   
115 }
116
117
118 //_____________________________________________________
119 void AliAnalysisTaskGamma::UserExec(Option_t */*option*/)
120 {
121   // Execute analysis for current event
122   //
123
124   //Get the type of data, check if type is correct
125   Int_t  datatype = fAna->GetReader()->GetDataType();
126   if(datatype != AliGammaReader::kData && 
127      datatype != AliGammaReader::kMC && 
128      datatype != AliGammaReader::kMCData){
129     AliFatal("Wrong type of data");
130     return ;
131   }
132   
133   fAna->SetData(InputEvent());
134   
135   //In case of montecarlo analysis, pass the stack also.
136   if((datatype == AliGammaReader::kMC || datatype == AliGammaReader::kMCData ) && MCEvent())
137     fAna -> SetKine(MCEvent()->Stack());
138   
139   //Process event
140   fAna->ProcessEvent();
141   
142   PostData(1, fOutputContainer);
143   
144 }
145
146 //_____________________________________________________
147 void AliAnalysisTaskGamma::Terminate(Option_t */*option*/)
148 {
149   // Terminate analysis
150   //
151   AliDebug(1,"Do nothing in Terminate");
152   //fAna->Terminate();
153 }
154