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

Public Member Functions

 RegCNNEventDump (fhicl::ParameterSet const &pset)
 
 ~RegCNNEventDump ()
 
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 RegPixelMap &pm)
 Function to extract TH2 from PixelMap and write to TFile. More...
 
void WriteMapTH3 (const art::Event &evt, int slice, const RegPixelMap3D &pm)
 
void WriteCroppedMapTH3 (const art::Event &evt, int slice, const RegPixelMap3D &pm)
 

Private Attributes

std::string fPixelMapInput
 
std::string fPixelMap3DInput
 
std::string fGenieGenModuleLabel
 
bool fWriteMapTH2
 
bool fWriteMapTH3
 
bool fWriteCroppedMapTH3
 
bool fApplyFidVol
 

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 48 of file RegCNNEventDump_module.cc.

Constructor & Destructor Documentation

cnn::RegCNNEventDump::RegCNNEventDump ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 79 of file RegCNNEventDump_module.cc.

80  : EDAnalyzer(pset)
81  {
82  this->reconfigure(pset);
83  }
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
void reconfigure(const fhicl::ParameterSet &pset)
cnn::RegCNNEventDump::~RegCNNEventDump ( )

Definition at line 86 of file RegCNNEventDump_module.cc.

87  { }

Member Function Documentation

void cnn::RegCNNEventDump::analyze ( const art::Event evt)
override

Definition at line 115 of file RegCNNEventDump_module.cc.

116  {
117 
118  // Get the pixel maps
119  std::vector< art::Ptr< cnn::RegPixelMap > > pixelmaplist;
121  auto pixelmapListHandle = evt.getHandle< std::vector< cnn::RegPixelMap > >(itag1);
122  if (pixelmapListHandle)
123  art::fill_ptr_vector(pixelmaplist, pixelmapListHandle);
124 
125  unsigned short nhits = pixelmaplist.size();
126 
127  // Get the 3D pixel maps
128  std::vector<art::Ptr<cnn::RegPixelMap3D> > pm3Dlist;
130  auto pm3DListHandle = evt.getHandle<std::vector<cnn::RegPixelMap3D> >(itag2);
131  if (pm3DListHandle)
132  art::fill_ptr_vector(pm3Dlist, pm3DListHandle);
133 
134  unsigned short npm3D = pm3Dlist.size();
135  std::cout<<"npm3D: "<<npm3D<<std::endl;
136 
137  // If we have no hits then return
138  if (npm3D < 1 && nhits < 1) return;
139 
140  // * monte carlo
141  std::vector<art::Ptr<simb::MCTruth> > mclist;
142  auto mctruthListHandle = evt.getHandle< std::vector<simb::MCTruth> >(fGenieGenModuleLabel);
143  if (mctruthListHandle)
144  art::fill_ptr_vector(mclist, mctruthListHandle);
145 
146  //unsigned short nmclist= mclist.size();
147 
148  //std::cout<<"mctruth: "<<nmclist<<std::endl;
149 
150  art::Ptr<simb::MCTruth> truth = mclist[0];
151  simb::MCNeutrino truthN=truth->GetNeutrino();
152  std::cout<<"nuPDG : "<<truthN.Nu().PdgCode()<<", ";
153  std::cout<<"lepPDG : "<<truthN.Lepton().PdgCode()<<std::endl;
154  //truth = mclist[0];
155 
156  //float nuEnergy = 0;
157  //float lepEnergy = 0;
158  ////if(truth.NeutrinoSet()){
159  //nuEnergy = truthN.Nu().E();
160  //lepEnergy = truthN.Lepton().E();
161  ////}
162 
163  // If outside the fiducial volume don't waste any time filling other variables
164  if(fApplyFidVol){
165  // Get the interaction vertex from the end point of the neutrino. This is
166  // because the start point of the lepton doesn't make sense for taus as they
167  // are decayed by the generator and not GEANT
168  TVector3 vtx = truthN.Nu().EndPosition().Vect();
169  bool isFid = (fabs(vtx.X())<310 && fabs(vtx.Y())<550 && vtx.Z()>50 && vtx.Z()<1244);
170  if(!isFid) return;
171  }
172 
173  // Make a plot of the pixel map if required
174  if (fWriteMapTH2) WriteMapTH2(evt, 0, *pixelmaplist[0]);
175  if (fWriteMapTH3) WriteMapTH3(evt, 0, *pm3Dlist[0]);
176  if (fWriteCroppedMapTH3) WriteCroppedMapTH3(evt, 0, *pm3Dlist[0]);
177 
178  }
int PdgCode() const
Definition: MCParticle.h:212
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:77
void WriteMapTH3(const art::Event &evt, int slice, const RegPixelMap3D &pm)
const TLorentzVector & EndPosition() const
Definition: MCParticle.h:225
void WriteCroppedMapTH3(const art::Event &evt, int slice, const RegPixelMap3D &pm)
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
const simb::MCParticle & Lepton() const
Definition: MCNeutrino.h:147
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
Event generator information.
Definition: MCNeutrino.h:18
void WriteMapTH2(const art::Event &evt, int slice, const RegPixelMap &pm)
Function to extract TH2 from PixelMap and write to TFile.
QTextStream & endl(QTextStream &s)
void cnn::RegCNNEventDump::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 103 of file RegCNNEventDump_module.cc.

104  {
105 
106  }
void cnn::RegCNNEventDump::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 109 of file RegCNNEventDump_module.cc.

110  {
111 
112  }
void cnn::RegCNNEventDump::reconfigure ( const fhicl::ParameterSet pset)

