Repository navigation
Expand file tree
/
Copy pathdrawRefDiff.C
More file actions
157 lines (128 loc) · 3.5 KB
/
Copy pathdrawRefDiff.C
File metadata and controls
157 lines (128 loc) · 3.5 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#define TTSelector_cxx
#include "prttools.C"
#include "drawRefDiff.h"
TCanvas * cTdc = new TCanvas("cTdc","cTdc",0,0,800,400);
TCanvas * cRef = new TCanvas("cRef","cRef",0,0,800,400);
TH2F *hRef = new TH2F("hRef","hRef;tdc [#]; tdc [#]",30,0,30,30,0,30);
TH1F *hTdc = new TH1F("hTdc","htdc;tdc [#]; entries [#]",50,0,50);
TH1F *hDif[50][50];
Int_t gRange(20);
TLine *gLine1 = new TLine(0,0,0,1000);
TBox *gBox = new TBox();
Int_t gState = 0;
Int_t gRef(0),gtRef(0);
Bool_t gDrawBox(1);
Bool_t gDrawLine(1);
void TTSelector::Begin(TTree *){
prt_setRootPalette(1);
prt_savepath = "auto";
gStyle->SetOptStat(1001111);
prt_createMap();
for(Int_t i=0; i<50; i++){
for(Int_t j=0; j<50; j++){
hDif[i][j] = new TH1F(Form("hDif%d_%d",i,j),Form("hDif%d_%d;time [ns];entries [#]",i,j),5000,-gRange,gRange);
}
}
}
Bool_t TTSelector::Process(Long64_t entry){
if(entry%1000==0) std::cout<<"event # "<< entry <<std::endl;
GetEntry(entry);
Double_t times[50]={0};
for(Int_t i=0; i<Hits_; i++){
Int_t tdc = map_tdc[Hits_nTrbAddress[i]];
if(tdc<0) continue;
Int_t lch = Hits_nTdcChannel[i];
Int_t ch = 48*tdc+lch;
if(lch==0){
hTdc->Fill(tdc);
times[tdc]=Hits_fTime[i];
}
}
for(Int_t i=0; i<50; i++){
for(Int_t j=0; j<50; j++){
Double_t diff =times[i]-times[j];
hDif[i][j]->Fill(diff);
hRef->Fill(i,j,diff);
}
}
return kTRUE;
}
void TTSelector::Terminate(){
// canvasAdd(Form("cChTime",0),800,5000);
cRef->cd();
hRef->Draw("colz");
hDif[2][5]->Draw();
// canvasAdd(Form("cTdc",0),800,5000);
cTdc->cd();
hTdc->Draw();
// canvasSave(1,0); //-1
}
void drawRefDiff(TString inFile= "/data.local/may2015/ce15145205719.hld.root",Int_t range=1000, Int_t events=0){ //ce15144155257.hld.root
gRange = range;
TChain* ch = new TChain("T");
ch->Add(inFile);
Int_t entries = ch->GetEntries();
std::cout<<"Entries in chain: "<< entries<<std::endl;
if(events!=0) entries = events;
//entries = 10000;
TTSelector *selector = new TTSelector();
ch->Process(selector,"",entries);
cTdc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", 0, 0,
"exec3event(Int_t,Int_t,Int_t,TObject*)");
}
void exec3event(Int_t event, Int_t gx, Int_t gy, TObject *selected){
TCanvas *c = (TCanvas *) gTQSender;
TPad *pad = (TPad *) c->GetSelectedPad();
if (!pad) return;
Float_t x = pad->AbsPixeltoX(gx);
Int_t binx = hTdc->GetXaxis()->FindBin( pad->PadtoX(x))-1;
if(binx<0 || binx >49) return;
if(gState==0){
gRef = binx;
}
if(event==1 && gState==0){
gState = 1;
gDrawBox = false;
gRef = binx;
return;
}
if(event==1 && gState==1){
gState = 2;
gDrawLine = false;
return;
}
if(event==1 && gState==2){
gState = 0;
gDrawLine = true;
gDrawBox = true;
return;
}
if(gState==2) return;
if(gtRef==binx) return;
else gtRef = binx;
if(gDrawLine){
cTdc->cd();
gLine1->SetX1(binx+0.5);
gLine1->SetX2(binx+0.5);
gLine1->SetY1(cTdc->GetUymin());
gLine1->SetY2(cTdc->GetUymax());
gLine1->SetLineColor(kRed);
gLine1->Draw();
cTdc->Update();
}
if(gDrawBox){
cTdc->cd();
gBox->SetX1(binx);
gBox->SetX2(binx+1);
gBox->SetY1(cTdc->GetUymin());
gBox->SetY2(cTdc->GetUymax());
gBox->SetFillColor(kRed);
gBox->SetFillStyle(3001);
gBox->Draw();
cTdc->Update();
}
cRef->cd();
hDif[gRef][binx]->SetTitle(prt_tdcsid[gRef]+"-"+prt_tdcsid[binx]);
hDif[gRef][binx]->Draw();
cRef->Update();
}