IB-0.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IBPWeightAlgorithms.h
Go to the documentation of this file.
1 /*////////////////////////////////////////////////////////////////////////////
2  Copyright 2018 Istituto Nazionale di Fisica Nucleare
3 
4  Licensed under the EUPL, Version 1.2 or - as soon they will be approved by
5  the European Commission - subsequent versions of the EUPL (the "Licence").
6  You may not use this work except in compliance with the Licence.
7 
8  You may obtain a copy of the Licence at:
9 
10  https://joinup.ec.europa.eu/software/page/eupl
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
14  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  Licence for the specific language governing permissions and limitations under
16  the Licence.
18 
19 
20 
21 #ifndef IBPWEIGHTALGORITHMS_H
22 #define IBPWEIGHTALGORITHMS_H
23 
24 
25 #include <Core/StaticInterface.h>
26 #include <Math/Dense.h>
27 
28 
29 using namespace uLib;
30 
31 
32 template <class EventT>
33 class IBPWeightAlgorithm_PW {
34 
35 public:
36  static void evaluate(EventT *evc, Scalarf nominalp) {
37  float pw_A = 1.42857;
38  float pw_epsilon = 4.0;
39  float Xres = 0;
40  for (int j = evc->elements.size(); j --> 0;) //BACKWARD
41  {
42  float L = evc->elements[j].Wij(0,0);
43 
44  evc->elements[j].pw = pw_A * (nominalp) *
45  sqrt(pw_epsilon/(Xres + pw_epsilon));
46  // Xres += (evc->elements[j].voxel->Value * 1.E6 < 2.5) ?
47  // L * evc->elements[j].voxel->Value * 40000 :
48  // L * 2.5 * 0.04;
49  Xres += L * evc->elements[j].voxel->Value * 40000;
50  }
51  }
52 
53 };
54 
55 
56 template <class EventT>
57 class IBPWeightAlgorithm_SW {
58 
59 public:
60  static void evaluate(EventT *evc, Scalarf nominalp) {
61  float scale = 0.8; //this is experimental and empirical!
62  float alpha = 0.436; // this is the distribution peak angle, 25 degrees
63  // note: albeit NOT efficient, this procedure is fundamental in testing the algorithm capability
64  TODO("Optimize PW functions");
65  float b1 = 13.52; // Iron Values
66  float b2 = 319.9;
67  float c1 = 3.73E-4;
68  float c2 = 2.55E-2;
69  float d = 2.33;
70  float e = 1.56;
71 
72  float sw_epsilon_1 = scale * sqrt(b1 + c1 * alpha * alpha);
73  float sw_epsilon_2 = scale * sqrt(b2 + c2 * alpha * alpha);
74  float sw_A = d + e * cos(alpha) * cos(alpha);
75 
76  float Xres = 0;
77  Matrix4f Wij;
78  for (int j = evc->elements.size(); j --> 0;) //BACKWARD
79  {
80  Wij = evc->elements[j].Wij;
81 
82  evc->elements[j].pw = (nominalp) * sqrt( sw_A /
83  (Xres/sw_epsilon_1 + pow(Xres/sw_epsilon_2,2) + 1) );
84  /*
85  Xres += (evc->elements[j].voxel->density * 1.E6 < 2.5) ?
86  Wij[0] * evc->elements[j].voxel->density * 40000 :
87  Wij[0] * 2.5 * 0.04;
88  */
89  Xres += Wij(0,0) * evc->elements[j].voxel->Value * 40000; //<- previous version of
90  // p_weight: bugged but enhancing!
91  }
92  }
93 
94 
95 };
96 
97 
98 template <class EventT>
100 public:
101  static void evaluate(EventT *evc, Scalarf nominalp){
102  float cw_A = 1.42857;
103  float cw_epsilon = 50;
104  float X0_tot = 0;
105  Matrix4f Wij;
106  for (int j = 0; j < evc->elements.size(); ++j)
107  {
108  Wij = evc->elements[j].Wij;
109  /*X0_tot += (evc->elements[j].voxel->density * 1.E6 < 2.5 ) ?
110  Wij[0] * evc->elements[j].voxel->density * 40000 :
111  Wij[0] * 2.5 * 0.04;
112  */
113  X0_tot += Wij(0,0) * evc->elements[j].voxel->Value * 40000;
114  }
115 
116  float _pw = cw_A * (nominalp) *
117  sqrt( cw_epsilon / ( X0_tot + cw_epsilon ));
118  for (int i = 0; i < evc->elements.size(); ++i )
119  {
120  evc->elements[i].pw = _pw;
121  }
122  }
123 };
124 
125 
126 
127 
128 #endif // IBPWEIGHTALGORITHMS_H
Definition: IBPWeightAlgorithms.h:99
static void evaluate(EventT *evc, Scalarf nominalp)
Definition: IBPWeightAlgorithms.h:101