corrected TRD/TOF MV position
[u/mrichter/AliRoot.git] / TOF / TOFMerger.C
CommitLineData
517b7f8f 1void TOFMerger (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 AliTOF *TOF = (AliTOF*) gAlice->GetModule("TOF");
24 cout<<" TOFMerger:: TOF "<<TOF<<" gAlice "<<gAlice<<endl;
25
26 if (TOF) {
27// ctor invocation
28 AliTOFMerger* merger = new AliTOFMerger();
29// configuration
30 if (ibg) {
31 merger->SetMode(ibg);
32 merger->SetBackgroundFileName("bg.root");
33 }
34 // pass signal filename
35 // merger->SetSignalFileName("galice.root");
36 TOF->SetMerger(merger);
37 }
38
39// Loop over events
40//
41 for (int nev=evNumber1; nev<= evNumber2; nev++) {
42 Int_t nparticles = gAlice->GetEvent(nev);
43 cout << "nev " << nev <<endl;
44 cout << "nparticles " << nparticles <<endl;
45 if (nev < evNumber1) continue;
46 if (nparticles <= 0) return;
47 Int_t nbgr_ev = Int_t(nev*bgr/(evNumber2+1));
48 cout<<" nbgr_ev "<<nbgr_ev<<endl;
49
50 if (ibg) {
51 merger->SetBackgroundEventNumber(nbgr_ev);
52 }
53
54 gAlice->SDigits2Digits("TOF");
55
56 char hname[30];
57 sprintf(hname,"TreeD%d",nev);
58 // gAlice->TreeD()->Write(hname);
59 // cout<<hname<<" was written in file"<<file<<endl;
60 // gAlice->TreeD()->Print();
61 //reset tree
62 gAlice->TreeD()->Reset();
63
64 } // event loop
65}
66
67
68
69
70
71
72
73
74
75
76
77
78
79