All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ClusteringValidation::ClusteringValidation Class Reference
Inheritance diagram for ClusteringValidation::ClusteringValidation:

Public Member Functions

 ClusteringValidation (fhicl::ParameterSet const &p)
 

Private Member Functions

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

Private Attributes

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

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 }

Member Function Documentation

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

Definition at line 680 of file ClusteringValidation_module.cc.

681 {
682  // Get the hits from the event
683  art::Handle<std::vector<recob::Hit>> hitHandle;
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
692  art::Handle<std::vector<recob::Cluster>> clusterHandle;
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:8
std::map< std::string, std::unique_ptr< ClusterAnalyser > > clusterAnalysis
void ClusteringValidation::ClusteringValidation::beginJob ( )
private

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 ( )
private

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 }
* file
Definition: file_to_url.sh:69
while getopts h
then echo fcl name
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: