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

Public Member Functions

 CVNSparseROOT (fhicl::ParameterSet const &p)
 
 CVNSparseROOT (CVNSparseROOT const &)=delete
 
 CVNSparseROOT (CVNSparseROOT &&)=delete
 
CVNSparseROOToperator= (CVNSparseROOT const &)=delete
 
CVNSparseROOToperator= (CVNSparseROOT &&)=delete
 
void reconfigure (fhicl::ParameterSet const &p)
 
void beginSubRun (art::SubRun const &sr) override
 Beginning of a subrun, make a new file. More...
 
void endSubRun (art::SubRun const &sr) override
 End of a subrun, write all events to a ROOT file. More...
 
void analyze (art::Event const &e) 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

std::string fMapModuleLabel
 Name of map producer module. More...
 
std::string fMapInstanceLabel
 Name of sparse map instance. More...
 
std::string fOutputName
 ROOT output filename. More...
 
std::string fTreeName
 ROOt tree name. More...
 
bool fIncludeGroundTruth
 Whether to include per-pixel ground truth. More...
 
std::vector< std::vector< float > > fCoordinates
 Pixel coordinates. More...
 
std::vector< std::vector< float > > fFeatures
 Pixel features. More...
 
std::vector< std::vector< int > > fPixelPDG
 Pixel PDG truth. More...
 
std::vector< std::vector< int > > fPixelTrackID
 Pixel track ID. More...
 
std::vector< std::vector< float > > fPixelEnergies
 Pixel energy. More...
 
std::vector< std::vector< std::string > > fProcesses
 
std::vector< unsigned int > fEvent
 Event numbers. More...
 
unsigned int fView
 View numbers. More...
 
TFile * fFile
 Output ROOT file. More...
 
TTree * fTree
 ROOT tree for writing to file. More...
 
size_t fCacheSize
 Size of TTree cache. More...
 

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 34 of file CVNSparseROOT_module.cc.

Constructor & Destructor Documentation

cvn::CVNSparseROOT::CVNSparseROOT ( fhicl::ParameterSet const &  p)
explicit

Definition at line 74 of file CVNSparseROOT_module.cc.

75  : EDAnalyzer{p} {
76  this->reconfigure(p);
77  }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
p
Definition: test.py:223
void reconfigure(fhicl::ParameterSet const &p)
cvn::CVNSparseROOT::CVNSparseROOT ( CVNSparseROOT const &  )
delete
cvn::CVNSparseROOT::CVNSparseROOT ( CVNSparseROOT &&  )
delete

Member Function Documentation

void cvn::CVNSparseROOT::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 90 of file CVNSparseROOT_module.cc.

90  {
91 
92  // Get the sparse maps
93  std::vector<art::Ptr<SparsePixelMap>> maps;
95  auto hMaps = e.getHandle<std::vector<SparsePixelMap>>(itag1);
96  if (!hMaps) {
98  << "Could not find SparsePixelMap vector with module label "
99  << fMapModuleLabel << " and instance label "
100  << fMapInstanceLabel << "!" << std::endl;
101  }
102  art::fill_ptr_vector(maps, hMaps);
103 
104  if (maps.size() > 1) throw art::Exception(art::errors::LogicError)
105  << "There shouldn't be more than one SparsePixelMap per producer per event,"
106  << " but here there are " << maps.size() << "." << std::endl;
107 
108  if (maps.empty()) return;
109 
110  for (unsigned int it = 0; it < maps[0]->GetViews(); ++it) {
111  fCoordinates = maps[0]->GetCoordinates(it);
112  fFeatures = maps[0]->GetFeatures(it);
113  if (fIncludeGroundTruth) {
114  fPixelPDG = maps[0]->GetPixelPDGs(it);
115  fPixelTrackID = maps[0]->GetPixelTrackIDs(it);
116  fPixelEnergies = maps[0]->GetPixelEnergies(it);
117  fProcesses = maps[0]->GetProcesses(it);
118  }
119  fEvent = std::vector<unsigned int>({e.id().run(), e.id().subRun(), e.id().event()});
120  fView = it;
121  fTree->Fill();
122  }
123 
124  } // cvn::CVNSparseROOT::analyze
unsigned int fView
View numbers.
std::string fMapInstanceLabel
Name of sparse map instance.
std::vector< std::vector< std::string > > fProcesses
std::vector< std::vector< int > > fPixelPDG
Pixel PDG truth.
const double e
bool fIncludeGroundTruth
Whether to include per-pixel ground truth.
std::vector< std::vector< int > > fPixelTrackID
Pixel track ID.
std::vector< std::vector< float > > fCoordinates
Pixel coordinates.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::vector< std::vector< float > > fPixelEnergies
Pixel energy.
std::string fMapModuleLabel
Name of map producer module.
std::vector< unsigned int > fEvent
Event numbers.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
TTree * fTree
ROOT tree for writing to file.
QTextStream & endl(QTextStream &s)
std::vector< std::vector< float > > fFeatures
Pixel features.
void cvn::CVNSparseROOT::beginSubRun ( art::SubRun const &  sr)
overridevirtual

