All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FluxGeoFilter_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: FluxGeoFilter
3 // Plugin Type: filter (art v3_01_02)
4 // File: FluxGeoFilter_module.cc
5 //
6 // Generated at Fri Apr 3 16:21:46 2020 by Zarko Pavlovic using cetskelgen
7 // from cetlib version v3_05_01.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDFilter.h"
11 #include "art/Framework/Core/ModuleMacros.h"
12 #include "art/Framework/Principal/Event.h"
13 #include "art/Framework/Principal/Handle.h"
14 #include "art/Framework/Principal/Run.h"
15 #include "art/Framework/Principal/SubRun.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 #include "messagefacility/MessageLogger/MessageLogger.h"
19 #include "art_root_io/TFileService.h"
20 
21 //geometry
24 #include "TGeoManager.h"
25 
26 #include "nusimdata/SimulationBase/MCFlux.h"
27 #include "nusimdata/SimulationBase/MCTruth.h"
28 
29 #include <memory>
30 
31 
32 class FluxGeoFilter;
33 
34 
35 class FluxGeoFilter : public art::EDFilter {
36 public:
37  explicit FluxGeoFilter(fhicl::ParameterSet const& p);
38  // The compiler-generated destructor is fine for non-base
39  // classes without bare pointers or other resource use.
40 
41  // Plugins should not be copied or assigned.
42  FluxGeoFilter(FluxGeoFilter const&) = delete;
43  FluxGeoFilter(FluxGeoFilter&&) = delete;
44  FluxGeoFilter& operator=(FluxGeoFilter const&) = delete;
46 
47  // Required functions.
48  bool filter(art::Event& e) override;
49 
50 private:
51  // Declare member data here.
52  std::set<std::string> fVolFlux;
53 };
54 
55 FluxGeoFilter::FluxGeoFilter(fhicl::ParameterSet const& p)
56  : EDFilter{p} // ,
57  // More initializers here.
58 {
59  std::cout<<"Configuring flux filter."<<std::endl;
60  std::vector<std::string> tmp=p.get<std::vector<std::string> >("volumes");
61  fVolFlux.insert(tmp.begin(),tmp.end());
62 
63  std::cout<<"Filtering flux through volumes: "<<std::endl;
64  for (auto s: fVolFlux) std::cout<<"\t"<<s<<std::endl;
65 }
66 
67 bool FluxGeoFilter::filter(art::Event& e)
68 {
69 
70  // Implementation of required member function here.
71  bool result=false; //false filters out, true passes
72 
73  //check if neutrino goes through volTPCActive
74  geo::GeometryCore const* geom = lar::providerFrom<geo::Geometry>();
75  TGeoManager* rgeo=geom->ROOTGeoManager();
76 
77  // art::Handle< std::vector<simb::MCFlux> > mcFluxHandle;
78  // e.getByLabel("flux",mcFluxHandle);
79  // std::vector<simb::MCFlux> const& fluxlist = *mcFluxHandle;
80 
81  art::Handle< std::vector<simb::MCTruth> > mctruthHandle;
82  e.getByLabel("flux",mctruthHandle);
83  std::vector<simb::MCTruth> const& mclist = *mctruthHandle;
84 
85  for(unsigned int inu = 0; inu < mclist.size(); inu++){
86  simb::MCParticle nu = mclist[inu].GetNeutrino().Nu();
87  rgeo->SetCurrentPoint(nu.Vx(),nu.Vy(),nu.Vz());
88  rgeo->SetCurrentDirection(nu.Px(),nu.Py(),nu.Pz());
89  TGeoNode* node=rgeo->FindNode();
90  while (node) {
91  std::string volname=node->GetVolume()->GetName();
92  rgeo->FindNextBoundary();
93  node=gGeoManager->Step();
94  if (fVolFlux.find(volname)!=fVolFlux.end()) {
95  result=true;
96  break;
97  }
98  }
99  }
100  return result;
101 }
102 
103 DEFINE_ART_MODULE(FluxGeoFilter)
Utilities related to art service access.
pdgs p
Definition: selectors.fcl:22
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
std::set< std::string > fVolFlux
Description of geometry of one entire detector.
FluxGeoFilter & operator=(FluxGeoFilter const &)=delete
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do i e
FluxGeoFilter(fhicl::ParameterSet const &p)
BEGIN_PROLOG SN nu
bool filter(art::Event &e) override
art framework interface to geometry description
BEGIN_PROLOG could also be cout