]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONtestzaza.C
Protect against no current file in FinishEvent
[u/mrichter/AliRoot.git] / MUON / MUONtestzaza.C
1 // option 1 : idres=114    if j/psi
2 //            idres=116    if upsilon
3
4 // option 2 : ireadgeant=1 if geant hits
5 //            ireadgeant=0 if space points
6
7 // option 3 : ibgr=1 if upsilon+background (option 3 usefull only for geant hits) 
8 //            ibgr=0 if no background
9
10 void MUONtestzaza (Int_t evNumber1=0, Int_t evNumber2=99, Int_t idres=116, Int_t ireadgeant=1, Int_t ibgr=0) 
11 {
12 /////////////////////////////////////////////////////////////////////////
13 //   This macro is a small example of a ROOT macro
14 //   illustrating how to read the output of GALICE
15 //   and do some analysis.
16 //   
17 /////////////////////////////////////////////////////////////////////////
18
19 // Dynamically link some shared libs                    
20
21    if (gClassTable->GetID("AliRun") < 0) {
22       gROOT->LoadMacro("loadlibs.C");
23       loadlibs();
24    }
25 // Connect the Root Galice file containing Geometry, Kine and Hits
26
27     TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
28     
29     if (!file) {
30         printf("\n Creating galice.root \n");
31         file = new TFile("galice.root");
32     } else {    printf("\n galice.root found in file list");
33     }
34     //    file->ls();
35     
36 // Get AliRun object from file or create it if not on file
37     if (!gAlice) {
38         gAlice = (AliRun*)(file->Get("gAlice"));
39         if (gAlice) printf("AliRun object found on file\n");
40         if (!gAlice) {
41             printf("\n create new gAlice object");
42             gAlice = new AliRun("gAlice","Alice test program");
43         }
44     }
45     
46     Double_t seff  = 0.95;
47     Double_t sb0   = 0.7;
48     Double_t sbl3  = 0.2;
49
50     Int_t ifit   = 0;
51     Int_t idebug = 1;
52
53     AliMUON *MUON  = (AliMUON*) gAlice->GetModule("MUON");
54     
55     Int_t nparticles = gAlice->GetEvent(evNumber1);
56     if (nparticles <= 0) return;
57     MUON->Init(seff,sb0,sbl3);
58 //   Loop over events 
59 //
60     Int_t inev_bgd=0;
61     Int_t nev_bgd=4;
62     
63     for (Int_t nev= evNumber1; nev<= evNumber2; nev++) 
64     {
65         printf("nev=%d\n",nev);
66         if (nev != evNumber1) Int_t nparticles = gAlice->GetEvent(nev);
67         if (nev < evNumber1) continue;
68         if (nparticles <= 0) return;
69         MUON->FinishEvent();
70         if (ireadgeant==1 && ibgr==1) {
71           if (inev_bgd==nev_bgd) inev_bgd=0;
72           MUON->Reconst(ifit,idebug,inev_bgd,nev,idres,ireadgeant,"Add","galice_bgr.root");
73           inev_bgd++;
74         }
75         else
76           MUON->Reconst(ifit,idebug,inev_bgd,nev,idres,ireadgeant,"rien1","rien2");
77         MUON->FinishEvent();
78
79
80         
81     } // event loop 
82     
83     MUON->Close();
84 }
85
86
87