]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONdigit.C
Double defined data members corrected.
[u/mrichter/AliRoot.git] / MUON / MUONdigit.C
1 #include "iostream.h"
2
3 void MUONdigit (Int_t evNumber1=0, Int_t evNumber2=9, Int_t ibg=1, Int_t bgr=10) 
4 {
5   //////////////////////////////////////
6   //                                  //
7   // ROOT macro for ALICE Dimuon Arm: //
8   // Digitization                     //
9   //                                  //
10   //////////////////////////////////////
11   //
12   // Adds the tree TD for digits (charges deposited on pads)
13   // to the ROOT file "galice.root"
14   // containing the signal hit coordinates from simulation (tree TH).
15   // Eventually (argument "ibg"), background hits are also taken into account,
16   // from the ROOT file "galice_bgr.root".
17   //
18   // Arguments:
19   //   evNumber1 = first event number to digitize in file "galice.root"
20   //   evNumber2 = last event number to digitize in file "galice.root"
21   //   ibg       = 0 if no background hits to be taken into account;
22   //             = 1 if  background hits to be taken into account
23   //                     in file "galice_bgr.root"
24   //   bgr       : used only if "ibg" = 1
25   //             = number of events in the background file "galice_bgr.root";
26   //               the signal events are divided into "bgr" successive parts,
27   //               all events of each part are associated
28   //               with the same background event,
29   //               starting with event number 0,
30   //               incrementing it by 1 for the next part.
31   //               Strictly speaking, "bgr" can be smaller than
32   //               the number of events in the background file,
33   //               in which case one will only use
34   //               the first "bgr" events of the background file.
35   //               But it SHOULD NOT BE LARGER THAN
36   //               THE NUMBER OF EVENTS IN THE BACKGROUND FILE.
37   //
38   // Input file(s):
39   //   "galice.root" for signal
40   //   "galice_bgr.root" for background (used only if "ibg" = 1)
41   //
42   // Output file:
43   //   "galice.root"
44   //
45   //__________________________________________________________________________
46
47 // Dynamically link some shared libs
48
49    if (gClassTable->GetID("AliRun") < 0) {
50       gROOT->LoadMacro("loadlibs.C");
51       loadlibs();
52    }
53
54 // Connect the Root Galice file containing Geometry, Kine and Hits
55
56    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
57    if (file) file->Close(); 
58    file = new TFile("galice.root","UPDATE");
59
60 // Get AliRun object from file or create it if not on file
61
62    if (!gAlice) {
63        gAlice = (AliRun*)file->Get("gAlice");
64        if (gAlice) printf("AliRun object found on file\n");
65        if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
66    }
67    printf ("I'm after gAlice \n");
68    
69    AliMUON *MUON  = (AliMUON*) gAlice->GetModule("MUON");
70
71 //
72 // Event Loop
73 //
74    Int_t nbgr_ev = 0;
75    
76    for (int nev=evNumber1; nev<= evNumber2; nev++) {
77        Int_t nparticles = gAlice->GetEvent(nev);
78        cout << "nev         " <<nev<<endl;
79        cout << "nparticles  " <<nparticles<<endl; 
80        if (nparticles <= 0) return;
81
82        nbgr_ev = Int_t(nev*bgr/(evNumber2+1));
83        
84        if (ibg) {
85          printf("nbgr_ev %d\n",nbgr_ev);
86          if (MUON) MUON->Digitise(nev,nbgr_ev,"Add"," ","galice_bgr.root");
87        } else {
88          if (MUON) MUON->Digitise(nev,nbgr_ev,"rien"," ","galice_bgr.root"); 
89        }
90
91    } // event loop 
92    file->Close();
93 }
94
95
96
97
98
99
100
101
102
103
104
105
106
107