Transition to NewIO
[u/mrichter/AliRoot.git] / ZDC / ZDCH2D2f.C
CommitLineData
79be9c7d 1// ------------------------------------------------------------
2// Macro for ZDC digitization
3// Macro arguments: totnev = num. of events to be processed
4// mode = 0 -> Only digitization (without merging) is performed
5// mode = 1 -> Signal for spectators is added to the generated
6// background and then the complete event is digitized
7// ------------------------------------------------------------
8void ZDCH2D2f(Int_t totnev=1, const char *filedig="ZDCdigits.root", Int_t mode=1)
9{
10 delete gAlice;
11 gAlice=0;
12
13 // Dynamically link some shared libs
14 if (gClassTable->GetID("AliRun") < 0) {
15 gROOT->LoadMacro("loadlibs.C");
16 loadlibs();
17 }
18
19 // Connect the Root Galice file containing Geometry, Kine, Hits and Digits
20 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
21 if (!file) {
22 printf("\n Creating galice.root \n");
23 file = new TFile("galice.root");
24 } else {
25 printf("\n galice.root found in file list");
26 }
27
28 // Get AliRun object from file or create it if not on file
29 if (!gAlice) {
30 gAlice = (AliRun*)file->Get("gAlice");
31 if (gAlice) printf("AliRun object found on file\n");
32 if (!gAlice) {
33 printf("\n create new gAlice object");
34 gAlice = new AliRun("gAlice","Alice test program");
35 }
36 }
37 // File where SDigits and Digits Tree are written
38 TFile *file2 = gAlice->InitTreeFile("SD", filedig);
39
40 AliZDC *ZDC = (AliZDC*) gAlice->GetModule("ZDC");
41 if (ZDC && mode) {
42 //printf("\n Initializing AliZDCMerger\n");
43 merger = new AliZDCMerger();
44 merger->SetMode(mode);
45 merger->SetBackgroundFileName("galice.root");
46 ZDC->SetMerger(merger);
47 }
48
49 //
50 // Loop over events
51 //
52 for(Int_t iev=0; iev<totnev; iev++) {
53 gAlice->GetEvent(iev);
54 if(mode){
55 merger->SetBackgroundEventNum(iev);
56 }
57 gAlice->MakeTree("S",file2);
58 gAlice->MakeTree("D",file2);
59 ZDC->MakeBranch("S");
60 ZDC->Hits2SDigits();
61 ZDC->MakeBranch("D");
62 ZDC->SDigits2Digits();
63 } // event loop
64}
65
66
67
68
69
70