Public Member Functions | Private Attributes | List of all members
tutorial::ClusterCounter2 Class Reference
Inheritance diagram for tutorial::ClusterCounter2:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 ClusterCounter2 (fhicl::ParameterSet const &p)
 
 ClusterCounter2 (ClusterCounter2 const &)=delete
 
 ClusterCounter2 (ClusterCounter2 &&)=delete
 
ClusterCounter2operator= (ClusterCounter2 const &)=delete
 
ClusterCounter2operator= (ClusterCounter2 &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void endJob () override
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

size_t fEvNumber
 
TTree * fEventTree
 
size_t fNClusters
 
TTree * fClusterTree
 
size_t fNHits
 
art::InputTag fClusterModuleLabel
 
size_t fMinSize
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 27 of file ClusterCounter2_module.cc.

Constructor & Destructor Documentation

tutorial::ClusterCounter2::ClusterCounter2 ( fhicl::ParameterSet const &  p)
explicit

Definition at line 58 of file ClusterCounter2_module.cc.

58  : EDAnalyzer(p)
59 {
60  fClusterModuleLabel = p.get< std::string >("ClusterModuleLabel");
61  fMinSize = p.get< size_t >("MinSize");
62 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
tutorial::ClusterCounter2::ClusterCounter2 ( ClusterCounter2 const &  )
delete
tutorial::ClusterCounter2::ClusterCounter2 ( ClusterCounter2 &&  )
delete

Member Function Documentation

void tutorial::ClusterCounter2::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 77 of file ClusterCounter2_module.cc.

78 {
79  fEvNumber = evt.id().event();
80  mf::LogVerbatim("ClusterCounter2") << "ClusterCounter2 module on event #" << fEvNumber;
81 
82  // use auto to make the line shorter when you remember all art types,
83  // the full type being de-referenced here is: art::ValidHandle< std::vector<recob::Cluster> >
84  auto const & clusters = *evt.getValidHandle< std::vector<recob::Cluster> >(fClusterModuleLabel);
85 
86  fNClusters = 0;
87 
88  // if you are old c++ granpa (or need cluster index, which may indeed happen!):
89  // for (size_t i = 0; i < clusters.size(); ++i)
90  // or:
91  for (auto const & clu : clusters) // loop over recob::Cluster's stored in the std::vector
92  {
93  fNHits = clu.NHits();
94  fClusterTree->Fill();
95 
96  if (fNHits >= fMinSize) { ++fNClusters; }
97  }
98  fEventTree->Fill();
99 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int event
Definition: DataStructs.h:636
TCEvent evt
Definition: DataStructs.cxx:7
void tutorial::ClusterCounter2::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 64 of file ClusterCounter2_module.cc.

65 {
66  art::ServiceHandle<art::TFileService> tfs; // TTree's are created in the memory managed by ROOT (you don't delete them)
67 
68  fEventTree = tfs->make<TTree>("EventTree", "event by event info");
69  fEventTree->Branch("event", &fEvNumber, "fEvNumber/I");
70  fEventTree->Branch("nclusters", &fNClusters, "fNClusters/I");
71 
72  fClusterTree = tfs->make<TTree>("ClusterTree", "cluster by cluster info");
73  fClusterTree->Branch("event", &fEvNumber, "fEvNumber/I");
74  fClusterTree->Branch("nhits", &fNHits, "fNHits/I");
75 }
void tutorial::ClusterCounter2::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 101 of file ClusterCounter2_module.cc.

102 {
103  mf::LogVerbatim("ClusterCounter2") << "ClusterCounter2 finished job";
104 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
ClusterCounter2& tutorial::ClusterCounter2::operator= ( ClusterCounter2 const &  )
delete
ClusterCounter2& tutorial::ClusterCounter2::operator= ( ClusterCounter2 &&  )
delete

Member Data Documentation

art::InputTag tutorial::ClusterCounter2::fClusterModuleLabel
private

Definition at line 54 of file ClusterCounter2_module.cc.

TTree* tutorial::ClusterCounter2::fClusterTree
private

Definition at line 50 of file ClusterCounter2_module.cc.

TTree* tutorial::ClusterCounter2::fEventTree
private

Definition at line 47 of file ClusterCounter2_module.cc.

size_t tutorial::ClusterCounter2::fEvNumber
private

Definition at line 45 of file ClusterCounter2_module.cc.

size_t tutorial::ClusterCounter2::fMinSize
private

Definition at line 55 of file ClusterCounter2_module.cc.

size_t tutorial::ClusterCounter2::fNClusters
private

Definition at line 48 of file ClusterCounter2_module.cc.

size_t tutorial::ClusterCounter2::fNHits
private

Definition at line 51 of file ClusterCounter2_module.cc.


The documentation for this class was generated from the following file: