All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TPCPurityInfoAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: TPCPurityInfoAna
3 // Plugin Type: analyzer (art v3_04_00)
4 // File: TPCPurityInfoAna_module.cc
5 //
6 // Generated at Sun Jan 26 22:13:22 2020 by Wesley Ketchum using cetskelgen
7 // from cetlib version v3_09_00.
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/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 
20 //purity info class
22 
23 //output to ntuple
24 #include "art_root_io/TFileService.h"
25 #include "TNtuple.h"
26 
27 namespace ana {
28  class TPCPurityInfoAna;
29 }
30 
31 
32 class ana::TPCPurityInfoAna : public art::EDAnalyzer {
33 public:
34  explicit TPCPurityInfoAna(fhicl::ParameterSet const& p);
35  // The compiler-generated destructor is fine for non-base
36  // classes without bare pointers or other resource use.
37 
38  // Plugins should not be copied or assigned.
39  TPCPurityInfoAna(TPCPurityInfoAna const&) = delete;
43 
44  void analyze(art::Event const& e) override;
45  void beginJob() override;
46 
47 private:
48 
49  // Declare member data here.
50  art::InputTag const fPurityInfoLabel;
51  TNtuple* fPurityTuple;
52 
53  bool fPrintInfo;
54 
55 };
56 
57 
58 ana::TPCPurityInfoAna::TPCPurityInfoAna(fhicl::ParameterSet const& p)
59  : EDAnalyzer{p} // ,
60  , fPurityInfoLabel(p.get<art::InputTag>("PurityInfoLabel"))
61  , fPrintInfo(p.get<bool>("PrintInfo",false))
62 {
63  consumes< std::vector<anab::TPCPurityInfo> >(fPurityInfoLabel);
64 }
65 
67 {
68 
69  // get access to the TFile service
70  art::ServiceHandle<art::TFileService> tfs;
71 
72  fPurityTuple = tfs->make<TNtuple>("purityTuple","Purity Tuple","run:subrun:ev:cryo:tpc:wires:ticks:att:err");
73 
74 }
75 void ana::TPCPurityInfoAna::analyze(art::Event const& e)
76 {
77 
78  if(fPrintInfo)
79  std::cout << "Processing Run " << e.run()
80  << ", Subrun " << e.subRun()
81  << ", Event " << e.event()
82  << ":" << std::endl;
83 
84  art::Handle< std::vector<anab::TPCPurityInfo> > purityInfoHandle;
85  e.getByLabel(fPurityInfoLabel,purityInfoHandle);
86  auto const& purityInfoVec(*purityInfoHandle);
87 
88  if(fPrintInfo)
89  std::cout << "\tThere are " << purityInfoVec.size() << " purity info objects in the event."
90  << std::endl;
91 
92  for(auto const& pinfo : purityInfoVec){
93  if(fPrintInfo) pinfo.Print();
94  fPurityTuple->Fill(e.run(),e.subRun(),e.event(),pinfo.Cryostat,pinfo.TPC,pinfo.Wires,pinfo.Ticks,pinfo.Attenuation,pinfo.FracError);
95  }
96 
97 
98 }
99 
100 DEFINE_ART_MODULE(ana::TPCPurityInfoAna)
void analyze(art::Event const &e) override
pdgs p
Definition: selectors.fcl:22
process_name opflashCryoW ana
do i e
TPCPurityInfoAna(fhicl::ParameterSet const &p)
art::ServiceHandle< art::TFileService > tfs
TPCPurityInfoAna & operator=(TPCPurityInfoAna const &)=delete
art::InputTag const fPurityInfoLabel
BEGIN_PROLOG could also be cout