13 #include "art_root_io/TFileService.h" 14 #include "canvas/Persistency/Common/FindManyP.h" 102 fTree = tfs->make<TTree>(
"tcshowerana",
"tcshowerana");
103 fTree->Branch(
"run", &
run,
"run/I");
112 fTree->Branch(
"shwid",
shwid,
"shwid[nshws]/I");
119 fTree->Branch(
"shwdedx",
shwdedx,
"shwdedx[nshws][2]/D");
138 std::vector<art::Ptr<recob::Hit>> hitlist;
142 std::vector<art::Ptr<sim::SimChannel>> simchanlist;
147 std::vector<art::Ptr<recob::Shower>> showerlist;
152 std::vector<art::Ptr<simb::MCTruth>> mclist;
159 if (showerListHandle.
isValid()) {
160 nshws = showerlist.size();
163 shwid[i] = showerlist[i]->ID();
164 shwdcosx[i] = showerlist[i]->Direction().X();
165 shwdcosy[i] = showerlist[i]->Direction().Y();
166 shwdcosz[i] = showerlist[i]->Direction().Z();
167 shwstartx[i] = showerlist[i]->ShowerStart().X();
168 shwstarty[i] = showerlist[i]->ShowerStart().Y();
169 shwstartz[i] = showerlist[i]->ShowerStart().Z();
170 for (
size_t j = 0; j < (showerlist[i]->dEdx()).
size(); ++j) {
171 shwdedx[i][j] = showerlist[i]->dEdx()[j];
188 if (showerlist.size()) {
190 std::vector<art::Ptr<recob::Hit>> showerhits = shwfm.at(0);
193 double tmpEfrac = 0.0;
194 double tmpEcomplet = 0;
195 truthMatcher(clockData, hitlist, showerhits, particle, tmpEfrac, tmpEcomplet);
197 std::cout <<
"shower pdg: " << particle->
PdgCode() <<
" efrac " << tmpEfrac <<
std::endl;
233 for (
int j = 0; j < 2; ++j) {
261 std::map<int, double> trkID_E;
262 for (
size_t j = 0; j < shower_hits.size(); ++j) {
265 if (hit->
View() != 1)
continue;
267 for (
size_t k = 0;
k < TrackIDs.size();
k++) {
268 if (trkID_E.find(
std::abs(TrackIDs[
k].trackID)) == trkID_E.end())
269 trkID_E[
std::abs(TrackIDs[k].trackID)] = 0;
270 trkID_E[
std::abs(TrackIDs[k].trackID)] += TrackIDs[
k].energy;
273 double max_E = -999.0;
274 double total_E = 0.0;
276 double partial_E = 0.0;
278 if (!trkID_E.size())
return;
280 total_E += ii->second;
281 if ((ii->second) > max_E) {
282 partial_E = ii->second;
289 Efrac = partial_E / total_E;
292 double totenergy = 0;
293 for (
size_t k = 0;
k < all_hits.size(); ++
k) {
296 for (
size_t l = 0;
l < TrackIDs.size(); ++
l) {
297 if (
std::abs(TrackIDs[
l].trackID) ==
TrackID) { totenergy += TrackIDs[
l].energy; }
300 Ecomplet = partial_E / totenergy;
float shwstartx[kMaxShowers]
double shwdedx[kMaxShowers][2]
const simb::MCNeutrino & GetNeutrino() const
TCShowerAnalysis(fhicl::ParameterSet const &pset)
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
void truthMatcher(detinfo::DetectorClocksData const &clockData, std::vector< art::Ptr< recob::Hit >> all_hits, std::vector< art::Ptr< recob::Hit >> shower_hits, const simb::MCParticle *&MCparticle, double &Efrac, double &Ecomplet)
const simb::MCParticle & Nu() const
int shwbestplane[kMaxShowers]
calo::CalorimetryAlg fCalorimetryAlg
geo::View_t View() const
View for the plane of the hit.
EDAnalyzer(fhicl::ParameterSet const &pset)
bool isValid() const noexcept
float shwdcosz[kMaxShowers]
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
#define DEFINE_ART_MODULE(klass)
float shwstarty[kMaxShowers]
constexpr int kMaxShowers
SubRunNumber_t subRun() const
std::string fHitModuleLabel
std::string fDigitModuleLabel
Detector simulation of raw signals on wires.
float shwdcosy[kMaxShowers]
std::string fShowerModuleLabel
float shwdcosx[kMaxShowers]
float shwstartz[kMaxShowers]
Declaration of signal hit object.
std::string fGenieGenModuleLabel
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
void analyze(const art::Event &evt) override
Contains all timing reference information for the detector.
std::vector< sim::TrackIDE > HitToEveTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
EventNumber_t event() const
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
QTextStream & endl(QTextStream &s)
Event finding and building.