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