]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliAnalysisTaskSE.cxx
- Protections
[u/mrichter/AliRoot.git] / ANALYSIS / AliAnalysisTaskSE.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 "AliAnalysisTaskSE.h"
26 #include "AliAnalysisManager.h"
27 #include "AliESDEvent.h"
28 #include "AliESD.h"
29 #include "AliAODEvent.h"
30 #include "AliVEvent.h"
31 #include "AliAODHandler.h"
32 #include "AliMCEventHandler.h"
33 #include "AliInputEventHandler.h"
34 #include "AliMCEvent.h"
35 #include "AliStack.h"
36 #include "AliLog.h"
37
38
39 ClassImp(AliAnalysisTaskSE)
40
41 ////////////////////////////////////////////////////////////////////////
42
43 AliAnalysisTaskSE::AliAnalysisTaskSE():
44     AliAnalysisTask(),
45     fDebug(0),
46     fEntry(0),
47     fInputEvent(0x0),
48     fInputHandler(0x0),
49     fOutputAOD(0x0),
50     fMCEvent(0x0),
51     fTreeA(0x0)
52 {
53   // Default constructor
54 }
55
56 AliAnalysisTaskSE::AliAnalysisTaskSE(const char* name):
57     AliAnalysisTask(name, "AnalysisTaskSE"),
58     fDebug(0),
59     fEntry(0),
60     fInputEvent(0x0),
61     fInputHandler(0x0),
62     fOutputAOD(0x0),
63     fMCEvent(0x0),
64     fTreeA(0x0)
65 {
66   // Default constructor
67     DefineInput (0, TChain::Class());
68     DefineOutput(0,  TTree::Class());
69 }
70
71 AliAnalysisTaskSE::AliAnalysisTaskSE(const AliAnalysisTaskSE& obj):
72     AliAnalysisTask(obj),
73     fDebug(0),
74     fEntry(0),
75     fInputEvent(0x0),
76     fInputHandler(0x0),
77     fOutputAOD(0x0),
78     fMCEvent(0x0),
79     fTreeA(0x0)
80 {
81 // Copy constructor
82     fDebug        = obj.fDebug;
83     fEntry        = obj.fEntry;
84     fInputEvent   = obj.fInputEvent;
85     fInputHandler = obj.fInputHandler;
86     fOutputAOD    = obj.fOutputAOD;
87     fMCEvent      = obj.fMCEvent;
88     fTreeA        = obj.fTreeA;    
89 }
90
91
92 AliAnalysisTaskSE& AliAnalysisTaskSE::operator=(const AliAnalysisTaskSE& other)
93 {
94 // Assignment
95     AliAnalysisTask::operator=(other);
96     fDebug        = other.fDebug;
97     fEntry        = other.fEntry;
98     fInputEvent   = other.fInputEvent;
99     fInputHandler = other.fInputHandler;
100     fOutputAOD    = other.fOutputAOD;
101     fMCEvent      = other.fMCEvent;
102     fTreeA        = other.fTreeA;    
103     return *this;
104 }
105
106
107 void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
108 {
109 // Connect the input data
110     if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
111 //
112 //  ESD
113 //
114     AliInputEventHandler* fInputHandler = (AliInputEventHandler*) 
115         ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
116     if (fInputHandler) {
117         fInputEvent = fInputHandler->GetEvent();
118     } else {
119         AliError("No Input Event Handler connected") ; 
120         return ; 
121     }
122 //
123 //  Monte Carlo
124 //
125     AliMCEventHandler*    mcH = 0;
126     mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
127     if (mcH) fMCEvent = mcH->MCEvent();
128 }
129
130 void AliAnalysisTaskSE::CreateOutputObjects()
131 {
132 // Create the output container
133 //
134 //  Default AOD
135     if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
136
137     AliAODHandler* handler = (AliAODHandler*) 
138         ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
139     
140     fOutputAOD   = handler->GetAOD();
141     fTreeA = handler->GetTree();
142     UserCreateOutputObjects();
143 }
144
145 void AliAnalysisTaskSE::Exec(Option_t* option)
146 {
147 //
148 // Exec analysis of one event
149     fEntry = fInputHandler->GetReadEntry();
150     if ( !((Entry()-1)%100) && fDebug > 0) 
151         AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
152 // Call the user analysis    
153     UserExec(option);
154 }
155
156 const char* AliAnalysisTaskSE::CurrentFileName()
157 {
158 // Returns the current file name    
159     return fInputHandler->GetTree()->GetCurrentFile()->GetName();
160 }
161