Beginning of a subrun, make a new file.

Reimplemented from art::EDAnalyzer.

Definition at line 127 of file CVNSparseROOT_module.cc.

127  {
128 
129  // Open ROOT file
130  boost::uuids::random_generator generator;
131  boost::uuids::uuid uuid = generator();
132  std::ostringstream fileName;
133  fileName << fOutputName << "_" << uuid << ".root";
134  fFile = TFile::Open(fileName.str().c_str(), "recreate");
135 
136  fTree = new TTree(fTreeName.c_str(), fTreeName.c_str());
137  fTree->SetCacheSize(fCacheSize);
138  fTree->Branch("Coordinates", &fCoordinates);
139  fTree->Branch("Features", &fFeatures);
140  if (fIncludeGroundTruth) {
141  fTree->Branch("PixelPDG", &fPixelPDG);
142  fTree->Branch("PixelTrackID", &fPixelTrackID);
143  fTree->Branch("PixelEnergy", &fPixelEnergies);
144  fTree->Branch("Process", &fProcesses);
145  }
146  fTree->Branch("Event", &fEvent);
147  fTree->Branch("View", &fView);
148 
149  } // function CVNSparseROOT::beginSubRun
unsigned int fView
View numbers.
std::vector< std::vector< std::string > > fProcesses
std::vector< std::vector< int > > fPixelPDG
Pixel PDG truth.
bool fIncludeGroundTruth
Whether to include per-pixel ground truth.
fileName
Definition: dumpTree.py:9
TFile * fFile
Output ROOT file.
std::vector< std::vector< int > > fPixelTrackID
Pixel track ID.
std::vector< std::vector< float > > fCoordinates
Pixel coordinates.
generator
Definition: train.py:468
std::vector< std::vector< float > > fPixelEnergies
Pixel energy.
std::string fOutputName
ROOT output filename.
std::vector< unsigned int > fEvent
Event numbers.
size_t fCacheSize
Size of TTree cache.
std::string fTreeName
ROOt tree name.
TTree * fTree
ROOT tree for writing to file.
std::vector< std::vector< float > > fFeatures
Pixel features.
void cvn::CVNSparseROOT::endSubRun ( art::SubRun const &  sr)
overridevirtual

End of a subrun, write all events to a ROOT file.

Reimplemented from art::EDAnalyzer.

Definition at line 152 of file CVNSparseROOT_module.cc.

152  {
153 
154  fFile->WriteTObject(fTree, fTreeName.c_str());
155  delete fFile;
156 
157  } // cvn::CVNSparseROOT::endSubRun
TFile * fFile
Output ROOT file.
std::string fTreeName
ROOt tree name.
TTree * fTree
ROOT tree for writing to file.
CVNSparseROOT& cvn::CVNSparseROOT::operator= ( CVNSparseROOT const &  )
delete
CVNSparseROOT& cvn::CVNSparseROOT::operator= ( CVNSparseROOT &&  )
delete
void cvn::CVNSparseROOT::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 79 of file CVNSparseROOT_module.cc.

