All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PIDAAnalyzer_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: PIDAAnalyzer
3 // Module Type: analyzer
4 // File: PIDAAnalyzer_module.cc
5 //
6 // Generated at Sat Nov 1 23:10:27 2014 by Wesley Ketchum using artmod
7 // from cetpkgsupport v1_07_01.
8 ////////////////////////////////////////////////////////////////////////
9 
10 #include "art/Framework/Core/EDAnalyzer.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/Services/Registry/ServiceHandle.h"
15 #include "fhiclcpp/ParameterSet.h"
16 #include "art_root_io/TFileService.h"
17 
18 #include "PIDAAlg.h"
20 
21 #include "TH1F.h"
22 #include "TTree.h"
23 
24 namespace pid{
25  class PIDAAnalyzer;
26 }
27 
28 class pid::PIDAAnalyzer : public art::EDAnalyzer {
29 public:
30  explicit PIDAAnalyzer(fhicl::ParameterSet const & p);
31  // The destructor generated by the compiler is fine for classes
32  // without bare pointers or other resource use.
33 
34  // Plugins should not be copied or assigned.
35  PIDAAnalyzer(PIDAAnalyzer const &) = delete;
36  PIDAAnalyzer(PIDAAnalyzer &&) = delete;
37  PIDAAnalyzer & operator = (PIDAAnalyzer const &) = delete;
38  PIDAAnalyzer & operator = (PIDAAnalyzer &&) = delete;
39 
40  void analyze(art::Event const & e) override;
41 
42  void beginJob() override;
43 
44 private:
45 
46  std::string fCaloModuleLabel;
48 
49 };
50 
51 
52 pid::PIDAAnalyzer::PIDAAnalyzer(fhicl::ParameterSet const & p)
53  :
54  EDAnalyzer(p),
55  fCaloModuleLabel(p.get<std::string>("CaloModuleLabel")),
56  fPIDAAlg(p.get<fhicl::ParameterSet>("PIDAAlg"))
57 {}
58 
60  art::ServiceHandle<art::TFileService const> tfs;
61 
62  std::vector<TH1F*> kde_hists;
63  for(size_t i_b=0; i_b<fPIDAAlg.getNKDEBandwidths(); i_b++){
64  std::stringstream hname;
65  hname << "hkde_" << i_b;
66  kde_hists.push_back(tfs->make<TH1F>(hname.str().c_str(),"PIDA KDE Distribution",100,0,30));
67  }
68 
69  fPIDAAlg.SetPIDATree(tfs->make<TTree>("pida","PIDAPropertiesTree"),
70  tfs->make<TH1F>("hvals","PIDA Distribution",100,0,30),
71  kde_hists);
72 
73 }
74 
75 void pid::PIDAAnalyzer::analyze(art::Event const & e)
76 {
77  art::Handle< std::vector<anab::Calorimetry> > caloHandle;
78  e.getByLabel(fCaloModuleLabel,caloHandle);
79  std::vector<anab::Calorimetry> const& caloVector(*caloHandle);
80 
81  for(size_t i_calo=0; i_calo<caloVector.size(); i_calo++){
82  fPIDAAlg.FillPIDATree(e.run(),e.event(),i_calo,caloVector[i_calo]);
83  }
84 
85 }
86 
87 DEFINE_ART_MODULE(pid::PIDAAnalyzer)
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
void beginJob() override
pdgs p
Definition: selectors.fcl:22
PIDAAnalyzer(fhicl::ParameterSet const &p)
PIDAAnalyzer & operator=(PIDAAnalyzer const &)=delete
std::string fCaloModuleLabel
do i e
art::ServiceHandle< art::TFileService > tfs
void analyze(art::Event const &e) override