All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SimDriftedElectronClusterAna_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // Class: SimDriftedElectronClusterAna
3 // Plugin Type: analyzer (art v2_05_00)
4 // File: DriftedElectronsClustersSAna_module.cc
5 //
6 ////////////////////////////////////////////////////////////////////////
7 
9 
10 #include "art_root_io/TFileService.h"
11 #include "art/Framework/Core/EDAnalyzer.h"
12 #include "art/Framework/Core/ModuleMacros.h"
13 #include "art/Framework/Principal/Event.h"
14 #include "art/Framework/Principal/Handle.h"
15 #include "art/Framework/Services/Registry/ServiceHandle.h"
16 #include "canvas/Utilities/InputTag.h"
17 #include "fhiclcpp/ParameterSet.h"
18 
19 #include "TNtuple.h"
20 
21 #include <iostream>
22 #include <vector>
23 
24 namespace detsim {
25 
26 class SimDriftedElectronClusterAna : public art::EDAnalyzer {
27 public:
28  explicit SimDriftedElectronClusterAna(fhicl::ParameterSet const & p);
29  // The compiler-generated destructor is fine for non-base
30  // classes without bare pointers or other resource use.
31 
32  // Plugins should not be copied or assigned.
37 
38  // Required functions.
39  void analyze(art::Event const & e) override;
40 
41  // Selected optional functions.
42  void beginJob() override;
43 
44 private:
45 
46 
47  art::InputTag fEDepTag;
48 
49  TNtuple* fNtuple;
50 };
51 
52 
54  : EDAnalyzer(p)
55  , fEDepTag{p.get<art::InputTag>("EDepModuleLabel")}
56 {}
57 
58 void SimDriftedElectronClusterAna::analyze(art::Event const & e)
59 {
60  auto const& edep_handle = e.getValidHandle< std::vector<sim::SimDriftedElectronCluster> >(fEDepTag);
61  auto const& edep_vec(*edep_handle);
62  std::cout<< "=====================edep"<<edep_vec.size()<<std::endl;
63  for(auto const& edep : edep_vec){
64  fNtuple->Fill(e.run(),e.event(),
65  edep.NumberOfElectrons(),
66  edep.Time());
67  }
68 }
69 
71 {
72  art::ServiceHandle<art::TFileService const> tfs;
73  fNtuple = tfs->make<TNtuple>("nt_is","EDep IS Calc Ntuple","run:event:ne:t");
74 }
75 } // namespace detsim
76 
77 DEFINE_ART_MODULE(detsim::SimDriftedElectronClusterAna)
contains objects relating to SimDriftedElectronCluster
pdgs p
Definition: selectors.fcl:22
SimDriftedElectronClusterAna & operator=(SimDriftedElectronClusterAna const &)=delete
do i e
art::ServiceHandle< art::TFileService > tfs
BEGIN_PROLOG could also be cout