]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHitsToSDigitsDefault.C
Functions for bitio. Taken as is from The Data Compression Book
[u/mrichter/AliRoot.git] / ITS / AliITSHitsToSDigitsDefault.C
1 Int_t AliITSHitsToSDigitsDefault(const char *inFile="galice.root"){
2 /////////////////////////////////////////////////////////////////////////
3 //   This macro is a small example of a ROOT macro
4 //   illustrating how to read the output of GALICE
5 //   and do some analysis.
6 //   
7 /////////////////////////////////////////////////////////////////////////
8
9     // Dynamically link some shared libs
10     if (gClassTable->GetID("AliRun") < 0) {
11         gROOT->LoadMacro("loadlibs.C");
12         loadlibs();
13     } // end if
14
15     // Connect the Root Galice file containing Geometry, Kine and Hits
16   
17     TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
18     if (file) {file->Close(); delete file;}
19     cout << "AliITSHits2SDigitsDefault" << endl;
20     file = new TFile(inFile,"UPDATE");
21     if (!file->IsOpen()) {
22         cerr<<"Can't open "<<inFile<<" !" << endl;
23         return 1;
24     } // end if !file
25     file->ls();
26
27     // Get AliRun object from file or create it if not on file
28     if (gAlice) delete gAlice;
29     gAlice = (AliRun*)file->Get("gAlice");
30     if (!gAlice) {
31         cerr << "AliITSITSHits2Digits.C : AliRun object not found on file"
32             << endl;
33         return 2;
34     } // end if !gAlice
35
36     gAlice->GetEvent(0);
37     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
38     if (!ITS) {
39         cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
40             << endl;
41         return 3;
42     }  // end if !ITS
43     if(!(ITS->GetITSgeom())){
44         cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
45         return 4;
46     } // end if
47
48     if(!gAlice->TreeS()){ 
49         cout << "Having to create the SDigits Tree." << endl;
50         gAlice->MakeTree("S");
51     } // end if !gAlice->TreeS()
52     //make branch
53     ITS->MakeBranch("S");
54     ITS->SetTreeAddress();
55     gAlice->GetEvent(0);
56     cout<<"SDigitizing ITS..." << endl;
57
58     TStopwatch timer;
59     Long_t size0 = file->GetSize();
60
61     for (Int_t nev=evNumber1; nev<= evNumber2; nev++) {
62         cout << "nev         " <<nev<<endl;
63         if(nev>0) {
64             gAlice->SetEvent(nev);
65             if(!gAlice->TreeD()) gAlice->MakeTree("D");
66             ITS->MakeBranch("D");
67         } // end if nev>0
68         if (nev < evNumber1) continue;
69         timer.Start();
70         ITS->HitsToDigits(nev,0,-1," ","All"," ");
71         timer.Stop(); timer.Print();
72     } // event loop
73
74     delete gAlice;   gAlice=0;
75     file->Close();
76     Long_t size1 = file->GetSize();
77     cout << "File size before = " << size0 << " file size after = " << size1;
78     cout << "Increase in file size is " << size1-size0 << " Bytes" << endl;
79     delete file;
80     return 0;
81 };