Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larpandora
larpandora
LArPandoraEventBuilding
LArPandoraShower
Tools
ShowerPCAEigenvalueLength_tool.cc
Go to the documentation of this file.
1
//############################################################################
2
//### Name: ShowerPCAEigenvalueLength ###
3
//### Author: Ed Tyley ###
4
//### Date: 07.01.20 ###
5
//### Description: Simple code to calculate the lenght from the PCA ###
6
//### eigenvalues ###
7
//############################################################################
8
9
//Framework Includes
10
#include "
art/Utilities/ToolMacros.h
"
11
12
//LArSoft Includes
13
#include "
lardataobj/RecoBase/PCAxis.h
"
14
#include "
larpandora/LArPandoraEventBuilding/LArPandoraShower/Tools/IShowerTool.h
"
15
16
namespace
ShowerRecoTools
{
17
18
class
ShowerPCAEigenvalueLength
:
public
IShowerTool
{
19
20
public
:
21
ShowerPCAEigenvalueLength
(
const
fhicl::ParameterSet
& pset);
22
23
//Generic Direction Finder
24
int
CalculateElement
(
const
art::Ptr<recob::PFParticle>
& pfparticle,
25
art::Event
&
Event
,
26
reco::shower::ShowerElementHolder
& ShowerEleHolder)
override
;
27
28
private
:
29
art::InputTag
fPFParticleLabel
;
30
int
fVerbose
;
31
std::string
fShowerPCAInputLabel
;
32
std::string
fShowerLengthOutputLabel
;
33
std::string
fShowerOpeningAngleOutputLabel
;
34
float
fNSigma
;
35
};
36
37
ShowerPCAEigenvalueLength::ShowerPCAEigenvalueLength
(
const
fhicl::ParameterSet
& pset)
38
:
IShowerTool
(pset.
get
<
fhicl
::ParameterSet>(
"BaseTools"
))
39
,
fPFParticleLabel
(pset.
get
<
art
::InputTag>(
"PFParticleLabel"
))
40
,
fVerbose
(pset.
get
<
int
>(
"Verbose"
))
41
,
fShowerPCAInputLabel
(pset.
get
<
std
::
string
>(
"ShowerPCAInputLabel"
))
42
,
fShowerLengthOutputLabel
(pset.
get
<
std
::
string
>(
"ShowerLengthOutputLabel"
))
43
,
fShowerOpeningAngleOutputLabel
(pset.
get
<
std
::
string
>(
"ShowerOpeningAngleOutputLabel"
))
44
,
fNSigma
(pset.
get
<
float
>(
"NSigma"
))
45
{}
46
47
int
48
ShowerPCAEigenvalueLength::CalculateElement
(
const
art::Ptr<recob::PFParticle>
& pfparticle,
49
art::Event
& Event,
50
reco::shower::ShowerElementHolder
& ShowerEleHolder)
51
{
52
53
if
(!ShowerEleHolder.
CheckElement
(
fShowerPCAInputLabel
)) {
54
if
(
fVerbose
)
55
mf::LogError
(
"ShowerPCAEigenvalueLength"
) <<
"PCA not set, returning "
<<
std::endl
;
56
return
1;
57
}
58
59
recob::PCAxis
PCA =
recob::PCAxis
();
60
ShowerEleHolder.
GetElement
(
fShowerPCAInputLabel
, PCA);
61
62
const
double
* eigenValues = PCA.
getEigenValues
();
63
64
// The PCA eigenvalues give the deviance of space points around the center
65
// Take the sqrt to get std. dev and take fNSigma in each direction:
66
// Call the length fNSigma x 2 x std. dev. along primary eigenvalues
67
// Call the width fNSigma x 2 x std. dev. along secondary eigenvalues
68
69
//TODO: Actually calculate the erros (Maybe fNSigma+-1Sigma?)
70
71
//Find the length
72
double
primaryEigenValue = (eigenValues)[0];
73
double
ShowerLength = std::sqrt(primaryEigenValue) * 2 *
fNSigma
;
74
double
ShowerLengthError = -999;
75
76
//Find the width of the shower
77
double
secondaryEigenValue = (eigenValues)[1];
78
double
ShowerWidth = std::sqrt(secondaryEigenValue) * 2 *
fNSigma
;
79
80
double
ShowerAngle = std::atan(ShowerWidth / ShowerLength);
81
double
ShowerAngleError = -999;
82
83
// Fill the shower element holder
84
ShowerEleHolder.
SetElement
(ShowerLength, ShowerLengthError,
fShowerLengthOutputLabel
);
85
ShowerEleHolder.
SetElement
(ShowerAngle, ShowerAngleError,
fShowerOpeningAngleOutputLabel
);
86
87
return
0;
88
}
89
}
90
91
DEFINE_ART_CLASS_TOOL
(
ShowerRecoTools::ShowerPCAEigenvalueLength
)
ShowerRecoTools::ShowerPCAEigenvalueLength::CalculateElement
int CalculateElement(const art::Ptr< recob::PFParticle > &pfparticle, art::Event &Event, reco::shower::ShowerElementHolder &ShowerEleHolder) override
Definition:
ShowerPCAEigenvalueLength_tool.cc:48
recob::PCAxis::getEigenValues
const double * getEigenValues() const
Definition:
PCAxis.h:65
ShowerRecoTools::ShowerPCAEigenvalueLength::ShowerPCAEigenvalueLength
ShowerPCAEigenvalueLength(const fhicl::ParameterSet &pset)
Definition:
ShowerPCAEigenvalueLength_tool.cc:37
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
IShowerTool.h
reco_momentum_tuples.float
float
Definition:
reco_momentum_tuples.py:12
string
std::string string
Definition:
nybbler.cc:12
reco::shower::ShowerElementHolder::SetElement
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
Definition:
ShowerElementHolder.hh:360
ShowerRecoTools::ShowerPCAEigenvalueLength
Definition:
ShowerPCAEigenvalueLength_tool.cc:18
std
STL namespace.
mf::LogError
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Definition:
MessageLogger.h:211
ShowerRecoTools::ShowerPCAEigenvalueLength::fPFParticleLabel
art::InputTag fPFParticleLabel
Definition:
ShowerPCAEigenvalueLength_tool.cc:29
recob::PCAxis
Definition:
PCAxis.h:25
PCAxis.h
ToolMacros.h
ShowerRecoTools::ShowerPCAEigenvalueLength::fNSigma
float fNSigma
Definition:
ShowerPCAEigenvalueLength_tool.cc:34
fhicl
Definition:
InputSourceFactory.h:7
ShowerRecoTools::ShowerPCAEigenvalueLength::fVerbose
int fVerbose
Definition:
ShowerPCAEigenvalueLength_tool.cc:30
art::InputTag
Definition:
InputTag.h:12
reco::shower::ShowerElementHolder::CheckElement
bool CheckElement(const std::string &Name) const
Definition:
ShowerElementHolder.hh:415
reco::shower::ShowerElementHolder::GetElement
int GetElement(const std::string &Name, T &Element) const
Definition:
ShowerElementHolder.hh:219
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
ShowerRecoTools::ShowerPCAEigenvalueLength::fShowerOpeningAngleOutputLabel
std::string fShowerOpeningAngleOutputLabel
Definition:
ShowerPCAEigenvalueLength_tool.cc:33
ShowerRecoTools
Definition:
ShowerDirectionCheater_tool.cc:16
art::Event
Definition:
Event.h:22
Event
Definition:
types.h:32
reco::shower::ShowerElementHolder
Definition:
ShowerElementHolder.hh:213
art
Definition:
BasicOptionsHandler.h:9
ShowerRecoTools::IShowerTool
Definition:
IShowerTool.h:25
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
ShowerRecoTools::ShowerPCAEigenvalueLength::fShowerLengthOutputLabel
std::string fShowerLengthOutputLabel
Definition:
ShowerPCAEigenvalueLength_tool.cc:32
art::Ptr< recob::PFParticle >
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
ShowerRecoTools::ShowerPCAEigenvalueLength::fShowerPCAInputLabel
std::string fShowerPCAInputLabel
Definition:
ShowerPCAEigenvalueLength_tool.cc:31
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11