New version of FMD code (A.Maevskaia)
[u/mrichter/AliRoot.git] / FMD / FMDMerger.C
CommitLineData
dc8af42e 1void FMDMerger (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
37c55dc0 12 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("pipe.root");
dc8af42e 13 if (file) file->Close();
37c55dc0 14 file = new TFile("galice.root","UPDATE");
dc8af42e 15 cout<<" Just starting... file "<<file<<endl;
16
17// Get AliRun object from file or create it if not on file
18
19 if (!gAlice) {
20 gAlice = (AliRun*)file->Get("gAlice");
21 if (gAlice) printf("AliRun object found on file\n");
22 if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
23 }
24 AliFMD *FMD = (AliFMD*) gAlice->GetModule("FMD");
dc8af42e 25
26 if (FMD) {
27// creation
28 AliFMDMerger* merger = new AliFMDMerger();
37c55dc0 29 cout<<" merger "<<merger<<endl;
30 /*
31 // granularity
32 merger->SetRingsSi1(128);
33 merger->SetRingsSi2(64);
34 merger->SetSectorsSi1(20);
35 merger->SetSectorsSi2(24);
36 */
dc8af42e 37// configuration
38 if (ibg) {
39 merger->SetMode(ibg);
40 merger->SetBackgroundFileName("bg.root");
37c55dc0 41 cout<<" background"<<endl;
dc8af42e 42 }
43 // pass
dc8af42e 44 FMD->SetMerger(merger);
45 }
46// Action !
47//
48// Loop over events
49//
50 for (int nev=evNumber1; nev<= evNumber2; nev++) {
51 Int_t nparticles = gAlice->GetEvent(nev);
52 cout << "nev " << nev <<endl;
53 cout << "nparticles " << nparticles <<endl;
54 if (nev < evNumber1) continue;
55 if (nparticles <= 0) return;
56 Int_t nbgr_ev = Int_t(nev*bgr/(evNumber2+1));
57 cout<<" nbgr_ev "<<nbgr_ev<<endl;
58
59 if (ibg) {
60 merger->SetBackgroundEventNumber(nbgr_ev);
61 }
62
63 gAlice->SDigits2Digits("FMD");
64
65 char hname[30];
66 sprintf(hname,"TreeD%d",nev);
67 // gAlice->TreeD()->Write(hname);
68 // cout<<hname<<" was written in file"<<file<<endl;
69 // gAlice->TreeD()->Print();
70 //reset tree
71 gAlice->TreeD()->Reset();
72
73 } // event loop
74}
75
76
77
78
79
80
81
82
83
84
85
86
87
88