Cleaning the code and using "const" wherever it is ppossible (Boris)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnBaseAT.cxx
CommitLineData
06351446 1#include "TChain.h"
2#include "TTree.h"
3#include "TH1F.h"
4#include "TCanvas.h"
5
6#include "AliLog.h"
7
8#include "AliAnalysisManager.h"
9#include "AliAnalysisTask.h"
10
11#include "AliESDEvent.h"
12#include "AliAODEvent.h"
13#include "AliRsnEvent.h"
14
15
16#include "AliESDInputHandler.h"
17#include "AliMCEventHandler.h"
18#include "AliAODInputHandler.h"
19
20#include "AliRsnBaseAT.h"
21
22
23ClassImp ( AliRsnBaseAT );
24
25//________________________________________________________________________
26AliRsnBaseAT::AliRsnBaseAT ( const char *name /*,Bool_t isSecondChain*/ )
27 : AliAnalysisTask ( name, "" ) /*,fIsSecondChain ( isSecondChain )*/
28{
29 InitIOVars ();
30 DefineInput ( 0, TChain::Class() );
31// if ( IsSecondChain() )
32// DefineInput ( 1, TChain::Class() );
33}
34
35void AliRsnBaseAT::InitIOVars ()
36{
37 AliDebug ( AliLog::kDebug, "<-" );
38
39 fNumOfEvents=0;
40 for ( Int_t i=0;i<3;i++ )
41 {
42 fChain[i]=0;
43 fRSN[i] = 0;
44 fESD[i] = 0;
45 fAOD[i] = 0;
46 fInputType[i] = kRSN;
47 }
48
49 fAnalysisMgr=0;
50
51 AliDebug ( AliLog::kDebug, "->" );
52}
53
54Bool_t AliRsnBaseAT::Notify()
55{
56 return AliAnalysisTask::Notify();
57}
58
59//________________________________________________________________________
60void AliRsnBaseAT::ConnectInputData ( Option_t * )
61{
62 ConnectInputDataByInputType ( fInputType[0],0 );
63// if ( IsSecondChain() )
64// ConnectInputDataByInputType ( fInputType[1],1 );
65
66}
67
68void AliRsnBaseAT::ConnectInputDataByInputType ( EInputType type ,Short_t inputIndex )
69{
70 AliDebug ( AliLog::kDebug, "<-" );
71
72 switch ( type )
73 {
74 case kAOD:
75 {
76 ConnectAOD ( inputIndex );
77 break;
78 }
79 case kESD:
80 {
81 ConnectESD ( inputIndex );
82 break;
83 }
84 case kESDMC:
85 {
86 ConnectESDMC ( inputIndex );
87 break;
88 }
89 case kMC:
90 AliError ( "Not Implemented Yet ..." );
91 break;
92 case kRSN:
93 {
94 ConnectRSN ( inputIndex );
95 break;
96 }
97 default:
98 AliError ( "Type not supported ..." );
99 break;
100 }
101 AliDebug ( AliLog::kDebug, "->" );
102}
103
104void AliRsnBaseAT::ConnectRSN ( Short_t inputIndex )
105{
106 AliDebug ( AliLog::kDebug, "<-" );
107 char ** address = ( char ** ) GetBranchAddress ( inputIndex, "RsnEvents" );
108 if ( address )
109 {
110 fRSN[inputIndex] = ( AliRsnEvent* ) ( *address );
111 }
112 else
113 {
114// fRSN[inputIndex] = new AliRsnEvent();
115 fRSN[inputIndex] = 0;
116 SetBranchAddress ( inputIndex, "RsnEvents", &fRSN[inputIndex] );
117 }
118 AliDebug ( AliLog::kDebug, "->" );
119}
120
121void AliRsnBaseAT::ConnectESD(Short_t inputIndex)
122{
123 AliDebug ( AliLog::kDebug, "<-" );
124
125// fAnalysisMgr->SetInputEventHandler ( new AliESDInputHandler() );
126
127 TTree* tree = dynamic_cast<TTree*> ( GetInputData ( inputIndex ) );
128 if ( !tree ) { AliError ( "Could not read chain from input slot 0" ); }
129 else
130 {
131 // Disable all branches, we want to process only MC
132 tree->SetBranchStatus ( "*", kFALSE );
133 tree->SetBranchStatus ( "fTracks.*", kTRUE );
134
135 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> ( AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler() );
136
137 if ( !esdH ) { AliError ( "Could not get ESDInputHandler" ); }
138 else
139 fESD[inputIndex] = esdH->GetEvent();
140 }
141 AliDebug ( AliLog::kDebug, "->" );
142
143}
144
145void AliRsnBaseAT::ConnectESDMC(Short_t inputIndex)
146{
147 AliDebug ( AliLog::kDebug, "<-" );
148
149// fAnalysisMgr->SetInputEventHandler ( new AliESDInputHandler() );
150// fAnalysisMgr->SetMCtruthEventHandler ( new AliMCEventHandler() );
151
152
153 TTree* tree = dynamic_cast<TTree*> ( GetInputData ( inputIndex ) );
154 if ( !tree ) { AliError ( "Could not read chain from input slot 0" ); }
155 else
156 {
157 // Disable all branches, we want to process only MC
158 tree->SetBranchStatus ( "*", kFALSE );
159 tree->SetBranchStatus ( "fTracks.*", kTRUE );
160
161 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> ( AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler() );
162
163 if ( !esdH ) { AliError ( "Could not get ESDInputHandler" ); }
164 else
165 fESD[inputIndex] = esdH->GetEvent();
166 }
167 AliDebug ( AliLog::kDebug, "->" );
168
169}
170
171void AliRsnBaseAT::ConnectAOD(Short_t inputIndex)
172{
173 AliDebug ( AliLog::kDebug, "<-" );
174
175 // fAnalysisMgr->SetInputEventHandler ( new AliAODInputHandler());
176
177 TTree* tree = dynamic_cast<TTree*> ( GetInputData ( inputIndex ) );
178 if ( !tree ) { AliError ( "Could not read chain from input slot 0" );}
179 else
180 {
181 AliAODInputHandler *aodH = dynamic_cast<AliAODInputHandler*> ( AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler() );
182
183 if ( !aodH ) { AliError ( "Could not get AODInputHandler" ); }
184 else
185 {
186 fAOD[inputIndex] = aodH->GetEvent();
187 }
188 }
189 AliDebug ( AliLog::kDebug, "->" );
190}