All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Namespaces | Functions
NuMuEfficiencyStudy_module.cc File Reference
#include "art/Framework/Core/EDAnalyzer.h"
#include "art/Framework/Core/ModuleMacros.h"
#include "art/Framework/Principal/Event.h"
#include "art/Framework/Principal/Handle.h"
#include "art/Framework/Principal/Run.h"
#include "art/Framework/Principal/SubRun.h"
#include "canvas/Utilities/InputTag.h"
#include "fhiclcpp/ParameterSet.h"
#include "messagefacility/MessageLogger/MessageLogger.h"
#include "art/Framework/Services/Registry/ServiceHandle.h"
#include "lardataalg/DetectorInfo/DetectorPropertiesStandard.h"
#include "lardata/DetectorInfoServices/DetectorPropertiesService.h"
#include "lardata/DetectorInfoServices/DetectorClocksService.h"
#include "larcore/Geometry/Geometry.h"
#include "larcore/CoreUtils/ServiceUtil.h"
#include "larcorealg/Geometry/GeometryCore.h"
#include "larcorealg/Geometry/BoxBoundedGeo.h"
#include "larsim/MCCheater/BackTrackerService.h"
#include "larsim/MCCheater/ParticleInventoryService.h"
#include "art_root_io/TFileService.h"
#include "lardataobj/AnalysisBase/T0.h"
#include "larreco/RecoAlg/TrackMomentumCalculator.h"
#include "lardataobj/RecoBase/PFParticle.h"
#include "lardataobj/RecoBase/Vertex.h"
#include "lardataobj/RecoBase/Shower.h"
#include "lardataobj/RecoBase/Slice.h"
#include "lardataobj/RecoBase/Track.h"
#include "lardataobj/RecoBase/Hit.h"
#include "lardataobj/RecoBase/Cluster.h"
#include "lardataobj/AnalysisBase/Calorimetry.h"
#include "lardataobj/AnalysisBase/ParticleID.h"
#include "lardataobj/RecoBase/PFParticleMetadata.h"
#include "lardataobj/RecoBase/MCSFitResult.h"
#include "nusimdata/SimulationBase/MCParticle.h"
#include "nusimdata/SimulationBase/MCTruth.h"
#include "larcorealg/GeoAlgo/GeoAlgo.h"
#include "TH1D.h"
#include "sbncode/CAFMaker/RecoUtils/RecoUtils.h"
#include <numeric>

Go to the source code of this file.

Classes

struct  Histos
 
class  numu::NuMuEfficiencyStudy
 

Namespaces

 numu
 

Functions

float ContainedLength (const TVector3 &v0, const TVector3 &v1, const std::vector< geoalgo::AABox > &boxes)
 
const simb::MCParticle * Genie2G4MCParticle (const simb::MCParticle &genie_part, const simb::MCTruth &mctruth, const std::vector< art::Ptr< simb::MCParticle >> &g4_mcparticles, const std::vector< const sim::GeneratedParticleInfo * > infos)
 
 for (auto const &cryo:geometry->IterateCryostats())
 
 for (const std::vector< geo::BoxBoundedGeo > &tpcs:fTPCVolumes)
 
 InitHistos ()
 

Function Documentation

float ContainedLength ( const TVector3 &  v0,
const TVector3 &  v1,
const std::vector< geoalgo::AABox > &  boxes 
)
for ( auto const &cryo:geometry->  IterateCryostats())

Definition at line 197 of file NuMuEfficiencyStudy_module.cc.

