]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ZDC/AliZDCReconstructor.cxx
moved component registration to agent; added component configuration/initialization...
[u/mrichter/AliRoot.git] / ZDC / AliZDCReconstructor.cxx
CommitLineData
8309c1ab 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 *
f5d41205 13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// class for ZDC reconstruction //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24
25#include <TF1.h>
26
27#include "AliRunLoader.h"
28#include "AliRawReader.h"
29#include "AliESDEvent.h"
a85132e7 30#include "AliESDZDC.h"
f5d41205 31#include "AliZDCDigit.h"
32#include "AliZDCRawStream.h"
33#include "AliZDCReco.h"
34#include "AliZDCReconstructor.h"
6024ec85 35#include "AliZDCPedestals.h"
36#include "AliZDCCalib.h"
37#include "AliZDCRecParam.h"
f5d41205 38
39
40ClassImp(AliZDCReconstructor)
41
42
43//_____________________________________________________________________________
44AliZDCReconstructor:: AliZDCReconstructor() :
45
46 fZNCen(new TF1("fZNCen",
47 "(-2.287920+sqrt(2.287920*2.287920-4*(-0.007629)*(11.921710-x)))/(2*(-0.007629))",0.,164.)),
48 fZNPer(new TF1("fZNPer",
49 "(-37.812280-sqrt(37.812280*37.812280-4*(-0.190932)*(-1709.249672-x)))/(2*(-0.190932))",0.,164.)),
50 fZPCen(new TF1("fZPCen",
51 "(-1.321353+sqrt(1.321353*1.321353-4*(-0.007283)*(3.550697-x)))/(2*(-0.007283))",0.,60.)),
52 fZPPer(new TF1("fZPPer",
53 "(-42.643308-sqrt(42.643308*42.643308-4*(-0.310786)*(-1402.945615-x)))/(2*(-0.310786))",0.,60.)),
54 fZDCCen(new TF1("fZDCCen",
55 "(-1.934991+sqrt(1.934991*1.934991-4*(-0.004080)*(15.111124-x)))/(2*(-0.004080))",0.,225.)),
56 fZDCPer(new TF1("fZDCPer",
57 "(-34.380639-sqrt(34.380639*34.380639-4*(-0.104251)*(-2612.189017-x)))/(2*(-0.104251))",0.,225.)),
58 fbCen(new TF1("fbCen","-0.056923+0.079703*x-0.0004301*x*x+0.000001366*x*x*x",0.,220.)),
59 fbPer(new TF1("fbPer","17.943998-0.046846*x+0.000074*x*x",0.,220.)),
60 //
61 fZEMn(new TF1("fZEMn","121.7-0.1934*x+0.00007565*x*x",0.,1200.)),
62 fZEMp(new TF1("fZEMp","80.05-0.1315*x+0.00005327*x*x",0.,1200.)),
63 fZEMsp(new TF1("fZEMsp","201.7-0.325*x+0.0001292*x*x",0.,1200.)),
64 fZEMb(new TF1("fZEMb",
65 "13.83-0.02851*x+5.101e-5*x*x-7.305e-8*x*x*x+5.101e-11*x*x*x*x-1.25e-14*x*x*x*x*x",0.,1200.)),
66 //
6024ec85 67 fPedData(GetPedData()),
68 fECalibData(GetECalibData()),
69 fRecParam(GetRecParams())
f5d41205 70{
71 // **** Default constructor
72
73}
74
75
76//_____________________________________________________________________________
77AliZDCReconstructor::~AliZDCReconstructor()
78{
79// destructor
80
81 delete fZNCen;
82 delete fZNPer;
83 delete fZPCen;
84 delete fZPPer;
85 delete fZDCCen;
86 delete fZDCPer;
87 delete fbCen;
88 delete fbPer;
89 delete fZEMn;
90 delete fZEMp;
91 delete fZEMsp;
92 delete fZEMb;
93
94}
95
96
97//_____________________________________________________________________________
98void AliZDCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
99{
100 // *** Local ZDC reconstruction for digits
101 // Works on the current event
102
103 // Retrieving calibration data
a85132e7 104 Float_t meanPed[48];
105 for(Int_t jj=0; jj<48; jj++) meanPed[jj] = fPedData->GetMeanPed(jj);
f5d41205 106
107 // get digits
108 AliZDCDigit digit;
109 AliZDCDigit* pdigit = &digit;
110 digitsTree->SetBranchAddress("ZDC", &pdigit);
c35ed519 111 //printf("\n\t # of digits in tree: %d\n",(Int_t) digitsTree->GetEntries());
f5d41205 112
113 // loop over digits
c35ed519 114 Float_t tZN1Corr[10], tZP1Corr[10], tZN2Corr[10], tZP2Corr[10];
115 Float_t dZEM1Corr[2], dZEM2Corr[2], PMRef1[2], PMRef2[2];
116 for(Int_t i=0; i<10; i++){
117 tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
118 if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = PMRef1[i] = PMRef2[i] = 0.;
119 }
120 //
f5d41205 121 for (Int_t iDigit = 0; iDigit < (digitsTree->GetEntries()/2); iDigit++) {
a85132e7 122 digitsTree->GetEntry(iDigit);
123 if (!pdigit) continue;
a85132e7 124 //
125 Int_t det = digit.GetSector(0);
126 Int_t quad = digit.GetSector(1);
c35ed519 127 Int_t pedindex = -1, kNch = 24;
a85132e7 128 //printf("\n\t Digit #%d det %d quad %d", iDigit, det, quad);
129 //
130 if(quad != 5){ // ZDC (not reference PTMs!)
c35ed519 131 if(det == 1){ // *** ZNC
f5d41205 132 pedindex = quad;
c35ed519 133 tZN1Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
134 if(tZN1Corr[quad]<0.) tZN1Corr[quad] = 0.;
135 tZN1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
136 if(tZN1Corr[quad+5]<0.) tZN1Corr[quad] = 0.;
137 //printf("\t pedindex %d tZN1Corr[%d] = %1.0f tZN1Corr[%d] = %1.0f",
138 // pedindex, quad, tZN1Corr[quad], quad+5, tZN1Corr[quad+5]);
f5d41205 139 }
140 else if(det == 2){ // *** ZP1
a85132e7 141 pedindex = quad+5;
c35ed519 142 tZP1Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
143 if(tZP1Corr[quad]<0.) tZP1Corr[quad] = 0.;
144 tZP1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
145 if(tZP1Corr[quad+5]<0.) tZP1Corr[quad] = 0.;
146 //printf("\t pedindex %d tZP1Corr[%d] = %1.0f tZP1Corr[%d] = %1.0f",
147 // pedindex, quad, tZP1Corr[quad], quad+5, tZP1Corr[quad+5]);
f5d41205 148 }
149 else if(det == 3){
c35ed519 150 pedindex = quad+9;
f5d41205 151 if(quad == 1){ // *** ZEM1
c35ed519 152 dZEM1Corr[0] += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
153 if(dZEM1Corr[0]<0.) dZEM1Corr[0] = 0.;
154 dZEM1Corr[1] += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
155 if(dZEM1Corr[1]<0.) dZEM1Corr[1] = 0.;
156 //printf("\t pedindex %d tZEM1Corr[%d] = %1.0f tZEM1Corr[%d] = %1.0f",
157 // pedindex, quad, tZEM1Corr[quad], quad+1, tZEM1Corr[quad+1]);
f5d41205 158 }
a85132e7 159 else if(quad == 2){ // *** ZEM2
c35ed519 160 dZEM2Corr[0] += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
161 if(dZEM2Corr[0]<0.) dZEM2Corr[0] = 0.;
162 dZEM2Corr[1] += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
163 if(dZEM2Corr[1]<0.) dZEM2Corr[1] = 0.;
164 //printf("\t pedindex %d tZEM2Corr[%d] = %1.0f tZEM2Corr[%d] = %1.0f",
165 // pedindex, quad, tZEM2Corr[quad], quad+1, tZEM2Corr[quad+1]);
f5d41205 166 }
167 }
168 else if(det == 4){ // *** ZN2
a85132e7 169 pedindex = quad+12;
c35ed519 170 tZN2Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
171 if(tZN2Corr[quad]<0.) tZN2Corr[quad] = 0.;
172 tZN2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
173 if(tZN2Corr[quad+5]<0.) tZN2Corr[quad+5] = 0.;
174 //printf("\t pedindex %d tZN2Corr[%d] = %1.0f tZN2Corr[%d] = %1.0f\n",
175 // pedindex, quad, tZN2Corr[quad], quad+5, tZN2Corr[quad+5]);
f5d41205 176 }
177 else if(det == 5){ // *** ZP2
a85132e7 178 pedindex = quad+17;
c35ed519 179 tZP2Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
180 if(tZP2Corr[quad]<0.) tZP2Corr[quad] = 0.;
181 tZP2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
182 if(tZP2Corr[quad+5]<0.) tZP2Corr[quad+5] = 0.;
183 //printf("\t pedindex %d tZP2Corr[%d] = %1.0f tZP2Corr[%d] = %1.0f\n",
184 // pedindex, quad, tZP2Corr[quad], quad+5, tZP2Corr[quad+5]);
f5d41205 185 }
a85132e7 186 }
c35ed519 187 else{ // Reference PMs
188 pedindex = (det-1)/3+22;
189 if(det == 1){
190 PMRef1[0] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
191 if(PMRef1[0]<0.) PMRef1[0] = 0.;
192 PMRef1[1] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
193 if(PMRef2[1]<0.) PMRef1[1] = 0.;
194 }
195 else if(det == 4){
196 PMRef2[0] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
197 if(PMRef2[0]<0.) PMRef2[0] = 0.;
198 PMRef2[1] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
199 if(PMRef2[1]<0.) PMRef2[1] = 0.;
200 }
201 }
f5d41205 202 }
203
204 // reconstruct the event
c35ed519 205 ReconstructEvent(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
206 dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
f5d41205 207
208}
209
210//_____________________________________________________________________________
211void AliZDCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
212{
213 // *** ZDC raw data reconstruction
214 // Works on the current event
215
216 // Retrieving calibration data
a85132e7 217 Float_t meanPed[48];
218 for(Int_t jj=0; jj<48; jj++) meanPed[jj] = fPedData->GetMeanPed(jj);
f5d41205 219
220 rawReader->Reset();
221
c35ed519 222 // loop over raw data
223 Float_t tZN1Corr[10], tZP1Corr[10], tZN2Corr[10], tZP2Corr[10];
224 Float_t dZEM1Corr[2], dZEM2Corr[2], PMRef1[2], PMRef2[2];
225 for(Int_t i=0; i<10; i++){
226 tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
227 if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = PMRef1[i] = PMRef2[i] = 0.;
228 }
f5d41205 229 //
230 AliZDCRawStream rawData(rawReader);
c35ed519 231 Int_t kNch = 24;
f5d41205 232 while (rawData.Next()) {
233 if(rawData.IsADCDataWord()){
a85132e7 234 Int_t det = rawData.GetSector(0);
235 Int_t quad = rawData.GetSector(1);
236 Int_t gain = rawData.GetADCGain();
237 Int_t pedindex=0;
238 //
239 if(quad !=5){ // ZDCs (not reference PTMs)
f5d41205 240 if(det == 1){
241 pedindex = quad;
c35ed519 242 if(gain == 0) tZN1Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
243 else tZN1Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 244 }
245 else if(det == 2){
a85132e7 246 pedindex = quad+5;
c35ed519 247 if(gain == 0) tZP1Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
248 else tZP1Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 249 }
250 else if(det == 3){
c35ed519 251 pedindex = quad+9;
f5d41205 252 if(quad==1){
c35ed519 253 if(gain == 0) dZEM1Corr[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
254 else dZEM1Corr[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 255 }
256 else if(quad==2){
c35ed519 257 if(gain == 0) dZEM2Corr[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
258 else dZEM2Corr[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 259 }
260 }
261 else if(det == 4){
a85132e7 262 pedindex = quad+12;
c35ed519 263 if(gain == 0) tZN2Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
264 else tZN2Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 265 }
266 else if(det == 5){
a85132e7 267 pedindex = quad+17;
c35ed519 268 if(gain == 0) tZP2Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
269 else tZP2Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 270 }
c35ed519 271 //printf("\t AliZDCReconstructor - det %d quad %d res %d -> Ped[%d] = %1.0f\n",
272 // det,quad,gain, pedindex, meanPed[pedindex]);
273 }
274 else{ // reference PM
275 pedindex = (det-1)/3 + 22;
276 if(det == 1){
277 if(gain==0) PMRef1[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
278 else PMRef1[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
279 }
280 else if(det ==4){
281 if(gain==0) PMRef2[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
282 else PMRef2[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
283 }
a85132e7 284 }
285 }//IsADCDataWord
f5d41205 286 }
287
288 // reconstruct the event
c35ed519 289 ReconstructEvent(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
290 dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
f5d41205 291
292}
293
294//_____________________________________________________________________________
c35ed519 295void AliZDCReconstructor::ReconstructEvent(TTree *clustersTree, Float_t* ZN1ADCCorr,
296 Float_t* ZP1ADCCorr, Float_t* ZN2ADCCorr, Float_t* ZP2ADCCorr,
297 Float_t* ZEM1ADCCorr, Float_t* ZEM2ADCCorr, Float_t* PMRef1, Float_t* PMRef2) const
f5d41205 298{
299 // ***** Reconstruct one event
300
f5d41205 301 // *** RECONSTRUCTION FROM "REAL" DATA
302 //
303 // Retrieving calibration data
84d6255e 304 // --- Equalization coefficients ---------------------------------------------
f5d41205 305 Float_t equalCoeffZN1[5], equalCoeffZP1[5], equalCoeffZN2[5], equalCoeffZP2[5];
306 for(Int_t ji=0; ji<5; ji++){
6024ec85 307 equalCoeffZN1[ji] = fECalibData->GetZN1EqualCoeff(ji);
308 equalCoeffZP1[ji] = fECalibData->GetZP1EqualCoeff(ji);
309 equalCoeffZN2[ji] = fECalibData->GetZN2EqualCoeff(ji);
310 equalCoeffZP2[ji] = fECalibData->GetZP2EqualCoeff(ji);
f5d41205 311 }
84d6255e 312 // --- Energy calibration factors ------------------------------------
f5d41205 313 Float_t calibEne[4];
6024ec85 314 for(Int_t ij=0; ij<4; ij++) calibEne[ij] = fECalibData->GetEnCalib(ij);
f5d41205 315 //
84d6255e 316 // --- Reconstruction parameters ------------------
6024ec85 317 Float_t endPointZEM = fRecParam->GetZEMEndValue();
318 Float_t cutFractionZEM = fRecParam->GetZEMCutFraction();
319 Float_t dZEMSup = fRecParam->GetDZEMSup();
320 Float_t dZEMInf = fRecParam->GetDZEMInf();
f5d41205 321 //
322 Float_t cutValueZEM = endPointZEM*cutFractionZEM;
323 Float_t supValueZEM = cutValueZEM+(endPointZEM*dZEMSup);
324 Float_t infValueZEM = cutValueZEM-(endPointZEM*dZEMInf);
325 //
c35ed519 326 Float_t maxValEZN1 = fRecParam->GetEZN1MaxValue();
327 Float_t maxValEZP1 = fRecParam->GetEZP1MaxValue();
6024ec85 328 Float_t maxValEZDC1 = fRecParam->GetEZDC1MaxValue();
c35ed519 329 Float_t maxValEZN2 = fRecParam->GetEZN2MaxValue();
330 Float_t maxValEZP2 = fRecParam->GetEZP2MaxValue();
6024ec85 331 Float_t maxValEZDC2 = fRecParam->GetEZDC2MaxValue();
f5d41205 332 //
333 //printf("\n\t AliZDCReconstructor -> ZEMEndPoint %1.0f, ZEMCutValue %1.0f,"
334 // " ZEMSupValue %1.0f, ZEMInfValue %1.0f\n",endPointZEM,cutValueZEM,supValueZEM,infValueZEM);
335
336 // Equalization of detector responses
c35ed519 337 Float_t equalTowZN1[10], equalTowZN2[10], equalTowZP1[10], equalTowZP2[10];
338 for(Int_t gi=0; gi<10; gi++){
339 equalTowZN1[gi] = ZN1ADCCorr[gi]*equalCoeffZN1[gi];
340 equalTowZP1[gi] = ZP1ADCCorr[gi]*equalCoeffZP1[gi];
341 equalTowZN2[gi] = ZN2ADCCorr[gi]*equalCoeffZN2[gi];
342 equalTowZP2[gi] = ZP2ADCCorr[gi]*equalCoeffZP2[gi];
f5d41205 343 }
344
345 // Energy calibration of detector responses
c35ed519 346 Float_t calibTowZN1[10], calibTowZN2[10], calibTowZP1[10], calibTowZP2[10];
c9102a72 347 Float_t calibSumZN1[]={0,0}, calibSumZN2[]={0,0}, calibSumZP1[]={0,0}, calibSumZP2[]={0,0};
c35ed519 348 for(Int_t gi=0; gi<10; gi++){
349 calibTowZN1[gi] = equalTowZN1[gi]*calibEne[0];
350 calibTowZP1[gi] = equalTowZP1[gi]*calibEne[1];
351 calibTowZN2[gi] = equalTowZN2[gi]*calibEne[2];
352 calibTowZP2[gi] = equalTowZP2[gi]*calibEne[3];
f5d41205 353 //
c35ed519 354 if(gi<5){
355 calibSumZN1[0] += calibTowZN1[gi];
356 calibSumZP1[0] += calibTowZP1[gi];
357 calibSumZN2[0] += calibTowZN2[gi];
358 calibSumZP2[0] += calibTowZP2[gi];
359 }
360 //
361 else{
362 calibSumZN1[1] += calibTowZN1[gi];
363 calibSumZP1[1] += calibTowZP1[gi];
364 calibSumZN2[1] += calibTowZN2[gi];
365 calibSumZP2[1] += calibTowZP2[gi];
366 }
f5d41205 367 }
368
369 // --- Number of detected spectator nucleons
370 // *** N.B. -> It works only in Pb-Pb
371 Int_t nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight;
c35ed519 372 nDetSpecNLeft = (Int_t) (calibSumZN1[0]/2.760);
373 nDetSpecPLeft = (Int_t) (calibSumZP1[0]/2.760);
374 nDetSpecNRight = (Int_t) (calibSumZN2[0]/2.760);
375 nDetSpecPRight = (Int_t) (calibSumZP2[0]/2.760);
f5d41205 376 /*printf("\n\t AliZDCReconstructor -> nDetSpecNLeft %d, nDetSpecPLeft %d,"
377 " nDetSpecNRight %d, nDetSpecPRight %d\n",nDetSpecNLeft, nDetSpecPLeft,
378 nDetSpecNRight, nDetSpecPRight);*/
379
380 // --- Number of generated spectator nucleons (from HIJING parameterization)
381 Int_t nGenSpecNLeft=0, nGenSpecPLeft=0, nGenSpecLeft=0;
382 Int_t nGenSpecNRight=0, nGenSpecPRight=0, nGenSpecRight=0;
383 Double_t impPar=0.;
384 //
f5d41205 385 //
c35ed519 386 Float_t corrADCZEMHG = ZEM1ADCCorr[0] + ZEM2ADCCorr[0];
a85132e7 387 //
a4cab348 388 if(corrADCZEMHG > supValueZEM){
c35ed519 389 nGenSpecNLeft = (Int_t) (fZNCen->Eval(calibSumZN1[0]));
390 nGenSpecPLeft = (Int_t) (fZPCen->Eval(calibSumZP1[0]));
391 nGenSpecLeft = (Int_t) (fZDCCen->Eval(calibSumZN1[0]+calibSumZP1[0]));
392 nGenSpecNRight = (Int_t) (fZNCen->Eval(calibSumZN2[0]));
393 nGenSpecPRight = (Int_t) (fZNCen->Eval(calibSumZP2[0]));
394 nGenSpecRight = (Int_t) (fZNCen->Eval(calibSumZN2[0]+calibSumZP2[0]));
395 impPar = fbCen->Eval(calibSumZN1[0]+calibSumZP1[0]);
646f1679 396 }
a4cab348 397 else if(corrADCZEMHG < infValueZEM){
c35ed519 398 nGenSpecNLeft = (Int_t) (fZNPer->Eval(calibSumZN1[0]));
399 nGenSpecPLeft = (Int_t) (fZPPer->Eval(calibSumZP1[0]));
400 nGenSpecLeft = (Int_t) (fZDCPer->Eval(calibSumZN1[0]+calibSumZP1[0]));
401 impPar = fbPer->Eval(calibSumZN1[0]+calibSumZP1[0]);
646f1679 402 }
a4cab348 403 else if(corrADCZEMHG >= infValueZEM && corrADCZEMHG <= supValueZEM){
404 nGenSpecNLeft = (Int_t) (fZEMn->Eval(corrADCZEMHG));
405 nGenSpecPLeft = (Int_t) (fZEMp->Eval(corrADCZEMHG));
406 nGenSpecLeft = (Int_t)(fZEMsp->Eval(corrADCZEMHG));
407 impPar = fZEMb->Eval(corrADCZEMHG);
646f1679 408 }
409 //
c35ed519 410 if(calibSumZN1[0]/maxValEZN1>1.) nGenSpecNLeft = (Int_t) (fZEMn->Eval(corrADCZEMHG));
411 if(calibSumZP1[0]/maxValEZP1>1.) nGenSpecPLeft = (Int_t) (fZEMp->Eval(corrADCZEMHG));
412 if((calibSumZN1[0]+calibSumZP1[0]/maxValEZDC1)>1.){
a4cab348 413 nGenSpecLeft = (Int_t)(fZEMsp->Eval(corrADCZEMHG));
414 impPar = fZEMb->Eval(corrADCZEMHG);
646f1679 415 }
c35ed519 416 if(calibSumZN2[0]/maxValEZN2>1.) nGenSpecNRight = (Int_t) (fZEMn->Eval(corrADCZEMHG));
417 if(calibSumZP2[0]/maxValEZP2>1.) nGenSpecPRight = (Int_t) (fZEMp->Eval(corrADCZEMHG));
418 if((calibSumZN2[0]+calibSumZP2[0]/maxValEZDC2)>1.) nGenSpecRight = (Int_t)(fZEMsp->Eval(corrADCZEMHG));
646f1679 419 //
420 if(nGenSpecNLeft>125) nGenSpecNLeft=125;
421 else if(nGenSpecNLeft<0) nGenSpecNLeft=0;
422 if(nGenSpecPLeft>82) nGenSpecPLeft=82;
423 else if(nGenSpecPLeft<0) nGenSpecPLeft=0;
424 if(nGenSpecLeft>207) nGenSpecLeft=207;
425 else if(nGenSpecLeft<0) nGenSpecLeft=0;
8309c1ab 426
980685f2 427 // --- Number of generated participants (from HIJING parameterization)
646f1679 428 Int_t nPart, nPartTotLeft, nPartTotRight;
429 nPart = 207-nGenSpecNLeft-nGenSpecPLeft;
430 nPartTotLeft = 207-nGenSpecLeft;
431 nPartTotRight = 207-nGenSpecRight;
e90a5fef 432 if(nPart<0) nPart=0;
433 if(nPartTotLeft<0) nPartTotLeft=0;
434 if(nPartTotRight<0) nPartTotRight=0;
e97af564 435 //
e90a5fef 436 // *** DEBUG ***
c35ed519 437 /*printf("\n\t AliZDCReconstructor -> calibSumZN1[0] %1.0f, calibSumZP1[0] %1.0f,"
438 " calibSumZN2[0] %1.0f, calibSumZP2[0] %1.0f, corrADCZEMHG %1.0f\n",
439 calibSumZN1[0],calibSumZP1[0],calibSumZN2[0],calibSumZP2[0],corrADCZEMHG);
e90a5fef 440 printf("\t AliZDCReconstructor -> nGenSpecNLeft %d, nGenSpecPLeft %d, nGenSpecLeft %d\n"
441 "\t\t nGenSpecNRight %d, nGenSpecPRight %d, nGenSpecRight %d\n",
442 nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft,
443 nGenSpecNRight, nGenSpecPRight, nGenSpecRight);
444 printf("\t AliZDCReconstructor -> NpartL %d, NpartR %d, b %1.2f fm\n\n",nPartTotLeft, nPartTotRight, impPar);
c35ed519 445 */
446
646f1679 447 // create the output tree
c35ed519 448 AliZDCReco reco(calibSumZN1, calibSumZP1, calibSumZN2, calibSumZP2,
449 calibTowZN1, calibTowZN2, calibTowZP1, calibTowZP2,
450 ZEM1ADCCorr, ZEM2ADCCorr, PMRef1, PMRef2,
646f1679 451 nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight,
452 nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft, nGenSpecNRight,
c35ed519 453 nGenSpecPRight, nGenSpecRight, nPartTotLeft, nPartTotRight, impPar);
646f1679 454
8309c1ab 455 AliZDCReco* preco = &reco;
456 const Int_t kBufferSize = 4000;
70f04f6d 457 clustersTree->Branch("ZDC", "AliZDCReco", &preco, kBufferSize);
8309c1ab 458
459 // write the output tree
70f04f6d 460 clustersTree->Fill();
8309c1ab 461}
462
463//_____________________________________________________________________________
70f04f6d 464void AliZDCReconstructor::FillZDCintoESD(TTree *clustersTree, AliESDEvent* esd) const
8309c1ab 465{
70f04f6d 466 // fill energies and number of participants to the ESD
8309c1ab 467
8309c1ab 468 AliZDCReco reco;
469 AliZDCReco* preco = &reco;
70f04f6d 470 clustersTree->SetBranchAddress("ZDC", &preco);
8309c1ab 471
70f04f6d 472 clustersTree->GetEntry(0);
84d6255e 473 //
a85132e7 474 AliESDZDC * esdzdc = esd->GetESDZDC();
475 Float_t tZN1Ene[5], tZN2Ene[5], tZP1Ene[5], tZP2Ene[5];
476 Float_t tZN1EneLR[5], tZN2EneLR[5], tZP1EneLR[5], tZP2EneLR[5];
477 for(Int_t i=0; i<5; i++){
c35ed519 478 tZN1Ene[i] = reco.GetZN1HREnTow(i);
479 tZN2Ene[i] = reco.GetZN2HREnTow(i);
480 tZP1Ene[i] = reco.GetZP1HREnTow(i);
481 tZP2Ene[i] = reco.GetZP2HREnTow(i);
482 //
483 tZN1EneLR[i] = reco.GetZN1LREnTow(i);
484 tZN2EneLR[i] = reco.GetZN2LREnTow(i);
485 tZP1EneLR[i] = reco.GetZP1LREnTow(i);
486 tZP2EneLR[i] = reco.GetZP2LREnTow(i);
e90a5fef 487 }
a85132e7 488 esdzdc->SetZN1TowerEnergy(tZN1Ene);
489 esdzdc->SetZN2TowerEnergy(tZN2Ene);
490 esdzdc->SetZP1TowerEnergy(tZP1Ene);
491 esdzdc->SetZP2TowerEnergy(tZP2Ene);
492 esdzdc->SetZN1TowerEnergyLR(tZN1EneLR);
493 esdzdc->SetZN2TowerEnergyLR(tZN2EneLR);
494 esdzdc->SetZP1TowerEnergyLR(tZP1EneLR);
495 esdzdc->SetZP2TowerEnergyLR(tZP2EneLR);
496 //
c35ed519 497 esd->SetZDC(reco.GetZN1HREnergy(), reco.GetZP1HREnergy(), reco.GetZEM1HRsignal(),
498 reco.GetZEM2HRsignal(), reco.GetZN2HREnergy(), reco.GetZP2HREnergy(),
646f1679 499 reco.GetNPartLeft());
a85132e7 500 //
a4cab348 501
8309c1ab 502}
48642b09 503
504//_____________________________________________________________________________
78d18275 505AliCDBStorage* AliZDCReconstructor::SetStorage(const char *uri)
48642b09 506{
cc2abffd 507 // Setting the storage
48642b09 508
78d18275 509 Bool_t deleteManager = kFALSE;
48642b09 510
78d18275 511 AliCDBManager *manager = AliCDBManager::Instance();
512 AliCDBStorage *defstorage = manager->GetDefaultStorage();
48642b09 513
78d18275 514 if(!defstorage || !(defstorage->Contains("ZDC"))){
515 AliWarning("No default storage set or default storage doesn't contain ZDC!");
516 manager->SetDefaultStorage(uri);
517 deleteManager = kTRUE;
518 }
519
520 AliCDBStorage *storage = manager->GetDefaultStorage();
521
522 if(deleteManager){
523 AliCDBManager::Instance()->UnsetDefaultStorage();
524 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
525 }
526
527 return storage;
528}
48642b09 529
78d18275 530//_____________________________________________________________________________
6024ec85 531AliZDCPedestals* AliZDCReconstructor::GetPedData() const
532{
533
534 // Getting pedestal calibration object for ZDC set
535
536 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Pedestals");
537 if(!entry) AliFatal("No calibration data loaded!");
538
539 AliZDCPedestals *calibdata = dynamic_cast<AliZDCPedestals*> (entry->GetObject());
540 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
541
542 return calibdata;
543}
544
545//_____________________________________________________________________________
546AliZDCCalib* AliZDCReconstructor::GetECalibData() const
547{
548
549 // Getting energy and equalization calibration object for ZDC set
550
551 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Calib");
552 if(!entry) AliFatal("No calibration data loaded!");
553
554 AliZDCCalib *calibdata = dynamic_cast<AliZDCCalib*> (entry->GetObject());
555 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
556
557 return calibdata;
558}
559
560//_____________________________________________________________________________
561AliZDCRecParam* AliZDCReconstructor::GetRecParams() const
78d18275 562{
48642b09 563
6024ec85 564 // Getting energy and equalization calibration object for ZDC set
4fda3ba1 565
6024ec85 566 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/RecParam");
457a440d 567 if(!entry) AliFatal("No calibration data loaded!");
4fda3ba1 568
6024ec85 569 AliZDCRecParam *calibdata = dynamic_cast<AliZDCRecParam*> (entry->GetObject());
457a440d 570 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
48642b09 571
78d18275 572 return calibdata;
48642b09 573}