ATTPCROOT
0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtTools
AtHitSampling
AtWeightedY.cxx
Go to the documentation of this file.
1
#include "
AtWeightedY.h
"
2
3
#include "
AtHit.h
"
4
#include "
AtSample.h
"
// for RandomSample
5
6
#include <FairLogger.h>
// for Logger, LOG
7
8
#include <algorithm>
// for max
9
#include <cmath>
// for pow, sqrt
10
11
using namespace
RandomSample
;
12
13
std::vector<AtHit>
AtWeightedY::SampleHits
(
int
N)
14
{
15
std::vector<AtHit> ret;
16
LOG(debug) <<
"Vetoing "
<<
fVetoIn
.size();
17
18
// If every hit is outside of the beam region, then skip the vetoed beam region
19
if
(
fVetoIn
.size() ==
fHits
->size() ||
fVetoIn
.size() == 0) {
20
LOG(error) <<
"Defaulting to normal sampling (fVetoIn is size: "
<<
fVetoIn
.size() <<
")"
;
21
for
(
auto
ind :
sampleIndicesFromCDF
(N))
22
ret.push_back(*
fHits
->at(ind));
23
return
ret;
24
}
25
26
for
(
auto
ind :
sampleIndicesFromCDF
(2,
fVetoIn
))
27
ret.push_back(*
fHits
->at(ind));
28
for
(
auto
ind :
sampleIndicesFromCDF
(N - 2,
fVetoOut
))
29
ret.push_back(*
fHits
->at(ind));
30
return
ret;
31
}
32
33
void
AtWeightedY::SetHitsToSample
(
const
std::vector<const AtHit *> &hits)
34
{
35
fHits
= &hits;
36
fVetoOut
.clear();
37
fVetoIn
.clear();
38
FillCDF
();
39
for
(
int
i = 0; i <
fHits
->size(); i++) {
40
if
(sqrt(pow(
fHits
->at(i)->GetPosition().X(), 2) + pow(
fHits
->at(i)->GetPosition().Y(), 2)) < 20) {
41
fVetoOut
.push_back(i);
42
}
else
{
43
fVetoIn
.push_back(i);
44
}
45
}
46
}
RandomSample
Definition:
AtSampleConsensus.h:26
RandomSample::AtSample::sampleIndicesFromCDF
std::vector< int > sampleIndicesFromCDF(int N, std::vector< int > vetoed={})
Definition:
AtSample.cxx:77
RandomSample::AtSample::fHits
const std::vector< const AtHit * > * fHits
Definition:
AtSample.h:38
AtHit.h
RandomSample::AtSample::FillCDF
void FillCDF()
Definition:
AtSample.cxx:115
RandomSample::AtWeightedY::fVetoIn
std::vector< int > fVetoIn
Definition:
AtWeightedY.h:19
AtWeightedY.h
RandomSample::AtWeightedY::fVetoOut
std::vector< int > fVetoOut
Definition:
AtWeightedY.h:20
RandomSample::AtWeightedY::SetHitsToSample
virtual void SetHitsToSample(const std::vector< const AtHit * > &hits) override
Definition:
AtWeightedY.cxx:33
AtSample.h
RandomSample::AtWeightedY::SampleHits
virtual std::vector< AtHit > SampleHits(int N) override
Sample hits (AtHit) from fHits.
Definition:
AtWeightedY.cxx:13
Generated on Sat Nov 11 2023 15:30:38 for ATTPCROOT by
1.8.18