-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathplot_hit_phos.C
More file actions
88 lines (78 loc) · 2.43 KB
/
plot_hit_phos.C
File metadata and controls
88 lines (78 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/// \file plot_hit_phos.C
/// \brief Simple macro to plot PHOS hits per event
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <sstream>
#include "TROOT.h"
#include "TTree.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH2.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "PHOSBase/Hit.h"
#include "DataFormatsPHOS/MCLabel.h"
#include "PHOSBase/Geometry.h"
#endif
void plot_hit_phos(int ievent = 0, TString inputfile = "AliceO2_TGeant3.phos.mc_10_event.root")
{
// macros to plot PHOS hits
TFile* file1 = TFile::Open(inputfile.Data());
TTree* hitTree = (TTree*)gFile->Get("o2sim");
std::vector<o2::phos::Hit>* mHitsArray = nullptr;
// o2::dataformats::MCTruthContainer<o2::MCCompLabel>* labels = nullptr;
hitTree->SetBranchAddress("PHSHit", &mHitsArray);
// digTree->SetBranchAddress("PHSDigitMCTruth", &labels);
if (!mHitsArray) {
std::cout << "PHOS hits not present. Exiting ..." << std::endl;
return;
}
hitTree->GetEvent(ievent);
TH2D* vMod[5][100] = {0};
int primLabels[5][100];
for (int mod = 1; mod < 5; mod++)
for (int j = 0; j < 100; j++)
primLabels[mod][j] = -1;
o2::phos::Geometry* geom = new o2::phos::Geometry("PHOS");
std::vector<o2::phos::Hit>::iterator it;
char relId[3];
// for(it=mHitsArray->begin(); it!=mHitsArray->end(); it++){
for (auto& it : *mHitsArray) {
short absId = it.GetDetectorID();
float en = it.GetEnergyLoss();
int lab = it.GetTrackID();
geom->absToRelNumbering(absId, relId);
// check, if this label already exist
int j = 0;
bool found = false;
while (primLabels[relId[0]][j] >= 0) {
if (primLabels[relId[0]][j] == lab) {
found = true;
break;
} else {
j++;
}
}
if (!found) {
primLabels[relId[0]][j] = lab;
}
if (!vMod[relId[0]][j]) {
gROOT->cd();
vMod[relId[0]][j] =
new TH2D(Form("hMod%d_prim%d", relId[0], j), Form("hMod%d_prim%d", relId[0], j), 64, 0., 64., 56, 0., 56.);
}
vMod[relId[0]][j]->Fill(relId[1] - 0.5, relId[2] - 0.5, en);
}
TCanvas* c[5];
for (int mod = 1; mod < 5; mod++) {
c[mod] =
new TCanvas(Form("HitInMod%d", mod), Form("PHOS hits in module %d", mod), 10 * mod, 0, 600 + 10 * mod, 400);
int j = 0;
while (vMod[mod][j]) {
vMod[mod][j]->SetLineColor(j + 1);
if (j == 0)
vMod[mod][j]->Draw("box");
else
vMod[mod][j]->Draw("boxsame");
j++;
}
}
}