Upadting tasks
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / GEO / AliAnalysisTaskZDCTreeMaker.cxx
CommitLineData
aea8c945 1/**************************************************************************
2 * Copyright(c) 1998-2008, 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// //
18// Class to analyze ZDC data //
19// //
20/////////////////////////////////////////////////////////////
21
22#include <TTree.h>
23//#include <TList.h>
24#include <TFile.h>
25#include <TString.h>
26#include <TCanvas.h>
27
28#include "AliAnalysisManager.h"
29#include "AliInputEventHandler.h"
30#include "AliVEvent.h"
31#include "AliESD.h"
32#include "AliESDEvent.h"
33#include "AliESDHeader.h"
34#include "AliESDInputHandler.h"
35#include "AliESDZDC.h"
36#include "AliMultiplicity.h"
37#include "AliAODHandler.h"
38#include "AliAODEvent.h"
39#include "AliAODHeader.h"
40#include "AliAODVertex.h"
41#include "AliAODVZERO.h"
42#include "AliAODZDC.h"
43#include "AliAODMCHeader.h"
44#include "AliMCEventHandler.h"
45#include "AliMCEvent.h"
46#include "AliHeader.h"
47#include "AliAODMCParticle.h"
48#include "AliAnalysisTaskSE.h"
49#include "AliGenEventHeader.h"
50#include "AliGenHijingEventHeader.h"
51#include "AliPhysicsSelectionTask.h"
52#include "AliPhysicsSelection.h"
53#include "AliTriggerAnalysis.h"
54#include "AliCentrality.h"
55#include "AliAnalysisTaskZDCTreeMaker.h"
56
57ClassImp(AliAnalysisTaskZDCTreeMaker)
58
59
60//________________________________________________________________________
61AliAnalysisTaskZDCTreeMaker::AliAnalysisTaskZDCTreeMaker():
62 AliAnalysisTaskSE(),
63 fDebug(0),
64 fAnalysisInput("ESD"),
65 fIsMCInput(kFALSE),
66 fUseSpecialOutput(kFALSE),
67 fOutput(0x0),
68 fCentralityTree(0x0),
69 fIsEventSelected(kFALSE),
7c6011b7 70 fIsPileupFromSPD(kFALSE),
add7cf94 71 /*fxVertex(0),
aea8c945 72 fyVertex(0),
73 fzVertex(0),
add7cf94 74 fVertexer3d(kFALSE),*/
aea8c945 75 fNTracklets(0),
76 fIsV0ATriggered(0),
77 fIsV0CTriggered(0),
78 fMultV0A(0),
79 fMultV0C(0),
80 fESDFlag(0),
add7cf94 81 /*fZNCEnergy(0),
aea8c945 82 fZPCEnergy(0),
83 fZNAEnergy(0),
add7cf94 84 fZPAEnergy(0),*/
aea8c945 85 fZEM1Energy(0),
86 fZEM2Energy(0),
add7cf94 87 //fCentralityV0M(0),
aea8c945 88 fCentralityV0A(0),
89 fCentralityV0C(0),
eedd57da 90 fCentralityCL1(0),
91 fCentralityZNA(0),
92 fCentralityZPA(0),
93 fCentralityZNC(0),
94 fCentralityZPC(0)
aea8c945 95{
96 // Default constructor
97
add7cf94 98 for(int i=0; i<400; i++) fTracklEta[i] = -999.;
aea8c945 99 fNClusters[0]=fNClusters[1]=0;
add7cf94 100 for(int i=0; i<8; i++) fRingMultV0[i] = 0.;
aea8c945 101 for(Int_t itow=0; itow<5; itow++){
102 fZNCtower[itow]=0.;
103 fZPCtower[itow]=0.;
104 fZNAtower[itow]=0.;
105 fZPAtower[itow]=0.;
106 fZNCtowerLG[itow]=0.;
107 fZPCtowerLG[itow]=0.;
108 fZNAtowerLG[itow]=0.;
109 fZPAtowerLG[itow]=0.;
110
111 }
add7cf94 112 /*for(Int_t itdc=0; itdc<32; itdc++){
158f334c 113 for(Int_t ihit=0; ihit<4; ihit++) fTDCvalues[itdc][ihit]=9999;
add7cf94 114 }*/
aea8c945 115
aea8c945 116}
117
118//________________________________________________________________________
119AliAnalysisTaskZDCTreeMaker::AliAnalysisTaskZDCTreeMaker(const char *name):
120 AliAnalysisTaskSE(name),
121 fDebug(0),
122 fAnalysisInput("ESD"),
123 fIsMCInput(kFALSE),
124 fUseSpecialOutput(kFALSE),
125 fOutput(0x0),
126 fCentralityTree(0x0),
127 fIsEventSelected(kFALSE),
7c6011b7 128 fIsPileupFromSPD(kFALSE),
add7cf94 129 /*fxVertex(0),
eedd57da 130 fyVertex(0),
131 fzVertex(0),
add7cf94 132 fVertexer3d(kFALSE),*/
aea8c945 133 fNTracklets(0),
134 fIsV0ATriggered(0),
135 fIsV0CTriggered(0),
136 fMultV0A(0),
137 fMultV0C(0),
138 fESDFlag(0),
add7cf94 139 /*fZNCEnergy(0),
aea8c945 140 fZPCEnergy(0),
141 fZNAEnergy(0),
add7cf94 142 fZPAEnergy(0),*/
aea8c945 143 fZEM1Energy(0),
144 fZEM2Energy(0),
add7cf94 145 //fCentralityV0M(0),
aea8c945 146 fCentralityV0A(0),
147 fCentralityV0C(0),
eedd57da 148 fCentralityCL1(0),
149 fCentralityZNA(0),
150 fCentralityZPA(0),
151 fCentralityZNC(0),
152 fCentralityZPC(0)
153
aea8c945 154{
155 // Default constructor
c0313f5c 156
add7cf94 157 for(int i=0; i<400; i++) fTracklEta[i] = -999.;
aea8c945 158 fNClusters[0]=fNClusters[1]=0;
add7cf94 159 for(int i=0; i<8; i++) fRingMultV0[i] = 0.;
aea8c945 160
161 for(Int_t itow=0; itow<5; itow++){
162 fZNCtower[itow]=0.;
163 fZPCtower[itow]=0.;
164 fZNAtower[itow]=0.;
165 fZPAtower[itow]=0.;
166 fZNCtowerLG[itow]=0.;
167 fZPCtowerLG[itow]=0.;
168 fZNAtowerLG[itow]=0.;
169 fZPAtowerLG[itow]=0.;
170
171 }
add7cf94 172 /*for(Int_t itdc=0; itdc<32; itdc++){
173 for(Int_t ihit=0; ihit<4; ihit++) fTDCvalues[itdc][ihit]=9999;
158f334c 174 }*/
aea8c945 175
aea8c945 176 // Output slot #1 writes into a TList container
177 DefineOutput(1, TList::Class());
178 //DefineOutput(1, TTree::Class());
179
180}
181
182//________________________________________________________________________
183AliAnalysisTaskZDCTreeMaker::~AliAnalysisTaskZDCTreeMaker()
184{
185 // Destructor
186 if(fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
187 delete fOutput; fOutput=0;
188 }
189 /*if(fCentralityTree && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
190 delete fCentralityTree; fCentralityTree=0;
191 }
192 */
193}
194
195//________________________________________________________________________
196void AliAnalysisTaskZDCTreeMaker::UserCreateOutputObjects()
197{
198 // Create the output containers
199 if(fDebug>1) printf("AliAnalysisTaskZDCTreeMaker::UserCreateOutputObjects() \n");
200
201 if (fUseSpecialOutput) OpenFile(1);
202
203 // Several histograms are more conveniently managed in a TList
204 fOutput = new TList;
205 fOutput->SetOwner();
206 //fOutput->SetName("output");
207
208 fCentralityTree = new TTree("fCentralityTree", "Centrality vs. multiplicity tree");
209 //
eedd57da 210 fCentralityTree->Branch("trigClass",&fTrigClass,"trigClass/C");
aea8c945 211 fCentralityTree->Branch("eventSelected",&fIsEventSelected,"eventSelected/O");
359d4192 212 fCentralityTree->Branch("pileupSPD",&fIsPileupFromSPD,"pileupSPD/O");
add7cf94 213 /*fCentralityTree->Branch("xVertex", &fxVertex,"xVertex/D");
aea8c945 214 fCentralityTree->Branch("yVertex", &fyVertex,"yVertex/D");
215 fCentralityTree->Branch("zVertex", &fzVertex,"zVertex/D");
add7cf94 216 fCentralityTree->Branch("vertexer3d", &fVertexer3d,"vertexer3d/O");*/
aea8c945 217 fCentralityTree->Branch("nTracklets", &fNTracklets,"nTracklets/I");
add7cf94 218 fCentralityTree->Branch("tracklEta", fTracklEta,"tracklEta[400]/D");
aea8c945 219 fCentralityTree->Branch("nClusters", fNClusters,"nClusters[2]/I");
add7cf94 220 //
aea8c945 221 fCentralityTree->Branch("isV0ATriggered", &fIsV0ATriggered,"isV0ATriggered/I");
222 fCentralityTree->Branch("isV0CTriggered", &fIsV0CTriggered,"isV0CTriggered/I");
223 fCentralityTree->Branch("multV0A", &fMultV0A,"multV0A/F");
224 fCentralityTree->Branch("multV0C", &fMultV0C,"multV0C/F");
add7cf94 225 fCentralityTree->Branch("ringmultV0", fRingMultV0,"ringmultV0[8]/F");
aea8c945 226
227 fCentralityTree->Branch("esdFlag", &fESDFlag,"esdFlag/i");
add7cf94 228 /*fCentralityTree->Branch("zncEnergy", &fZNCEnergy, "zncEnergy/F");
aea8c945 229 fCentralityTree->Branch("zpcEnergy", &fZPCEnergy, "zpcEnergy/F");
230 fCentralityTree->Branch("znaEnergy", &fZNAEnergy, "znaEnergy/F");
add7cf94 231 fCentralityTree->Branch("zpaEnergy", &fZPAEnergy, "zpaEnergy/F");*/
aea8c945 232 fCentralityTree->Branch("zem1Energy", &fZEM1Energy, "zem1Energy/F");
233 fCentralityTree->Branch("zem2Energy", &fZEM2Energy, "zem2Energy/F");
234
235 fCentralityTree->Branch("znctower", fZNCtower, "znctower[5]/F");
236 fCentralityTree->Branch("zpctower", fZPCtower, "zpctower[5]/F");
237 fCentralityTree->Branch("znatower", fZNAtower, "znatower[5]/F");
238 fCentralityTree->Branch("zpatower", fZPAtower, "zpatower[5]/F");
239 fCentralityTree->Branch("znctowerLG", fZNCtowerLG, "znctowerLG[5]/F");
240 fCentralityTree->Branch("zpctowerLG", fZPCtowerLG, "zpctowerLG[5]/F");
241 fCentralityTree->Branch("znatowerLG", fZNAtowerLG, "znatowerLG[5]/F");
242 fCentralityTree->Branch("zpatowerLG", fZPAtowerLG, "zpatowerLG[5]/F");
243
add7cf94 244// fCentralityTree->Branch("tdc", fTDCvalues, "tdc[32][4]/I");
aea8c945 245// fCentralityTree->Branch("tdcCorr", fTDCcorr, "tdcCorr[32][4]/F");
add7cf94 246
247 //fCentralityTree->Branch("centrV0mult", &fCentralityV0M, "centrV0mult/F");
aea8c945 248 fCentralityTree->Branch("centrV0Amult", &fCentralityV0A, "centrV0Amult/F");
249 fCentralityTree->Branch("centrV0Cmult", &fCentralityV0C, "centrV0Cmult/F");
250 fCentralityTree->Branch("centrSPDclu1", &fCentralityCL1, "centrSPDclu1/F");
eedd57da 251 fCentralityTree->Branch("centrZNA", &fCentralityZNA, "centrZNA/F");
252 fCentralityTree->Branch("centrZPA", &fCentralityZPA, "centrZPA/F");
add7cf94 253 fCentralityTree->Branch("centrZNC", &fCentralityZNC, "centrZNC/F");
254 fCentralityTree->Branch("centrZPC", &fCentralityZPC, "centrZPC/F");
aea8c945 255
256 fOutput->Add(fCentralityTree);
257 PostData(1, fOutput);
258
259 //PostData(1, fCentralityTree);
260}
261
262//________________________________________________________________________
263void AliAnalysisTaskZDCTreeMaker::UserExec(Option_t */*option*/)
264{
265 // Execute analysis for current event:
266 if(fDebug>1) printf(" **** AliAnalysisTaskZDCTreeMaker::UserExec() \n");
267
268 if (!InputEvent()) {
269 Printf("ERROR: InputEvent not available");
270 return;
271 }
272
273 if(fAnalysisInput.CompareTo("ESD")==0){
274
275 //printf(" \t ***Analizing ESD ev. %d\n",fNev);
276
277 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
278 if(!esd) return;
279
280 // Select PHYSICS events (type=7, for data)
281 if(!fIsMCInput && esd->GetEventType()!=7) return;
add7cf94 282
283 for(int ir=0; ir<8; ir++) fRingMultV0[ir]=0.;
284
aea8c945 285 // ***** Trigger selection
c0313f5c 286 TString triggerClass = esd->GetFiredTriggerClasses();
287 sprintf(fTrigClass,"%s",triggerClass.Data());
aea8c945 288
289 // use response of AliPhysicsSelection
290 fIsEventSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
add7cf94 291 fIsPileupFromSPD = esd->IsPileupFromSPD(6, 0.8);
292 //fIsPileupFromSPD = esd->IsPileupFromSPDInMultBins();
aea8c945 293
294 AliCentrality *centrality = esd->GetCentrality();
add7cf94 295 //fCentralityV0M = centrality->GetCentralityPercentile("V0M");
aea8c945 296 fCentralityV0A = centrality->GetCentralityPercentile("V0A");
297 fCentralityV0C = centrality->GetCentralityPercentile("V0C");
298 fCentralityCL1 = centrality->GetCentralityPercentile("CL1");
eedd57da 299 fCentralityZNA = centrality->GetCentralityPercentile("ZNA");
300 fCentralityZPA = centrality->GetCentralityPercentile("ZPA");
301 fCentralityZNC = centrality->GetCentralityPercentile("ZNC");
302 fCentralityZPC = centrality->GetCentralityPercentile("ZPC");
aea8c945 303
add7cf94 304 /*const AliESDVertex *vertex = esd->GetPrimaryVertexSPD();
aea8c945 305 fxVertex = vertex->GetX();
306 fyVertex = vertex->GetY();
307 fzVertex = vertex->GetZ();
308 if(vertex->IsFromVertexer3D()) fVertexer3d = kTRUE;
add7cf94 309 else fVertexer3d = kFALSE;*/
aea8c945 310
311 const AliMultiplicity *mult = esd->GetMultiplicity();
312 fNTracklets = mult->GetNumberOfTracklets();
add7cf94 313 for(int itr=0; itr<fNTracklets; itr++){
314 if(itr<400) fTracklEta[itr] = mult->GetEta(itr);
315 }
aea8c945 316
317 for(Int_t ilay=0; ilay<2; ilay++){
318 fNClusters[ilay] = mult->GetNumberOfITSClusters(ilay);
319 }
320
add7cf94 321 AliESDVZERO *vzeroESD = esd->GetVZEROData();
322 fMultV0A = vzeroESD->GetMTotV0A();
323 fMultV0C = vzeroESD->GetMTotV0C();
aea8c945 324 //
add7cf94 325 fIsV0ATriggered = vzeroESD->GetV0ADecision();
326 fIsV0CTriggered = vzeroESD->GetV0CDecision();
327 //
328 for(Int_t iRing = 0; iRing < 8; ++iRing) {
329 for(Int_t i = 0; i < 8; ++i) {
330// fRingMultV0[iRing] += esd->GetVZEROEqMultiplicity(8*iRing+i);
331 fRingMultV0[iRing] += vzeroESD->GetMultiplicity(8*iRing+i);
332 }
333 }
aea8c945 334
335 AliESDZDC *esdZDC = esd->GetESDZDC();
336
337 fESDFlag = esdZDC->GetESDQuality();
338
add7cf94 339 /*fZNCEnergy = (Float_t) (esdZDC->GetZDCN1Energy());
aea8c945 340 fZPCEnergy = (Float_t) (esdZDC->GetZDCP1Energy());
341 fZNAEnergy = (Float_t) (esdZDC->GetZDCN2Energy());
add7cf94 342 fZPAEnergy = (Float_t) (esdZDC->GetZDCP2Energy());*/
aea8c945 343 fZEM1Energy = (Float_t) (esdZDC->GetZDCEMEnergy(0));
344 fZEM2Energy = (Float_t) (esdZDC->GetZDCEMEnergy(1));
345
346 const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
347 const Double_t * towZPC = esdZDC->GetZP1TowerEnergy();
348 const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
349 const Double_t * towZPA = esdZDC->GetZP2TowerEnergy();
350 //
351 const Double_t * towZNCLG = esdZDC->GetZN1TowerEnergyLR();
352 const Double_t * towZPCLG = esdZDC->GetZP1TowerEnergyLR();
353 const Double_t * towZNALG = esdZDC->GetZN2TowerEnergyLR();
354 const Double_t * towZPALG = esdZDC->GetZP2TowerEnergyLR();
355 //
356 for(Int_t it=0; it<5; it++){
357 fZNCtower[it] = (Float_t) (towZNC[it]);
358 fZPCtower[it] = (Float_t) (towZPC[it]);
359 fZNAtower[it] = (Float_t) (towZNA[it]);
360 fZPAtower[it] = (Float_t) (towZPA[it]);
361 fZNCtowerLG[it] = (Float_t) (towZNCLG[it]);
362 fZPCtowerLG[it] = (Float_t) (towZPCLG[it]);
363 fZNAtowerLG[it] = (Float_t) (towZNALG[it]);
364 fZPAtowerLG[it] = (Float_t) (towZPALG[it]);
365 }
366
add7cf94 367 /*for(Int_t itdc=0; itdc<32; itdc++){
158f334c 368 for(Int_t i=0; i<4; i++){
369 fTDCvalues[itdc][i] = esdZDC->GetZDCTDCData(itdc, i);
370 }
add7cf94 371 }*/
aea8c945 372
aea8c945 373 }
374 else if(fAnalysisInput.CompareTo("AOD")==0){
375
add7cf94 376 printf("\n \t *** Analysis on AODs is NOT implemented\n\n");
aea8c945 377
aea8c945 378
379 }
380
381 fCentralityTree->Fill();
382
383 PostData(1, fOutput);
384
385 //PostData(1, fCentralityTree);
386
387}
388
389
390
391//________________________________________________________________________
392void AliAnalysisTaskZDCTreeMaker::Terminate(Option_t */*option*/)
393{
394 // Terminate analysis
395 //
396 printf(" **** AliAnalysisTaskZDCTreeMaker::Terminate() \n");
397}