19 #include "canvas/Persistency/Common/FindManyP.h" 23 #include "art_root_io/TFileService.h" 31 #include "TPrincipal.h" 92 fTree = tfs->make<TTree>(
"PCATree",
"PCATree");
108 constexpr
size_t nViews = 3;
112 std::array<std::vector<size_t>, nViews> ClsIndex;
115 for(
size_t i = 0; i < clusterVecHandle->size(); ++i){
132 <<
"Hit belongs to an unsupported view (#" << cl->
View() <<
")";
136 ClsIndex[
fView].push_back(i);
142 const std::vector<size_t>& ClsIndices = ClsIndex[
fView];
144 for(
size_t c = 0;
c < ClsIndices.size(); ++
c){
147 const std::vector<art::Ptr<recob::Hit>>& ptrvs = fm.at(ClsIndices[
c]);
149 double PrincDir[2], PrincValue=0;
150 double TotalCharge=0;
191 double Center[2] = {0,0};
194 for(
auto itHit = HitsThisCluster.begin(); itHit!=HitsThisCluster.end(); ++itHit)
196 Center[0] += (*itHit)->WireID().Wire;
197 Center[1] += (*itHit)->PeakTime();
198 TotalCharge += (*itHit)->Integral();
201 Center[0] /=
float(HitsThisCluster.size());
202 Center[1] /=
float(HitsThisCluster.size());
214 TPrincipal
pc(2, OptionString.c_str());
217 for(
auto itHit = HitsThisCluster.begin(); itHit!=HitsThisCluster.end(); ++itHit)
219 WireTime[0] = (*itHit)->WireID().Wire - Center[0];
220 WireTime[1] = (*itHit)->PeakTime() - Center[1];
228 PrincipalEigenvalue = (*
pc.GetEigenValues())[0];
230 for(
size_t n=0;
n!=2; ++
n)
232 PrincipalDirection[
n]= (*
pc.GetEigenVectors())[0][
n];
Planes which measure Z direction.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
EDAnalyzer(fhicl::ParameterSet const &pset)
void analyze(art::Event const &evt)
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#define DEFINE_ART_MODULE(klass)
std::string fClusterModuleLabel
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.
Declaration of signal hit object.
ClusterPCA(fhicl::ParameterSet const &pset)
static constexpr double fm
auto const & get(AssnsNode< L, R, D > const &r)