forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAliZDCCalibTask.cxx
271 lines (225 loc) · 8.79 KB
/
AliZDCCalibTask.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
* *
* Author: The ALICE Off-line Project. *
* Contributors are mentioned in the code where appropriate. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
#include <Riostream.h>
#include <TROOT.h>
#include <TSystem.h>
#include <TInterpreter.h>
#include <TTree.h>
#include <TCanvas.h>
#include <TList.h>
#include <TH1F.h>
#include <TFile.h>
#include "AliZDCCalibTask.h"
#include "AliESDEvent.h"
#include "AliLog.h"
ClassImp(AliZDCCalibTask)
//_______________________________________________________
AliZDCCalibTask::AliZDCCalibTask(const char *name):
AliAnalysisTaskSE(name),
fESD(0),
fListOfHistos(0x0),
fZNCHisto(0x0),
fZPCHisto(0x0),
fZNAHisto(0x0),
fZPAHisto(0x0)
{
// Constructor
DefineOutput(1, TList::Class());
}
//_______________________________________________________
AliZDCCalibTask::AliZDCCalibTask(const AliZDCCalibTask &calibTask):
AliAnalysisTaskSE("AliZDCCalibTask"),
fESD(calibTask.fESD),
fListOfHistos(calibTask.fListOfHistos),
fZNCHisto(calibTask.fZNCHisto),
fZPCHisto(calibTask.fZPCHisto),
fZNAHisto(calibTask.fZNAHisto),
fZPAHisto(calibTask.fZPAHisto)
{
// Copy constructor
}
//______________________________________________________________________________
AliZDCCalibTask:: ~AliZDCCalibTask()
{
// destructor
delete fESD;
delete fListOfHistos;
delete fZNCHisto;
delete fZPCHisto;
delete fZNAHisto;
delete fZPAHisto;
}
//______________________________________________________________________________
AliZDCCalibTask& AliZDCCalibTask::operator=(const AliZDCCalibTask &calibtask)
{
//assignment operator
fESD = calibtask.fESD;
fListOfHistos = calibtask.fListOfHistos;
fZNCHisto = calibtask.fZNCHisto;
fZPCHisto = calibtask.fZPCHisto;
fZNAHisto = calibtask.fZNAHisto;
fZPAHisto = calibtask.fZPAHisto;
return *this;
}
//--------------------------------------------------------------------------
void AliZDCCalibTask::BookHistos(){
//booking histos
AliInfo(Form("*** Booking Histograms %s", GetName())) ;
fZNCHisto = new TH1F("fZNCHisto", "Energy in ZNC",100,0.,MAXENVALUE);
fZNCHisto->SetXTitle("E (GeV)");
fZPCHisto = new TH1F("fZPCHisto", "Energy in ZPC",100,0.,MAXENVALUE);
fZPCHisto->SetXTitle("E (GeV)");
fZNAHisto = new TH1F("fZNAHisto", "Energy in ZNA",100,0.,MAXENVALUE);
fZNAHisto->SetXTitle("E (GeV)");
fZPAHisto = new TH1F("fZPAHisto", "Energy in ZPA",100,0.,MAXENVALUE);
fZPAHisto->SetXTitle("E (GeV)");
if(!fListOfHistos) fListOfHistos = new TList();
fListOfHistos->SetOwner();
fListOfHistos->AddAt(fZNCHisto, 0);
fListOfHistos->AddAt(fZPCHisto, 1);
fListOfHistos->AddAt(fZNAHisto, 2);
fListOfHistos->AddAt(fZPAHisto, 3);
}
//--------------------------------------------------------------------------
void AliZDCCalibTask::DrawHistos(){
//drawing output histos
AliInfo(Form("*** Drawing Histograms %s", GetName())) ;
if(!gROOT->IsBatch()){
fListOfHistos = dynamic_cast<TList*>(GetOutputData(1));
fZNCHisto = (TH1F*) fListOfHistos->At(0);
fZPCHisto = (TH1F*) fListOfHistos->At(1);
fZNAHisto = (TH1F*) fListOfHistos->At(2);
fZPAHisto = (TH1F*) fListOfHistos->At(3);
TCanvas * canvPlot = new TCanvas("canvPlot","ZDC energy",0,0,600,600);
canvPlot->Divide(2,2);
canvPlot->cd(1);
fZNCHisto->SetLineColor(kTeal+1);
fZNCHisto->DrawCopy("hist");
canvPlot->cd(2);
fZPCHisto->SetLineColor(kAzure+1);
fZPCHisto->DrawCopy("hist");
canvPlot->cd(3);
fZNCHisto->SetLineColor(kGreen+1);
fZNCHisto->DrawCopy("hist");
canvPlot->cd(4);
fZPCHisto->SetLineColor(kBlue+1);
fZPCHisto->DrawCopy("hist");
}
}
//_______________________________________________________
void AliZDCCalibTask::UserCreateOutputObjects()
{
// Create histograms
if(fDebug>1) printf("ZDCCalibTask::UserCreateOutputObjects() \n");
//Open histograms
OpenFile(1);
BookHistos();
}
//_______________________________________________________
void AliZDCCalibTask::UserExec(Option_t */*option*/)
{
// Execute analysis
AliVEvent *event = InputEvent();
if (!event) {
printf("ERROR: Could not retrieve event\n");
return;
}
AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event);
AliESDZDC *esdZDC = esd->GetESDZDC();
Float_t *znctow = (Float_t *) (esdZDC->GetZN1TowerEnergyLR());
Float_t *zpctow = (Float_t *) (esdZDC->GetZP1TowerEnergyLR());
Float_t *znatow = (Float_t *) (esdZDC->GetZN2TowerEnergyLR());
Float_t *zpatow = (Float_t *) (esdZDC->GetZP2TowerEnergyLR());
Float_t energyZNC=0., energyZPC=0.;
Float_t energyZNA=0., energyZPA=0.;
for(Int_t j=0; j<5; j++){
energyZNC += znctow[j];
energyZPC += zpctow[j];
energyZNA += znatow[j];
energyZPA += zpatow[j];
}
//printf(" Filling histos with values: %f %f %f %f\n",
// energyZNC,energyZPC,energyZNA,energyZPA);
//
fZNCHisto->Fill(energyZNC);
fZPCHisto->Fill(energyZPC);
fZNAHisto->Fill(energyZNA);
fZPAHisto->Fill(energyZPA);
PostData(1, fListOfHistos);
}
//_______________________________________________________
void AliZDCCalibTask::Terminate(Option_t *)
{
// Draw results
TH1::AddDirectory(0);
fListOfHistos = dynamic_cast<TList*>(GetOutputData(1));
fZNCHisto = (TH1F*) fListOfHistos->At(0);
fZPCHisto = (TH1F*) fListOfHistos->At(1);
fZNAHisto = (TH1F*) fListOfHistos->At(2);
fZPAHisto = (TH1F*) fListOfHistos->At(3);
Int_t binMax[4], nBinsx[4];
Float_t yMax[4], meanFitVal[4]={0.,0.,0.,0.};
TF1 *fitfun[4];
/*printf("\n # of entries in histos: %d %d %d %d \n",
(Int_t) fZNCHisto->GetEntries(),(Int_t) fZPCHisto->GetEntries(),
(Int_t) fZNAHisto->GetEntries(),(Int_t) fZPAHisto->GetEntries());*/
if(fZNCHisto->GetEntries() != 0){
binMax[0] = fZNCHisto->GetMaximumBin();
yMax[0] = (fZNCHisto->GetXaxis())->GetXmax();
nBinsx[0] = (fZNCHisto->GetXaxis())->GetNbins();
fZNCHisto->Fit("gaus","Q","",binMax[0]*yMax[0]/nBinsx[0]*0.7,binMax[0]*yMax[0]/nBinsx[0]*1.25);
fitfun[0] = fZNCHisto->GetFunction("gaus");
if(fitfun[0]) meanFitVal[0] = (Float_t) (fitfun[0]->GetParameter(1));
else printf(" !!! No fit on fZNCHisto !!!\n");
}
else AliWarning(" !!! ZNC empty histo !!!\n");
if(fZPCHisto->GetEntries() != 0){
binMax[1] = fZPCHisto->GetMaximumBin();
yMax[1] = (fZPCHisto->GetXaxis())->GetXmax();
nBinsx[1] = (fZPCHisto->GetXaxis())->GetNbins();
fZPCHisto->Fit("gaus","Q","",binMax[1]*yMax[1]/nBinsx[1]*0.7,binMax[1]*yMax[1]/nBinsx[1]*1.25);
fitfun[1] = fZPCHisto->GetFunction("gaus");
if(fitfun[1]) meanFitVal[1] = (Float_t) (fitfun[1]->GetParameter(1));
else printf(" !!! No fit on fZPCHisto !!!\n");
}
else AliWarning(" !!! ZPC empty histo !!!\n");
if(fZNAHisto->GetEntries() != 0){
binMax[2] = fZNAHisto->GetMaximumBin();
yMax[2] = (fZNAHisto->GetXaxis())->GetXmax();
nBinsx[2] = (fZNAHisto->GetXaxis())->GetNbins();
fZNAHisto->Fit("gaus","Q","",binMax[2]*yMax[2]/nBinsx[2]*0.7,binMax[2]*yMax[2]/nBinsx[2]*1.25);
fitfun[2] = fZNAHisto->GetFunction("gaus");
if(fitfun[2]) meanFitVal[2] = (Float_t) (fitfun[2]->GetParameter(1));
else printf(" !!! No fit on fZNAHisto !!!\n");
}
else AliWarning(" !!! ZNA empty histo !!!\n");
if(fZPAHisto->GetEntries() != 0){
binMax[3] = fZPAHisto->GetMaximumBin();
yMax[3] = (fZPAHisto->GetXaxis())->GetXmax();
nBinsx[3] = (fZPAHisto->GetXaxis())->GetNbins();
fZPAHisto->Fit("gaus","Q","",binMax[3]*yMax[3]/nBinsx[3]*0.7,binMax[3]*yMax[3]/nBinsx[3]*1.25);
fitfun[3] = fZPAHisto->GetFunction("gaus");
if(fitfun[3]) meanFitVal[3] = (Float_t) (fitfun[3]->GetParameter(1));
else printf(" !!! No fit on fZPAHisto !!!\n");
}
else AliWarning(" !!! ZPA empty histo !!!\n");
FILE *fileOut = fopen("EMDCalibData.dat","w");
for(Int_t j=0; j<6; j++){
if(j<4) fprintf(fileOut,"\t%f\n",meanFitVal[j]);
else fprintf(fileOut,"\t1.0000\n");
}
fclose(fileOut);
DrawHistos();
}