update to master versions
[u/mrichter/AliRoot.git] / PWGCF / Correlations / JCORRAN / AliJCORRANTask.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 //______________________________________________________________________________
17 // Analysis task for high pt particle correlations 
18 // author: R.Diaz, J. Rak,  D.J. Kim
19 // ALICE Group University of Jyvaskyla 
20 // Finland 
21 // Fill the analysis containers for ESD or AOD
22 // Adapted for AliAnalysisTaskSE and AOD objects  
23 //////////////////////////////////////////////////////////////////////////////
24
25 #include "TChain.h"
26 #include "TList.h"
27 #include "TTree.h"
28 #include "TFile.h"
29
30
31 #include "AliAnalysisTaskSE.h"
32 #include "AliAODHandler.h"
33
34 #include "AliJCORRANTask.h" 
35 #include "AliAnalysisManager.h"
36
37 #include "AliJTrack.h"
38 #include "AliJMCTrack.h"
39 #include "AliJPhoton.h"
40 //#include "AliJCaloCell.h"
41 #include "AliJEventHeader.h"
42 #include "AliJRunHeader.h"
43
44 //______________________________________________________________________________
45 AliJCORRANTask::AliJCORRANTask() :   
46     AliAnalysisTaskSE("PWG4JCORRAN"),
47     fFilter(0x0),
48     fAliJRunHeader(0x0)
49 {
50
51   DefineInput (0, TChain::Class());
52   
53    fFilter = new AliJFilter();
54 }
55
56 //______________________________________________________________________________
57 AliJCORRANTask::AliJCORRANTask(const char *name, TString inputformat):
58     AliAnalysisTaskSE(name), 
59     fFilter(0x0),
60     fAliJRunHeader(0x0)
61 {
62   // Constructor
63   AliInfo("---- AliJCORRANTask Constructor ----");
64
65   JUNUSED(inputformat);
66
67   DefineInput (0, TChain::Class());
68
69    fFilter = new AliJFilter( Form("%sFilter",name), this );
70 }
71
72 //____________________________________________________________________________
73 AliJCORRANTask::AliJCORRANTask(const AliJCORRANTask& ap) :
74     AliAnalysisTaskSE(ap.GetName()), 
75     fFilter(ap.fFilter),
76     fAliJRunHeader(ap.fAliJRunHeader)
77
78
79   AliInfo("----DEBUG AliJCORRANTask COPY ----");
80
81 }
82
83 //_____________________________________________________________________________
84 AliJCORRANTask& AliJCORRANTask::operator = (const AliJCORRANTask& ap)
85 {
86   // assignment operator
87
88   AliInfo("----DEBUG AliJCORRANTask operator= ----");
89   this->~AliJCORRANTask();
90   new(this) AliJCORRANTask(ap);
91   return *this;
92 }
93
94 //______________________________________________________________________________
95 AliJCORRANTask::~AliJCORRANTask()
96 {
97   // destructor 
98
99    delete fFilter;
100    delete fAliJRunHeader;
101
102 }
103
104 //________________________________________________________________________
105
106 void AliJCORRANTask::UserCreateOutputObjects()
107 {  
108   //=== create the jcorran outputs objects
109   if(fDebug > 1) printf("AliJCORRANTask::UserCreateOutPutData() \n");
110   
111   //=== Get AnalysisManager
112   AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
113   if(!man->GetOutputEventHandler()) {
114     Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
115     return;
116   }
117
118    // run the filter class
119    fFilter->SetMyTask( this );
120    fFilter->SetAliJRunHeader( fAliJRunHeader );
121    fFilter->UserCreateOutputObjects();
122
123
124   cout << "Add(fAliRunHeader) in UserCreateObject() ======= " << endl;
125
126 }
127
128 //______________________________________________________________________________
129 void AliJCORRANTask::UserExec(Option_t* /*option*/) 
130 {
131
132         // Processing of one event
133         if(fDebug > 5) cout << "------- AliJCORRANTask Exec-------"<<endl;
134         if(!((Entry()-1)%100))  AliInfo(Form(" Processing event # %lld",  Entry())); 
135
136         fFilter->UserExec("");
137
138         if(fDebug > 5) cout << "\t------- End UserExec "<<endl;
139 }
140
141 //______________________________________________________________________________
142 void AliJCORRANTask::Init()
143 {
144         // Intialisation of parameters
145         AliInfo("Doing initialization") ; 
146
147         fFilter->Init();
148 }
149
150 //______________________________________________________________________________
151 void AliJCORRANTask::Terminate(Option_t *)
152 {
153         fFilter->Terminate();
154
155         // Processing when the event loop is ended
156         fAliJRunHeader->PrintOut();
157         cout<<"AliJCORRANTask Analysis DONE !!"<<endl; 
158 }