1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for ZDC reconstruction //
22 ///////////////////////////////////////////////////////////////////////////////
27 #include "AliRunLoader.h"
28 #include "AliRawReader.h"
30 #include "AliZDCDigit.h"
31 #include "AliZDCRawStream.h"
32 #include "AliZDCReco.h"
33 #include "AliZDCReconstructor.h"
34 #include "AliZDCCalibData.h"
37 ClassImp(AliZDCReconstructor)
40 //_____________________________________________________________________________
41 AliZDCReconstructor:: AliZDCReconstructor()
43 // **** Default constructor
44 // if(!fStorage) fStorage = AliCDBManager::Instance()->GetStorage("local://DBlocal");
46 // --- Number of generated spectator nucleons and impact parameter
47 // --------------------------------------------------------------------------------------------------
48 // [1] ### Results from a new production -> 0<b<18 fm (Apr 2002)
49 // Fit results for neutrons (Nspectator n true vs. EZN)
50 fZNCen = new TF1("fZNCen",
51 "(-2.287920+sqrt(2.287920*2.287920-4*(-0.007629)*(11.921710-x)))/(2*(-0.007629))",0.,164.);
52 fZNPer = new TF1("fZNPer",
53 "(-37.812280-sqrt(37.812280*37.812280-4*(-0.190932)*(-1709.249672-x)))/(2*(-0.190932))",0.,164.);
54 // Fit results for protons (Nspectator p true vs. EZP)
55 fZPCen = new TF1("fZPCen",
56 "(-1.321353+sqrt(1.321353*1.321353-4*(-0.007283)*(3.550697-x)))/(2*(-0.007283))",0.,60.);
57 fZPPer = new TF1("fZPPer",
58 "(-42.643308-sqrt(42.643308*42.643308-4*(-0.310786)*(-1402.945615-x)))/(2*(-0.310786))",0.,60.);
59 // Fit results for total number of spectators (Nspectators true vs. EZDC)
60 fZDCCen = new TF1("fZDCCen",
61 "(-1.934991+sqrt(1.934991*1.934991-4*(-0.004080)*(15.111124-x)))/(2*(-0.004080))",0.,225.);
62 fZDCPer = new TF1("fZDCPer",
63 "(-34.380639-sqrt(34.380639*34.380639-4*(-0.104251)*(-2612.189017-x)))/(2*(-0.104251))",0.,225.);
64 // --------------------------------------------------------------------------------------------------
65 // Fit results for b (b vs. EZDC)
66 // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
67 fbCen = new TF1("fbCen","-0.056923+0.079703*x-0.0004301*x*x+0.000001366*x*x*x",0.,220.);
68 fbPer = new TF1("fbPer","17.943998-0.046846*x+0.000074*x*x",0.,220.);
69 // --------------------------------------------------------------------------------------------------
70 // Evaluating Nspectators and b from ZEM energy
71 // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
72 fZEMn = new TF1("fZEMn","126.2-0.05399*x+0.000005679*x*x",0.,4000.);
73 fZEMp = new TF1("fZEMp","82.49-0.03611*x+0.00000385*x*x",0.,4000.);
74 fZEMsp = new TF1("fZEMsp","208.7-0.09006*x+0.000009526*x*x",0.,4000.);
75 fZEMb = new TF1("fZEMb","16.06-0.01633*x+1.44e-5*x*x-6.778e-9*x*x*x+1.438e-12*x*x*x*x-1.112e-16*x*x*x*x*x",0.,4000.);
78 //_____________________________________________________________________________
79 AliZDCReconstructor::AliZDCReconstructor(const AliZDCReconstructor&
81 AliReconstructor(reconstructor)
85 Fatal("AliZDCReconstructor", "copy constructor not implemented");
88 //_____________________________________________________________________________
89 AliZDCReconstructor& AliZDCReconstructor::operator =
90 (const AliZDCReconstructor& /*reconstructor*/)
92 // assignment operator
94 Fatal("operator =", "assignment operator not implemented");
98 //_____________________________________________________________________________
99 AliZDCReconstructor::~AliZDCReconstructor()
118 //_____________________________________________________________________________
119 void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader) const
121 // *** Local ZDC reconstruction for digits
123 // Get calibration data
125 AliZDCCalibData *calibda = GetCalibData(runNumber);
128 for(Int_t jj=0; jj<47; jj++) meanPed[jj] = calibda->GetMeanPed(jj);
130 AliLoader* loader = runLoader->GetLoader("ZDCLoader");
132 loader->LoadDigits("read");
133 loader->LoadRecPoints("recreate");
135 AliZDCDigit* pdigit = &digit;
138 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
139 runLoader->GetEvent(iEvent);
142 loader->LoadDigits();
143 TTree* treeD = loader->TreeD();
144 if (!treeD) continue;
145 treeD->SetBranchAddress("ZDC", &pdigit);
148 Float_t zncorr=0, zpcorr=0, zemcorr=0;
149 for (Int_t iDigit = 0; iDigit < treeD->GetEntries(); iDigit++) {
150 treeD->GetEntry(iDigit);
151 if (!pdigit) continue;
153 if(digit.GetSector(0) == 1)
154 zncorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)]); // ped 4 high gain ZN ADCs
155 else if(digit.GetSector(0) == 2)
156 zpcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+10]); // ped 4 high gain ZP ADCs
157 else if(digit.GetSector(0) == 3){
158 if(digit.GetSector(1)==1) zemcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+20]); // ped 4 high gain ZEM1 ADCs
159 else if(digit.GetSector(1)==2) zemcorr += (Float_t) (digit.GetADCValue(0)-meanPed[digit.GetSector(1)+22]); // ped 4 high gain ZEM2 ADCs
162 if(zncorr<0) zncorr=0;
163 if(zpcorr<0) zpcorr=0;
164 if(zemcorr<0) zemcorr=0;
166 // reconstruct the event
167 printf("\n \t ZDCReco from digits-> Ev.#%d ZN = %.0f, ZP = %.0f, ZEM = %.0f\n",iEvent,zncorr,zpcorr,zemcorr);
168 ReconstructEvent(loader, zncorr, zpcorr, zemcorr);
171 loader->UnloadDigits();
172 loader->UnloadRecPoints();
175 //_____________________________________________________________________________
176 void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader,
177 AliRawReader* rawReader) const
179 // *** Local ZDC reconstruction for raw data
183 AliZDCCalibData *calibda = GetCalibData(runNumber);
186 for(Int_t jj=0; jj<47; jj++) meanPed[jj] = calibda->GetMeanPed(jj);
188 AliLoader* loader = runLoader->GetLoader("ZDCLoader");
190 loader->LoadRecPoints("recreate");
193 while (rawReader->NextEvent()) {
194 runLoader->GetEvent(iEvent++);
196 // loop over raw data digits
197 Float_t zncorr=0, zpcorr=0, zemcorr=0;
198 AliZDCRawStream digit(rawReader);
199 while (digit.Next()) {
200 if(digit.IsADCDataWord()){
201 if(digit.GetADCGain() == 0){
202 if(digit.GetSector(0) == 1) zncorr += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)]); // pedestals for high gain ZN ADCs;
203 else if(digit.GetSector(0) == 2) zpcorr += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+10]); // pedestals for high gain ZP ADCs;
204 else if(digit.GetSector(0) == 3) zemcorr += (Float_t) (digit.GetADCValue()-meanPed[digit.GetSector(1)+20]); // pedestals for high gain ZEM ADCs;
208 if(zncorr<0) zncorr=0;
209 if(zpcorr<0) zpcorr=0;
210 if(zemcorr<0) zemcorr=0;
212 // reconstruct the event
213 printf("\n\t ZDCReco from raw-> Ev.#%d ZN = %.0f, ZP = %.0f, ZEM = %.0f\n",iEvent,zncorr,zpcorr,zemcorr);
214 ReconstructEvent(loader, zncorr, zpcorr, zemcorr);
217 loader->UnloadRecPoints();
220 //_____________________________________________________________________________
221 void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Float_t zncorr,
222 Float_t zpcorr, Float_t zemcorr) const
224 // ***** Reconstruct one event
226 // --- ADCchannel -> photoelectrons
227 // NB-> PM gain = 10^(5), ADC resolution = 6.4*10^(-7)
228 // Move to V965 (E.S.,15/09/04) NB-> PM gain = 10^(5), ADC resolution = 8*10^(-7)
229 Float_t znphe, zpphe, zemphe, convFactor = 0.08;
230 znphe = zncorr/convFactor;
231 zpphe = zpcorr/convFactor;
232 zemphe = zemcorr/convFactor;
233 //if AliDebug(1,Form("\n znphe = %f, zpphe = %f, zemphe = %f\n",znphe, zpphe, zemphe);
235 // --- Energy calibration
236 // Conversion factors for hadronic ZDCs goes from phe yield to TRUE
237 // incident energy (conversion from GeV to TeV is included); while for EM
238 // calos conversion is from light yield to detected energy calculated by
239 // GEANT NB -> ZN and ZP conversion factors are constant since incident
240 // spectators have all the same energy, ZEM energy is obtained through a
241 // fit over the whole range of incident particle energies
242 // (obtained with full HIJING simulations)
243 Float_t znenergy, zpenergy, zemenergy, zdcenergy;
244 Float_t znphexTeV=329., zpphexTeV=369.;
245 znenergy = znphe/znphexTeV;
246 zpenergy = zpphe/zpphexTeV;
247 zdcenergy = znenergy+zpenergy;
248 zemenergy = -4.81+0.3238*zemphe;
249 if(zemenergy<0) zemenergy=0;
250 // if AliDebug(1,Form(" znenergy = %f TeV, zpenergy = %f TeV, zdcenergy = %f GeV, "
251 // "\n zemenergy = %f TeV\n", znenergy, zpenergy,
252 // zdcenergy, zemenergy);
255 // if AliDebug(1,Form("\n\n ### ATTENZIONE!!! -> ev# %d: znenergy = %f TeV, zpenergy = %f TeV, zdcenergy = %f GeV, "
256 // " zemenergy = %f TeV\n\n", fMerger->EvNum(), znenergy, zpenergy, zdcenergy, zemenergy);
258 // --- Number of incident spectator nucleons
259 Int_t nDetSpecN, nDetSpecP;
260 nDetSpecN = (Int_t) (znenergy/2.760);
261 nDetSpecP = (Int_t) (zpenergy/2.760);
262 // if AliDebug(1,Form("\n nDetSpecN = %d, nDetSpecP = %d\n",nDetSpecN, nDetSpecP);
264 Int_t nGenSpecN=0, nGenSpecP=0, nGenSpec=0;
266 // Cut value for Ezem (GeV)
267 // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
268 Float_t eZEMCut = 420.;
269 Float_t deltaEZEMSup = 690.;
270 Float_t deltaEZEMInf = 270.;
271 if(zemenergy > (eZEMCut+deltaEZEMSup)){
272 nGenSpecN = (Int_t) (fZNCen->Eval(znenergy));
273 nGenSpecP = (Int_t) (fZPCen->Eval(zpenergy));
274 nGenSpec = (Int_t) (fZDCCen->Eval(zdcenergy));
275 impPar = fbCen->Eval(zdcenergy);
277 else if(zemenergy < (eZEMCut-deltaEZEMInf)){
278 nGenSpecN = (Int_t) (fZNPer->Eval(znenergy));
279 nGenSpecP = (Int_t) (fZPPer->Eval(zpenergy));
280 nGenSpec = (Int_t) (fZDCPer->Eval(zdcenergy));
281 impPar = fbPer->Eval(zdcenergy);
283 else if(zemenergy >= (eZEMCut-deltaEZEMInf) && zemenergy <= (eZEMCut+deltaEZEMSup)){
284 nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy));
285 nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy));
286 nGenSpec = (Int_t)(fZEMsp->Eval(zemenergy));
287 impPar = fZEMb->Eval(zemenergy);
289 // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
290 if(znenergy>162.) nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy));
291 if(zpenergy>59.75) nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy));
292 if(zdcenergy>221.5) nGenSpec = (Int_t)(fZEMsp->Eval(zemenergy));
293 if(zdcenergy>220.) impPar = fZEMb->Eval(zemenergy);
295 if(nGenSpecN>125) nGenSpecN=125;
296 else if(nGenSpecN<0) nGenSpecN=0;
297 if(nGenSpecP>82) nGenSpecP=82;
298 else if(nGenSpecP<0) nGenSpecP=0;
299 if(nGenSpec>207) nGenSpec=207;
300 else if(nGenSpec<0) nGenSpec=0;
302 // --- Number of participants
303 Int_t nPart, nPartTot;
304 nPart = 207-nGenSpecN-nGenSpecP;
305 nPartTot = 207-nGenSpec;
306 printf("\t ZDCeventReco-> ZNEn = %.0f GeV, ZPEn = %.0f GeV, ZEMEn = %.0f GeV\n",
307 znenergy, zpenergy, zemenergy);
309 // create the output tree
310 loader->MakeTree("R");
311 TTree* treeR = loader->TreeR();
312 AliZDCReco reco(znenergy, zpenergy, zdcenergy, zemenergy,
313 nDetSpecN, nDetSpecP, nGenSpecN, nGenSpecP, nGenSpec,
315 AliZDCReco* preco = &reco;
316 const Int_t kBufferSize = 4000;
317 treeR->Branch("ZDC", "AliZDCReco", &preco, kBufferSize);
319 // write the output tree
321 loader->WriteRecPoints("OVERWRITE");
324 //_____________________________________________________________________________
325 void AliZDCReconstructor::FillESD(AliRunLoader* runLoader,
328 // fill energies and number of participants to the ESD
330 AliLoader* loader = runLoader->GetLoader("ZDCLoader");
332 loader->LoadRecPoints();
334 TTree* treeR = loader->TreeR();
337 AliZDCReco* preco = &reco;
338 treeR->SetBranchAddress("ZDC", &preco);
341 esd->SetZDC(reco.GetZNenergy(), reco.GetZPenergy(), reco.GetZEMenergy(),
344 loader->UnloadRecPoints();
347 //_____________________________________________________________________________
348 AliZDCCalibData* AliZDCReconstructor::GetCalibData(int runNumber) const
351 //printf("\n\t AliZDCReconstructor::GetCalibData \n");
352 //fStorage->PrintSelectionList();
353 //AliCDBEntry *entry = fStorage->Get("DBlocal/ZDC/Calib/Data",runNumber);
356 AliCDBStorage *fStorage = AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
357 AliCDBEntry *entry = fStorage->Get("ZDC/Calib/Data",0);
359 AliZDCCalibData *calibda = (AliZDCCalibData*) entry->GetObject();
361 //AliCDBManager::Instance()->Destroy();