Changes according to AliPreprocessor class
[u/mrichter/AliRoot.git] / ZDC / AliZDC.cxx
CommitLineData
4c039060 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 *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
88cb7938 16/* $Id$ */
4c039060 17
fe4da5cc 18///////////////////////////////////////////////////////////////////////////////
19// //
359cdddc 20// Zero Degree Calorimeter //
21// This class contains the basic functions for the ZDCs; //
22// functions specific to one particular geometry are //
23// contained in the derived classes //
fe4da5cc 24// //
fe4da5cc 25///////////////////////////////////////////////////////////////////////////////
26
f901045b 27// --- ROOT system
fe4da5cc 28#include <TBRIK.h>
88cb7938 29#include <TGeometry.h>
30#include <TNode.h>
31#include <TTree.h>
232b622f 32#include <TFile.h>
8af17dba 33#include <TSystem.h>
fe4da5cc 34
f901045b 35// --- AliRoot header files
88cb7938 36#include "AliDetector.h"
fe4da5cc 37#include "AliZDC.h"
f901045b 38#include "AliZDCHit.h"
6de91202 39#include "AliZDCSDigit.h"
40#include "AliZDCDigit.h"
41#include "AliZDCDigitizer.h"
42#include "AliZDCRawStream.h"
8af17dba 43#include "AliZDCCalibData.h"
88cb7938 44
6de91202 45#include "AliRawDataHeader.h"
88cb7938 46#include "AliLoader.h"
47#include "AliRun.h"
5d12ce38 48#include "AliMC.h"
99a553ce 49#include "AliLog.h"
362c9d61 50#include "AliDAQ.h"
fe4da5cc 51
52ClassImp(AliZDC)
8af17dba 53
8a2624cc 54AliZDC *gAliZDC;
fe4da5cc 55
56//_____________________________________________________________________________
57AliZDC::AliZDC()
58{
59 //
60 // Default constructor for the Zero Degree Calorimeter base class
61 //
2e6fc82a 62
1450a7cd 63 fIshunt = 1;
64 fNoShower = 0;
09630792 65
1450a7cd 66 fHits = 0;
67 fNhits = 0;
09630792 68
1450a7cd 69 fDigits = 0;
70 fNdigits = 0;
d16dd065 71
72 fCalibData = 0;
2685bf00 73
fe4da5cc 74}
75
76//_____________________________________________________________________________
77AliZDC::AliZDC(const char *name, const char *title)
78 : AliDetector(name,title)
79{
80 //
81 // Standard constructor for the Zero Degree Calorimeter base class
82 //
83
359cdddc 84 fIshunt = 1;
85 fNoShower = 0;
f901045b 86
359cdddc 87 // Allocate the hits array
f901045b 88 fHits = new TClonesArray("AliZDCHit",1000);
5d12ce38 89 gAlice->GetMCApp()->AddHitList(fHits);
8af17dba 90
91 char sensname[5],senstitle[25];
92 sprintf(sensname,"ZDC");
93 sprintf(senstitle,"ZDC dummy");
94 SetName(sensname); SetTitle(senstitle);
f901045b 95
6de91202 96 fDigits = 0;
97 fNdigits = 0;
8af17dba 98
d16dd065 99 fCalibData = 0;
100
8a2624cc 101 gAliZDC=this;
866ab5a2 102
103}
104//____________________________________________________________________________
105AliZDC::~AliZDC()
106{
107 //
108 // ZDC destructor
109 //
110
111 fIshunt = 0;
8a2624cc 112 gAliZDC=0;
2e6fc82a 113
d16dd065 114 delete fCalibData;
115
fe4da5cc 116}
fe4da5cc 117//_____________________________________________________________________________
118void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
119{
120 //
f901045b 121 // Add a ZDC hit to the hit list.
122 // -> We make use of 2 array of hits:
123 // [1] fHits (the usual one) that contains hits for each PRIMARY
124 // [2] fStHits that contains hits for each EVENT and is used to
125 // obtain digits at the end of each event
fe4da5cc 126 //
f901045b 127
68ca986e 128 static Float_t primKinEn, xImpact, yImpact, sFlag;
129
43f34e8b 130 AliZDCHit *newquad, *curprimquad;
f901045b 131 newquad = new AliZDCHit(fIshunt, track, vol, hits);
65d4f2be 132 TClonesArray &lhits = *fHits;
cefa66cb 133
134 if(fNhits==0){
135 // First hit -> setting flag for primary or secondary particle
5d12ce38 136 Int_t primary = gAlice->GetMCApp()->GetPrimary(track);
cefa66cb 137 if(track != primary){
3ff116f2 138 newquad->SetSFlag(1); // SECONDARY particle entering the ZDC
cefa66cb 139 }
140 else if(track == primary){
3ff116f2 141 newquad->SetSFlag(0); // PRIMARY particle entering the ZDC
cefa66cb 142 }
3ff116f2 143 sFlag = newquad->GetSFlag();
144 primKinEn = newquad->GetPrimKinEn();
145 xImpact = newquad->GetXImpact();
146 yImpact = newquad->GetYImpact();
cefa66cb 147 }
148 else{
3ff116f2 149 newquad->SetPrimKinEn(primKinEn);
150 newquad->SetXImpact(xImpact);
151 newquad->SetYImpact(yImpact);
152 newquad->SetSFlag(sFlag);
cefa66cb 153 }
154
43f34e8b 155 Int_t j;
f901045b 156 for(j=0; j<fNhits; j++){
2e6fc82a 157 // If hits are equal (same track, same volume), sum them.
f901045b 158 curprimquad = (AliZDCHit*) lhits[j];
159 if(*curprimquad == *newquad){
160 *curprimquad = *curprimquad+*newquad;
161 delete newquad;
68ca986e 162 return;
f901045b 163 }
164 }
f901045b 165
166 //Otherwise create a new hit
167 new(lhits[fNhits]) AliZDCHit(newquad);
168 fNhits++;
169
866ab5a2 170 delete newquad;
cefa66cb 171}
172
866ab5a2 173//_____________________________________________________________________________
fe4da5cc 174void AliZDC::BuildGeometry()
175{
176 //
177 // Build the ROOT TNode geometry for event display
178 // in the Zero Degree Calorimeter
179 // This routine is dummy for the moment
180 //
181
68ca986e 182 TNode *node, *top;
183 TBRIK *brik;
359cdddc 184 const int kColorZDC = kBlue;
fe4da5cc 185
186 //
68ca986e 187 top=gAlice->GetGeometry()->GetNode("alice");
fe4da5cc 188
189 // ZDC
fe4da5cc 190 brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
68ca986e 191 top->cd();
192 node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
193 node->SetLineColor(kColorZDC);
194 fNodes->Add(node);
fe4da5cc 195}
196
359cdddc 197//____________________________________________________________________________
198Float_t AliZDC::ZMin(void) const
199{
200 // Minimum dimension of the ZDC module in z
6de91202 201 return -11600.;
359cdddc 202}
203
204//____________________________________________________________________________
205Float_t AliZDC::ZMax(void) const
206{
207 // Maximum dimension of the ZDC module in z
6de91202 208 return -11750.;
359cdddc 209}
210
211
fe4da5cc 212//_____________________________________________________________________________
5bc762ca 213void AliZDC::MakeBranch(Option_t *opt)
fe4da5cc 214{
215 //
359cdddc 216 // Create Tree branches for the ZDC
fe4da5cc 217 //
359cdddc 218
219 char branchname[10];
220 sprintf(branchname,"%s",GetName());
88cb7938 221
222 const char *cH = strstr(opt,"H");
223
224 if (cH && fLoader->TreeH())
225 fHits = new TClonesArray("AliZDCHit",1000);
359cdddc 226
227 AliDetector::MakeBranch(opt);
b6d27557 228}
1450a7cd 229
1450a7cd 230//_____________________________________________________________________________
b6d27557 231void AliZDC::Hits2SDigits()
232{
6de91202 233 // Create summable digits from hits
234
99a553ce 235 AliDebug(1,"\n Entering AliZDC::Hits2Digits() ");
b6d27557 236
85a5290f 237 fLoader->LoadHits("read");
238 fLoader->LoadSDigits("recreate");
6de91202 239 AliRunLoader* runLoader = fLoader->GetRunLoader();
240 AliZDCSDigit sdigit;
241 AliZDCSDigit* psdigit = &sdigit;
85a5290f 242
6de91202 243 // Event loop
85a5290f 244 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
6de91202 245 Float_t pmCZN = 0, pmCZP = 0, pmQZN[4], pmQZP[4], pmZEM1 = 0, pmZEM2 = 0;
246 for (Int_t i = 0; i < 4; i++) pmQZN[i] = pmQZP[i] = 0;
85a5290f 247
6de91202 248 runLoader->GetEvent(iEvent);
249 TTree* treeH = fLoader->TreeH();
359cdddc 250 Int_t ntracks = (Int_t) treeH->GetEntries();
6de91202 251 ResetHits();
252
359cdddc 253 // Tracks loop
6de91202 254 Int_t sector[2];
255 for (Int_t itrack = 0; itrack < ntracks; itrack++) {
256 treeH->GetEntry(itrack);
257 for (AliZDCHit* zdcHit = (AliZDCHit*)FirstHit(-1); zdcHit;
258 zdcHit = (AliZDCHit*)NextHit()) {
b6d27557 259
6de91202 260 sector[0] = zdcHit->GetVolume(0);
261 sector[1] = zdcHit->GetVolume(1);
262 if ((sector[1] < 1) || (sector[1] > 4)) {
263 Error("Hits2SDigits", "sector[0] = %d, sector[1] = %d",
264 sector[0], sector[1]);
265 continue;
266 }
267 Float_t lightQ = zdcHit->GetLightPMQ();
268 Float_t lightC = zdcHit->GetLightPMC();
269
270 if (sector[0] == 1) { //ZN
271 pmCZN += lightC;
272 pmQZN[sector[1]-1] += lightQ;
273 } else if (sector[0] == 2) { //ZP
274 pmCZP += lightC;
275 pmQZP[sector[1]-1] += lightQ;
276 } else if (sector[0] == 3) { //ZEM
277 if (sector[1] == 1) pmZEM1 += lightC;
278 else pmZEM2 += lightQ;
279 }
280 }//Hits loop
359cdddc 281 }
6de91202 282
283 // create the output tree
284 fLoader->MakeTree("S");
285 TTree* treeS = fLoader->TreeS();
286 const Int_t kBufferSize = 4000;
287 treeS->Branch(GetName(), "AliZDCSDigit", &psdigit, kBufferSize);
288
289 // Create sdigits for ZN
290 sector[0] = 1; // Detector = ZN
291 sector[1] = 0; // Common PM ADC
292 new(psdigit) AliZDCSDigit(sector, pmCZN);
293 if (pmCZN > 0) treeS->Fill();
294 for (Int_t j = 0; j < 4; j++) {
295 sector[1] = j+1; // Towers PM ADCs
296 new(psdigit) AliZDCSDigit(sector, pmQZN[j]);
297 if (pmQZN[j] > 0) treeS->Fill();
b6d27557 298 }
359cdddc 299
6de91202 300 // Create sdigits for ZP
301 sector[0] = 2; // Detector = ZP
302 sector[1] = 0; // Common PM ADC
303 new(psdigit) AliZDCSDigit(sector, pmCZP);
304 if (pmCZP > 0) treeS->Fill();
305 for (Int_t j = 0; j < 4; j++) {
306 sector[1] = j+1; // Towers PM ADCs
307 new(psdigit) AliZDCSDigit(sector, pmQZP[j]);
308 if (pmQZP[j] > 0) treeS->Fill();
309 }
310
311 // Create sdigits for ZEM
312 sector[0] = 3;
313 sector[1] = 1; // Detector = ZEM1
314 new(psdigit) AliZDCSDigit(sector, pmZEM1);
315 if (pmZEM1 > 0) treeS->Fill();
316 sector[1] = 2; // Detector = ZEM2
317 new(psdigit) AliZDCSDigit(sector, pmZEM2);
318 if (pmZEM2 > 0) treeS->Fill();
319
320 // write the output tree
321 fLoader->WriteSDigits("OVERWRITE");
85a5290f 322 }
323
324 fLoader->UnloadHits();
325 fLoader->UnloadSDigits();
359cdddc 326}
327
328//_____________________________________________________________________________
6de91202 329AliDigitizer* AliZDC::CreateDigitizer(AliRunDigitizer* manager) const
359cdddc 330{
6de91202 331 // Create the digitizer for ZDC
332
333 return new AliZDCDigitizer(manager);
359cdddc 334}
335
336//_____________________________________________________________________________
6de91202 337void AliZDC::Digits2Raw()
359cdddc 338{
6de91202 339 // Convert ZDC digits to raw data
340
abf60186 341 // Format: 22 interger values -> ZN1 (C+Q1-4), ZP1 (C+Q1-4), ZEM1, 2, ZN (C+Q1-4), ZP2 (C+Q1-4))
6de91202 342 // For the CAEN module V965 we have an header, the Data Words and an End Of Block
abf60186 343 // 24 channels read on 1st ADC module, 20 channels read on 2nd ADC module
344 const int knADCData1=24, knADCData2=20;
7f73eb6b 345 UInt_t lADCHeader1;
8a2624cc 346 UInt_t lADCData1[knADCData1];
7f73eb6b 347 //
348 UInt_t lADCHeader2;
8a2624cc 349 UInt_t lADCData2[knADCData2];
7f73eb6b 350 //
232b622f 351 UInt_t lADCEndBlock;
6de91202 352
353 // load the digits
354 fLoader->LoadDigits("read");
355 AliZDCDigit digit;
356 AliZDCDigit* pdigit = &digit;
357 TTree* treeD = fLoader->TreeD();
358 if (!treeD) return;
359 treeD->SetBranchAddress("ZDC", &pdigit);
abf60186 360 //printf("\t AliZDC::Digits2raw -> TreeD has %d entries\n",(Int_t) treeD->GetEntries());
361 //digit.Print(""); // Ch. debug
362
6de91202 363
364 // Fill data array
365 // ADC header
232b622f 366 UInt_t lADCHeaderGEO = 0;
367 UInt_t lADCHeaderCRATE = 0;
8a2624cc 368 UInt_t lADCHeaderCNT1 = knADCData1;
369 UInt_t lADCHeaderCNT2 = knADCData2;
1450a7cd 370
7f73eb6b 371 lADCHeader1 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 |
372 lADCHeaderCNT1 << 8 ;
abf60186 373 //
7f73eb6b 374 lADCHeader2 = lADCHeaderGEO << 27 | 0x1 << 25 | lADCHeaderCRATE << 16 |
375 lADCHeaderCNT2 << 8 ;
6de91202 376
abf60186 377 //printf("\t lADCHeader1 = %x, lADCHeader2 = %x\n",lADCHeader1, lADCHeader2);
6de91202 378
379 // ADC data word
232b622f 380 UInt_t lADCDataGEO = lADCHeaderGEO;
8a2624cc 381 UInt_t lADCDataValue1[knADCData1];
382 UInt_t lADCDataValue2[knADCData2];
383 UInt_t lADCDataOvFlw1[knADCData1];
384 UInt_t lADCDataOvFlw2[knADCData2];
385 for(Int_t i = 0; i<knADCData1 ; i++){
7f73eb6b 386 lADCDataValue1[i] = 0;
387 lADCDataOvFlw1[i] = 0;
388 }
8a2624cc 389 for(Int_t i = 0; i<knADCData2 ; i++){
7f73eb6b 390 lADCDataValue2[i] = 0;
391 lADCDataOvFlw2[i] = 0;
6de91202 392 }
232b622f 393 UInt_t lADCDataChannel = 0;
6de91202 394
395 // loop over digits
abf60186 396 for (Int_t iDigit = 0; iDigit<treeD->GetEntries(); iDigit++) {
6de91202 397 treeD->GetEntry(iDigit);
398 if (!pdigit) continue;
abf60186 399
6de91202 400 //ADC data
7f73eb6b 401 Int_t index1 = 0, index2 = 0;
abf60186 402 // ADC #1 (ZN1, ZP1, ZEM1,2)
7f73eb6b 403 if(digit.GetSector(0)==1 || digit.GetSector(0)==2 || digit.GetSector(0)==3){
404 if(digit.GetSector(0)==1 || digit.GetSector(0)==2){
abf60186 405 index1 = (digit.GetSector(0)-1) + digit.GetSector(1)*4; // ZN1 or ZP1
7f73eb6b 406 lADCDataChannel = (digit.GetSector(0)-1)*8 + digit.GetSector(1);
407 }
abf60186 408 else if(digit.GetSector(0)==3){ // ZEM 1,2
409 index1 = 20 + (digit.GetSector(1)-1);
410 lADCDataChannel = 5 + (digit.GetSector(1)-1)*8;
7f73eb6b 411 }
abf60186 412 //
413 /*printf("\t AliZDC::Digits2raw -> det %d, quad %d, index = %d, ADCch = %d\n",
414 digit.GetSector(0),digit.GetSector(1),index1,lADCDataChannel);// Ch. debug
415 */
416 //
417 lADCDataValue1[index1] = digit.GetADCValue(0); // High gain ADC ch.
418 if(lADCDataValue1[index1] > 2047) lADCDataOvFlw1[index1] = 1;
419 lADCDataValue1[index1+2] = digit.GetADCValue(1); // Low gain ADC ch.
420 if(lADCDataValue1[index1+2] > 2047) lADCDataOvFlw1[index1+2] = 1;
7f73eb6b 421
abf60186 422 lADCData1[index1] = lADCDataGEO << 27 | lADCDataChannel << 17 |
7f73eb6b 423 lADCDataOvFlw1[index1] << 12 | (lADCDataValue1[index1] & 0xfff);
424 lADCData1[index1+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
425 lADCDataOvFlw1[index1+2] << 12 | (lADCDataValue1[index1+2] & 0xfff);
6de91202 426 }
abf60186 427 // ADC #2 (ZN2, ZP2)
7f73eb6b 428 else if(digit.GetSector(0)==4 || digit.GetSector(0)==5){
abf60186 429 index2 = (digit.GetSector(0)-4) + digit.GetSector(1)*4; // ZN2 or ZP2
7f73eb6b 430 lADCDataChannel = (digit.GetSector(0)-4)*8 + digit.GetSector(1);
abf60186 431 //
432 /*printf("\t AliZDC::Digits2raw -> det %d, quad %d, index = %d, ADCch = %d\n",
433 digit.GetSector(0),digit.GetSector(1),index1,lADCDataChannel); // Ch. debug
434 */
435 //
7f73eb6b 436 lADCDataValue2[index2] = digit.GetADCValue(0);
437 if (lADCDataValue2[index2] > 2047) lADCDataOvFlw2[index2] = 1;
438 lADCDataValue2[index2+2] = digit.GetADCValue(1);
439 if (lADCDataValue2[index2+2] > 2047) lADCDataOvFlw2[index2+2] = 1;
440 //
441 lADCData2[index2] = lADCDataGEO << 27 | lADCDataChannel << 17 |
442 lADCDataOvFlw2[index2] << 12 | (lADCDataValue2[index2] & 0xfff);
443 lADCData2[index2+2] = lADCDataGEO << 27 | lADCDataChannel << 17 | 0x1 << 16 |
444 lADCDataOvFlw2[index2+2] << 12 | (lADCDataValue2[index2+2] & 0xfff);
445 }
abf60186 446 if((index1<0) || (index1>23)) {
7f73eb6b 447 Error("Digits2Raw", "sector[0] = %d, sector[1] = %d",
448 digit.GetSector(0), digit.GetSector(1));
449 continue;
6de91202 450 }
abf60186 451 if((index2<0) || (index2>19)) {
6de91202 452 Error("Digits2Raw", "sector[0] = %d, sector[1] = %d",
453 digit.GetSector(0), digit.GetSector(1));
454 continue;
1450a7cd 455 }
1450a7cd 456
1450a7cd 457
1450a7cd 458 }
abf60186 459 //for(Int_t i=0;i<24;i++) printf("\t ADCData1[%d] = %x\n",i,lADCData1[i]);
460 //for(Int_t i=0;i<20;i++) printf("\t ADCData2[%d] = %x\n",i,lADCData2[i]);
7f73eb6b 461
6de91202 462 // End of Block
232b622f 463 UInt_t lADCEndBlockGEO = lADCHeaderGEO;
464 UInt_t lADCEndBlockEvCount = gAlice->GetEventNrInRun();
1450a7cd 465
232b622f 466 lADCEndBlock = lADCEndBlockGEO << 27 | 0x1 << 26 | lADCEndBlockEvCount;
1450a7cd 467
abf60186 468 //printf("\t ADCEndBlock = %d\n",lADCEndBlock);
6de91202 469
470
471 // open the output file
472 char fileName[30];
362c9d61 473 strcpy(fileName,AliDAQ::DdlFileName("ZDC",0));
6de91202 474#ifndef __DECCXX
475 ofstream file(fileName, ios::binary);
476#else
477 ofstream file(fileName);
478#endif
479
480 // write the DDL data header
481 AliRawDataHeader header;
7f73eb6b 482 header.fSize = sizeof(header) + sizeof(lADCHeader1) + sizeof(lADCData1) +
483 sizeof(lADCEndBlock)+ sizeof(lADCHeader2) + sizeof(lADCData2) + sizeof(lADCEndBlock);
abf60186 484 /*printf("sizeof header = %d, ADCHeader1 = %d, ADCData1 = %d, ADCEndBlock = %d\n",
485 sizeof(header),sizeof(lADCHeader1),sizeof(lADCData1),sizeof(lADCEndBlock));
486 printf("sizeof header = %d, ADCHeader2 = %d, ADCData2 = %d, ADCEndBlock = %d\n",
487 sizeof(header),sizeof(lADCHeader2),sizeof(lADCData2),sizeof(lADCEndBlock));*/
6de91202 488 header.SetAttribute(0); // valid data
489 file.write((char*)(&header), sizeof(header));
490
491 // write the raw data and close the file
7f73eb6b 492 file.write((char*) &lADCHeader1, sizeof (lADCHeader1));
493 file.write((char*)(lADCData1), sizeof(lADCData1));
494 file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock));
495 file.write((char*) &lADCHeader2, sizeof (lADCHeader2));
496 file.write((char*)(lADCData2), sizeof(lADCData2));
232b622f 497 file.write((char*) &lADCEndBlock, sizeof(lADCEndBlock));
6de91202 498 file.close();
499
500 // unload the digits
501 fLoader->UnloadDigits();
359cdddc 502}
503
b81c9821 504//______________________________________________________________________
505void AliZDC::SetTreeAddress(){
506 // Set branch address for the Trees.
507 // Inputs:
508 // none.
509 // Outputs:
510 // none.
511 // Return:
512 // none.
513 if (fLoader->TreeH() && (fHits == 0x0))
514 fHits = new TClonesArray("AliZDCHit",1000);
515
b81c9821 516 AliDetector::SetTreeAddress();
517}
359cdddc 518
8af17dba 519
520//Calibration methods (by Alberto Colla)
521
522
523//________________________________________________________________
524void AliZDC::CreateCalibData()
525{
526 //
527 //if (fCalibData) delete fCalibData; // delete previous version
528 fCalibData = new AliZDCCalibData(GetName());
529}
530//________________________________________________________________
531void AliZDC::WriteCalibData(Int_t option)
532{
533 //
534 const int kCompressLevel = 9;
4d81e5e7 535 char* fnam = GetZDCCalibFName();
8af17dba 536 if (!fnam || fnam[0]=='\0') {
232b622f 537 fnam = gSystem->ExpandPathName("$(ALICE)/$(ALICE_LEVEL)/data/AliZDCCalib.root");
8af17dba 538 Warning("WriteCalibData","No File Name is provided, using default %s",fnam);
539 }
540 TFile* cdfile = TFile::Open(fnam,"UPDATE","",kCompressLevel);
541
542 // Writes Calibration Data to current directory.
543 // User MUST take care of corresponding file opening and ->cd()... !!!
544 // By default, the object is overwritten. Use 0 option for opposite.
545 if (option) option = TObject::kOverwrite;
546 if (fCalibData) fCalibData->Write(0,option);
547 else if (fCalibData) fCalibData->Write(0,option);
548
549 cdfile->Close();
550 delete cdfile;
551}
552
553//________________________________________________________________
554void AliZDC::LoadCalibData()
555{
556 //
4d81e5e7 557 char* fnam = GetZDCCalibFName();
8af17dba 558 if (!fnam || fnam[0]=='\0') return;
559 if (!gAlice->IsFileAccessible(fnam)) {
560 Error("LoadCalibData","ZDC Calibration Data file is not accessible, %s",fnam);
561 exit(1);
562 }
563 TFile* cdfile = TFile::Open(fnam);
564
565 // Loads Calibration Data from current directory.
566 // User MUST take care of corresponding file opening and ->cd()...!!!
567 //
568 if (fCalibData) delete fCalibData; // delete previous version
569 TString dtname = "Calib_";
570 dtname += GetName();
571 fCalibData = (AliZDCCalibData*) gDirectory->Get(dtname.Data());
572 if (!fCalibData) {
573 Error("LoadCalibData","No Calibration data found for %s",GetName());
574 exit(1);
575 }
576
577 cdfile->Close();
578 delete cdfile;
579}
580
581
582//Calibration methods (by Alberto Colla)