1 ////////////////////////////////////////////////////////////////////////
3 // name: AliPHOSHits2SDigits
5 // last update: 4.4.2002
6 // author: Jiri Chudoba
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
16 // TString fileNameHits ... input file with hits
17 // TString fileNameSDigits ... output file with sdigits
21 // 04.04.02 - first version
23 ////////////////////////////////////////////////////////////////////////
26 Int_t AliPHOSHits2SDigits(TString
27 fileNameSDigits="PHOS.sdigits.root",TString fileNameHits="rfio:galice.root")
31 fileSDigits = Init(fileNameSDigits, fileNameHits);
32 if (!fileSDigits) return 1;
34 AliPHOSSDigitizer *sdPHOS = new AliPHOSSDigitizer(fileNameHits.Data(),"PHOS");
39 gAlice->MakeTree("S",fileSDigits);
40 sdPHOS->ExecuteTask("deb all");
51 ////////////////////////////////////////////////////////////////////////
52 TFile* Init(TString fileNameSDigits, TString fileNameHits) {
53 // open input file, read in gAlice, prepare output file
54 if (gAlice) delete gAlice;
57 Bool_t sameFiles = kFALSE;
58 if (fileNameSDigits == fileNameHits || fileNameSDigits == "") sameFiles = kTRUE;
60 TString fileMode = "read";
61 if (sameFiles) fileMode = "update";
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());
71 ////////////////////////////////////////////////////////////////////////
72 TFile* OpenFile(TString fileName, TString fileMode) {
74 TFile *file = TFile::Open(fileName.Data(),fileMode.Data());
75 if (!file->IsOpen()) {
76 cerr<<"Can't open "<<fileName.Data()<<" !\n";
82 ////////////////////////////////////////////////////////////////////////
83 Bool_t ImportgAlice(TFile *file) {
84 // read in gAlice object from the file
85 gAlice = (AliRun*)file->Get("gAlice");
86 if (!gAlice) return kFALSE;
89 ////////////////////////////////////////////////////////////////////////