]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONdigit.C
Use access methods to hit data.
[u/mrichter/AliRoot.git] / MUON / MUONdigit.C
1 void MUONdigit (Int_t evNumber1=0, Int_t evNumber2=0, Int_t ibg=0, Int_t bgr=10) 
2 {
3 // Dynamically link some shared libs
4
5    if (gClassTable->GetID("AliRun") < 0) {
6       gROOT->LoadMacro("loadlibs.C");
7       loadlibs();
8    }
9
10 // Connect the Root Galice file containing Geometry, Kine and Hits
11
12    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
13    if (file) file->Close(); 
14    file = new TFile("galice.root","UPDATE");
15
16 // Get AliRun object from file or create it if not on file
17
18    if (!gAlice) {
19        gAlice = (AliRun*)file->Get("gAlice");
20        if (gAlice) printf("AliRun object found on file\n");
21        if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
22    }
23    AliMUON *pMUON  = (AliMUON*) gAlice->GetModule("MUON");
24    if (pMUON) {
25 // creation
26        AliMUONMerger* merger = new AliMUONMerger();
27 // configuration
28        if (ibg) {
29          merger->SetMode(ibg);
30          merger->SetBackgroundFileName("bg.root");
31        }
32        // pass
33        pMUON->SetMerger(merger);
34    }
35 // Action !
36 //
37 //   Loop over events              
38 //
39     for (int nev=evNumber1; nev<= evNumber2; nev++) {
40         Int_t nparticles = gAlice->GetEvent(nev);
41         cout << "nev         " << nev <<endl;
42         cout << "nparticles  " << nparticles <<endl;
43         if (nev < evNumber1) continue;
44         if (nparticles <= 0) return;
45         Int_t nbgr_ev = Int_t(nev*bgr/(evNumber2+1));
46         
47         if (ibg) {
48             merger->SetBackgroundEventNumber(nbgr_ev);
49         }
50
51         gAlice->SDigits2Digits();
52
53         char hname[30];
54         sprintf(hname,"TreeD%d",nev);
55         gAlice->TreeD()->Write(hname);
56         // reset tree
57         gAlice->TreeD()->Reset();
58
59     }   // event loop 
60 }
61
62
63
64
65
66
67
68
69
70
71
72
73
74