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

Public Member Functions

 CVNEventDumpProtoDUNE (fhicl::ParameterSet const &pset)
 
 ~CVNEventDumpProtoDUNE ()
 
void analyze (const art::Event &evt) override
 
void reconfigure (const fhicl::ParameterSet &pset)
 
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

void WriteMapTH2 (const art::Event &evt, int slice, const PixelMap &pm)
 Function to extract TH2 from PixelMap and write to TFile. More...
 

Private Attributes

std::string fPixelMapInput
 
bool fWriteMapTH2
 
TrainingDatafTrain
 
TTree * fTrainTree
 

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 CVNEventDumpProtoDUNE_module.cc.

Constructor & Destructor Documentation

cvn::CVNEventDumpProtoDUNE::CVNEventDumpProtoDUNE ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 60 of file CVNEventDumpProtoDUNE_module.cc.

61  : EDAnalyzer(pset)
62  {
63  this->reconfigure(pset);
64  }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
void reconfigure(const fhicl::ParameterSet &pset)
cvn::CVNEventDumpProtoDUNE::~CVNEventDumpProtoDUNE ( )

Definition at line 67 of file CVNEventDumpProtoDUNE_module.cc.

68  { }

Member Function Documentation

void cvn::CVNEventDumpProtoDUNE::analyze ( const art::Event evt)
override

Definition at line 97 of file CVNEventDumpProtoDUNE_module.cc.

98  {
99 
100  // Get the pixel maps
101  std::vector< art::Ptr< cvn::PixelMap > > pixelmaplist;
103  auto pixelmapListHandle = evt.getHandle< std::vector< cvn::PixelMap > >(itag1);
104  if (pixelmapListHandle)
105  art::fill_ptr_vector(pixelmaplist, pixelmapListHandle);
106 
107  std::cout << "Found " << pixelmaplist.size() << " pixel maps in event" << std::endl;
108 
109  for(unsigned int p = 0; p < pixelmaplist.size(); ++p){
110 
111  // We will have to just fake the truth information we would usually have for the events
113 
114  // Create the training data and add it to the tree
115  TrainingData train(interaction, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, *pixelmaplist[p]);
116  fTrain = &train;
117  fTrainTree->Fill();
118 
119  // Make a plot of the pixel map if required
120  if (fWriteMapTH2) WriteMapTH2(evt, p, train.fPMap);
121 
122  }
123 
124  }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
void WriteMapTH2(const art::Event &evt, int slice, const PixelMap &pm)
Function to extract TH2 from PixelMap and write to TFile.
enum cvn::Interaction InteractionType
def train(model, train_files, valid_files, maskpatterns, epochs, batchsize, info)
Definition: train.py:16
Definition: train.py:1
p
Definition: test.py:223
Something else. Tau? Hopefully we don&#39;t use this.
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
QTextStream & endl(QTextStream &s)
void cvn::CVNEventDumpProtoDUNE::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 78 of file CVNEventDumpProtoDUNE_module.cc.

79  {
80 
81 
83 
84  fTrainTree = tfs->make<TTree>("CVNTrainTree", "Training records");
85  fTrainTree->Branch("train", "cvn::TrainingData", &fTrain);
86 
87 
88  }
void cvn::CVNEventDumpProtoDUNE::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 91 of file CVNEventDumpProtoDUNE_module.cc.

92  {
93 
94  }
void cvn::CVNEventDumpProtoDUNE::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 71 of file CVNEventDumpProtoDUNE_module.cc.

72  {
73  fPixelMapInput = pset.get<std::string>("PixelMapInput");
74  fWriteMapTH2 = pset.get<bool> ("WriteMapTH2");
75  }
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
void cvn::CVNEventDumpProtoDUNE::WriteMapTH2 ( const art::Event evt,
int  slice,
const PixelMap pm 
)
private

Function to extract TH2 from PixelMap and write to TFile.

Definition at line 130 of file CVNEventDumpProtoDUNE_module.cc.

131  {
132  std::stringstream name;
133  name << "PixelMap_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
134  std::stringstream nameL;
135  nameL << "PixelTruthMap_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
136  std::stringstream nameX;
137  nameX << "PixelMap_X_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
138  std::stringstream nameY;
139  nameY << "PixelMap_Y_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
140  std::stringstream nameZ;
141  nameZ << "PixelMap_Z_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
142  TH2F* hist = pm.ToTH2();
143  TH2F* histL = pm.ToLabTH2();
144  TH2F* histX = pm.SingleViewToTH2(0);
145  TH2F* histY = pm.SingleViewToTH2(1);
146  TH2F* histZ = pm.SingleViewToTH2(2);
147  hist->SetName(name.str().c_str());
148  histL->SetName(nameL.str().c_str());
149  histX->SetName(nameX.str().c_str());
150  histY->SetName(nameY.str().c_str());
151  histZ->SetName(nameZ.str().c_str());
152 
154 
155  TH2F* histWrite = tfs->make<TH2F>(*hist);
156  histWrite->Write();
157  TH2F* histWriteL = tfs->make<TH2F>(*histL);
158  histWriteL->GetZaxis()->SetRangeUser(0,10);
159  histWriteL->Write();
160  TH2F* histWriteX = tfs->make<TH2F>(*histX);
161  histWriteX->Write();
162  TH2F* histWriteY = tfs->make<TH2F>(*histY);
163  histWriteY->Write();
164  TH2F* histWriteZ = tfs->make<TH2F>(*histZ);
165  histWriteZ->Write();
166 
167  delete hist;
168  delete histWrite;
169  delete histL;
170  delete histWriteL;
171  delete histX;
172  delete histWriteX;
173  delete histY;
174  delete histWriteY;
175  delete histZ;
176  delete histWriteZ;
177 
178  }
static QCString name
Definition: declinfo.cpp:673
EventNumber_t event() const
Definition: DataViewImpl.cc:85
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
RunNumber_t run() const
Definition: DataViewImpl.cc:71

Member Data Documentation

std::string cvn::CVNEventDumpProtoDUNE::fPixelMapInput
private

Definition at line 47 of file CVNEventDumpProtoDUNE_module.cc.

TrainingData* cvn::CVNEventDumpProtoDUNE::fTrain
private

Definition at line 51 of file CVNEventDumpProtoDUNE_module.cc.

TTree* cvn::CVNEventDumpProtoDUNE::fTrainTree
private

Definition at line 52 of file CVNEventDumpProtoDUNE_module.cc.

bool cvn::CVNEventDumpProtoDUNE::fWriteMapTH2
private

Definition at line 48 of file CVNEventDumpProtoDUNE_module.cc.


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