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

Public Member Functions

 ClusteringValidation (fhicl::ParameterSet const &p)
 
- 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

void analyze (art::Event const &evt)
 
void beginJob ()
 
void endJob ()
 

Private Attributes

std::vector< std::stringfClusterModuleLabels
 
std::string fHitsModuleLabel
 
int fMinHitsInPlane
 
TCanvas * fCanvas
 
std::map< std::string, std::unique_ptr< ClusterAnalyser > > clusterAnalysis
 

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 644 of file ClusteringValidation_module.cc.

Constructor & Destructor Documentation

ClusteringValidation::ClusteringValidation::ClusteringValidation ( fhicl::ParameterSet const &  p)
explicit

Definition at line 668 of file ClusteringValidation_module.cc.

669  : EDAnalyzer(pset)
670 {
671  fMinHitsInPlane = pset.get<int>("MinHitsInPlane");
672  fClusterModuleLabels = pset.get<std::vector<std::string>>("ClusterModuleLabels");
673  fHitsModuleLabel = pset.get<std::string>("HitsModuleLabel");
674 
675  fCanvas = new TCanvas("fCanvas", "", 800, 600);
676  gStyle->SetOptStat(0);
677 }
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25

Member Function Documentation

void ClusteringValidation::ClusteringValidation::analyze ( art::Event const &  evt)
privatevirtual

Implements art::EDAnalyzer.

Definition at line 680 of file ClusteringValidation_module.cc.

681 {
682  // Get the hits from the event
684  std::vector<art::Ptr<recob::Hit>> hits;
685  if (evt.getByLabel(fHitsModuleLabel, hitHandle)) art::fill_ptr_vector(hits, hitHandle);
686 
687  // Get clustering information from event
688  // and give to the ClusterAnalyser to analyse
689  for (auto clustering : fClusterModuleLabels) {
690 
691  // Get the clusters from the event
693  std::vector<art::Ptr<recob::Cluster>> clusters;
694  if (evt.getByLabel(clustering, clusterHandle)) art::fill_ptr_vector(clusters, clusterHandle);
695 
696  // Find the associations (the hits) for the clusters
697  art::FindManyP<recob::Hit> fmh(clusterHandle, evt, clustering);
698 
699  // Analyse this particular clustering
700  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
701  clusterAnalysis.at(clustering)->Analyse(clockData, hits, clusters, fmh, fMinHitsInPlane);
702  }
703 }
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
std::map< std::string, std::unique_ptr< ClusterAnalyser > > clusterAnalysis
void ClusteringValidation::ClusteringValidation::beginJob ( )
privatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 706 of file ClusteringValidation_module.cc.

707 {
708 
709  // Construct the cluster analysers here
710  // -- one for each of the clustering types to compare
711  for (auto clustering : fClusterModuleLabels)
712  clusterAnalysis[clustering] = (std::unique_ptr<ClusterAnalyser>)new ClusterAnalyser(clustering);
713 }
std::map< std::string, std::unique_ptr< ClusterAnalyser > > clusterAnalysis
void ClusteringValidation::ClusteringValidation::endJob ( )
privatevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 716 of file ClusteringValidation_module.cc.

717 {
718 
719  // Make a map of all the histograms for each clustering
720  std::map<std::string, TObjArray> allHistograms;
721  for (auto clustering : fClusterModuleLabels)
722  allHistograms[clustering] = clusterAnalysis.at(clustering)->GetHistograms();
723 
724  // Write histograms to file
725  TFile* file = TFile::Open("validationHistograms.root", "RECREATE");
726  for (auto clustering : fClusterModuleLabels) {
727  file->cd();
728  file->mkdir(clustering.c_str());
729  file->cd(clustering.c_str());
730  for (int histIt = 0; histIt < allHistograms.begin()->second.GetEntriesFast(); ++histIt)
731  allHistograms.at(clustering).At(histIt)->Write();
732  }
733 
734  // Write images of overlaid histograms
735  for (int histIt = 0; histIt < allHistograms.begin()->second.GetEntriesFast(); ++histIt) {
736  fCanvas->cd();
737  fCanvas->Clear();
738  const char* name = allHistograms.begin()->second.At(histIt)->GetName();
739  TLegend* l = new TLegend(0.6, 0.8, 0.8, 0.9, name, "brNDC");
740  int clusterings = 1;
741  for (std::map<std::string, TObjArray>::iterator clusteringIt = allHistograms.begin();
742  clusteringIt != allHistograms.end();
743  ++clusteringIt, ++clusterings) {
744  TH1* h = (TH1*)allHistograms.at(clusteringIt->first).At(histIt);
745  h->SetLineColor(clusterings);
746  h->SetMarkerColor(clusterings);
747  if (clusterings == 1)
748  h->Draw();
749  else
750  h->Draw("same");
751  l->AddEntry(h, clusteringIt->first.c_str(), "lp");
752  }
753  l->Draw("same");
754  //fCanvas->SaveAs(name+TString(".png"));
755  file->cd();
756  fCanvas->Write(name);
757  }
758 
759  file->Close();
760  delete file;
761 
762  if (clusterAnalysis.find("blurredclusteringdc") != clusterAnalysis.end())
763  clusterAnalysis.at("blurredclusteringdc")->WriteFile();
764 }
static QCString name
Definition: declinfo.cpp:673
intermediate_table::iterator iterator
static QStrList * l
Definition: config.cpp:1044
std::map< std::string, std::unique_ptr< ClusterAnalyser > > clusterAnalysis

Member Data Documentation

std::map<std::string, std::unique_ptr<ClusterAnalyser> > ClusteringValidation::ClusteringValidation::clusterAnalysis
private

Definition at line 665 of file ClusteringValidation_module.cc.

TCanvas* ClusteringValidation::ClusteringValidation::fCanvas
private

Definition at line 661 of file ClusteringValidation_module.cc.

std::vector<std::string> ClusteringValidation::ClusteringValidation::fClusterModuleLabels
private

Definition at line 654 of file ClusteringValidation_module.cc.

std::string ClusteringValidation::ClusteringValidation::fHitsModuleLabel
private

Definition at line 655 of file ClusteringValidation_module.cc.

int ClusteringValidation::ClusteringValidation::fMinHitsInPlane
private

Definition at line 658 of file ClusteringValidation_module.cc.


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