]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHits2DigitsDefault.C
Functions for bitio. Taken as is from The Data Compression Book
[u/mrichter/AliRoot.git] / ITS / AliITSHits2DigitsDefault.C
1 Int_t AliITSHits2DigitsDefault(const char *inFile = "galice.root"){
2     ////////////////////////////////////////////////////////////////////
3     //      This macro will take hits from a galice.root file and 
4     // produce digits for the ITS using the standard detector 
5     // simulations. It will measure the time required to do so and the
6     // increase in the galice.root file. There is only one input, that
7     // of the name of the root file containing the hits and to which the
8     // digits will be written to. This macro will process all of the 
9     // events on the root file.
10     ////////////////////////////////////////////////////////////////////
11
12     // Dynamically link some shared libs
13     if (gClassTable->GetID("AliRun") < 0) {
14         gROOT->LoadMacro("loadlibs.C");
15         loadlibs();
16     } // end if
17
18     // Connect the Root Galice file containing Geometry, Kine and Hits
19   
20     TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
21     if (file) {file->Close(); delete file;}
22     cout << "AliITSHits2DigitsDefault" << endl;
23     file = new TFile(inFile,"UPDATE");
24     if (!file->IsOpen()) {
25         cerr<<"Can't open "<<inFile<<" !" << endl;
26         return 1;
27     } // end if !file
28     file->ls();
29
30     // Get AliRun object from file or return if not on file
31     if (gAlice) delete gAlice;
32     gAlice = (AliRun*)file->Get("gAlice");
33     if (!gAlice) {
34         cerr << "AliITSITSHits2Digits.C : AliRun object not found on file"
35             << endl;
36         return 2;
37     } // end if !gAlice
38
39     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
40     if (!ITS) {
41         cerr<<"ITSHits2Digits.C : AliITS object not found on file" << endl;
42         return 3;
43     }  // end if !ITS
44     if(!(ITS->GetITSgeom())){
45         cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
46         return 4;
47     } // end if
48     cout << "Digitizing ITS..." << endl;
49
50     TStopwatch timer;
51     Long_t size0 = file->GetSize();
52     timer.Start();
53     gAlice->Hits2Digits("ITS");
54     timer.Stop(); timer.Print();
55
56     file->Close();
57     Long_t size1 = file->GetSize();
58     cout << "File size before = " << size0 << " file size after = " << size1;
59     cout << "Increase in file size is " << size1-size0 << " Bytes" << endl;
60     delete file;
61     return 0;
62 };
63