-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrosscheck.C
131 lines (111 loc) · 4.48 KB
/
crosscheck.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "crosscheck.hh"
void crosscheck() {
TFile *data_file = TFile::Open("data/run81408.root", "read");
TTree *event_tree = (TTree *)data_file->Get("Event"); // main detector
TTree *pool_muon_tree = (TTree *)data_file->Get("PoolMuon"); // main detector
int total_events = event_tree->GetEntries();
printf("total events: %d\n", total_events);
EventTree Event(event_tree);
PoolMuonTree PoolMuon(pool_muon_tree);
Event.tree->GetEntry(0);
PoolMuon.tree->GetEntry(0);
int t0 = std::min(Event.sec, PoolMuon.msec);
TDatime td_t0(t0);
cout << "[Run start time] " << t0 << endl;
cout << "[Run start time] ";
td_t0.Print();
int Nsingle = 0; // single nGd
int Npair = 0;
TFile *fout = TFile::Open("output/pair_81408.root", "recreate");
PairTree pair_tree("pair_tree", "pair tree 81408 v22/11/05");
vector<AdEvent> vmuad;
vector<AdEvent> vmush;
for (int i = 0; i < total_events; ++i) {
Event.tree->GetEntry(i);
// ad muon
if (Event.energy > 20 && Event.energy < 2500) {
auto muad = Event.GetEvent(i);
auto muWsVeto = PoolMuon.CalcMuWsVeto(muad);
if (muWsVeto[0] < 2e-6 || muWsVeto[1] < 2e-6) {
vmuad.push_back(muad); // save mu_ad event
}
}
// ad muon shower
if (Event.energy > 2500) {
auto mush = Event.GetEvent(i);
auto muWsVeto = PoolMuon.CalcMuWsVeto(mush);
if (muWsVeto[0] < 2e-6 || muWsVeto[1] < 2e-6) {
vmush.push_back(mush); // save mu_ad event
}
}
// n-Gd
if (Event.energy > 6 && Event.energy < 10) {
auto delay = Event.GetEvent(i);
vector<AdEvent> pair = {delay};
cout << "i: " << i << " ";
cout << "Ed: " << Event.energy << " ";
auto vprompt = Event.SearchPrompt(i);
int Nmulti = 0;
if (vprompt.size() == 0) {
// single nGd event
cout << endl;
Nmulti = Event.SearchMultiplicity(delay.i, delay.i, total_events);
Nsingle++;
} else {
// paired events
for (const auto &prompt : vprompt) {
cout << "Ep: " << prompt.energy << " ";
cout << "Tp: " << GetTimeDiff(prompt, delay) * 1e6 << " " << endl;
}
Nmulti = Event.SearchMultiplicity(vprompt.front().i, delay.i, total_events);
pair.insert(pair.begin(), vprompt.begin(), vprompt.end());
Npair++;
}
// check water pool muon veto
auto muWsVeto = PoolMuon.CalcMuWsVeto(delay);
pair_tree.wpMuVeto = muWsVeto[0] > 600e-6 ? true : false;
pair_tree.tPrevMuWs = muWsVeto[0];
pair_tree.tPostMuWs = muWsVeto[1];
// check ad muon veto
if (vmuad.size() > 0) {
auto tdiff = GetTimeDiff(vmuad.back(), delay);
pair_tree.adMuVeto = tdiff > 1000e-6 ? true : false;
pair_tree.tPrevAdMu = tdiff;
} else {
pair_tree.adMuVeto = true;
pair_tree.tPrevAdMu = -1;
}
// check ad shower muon veto
if (vmush.size() > 0) {
auto tdiff = GetTimeDiff(vmush.back(), delay);
pair_tree.adShVeto = tdiff > 1 ? true : false;
pair_tree.tPrevAdSh = tdiff;
} else {
pair_tree.adShVeto = true;
pair_tree.tPrevAdSh = -1;
}
pair_tree.Nmulti = Nmulti;
pair_tree.WriteEvent(pair);
}
}
auto c1 = new TCanvas("c1");
pair_tree.tree->Draw("energy[0]", "Nprompt==1 && Nmulti==0");
c1->SaveAs("crosscheck.pdf(");
pair_tree.tree->Draw("energy[1]", "Nprompt==1 && Nmulti==0");
c1->SaveAs("crosscheck.pdf");
pair_tree.tree->Draw("dt", "Nprompt==1 && Nmulti==0");
c1->SaveAs("crosscheck.pdf");
pair_tree.tree->Draw("dr", "Nprompt==1 && Nmulti==0");
c1->SaveAs("crosscheck.pdf)");
fout->cd();
pair_tree.tree->Write();
fout->Close();
cout << endl;
cout << "number of single nGd events: " << Nsingle << endl;
cout << "number of paired events: " << Npair << endl;
// output file and tree
// auto fout = TFile::Open("output/test_81408.root", "recreate");
// auto ibd_tree = new TTree("ibd_tree", "");
// float t1;
// ibd_tree->Branch("t1", &t1);
}