19 #include "art_root_io/TFileService.h" 31 #include "TPrincipal.h" 44 double* PrincDirectionWT,
87 fTree = tfs->make<TTree>(
"PCATree",
"PCATree");
103 constexpr
size_t nViews = 3;
107 std::array<std::vector<size_t>, nViews> ClsIndex;
110 for (
size_t i = 0; i < clusterVecHandle->size(); ++i) {
115 switch (cl->
View()) {
120 mf::LogError(
"ClusterPCA") <<
"Hit belongs to an unsupported view (#" << cl->
View() <<
")";
124 ClsIndex[
fView].push_back(i);
130 const std::vector<size_t>& ClsIndices = ClsIndex[
fView];
132 for (
size_t c = 0; c < ClsIndices.size(); ++c) {
135 const std::vector<art::Ptr<recob::Hit>>& ptrvs = fm.at(ClsIndices[c]);
137 double PrincDir[2], PrincValue = 0;
138 double TotalCharge = 0;
170 double* PrincipalDirection,
171 double& PrincipalEigenvalue,
176 double Center[2] = {0, 0};
179 for (
auto itHit = HitsThisCluster.begin(); itHit != HitsThisCluster.end(); ++itHit) {
180 Center[0] += (*itHit)->WireID().Wire;
181 Center[1] += (*itHit)->PeakTime();
182 TotalCharge += (*itHit)->Integral();
185 Center[0] /= float(HitsThisCluster.size());
186 Center[1] /= float(HitsThisCluster.size());
190 std::string OptionString;
197 TPrincipal pc(2, OptionString.c_str());
199 for (
auto itHit = HitsThisCluster.begin(); itHit != HitsThisCluster.end(); ++itHit) {
200 WireTime[0] = (*itHit)->WireID().Wire - Center[0];
201 WireTime[1] = (*itHit)->PeakTime() - Center[1];
208 PrincipalEigenvalue = (*pc.GetEigenValues())[0];
210 for (
size_t n = 0;
n != 2; ++
n) {
211 PrincipalDirection[
n] = (*pc.GetEigenVectors())[0][
n];
Declaration of signal hit object.
Planes which measure Z direction.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
EDAnalyzer(fhicl::ParameterSet const &pset)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
void analyze(art::Event const &evt)
#define DEFINE_ART_MODULE(klass)
std::string fClusterModuleLabel
Declaration of cluster object.
Definition of data types for geometry description.
void PerformClusterPCA(const std::vector< art::Ptr< recob::Hit >> &HitsThisCluster, double *PrincDirectionWT, double &PrincValue, double &TotalCharge, bool NormPC)
geo::View_t View() const
Returns the view for this cluster.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
ClusterPCA(fhicl::ParameterSet const &pset)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const