-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmasktools.cxx
56 lines (43 loc) · 1.14 KB
/
masktools.cxx
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
#ifndef MASKTOOLS_C
#define MASKTOOLS_C
#include "masktools.h"
using namespace std;
int passMask(TH1D* hmask, double value){
int ibin = hmask->FindBin(value);
return (int)hmask->GetBinContent(ibin);
}
void masktools::makethismask(const char* filename){
// make histograms
hwall = new TH1D("hwall","hwall",nbins,0,1000);
hmask = (TH1D*)hwall->Clone("hmask");
// fill histogram
#ifndef T2K
fqEvent* fqevent = new fqEvent(chdata);
#else
t2kfqEvent *fqevent = new t2kfqEvent(chdata);
#endif
int nev = chdata->GetEntries();
TVector3* vpos = new TVector3();
for (int iev=0; iev<nev; iev++){
chdata->GetEntry(iev);
vpos->SetXYZ(fqevent->fq1rpos[0][2][0],
fqevent->fq1rpos[0][2][1],
fqevent->fq1rpos[0][2][2]);
double wall = calcWall(vpos);
hwall->Fill(wall);
}
// make mask
for (int ibin=1; ibin<=hwall->GetNbinsX(); ibin++){
double content = hwall->GetBinContent(ibin);
if (content<thresh) hmask->SetBinContent(ibin,1.);
else{
hmask->SetBinContent(ibin,0.);
}
}
// save mask
hmask->SaveAs(filename);
return;
}
masktools::masktools(){
}
#endif