-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawtimehists.C
110 lines (100 loc) · 2.11 KB
/
drawtimehists.C
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
107
108
109
110
int UnitNumber;
int ChannelNumber;
TFile *RootFile;
FILE *RepFile;
TCanvas *cv;
TH1D *hSum;
int Open(const char *name)
{
char str[1024];
char *ptr;
strncpy(str, name, sizeof(str)-10);
ptr = strrchr(str, '.');
if (!ptr) ptr = strchr(str, '\0');
strcpy(ptr, ".log");
RootFile = new TFile(name);
if (!RootFile->IsOpen()) return -1;
RepFile = fopen(str, "wt");
UnitNumber = 1;
ChannelNumber = 0;
return 0;
}
int Draw(int update = 1)
{
char str[128];
int i;
TH1 *h;
int cnt = 0;
if (!RootFile->IsOpen()) return 0;
cv = (TCanvas *) gROOT->FindObject("CVT");
if (!cv) cv = new TCanvas("CVT", "Canvas", 1500, 1200);
cv->Clear();
cv->Divide(4, 4);
for (i=0; i<16; i++) {
cv->cd(i+1);
sprintf(str, "hDTP%2.2dc%2.2d", UnitNumber, ChannelNumber + i);
h = (TH1 *) RootFile->Get(str);
if (h) {
h->Draw();
hSum->Add(h);
cnt++;
if (h->GetEntries() > 1000 && RepFile)
fprintf(RepFile, "Channel=%2.2d.%2.2d DT=%6.1f\n", UnitNumber, ChannelNumber + i, h->GetMean());
}
}
if (update) cv->Update();
return cnt;
}
void Next(void)
{
Draw();
ChannelNumber += 16;
if (ChannelNumber >= 64) {
ChannelNumber = 0;
UnitNumber++;
if (UnitNumber >= 50) UnitNumber = 0;
}
}
void Prev(void)
{
Draw();
ChannelNumber -= 16;
if (ChannelNumber < 0) {
ChannelNumber = 48;
UnitNumber--;
if (UnitNumber < 1) UnitNumber = 47;
}
}
void Print(const char *name)
{
char str[1024];
char *ptr;
int irc;
strncpy(str, name, sizeof(str)-10);
ptr = strrchr(str, '.');
if (!ptr) ptr = strchr(str, '\0');
strcpy(ptr, ".pdf");
ptr += strlen(".pdf");
cv = new TCanvas("CVT", "CVT", 1500, 1200);
strcpy(ptr, "[");
cv->Print(str);
*ptr = '\0';
hSum = new TH1D("hTimeSum", "Average time distribution", 250, -25, 25);
for (UnitNumber = 1; UnitNumber < 60; UnitNumber++) for (ChannelNumber = 0; ChannelNumber<64; ChannelNumber += 16) {
irc = Draw(1);
if (irc) cv->Print(str);
}
cv->Clear();
gStyle->SetOptFit(1);
hSum->Fit("gaus");
cv->Update();
cv->Print(str);
strcpy(ptr, "]");
cv->Print(str);
}
void drawtimehists(const char *name)
{
if (Open(name)) return;
Print(name);
if (RepFile) fclose(RepFile);
}