79  {
80 
81  fMapModuleLabel = p.get<std::string>("MapModuleLabel");
82  fMapInstanceLabel = p.get<std::string>("MapInstanceLabel");
83  fOutputName = p.get<std::string>("OutputName");
84  fTreeName = p.get<std::string>("TreeName");
85  fIncludeGroundTruth = p.get<bool>("IncludeGroundTruth");
86  fCacheSize = p.get<size_t>("CacheSize");
87 
88  } // cvn::CVNSparseROOT::reconfigure
std::string string
Definition: nybbler.cc:12
std::string fMapInstanceLabel
Name of sparse map instance.
bool fIncludeGroundTruth
Whether to include per-pixel ground truth.
p
Definition: test.py:223
std::string fMapModuleLabel
Name of map producer module.
std::string fOutputName
ROOT output filename.
size_t fCacheSize
Size of TTree cache.
std::string fTreeName
ROOt tree name.

Member Data Documentation

size_t cvn::CVNSparseROOT::fCacheSize
private

Size of TTree cache.

Definition at line 69 of file CVNSparseROOT_module.cc.

std::vector<std::vector<float> > cvn::CVNSparseROOT::fCoordinates
private

Pixel coordinates.

Definition at line 57 of file CVNSparseROOT_module.cc.

std::vector<unsigned int> cvn::CVNSparseROOT::fEvent
private

Event numbers.

Definition at line 64 of file CVNSparseROOT_module.cc.

std::vector<std::vector<float> > cvn::CVNSparseROOT::fFeatures
private

Pixel features.

Definition at line 58 of file CVNSparseROOT_module.cc.

TFile* cvn::CVNSparseROOT::fFile
private

Output ROOT file.

Definition at line 67 of file CVNSparseROOT_module.cc.

bool cvn::CVNSparseROOT::fIncludeGroundTruth
private

Whether to include per-pixel ground truth.

Definition at line 55 of file CVNSparseROOT_module.cc.

std::string cvn::CVNSparseROOT::fMapInstanceLabel
private

Name of sparse map instance.

Definition at line 52 of file CVNSparseROOT_module.cc.

std::string cvn::CVNSparseROOT::fMapModuleLabel
private

Name of map producer module.

Definition at line 51 of file CVNSparseROOT_module.cc.

std::string cvn::CVNSparseROOT::fOutputName
private

ROOT output filename.

Definition at line 53 of file CVNSparseROOT_module.cc.

std::vector<std::vector<float> > cvn::CVNSparseROOT::fPixelEnergies
private

Pixel energy.

Definition at line 61 of file CVNSparseROOT_module.cc.

std::vector<std::vector<int> > cvn::CVNSparseROOT::fPixelPDG
private

Pixel PDG truth.

Definition at line 59 of file CVNSparseROOT_module.cc.

std::vector<std::vector<int> > cvn::CVNSparseROOT::fPixelTrackID
private

Pixel track ID.

Definition at line 60 of file CVNSparseROOT_module.cc.

std::vector<std::vector<std::string> > cvn::CVNSparseROOT::fProcesses
private

Definition at line 62 of file CVNSparseROOT_module.cc.

TTree* cvn::CVNSparseROOT::fTree
private

ROOT tree for writing to file.

Definition at line 68 of file CVNSparseROOT_module.cc.

std::string cvn::CVNSparseROOT::fTreeName
private

ROOt tree name.

Definition at line 54 of file CVNSparseROOT_module.cc.

unsigned int cvn::CVNSparseROOT::fView
private

View numbers.

Definition at line 65 of file CVNSparseROOT_module.cc.


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