-
Notifications
You must be signed in to change notification settings - Fork 1
/
getSystWeight.cxx
198 lines (171 loc) · 4.61 KB
/
getSystWeight.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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#ifndef GETSYSTWEIGHT_C
#define GETSYSTWEIGHT_C
#include "getSystWeight.h"
using namespace std;
//////////////////////////////////////////////////////////////////////////////
// A function to calculate the systematic error weight that should be assigned
// to this event give the value "value" of parameter "ipar"
double getSystWeight(const char* systype, fqProcessedEvent* mcevent, int ipar, double value){
//initial weight is always one:
double ww = 1.0;
//get string to determine the parameterization type
TString parameterization_type = systype;
//simple TN186 parameterization
if (!parameterization_type.CompareTo("tn186simple")){
//these values are needed to determine the event weight
int absmode = TMath::Abs(mcevent->mode); //< NEUT mode for this event
double Enu = mcevent->pmomv[0]; //< True neutrino Energy
int nutype = TMath::Abs(mcevent->ipnu[0]); //< True neutrino type
// all of these parameters are sclaing parameters. If the value is <0,
// then just set weight to 0
if (value<0.){
ww=0.;
return ww;
}
//CCQE norm bin1
if (ipar==0){
if ((absmode==1)&&(Enu<190.)) ww*=value;
}
//CCQE norm bin2
if (ipar==1){
if ((absmode==1)&&(Enu>190.)&&(Enu<240.)) ww*=value;
}
//CCQE norm bin3
if (ipar==2){
if ((absmode==1)&&(Enu>240.)&&(Enu<294.)) ww*=value;
}
//CCQE norm bin4
if (ipar==3){
if ((absmode==1)&&(Enu>294.)&&(Enu<333.)) ww*=value;
}
//SubGevFlux
if (ipar==4){
if (Enu<1000.) ww*=value;
}
//MultiGeVFlux
if (ipar==5){
if (Enu>1000.) ww*=value;
}
//CCnQE
if (ipar==6){
if ((absmode>1)&&(absmode<30)) ww*=value;
}
//NC
if (ipar==7){
if (absmode>=30) ww*=value;
}
//mu2e ratio
if (ipar==8){
if (nutype==14) ww*=value;
}
}
//full TN186 parameterization
if (!parameterization_type.CompareTo("tn186")){
//these values are needed to determine the event weight
int absmode = TMath::Abs(mcevent->mode); //< NEUT mode for this event
double Enu = mcevent->pmomv[0]; //< True neutrino Energy
int nutype = TMath::Abs(mcevent->ipnu[0]); //< True neutrino type
//CCQE norm bin1
if (ipar==0){
if ((absmode==1)&&(Enu<190.)) ww*=value;
}
//CCQE norm bin2
if (ipar==1){
if ((absmode==1)&&(Enu>190.)&&(Enu<240.)) ww*=value;
}
//CCQE norm bin3
if (ipar==2){
if ((absmode==1)&&(Enu>240.)&&(Enu<294.)) ww*=value;
}
//CCQE norm bin4
if (ipar==3){
if ((absmode==1)&&(Enu>294.)&&(Enu<333.)) ww*=value;
}
//CCQE norm bin5
if (ipar==4){
if ((absmode==1)&&(Enu>333.)&&(Enu<390.)) ww*=value;
}
//CCQE norm bin6
if (ipar==5){
if ((absmode==1)&&(Enu>390.)&&(Enu<440.)) ww*=value;
}
//CCQE norm bin7
if (ipar==6){
if ((absmode==1)&&(Enu>440.)&&(Enu<487.)) ww*=value;
}
//CCQE norm bin8
if (ipar==7){
if ((absmode==1)&&(Enu>487.)&&(Enu<590.)) ww*=value;
}
//CCQE norm bin9
if (ipar==8){
if ((absmode==1)&&(Enu>590.)&&(Enu<690.)) ww*=value;
}
//CCQE norm bin10
if (ipar==9){
if ((absmode==1)&&(Enu>690.)&&(Enu<786.)) ww*=value;
}
//CCQE norm bin11
if (ipar==10){
if ((absmode==1)&&(Enu>786.)&&(Enu<896.)) ww*=value;
}
//CCQE norm bin12
if (ipar==11){
if ((absmode==1)&&(Enu>896.)&&(Enu<994.)) ww*=value;
}
//CCQE norm bin13
if (ipar==12){
if ((absmode==1)&&(Enu>994.)&&(Enu<2000.)) ww*=value;
}
//CCQE norm bin14
if (ipar==13){
if ((absmode==1)&&(Enu>2000.)&&(Enu<3000.)) ww*=value;
}
//SubGevFlux
if (ipar==14){
if (Enu<=1000.) ww*=value;
}
//MultiGeVFlux
if (ipar==15){
if (Enu>1000.) ww*=value;
}
//CCnQE
if (ipar==16){
if ((absmode>1)&&(absmode<30)) ww*=value;
}
//NC
if (ipar==17){
if (absmode>=30) ww*=value;
}
//mu2e ratio
if (ipar==18){
if (nutype==14) ww*=value;
}
}
///////////////////////////////
//cosmic muons systematics
if (!parameterization_type.CompareTo("cosmic")){
//these values are needed to determine the event weight
int fvbin = mcevent->nbin; //< fiducial bin of event
//FV Bin 1
if (ipar==0){
if (fvbin==0) ww*=value;
}
//FV Bin 2
if (ipar==1){
if (fvbin==1) ww*=value;
}
//FV Bin 3
if (ipar==2){
if (fvbin==2) ww*=value;
}
}
if (!parameterization_type.CompareTo("debug")){
return value;
}
//no negative weights
if (ww<0.) ww = 0.;
//////////
return ww;
}
#endif