]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFtestDigitizer.C
Correcting some trivial warnings on Alpha
[u/mrichter/AliRoot.git] / TOF / AliTOFtestDigitizer.C
CommitLineData
8e72349e 1////////////////////////////////////////////////////////////////////////
2//
3// name: AliTOFtestDigitizer
4// date: 11-VI-2002
5// last update: 11-VI-2002
6// author: F. Pierella | pierella@bo.infn.it
7// version: 1.0
8//
9// description:
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
13// file with digits
14//
15// input:
16// TString fileNameSDigits ... input file with sdigits
17// TString fileNameDigits ... output file with digits
18// Int_t nEvents ... how many events to process
19//
20
21#if !defined(__CINT__) || defined(__MAKECINT__)
22#include "iostream.h"
23#include "AliTOFDigitizer.h"
24#include "../STEER/AliRunDigitizer.h"
25#include "../STEER/AliDigitizer.h"
26#include "TStopwatch.h"
27#endif
28
29//#include "AliHits2SDigits.C"
30
31TFile* OpenFile(TString fileName);
32Bool_t ImportgAlice(TFile *file);
33void AliCopyN(TString inputFile, TString outputFile);
34void AliCopy(TFile *inputFile, TFile *outputFile);
35Int_t gDEBUG = 1;
36
37
38Int_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)
41{
42// delete the current gAlice object, the one from input file
43// will be used
44
45 if(gAlice){
46 delete gAlice;
47 gAlice = 0;
48 } // end if gAlice
49 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
50 manager->SetInputStream(0,fileNameSDigits.Data());
51 if (fileNameDigits != "") {
52 if (iCopy) {
53 AliCopyN(fileNameSDigits,fileNameDigits);
54 }
55 manager->SetOutputFile(fileNameDigits);
56 }
57 manager->SetNrOfEventsToWrite(nEvents);
58 if (iTOF) AliTOFDigitizer *dTOF = new AliTOFDigitizer(manager);
59 TStopwatch timer;
60 timer.Start();
61 manager->Exec("deb all");
62 timer.Stop();
63 timer.Print();
64 delete manager;
65}
66
67
68////////////////////////////////////////////////////////////////////////
69void AliCopyN(TString inputFileName, TString outputFileName) {
70// copy some objects
71
72 TFile *inputFile = OpenFile(inputFileName);
73 if (!inputFile) return;
74
75 TFile *outputFile = TFile::Open(outputFileName.Data(),"update");
76 if (!outputFile->IsOpen()) {
77 cerr<<"Can't open "<<outputFileName.Data()<<" !\n";
78 return;
79 }
80 if (!ImportgAlice(inputFile)) return;
81 AliCopy(inputFile, outputFile);
82 inputFile->Close();
83 delete inputFile;
84 outputFile->Close();
85 delete outputFile;
86}
87
88////////////////////////////////////////////////////////////////////////
89TFile* OpenFile(TString fileName) {
90 // open file fileName
91 TFile *file = TFile::Open(fileName.Data());
92 if (!file->IsOpen()) {
93 cerr<<"Can't open "<<fileName.Data()<<" !\n";
94 return 0;
95 }
96 return file;
97}
98
99////////////////////////////////////////////////////////////////////////
100Bool_t ImportgAlice(TFile *file) {
101 // read in gAlice object from the file
102 gAlice = (AliRun*)file->Get("gAlice");
103 if (!gAlice) return kFALSE;
104 return kTRUE;
105}
106
107////////////////////////////////////////////////////////////////////////
108void AliCopy(TFile *inputFile, TFile *outputFile) {
109// copy some objects
110
111// copy gAlice
112 if (gDEBUG) cout<<"Copy gAlice: ";
113 outputFile->cd();
114 gAlice->Write();
115 if (gDEBUG) cout<<"done"<<endl;
116
117 TTree *treeE = gAlice->TreeE();
118 if (!treeE) {
119 cerr<<"No TreeE found "<<endl;
120 return;
121 }
122
123// copy TreeE
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();
129 treeENew->Write();
130 if (gDEBUG) cout<<"done"<<endl;
131
132// copy AliceGeom
133 if (gDEBUG) cout<<"Copy AliceGeom: ";
134 TGeometry *AliceGeom = static_cast<TGeometry*>(inputFile->Get("AliceGeom"));
135 if (!AliceGeom) {
136 cerr<<"AliceGeom was not found in the input file "<<endl;
137 return;
138 }
139 AliceGeom->Write();
140 if (gDEBUG) cout<<"done"<<endl;
141
142}
143