1 ////////////////////////////////////////////////////////////////////////
3 // name: AliTOFtestDigitizer
5 // last update: 11-VI-2002
6 // author: F. Pierella | pierella@bo.infn.it
10 // creates digits from sdigits for TOF detector
11 // stores sdigits in separate file (or in the source file
12 // with sdigits). Stores gAlice object and copies TE to the
16 // TString fileNameSDigits ... input file with sdigits
17 // TString fileNameDigits ... output file with digits
18 // Int_t nEvents ... how many events to process
21 #if !defined(__CINT__) || defined(__MAKECINT__)
23 #include "AliTOFDigitizer.h"
24 #include "../STEER/AliRunDigitizer.h"
25 #include "../STEER/AliDigitizer.h"
26 #include "TStopwatch.h"
29 //#include "AliHits2SDigits.C"
31 TFile* OpenFile(TString fileName);
32 Bool_t ImportgAlice(TFile *file);
33 void AliCopyN(TString inputFile, TString outputFile);
34 void AliCopy(TFile *inputFile, TFile *outputFile);
38 Int_t AliTOFtestDigitizer(TString fileNameDigits="digits.root",
39 TString fileNameSDigits="rfio:sdigits.root",
40 Int_t nEvents = 1, Int_t iTOF = 1, Int_t iCopy = 1)
42 // delete the current gAlice object, the one from input file
49 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
50 manager->SetInputStream(0,fileNameSDigits.Data());
51 if (fileNameDigits != "") {
53 AliCopyN(fileNameSDigits,fileNameDigits);
55 manager->SetOutputFile(fileNameDigits);
57 manager->SetNrOfEventsToWrite(nEvents);
58 if (iTOF) AliTOFDigitizer *dTOF = new AliTOFDigitizer(manager);
61 manager->Exec("deb all");
68 ////////////////////////////////////////////////////////////////////////
69 void AliCopyN(TString inputFileName, TString outputFileName) {
72 TFile *inputFile = OpenFile(inputFileName);
73 if (!inputFile) return;
75 TFile *outputFile = TFile::Open(outputFileName.Data(),"update");
76 if (!outputFile->IsOpen()) {
77 cerr<<"Can't open "<<outputFileName.Data()<<" !\n";
80 if (!ImportgAlice(inputFile)) return;
81 AliCopy(inputFile, outputFile);
88 ////////////////////////////////////////////////////////////////////////
89 TFile* OpenFile(TString fileName) {
91 TFile *file = TFile::Open(fileName.Data());
92 if (!file->IsOpen()) {
93 cerr<<"Can't open "<<fileName.Data()<<" !\n";
99 ////////////////////////////////////////////////////////////////////////
100 Bool_t ImportgAlice(TFile *file) {
101 // read in gAlice object from the file
102 gAlice = (AliRun*)file->Get("gAlice");
103 if (!gAlice) return kFALSE;
107 ////////////////////////////////////////////////////////////////////////
108 void AliCopy(TFile *inputFile, TFile *outputFile) {
112 if (gDEBUG) cout<<"Copy gAlice: ";
115 if (gDEBUG) cout<<"done"<<endl;
117 TTree *treeE = gAlice->TreeE();
119 cerr<<"No TreeE found "<<endl;
124 if (gDEBUG) cout<<"Copy TreeE: ";
125 AliHeader *header = new AliHeader();
126 treeE->SetBranchAddress("Header", &header);
127 treeE->SetBranchStatus("*",1);
128 TTree *treeENew = treeE->CloneTree();
130 if (gDEBUG) cout<<"done"<<endl;
133 if (gDEBUG) cout<<"Copy AliceGeom: ";
134 TGeometry *AliceGeom = static_cast<TGeometry*>(inputFile->Get("AliceGeom"));
136 cerr<<"AliceGeom was not found in the input file "<<endl;
140 if (gDEBUG) cout<<"done"<<endl;