197  : geometry->IterateCryostats()) {
199  tend = geometry->end_TPC(cryo.ID());
200  std::vector<geo::BoxBoundedGeo> this_tpc_volumes;
201  while (iTPC != tend) {
202  geo::TPCGeo const& TPC = *iTPC;
203  this_tpc_volumes.push_back(TPC.ActiveBoundingBox());
204  iTPC++;
205  }
206  fTPCVolumes.push_back(std::move(this_tpc_volumes));
207  }
const geo::GeometryCore * geometry
Geometry information for a single TPC.
Definition: TPCGeo.h:38
geo::BoxBoundedGeo const & ActiveBoundingBox() const
Returns the box of the active volume of this TPC.
Definition: TPCGeo.h:320
BEGIN_PROLOG TPC
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC in the detector.
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
Forward iterator browsing all geometry elements in the detector.
Definition: GeometryCore.h:727
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.
for ( const std::vector< geo::BoxBoundedGeo > &tpcs:fTPCVolumes  )

Definition at line 210 of file NuMuEfficiencyStudy_module.cc.

210  : fTPCVolumes) {
211  double XMin = std::min_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MinX() < rhs.MinX(); })->MinX();
212  double YMin = std::min_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MinY() < rhs.MinY(); })->MinY();
213  double ZMin = std::min_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MinZ() < rhs.MinZ(); })->MinZ();
214 
215  double XMax = std::max_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MaxX() < rhs.MaxX(); })->MaxX();
216  double YMax = std::max_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MaxY() < rhs.MaxY(); })->MaxY();
217  double ZMax = std::max_element(tpcs.begin(), tpcs.end(), [](auto &lhs, auto &rhs) { return lhs.MaxZ() < rhs.MaxZ(); })->MaxZ();
218 
219  fActiveVolumes.emplace_back(XMin, XMax, YMin, YMax, ZMin, ZMax);
220  fFiducialVolumes.emplace_back(XMin + fFiducialInset[0], XMax - fFiducialInset[1],
221  YMin + fFiducialInset[2], YMax - fFiducialInset[3],
222  ZMin + fFiducialInset[4], ZMax - fFiducialInset[5]);
223  }
const simb::MCParticle * Genie2G4MCParticle ( const simb::MCParticle &  genie_part,
const simb::MCTruth &  mctruth,
const std::vector< art::Ptr< simb::MCParticle >> &  g4_mcparticles,
const std::vector< const sim::GeneratedParticleInfo * >  infos 
)

Definition at line 591 of file NuMuEfficiencyStudy_module.cc.

595  {
596 
597  // only stable final state particles are propogated by G4
598  if (genie_part.StatusCode() != 1) return NULL;
599 
600  const simb::MCParticle *ret = NULL;
601  for (int iparticle = 0; iparticle < (int)g4_mcparticles.size(); iparticle++) {
602  if (infos[iparticle]->hasGeneratedParticleIndex() &&
603  (int)infos[iparticle]->generatedParticleIndex() < mctruth.NParticles() && // TODO: why is this number sometimes bigger than the number of particles?
604  mctruth.GetParticle(infos[iparticle]->generatedParticleIndex()).TrackId() == genie_part.TrackId() &&
605  g4_mcparticles[iparticle]->Process() == "primary" /* TODO: will have to remove this restriction to include secondary particles*/) {
606 
607  // if a genie particle re-scatters in g4 and makes more particles, then multiple g4 particles can match to a
608  // genie particle. Thus, we also check that the start location of the associated genie particle matches the g4
609  // and that the pdgid matches (to be on the safe side)
610  //
611  // Note that this should be accounted for by requiring the process to be primary. This is a bit of redundancy.
612  const simb::MCParticle& matched_genie_particle = mctruth.GetParticle(infos[iparticle]->generatedParticleIndex());
613  if ((matched_genie_particle.Position().Vect() - g4_mcparticles[iparticle]->Position().Vect()).Mag() < 1e-4 &&
614  matched_genie_particle.PdgCode() == g4_mcparticles[iparticle]->PdgCode()) {
615 
616  // this should only be true for one particle
617  assert(ret == NULL);
618  ret = g4_mcparticles[iparticle].get();
619  }
620  }
621  }
622  return ret;
623 }
do i e
InitHistos ( )