Jpp
examples
JNanobeacon
JVoltageOptimizer_utils.hh
Go to the documentation of this file.
1
#ifndef __OPT_UTILS__
2
#define __OPT_UTILS__
3
4
//c++ standard library
5
#include <iostream>
6
7
//root
8
#include "TH2D.h"
9
10
//Nanobeacons
11
#include "
NBRun.hh
"
12
13
// namespaces
14
using namespace
std
;
15
16
17
/**
18
* \author rgruiz
19
*/
20
21
22
23
/**
24
* Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a source and target modules.
25
*/
26
struct
event{
27
28
double
V = 999;
29
30
double
meanToT_ref = 999;
31
32
double
meanToT_tgt = 999 ;
33
34
double
sigmaToT_ref = 999 ;
35
36
double
sigmaToT_tgt = 999 ;
37
38
};
39
40
41
42
/**
43
* Optimizes the voltage of each nanobeacon
44
*
45
* \param max_tot maximum allowed ToT value
46
* \param evt_table table of event structures for each nanobeacon and run
47
* \return vector of pairs with optimal voltage and corresponding run number
48
*/
49
inline
vector < pair < double , int >
>
optimize_voltage
(
vector
<
vector < event >
> evt_table ,
double
max_tot){
50
51
int
Nbeacons = evt_table.size() ;
52
53
int
Nruns = evt_table[0].size() ;
54
55
vector < pair < double , int >
> optimal_voltages (Nbeacons) ;
56
57
for
(
int
i=0 ; i<Nbeacons ; i++){
58
59
for
(
int
j
=Nruns-1 ;
j
>=0 ;
j
--){
60
61
if
(evt_table[i][
j
].meanToT_ref < max_tot){
62
63
cout << evt_table[i][
j
].meanToT_ref <<
"\t "
<< evt_table[i][
j
].V << endl ;
64
65
optimal_voltages[i] = make_pair(evt_table[i][
j
].V ,
j
);
66
67
break ;
68
69
}
70
71
}
72
73
}
74
75
return
optimal_voltages ;
76
77
}
78
79
80
#endif
std::vector
Definition:
JSTDTypes.hh:12
JTOOLS::j
int j
Definition:
JPolint.hh:634
optimize_voltage
vector< pair< double, int > > optimize_voltage(vector< vector< event > > evt_table, double max_tot)
Optimizes the voltage of each nanobeacon.
Definition:
JVoltageOptimizer_utils.hh:49
std
Definition:
jaanetDictionary.h:36
NBRun.hh
Generated by
1.8.16