18 #include "canvas/Persistency/Common/FindManyP.h"    20 #include "art_root_io/TFileService.h"    37 #include "TEfficiency.h"    38 #include "TGraphAsymmErrors.h"    41 #define MAX_SHOWERS 1000    67   void endJob() 
override;
    69   void doEfficiencies();
    70   bool insideFV(
double vertex[4]);
   114   double MC_incoming_P[4];
   115   double MC_lepton_startMomentum[4];
   116   double MC_lepton_endMomentum[40];
   117   double MC_lepton_startXYZT[4];
   118   double MC_lepton_endXYZT[4];
   158   TEfficiency* h_Eff_Ev = 0;
   159   TEfficiency* h_Eff_Ee = 0;
   170   fMCTruthModuleLabel (p.
get< 
std::
string >(
"MCTruthModuleLabel")),
   171   fHitModuleLabel     (p.
get< 
std::
string >(
"HitModuleLabel")),
   172   fShowerModuleLabel  (p.
get< 
std::
string >(
"ShowerModuleLabel")),
   173   fTruthMatchDataModuleLabel (p.
get< 
std::
string >(
"TruthMatchDataModuleLabel")),
   174   fNeutrinoPDGcode    (p.
get<
int>(
"NeutrinoPDGcode")),
   175   fLeptonPDGcode      (p.
get<
int>(
"LeptonPDGcode")),
   176   fSaveMCTree         (p.
get<
bool>(
"SaveMCTree")),
   177   fHitShowerThroughPFParticle (p.
get<
bool>(
"HitShowerThroughPFParticle")),
   178   fMinPurity          (p.
get<double>(
"MinPurity")),
   179   fMinCompleteness    (p.
get<double>(
"MinCompleteness")),
   180   fFidVolCutX         (p.
get<
float>(
"FidVolCutX")),
   181   fFidVolCutY         (p.
get<
float>(
"FidVolCutY")),
   182   fFidVolCutZ         (p.
get<
float>(
"FidVolCutZ"))
   192   auto const* 
