14 #include "art_root_io/TFileService.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");
137 std::vector<art::Ptr<recob::Hit>> hitlist;
141 std::vector<art::Ptr<sim::SimChannel>> simchanlist;
146 std::vector<art::Ptr<recob::Shower>> showerlist;
151 std::vector<art::Ptr<simb::MCTruth>> mclist;
158 if (showerListHandle.
isValid()) {
159 nshws = showerlist.size();
161 for (
int i = 0; i < std::min(
int(showerlist.size()),
kMaxShowers); ++i) {
162 shwid[i] = showerlist[i]->ID();
163 shwdcosx[i] = showerlist[i]->Direction().X();
164 shwdcosy[i] = showerlist[i]->Direction().Y();
165 shwdcosz[i] = showerlist[i]->Direction().Z();
166 shwstartx[i] = showerlist[i]->ShowerStart().X();
167 shwstarty[i] = showerlist[i]->ShowerStart().Y();
168 shwstartz[i] = showerlist[i]->ShowerStart().Z();
169 for (
size_t j = 0; j < (showerlist[i]->dEdx()).
size(); ++j) {
170 shwdedx[i][j] = showerlist[i]->dEdx()[j];
187 if (showerlist.size()) {
189 std::vector<art::Ptr<recob::Hit>> showerhits = shwfm.at(0);
192 double tmpEfrac = 0.0;
193 double tmpEcomplet = 0;
194 truthMatcher(clockData, hitlist, showerhits, particle, tmpEfrac, tmpEcomplet);
196 std::cout <<
"shower pdg: " << particle->
PdgCode() <<
" efrac " << tmpEfrac << std::endl;
231 for (
int j = 0; j < 2; ++j) {
258 std::map<int, double> trkID_E;
259 for (
size_t j = 0; j < shower_hits.size(); ++j) {
262 if (hit->
View() != 1)
continue;
264 for (
size_t k = 0; k < TrackIDs.size(); k++) {
265 if (trkID_E.find(
std::abs(TrackIDs[k].trackID)) == trkID_E.end())
266 trkID_E[
std::abs(TrackIDs[k].trackID)] = 0;
267 trkID_E[
std::abs(TrackIDs[k].trackID)] += TrackIDs[k].energy;
270 double max_E = -999.0;
271 double total_E = 0.0;
273 double partial_E = 0.0;
275 if (!trkID_E.size())
return;
277 total_E += ii->second;
278 if ((ii->second) > max_E) {
279 partial_E = ii->second;
286 Efrac = partial_E / total_E;
289 double totenergy = 0;
290 for (
size_t k = 0; k < all_hits.size(); ++k) {
293 for (
size_t l = 0; l < TrackIDs.size(); ++l) {
294 if (
std::abs(TrackIDs[l].trackID) ==
TrackID) { totenergy += TrackIDs[l].energy; }
297 Ecomplet = partial_E / totenergy;
SubRunNumber_t subRun() const
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)
Declaration of signal hit object.
const simb::MCParticle & Nu() const
constexpr auto abs(T v)
Returns the absolute value of the argument.
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.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
#define DEFINE_ART_MODULE(klass)
float shwstarty[kMaxShowers]
constexpr int kMaxShowers
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]
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
std::string fGenieGenModuleLabel
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
object containing MC truth information necessary for making RawDigits and doing back tracking ...
EventNumber_t event() const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Event finding and building.