-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathplot_dig_cpv.C
More file actions
106 lines (96 loc) · 3.22 KB
/
plot_dig_cpv.C
File metadata and controls
106 lines (96 loc) · 3.22 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <sstream>
#include <iostream>
#include "TROOT.h"
#include <TStopwatch.h>
#include "TCanvas.h"
#include "TH2.h"
#include "TH1.h"
//#include "DataFormatsParameters/GRPObject.h"
#include "FairFileSource.h"
#include <fairlogger/Logger.h>
#include "FairRunAna.h"
//#include "FairRuntimeDb.h"
#include "FairParRootFileIo.h"
#include "FairSystemInfo.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "DataFormatsCPV/Digit.h"
#include "CPVBase/Geometry.h"
#endif
void plot_dig_cpv(int ievent = 0, std::string inputfile = "o2dig.root")
{
// macros to plot CPV digits
// Digits
TFile* file0 = TFile::Open(inputfile.data());
std::cout << " Open digits file " << inputfile << std::endl;
TTree* hitTree = (TTree*)gFile->Get("o2sim");
std::vector<o2::cpv::Digit>* mDigitsArray = nullptr;
hitTree->SetBranchAddress("CPVDigit", &mDigitsArray);
if (!mDigitsArray) {
std::cout << "CPV digits not found in the file. Exiting ..." << std::endl;
return;
}
hitTree->GetEvent(ievent);
TH1F* hDigitAmplitude[5];
TH2D* vMod[5][1000] = {0};
int primLabels[5][1000];
for (int mod = 1; mod < 5; mod++) {
hDigitAmplitude[mod] = new TH1F(Form("hDigitAmplitude_mod%d", mod),
Form("Digit amplitudes in module %d", mod),
4096, 0., 4096.);
for (int j = 0; j < 100; j++)
primLabels[mod][j] = -1;
}
std::vector<o2::cpv::Digit>::const_iterator it;
short relId[3];
std::cout << "I start digit cycling" << std::endl;
for (it = mDigitsArray->begin(); it != mDigitsArray->end(); it++) {
short absId = (*it).getAbsId();
float en = (*it).getAmplitude();
int lab = (*it).getLabel(); //TODO
//std::cout << "label = " << lab << std::endl;
o2::cpv::Geometry::absToRelNumbering(absId, relId);
hDigitAmplitude[relId[0]]->Fill(en);
// check, if this label already exist
int j = 0;
bool found = false;
//no labels for the time being
// while (primLabels[relId[0]][j] >= -2) {
// 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), 128, 0., 128., 60, 0., 60.);
}
vMod[relId[0]][j]->Fill(relId[1] - 0.5, relId[2] - 0.5, en);
}
std::cout << "I finish cycling digits" << std::endl;
TCanvas *c[5], *c_ampl[5];
TH2D* box = new TH2D("box", "CPV module", 128, 0., 128., 60, 0., 60.);
for (int mod = 2; mod < 5; mod++) {
c[mod] =
new TCanvas(Form("DigitInMod%d", mod), Form("CPV digits in module %d", mod), 10 * mod, 0, 600 + 10 * mod, 400);
box->Draw();
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++;
}
c_ampl[mod] = new TCanvas(Form("DigitAmplitudes_%d", mod), Form("DigitAmplitudes_%d", mod),
10 * mod + 800, 0, 600 + 10 * mod + 200, 400);
hDigitAmplitude[mod]->Draw();
}
}