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

Public Member Functions

 ClusterCounter3 (fhicl::ParameterSet const &p)
 
 ClusterCounter3 (ClusterCounter3 const &)=delete
 
 ClusterCounter3 (ClusterCounter3 &&)=delete
 
ClusterCounter3operator= (ClusterCounter3 const &)=delete
 
ClusterCounter3operator= (ClusterCounter3 &&)=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 Member Functions

float sumAdc (const std::vector< art::Ptr< recob::Hit > > &hits) const
 

Private Attributes

size_t fEvNumber
 
TTree * fEventTree
 
size_t fNClusters
 
TTree * fClusterTree
 
size_t fNHits
 
float fAdcSum
 
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 29 of file ClusterCounter3_module.cc.

Constructor & Destructor Documentation

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

Definition at line 63 of file ClusterCounter3_module.cc.

63  : EDAnalyzer(p)
64 {
65  fClusterModuleLabel = p.get< std::string >("ClusterModuleLabel");
66  fMinSize = p.get< size_t >("MinSize");
67 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
tutorial::ClusterCounter3::ClusterCounter3 ( ClusterCounter3 const &  )
delete
tutorial::ClusterCounter3::ClusterCounter3 ( ClusterCounter3 &&  )
delete

Member Function Documentation

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

Implements art::EDAnalyzer.

Definition at line 83 of file ClusterCounter3_module.cc.

84 {
85  fEvNumber = evt.id().event();
86  mf::LogVerbatim("ClusterCounter3") << "ClusterCounter3 module on event #" << fEvNumber;
87 
88  // use auto to make the line shorter when you remember all art types,
89  // the full type of the handle is: art::ValidHandle< std::vector<recob::Cluster> >
90  auto cluHandle = evt.getValidHandle< std::vector<recob::Cluster> >(fClusterModuleLabel);
91 
92  // this will let us look for all hits associated to selected cluster
93  art::FindManyP< recob::Hit > hitsFromClusters(cluHandle, evt, fClusterModuleLabel);
94 
95  fNClusters = 0;
96 
97  // and here we go by index:
98  for (size_t i = 0; i < cluHandle->size(); ++i)
99  {
100  fNHits = cluHandle->at(i).NHits();
101  fAdcSum = sumAdc(hitsFromClusters.at(i));
102  fClusterTree->Fill();
103 
104  mf::LogVerbatim("ClusterCounter3")
105  << "NHits() = " << fNHits << ", assn size = " << hitsFromClusters.at(i).size()
106  << " SummedADC() = " << cluHandle->at(i).SummedADC() << ", sum hits adc = " << fAdcSum;
107 
108  if (fNHits >= fMinSize) { ++fNClusters; }
109  }
110  fEventTree->Fill();
111 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
unsigned int event
Definition: DataStructs.h:636
TCEvent evt
Definition: DataStructs.cxx:7
float sumAdc(const std::vector< art::Ptr< recob::Hit > > &hits) const
void tutorial::ClusterCounter3::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 69 of file ClusterCounter3_module.cc.

70 {
71  art::ServiceHandle<art::TFileService> tfs; // TTree's are created in the memory managed by ROOT (you don't delete them)
72 
73  fEventTree = tfs->make<TTree>("EventTree", "event by event info");
74  fEventTree->Branch("event", &fEvNumber, "fEvNumber/I");
75  fEventTree->Branch("nclusters", &fNClusters, "fNClusters/I");
76 
77  fClusterTree = tfs->make<TTree>("ClusterTree", "cluster by cluster info");
78  fClusterTree->Branch("event", &fEvNumber, "fEvNumber/I");
79  fClusterTree->Branch("nhits", &fNHits, "fNHits/I");
80  fClusterTree->Branch("adcsum", &fAdcSum, "fAdcSum/F");
81 }
void tutorial::ClusterCounter3::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 123 of file ClusterCounter3_module.cc.

124 {
125  mf::LogVerbatim("ClusterCounter3") << "ClusterCounter3 finished job";
126 }
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
ClusterCounter3& tutorial::ClusterCounter3::operator= ( ClusterCounter3 const &  )
delete
ClusterCounter3& tutorial::ClusterCounter3::operator= ( ClusterCounter3 &&  )
delete
float tutorial::ClusterCounter3::sumAdc ( const std::vector< art::Ptr< recob::Hit > > &  hits) const
private

Definition at line 113 of file ClusterCounter3_module.cc.

114 {
115  float sum = 0;
116  for (auto const & h : hits)
117  {
118  sum += h->SummedADC();
119  }
120  return sum;
121 }

Member Data Documentation

float tutorial::ClusterCounter3::fAdcSum
private

Definition at line 56 of file ClusterCounter3_module.cc.

art::InputTag tutorial::ClusterCounter3::fClusterModuleLabel
private

Definition at line 59 of file ClusterCounter3_module.cc.

TTree* tutorial::ClusterCounter3::fClusterTree
private

Definition at line 54 of file ClusterCounter3_module.cc.

TTree* tutorial::ClusterCounter3::fEventTree
private

Definition at line 51 of file ClusterCounter3_module.cc.

size_t tutorial::ClusterCounter3::fEvNumber
private

Definition at line 49 of file ClusterCounter3_module.cc.

size_t tutorial::ClusterCounter3::fMinSize
private

Definition at line 60 of file ClusterCounter3_module.cc.

size_t tutorial::ClusterCounter3::fNClusters
private

Definition at line 52 of file ClusterCounter3_module.cc.

size_t tutorial::ClusterCounter3::fNHits
private

Definition at line 55 of file ClusterCounter3_module.cc.


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