geo = lar::providerFrom<geo::Geometry>();
   200   for (
size_t i = 0; i<
geo->NTPC(); ++i){
   201     double local[3] = {0.,0.,0.};
   202     double world[3] = {0.,0.,0.};
   211     if (minx > world[0] - 
geo->DetHalfWidth(i))  minx = world[0]-
geo->DetHalfWidth(i);
   212     if (maxx < world[0] + 
geo->DetHalfWidth(i))  maxx = world[0]+
geo->DetHalfWidth(i);
   213     if (miny > world[1] - 
geo->DetHalfHeight(i)) miny = world[1]-
geo->DetHalfHeight(i);
   214     if (maxy < world[1] + 
geo->DetHalfHeight(i)) maxy = world[1]+
geo->DetHalfHeight(i);
   215     if (minz > world[2] - 
geo->DetLength(i)/2.)  minz = world[2]-
geo->DetLength(i)/2.;
   216     if (maxz < world[2] + 
geo->DetLength(i)/2.)  maxz = world[2]+
geo->DetLength(i)/2.;
   233   double E_bins[21] = {0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4,4.5,5.0,5.5,6.0,7.0,8.0,10.0,12.0,14.0,17.0,20.0,25.0};
   237   h_Ev_den = tfs->make<TH1D>(
"h_Ev_den", 
"Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency", 20, E_bins);
   239   h_Ev_num = tfs->make<TH1D>(
"h_Ev_num",
"Neutrino Energy; Neutrino Energy (GeV); Shower Reconstruction Efficiency",20,E_bins);
   242   h_Ee_den = tfs->make<TH1D>(
"h_Ee_den",
"Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",20,E_bins);
   244   h_Ee_num = tfs->make<TH1D>(
"h_Ee_num",
"Electron Energy; Electron Energy (GeV); Shower Reconstruction Efficiency",20,E_bins);
   248     fEventTree = 
new TTree(
"Event", 
"Event Tree from Sim & Reco");
   304   std::vector<art::Ptr<simb::MCTruth>> MCtruthlist;
   308   int MCinteractions = MCtruthlist.size();
   310   for (
int i=0; i<MCinteractions; i++){
   311     MCtruth = MCtruthlist[i];
   322       const TLorentzVector& nu_momentum = nu.
Nu().
Momentum(0);
   339     int nParticles =  MCtruthlist[0]->NParticles();
   341     for (
int i=0; i<nParticles; i++){
   354   const sim::ParticleList& plist = pi_serv->
ParticleList();
   358     particle = ipar->second; 
   362       const TLorentzVector& lepton_momentum =particle->
Momentum(0);
   363       const TLorentzVector& lepton_position =particle->
Position(0);
   364       const TLorentzVector& lepton_positionEnd   = particle->
EndPosition();
   365       const TLorentzVector& lepton_momentumEnd   = particle->
EndMomentum();
   382   bool isFiducial = 
false;
   411   std::vector<art::Ptr<recob::Hit>> all_hits;
   418   double ehit_total =0.0;
   422   std::map<int,double> all_hits_trk_Q;
   423   for (
size_t i=0; i <  all_hits.size(); ++i) {
   425     auto particles = fmhitmc.at(hit.
key());
   426     auto hitmatch = fmhitmc.data(hit.
key());
   427     double maxenergy = -1e9;
   429     for (
size_t j = 0; j < particles.size(); ++j){
   430       if (!particles[j]) 
continue;
   434       if ( (hitmatch[j]->
energy) > maxenergy ){
   435         maxenergy = hitmatch[j]->energy;
   440    all_hits_trk_Q[hit_TrackId] += hit->
Integral(); 
   449   double temp_sh_ehit_Q = 0.0;
   450   double temp_sh_allHit_Q = 0.0;
   451   int temp_sh_TrackId = -999;
   455   std::vector<art::Ptr<recob::Shower>> showerlist;
   465   std::map<int,double> showers_trk_Q;
   470     std::map<int,double> sh_hits_trk_Q;
   471     sh_hits_trk_Q.clear();
   487     std::vector<art::Ptr<recob::Hit>> sh_hits;
   497       std::vector<art::Ptr<recob::PFParticle> > pfps;
   501       std::vector<art::Ptr<recob::Cluster> > clusters;
   507         std::vector<art::Ptr<recob::PFParticle>> pfs = fmps.at(i);
   508         for (
size_t ipf = 0; ipf<pfs.size(); ++ipf){
   510             std::vector<art::Ptr<recob::Cluster>> clus = fmcp.at(pfs[ipf].
key());
   511             for (
size_t iclu = 0; iclu<clus.size(); ++iclu){
   513                 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(clus[iclu].
key());
   514                 for (
size_t ihit = 0; ihit<hits.size(); ++ihit){
   515                   sh_hits.push_back(hits[ihit]);
   533       sh_hits = sh_hitsAll.at(i);
   538     for (
size_t k=0; 
k <  sh_hits.size(); ++
k) {
   540       auto particles = fmhitmc.at(hit.
key());
   541       auto hitmatch = fmhitmc.data(hit.
key());
   542       double maxenergy = -1e9;
   544       for (
size_t j = 0; j < particles.size(); ++j){
   545         if (!particles[j]) 
continue;
   549         if ( (hitmatch[j]->
energy) > maxenergy ){
   550           maxenergy = hitmatch[j]->energy;
   558       sh_hits_trk_Q[hit_TrackId] += hit->
Integral();
   564     double maxshowerQ = -1.0e9;
   568       if (
k->second > maxshowerQ) {
   569         maxshowerQ = 
k->second;
   606   if (MClepton_reco && MClepton) {
   608       if ((temp_sh_allHit_Q >= temp_sh_ehit_Q) && (temp_sh_ehit_Q > 0.0)) {
   629     double temp_esh_1_allhit = -1.0e9;
   630     int temp_shower_index = -999;
   631     int temp_esh_index = 0;
   645           temp_shower_index = i;
   668     TGraphAsymmErrors *grEff_Ev = 
h_Eff_Ev->CreateGraph();
   669     grEff_Ev->Write(
"grEff_Ev");
   675     TGraphAsymmErrors *grEff_Ee = 
h_Eff_Ee->CreateGraph();
   676     grEff_Ee->Write(
"grEff_Ee");
   685   double x = vertex[0];
   686   double y = vertex[1];
   687   double z = vertex[2];
 def analyze(root, level, gtrees, gbranches, doprint)
 
double esh_each_purity[MAX_SHOWERS]
 
double sh_direction_X[MAX_SHOWERS]
 
const TVector3 & ShowerStart() const 
 
const TLorentzVector & Position(const int i=0) const 
 
const simb::MCNeutrino & GetNeutrino() const 
 
double MC_lepton_startEnergy
 
const TLorentzVector & EndPosition() const 
 
double esh_1_completeness
 
NuShowerEff(fhicl::ParameterSet const &p)
 
double sh_start_Y[MAX_SHOWERS]
 
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
 
const simb::MCParticle * TrackIdToParticle_P(int id) const 
 
const simb::MCParticle & Nu() const 
 
int count_primary_e_in_Event
 
Geometry information for a single TPC. 
 
double sh_direction_Y[MAX_SHOWERS]
 
std::string fMCTruthModuleLabel
 
float Integral() const 
Integral under the calibrated signal waveform of the hit, in tick x ADC units. 
 
double MC_lepton_startMomentum[4]
 
const art::Ptr< simb::MCTruth > & ParticleToMCTruth_P(const simb::MCParticle *p) const 
 
art framework interface to geometry description 
 
bool fHitShowerThroughPFParticle
 
int sh_TrackId[MAX_SHOWERS]
 
std::string fShowerModuleLabel
 
int InteractionType() const 
 
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const 
 
QTextStream & reset(QTextStream &s)
 
const simb::MCParticle & Lepton() const 
 
#define DEFINE_ART_MODULE(klass)                                                                                          
 
std::string fHitModuleLabel
 
double esh_each_completeness[MAX_SHOWERS]
 
int sh_hasPrimary_e[MAX_SHOWERS]
 
void analyze(art::Event const &e) override
 
key_type key() const  noexcept
 
bool insideFV(double vertex[4])
 
SubRunNumber_t subRun() const 
 
const TVector3 & Direction() const 
 
double sh_start_Z[MAX_SHOWERS]
 
double sh_purity[MAX_SHOWERS]
 
Detector simulation of raw signals on wires. 
 
const sim::ParticleList & ParticleList() const 
 
double sh_ehit_Q[MAX_SHOWERS]
 
double MC_lepton_startXYZT[4]
 
double MC_lepton_endXYZT[4]
 
double sh_direction_Z[MAX_SHOWERS]
 
Declaration of signal hit object. 
 
double sh_completeness[MAX_SHOWERS]
 
double MC_lepton_endMomentum[40]
 
double sh_allhit_Q[MAX_SHOWERS]
 
const TLorentzVector & Momentum(const int i=0) const 
 
EventNumber_t event() const 
 
void beginRun(art::Run const &run) override
 
std::string fTruthMatchDataModuleLabel
 
auto const & get(AssnsNode< L, R, D > const &r)
 
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
 
const simb::MCParticle * TrackIdToMotherParticle_P(int id) const 
 
Event generator information. 
 
LArSoft geometry interface. 
 
double sh_start_X[MAX_SHOWERS]
 
const TLorentzVector & EndMomentum() const 
 
void LocalToWorld(const double *tpc, double *world) const 
Transform point from local TPC frame to world frame. 
 
double sh_length[MAX_SHOWERS]
 
QTextStream & endl(QTextStream &s)