]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/ZDC/AliAnalysisTaskZDC.cxx
PWGPP-53 fix run data extraction during the period level QA by reusing the
[u/mrichter/AliRoot.git] / PWGPP / ZDC / AliAnalysisTaskZDC.cxx
CommitLineData
d42843d3 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 <TList.h>
23#include <TH2F.h>
24#include <TH1F.h>
25#include <TFile.h>
26#include <TString.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 "AliAODVertex.h"
40#include "AliAODMCHeader.h"
41#include "AliMCEventHandler.h"
42#include "AliMCEvent.h"
43#include "AliHeader.h"
44#include "AliAODMCParticle.h"
45#include "AliAnalysisTaskSE.h"
46#include "AliGenEventHeader.h"
47#include "AliGenHijingEventHeader.h"
48#include "AliPhysicsSelectionTask.h"
49#include "AliPhysicsSelection.h"
50#include "AliBackgroundSelection.h"
51#include "AliTriggerAnalysis.h"
52#include "AliCentrality.h"
53#include "AliAnalysisTaskZDC.h"
54
55ClassImp(AliAnalysisTaskZDC)
56
57
58//________________________________________________________________________
59AliAnalysisTaskZDC::AliAnalysisTaskZDC():
60 AliAnalysisTaskSE(),
61 fDebug(0),
62 fIsMCInput(kFALSE),
63 fOutput(0x0),
64 fhTDCZNSum(0x0),
65 fhTDCZNDiff(0x0),
66 fhZNCSpectrum(0x0),
67 fhZNASpectrum(0x0),
68 fhZPCSpectrum(0x0),
69 fhZPASpectrum(0x0),
70 fhZEM1Spectrum(0x0),
71 fhZEM2Spectrum(0x0),
72 fhZNCpmc(0x0),
73 fhZNApmc(0x0),
74 fhZPCpmc(0x0),
75 fhZPApmc(0x0),
76 fhZNCCentroid(0x0),
77 fhZNACentroid(0x0),
78 fhZNCemd(0x0),
79 fhZNAemd(0x0),
80 fhPMCZNCemd(0x0),
81 fhPMCZNAemd(0x0),
82 fDebunch(0x0)
83{
84 // Default constructor
85}
86
87//________________________________________________________________________
88AliAnalysisTaskZDC::AliAnalysisTaskZDC(const char *name):
89 AliAnalysisTaskSE(name),
90 fDebug(0),
91 fIsMCInput(kFALSE),
92 fOutput(0x0),
93 fhTDCZNSum(0x0),
94 fhTDCZNDiff(0x0),
95 fhZNCSpectrum(0x0),
96 fhZNASpectrum(0x0),
97 fhZPCSpectrum(0x0),
98 fhZPASpectrum(0x0),
99 fhZEM1Spectrum(0x0),
100 fhZEM2Spectrum(0x0),
101 fhZNCpmc(0x0),
102 fhZNApmc(0x0),
103 fhZPCpmc(0x0),
104 fhZPApmc(0x0),
105 fhZNCCentroid(0x0),
106 fhZNACentroid(0x0),
107 fhZNCemd(0x0),
108 fhZNAemd(0x0),
109 fhPMCZNCemd(0x0),
110 fhPMCZNAemd(0x0),
111 fDebunch(0x0)
112{
113 // Output slot #1 writes into a TList container
114 DefineOutput(1, TList::Class());
115
116}
117
118//________________________________________________________________________
119AliAnalysisTaskZDC& AliAnalysisTaskZDC::operator=(const AliAnalysisTaskZDC& c)
120{
121 //
122 // Assignment operator
123 //
124 if (this!=&c) {
125 AliAnalysisTaskSE::operator=(c);
126 }
127 return *this;
128}
129
130//________________________________________________________________________
131AliAnalysisTaskZDC::AliAnalysisTaskZDC(const AliAnalysisTaskZDC& ana):
132 AliAnalysisTaskSE(ana),
133 fDebug(ana.fDebug),
134 fIsMCInput(ana.fIsMCInput),
135 fOutput(ana.fOutput),
136 fhTDCZNSum(ana.fhTDCZNSum),
137 fhTDCZNDiff(ana.fhTDCZNDiff),
138 fhZNCSpectrum(ana.fhZNCSpectrum),
139 fhZNASpectrum(ana.fhZNASpectrum),
140 fhZPCSpectrum(ana.fhZPCSpectrum),
141 fhZPASpectrum(ana.fhZPASpectrum),
142 fhZEM1Spectrum(ana.fhZEM1Spectrum),
143 fhZEM2Spectrum(ana.fhZEM2Spectrum),
144 fhZNCpmc(ana.fhZNCpmc),
145 fhZNApmc(ana.fhZNApmc),
146 fhZPCpmc(ana.fhZPCpmc),
147 fhZPApmc(ana.fhZPApmc),
148 fhZNCCentroid(ana.fhZNCCentroid),
149 fhZNACentroid(ana.fhZNACentroid),
150 fhZNCemd(ana.fhZNCemd),
151 fhZNAemd(ana.fhZNAemd),
152 fhPMCZNCemd(ana.fhPMCZNCemd),
153 fhPMCZNAemd(ana.fhPMCZNAemd),
154 fDebunch(ana.fDebunch)
155{
156 //
157 // Copy Constructor
158 //
159}
160
161//________________________________________________________________________
162AliAnalysisTaskZDC::~AliAnalysisTaskZDC()
163{
164 // Destructor
165 if(fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()){
166 delete fOutput; fOutput=0;
167 }
168
169}
170
171//________________________________________________________________________
172void AliAnalysisTaskZDC::UserCreateOutputObjects()
173{
174 // Create the output containers
175
176 fOutput = new TList;
177 fOutput->SetOwner();
178 //fOutput->SetName("output");
179
31d3f53d 180 fhTDCZNSum = new TH1F("fhTDCZNSum","TDC_{ZNC}+TDC_{ZNA}",60,-30.,30.);
d42843d3 181 fhTDCZNSum->GetXaxis()->SetTitle("TDC_{ZNC}+TDC_{ZNA} (ns)");
182 fOutput->Add(fhTDCZNSum);
183
184 fhTDCZNDiff = new TH1F("fhTDCZNDiff","TDC_{ZNC}-TDC_{ZNA}",60,-30.,30.);
185 fhTDCZNDiff->GetXaxis()->SetTitle("TDC_{ZNC}-TDC_{ZNA} (ns)");
9486fe5e 186 fOutput->Add(fhTDCZNDiff);
d42843d3 187
a81cad3f 188 fhZNCSpectrum = new TH1F("fhZNCSpectrum", "ZNC signal", 200,0., 140000.);
d42843d3 189 fOutput->Add(fhZNCSpectrum);
a81cad3f 190 fhZNASpectrum = new TH1F("fhZNASpectrum", "ZNA signal", 200,0., 140000.) ;
d42843d3 191 fOutput->Add(fhZNASpectrum);
a81cad3f 192 fhZPCSpectrum = new TH1F("fhZPCSpectrum", "ZPC signal", 200,0., 50000.) ;
d42843d3 193 fOutput->Add(fhZPCSpectrum);
a81cad3f 194 fhZPASpectrum = new TH1F("fhZPASpectrum", "ZPA signal", 200,0., 50000.) ;
d42843d3 195 fOutput->Add(fhZPASpectrum);
196 fhZEM1Spectrum = new TH1F("fhZEM1Spectrum", "ZEM1 signal", 100,0., 2500.);
197 fOutput->Add(fhZEM1Spectrum);
198 fhZEM2Spectrum = new TH1F("fhZEM2Spectrum", "ZEM2 signal", 100,0., 2500.);
199 fOutput->Add(fhZEM2Spectrum);
200
a81cad3f 201 fhZNCpmc = new TH1F("fhZNCpmc","ZNC PMC",200, 0., 160000.);
d42843d3 202 fOutput->Add(fhZNCpmc);
a81cad3f 203 fhZNApmc = new TH1F("fhZNApmc","ZNA PMC",200, 0., 160000.);
d42843d3 204 fOutput->Add(fhZNApmc);
a81cad3f 205 fhZPCpmc = new TH1F("fhZPCpmc","ZPC PMC",200, 0., 40000.);
d42843d3 206 fOutput->Add(fhZPCpmc);
a81cad3f 207 fhZPApmc = new TH1F("fhZPApmc","ZPA PMC",200, 0., 40000.);
d42843d3 208 fOutput->Add(fhZPApmc);
209
210 fhZNCCentroid = new TH2F("fhZNCCentroid","Centroid over ZNC",70,-3.5,3.5,70,-3.5,3.5);
211 fOutput->Add(fhZNCCentroid);
212 fhZNACentroid = new TH2F("fhZNACentroid","Centroid over ZNA",70,-3.5,3.5,70,-3.5,3.5);
213 fOutput->Add(fhZNACentroid);
214
a81cad3f 215 fhZNCemd = new TH1F("fhZNCemd","ZNC signal lg",200,0.,6000.);
d42843d3 216 fOutput->Add(fhZNCemd);
a81cad3f 217 fhZNAemd = new TH1F("fhZNAemd","ZNA signal lg",200,0.,6000.);
d42843d3 218 fOutput->Add(fhZNAemd);
a81cad3f 219 fhPMCZNCemd = new TH1F("fhPMCZNCemd","ZNC PMC lg",200, 10., 6000.);
d42843d3 220 fOutput->Add(fhPMCZNCemd);
a81cad3f 221 fhPMCZNAemd = new TH1F("fhPMCZNAemd","ZNA PMC lg",200, 10., 6000.);
d42843d3 222 fOutput->Add(fhPMCZNAemd);
223
42339ccf 224 fDebunch = new TH2F("fDebunch","ZN TDC sum vs. diff", 120,-30,30,120,-30,-30);
d42843d3 225 fOutput->Add(fDebunch);
226
227 PostData(1, fOutput);
228}
229
230//________________________________________________________________________
231void AliAnalysisTaskZDC::UserExec(Option_t */*option*/)
232{
233 // Execute analysis for current event:
234 if(fDebug>1) printf(" **** AliAnalysisTaskZDC::UserExec() \n");
235
236 if (!InputEvent()) {
237 Printf("ERROR: InputEvent not available");
238 return;
239 }
240
241
242 AliESDEvent* esd = dynamic_cast<AliESDEvent*> (InputEvent());
37efa503 243 if(!esd) return;
d42843d3 244 // Select PHYSICS events (type=7, for data)
31d3f53d 245 //if(!fIsMCInput && esd->GetEventType()!=7) return;
d42843d3 246
247 // ********* MC INFO *********************************
248 if(fIsMCInput){
249
250 AliMCEventHandler* eventHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
251 if (!eventHandler) {
252 Printf("ERROR: Could not retrieve MC event handler");
253 return;
254 }
255
256 AliMCEvent* mcEvent = eventHandler->MCEvent();
257 if (!mcEvent) {
258 Printf("ERROR: Could not retrieve MC event");
259 return;
260 }
261
d42843d3 262 }
263 // ****************************************************
264
265 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
593ced83 266
267 AliESDZDC *esdZDC = esd->GetESDZDC();
d42843d3 268
8c03b6e8 269 if((((AliInputEventHandler*)(am->GetInputEventHandler()))->IsEventSelected())){
d42843d3 270
a81cad3f 271 fhZNCSpectrum->Fill(esdZDC->GetZDCN1Energy());
d42843d3 272 fhZNASpectrum->Fill(esdZDC->GetZDCN2Energy());
a81cad3f 273 fhZPCSpectrum->Fill(esdZDC->GetZDCP1Energy());
274 fhZPASpectrum->Fill(esdZDC->GetZDCP2Energy());
275 fhZEM1Spectrum->Fill(esdZDC->GetZDCEMEnergy(0)/8.);
276 fhZEM2Spectrum->Fill(esdZDC->GetZDCEMEnergy(1)/8.);
d42843d3 277
278 const Double_t * towZNC = esdZDC->GetZN1TowerEnergy();
279 const Double_t * towZPC = esdZDC->GetZP1TowerEnergy();
280 const Double_t * towZNA = esdZDC->GetZN2TowerEnergy();
281 const Double_t * towZPA = esdZDC->GetZP2TowerEnergy();
282 //
283 fhZNCpmc->Fill(towZNC[0]);
593ced83 284 fhZNApmc->Fill(towZNA[0]);
285 fhZPCpmc->Fill(towZPC[0]);
d42843d3 286 fhZPApmc->Fill(towZPA[0]);
287
288 Double_t xyZNC[2]={-99.,-99.}, xyZNA[2]={-99.,-99.};
a81cad3f 289 esdZDC->GetZNCentroidInPbPb(1380., xyZNC, xyZNA);
290 //esdZDC->GetZNCentroidInpp(xyZNC, xyZNA);
d42843d3 291
292 fhZNCCentroid->Fill(xyZNC[0], xyZNC[1]);
293 fhZNACentroid->Fill(xyZNA[0], xyZNA[1]);
294
295 const Double_t * towZNCLG = esdZDC->GetZN1TowerEnergyLR();
296 const Double_t * towZNALG = esdZDC->GetZN2TowerEnergyLR();
297 Double_t znclg=0., znalg=0.;
298 for(Int_t iq=0; iq<5; iq++){
299 znclg += towZNCLG[iq];
300 znalg += towZNALG[iq];
301 }
593ced83 302 fhZNCemd->Fill(znclg/2.);
303 fhZNAemd->Fill(znalg/2.);
d42843d3 304 fhPMCZNCemd->Fill(towZNCLG[0]);
305 fhPMCZNAemd->Fill(towZNALG[0]);
d42843d3 306
307 }
593ced83 308
f2772cc0 309 Float_t tdcC=999., tdcA=999;
310 Float_t tdcSum=999., tdcDiff=999;
e62e3529 311 for(int i=0; i<4; i++){
312 if(esdZDC->GetZDCTDCData(10,i) != 0.){
313 tdcC = esdZDC->GetZDCTDCCorrected(10,i);
314 if(esdZDC->GetZDCTDCData(12,i) != 0.){
315 tdcA = esdZDC->GetZDCTDCCorrected(12,i);
316 tdcSum = tdcC+tdcA;
317 tdcDiff = tdcC-tdcA;
318 }
f4d55584 319 }
7f7e8823 320 if(tdcSum!=999.) fhTDCZNSum->Fill(tdcSum);
321 if(tdcDiff!=999.)fhTDCZNDiff->Fill(tdcDiff);
322 if(tdcSum!=999. && tdcDiff!=999.) fDebunch->Fill(tdcDiff, tdcSum);
e62e3529 323 }
593ced83 324
325 PostData(1, fOutput);
d42843d3 326
327}
328
329
330
331//________________________________________________________________________
332void AliAnalysisTaskZDC::Terminate(Option_t */*option*/)
333{
334 // Terminate analysis
335 //
336}