33 #include "TPrincipal.h" 80 ,
fNormPC (pset.get<bool>(
"NormPC"))
94 fTree = tfs->
make<TTree>(
"PCATree",
"PCATree");
110 constexpr
size_t nViews = 3;
114 std::array<std::vector<size_t>, nViews> ClsIndex;
117 for(
size_t i = 0; i < clusterVecHandle->size(); ++i){
134 <<
"Hit belongs to an unsupported view (#" << cl->
View() <<
")";
138 ClsIndex[
fView].push_back(i);
144 const std::vector<size_t>& ClsIndices = ClsIndex[
fView];
146 for(
size_t c = 0; c < ClsIndices.size(); ++c){
149 const std::vector<art::Ptr<recob::Hit>>& ptrvs = fm.at(ClsIndices[c]);
151 double PrincDir[2], PrincValue=0;
152 double TotalCharge=0;
193 double Center[2] = {0,0};
196 for(
auto itHit = HitsThisCluster.begin(); itHit!=HitsThisCluster.end(); ++itHit)
198 Center[0] += (*itHit)->WireID().Wire;
199 Center[1] += (*itHit)->PeakTime();
200 TotalCharge += (*itHit)->Integral();
203 Center[0] /= float(HitsThisCluster.size());
204 Center[1] /= float(HitsThisCluster.size());
209 std::string OptionString;
216 TPrincipal pc(2, OptionString.c_str());
219 for(
auto itHit = HitsThisCluster.begin(); itHit!=HitsThisCluster.end(); ++itHit)
221 WireTime[0] = (*itHit)->WireID().Wire - Center[0];
222 WireTime[1] = (*itHit)->PeakTime() - Center[1];
230 PrincipalEigenvalue = (*pc.GetEigenValues())[0];
232 for(
size_t n=0;
n!=2; ++
n)
234 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.
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
EDAnalyzer(Table< Config > const &config)
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.
T * make(ARGS...args) const
ClusterPCA(fhicl::ParameterSet const &pset)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const