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