65 Tree =
tfs->make<TTree>(
"DebugTreeDirCheater",
"DebugTree from shower direction cheater");
82 auto const clockData =
93 std::map<int, const simb::MCParticle*> trueParticles =
95 std::map<int, std::vector<int>> showersMothers =
101 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.
key());
106 std::vector<art::Ptr<recob::Hit>> showerHits;
107 for (
auto const&
cluster : clusters) {
109 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
110 showerHits.insert(showerHits.end(), hits.begin(), hits.end());
114 std::pair<int, double> ShowerTrackInfo =
116 clockData, showersMothers, showerHits, 2);
118 if (ShowerTrackInfo.first == -99999) {
119 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
122 trueParticle = trueParticles[ShowerTrackInfo.first];
127 mf::LogError(
"ShowerDirectionCheater") <<
"True shower not found, returning";
131 TVector3 trueDir = TVector3{trueParticle->
Px(), trueParticle->
Py(), trueParticle->
Pz()}.Unit();
133 TVector3 trueDirErr = {-999, -999, -999};
139 rmsGradient = std::numeric_limits<float>::lowest();
143 art::FindManyP<recob::SpacePoint> fmspp(pfpHandle, Event,
fPFParticleLabel);
145 if (!fmspp.isValid()) {
147 <<
"Trying to get the spacepoint and failed. Something is not configured correctly. " 153 if (!fmh.isValid()) {
155 <<
"Spacepoint and hit association not valid. Stopping.";
157 std::vector<art::Ptr<recob::SpacePoint>> spacePoints = fmspp.at(pfparticle.
key());
159 if (spacePoints.size() < 3) {
161 << spacePoints.size() <<
" spacepoints in shower, not calculating direction" <<
std::endl;
169 clockData, detProp, spacePoints, fmh, TotalCharge);
175 TVector3 StartPositionVec = {-999, -999, -999};
178 TVector3 GeneralDir = (ShowerCentre - StartPositionVec).Unit();
187 spacePoints, ShowerCentre, trueDir,
fNSegments);
double Py(const int i=0) const
std::map< int, const simb::MCParticle * > GetTrueParticleMap() const
double Px(const int i=0) const
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
double RMSShowerGradient(std::vector< art::Ptr< recob::SpacePoint >> &sps, const TVector3 &ShowerCentre, const TVector3 &Direction, const unsigned int nSegments) const
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
key_type key() const noexcept
std::map< int, std::vector< int > > GetTrueChain(std::map< int, const simb::MCParticle * > &trueParticles) const
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
std::pair< int, double > TrueParticleIDFromTrueChain(detinfo::DetectorClocksData const &clockData, std::map< int, std::vector< int >> const &ShowersMothers, std::vector< art::Ptr< recob::Hit >> const &hits, int planeid) const
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
double Pz(const int i=0) const
TVector3 ShowerCentre(std::vector< art::Ptr< recob::SpacePoint >> const &showersps) const
auto const & get(AssnsNode< L, R, D > const &r)
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)