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