adding default configuration object for SampleCalibration component
[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// //
73bc3a3f 20// ************** Class for ZDC reconstruction ************** //
21// Author: Chiara.Oppedisano@to.infn.it //
22// //
23// NOTATIONS ADOPTED TO IDENTIFY DETECTORS (used in different ages!): //
24// (ZN1,ZP1) or (ZNC, ZPC) or RIGHT refers to side C (RB26) //
25// (ZN2,ZP2) or (ZNA, ZPA) or LEFT refers to side A (RB24) //
f5d41205 26// //
27///////////////////////////////////////////////////////////////////////////////
28
29
73bc3a3f 30#include <TH2F.h>
31#include <TH1D.h>
32#include <TAxis.h>
fd9afd60 33#include <TMap.h>
f5d41205 34
f5d41205 35#include "AliRawReader.h"
36#include "AliESDEvent.h"
a85132e7 37#include "AliESDZDC.h"
f5d41205 38#include "AliZDCDigit.h"
39#include "AliZDCRawStream.h"
40#include "AliZDCReco.h"
41#include "AliZDCReconstructor.h"
6024ec85 42#include "AliZDCPedestals.h"
73bc3a3f 43#include "AliZDCEnCalib.h"
44#include "AliZDCTowerCalib.h"
0d579f58 45#include "AliZDCMBCalib.h"
7bff3766 46#include "AliZDCRecoParam.h"
47#include "AliZDCRecoParampp.h"
48#include "AliZDCRecoParamPbPb.h"
4a72fbdb 49#include "AliRunInfo.h"
f5d41205 50
51
52ClassImp(AliZDCReconstructor)
90936733 53AliZDCRecoParam *AliZDCReconstructor::fgRecoParam=0; //reconstruction parameters
54AliZDCMBCalib *AliZDCReconstructor::fgMBCalibData=0; //calibration parameters for A-A reconstruction
f5d41205 55
56//_____________________________________________________________________________
57AliZDCReconstructor:: AliZDCReconstructor() :
1e319f71 58 fPedData(GetPedestalData()),
59 fEnCalibData(GetEnergyCalibData()),
60 fTowCalibData(GetTowerCalibData()),
fd9afd60 61 fRecoMode(0),
42d8b8d5 62 fBeamEnergy(0.),
73bc3a3f 63 fNRun(0),
64 fIsCalibrationMB(kFALSE),
65 fPedSubMode(0),
12434381 66 fSignalThreshold(7)
f5d41205 67{
68 // **** Default constructor
f5d41205 69}
70
71
72//_____________________________________________________________________________
73AliZDCReconstructor::~AliZDCReconstructor()
74{
75// destructor
90936733 76// if(fgRecoParam) delete fgRecoParam;
73bc3a3f 77 if(fPedData) delete fPedData;
78 if(fEnCalibData) delete fEnCalibData;
79 if(fTowCalibData) delete fTowCalibData;
90936733 80 if(fgMBCalibData) delete fgMBCalibData;
f5d41205 81}
82
fd9afd60 83//____________________________________________________________________________
73bc3a3f 84void AliZDCReconstructor::Init()
fd9afd60 85{
86 // Setting reconstruction mode
73bc3a3f 87 // Getting beam type and beam energy from GRP calibration object
88
4a72fbdb 89 TString runType = GetRunInfo()->GetRunType();
4a72fbdb 90 if((runType.CompareTo("CALIBRATION_MB")) == 0){
91 fIsCalibrationMB = kTRUE;
92 }
73bc3a3f 93
4a72fbdb 94 TString beamType = GetRunInfo()->GetBeamType();
95 // This is a temporary solution to allow reconstruction in tests without beam
55d9b744 96 if(((beamType.CompareTo("UNKNOWN"))==0) &&
97 ((runType.CompareTo("PHYSICS"))==0 || (runType.CompareTo("CALIBRATION_BC"))==0)){
4a72fbdb 98 fRecoMode=1;
99 }
81f09162 100 /*else if((beamType.CompareTo("UNKNOWN"))==0){
101 AliError("\t UNKNOWN beam type\n");
4a72fbdb 102 return;
81f09162 103 }*/
4a72fbdb 104
105 if(((beamType.CompareTo("pp"))==0) || ((beamType.CompareTo("p-p"))==0)
81f09162 106 ||((beamType.CompareTo("PP"))==0) || ((beamType.CompareTo("P-P"))==0)){
107 fRecoMode=1;
108 }
2d9c70ab 109 else if((beamType.CompareTo("A-A")) == 0 || (beamType.CompareTo("AA")) == 0){
4a72fbdb 110 fRecoMode=2;
fd9afd60 111 }
4a72fbdb 112
113 fBeamEnergy = GetRunInfo()->GetBeamEnergy();
90936733 114 if(fBeamEnergy<0.01) AliWarning(" Beam energy value missing -> E_beam = 0");
4a72fbdb 115
116 if(fIsCalibrationMB==kFALSE)
2d9c70ab 117 printf("\n\n ***** ZDC reconstruction initialized for %s @ %1.0f + %1.0f GeV *****\n\n",
118 beamType.Data(), fBeamEnergy, fBeamEnergy);
fd9afd60 119
fd9afd60 120}
121
f5d41205 122//_____________________________________________________________________________
1e319f71 123void AliZDCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
f5d41205 124{
125 // *** Local ZDC reconstruction for digits
126 // Works on the current event
127
128 // Retrieving calibration data
42d8b8d5 129 // Parameters for mean value pedestal subtraction
73bc3a3f 130 int const kNch = 24;
131 Float_t meanPed[2*kNch];
132 for(Int_t jj=0; jj<2*kNch; jj++) meanPed[jj] = fPedData->GetMeanPed(jj);
42d8b8d5 133 // Parameters pedestal subtraction through correlation with out-of-time signals
73bc3a3f 134 Float_t corrCoeff0[2*kNch], corrCoeff1[2*kNch];
135 for(Int_t jj=0; jj<2*kNch; jj++){
81f09162 136 corrCoeff0[jj] = fPedData->GetPedCorrCoeff0(jj);
137 corrCoeff1[jj] = fPedData->GetPedCorrCoeff1(jj);
42d8b8d5 138 }
f5d41205 139
140 // get digits
141 AliZDCDigit digit;
142 AliZDCDigit* pdigit = &digit;
143 digitsTree->SetBranchAddress("ZDC", &pdigit);
c35ed519 144 //printf("\n\t # of digits in tree: %d\n",(Int_t) digitsTree->GetEntries());
f5d41205 145
146 // loop over digits
c35ed519 147 Float_t tZN1Corr[10], tZP1Corr[10], tZN2Corr[10], tZP2Corr[10];
73bc3a3f 148 Float_t dZEM1Corr[2], dZEM2Corr[2], sPMRef1[2], sPMRef2[2];
c35ed519 149 for(Int_t i=0; i<10; i++){
150 tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
73bc3a3f 151 if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = sPMRef1[i] = sPMRef2[i] = 0.;
c35ed519 152 }
42d8b8d5 153
154 Int_t digNentries = digitsTree->GetEntries();
796c8b58 155 Float_t ootDigi[kNch]; Int_t i=0;
42d8b8d5 156 // -- Reading out-of-time signals (last kNch entries) for current event
157 if(fPedSubMode==1){
158 for(Int_t iDigit=kNch; iDigit<digNentries; iDigit++){
796c8b58 159 if(i<=kNch) ootDigi[i] = digitsTree->GetEntry(iDigit);
160 else AliWarning(" Can't read more out of time values: index>kNch !!!\n");
161 i++;
42d8b8d5 162 }
163 }
164
165 for(Int_t iDigit=0; iDigit<(digNentries/2); iDigit++) {
a85132e7 166 digitsTree->GetEntry(iDigit);
167 if (!pdigit) continue;
a85132e7 168 //
169 Int_t det = digit.GetSector(0);
170 Int_t quad = digit.GetSector(1);
42d8b8d5 171 Int_t pedindex = -1;
172 Float_t ped2SubHg=0., ped2SubLg=0.;
173 if(quad!=5){
174 if(det==1) pedindex = quad;
175 else if(det==2) pedindex = quad+5;
176 else if(det==3) pedindex = quad+9;
177 else if(det==4) pedindex = quad+12;
178 else if(det==5) pedindex = quad+17;
179 }
180 else pedindex = (det-1)/3+22;
a85132e7 181 //
42d8b8d5 182 if(fPedSubMode==0){
183 ped2SubHg = meanPed[pedindex];
184 ped2SubLg = meanPed[pedindex+kNch];
185 }
186 else if(fPedSubMode==1){
187 ped2SubHg = corrCoeff1[pedindex]*ootDigi[pedindex]+corrCoeff0[pedindex];
188 ped2SubLg = corrCoeff1[pedindex+kNch]*ootDigi[pedindex+kNch]+corrCoeff0[pedindex+kNch];
189 }
42d8b8d5 190
a85132e7 191 if(quad != 5){ // ZDC (not reference PTMs!)
c35ed519 192 if(det == 1){ // *** ZNC
42d8b8d5 193 tZN1Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
194 tZN1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
c35ed519 195 if(tZN1Corr[quad]<0.) tZN1Corr[quad] = 0.;
58dd32ca 196 if(tZN1Corr[quad+5]<0.) tZN1Corr[quad+5] = 0.;
f5d41205 197 }
198 else if(det == 2){ // *** ZP1
42d8b8d5 199 tZP1Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
42d8b8d5 200 tZP1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
73bc3a3f 201 if(tZP1Corr[quad]<0.) tZP1Corr[quad] = 0.;
58dd32ca 202 if(tZP1Corr[quad+5]<0.) tZP1Corr[quad+5] = 0.;
f5d41205 203 }
204 else if(det == 3){
205 if(quad == 1){ // *** ZEM1
42d8b8d5 206 dZEM1Corr[0] += (Float_t) (digit.GetADCValue(0)-ped2SubHg);
42d8b8d5 207 dZEM1Corr[1] += (Float_t) (digit.GetADCValue(1)-ped2SubLg);
73bc3a3f 208 if(dZEM1Corr[0]<0.) dZEM1Corr[0] = 0.;
c35ed519 209 if(dZEM1Corr[1]<0.) dZEM1Corr[1] = 0.;
f5d41205 210 }
a85132e7 211 else if(quad == 2){ // *** ZEM2
42d8b8d5 212 dZEM2Corr[0] += (Float_t) (digit.GetADCValue(0)-ped2SubHg);
42d8b8d5 213 dZEM2Corr[1] += (Float_t) (digit.GetADCValue(1)-ped2SubLg);
73bc3a3f 214 if(dZEM2Corr[0]<0.) dZEM2Corr[0] = 0.;
c35ed519 215 if(dZEM2Corr[1]<0.) dZEM2Corr[1] = 0.;
f5d41205 216 }
217 }
218 else if(det == 4){ // *** ZN2
42d8b8d5 219 tZN2Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
42d8b8d5 220 tZN2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
73bc3a3f 221 if(tZN2Corr[quad]<0.) tZN2Corr[quad] = 0.;
c35ed519 222 if(tZN2Corr[quad+5]<0.) tZN2Corr[quad+5] = 0.;
59a953e0 223 }
f5d41205 224 else if(det == 5){ // *** ZP2
42d8b8d5 225 tZP2Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
42d8b8d5 226 tZP2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
73bc3a3f 227 if(tZP2Corr[quad]<0.) tZP2Corr[quad] = 0.;
c35ed519 228 if(tZP2Corr[quad+5]<0.) tZP2Corr[quad+5] = 0.;
f5d41205 229 }
a85132e7 230 }
c35ed519 231 else{ // Reference PMs
c35ed519 232 if(det == 1){
73bc3a3f 233 sPMRef1[0] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
234 sPMRef1[1] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
235 // Ch. debug
236 if(sPMRef1[0]<0.) sPMRef1[0] = 0.;
237 if(sPMRef2[1]<0.) sPMRef1[1] = 0.;
c35ed519 238 }
239 else if(det == 4){
73bc3a3f 240 sPMRef2[0] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
241 sPMRef2[1] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
242 // Ch. debug
243 if(sPMRef2[0]<0.) sPMRef2[0] = 0.;
244 if(sPMRef2[1]<0.) sPMRef2[1] = 0.;
c35ed519 245 }
246 }
f5d41205 247
73bc3a3f 248 // Ch. debug
59a953e0 249 /*printf("AliZDCReconstructor: digit #%d det %d quad %d pedHG %1.0f pedLG %1.0f\n",
73bc3a3f 250 iDigit, det, quad, ped2SubHg, ped2SubLg);
59a953e0 251 printf(" -> pedindex %d\n", pedindex);
252 printf(" HGChain -> RawDig %d DigCorr %1.2f",
253 digit.GetADCValue(0), digit.GetADCValue(0)-ped2SubHg);
254 printf(" LGChain -> RawDig %d DigCorr %1.2f\n",
255 digit.GetADCValue(1), digit.GetADCValue(1)-ped2SubLg);*/
256
73bc3a3f 257 }//digits loop
58671297 258
81f09162 259 UInt_t counts[32];
260 for(Int_t jj=0; jj<32; jj++) counts[jj]=0;
261
262 Int_t evQualityBlock[4] = {1,0,0,0};
263 Int_t triggerBlock[4] = {0,0,0,0};
264 Int_t chBlock[3] = {0,0,0};
265 UInt_t puBits=0;
73bc3a3f 266
69550cf5 267 // reconstruct the event
73bc3a3f 268 if(fRecoMode==1)
fd9afd60 269 ReconstructEventpp(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
81f09162 270 dZEM1Corr, dZEM2Corr, sPMRef1, sPMRef2,
271 kFALSE, counts,
272 evQualityBlock, triggerBlock, chBlock, puBits);
73bc3a3f 273 else if(fRecoMode==2)
fd9afd60 274 ReconstructEventPbPb(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
81f09162 275 dZEM1Corr, dZEM2Corr, sPMRef1, sPMRef2,
276 kFALSE, counts,
91debfd4 277 evQualityBlock, triggerBlock, chBlock, puBits);
f5d41205 278}
279
280//_____________________________________________________________________________
1e319f71 281void AliZDCReconstructor::Reconstruct(AliRawReader* rawReader, TTree* clustersTree) const
f5d41205 282{
283 // *** ZDC raw data reconstruction
284 // Works on the current event
285
286 // Retrieving calibration data
73bc3a3f 287 // Parameters for pedestal subtraction
288 int const kNch = 24;
289 Float_t meanPed[2*kNch];
290 for(Int_t jj=0; jj<2*kNch; jj++) meanPed[jj] = fPedData->GetMeanPed(jj);
42d8b8d5 291 // Parameters pedestal subtraction through correlation with out-of-time signals
73bc3a3f 292 Float_t corrCoeff0[2*kNch], corrCoeff1[2*kNch];
293 for(Int_t jj=0; jj<2*kNch; jj++){
42d8b8d5 294 corrCoeff0[jj] = fPedData->GetPedCorrCoeff0(jj);
295 corrCoeff1[jj] = fPedData->GetPedCorrCoeff1(jj);
296 }
f5d41205 297
73bc3a3f 298 Int_t adcZN1[5], adcZN1oot[5], adcZN1lg[5], adcZN1ootlg[5];
299 Int_t adcZP1[5], adcZP1oot[5], adcZP1lg[5], adcZP1ootlg[5];
300 Int_t adcZN2[5], adcZN2oot[5], adcZN2lg[5], adcZN2ootlg[5];
301 Int_t adcZP2[5], adcZP2oot[5], adcZP2lg[5], adcZP2ootlg[5];
302 Int_t adcZEM[2], adcZEMoot[2], adcZEMlg[2], adcZEMootlg[2];
303 Int_t pmRef[2], pmRefoot[2], pmReflg[2], pmRefootlg[2];
304 for(Int_t ich=0; ich<5; ich++){
305 adcZN1[ich] = adcZN1oot[ich] = adcZN1lg[ich] = adcZN1ootlg[ich] = 0;
306 adcZP1[ich] = adcZP1oot[ich] = adcZP1lg[ich] = adcZP1ootlg[ich] = 0;
307 adcZN2[ich] = adcZN2oot[ich] = adcZN2lg[ich] = adcZN2ootlg[ich] = 0;
308 adcZP2[ich] = adcZP2oot[ich] = adcZP2lg[ich] = adcZP2ootlg[ich] = 0;
309 if(ich<2){
310 adcZEM[ich] = adcZEMoot[ich] = adcZEMlg[ich] = adcZEMootlg[ich] = 0;
311 pmRef[ich] = pmRefoot[ich] = pmReflg[ich] = pmRefootlg[ich] = 0;
312 }
313 }
7bff3766 314
c35ed519 315 Float_t tZN1Corr[10], tZP1Corr[10], tZN2Corr[10], tZP2Corr[10];
73bc3a3f 316 Float_t dZEM1Corr[2], dZEM2Corr[2], sPMRef1[2], sPMRef2[2];
c35ed519 317 for(Int_t i=0; i<10; i++){
318 tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
73bc3a3f 319 if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = sPMRef1[i] = sPMRef2[i] = 0.;
c35ed519 320 }
1e319f71 321
81f09162 322 Bool_t isScalerOn=kFALSE;
323 Int_t jsc=0;
324 UInt_t scalerData[32];
325 for(Int_t k=0; k<32; k++) scalerData[k]=0;
326
327 Int_t evQualityBlock[4] = {1,0,0,0};
328 Int_t triggerBlock[4] = {0,0,0,0};
329 Int_t chBlock[3] = {0,0,0};
330 UInt_t puBits=0;
331
1e319f71 332 //fNRun = (Int_t) rawReader->GetRunNumber();
81f09162 333 Int_t kFirstADCGeo=0, kLastADCGeo=3, kScalerGeo=8, kPUGeo=29;
334 //Int_t kTrigScales=30, kTrigHistory=31;
335
336 // loop over raw data
73bc3a3f 337 rawReader->Reset();
f5d41205 338 AliZDCRawStream rawData(rawReader);
73bc3a3f 339 while(rawData.Next()){
81f09162 340
341 // ***************************** Reading ADCs
f70a5526 342 if((rawData.GetADCModule()>=kFirstADCGeo) && (rawData.GetADCModule()<=kLastADCGeo)){
343 //printf(" **** Reading ADC raw data from module %d **** \n",rawData.GetADCModule());
58671297 344 //
81f09162 345 if((rawData.IsADCDataWord()) && (rawData.GetNChannelsOn()<48)) chBlock[0] = kTRUE;
346 if((rawData.IsADCDataWord()) && (rawData.IsOverflow() == kTRUE)) chBlock[1] = kTRUE;
347 if((rawData.IsADCDataWord()) && (rawData.IsUnderflow() == kTRUE)) chBlock[2] = kTRUE;
348 if((rawData.IsADCDataWord()) && (rawData.IsADCEventGood() == kTRUE)) evQualityBlock[0] = kTRUE;
f70a5526 349
81f09162 350 if((rawData.IsADCDataWord()) && (rawData.IsUnderflow()==kFALSE)
351 && (rawData.IsOverflow()==kFALSE) && (rawData.IsADCEventGood()==kTRUE)){
73bc3a3f 352
58671297 353 Int_t adcMod = rawData.GetADCModule();
354 Int_t det = rawData.GetSector(0);
355 Int_t quad = rawData.GetSector(1);
356 Int_t gain = rawData.GetADCGain();
357 Int_t pedindex=0;
358 //
359 // Mean pedestal value subtraction -------------------------------------------------------
360 if(fPedSubMode == 0){
73bc3a3f 361 // Not interested in o.o.t. signals (ADC modules 2, 3)
1e319f71 362 if(adcMod == 2 || adcMod == 3) continue;
73bc3a3f 363 //
364 if(quad != 5){ // ZDCs (not reference PTMs)
365 if(det == 1){
366 pedindex = quad;
367 if(gain == 0) tZN1Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
368 else tZN1Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 369 }
73bc3a3f 370 else if(det == 2){
371 pedindex = quad+5;
372 if(gain == 0) tZP1Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
373 else tZP1Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
374 }
375 else if(det == 3){
376 pedindex = quad+9;
377 if(quad==1){
378 if(gain == 0) dZEM1Corr[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
379 else dZEM1Corr[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
380 }
381 else if(quad==2){
382 if(gain == 0) dZEM2Corr[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
383 else dZEM2Corr[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
384 }
385 }
386 else if(det == 4){
387 pedindex = quad+12;
388 if(gain == 0) tZN2Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
389 else tZN2Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
390 }
391 else if(det == 5){
392 pedindex = quad+17;
393 if(gain == 0) tZP2Corr[quad] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
394 else tZP2Corr[quad+5] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
f5d41205 395 }
c35ed519 396 }
73bc3a3f 397 else{ // reference PM
398 pedindex = (det-1)/3 + 22;
399 if(det == 1){
400 if(gain==0) sPMRef1[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
81f09162 401 else sPMRef1[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
73bc3a3f 402 }
403 else if(det == 4){
404 if(gain==0) sPMRef2[0] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex]);
81f09162 405 else sPMRef2[1] += (Float_t) (rawData.GetADCValue()-meanPed[pedindex+kNch]);
73bc3a3f 406 }
c35ed519 407 }
73bc3a3f 408 // Ch. debug
81f09162 409 /*if(gain==0){
410 printf(" AliZDCReconstructor: det %d quad %d res %d -> Pedestal[%d] %1.0f",
411 det,quad,gain, pedindex, meanPed[pedindex]);
412 printf(" RawADC %d ADCCorr %1.0f\n",
413 rawData.GetADCValue(), rawData.GetADCValue()-meanPed[pedindex]);
414 }*/
58671297 415 }// mean pedestal subtraction
416 // Pedestal subtraction from correlation ------------------------------------------------
417 else if(fPedSubMode == 1){
73bc3a3f 418 // In time signals
419 if(adcMod==0 || adcMod==1){
420 if(quad != 5){ // signals from ZDCs
421 if(det == 1){
422 if(gain==0) adcZN1[quad] = rawData.GetADCValue();
423 else adcZN1lg[quad] = rawData.GetADCValue();
424 }
425 else if(det == 2){
426 if(gain==0) adcZP1[quad] = rawData.GetADCValue();
427 else adcZP1lg[quad] = rawData.GetADCValue();
428 }
429 else if(det == 3){
430 if(gain==0) adcZEM[quad-1] = rawData.GetADCValue();
431 else adcZEMlg[quad-1] = rawData.GetADCValue();
432 }
433 else if(det == 4){
434 if(gain==0) adcZN2[quad] = rawData.GetADCValue();
435 else adcZN2lg[quad] = rawData.GetADCValue();
436 }
437 else if(det == 5){
438 if(gain==0) adcZP2[quad] = rawData.GetADCValue();
439 else adcZP2lg[quad] = rawData.GetADCValue();
440 }
441 }
442 else{ // signals from reference PM
443 if(gain==0) pmRef[quad-1] = rawData.GetADCValue();
444 else pmReflg[quad-1] = rawData.GetADCValue();
445 }
446 }
447 // Out-of-time pedestals
448 else if(adcMod==2 || adcMod==3){
449 if(quad != 5){ // signals from ZDCs
450 if(det == 1){
451 if(gain==0) adcZN1oot[quad] = rawData.GetADCValue();
452 else adcZN1ootlg[quad] = rawData.GetADCValue();
453 }
454 else if(det == 2){
455 if(gain==0) adcZP1oot[quad] = rawData.GetADCValue();
456 else adcZP1ootlg[quad] = rawData.GetADCValue();
457 }
458 else if(det == 3){
459 if(gain==0) adcZEMoot[quad-1] = rawData.GetADCValue();
460 else adcZEMootlg[quad-1] = rawData.GetADCValue();
461 }
462 else if(det == 4){
463 if(gain==0) adcZN2oot[quad] = rawData.GetADCValue();
464 else adcZN2ootlg[quad] = rawData.GetADCValue();
465 }
466 else if(det == 5){
467 if(gain==0) adcZP2oot[quad] = rawData.GetADCValue();
468 else adcZP2ootlg[quad] = rawData.GetADCValue();
469 }
470 }
471 else{ // signals from reference PM
472 if(gain==0) pmRefoot[quad-1] = rawData.GetADCValue();
473 else pmRefootlg[quad-1] = rawData.GetADCValue();
474 }
475 }
58671297 476 } // pedestal subtraction from correlation
477 // Ch. debug
59a953e0 478 /*printf("\t AliZDCReconstructor: det %d quad %d res %d -> Ped[%d] = %1.0f\n",
479 det,quad,gain, pedindex, meanPed[pedindex]);*/
58671297 480 }//IsADCDataWord
81f09162 481 }// ADC DATA
482 // ***************************** Reading Scaler
483 else if(rawData.GetADCModule()==kScalerGeo){
ad3a602e 484 if(rawData.IsScalerWord()==kTRUE && rawData.IsScEventGood()==kTRUE){
81f09162 485 isScalerOn = kTRUE;
486 scalerData[jsc] = rawData.GetTriggerCount();
ad3a602e 487 // Ch. debug
488 //printf(" Reconstructed VME Scaler: %d %d ",jsc,scalerData[jsc]);
489 //
81f09162 490 jsc++;
491 }
492 }// VME SCALER DATA
493 // ***************************** Reading PU
494 else if(rawData.GetADCModule()==kPUGeo){
495 puBits = rawData.GetDetectorPattern();
58671297 496 }
81f09162 497 // ***************************** Reading trigger history
498 else if(rawData.IstriggerHistoryWord()==kTRUE){
499 triggerBlock[0] = rawData.IsCPTInputEMDTrigger();
500 triggerBlock[1] = rawData.IsCPTInputSemiCentralTrigger();
501 triggerBlock[2] = rawData.IsCPTInputCentralTrigger();
502 triggerBlock[3] = rawData.IsCPTInputMBTrigger();
503 }
504
73bc3a3f 505 }//loop on raw data
506
507 if(fPedSubMode==1){
508 for(Int_t t=0; t<5; t++){
509 tZN1Corr[t] = adcZN1[t] - (corrCoeff1[t]*adcZN1oot[t]+corrCoeff0[t]);
510 tZN1Corr[t+5] = adcZN1lg[t] - (corrCoeff1[t+kNch]*adcZN1ootlg[t]+corrCoeff0[t+kNch]);
511 //
512 tZP1Corr[t] = adcZP1[t] - (corrCoeff1[t+5]*adcZP1oot[t]+corrCoeff0[t+5]);
513 tZP1Corr[t+5] = adcZP1lg[t] - (corrCoeff1[t+5+kNch]*adcZP1ootlg[t]+corrCoeff0[t+5+kNch]);
514 //
515 tZN2Corr[t] = adcZN2[t] - (corrCoeff1[t+12]*adcZN2oot[t]+corrCoeff0[t+12]);
516 tZN2Corr[t+5] = adcZN2lg[t] - (corrCoeff1[t+12+kNch]*adcZN2ootlg[t]+corrCoeff0[t+12+kNch]);
517 //
518 tZP2Corr[t] = adcZP2[t] - (corrCoeff1[t+17]*adcZP2oot[t]+corrCoeff0[t+17]);
519 tZP2Corr[t+5] = adcZP2lg[t] - (corrCoeff1[t+17+kNch]*adcZP2ootlg[t]+corrCoeff0[t+17+kNch]);
520 // 0---------0 Ch. debug 0---------0
521/* printf("\n\n ---------- Debug of pedestal subtraction from correlation ----------\n");
522 printf("\tCorrCoeff0\tCorrCoeff1\n");
523 printf(" ZN1 %d\t%1.0f\t%1.0f\n",t,corrCoeff0[t],corrCoeff1[t]);
524 printf(" ZN1lg %d\t%1.0f\t%1.0f\n",t+kNch,corrCoeff0[t+kNch],corrCoeff1[t+kNch]);
525 printf(" ZP1 %d\t%1.0f\t%1.0f\n",t+5,corrCoeff0[t+5],corrCoeff1[t+5]);
526 printf(" ZP1lg %d\t%1.0f\t%1.0f\n",t+5+kNch,corrCoeff0[t+5+kNch],corrCoeff1[t+5+kNch]);
527 printf(" ZN2 %d\t%1.0f\t%1.0f\n",t+12,corrCoeff0[t+12],corrCoeff1[t+12]);
528 printf(" ZN2lg %d\t%1.0f\t%1.0f\n",t+12+kNch,corrCoeff0[t+12+kNch],corrCoeff1[t+12+kNch]);
529 printf(" ZP2 %d\t%1.0f\t%1.0f\n",t+17,corrCoeff0[t+17],corrCoeff1[t+17]);
530 printf(" ZP2lg %d\t%1.0f\t%1.0f\n",t+17+kNch,corrCoeff0[t+17+kNch],corrCoeff1[t+17+kNch]);
531
532 printf("ZN1 -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
533 adcZN1[t],(corrCoeff1[t]*adcZN1oot[t]+corrCoeff0[t]),tZN1Corr[t]);
534 printf(" lg -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
535 adcZN1lg[t],(corrCoeff1[t+kNch]*adcZN1ootlg[t]+corrCoeff0[t+kNch]),tZN1Corr[t+5]);
536 //
537 printf("ZP1 -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
538 adcZP1[t],(corrCoeff1[t+5]*adcZP1oot[t]+corrCoeff0[t+5]),tZP1Corr[t]);
539 printf(" lg -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
540 adcZP1lg[t],(corrCoeff1[t+5+kNch]*adcZP1ootlg[t]+corrCoeff0[t+5+kNch]),tZP1Corr[t+5]);
541 //
542 printf("ZN2 -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
543 adcZN2[t],(corrCoeff1[t+12]*adcZN2oot[t]+corrCoeff0[t+12]),tZN2Corr[t]);
544 printf(" lg -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
545 adcZN2lg[t],(corrCoeff1[t+12+kNch]*adcZN2ootlg[t]+corrCoeff0[t+12+kNch]),tZN2Corr[t+5]);
546 //
547 printf("ZP2 -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
548 adcZP2[t],(corrCoeff1[t+17]*adcZP2oot[t]+corrCoeff0[t+17]),tZP2Corr[t]);
549 printf(" lg -> rawADC %d\tpedestal%1.2f\tcorrADC%1.2f\n",
550 adcZP2lg[t],(corrCoeff1[t+17+kNch]*adcZP2ootlg[t]+corrCoeff0[t+17+kNch]),tZP2Corr[t+5]);
551*/
552 }
553 dZEM1Corr[0] = adcZEM[0] - (corrCoeff1[9]*adcZEMoot[0]+corrCoeff0[9]);
554 dZEM1Corr[1] = adcZEMlg[0] - (corrCoeff1[9+kNch]*adcZEMootlg[0]+corrCoeff0[9+kNch]);
555 dZEM2Corr[0] = adcZEM[1] - (corrCoeff1[10]*adcZEMoot[1]+corrCoeff0[10]);
556 dZEM2Corr[1] = adcZEMlg[1] - (corrCoeff1[10+kNch]*adcZEMootlg[1]+corrCoeff0[10+kNch]);
557 //
558 sPMRef1[0] = pmRef[0] - (corrCoeff1[22]*pmRefoot[0]+corrCoeff0[22]);
559 sPMRef1[1] = pmReflg[0] - (corrCoeff1[22+kNch]*pmRefootlg[0]+corrCoeff0[22+kNch]);
560 sPMRef2[0] = pmRef[0] - (corrCoeff1[23]*pmRefoot[1]+corrCoeff0[23]);
561 sPMRef2[1] = pmReflg[0] - (corrCoeff1[23+kNch]*pmRefootlg[1]+corrCoeff0[23+kNch]);
f5d41205 562 }
563
81f09162 564 if(fRecoMode==1) // p-p data
565 ReconstructEventpp(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
566 dZEM1Corr, dZEM2Corr, sPMRef1, sPMRef2,
567 isScalerOn, scalerData,
568 evQualityBlock, triggerBlock, chBlock, puBits);
569 else if(fRecoMode==2) // Pb-Pb data
91debfd4 570 ReconstructEventPbPb(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
81f09162 571 dZEM1Corr, dZEM2Corr, sPMRef1, sPMRef2,
572 isScalerOn, scalerData,
573 evQualityBlock, triggerBlock, chBlock, puBits);
f5d41205 574}
575
576//_____________________________________________________________________________
90936733 577void AliZDCReconstructor::ReconstructEventpp(TTree *clustersTree,
578 const Float_t* const corrADCZN1, const Float_t* const corrADCZP1,
579 const Float_t* const corrADCZN2, const Float_t* const corrADCZP2,
580 const Float_t* const corrADCZEM1, const Float_t* const corrADCZEM2,
581 Float_t* sPMRef1, Float_t* sPMRef2, Bool_t isScalerOn, UInt_t* scaler,
582 const Int_t* const evQualityBlock, const Int_t* const triggerBlock,
583 const Int_t* const chBlock, UInt_t puBits) const
f5d41205 584{
73bc3a3f 585 // ****************** Reconstruct one event ******************
59a953e0 586
587 // CH. debug
588 /*printf("\n*************************************************\n");
589 printf(" ReconstructEventpp -> values after pedestal subtraction:\n");
590 printf(" ADCZN1 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
591 corrADCZN1[0],corrADCZN1[1],corrADCZN1[2],corrADCZN1[3],corrADCZN1[4]);
592 printf(" ADCZP1 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
593 corrADCZP1[0],corrADCZP1[1],corrADCZP1[2],corrADCZP1[3],corrADCZP1[4]);
594 printf(" ADCZN2 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
595 corrADCZN2[0],corrADCZN2[1],corrADCZN2[2],corrADCZN2[3],corrADCZN2[4]);
596 printf(" ADCZP2 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
597 corrADCZP2[0],corrADCZP2[1],corrADCZP2[2],corrADCZP2[3],corrADCZP2[4]);
598 printf(" ADCZEM1 [%1.2f] ADCZEM2 [%1.2f] \n",corrADCZEM1[0],corrADCZEM2[0]);
599 printf("*************************************************\n");*/
1e319f71 600
81f09162 601 // ---------------------- Setting reco flags for ESD
6b793021 602 UInt_t rFlags[32];
603 for(Int_t ifl=0; ifl<32; ifl++) rFlags[ifl]=0;
81f09162 604
605 if(evQualityBlock[0] == 1) rFlags[31] = 0x0;
606 else rFlags[31] = 0x1;
1e319f71 607 //
81f09162 608 if(evQualityBlock[1] == 1) rFlags[30] = 0x1;
609 if(evQualityBlock[2] == 1) rFlags[29] = 0x1;
610 if(evQualityBlock[3] == 1) rFlags[28] = 0x1;
611
612 if(triggerBlock[0] == 1) rFlags[27] = 0x1;
613 if(triggerBlock[1] == 1) rFlags[26] = 0x1;
614 if(triggerBlock[2] == 1) rFlags[25] = 0x1;
615 if(triggerBlock[3] == 1) rFlags[24] = 0x1;
616
617 if(chBlock[0] == 1) rFlags[18] = 0x1;
618 if(chBlock[1] == 1) rFlags[17] = 0x1;
619 if(chBlock[2] == 1) rFlags[16] = 0x1;
620
621
622 rFlags[13] = puBits & 0x00000020;
623 rFlags[12] = puBits & 0x00000010;
624 rFlags[11] = puBits & 0x00000080;
625 rFlags[10] = puBits & 0x00000040;
626 rFlags[9] = puBits & 0x00000020;
627 rFlags[8] = puBits & 0x00000010;
628
629 if(corrADCZP1[0]>fSignalThreshold) rFlags[5] = 0x1;
630 if(corrADCZN1[0]>fSignalThreshold) rFlags[4] = 0x1;
631 if(corrADCZEM2[0]>fSignalThreshold) rFlags[3] = 0x1;
632 if(corrADCZEM1[0]>fSignalThreshold) rFlags[2] = 0x1;
633 if(corrADCZP2[0]>fSignalThreshold) rFlags[1] = 0x1;
634 if(corrADCZN2[0]>fSignalThreshold) rFlags[0] = 0x1;
635
636 UInt_t recoFlag = rFlags[31] << 31 | rFlags[30] << 30 | rFlags[29] << 29 | rFlags[28] << 28 |
637 rFlags[27] << 27 | rFlags[26] << 26 | rFlags[25] << 25 | rFlags[24] << 24 |
638 0x0 << 23 | 0x0 << 22 | 0x0 << 21 | 0x0 << 20 |
639 0x0 << 19 | rFlags[18] << 18 | rFlags[17] << 17 | rFlags[16] << 16 |
640 0x0 << 15 | 0x0 << 14 | rFlags[13] << 13 | rFlags[12] << 12 |
641 rFlags[11] << 11 |rFlags[10] << 10 | rFlags[9] << 9 | rFlags[8] << 8 |
642 0x0 << 7 | 0x0 << 6 | rFlags[5] << 5 | rFlags[4] << 4 |
643 rFlags[3] << 3 | rFlags[2] << 2 | rFlags[1] << 1 | rFlags[0];
644 // --------------------------------------------------
1e319f71 645
73bc3a3f 646 // ****** Retrieving calibration data
84d6255e 647 // --- Equalization coefficients ---------------------------------------------
f5d41205 648 Float_t equalCoeffZN1[5], equalCoeffZP1[5], equalCoeffZN2[5], equalCoeffZP2[5];
649 for(Int_t ji=0; ji<5; ji++){
73bc3a3f 650 equalCoeffZN1[ji] = fTowCalibData->GetZN1EqualCoeff(ji);
651 equalCoeffZP1[ji] = fTowCalibData->GetZP1EqualCoeff(ji);
652 equalCoeffZN2[ji] = fTowCalibData->GetZN2EqualCoeff(ji);
653 equalCoeffZP2[ji] = fTowCalibData->GetZP2EqualCoeff(ji);
f5d41205 654 }
84d6255e 655 // --- Energy calibration factors ------------------------------------
796c8b58 656 Float_t calibEne[6];
42d8b8d5 657 // **** Energy calibration coefficient set to 1
658 // **** (no trivial way to calibrate in p-p runs)
76725070 659 for(Int_t ij=0; ij<6; ij++) calibEne[ij] = fEnCalibData->GetEnCalib(ij);
7bff3766 660
73bc3a3f 661 // ****** Equalization of detector responses
7bff3766 662 Float_t equalTowZN1[10], equalTowZN2[10], equalTowZP1[10], equalTowZP2[10];
73bc3a3f 663 for(Int_t gi=0; gi<10; gi++){
31474197 664 if(gi<5){
665 equalTowZN1[gi] = corrADCZN1[gi]*equalCoeffZN1[gi];
666 equalTowZP1[gi] = corrADCZP1[gi]*equalCoeffZP1[gi];
667 equalTowZN2[gi] = corrADCZN2[gi]*equalCoeffZN2[gi];
668 equalTowZP2[gi] = corrADCZP2[gi]*equalCoeffZP2[gi];
669 }
670 else{
671 equalTowZN1[gi] = corrADCZN1[gi]*equalCoeffZN1[gi-5];
672 equalTowZP1[gi] = corrADCZP1[gi]*equalCoeffZP1[gi-5];
673 equalTowZN2[gi] = corrADCZN2[gi]*equalCoeffZN2[gi-5];
674 equalTowZP2[gi] = corrADCZP2[gi]*equalCoeffZP2[gi-5];
675 }
73bc3a3f 676 }
59a953e0 677 // Ch. debug
678 /*printf("\n ------------- EQUALIZATION -------------\n");
679 printf(" ADCZN1 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
680 equalTowZN1[0],equalTowZN1[1],equalTowZN1[2],equalTowZN1[3],equalTowZN1[4]);
681 printf(" ADCZP1 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
682 equalTowZP1[0],equalTowZP1[1],equalTowZP1[2],equalTowZP1[3],equalTowZP1[4]);
683 printf(" ADCZN2 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
684 equalTowZN2[0],equalTowZN2[1],equalTowZN2[2],equalTowZN2[3],equalTowZN2[4]);
685 printf(" ADCZP2 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
686 equalTowZP2[0],equalTowZP2[1],equalTowZP2[2],equalTowZP2[3],equalTowZP2[4]);
687 printf(" ----------------------------------------\n");*/
73bc3a3f 688
689 // ****** Summed response for hadronic calorimeter (SUMMED and then CALIBRATED!)
690 Float_t calibSumZN1[]={0,0}, calibSumZN2[]={0,0}, calibSumZP1[]={0,0}, calibSumZP2[]={0,0};
7bff3766 691 for(Int_t gi=0; gi<5; gi++){
73bc3a3f 692 calibSumZN1[0] += equalTowZN1[gi];
693 calibSumZP1[0] += equalTowZP1[gi];
694 calibSumZN2[0] += equalTowZN2[gi];
695 calibSumZP2[0] += equalTowZP2[gi];
696 //
697 calibSumZN1[1] += equalTowZN1[gi+5];
698 calibSumZP1[1] += equalTowZP1[gi+5];
699 calibSumZN2[1] += equalTowZN2[gi+5];
700 calibSumZP2[1] += equalTowZP2[gi+5];
7bff3766 701 }
73bc3a3f 702 // High gain chain
59a953e0 703 calibSumZN1[0] = calibSumZN1[0]*calibEne[0];
704 calibSumZP1[0] = calibSumZP1[0]*calibEne[1];
705 calibSumZN2[0] = calibSumZN2[0]*calibEne[2];
706 calibSumZP2[0] = calibSumZP2[0]*calibEne[3];
73bc3a3f 707 // Low gain chain
708 calibSumZN1[1] = calibSumZN1[1]*calibEne[0];
709 calibSumZP1[1] = calibSumZP1[1]*calibEne[1];
710 calibSumZN2[1] = calibSumZN2[1]*calibEne[2];
711 calibSumZP2[1] = calibSumZP2[1]*calibEne[3];
7bff3766 712
73bc3a3f 713 // ****** Energy calibration of detector responses
7bff3766 714 Float_t calibTowZN1[10], calibTowZN2[10], calibTowZP1[10], calibTowZP2[10];
73bc3a3f 715 for(Int_t gi=0; gi<5; gi++){
716 // High gain chain
59a953e0 717 calibTowZN1[gi] = equalTowZN1[gi]*calibEne[0];
718 calibTowZP1[gi] = equalTowZP1[gi]*calibEne[1];
719 calibTowZN2[gi] = equalTowZN2[gi]*calibEne[2];
720 calibTowZP2[gi] = equalTowZP2[gi]*calibEne[3];
73bc3a3f 721 // Low gain chain
722 calibTowZN1[gi+5] = equalTowZN1[gi+5]*calibEne[0];
723 calibTowZP1[gi+5] = equalTowZP1[gi+5]*calibEne[1];
724 calibTowZN2[gi+5] = equalTowZN2[gi+5]*calibEne[2];
725 calibTowZP2[gi+5] = equalTowZP2[gi+5]*calibEne[3];
7bff3766 726 }
73bc3a3f 727 //
728 Float_t sumZEM[]={0,0}, calibZEM1[]={0,0}, calibZEM2[]={0,0};
c7d86465 729 calibZEM1[0] = corrADCZEM1[0]*calibEne[4];
730 calibZEM1[1] = corrADCZEM1[1]*calibEne[4];
59a953e0 731 calibZEM2[0] = corrADCZEM2[0]*calibEne[5];
73bc3a3f 732 calibZEM2[1] = corrADCZEM2[1]*calibEne[5];
733 for(Int_t k=0; k<2; k++) sumZEM[k] = calibZEM1[k] + calibZEM2[k];
59a953e0 734 // Ch. debug
735 /*printf("\n ------------- CALIBRATION -------------\n");
736 printf(" ADCZN1 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
737 calibTowZN1[0],calibTowZN1[1],calibTowZN1[2],calibTowZN1[3],calibTowZN1[4]);
738 printf(" ADCZP1 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
739 calibTowZP1[0],calibTowZP1[1],calibTowZP1[2],calibTowZP1[3],calibTowZP1[4]);
740 printf(" ADCZN2 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
741 calibTowZN2[0],calibTowZN2[1],calibTowZN2[2],calibTowZN2[3],calibTowZN2[4]);
742 printf(" ADCZP2 [%1.2f %1.2f %1.2f %1.2f %1.2f]\n",
743 calibTowZP2[0],calibTowZP2[1],calibTowZP2[2],calibTowZP2[3],calibTowZP2[4]);
744 printf(" ADCZEM1 [%1.2f] ADCZEM2 [%1.2f] \n",calibZEM1[0],calibZEM2[0]);
745 printf(" ----------------------------------------\n");*/
7bff3766 746
73bc3a3f 747 // ****** No. of spectator and participants nucleons
42d8b8d5 748 // Variables calculated to comply with ESD structure
73bc3a3f 749 // *** N.B. -> They have a meaning only in Pb-Pb!!!!!!!!!!!!
d9ec113e 750 Int_t nDetSpecNLeft=0, nDetSpecPLeft=0, nDetSpecNRight=0, nDetSpecPRight=0;
73bc3a3f 751 Int_t nGenSpec=0, nGenSpecLeft=0, nGenSpecRight=0;
752 Int_t nPart=0, nPartTotLeft=0, nPartTotRight=0;
753 Double_t impPar=0., impPar1=0., impPar2=0.;
7bff3766 754
755 // create the output tree
1e319f71 756 AliZDCReco* reco = new AliZDCReco(calibSumZN1, calibSumZP1, calibSumZN2, calibSumZP2,
757 calibTowZN1, calibTowZP1, calibTowZN2, calibTowZP2,
758 calibZEM1, calibZEM2, sPMRef1, sPMRef2,
759 nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight,
760 nGenSpec, nGenSpecLeft, nGenSpecRight,
761 nPart, nPartTotLeft, nPartTotRight,
762 impPar, impPar1, impPar2,
81f09162 763 recoFlag, isScalerOn, scaler);
7bff3766 764
1b467dea 765 const Int_t kBufferSize = 4000;
1e319f71 766 clustersTree->Branch("ZDC", "AliZDCReco", &reco, kBufferSize);
7bff3766 767 // write the output tree
768 clustersTree->Fill();
769}
770
771//_____________________________________________________________________________
73bc3a3f 772void AliZDCReconstructor::ReconstructEventPbPb(TTree *clustersTree,
90936733 773 const Float_t* const corrADCZN1, const Float_t* const corrADCZP1,
774 const Float_t* const corrADCZN2, const Float_t* const corrADCZP2,
775 const Float_t* const corrADCZEM1, const Float_t* const corrADCZEM2,
776 Float_t* sPMRef1, Float_t* sPMRef2, Bool_t isScalerOn, UInt_t* scaler,
777 const Int_t* const evQualityBlock, const Int_t* const triggerBlock,
778 const Int_t* const chBlock, UInt_t puBits) const
7bff3766 779{
73bc3a3f 780 // ****************** Reconstruct one event ******************
81f09162 781 // ---------------------- Setting reco flags for ESD
6b793021 782 UInt_t rFlags[32];
783 for(Int_t ifl=0; ifl<32; ifl++) rFlags[ifl]=0;
81f09162 784
785 if(evQualityBlock[0] == 1) rFlags[31] = 0x0;
786 else rFlags[31] = 0x1;
1e319f71 787 //
81f09162 788 if(evQualityBlock[1] == 1) rFlags[30] = 0x1;
789 if(evQualityBlock[2] == 1) rFlags[29] = 0x1;
790 if(evQualityBlock[3] == 1) rFlags[28] = 0x1;
791
792 if(triggerBlock[0] == 1) rFlags[27] = 0x1;
793 if(triggerBlock[1] == 1) rFlags[26] = 0x1;
794 if(triggerBlock[2] == 1) rFlags[25] = 0x1;
795 if(triggerBlock[3] == 1) rFlags[24] = 0x1;
796
797 if(chBlock[0] == 1) rFlags[18] = 0x1;
798 if(chBlock[1] == 1) rFlags[17] = 0x1;
799 if(chBlock[2] == 1) rFlags[16] = 0x1;
800
801 rFlags[13] = puBits & 0x00000020;
802 rFlags[12] = puBits & 0x00000010;
803 rFlags[11] = puBits & 0x00000080;
804 rFlags[10] = puBits & 0x00000040;
805 rFlags[9] = puBits & 0x00000020;
806 rFlags[8] = puBits & 0x00000010;
807
808 if(corrADCZP1[0]>fSignalThreshold) rFlags[5] = 0x1;
809 if(corrADCZN1[0]>fSignalThreshold) rFlags[4] = 0x1;
810 if(corrADCZEM2[0]>fSignalThreshold) rFlags[3] = 0x1;
811 if(corrADCZEM1[0]>fSignalThreshold) rFlags[2] = 0x1;
812 if(corrADCZP2[0]>fSignalThreshold) rFlags[1] = 0x1;
813 if(corrADCZN2[0]>fSignalThreshold) rFlags[0] = 0x1;
814
815 UInt_t recoFlag = rFlags[31] << 31 | rFlags[30] << 30 | rFlags[29] << 29 | rFlags[28] << 28 |
816 rFlags[27] << 27 | rFlags[26] << 26 | rFlags[25] << 25 | rFlags[24] << 24 |
817 0x0 << 23 | 0x0 << 22 | 0x0 << 21 | 0x0 << 20 |
818 0x0 << 19 | rFlags[18] << 18 | rFlags[17] << 17 | rFlags[16] << 16 |
819 0x0 << 15 | 0x0 << 14 | rFlags[13] << 13 | rFlags[12] << 12 |
820 rFlags[11] << 11 |rFlags[10] << 10 | rFlags[9] << 9 | rFlags[8] << 8 |
821 0x0 << 7 | 0x0 << 6 | rFlags[5] << 5 | rFlags[4] << 4 |
822 rFlags[3] << 3 | rFlags[2] << 2 | rFlags[1] << 1 | rFlags[0];
823 // --------------------------------------------------
824
73bc3a3f 825
826 // ****** Retrieving calibration data
7bff3766 827 // --- Equalization coefficients ---------------------------------------------
828 Float_t equalCoeffZN1[5], equalCoeffZP1[5], equalCoeffZN2[5], equalCoeffZP2[5];
829 for(Int_t ji=0; ji<5; ji++){
73bc3a3f 830 equalCoeffZN1[ji] = fTowCalibData->GetZN1EqualCoeff(ji);
831 equalCoeffZP1[ji] = fTowCalibData->GetZP1EqualCoeff(ji);
832 equalCoeffZN2[ji] = fTowCalibData->GetZN2EqualCoeff(ji);
833 equalCoeffZP2[ji] = fTowCalibData->GetZP2EqualCoeff(ji);
7bff3766 834 }
835 // --- Energy calibration factors ------------------------------------
73bc3a3f 836 Float_t valFromOCDB[6], calibEne[6];
837 for(Int_t ij=0; ij<6; ij++){
838 valFromOCDB[ij] = fEnCalibData->GetEnCalib(ij);
839 if(ij<4){
840 if(valFromOCDB[ij]!=0) calibEne[ij] = fBeamEnergy/valFromOCDB[ij];
841 else AliWarning(" Value from OCDB for E calibration = 0 !!!\n");
842 }
843 else calibEne[ij] = valFromOCDB[ij];
844 }
f5d41205 845
73bc3a3f 846 // ****** Equalization of detector responses
c35ed519 847 Float_t equalTowZN1[10], equalTowZN2[10], equalTowZP1[10], equalTowZP2[10];
73bc3a3f 848 for(Int_t gi=0; gi<10; gi++){
31474197 849 if(gi<5){
850 equalTowZN1[gi] = corrADCZN1[gi]*equalCoeffZN1[gi];
851 equalTowZP1[gi] = corrADCZP1[gi]*equalCoeffZP1[gi];
852 equalTowZN2[gi] = corrADCZN2[gi]*equalCoeffZN2[gi];
853 equalTowZP2[gi] = corrADCZP2[gi]*equalCoeffZP2[gi];
854 }
855 else{
856 equalTowZN1[gi] = corrADCZN1[gi]*equalCoeffZN1[gi-5];
857 equalTowZP1[gi] = corrADCZP1[gi]*equalCoeffZP1[gi-5];
858 equalTowZN2[gi] = corrADCZN2[gi]*equalCoeffZN2[gi-5];
859 equalTowZP2[gi] = corrADCZP2[gi]*equalCoeffZP2[gi-5];
860 }
f5d41205 861 }
862
73bc3a3f 863 // ****** Summed response for hadronic calorimeter (SUMMED and then CALIBRATED!)
c9102a72 864 Float_t calibSumZN1[]={0,0}, calibSumZN2[]={0,0}, calibSumZP1[]={0,0}, calibSumZP2[]={0,0};
73bc3a3f 865 for(Int_t gi=0; gi<5; gi++){
866 calibSumZN1[0] += equalTowZN1[gi];
867 calibSumZP1[0] += equalTowZP1[gi];
868 calibSumZN2[0] += equalTowZN2[gi];
869 calibSumZP2[0] += equalTowZP2[gi];
870 //
871 calibSumZN1[1] += equalTowZN1[gi+5];
872 calibSumZP1[1] += equalTowZP1[gi+5];
873 calibSumZN2[1] += equalTowZN2[gi+5];
874 calibSumZP2[1] += equalTowZP2[gi+5];
f5d41205 875 }
73bc3a3f 876 // High gain chain
1b32dcc6 877 calibSumZN1[0] = calibSumZN1[0]*calibEne[0]*8.;
878 calibSumZP1[0] = calibSumZP1[0]*calibEne[1]*8.;
879 calibSumZN2[0] = calibSumZN2[0]*calibEne[2]*8.;
880 calibSumZP2[0] = calibSumZP2[0]*calibEne[3]*8.;
73bc3a3f 881 // Low gain chain
882 calibSumZN1[1] = calibSumZN1[1]*calibEne[0];
883 calibSumZP1[1] = calibSumZP1[1]*calibEne[1];
884 calibSumZN2[1] = calibSumZN2[1]*calibEne[2];
885 calibSumZP2[1] = calibSumZP2[1]*calibEne[3];
7bff3766 886 //
73bc3a3f 887 Float_t sumZEM[]={0,0}, calibZEM1[]={0,0}, calibZEM2[]={0,0};
c7d86465 888 calibZEM1[0] = corrADCZEM1[0]*calibEne[4]*8.;
889 calibZEM1[1] = corrADCZEM1[1]*calibEne[4];
1b32dcc6 890 calibZEM2[0] = corrADCZEM2[0]*calibEne[5]*8.;
73bc3a3f 891 calibZEM2[1] = corrADCZEM2[1]*calibEne[5];
892 for(Int_t k=0; k<2; k++) sumZEM[k] = calibZEM1[k] + calibZEM2[k];
893
894 // ****** Energy calibration of detector responses
895 Float_t calibTowZN1[10], calibTowZN2[10], calibTowZP1[10], calibTowZP2[10];
896 for(Int_t gi=0; gi<5; gi++){
897 // High gain chain
1b32dcc6 898 calibTowZN1[gi] = equalTowZN1[gi]*calibEne[0]*8.;
899 calibTowZP1[gi] = equalTowZP1[gi]*calibEne[1]*8.;
900 calibTowZN2[gi] = equalTowZN2[gi]*calibEne[2]*8.;
901 calibTowZP2[gi] = equalTowZP2[gi]*calibEne[3]*8.;
73bc3a3f 902 // Low gain chain
903 calibTowZN1[gi+5] = equalTowZN1[gi+5]*calibEne[0];
904 calibTowZP1[gi+5] = equalTowZP1[gi+5]*calibEne[1];
905 calibTowZN2[gi+5] = equalTowZN2[gi+5]*calibEne[2];
906 calibTowZP2[gi+5] = equalTowZP2[gi+5]*calibEne[3];
907 }
f5d41205 908
73bc3a3f 909 // ****** Number of detected spectator nucleons
d9ec113e 910 Int_t nDetSpecNLeft=0, nDetSpecPLeft=0, nDetSpecNRight=0, nDetSpecPRight=0;
90936733 911 if(fBeamEnergy>0.01){
fd9afd60 912 nDetSpecNLeft = (Int_t) (calibSumZN1[0]/fBeamEnergy);
913 nDetSpecPLeft = (Int_t) (calibSumZP1[0]/fBeamEnergy);
914 nDetSpecNRight = (Int_t) (calibSumZN2[0]/fBeamEnergy);
915 nDetSpecPRight = (Int_t) (calibSumZP2[0]/fBeamEnergy);
916 }
73bc3a3f 917 else AliWarning(" ATTENTION!!! fBeamEnergy=0 -> N_spec will be ZERO!!! \n");
f5d41205 918 /*printf("\n\t AliZDCReconstructor -> nDetSpecNLeft %d, nDetSpecPLeft %d,"
919 " nDetSpecNRight %d, nDetSpecPRight %d\n",nDetSpecNLeft, nDetSpecPLeft,
920 nDetSpecNRight, nDetSpecPRight);*/
73bc3a3f 921
1e319f71 922 Int_t nGenSpec=0, nGenSpecA=0, nGenSpecC=0;
923 Int_t nPart=0, nPartA=0, nPartC=0;
924 Double_t b=0., bA=0., bC=0.;
925
73bc3a3f 926 if(fIsCalibrationMB == kFALSE){
927 // ****** Reconstruction parameters ------------------
90936733 928 if(!fgMBCalibData) fgMBCalibData = const_cast<AliZDCMBCalib*>(GetMBCalibData());
2d9c70ab 929 if(!fgRecoParam) fgRecoParam = const_cast<AliZDCRecoParam*>(GetRecoParam());
930 fgRecoParam->SetGlauberMCDist(fBeamEnergy);
931
90936733 932 TH2F *hZDCvsZEM = fgMBCalibData->GethZDCvsZEM();
933 TH2F *hZDCCvsZEM = fgMBCalibData->GethZDCCvsZEM();
934 TH2F *hZDCAvsZEM = fgMBCalibData->GethZDCAvsZEM();
0d579f58 935 //
90936733 936 TH1D *hNpartDist = fgRecoParam->GethNpartDist();
937 TH1D *hbDist = fgRecoParam->GethbDist();
938 Float_t clkCenter = fgRecoParam->GetClkCenter();
73bc3a3f 939 //
940 Double_t xHighEdge = hZDCvsZEM->GetXaxis()->GetXmax();
90936733 941 Double_t origin = xHighEdge*clkCenter;
73bc3a3f 942 // Ch. debug
1e319f71 943 //printf("\n\n xHighEdge %1.2f, origin %1.4f \n", xHighEdge, origin);
73bc3a3f 944 //
945 // ====> Summed ZDC info (sideA+side C)
946 TF1 *line = new TF1("line","[0]*x+[1]",0.,xHighEdge);
947 Float_t y = (calibSumZN1[0]+calibSumZP1[0]+calibSumZN2[0]+calibSumZP2[0])/1000.;
948 Float_t x = (calibZEM1[0]+calibZEM2[0])/1000.;
949 line->SetParameter(0, y/(x-origin));
950 line->SetParameter(1, -origin*y/(x-origin));
951 // Ch. debug
1e319f71 952 //printf(" ***************** Summed ZDC info (sideA+side C) \n");
953 //printf(" E_{ZEM} %1.4f, E_{ZDC} %1.2f, TF1: %1.2f*x + %1.2f ", x, y,y/(x-origin),-origin*y/(x-origin));
73bc3a3f 954 //
955 Double_t countPerc=0;
956 Double_t xBinCenter=0, yBinCenter=0;
957 for(Int_t nbinx=1; nbinx<=hZDCvsZEM->GetNbinsX(); nbinx++){
958 for(Int_t nbiny=1; nbiny<=hZDCvsZEM->GetNbinsY(); nbiny++){
959 xBinCenter = hZDCvsZEM->GetXaxis()->GetBinCenter(nbinx);
960 yBinCenter = hZDCvsZEM->GetYaxis()->GetBinCenter(nbiny);
961 //
962 if(line->GetParameter(0)>0){
963 if(yBinCenter < (line->GetParameter(0)*xBinCenter + line->GetParameter(1))){
964 countPerc += hZDCvsZEM->GetBinContent(nbinx,nbiny);
965 // Ch. debug
966 /*printf(" xBinCenter %1.3f, yBinCenter %1.0f, countPerc %1.0f\n",
967 xBinCenter, yBinCenter, countPerc);*/
968 }
969 }
970 else{
971 if(yBinCenter > (line->GetParameter(0)*xBinCenter + line->GetParameter(1))){
972 countPerc += hZDCvsZEM->GetBinContent(nbinx,nbiny);
973 // Ch. debug
974 /*printf(" xBinCenter %1.3f, yBinCenter %1.0f, countPerc %1.0f\n",
975 xBinCenter, yBinCenter, countPerc);*/
976 }
977 }
978 }
979 }
980 //
981 Double_t xSecPerc = 0.;
982 if(hZDCvsZEM->GetEntries()!=0){
983 xSecPerc = countPerc/hZDCvsZEM->GetEntries();
984 }
985 else{
986 AliWarning(" Histogram hZDCvsZEM from OCDB has no entries!!!");
987 }
988 // Ch. debug
989 //printf(" xSecPerc %1.4f \n", xSecPerc);
f5d41205 990
73bc3a3f 991 // ====> side C
992 TF1 *lineC = new TF1("lineC","[0]*x+[1]",0.,xHighEdge);
993 Float_t yC = (calibSumZN1[0]+calibSumZP1[0])/1000.;
994 lineC->SetParameter(0, yC/(x-origin));
995 lineC->SetParameter(1, -origin*yC/(x-origin));
996 // Ch. debug
997 //printf(" ***************** Side C \n");
998 //printf(" E_{ZEM} %1.4f, E_{ZDCC} %1.2f, TF1: %1.2f*x + %1.2f ", x, yC,yC/(x-origin),-origin*yC/(x-origin));
999 //
1000 Double_t countPercC=0;
1001 Double_t xBinCenterC=0, yBinCenterC=0;
1002 for(Int_t nbinx=1; nbinx<=hZDCCvsZEM->GetNbinsX(); nbinx++){
1003 for(Int_t nbiny=1; nbiny<=hZDCCvsZEM->GetNbinsY(); nbiny++){
1004 xBinCenterC = hZDCCvsZEM->GetXaxis()->GetBinCenter(nbinx);
1005 yBinCenterC = hZDCCvsZEM->GetYaxis()->GetBinCenter(nbiny);
1006 if(lineC->GetParameter(0)>0){
1007 if(yBinCenterC < (lineC->GetParameter(0)*xBinCenterC + lineC->GetParameter(1))){
1008 countPercC += hZDCCvsZEM->GetBinContent(nbinx,nbiny);
1009 }
1010 }
1011 else{
1012 if(yBinCenterC > (lineC->GetParameter(0)*xBinCenterC + lineC->GetParameter(1))){
1013 countPercC += hZDCCvsZEM->GetBinContent(nbinx,nbiny);
1014 }
1015 }
1016 }
1017 }
1018 //
1019 Double_t xSecPercC = 0.;
1020 if(hZDCCvsZEM->GetEntries()!=0){
1021 xSecPercC = countPercC/hZDCCvsZEM->GetEntries();
1022 }
1023 else{
1024 AliWarning(" Histogram hZDCCvsZEM from OCDB has no entries!!!");
1025 }
1026 // Ch. debug
1027 //printf(" xSecPercC %1.4f \n", xSecPercC);
1028
1029 // ====> side A
1030 TF1 *lineA = new TF1("lineA","[0]*x+[1]",0.,xHighEdge);
1031 Float_t yA = (calibSumZN2[0]+calibSumZP2[0])/1000.;
1032 lineA->SetParameter(0, yA/(x-origin));
1033 lineA->SetParameter(1, -origin*yA/(x-origin));
1034 //
1035 // Ch. debug
1036 //printf(" ***************** Side A \n");
1037 //printf(" E_{ZEM} %1.4f, E_{ZDCA} %1.2f, TF1: %1.2f*x + %1.2f ", x, yA,yA/(x-origin),-origin*yA/(x-origin));
1038 //
1039 Double_t countPercA=0;
1040 Double_t xBinCenterA=0, yBinCenterA=0;
1041 for(Int_t nbinx=1; nbinx<=hZDCAvsZEM->GetNbinsX(); nbinx++){
1042 for(Int_t nbiny=1; nbiny<=hZDCAvsZEM->GetNbinsY(); nbiny++){
1043 xBinCenterA = hZDCAvsZEM->GetXaxis()->GetBinCenter(nbinx);
1044 yBinCenterA = hZDCAvsZEM->GetYaxis()->GetBinCenter(nbiny);
1045 if(lineA->GetParameter(0)>0){
1046 if(yBinCenterA < (lineA->GetParameter(0)*xBinCenterA + lineA->GetParameter(1))){
1047 countPercA += hZDCAvsZEM->GetBinContent(nbinx,nbiny);
1048 }
1049 }
1050 else{
1051 if(yBinCenterA > (lineA->GetParameter(0)*xBinCenterA + lineA->GetParameter(1))){
1052 countPercA += hZDCAvsZEM->GetBinContent(nbinx,nbiny);
1053 }
1054 }
1055 }
1056 }
1057 //
1058 Double_t xSecPercA = 0.;
1059 if(hZDCAvsZEM->GetEntries()!=0){
1060 xSecPercA = countPercA/hZDCAvsZEM->GetEntries();
1061 }
1062 else{
1063 AliWarning(" Histogram hZDCAvsZEM from OCDB has no entries!!!");
1064 }
1065 // Ch. debug
1066 //printf(" xSecPercA %1.4f \n", xSecPercA);
1067
1068 // ****** Number of participants (from E_ZDC vs. E_ZEM correlation)
73bc3a3f 1069 Double_t nPartFrac=0., nPartFracC=0., nPartFracA=0.;
1070 for(Int_t npbin=1; npbin<hNpartDist->GetNbinsX(); npbin++){
1071 nPartFrac += (hNpartDist->GetBinContent(npbin))/(hNpartDist->GetEntries());
1072 if((1.-nPartFrac) < xSecPerc){
1073 nPart = (Int_t) hNpartDist->GetBinLowEdge(npbin);
1074 // Ch. debug
1075 //printf(" ***************** Summed ZDC info (sideA+side C) \n");
1076 //printf(" nPartFrac %1.4f, nPart %d\n", nPartFrac, nPart);
1077 break;
1078 }
1079 }
1080 if(nPart<0) nPart=0;
1081 //
1082 for(Int_t npbin=1; npbin<hNpartDist->GetNbinsX(); npbin++){
1083 nPartFracC += (hNpartDist->GetBinContent(npbin))/(hNpartDist->GetEntries());
1084 if((1.-nPartFracC) < xSecPercC){
1085 nPartC = (Int_t) hNpartDist->GetBinLowEdge(npbin);
1086 // Ch. debug
1087 //printf(" ***************** Side C \n");
1088 //printf(" nPartFracC %1.4f, nPartC %d\n", nPartFracC, nPartC);
1089 break;
1090 }
1091 }
1092 if(nPartC<0) nPartC=0;
1093 //
1094 for(Int_t npbin=1; npbin<hNpartDist->GetNbinsX(); npbin++){
1095 nPartFracA += (hNpartDist->GetBinContent(npbin))/(hNpartDist->GetEntries());
1096 if((1.-nPartFracA) < xSecPercA){
1097 nPartA = (Int_t) hNpartDist->GetBinLowEdge(npbin);
1098 // Ch. debug
1099 //printf(" ***************** Side A \n");
1100 //printf(" nPartFracA %1.4f, nPartA %d\n\n", nPartFracA, nPartA);
1101 break;
1102 }
1103 }
1104 if(nPartA<0) nPartA=0;
1105
1106 // ****** Impact parameter (from E_ZDC vs. E_ZEM correlation)
73bc3a3f 1107 Double_t bFrac=0., bFracC=0., bFracA=0.;
1108 for(Int_t ibbin=1; ibbin<hbDist->GetNbinsX(); ibbin++){
1109 bFrac += (hbDist->GetBinContent(ibbin))/(hbDist->GetEntries());
1110 if((1.-bFrac) < xSecPerc){
1111 b = hbDist->GetBinLowEdge(ibbin);
1112 break;
1113 }
1114 }
1115 //
1116 for(Int_t ibbin=1; ibbin<hbDist->GetNbinsX(); ibbin++){
1117 bFracC += (hbDist->GetBinContent(ibbin))/(hbDist->GetEntries());
1118 if((1.-bFracC) < xSecPercC){
1119 bC = hbDist->GetBinLowEdge(ibbin);
1120 break;
1121 }
1122 }
1123 //
1124 for(Int_t ibbin=1; ibbin<hbDist->GetNbinsX(); ibbin++){
1125 bFracA += (hbDist->GetBinContent(ibbin))/(hNpartDist->GetEntries());
1126 if((1.-bFracA) < xSecPercA){
1127 bA = hbDist->GetBinLowEdge(ibbin);
1128 break;
1129 }
1130 }
1131
1132 // ****** Number of spectator nucleons
73bc3a3f 1133 nGenSpec = 416 - nPart;
1134 nGenSpecC = 416 - nPartC;
1135 nGenSpecA = 416 - nPartA;
1136 if(nGenSpec>416) nGenSpec=416; if(nGenSpec<0) nGenSpec=0;
1137 if(nGenSpecC>416) nGenSpecC=416; if(nGenSpecC<0) nGenSpecC=0;
1138 if(nGenSpecA>416) nGenSpecA=416; if(nGenSpecA<0) nGenSpecA=0;
8309c1ab 1139
73bc3a3f 1140 // Ch. debug
1141 /*printf("\n\t AliZDCReconstructor -> calibSumZN1[0] %1.0f, calibSumZP1[0] %1.0f,"
1142 " calibSumZN2[0] %1.0f, calibSumZP2[0] %1.0f, corrADCZEMHG %1.0f\n",
1143 calibSumZN1[0],calibSumZP1[0],calibSumZN2[0],calibSumZP2[0],corrADCZEMHG);
1144 printf("\t AliZDCReconstructor -> nGenSpecLeft %d nGenSpecRight %d\n",
1145 nGenSpecLeft, nGenSpecRight);
1146 printf("\t AliZDCReconstructor -> NpartL %d, NpartR %d, b %1.2f fm\n\n",nPartTotLeft, nPartTotRight, impPar);
1147 */
c35ed519 1148
73bc3a3f 1149 delete lineC; delete lineA;
1e319f71 1150
73bc3a3f 1151 } // ONLY IF fIsCalibrationMB==kFALSE
1e319f71 1152
1153 AliZDCReco* reco = new AliZDCReco(calibSumZN1, calibSumZP1, calibSumZN2, calibSumZP2,
1154 calibTowZN1, calibTowZP1, calibTowZN2, calibTowZP2,
1155 calibZEM1, calibZEM2, sPMRef1, sPMRef2,
1156 nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight,
1157 nGenSpec, nGenSpecA, nGenSpecC,
1158 nPart, nPartA, nPartC, b, bA, bC,
81f09162 1159 recoFlag, isScalerOn, scaler);
1e319f71 1160
1161 const Int_t kBufferSize = 4000;
1162 clustersTree->Branch("ZDC", "AliZDCReco", &reco, kBufferSize);
c2bb665a 1163 //reco->Print("");
1e319f71 1164 // write the output tree
1165 clustersTree->Fill();
73bc3a3f 1166}
8309c1ab 1167
8309c1ab 1168
1169//_____________________________________________________________________________
70f04f6d 1170void AliZDCReconstructor::FillZDCintoESD(TTree *clustersTree, AliESDEvent* esd) const
8309c1ab 1171{
70f04f6d 1172 // fill energies and number of participants to the ESD
8309c1ab 1173
8309c1ab 1174 AliZDCReco reco;
1175 AliZDCReco* preco = &reco;
70f04f6d 1176 clustersTree->SetBranchAddress("ZDC", &preco);
8309c1ab 1177
70f04f6d 1178 clustersTree->GetEntry(0);
84d6255e 1179 //
a85132e7 1180 AliESDZDC * esdzdc = esd->GetESDZDC();
1181 Float_t tZN1Ene[5], tZN2Ene[5], tZP1Ene[5], tZP2Ene[5];
1182 Float_t tZN1EneLR[5], tZN2EneLR[5], tZP1EneLR[5], tZP2EneLR[5];
1183 for(Int_t i=0; i<5; i++){
c35ed519 1184 tZN1Ene[i] = reco.GetZN1HREnTow(i);
1185 tZN2Ene[i] = reco.GetZN2HREnTow(i);
1186 tZP1Ene[i] = reco.GetZP1HREnTow(i);
1187 tZP2Ene[i] = reco.GetZP2HREnTow(i);
1188 //
1189 tZN1EneLR[i] = reco.GetZN1LREnTow(i);
1190 tZN2EneLR[i] = reco.GetZN2LREnTow(i);
1191 tZP1EneLR[i] = reco.GetZP1LREnTow(i);
1192 tZP2EneLR[i] = reco.GetZP2LREnTow(i);
e90a5fef 1193 }
73bc3a3f 1194 //
a85132e7 1195 esdzdc->SetZN1TowerEnergy(tZN1Ene);
1196 esdzdc->SetZN2TowerEnergy(tZN2Ene);
1197 esdzdc->SetZP1TowerEnergy(tZP1Ene);
1198 esdzdc->SetZP2TowerEnergy(tZP2Ene);
73bc3a3f 1199 //
a85132e7 1200 esdzdc->SetZN1TowerEnergyLR(tZN1EneLR);
1201 esdzdc->SetZN2TowerEnergyLR(tZN2EneLR);
1202 esdzdc->SetZP1TowerEnergyLR(tZP1EneLR);
1203 esdzdc->SetZP2TowerEnergyLR(tZP2EneLR);
1204 //
73bc3a3f 1205 Int_t nPart = reco.GetNParticipants();
1206 Int_t nPartA = reco.GetNPartSideA();
1207 Int_t nPartC = reco.GetNPartSideC();
1208 Double_t b = reco.GetImpParameter();
1209 Double_t bA = reco.GetImpParSideA();
1210 Double_t bC = reco.GetImpParSideC();
1e319f71 1211 UInt_t recoFlag = reco.GetRecoFlag();
1212 //
c35ed519 1213 esd->SetZDC(reco.GetZN1HREnergy(), reco.GetZP1HREnergy(), reco.GetZEM1HRsignal(),
1214 reco.GetZEM2HRsignal(), reco.GetZN2HREnergy(), reco.GetZP2HREnergy(),
1e319f71 1215 nPart, nPartA, nPartC, b, bA, bC, recoFlag);
a4cab348 1216
81f09162 1217 // Writing ZDC scaler for cross section calculation
1218 // ONLY IF the scaler has been read during the event
1219 if(reco.IsScalerOn()==kTRUE){
1220 UInt_t counts[32];
1221 for(Int_t jk=0; jk<32; jk++) counts[jk] = reco.GetZDCScaler(jk);
1222 esd->SetZDCScaler(counts);
1223 }
8309c1ab 1224}
48642b09 1225
1226//_____________________________________________________________________________
78d18275 1227AliCDBStorage* AliZDCReconstructor::SetStorage(const char *uri)
48642b09 1228{
cc2abffd 1229 // Setting the storage
48642b09 1230
78d18275 1231 Bool_t deleteManager = kFALSE;
48642b09 1232
78d18275 1233 AliCDBManager *manager = AliCDBManager::Instance();
1234 AliCDBStorage *defstorage = manager->GetDefaultStorage();
48642b09 1235
78d18275 1236 if(!defstorage || !(defstorage->Contains("ZDC"))){
1237 AliWarning("No default storage set or default storage doesn't contain ZDC!");
1238 manager->SetDefaultStorage(uri);
1239 deleteManager = kTRUE;
1240 }
1241
1242 AliCDBStorage *storage = manager->GetDefaultStorage();
1243
1244 if(deleteManager){
1245 AliCDBManager::Instance()->UnsetDefaultStorage();
1246 defstorage = 0; // the storage is killed by AliCDBManager::Instance()->Destroy()
1247 }
1248
1249 return storage;
1250}
48642b09 1251
78d18275 1252//_____________________________________________________________________________
1e319f71 1253AliZDCPedestals* AliZDCReconstructor::GetPedestalData() const
6024ec85 1254{
1255
1256 // Getting pedestal calibration object for ZDC set
1257
1258 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/Pedestals");
f00081c8 1259 if(!entry) AliFatal("No calibration data loaded!");
1260 entry->SetOwner(kFALSE);
6024ec85 1261
1262 AliZDCPedestals *calibdata = dynamic_cast<AliZDCPedestals*> (entry->GetObject());
1263 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
1264
1265 return calibdata;
1266}
1267
1268//_____________________________________________________________________________
1e319f71 1269AliZDCEnCalib* AliZDCReconstructor::GetEnergyCalibData() const
6024ec85 1270{
1271
1272 // Getting energy and equalization calibration object for ZDC set
1273
dd98e862 1274 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/EnergyCalib");
6024ec85 1275 if(!entry) AliFatal("No calibration data loaded!");
f00081c8 1276 entry->SetOwner(kFALSE);
6024ec85 1277
73bc3a3f 1278 AliZDCEnCalib *calibdata = dynamic_cast<AliZDCEnCalib*> (entry->GetObject());
6024ec85 1279 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
1280
1281 return calibdata;
1282}
1283
73bc3a3f 1284//_____________________________________________________________________________
1e319f71 1285AliZDCTowerCalib* AliZDCReconstructor::GetTowerCalibData() const
73bc3a3f 1286{
1287
1288 // Getting energy and equalization calibration object for ZDC set
1289
dd98e862 1290 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/TowerCalib");
73bc3a3f 1291 if(!entry) AliFatal("No calibration data loaded!");
f00081c8 1292 entry->SetOwner(kFALSE);
73bc3a3f 1293
1294 AliZDCTowerCalib *calibdata = dynamic_cast<AliZDCTowerCalib*> (entry->GetObject());
1295 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
1296
1297 return calibdata;
1298}
1299
1300//_____________________________________________________________________________
0d579f58 1301AliZDCMBCalib* AliZDCReconstructor::GetMBCalibData() const
1302{
1303
1304 // Getting energy and equalization calibration object for ZDC set
1305
1306 AliCDBEntry *entry = AliCDBManager::Instance()->Get("ZDC/Calib/MBCalib");
1307 if(!entry) AliFatal("No calibration data loaded!");
1308 entry->SetOwner(kFALSE);
1309
1310 AliZDCMBCalib *calibdata = dynamic_cast<AliZDCMBCalib*> (entry->GetObject());
1311 if(!calibdata) AliFatal("Wrong calibration object in calibration file!");
1312
1313 return calibdata;
1314}