Definition at line 90 of file RegCNNEventDump_module.cc.

91  {
92  fPixelMapInput = pset.get<std::string>("PixelMapInput");
93  fPixelMap3DInput = pset.get<std::string>("PixelMap3DInput");
94  fGenieGenModuleLabel = pset.get<std::string>("GenieGenModuleLabel");
95  fWriteMapTH2 = pset.get<bool> ("WriteMapTH2");
96  fWriteMapTH3 = pset.get<bool> ("WriteMapTH3");
97  fWriteCroppedMapTH3 = pset.get<bool> ("WriteCroppedMapTH3");
98  fApplyFidVol = pset.get<bool> ("ApplyFidVol");
99 
100  }
std::string string
Definition: nybbler.cc:12
T get(std::string const &key) const
Definition: ParameterSet.h:271
void cnn::RegCNNEventDump::WriteCroppedMapTH3 ( const art::Event evt,
int  slice,
const RegPixelMap3D pm 
)
private

Definition at line 249 of file RegCNNEventDump_module.cc.

249  {
250  std::cout<<"Write Cropped Map to TH3"<<std::endl;
251  std::stringstream name;
252  name << "RegCroppedPixelMap3D_r" << evt.run() << "_s" << evt.subRun() << "_e" << evt.event() << "_sl" << slice;
253  TH3F* hist = pm.ToCroppedTH3();
254  hist->SetName(name.str().c_str());
255 
257  TH3F* histWrite = tfs->make<TH3F>(*hist);
258  histWrite->Write();
259 
260  delete hist;
261  delete histWrite;
262  }
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
QTextStream & endl(QTextStream &s)
void cnn::RegCNNEventDump::WriteMapTH2 ( const art::Event evt,
int  slice,
const RegPixelMap pm 
)
private

Function to extract TH2 from PixelMap and write to TFile.

Definition at line 184 of file RegCNNEventDump_module.cc.

185  {
186  std::stringstream name;
187  name << "RegPixelMap_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
188  std::stringstream nameL;
189  nameL << "PixelTruthMap_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
190  std::stringstream nameX;
191  nameX << "RegPixelMap_X_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
192  std::stringstream nameY;
193  nameY << "RegPixelMap_Y_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
194  std::stringstream nameZ;
195  nameZ << "RegPixelMap_Z_r" << evt.run() << "_s" << evt.subRun()<< "_e" << evt.event() << "_sl" << slice;
196  TH2F* hist = pm.ToTH2();
197  TH2F* histL = pm.ToLabTH2();
198  TH2F* histX = pm.SingleViewToTH2(0);
199  TH2F* histY = pm.SingleViewToTH2(1);
200  TH2F* histZ = pm.SingleViewToTH2(2);
201  hist->SetName(name.str().c_str());
202  histL->SetName(nameL.str().c_str());
203  histX->SetName(nameX.str().c_str());
204  histY->SetName(nameY.str().c_str());
205  histZ->SetName(nameZ.str().c_str());
206 
208 
209  TH2F* histWrite = tfs->make<TH2F>(*hist);
210  histWrite->Write();
211  TH2F* histWriteL = tfs->make<TH2F>(*histL);
212  histWriteL->GetZaxis()->SetRangeUser(0,10);
213  histWriteL->Write();
214  TH2F* histWriteX = tfs->make<TH2F>(*histX);
215  histWriteX->Write();
216  TH2F* histWriteY = tfs->make<TH2F>(*histY);
217  histWriteY->Write();
218  TH2F* histWriteZ = tfs->make<TH2F>(*histZ);
219  histWriteZ->Write();
220 
221  delete hist;
222  delete histWrite;
223  delete histL;
224  delete histWriteL;
225  delete histX;
226  delete histWriteX;
227  delete histY;
228  delete histWriteY;
229  delete histZ;
230  delete histWriteZ;
231 
232  }
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
void cnn::RegCNNEventDump::WriteMapTH3 ( const art::Event evt,
int  slice,
const RegPixelMap3D pm 
)
private

Definition at line 234 of file RegCNNEventDump_module.cc.

234  {
235  std::cout<<"Write Map to TH3"<<std::endl;
236  std::stringstream name;
237  name << "RegPixelMap3D_r" << evt.run() << "_s" << evt.subRun() << "_e" << evt.event() << "_sl" << slice;
238  TH3F* hist = pm.ToTH3();
239  hist->SetName(name.str().c_str());
240 
242  TH3F* histWrite = tfs->make<TH3F>(*hist);
243  histWrite->Write();
244 
245  delete hist;
246  delete histWrite;
247  }
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
QTextStream & endl(QTextStream &s)

Member Data Documentation

bool cnn::RegCNNEventDump::fApplyFidVol
private

Definition at line 67 of file RegCNNEventDump_module.cc.

std::string cnn::RegCNNEventDump::fGenieGenModuleLabel
private

Definition at line 63 of file RegCNNEventDump_module.cc.

std::string cnn::RegCNNEventDump::fPixelMap3DInput
private

Definition at line 62 of file RegCNNEventDump_module.cc.

std::string cnn::RegCNNEventDump::fPixelMapInput
private

Definition at line 61 of file RegCNNEventDump_module.cc.

bool cnn::RegCNNEventDump::fWriteCroppedMapTH3
private

Definition at line 66 of file RegCNNEventDump_module.cc.

bool cnn::RegCNNEventDump::fWriteMapTH2
private

Definition at line 64 of file RegCNNEventDump_module.cc.

bool cnn::RegCNNEventDump::fWriteMapTH3
private

Definition at line 65 of file RegCNNEventDump_module.cc.


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