Make separate, specialized geometries for RPhi and RhoZ views.
[u/mrichter/AliRoot.git] / PHOS / AliPHOSHits2SDigits.C
CommitLineData
811188e6 1////////////////////////////////////////////////////////////////////////
2//
3// name: AliPHOSHits2SDigits
4// date: 4.4.2002
5// last update: 4.4.2002
6// author: Jiri Chudoba
7// version: 1.0
8//
9// description:
10// creates sdigits for digits for PHOS.
11// stores sdigits in separate file (or in the source file
12// with hits). Stores gAlice object and copies TE to the
13// file with sdigits.
14//
15// input:
16// TString fileNameHits ... input file with hits
17// TString fileNameSDigits ... output file with sdigits
18//
19// History:
20//
21// 04.04.02 - first version
22//
23////////////////////////////////////////////////////////////////////////
24
25
26Int_t AliPHOSHits2SDigits(TString
27fileNameSDigits="PHOS.sdigits.root",TString fileNameHits="rfio:galice.root")
28
29{
30 TFile *fileSDigits;
31 fileSDigits = Init(fileNameSDigits, fileNameHits);
32 if (!fileSDigits) return 1;
33
34 AliPHOSSDigitizer *sdPHOS = new AliPHOSSDigitizer(fileNameHits.Data(),"PHOS");
35
36 TStopwatch timer;
37 timer.Start();
38
39 gAlice->MakeTree("S",fileSDigits);
40 sdPHOS->ExecuteTask("deb all");
41
42 timer.Stop();
43 timer.Print();
44
45 fileSDigits->Close();
46 delete fileSDigits;
47
48}
49
50
51////////////////////////////////////////////////////////////////////////
52TFile* Init(TString fileNameSDigits, TString fileNameHits) {
53// open input file, read in gAlice, prepare output file
54 if (gAlice) delete gAlice;
55 gAlice = 0;
56
57 Bool_t sameFiles = kFALSE;
58 if (fileNameSDigits == fileNameHits || fileNameSDigits == "") sameFiles = kTRUE;
59
60 TString fileMode = "read";
61 if (sameFiles) fileMode = "update";
62
63 TFile *fileHits = OpenFile(fileNameHits.Data(),fileMode.Data());
64 if (!fileHits) return 0;
65 if (!ImportgAlice(fileHits)) return 0;
66 if (!sameFiles) return gAlice->InitTreeFile("S",fileNameSDigits.Data());
67 return fileHits;
68
69}
70
71////////////////////////////////////////////////////////////////////////
72TFile* OpenFile(TString fileName, TString fileMode) {
73// open file fileName
74 TFile *file = TFile::Open(fileName.Data(),fileMode.Data());
75 if (!file->IsOpen()) {
76 cerr<<"Can't open "<<fileName.Data()<<" !\n";
77 return 0;
78 }
79 return file;
80}
81
82////////////////////////////////////////////////////////////////////////
83Bool_t ImportgAlice(TFile *file) {
84// read in gAlice object from the file
85 gAlice = (AliRun*)file->Get("gAlice");
86 if (!gAlice) return kFALSE;
87 return kTRUE;
88}
89////////////////////////////////////////////////////////////////////////