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