]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/Correlations/JCORRAN/AliJCORRANTask.cxx
JCORRAN code update from DongJo
[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     fAODName("jcorran.root"),
49     fJODTree(0x0),
50     fAliJRunHeader(0x0),
51     fDoStoreJOD(kFALSE)
52
53 {
54
55   DefineInput (0, TChain::Class());
56   DefineOutput (1, TTree::Class());
57   DefineOutput (2, TList::Class());
58   
59    fFilter = new AliJFilter();
60 }
61
62 //______________________________________________________________________________
63 AliJCORRANTask::AliJCORRANTask(const char *name, TString inputformat):
64     AliAnalysisTaskSE(name), 
65     fFilter(0x0),
66     fAODName("jcorran.root"),
67     fJODTree(0x0),
68     fAliJRunHeader(0x0),
69     fDoStoreJOD(kFALSE)
70 {
71   // Constructor
72   AliInfo("---- AliJCORRANTask Constructor ----");
73
74   JUNUSED(inputformat);
75
76   DefineInput (0, TChain::Class());
77   DefineOutput (1, TTree::Class());
78   DefineOutput (2, TList::Class());
79
80    fFilter = new AliJFilter( Form("%sFilter",name), this );
81 }
82
83 //____________________________________________________________________________
84 AliJCORRANTask::AliJCORRANTask(const AliJCORRANTask& ap) :
85     AliAnalysisTaskSE(ap.GetName()), 
86     fFilter(ap.fFilter),
87     fAODName(ap.fAODName),
88     fJODTree(ap.fJODTree),
89     fAliJRunHeader(ap.fAliJRunHeader),
90     fDoStoreJOD(ap.fDoStoreJOD)
91
92
93   AliInfo("----DEBUG AliJCORRANTask COPY ----");
94
95 }
96
97 //_____________________________________________________________________________
98 AliJCORRANTask& AliJCORRANTask::operator = (const AliJCORRANTask& ap)
99 {
100   // assignment operator
101
102   AliInfo("----DEBUG AliJCORRANTask operator= ----");
103   this->~AliJCORRANTask();
104   new(this) AliJCORRANTask(ap);
105   return *this;
106 }
107
108 //______________________________________________________________________________
109 AliJCORRANTask::~AliJCORRANTask()
110 {
111   // destructor 
112
113    delete fFilter;
114    delete fJODTree;
115    delete fAliJRunHeader;
116
117 }
118
119 //________________________________________________________________________
120
121 void AliJCORRANTask::UserCreateOutputObjects()
122 {  
123   //=== create the jcorran outputs objects
124   if(fDebug > 1) printf("AliJCORRANTask::UserCreateOutPutData() \n");
125   
126   //=== Get AnalysisManager
127   AliAnalysisManager *man = AliAnalysisManager::GetAnalysisManager();
128   if(!man->GetOutputEventHandler()) {
129     Fatal("UserCreateOutputObjects", "This task needs an AOD handler");
130     return;
131   }
132
133    // run the filter class
134    fFilter->SetMyTask( this );
135    fFilter->SetAliJRunHeader( fAliJRunHeader );
136    fFilter->UserCreateOutputObjects();
137
138   // register ouput branches
139
140   if(fDoStoreJOD){
141                 TFile * file1 = OpenFile(1);
142                 file1-> SetCompressionLevel(9);
143                 TTree * tree = new TTree("JODTree","JYFL Object Data");
144                 int split = 2;
145                 int basketsize = 32000;
146                 tree->Branch("TrackList", fFilter->GetTrackList(),basketsize, split);
147                 if( fFilter->IsMC() ) 
148                                 tree->Branch("MCTrackList", fFilter->GetMCTrackList(),basketsize, split );
149                 //== Event Header
150                 tree->Branch("HeaderList", fFilter->GetHeaderList(),basketsize, split );
151                 //== EventPlane SRC
152                 if( fFilter->GetStoreEventPlaneSource() ){
153                                 tree->Branch("AliESDVZERO", fFilter->GetESDVZERO());
154                                 tree->Branch("AliESDTZERO", fFilter->GetESDTZERO());
155                                 tree->Branch("AliESDZDC",   fFilter->GetESDZDC());
156                 }
157                 fJODTree = tree;
158   }
159
160   PostData( 1, fJODTree );
161   //OpenFile(2);
162   PostData( 2,fFilter->GetRunInfoList());
163
164
165   cout << "Add(fAliRunHeader) in UserCreateObject() ======= " << endl;
166
167 }
168
169 //______________________________________________________________________________
170 void AliJCORRANTask::UserExec(Option_t* /*option*/) 
171 {
172
173         // Processing of one event
174         if(fDebug > 5) cout << "------- AliJCORRANTask Exec-------"<<endl;
175         if(!((Entry()-1)%100))  AliInfo(Form(" Processing event # %lld",  Entry())); 
176
177         fFilter->UserExec("");
178
179         if(  1 || fFilter->GetEventSuccess() ){ // TODO
180                 if( fDoStoreJOD ){
181                         fJODTree->Fill();
182                 }
183         }
184         PostData(1,fJODTree);
185         PostData(2,fFilter->GetRunInfoList());
186
187
188         if(fDebug > 5) cout << "\t------- End UserExec "<<endl;
189 }
190
191 //______________________________________________________________________________
192 void AliJCORRANTask::Init()
193 {
194         // Intialisation of parameters
195         AliInfo("Doing initialization") ; 
196
197         fFilter->Init();
198
199         //   TString formula(fEsdTrackCuts->GetMaxDCAToVertexXYPtDep());
200         //   if(formula.Length()>0){ // momentum dep DCA cut for AOD
201         //     formula.ReplaceAll("pt","x");
202         //   }
203 }
204
205 //______________________________________________________________________________
206 void AliJCORRANTask::Terminate(Option_t * option)
207 {
208         fFilter->Terminate();
209
210         // Processing when the event loop is ended
211         fAliJRunHeader->PrintOut();
212         cout<<"AliJCORRANTask Analysis DONE !!"<<endl; 
213         // Printout fRunInfoList here
214         TList* fRunInfoList = dynamic_cast<TList*> (GetOutputData(1));
215         if(fRunInfoList)
216         {
217                 AliJRunHeader *fAliRunHeader = dynamic_cast<AliJRunHeader*> (fRunInfoList->FindObject("AliJRunHeader"));
218                 if(fAliRunHeader) {fAliRunHeader->Print();}
219         }
220         else
221         {
222                 cout << "WARNING : Run Information List is empty" << endl;
223         }
224
225 }