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