]> git.uio.no Git - u/mrichter/AliRoot.git/blob - macros/printProfile.C
4a1c5974e57336e6329cdb0f8b063b4e306e9877
[u/mrichter/AliRoot.git] / macros / printProfile.C
1 void printProfile(char* g3 = "geant3/timing_200_woZDC.root", char* g4 ="geant4/timing_200_woZDC.root")
2 {
3   // Create monitors 
4   AliTransportMonitor* mon3 = AliTransportMonitor::Import(g3);
5   AliTransportMonitor* mon4 = AliTransportMonitor::Import(g4);
6   //
7   // Create timing histos and volume lists
8   mon3->Print();
9   tH3 = (TH1F*) volume_timing->Clone();
10   TObjArray* volumes3 = mon3->GetVolumes(); 
11   mon4->Print();
12   tH4 = (TH1F*) volume_timing->Clone();
13   TObjArray* volumes4 = mon4->GetVolumes(); 
14   //
15   // Normalise the geant 3 histo
16   // Fraction of time in %
17   Float_t ri = tH3->Integral();
18   tH3->Scale(100./ri);
19   //
20   Float_t cumulant = 0.;  // cumulant
21   Int_t   i = 1;          // position in list
22   //
23   // print up to 90% of total time
24   //
25   printf(" Pos.               Volume  t (%) ct (%)  Time_G3  Time_G4 perStepG3 perStepG4   StepsG3   StepsG4    te+e-     tgam     thad     te+e-    tgam     thad\n"); 
26   while (cumulant < 90.) {
27     Float_t rt = tH3->GetBinContent(i);
28     cumulant += rt;
29     // extract the corresponding geant3 and geant4 volumes
30     char* volN = (tH3->GetXaxis())->GetBinLabel(i);
31   AliTransportMonitor::AliTransportMonitorVol* vol4 = (AliTransportMonitor::AliTransportMonitorVol*) 
32     volumes4->FindObject(volN);
33   AliTransportMonitor::AliTransportMonitorVol* vol3 = 0;
34     if (i > 1) {
35       vol3 = (AliTransportMonitor::AliTransportMonitorVol*) 
36         volumes3->FindObject(volN);
37     } else {
38       vol3 = (AliTransportMonitor::AliTransportMonitorVol*) 
39         volumes3->At(1);
40      }
41     // Total time
42     
43     Float_t t4[5]; 
44     t4[0] = vol4->GetTotalTime();
45     Float_t t3[5]; 
46     t3[0] = vol3->GetTotalTime();
47
48     // For e+/e-
49     t4[1] = ElectronTime(vol4);
50     t3[1] = ElectronTime(vol3);
51  
52     // For photons
53     t4[2] = PhotonTime(vol4);
54     t3[2] = PhotonTime(vol3);
55    
56     // Hadrons
57     t4[3] = HadronTime(vol4);
58     t3[3] = HadronTime(vol3);
59    
60     printf("%5d %20s %6.2f %6.2f %8.3f %8.3f %8.3e %8.3e %8.3e %8.3e %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n", 
61            i,
62            volN,
63            rt, cumulant, t3[0], t4[0], t3[0]/(1.+vol3->GetNSteps()), 
64            t4[0]/(1.+vol4->GetNSteps()), vol3->GetNSteps(), vol4->GetNSteps(),
65            t3[1]/t3[0] * 100., t3[2]/t3[0] * 100., t3[3]/t3[0] * 100.,
66            t4[1]/t4[0] * 100., t4[2]/t4[0] * 100., t4[3]/t4[0] * 100.
67
68            );
69     i++;
70   }
71 }
72
73 Float_t ElectronTime(AliTransportMonitor::AliTransportMonitorVol* vol)
74 {
75    Int_t nt = vol->GetNtypes();
76    Float_t t = 0.;
77    for (Int_t i = 0; i < nt; i++) {
78      Int_t pdg = TMath::Abs(vol->GetPDG(i));
79      if (pdg == 11) t += vol->GetTime(i);
80    }
81
82    return t;
83 }
84
85 Float_t PhotonTime(AliTransportMonitor::AliTransportMonitorVol* vol)
86 {
87    Int_t nt = vol->GetNtypes();
88    Float_t t = 0.;
89    for (Int_t i = 0; i < nt; i++) {
90      Int_t pdg = TMath::Abs(vol->GetPDG(i));
91      if (pdg == 22) t += vol->GetTime(i);
92    }
93    return t;
94 }
95
96 Float_t HadronTime(AliTransportMonitor::AliTransportMonitorVol* vol)
97 {
98    Int_t nt = vol->GetNtypes();
99    Float_t t = 0.;
100    for (Int_t i = 0; i < nt; i++) {
101      Int_t pdg = TMath::Abs(vol->GetPDG(i));
102      if (pdg == 211 || pdg == 2212 || pdg == 2112 || pdg == 130 || pdg == 321) t += vol->GetTime(i);
103    }
104    return t;
105 }
106
107