]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSHits2SDigitsDefault.C
Functions for bitio. Taken as is from The Data Compression Book
[u/mrichter/AliRoot.git] / ITS / AliITSHits2SDigitsDefault.C
CommitLineData
d4b94d24 1Int_t AliITSHits2SDigitsDefault(const char *inFile = "galice.root"){
2603d98a 2
3 // Dynamically link some shared libs
4 if (gClassTable->GetID("AliRun") < 0) {
5 gROOT->LoadMacro("loadlibs.C");
6 loadlibs();
7 } // end if
8
d4b94d24 9 // Connect the Root Galice file containing Geometry, Kine and Hits
10
11 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
12 if (file) {file->Close(); delete file;}
2603d98a 13 cout << "AliITSHits2SDigitsDefault" << endl;
d4b94d24 14 file = new TFile(inFile,"UPDATE");
15 if (!file->IsOpen()) {
16 cerr<<"Can't open "<<inFile<<" !" << endl;
17 return 1;
18 } // end if !file
19 file->ls();
20
21 // Get AliRun object from file or return if not on file
22 if (gAlice) delete gAlice;
23 gAlice = (AliRun*)file->Get("gAlice");
24 if (!gAlice) {
25 cerr << "AliITSITSHits2Digits.C : AliRun object not found on file"
26 << endl;
27 return 2;
28 } // end if !gAlice
29
30 gAlice->GetEvent(0);
31 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
32 if (!ITS) {
33 cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
34 << endl;
35 return 3;
36 } // end if !ITS
2603d98a 37 if(!(ITS->GetITSgeom())){
38 cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
39 return 4;
40 } // end if
d4b94d24 41
42 if(!gAlice->TreeS()){
43 cout << "Having to create the SDigits Tree." << endl;
44 gAlice->MakeTree("S");
45 } // end if !gAlice->TreeS()
46 //make branch
47 ITS->MakeBranch("S");
48 ITS->SetTreeAddress();
49 cout << "Digitizing ITS..." << endl;
50
51 TStopwatch timer;
52 Long_t size0 = file->GetSize();
53 timer.Start();
54 ITS->Hits2SDigits();
55 timer.Stop(); timer.Print();
56
57 delete gAlice; gAlice=0;
58 file->Close();
59 Long_t size1 = file->GetSize();
60 cout << "File size before = " << size0 << " file size after = " << size1;
61 cout << "Increase in file size is " << size1-size0 << " Bytes" << endl;
62 delete file;
63 return 0;
64};
65