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