Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
evd::SliceNavigator Class Reference

Look up products dependent on the current slice. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-02-25/EventDisplayServices/SliceNavigator.h"

Inheritance diagram for evd::SliceNavigator:
evdb::Reconfigurable

Public Member Functions

 SliceNavigator (const fhicl::ParameterSet &pset, art::ActivityRegistry &reg)
 
 ~SliceNavigator ()
 
void reconfigure (const fhicl::ParameterSet &pset) override
 
void preBeginRun (art::Run const &r)
 
void postProcessEvent (const art::Event &evt)
 
template<class T >
size_t GetProducts (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
 
template<class T >
size_t GetProducts (const art::Event &evt, const std::string &whichTrack, const std::string &whichMichel, const std::string &instance, std::vector< const T * > &prods)
 
bool FullEventMode () const
 
void SetFullEventMode (bool mode)
 
void Previous ()
 
void Next ()
 
int CurrentSlice () const
 
int CurrentSliceIndex () const
 
void AutoAdvance ()
 
void StopAutoAdvance ()
 
bool AutoAdvancing ()
 
void SetCurrentSlice (int slice)
 
int MaxSlice () const
 
std::vector< const rb::Cluster * > SlicesToNavigate (const art::Event &evt)
 
void GetBounds (const art::Event &evt, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax, double trimfrac=0)
 
void GetBox (const art::Event &evt, double &xmin, double &xmax, double &ymin, double &ymax, double &zmin, double &zmax, double trimfrac=0)
 
bool DimHits () const
 
bool DimOthers () const
 
template<>
size_t GetProductsImplFull (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const rb::Cluster * > &clusts)
 
template<>
size_t GetProducts (const art::Event &evt, const std::string &whichTrack, const std::string &whichMichel, const std::string &instance, std::vector< const rb::Track * > &tracks)
 
template<>
size_t GetProducts (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const rb::Cluster * > &clusts)
 
template<>
size_t GetProducts (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const simb::MCTruth * > &truths)
 

Protected Member Functions

Bool_t HandleTimer (TTimer *t)
 
template<class T >
size_t GetProductsImpl (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
 
template<class T >
size_t GetProductsImplFull (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
 
template<class T >
size_t GetProductsImplPart (const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
 
void ParseModuleInstanceString (std::string &mod, std::string &inst)
 
std::string stringReplace (std::string &s, const std::string &toReplace, const std::string &replaceWith)
 

Protected Attributes

int fAutoAdvanceInterval
 Wait time in milliseconds. More...
 
std::string fAutoPrintPattern
 Pattern for constructing filename. More...
 
int fAutoPrintMax
 How many events to print (zero = disable printing) More...
 
int fAutoPrintCount
 
int fRun
 
bool fFilterResults
 Only navigate slices that aren't filtered out. More...
 
bool fDimHits
 
bool fDimOthers
 
std::string fSliceLabel
 
std::string fCellHitLabel
 
std::string fSliceInstance
 
std::string fCellHitInstance
 
bool fFullEvent
 
int fCurrentSlice
 Index into fSlicesToNavigate. More...
 
int fMaxSliceId
 
std::vector< intfSlicesToNavigate
 
std::vector< art::Ptr< rb::Cluster > > fSlices
 
art::PtrVector< rb::CellHitfAllHits
 
int fInitialSlice
 -1 afterwards More...
 
TTimer * fTimer
 

Private Member Functions

void do_reconfigure (fhicl::ParameterSet const &pset)
 

Detailed Description

Look up products dependent on the current slice.

Definition at line 23 of file SliceNavigator.h.

Constructor & Destructor Documentation

evd::SliceNavigator::SliceNavigator ( const fhicl::ParameterSet pset,
art::ActivityRegistry reg 
)
explicit

Definition at line 40 of file SliceNavigator_service.cc.

References fAutoPrintCount, fCurrentSlice, fFullEvent, fInitialSlice, fMaxSliceId, fRun, fTimer, evdb::kDRAWING_SERVICE, evdb::ServiceTable::OverrideCategory(), postProcessEvent(), preBeginRun(), and reconfigure().

42  : evdb::Reconfigurable{pset},
43  fAutoPrintCount(0),
44  fRun(0),
45  fFullEvent(true),
46  fCurrentSlice(0),
47  fMaxSliceId(0),
48  fInitialSlice(-1),
49  fTimer(0)
50  {
51  reconfigure(pset);
52 
53  evdb::ServiceTable::OverrideCategory("SliceNavigator",
55 
57  reg.sPreBeginRun.watch(this, &SliceNavigator::preBeginRun);
58  }
static constexpr int kDRAWING_SERVICE
Definition: ServiceTable.h:19
void postProcessEvent(const art::Event &evt)
int fInitialSlice
-1 afterwards
int fCurrentSlice
Index into fSlicesToNavigate.
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
void preBeginRun(art::Run const &r)
static void OverrideCategory(std::string const &s, int cat)
GlobalSignal< detail::SignalResponseType::LIFO, void(Event const &)> sPostProcessEvent
void reconfigure(const fhicl::ParameterSet &pset) override
evd::SliceNavigator::~SliceNavigator ( )

Definition at line 61 of file SliceNavigator_service.cc.

References fSlicesToNavigate, and fTimer.

62  {
63  fSlicesToNavigate.clear();
64  delete fTimer;
65  }
std::vector< int > fSlicesToNavigate

Member Function Documentation

void evd::SliceNavigator::AutoAdvance ( )

Definition at line 494 of file SliceNavigator_service.cc.

References fAutoAdvanceInterval, and fTimer.

Referenced by evd::SliceButtonBar::AutoAdvance().

495  {
496  delete fTimer;
497  fTimer = new TTimer;
498  fTimer->SetObject(this);
499  // One-shot timer, will be re-primed by postProcessEvent()
500  fTimer->Start(fAutoAdvanceInterval, true);
501  }
int fAutoAdvanceInterval
Wait time in milliseconds.
bool evd::SliceNavigator::AutoAdvancing ( )

Definition at line 513 of file SliceNavigator_service.cc.

References fTimer.

Referenced by evd::SliceButtonBar::AutoAdvance().

514  {
515  return fTimer != 0;
516  }
int evd::SliceNavigator::CurrentSlice ( ) const

Definition at line 519 of file SliceNavigator_service.cc.

References fCurrentSlice, and fSlicesToNavigate.

Referenced by postProcessEvent(), evd::SliceButtonBar::SliceButtonBar(), and evd::SliceButtonBar::Update().

520  {
521  if(fSlicesToNavigate.empty() || fCurrentSlice < 0) return 0;
522 
524  }
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
int evd::SliceNavigator::CurrentSliceIndex ( ) const

Definition at line 527 of file SliceNavigator_service.cc.

References fCurrentSlice.

Referenced by evd::RawDataDrawer::RawDigit2D(), evd::RawDataDrawer::RawDigit3D(), and evd::RawDataDrawer::RawDigitHardware().

528  {
529  return fCurrentSlice;
530  }
int fCurrentSlice
Index into fSlicesToNavigate.
bool evd::SliceNavigator::DimHits ( ) const
inline

Definition at line 75 of file SliceNavigator.h.

References fDimHits.

Referenced by evd::RecoBaseDrawer::CellHit2D().

75 {return fDimHits;}
bool evd::SliceNavigator::DimOthers ( ) const
inline
void evdb::Reconfigurable::do_reconfigure ( fhicl::ParameterSet const &  pset)
inlineinherited

Definition at line 17 of file Reconfigurable.h.

17 { reconfigure(pset); }
virtual void reconfigure(fhicl::ParameterSet const &)=0
bool evd::SliceNavigator::FullEventMode ( ) const
void evd::SliceNavigator::GetBounds ( const art::Event evt,
double &  xmin,
double &  xmax,
double &  ymin,
double &  ymax,
double &  zmin,
double &  zmax,
double  trimfrac = 0 
)

Definition at line 556 of file SliceNavigator_service.cc.

References rb::CellHit::Cell(), rb::Cluster::Cell(), om::cerr, geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), geo::GeometryBase::DetLength(), allTimeWatchdog::endl, art::Handle< T >::failedToGet(), fCurrentSlice, fSliceInstance, fSliceLabel, fSlicesToNavigate, geom(), art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, geo::kX, rb::Cluster::MaxXYZ(), rb::Cluster::MinXYZ(), rb::Cluster::NCell(), rb::CellHit::Plane(), geo::GeometryBase::Plane(), and rb::CellHit::View().

Referenced by evd::TZProjPad::AutoZoomSlice().

561  {
562  // Fallback to the whole detector in case we don't get values below
564  xmin = -geom->DetHalfWidth();
565  xmax = +geom->DetHalfWidth();
566  ymin = -geom->DetHalfHeight();
567  ymax = +geom->DetHalfHeight();
568  zmin = 0;
569  zmax = geom->DetLength();
570 
573 
574  if(slices.failedToGet()){
575  std::cerr << "Couldn't find any slices under label "
576  << fSliceLabel << std::endl;
577  return;
578  }
579 
580  if(fCurrentSlice >= 0 && fCurrentSlice < int(slices->size())){
581  const rb::Cluster& slice = (*slices)[fSlicesToNavigate[fCurrentSlice]];
582 
583  if(trimfrac == 0){
584  const TVector3 r0 = slice.MinXYZ();
585  const TVector3 r1 = slice.MaxXYZ();
586  xmin = r0.X(); xmax = r1.X();
587  ymin = r0.Y(); ymax = r1.Y();
588  zmin = r0.Z(); zmax = r1.Z();
589  return;
590  }
591 
592  std::vector<double> xs, ys, zs;
593 
594  for(unsigned int i = 0; i < slice.NCell(); ++i){
595  const art::Ptr<rb::CellHit>& chit = slice.Cell(i);
596  double xyz[3];
597  geom->Plane(chit->Plane())->Cell(chit->Cell())->GetCenter(xyz);
598  zs.push_back(xyz[2]);
599  if(chit->View() == geo::kX)
600  xs.push_back(xyz[0]);
601  else
602  ys.push_back(xyz[1]);
603  }
604 
605  std::sort(xs.begin(), xs.end());
606  std::sort(ys.begin(), ys.end());
607  std::sort(zs.begin(), zs.end());
608 
609  xmin = xs[xs.size()*trimfrac];
610  ymin = ys[ys.size()*trimfrac];
611  zmin = zs[zs.size()*trimfrac];
612 
613  // For small events we want to pick up the last hit, not the N-1th hit
614  xmax = xs[(xs.size()-1)*(1-trimfrac)+1];
615  ymax = ys[(ys.size()-1)*(1-trimfrac)+1];
616  zmax = zs[(zs.size()-1)*(1-trimfrac)+1];
617  }
618  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
std::map< std::string, double > xmax
unsigned short Plane() const
Definition: CellHit.h:39
std::string fSliceLabel
geo::View_t View() const
Definition: CellHit.h:41
Vertical planes which measure X.
Definition: PlaneGeo.h:28
A collection of associated CellHits.
Definition: Cluster.h:47
double DetLength() const
OStream cerr
Definition: OStream.cxx:7
const PlaneGeo * Plane(unsigned int i) const
TVector3 MaxXYZ() const
Definition: Cluster.cxx:492
Double_t ymax
Definition: plot.C:25
unsigned short Cell() const
Definition: CellHit.h:40
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
double DetHalfHeight() const
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
double DetHalfWidth() const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TVector3 MinXYZ() const
Definition: Cluster.cxx:446
void geom(int which=0)
Definition: geom.C:163
Double_t ymin
Definition: plot.C:24
std::string fSliceInstance
bool failedToGet() const
Definition: Handle.h:196
void evd::SliceNavigator::GetBox ( const art::Event evt,
double &  xmin,
double &  xmax,
double &  ymin,
double &  ymax,
double &  zmin,
double &  zmax,
double  trimfrac = 0 
)

Definition at line 621 of file SliceNavigator_service.cc.

References rb::CellHit::Cell(), rb::Cluster::Cell(), om::cerr, geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), geo::GeometryBase::DetLength(), allTimeWatchdog::endl, art::Handle< T >::failedToGet(), fCurrentSlice, evd::GeometryDrawingOptions::fSliceBoxSize, fSliceInstance, fSliceLabel, fSlicesToNavigate, geom(), art::DataViewImpl::getByLabel(), MECModelEnuComparisons::i, geo::kX, rb::Cluster::MaxXYZ(), rb::Cluster::MinXYZ(), rb::Cluster::NCell(), rb::CellHit::Plane(), geo::GeometryBase::Plane(), nd_projection_maker::sizes, rb::CellHit::View(), make_mec_shifts_plots::xmin, and ymin.

Referenced by evd::TZProjPad::AutoZoomBox().

626  {
627  // Fallback to the whole detector in case we don't get values below
629  xmin = -geom->DetHalfWidth();
630  xmax = +geom->DetHalfWidth();
631  ymin = -geom->DetHalfHeight();
632  ymax = +geom->DetHalfHeight();
633  zmin = 0;
634  zmax = geom->DetLength();
635 
636  // Use Fiducial dimensions if smaller than slice
638 
639  float xbox=0;
640  float ybox=0;
641  float zbox=0;
642  if ( (drawopt->fSliceBoxSize).size() == 3 ) {
643  std::vector< float > sizes = drawopt->fSliceBoxSize;
644  xbox = sizes[0];
645  ybox = sizes[1];
646  zbox = sizes[2];
647  }
650 
651  if(slices.failedToGet()){
652  std::cerr << "Couldn't find any slices under label "
653  << fSliceLabel << std::endl;
654  return;
655  }
656 
657  if(fCurrentSlice >= 0 && fCurrentSlice < int(slices->size())){
658  const rb::Cluster& slice = (*slices)[fSlicesToNavigate[fCurrentSlice]];
659 
660  if(trimfrac == 0){
661  const TVector3 r0 = slice.MinXYZ();
662  const TVector3 r1 = slice.MaxXYZ();
663  xmin = r0.X(); xmax = r1.X();
664  ymin = r0.Y(); ymax = r1.Y();
665  zmin = r0.Z(); zmax = r1.Z();
666  return;
667  }
668 
669  std::vector<double> xs, ys, zs;
670 
671  for(unsigned int i = 0; i < slice.NCell(); ++i){
672  const art::Ptr<rb::CellHit>& chit = slice.Cell(i);
673  double xyz[3];
674  geom->Plane(chit->Plane())->Cell(chit->Cell())->GetCenter(xyz);
675  zs.push_back(xyz[2]);
676  if(chit->View() == geo::kX)
677  xs.push_back(xyz[0]);
678  else
679  ys.push_back(xyz[1]);
680  }
681  std::sort(xs.begin(), xs.end());
682  std::sort(ys.begin(), ys.end());
683  std::sort(zs.begin(), zs.end());
684 
685  xmin = xs[xs.size()*trimfrac];
686  ymin = ys[ys.size()*trimfrac];
687  zmin = zs[zs.size()*trimfrac];
688 
689  // For small events we want to pick up the last hit, not the N-1th hit
690  xmax = xs[(xs.size()-1)*(1-trimfrac)+1];
691  ymax = ys[(ys.size()-1)*(1-trimfrac)+1];
692  zmax = zs[(zs.size()-1)*(1-trimfrac)+1];
693 
694  double xmid=(xmax+xmin)/2;
695  double ymid=(ymax+ymin)/2;
696  double zmid=(zmax+zmin)/2;
697  xmax= ( xbox==0 ) ? xmax : xmid+xbox/2;
698  ymax= ( ybox==0 ) ? ymax : ymid+ybox/2;
699  zmax= ( zbox==0 ) ? zmax : zmid+zbox/2;
700  xmin= ( xbox==0 ) ? xmin : xmid-xbox/2;
701  ymin= ( ybox==0 ) ? ymin : ymid-ybox/2;
702  zmin= ( zbox==0 ) ? zmin : zmid-zbox/2;
703  }
704  }
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
std::map< std::string, double > xmax
unsigned short Plane() const
Definition: CellHit.h:39
std::string fSliceLabel
geo::View_t View() const
Definition: CellHit.h:41
Vertical planes which measure X.
Definition: PlaneGeo.h:28
A collection of associated CellHits.
Definition: Cluster.h:47
double DetLength() const
OStream cerr
Definition: OStream.cxx:7
const PlaneGeo * Plane(unsigned int i) const
TVector3 MaxXYZ() const
Definition: Cluster.cxx:492
Double_t ymax
Definition: plot.C:25
unsigned short Cell() const
Definition: CellHit.h:40
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
double DetHalfHeight() const
art::Ptr< rb::CellHit > Cell(geo::View_t view, unsigned int viewIdx) const
Get the ith cell from view view.
Definition: Cluster.cxx:145
double DetHalfWidth() const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
TVector3 MinXYZ() const
Definition: Cluster.cxx:446
void geom(int which=0)
Definition: geom.C:163
std::vector< float > fSliceBoxSize
Double_t ymin
Definition: plot.C:24
std::string fSliceInstance
bool failedToGet() const
Definition: Handle.h:196
template<class T >
size_t evd::SliceNavigator::GetProducts ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const T * > &  prods 
)
template<class T >
size_t evd::SliceNavigator::GetProducts ( const art::Event evt,
const std::string whichTrack,
const std::string whichMichel,
const std::string instance,
std::vector< const T * > &  prods 
)
template<>
size_t evd::SliceNavigator::GetProducts ( const art::Event evt,
const std::string whichTrack,
const std::string whichMichel,
const std::string instance,
std::vector< const rb::Track * > &  tracks 
)

Definition at line 365 of file SliceNavigator_service.cc.

References plot_validation_datamc::c, GetProducts(), and GetProductsImpl().

370  {
371  std::vector<const me::TrkME*> clusts;
372  GetProductsImpl(evt, whichTrack, instance, tracks);
373  GetProductsImpl(evt, whichMichel, instance, clusts);
374 
375  for(const me::TrkME* c: clusts)
376  tracks.push_back(c->ParentTrk().get());
377 
378  return tracks.size();
379  }
size_t GetProductsImpl(const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
template<>
size_t evd::SliceNavigator::GetProducts ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const rb::Cluster * > &  clusts 
)

Definition at line 384 of file SliceNavigator_service.cc.

References om::cerr, allTimeWatchdog::endl, art::Handle< T >::failedToGet(), fCurrentSlice, fFilterResults, fFullEvent, fSliceLabel, fSlicesToNavigate, art::DataViewImpl::getByLabel(), GetProducts(), GetProductsImplFull(), compare_h5_caf::idx, and rb::IsFiltered().

388  {
389  // If it's the actual slices, look them up by index.
390  // Otherwise we'll get nothing
391  // (not possible to associate Cluster with Cluster)
392  if(which == fSliceLabel && instance == ""){
394  evt.getByLabel(fSliceLabel, slices);
395  if(slices.failedToGet()){
396  std::cerr << "Couldn't find any slices under label "
397  << fSliceLabel << std::endl;
398  return 0;
399  }
400  if( fFullEvent ){
401  int nSli = slices->size();
402  for( int iSli=0; iSli < nSli; ++iSli){
403  if ( fFilterResults && rb::IsFiltered(evt,slices, iSli ) )
404  continue;
405  clusts.push_back((art::Ptr<rb::Cluster>(slices, iSli).get())) ;
406  }
407  }// if full event
408  else{
410  if( fCurrentSlice >=0 )
411  clusts.push_back( (art::Ptr<rb::Cluster>(slices, idx)).get() );
412  }
413  }
414  else
415  GetProductsImplFull(evt, which, instance, clusts);
416 
417  return clusts.size();
418  }
std::string fSliceLabel
OStream cerr
Definition: OStream.cxx:7
size_t GetProductsImplFull(const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
bool fFilterResults
Only navigate slices that aren&#39;t filtered out.
bool failedToGet() const
Definition: Handle.h:196
template<>
size_t evd::SliceNavigator::GetProducts ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const simb::MCTruth * > &  truths 
)

Definition at line 423 of file SliceNavigator_service.cc.

References fAllHits, fCurrentSlice, fFullEvent, fSlices, fSlicesToNavigate, GetProductsImpl(), and cheat::BackTracker::SliceToMCTruth().

427  {
428  truths.clear();
429 
430  if(fFullEvent){
431  GetProductsImpl(evt, which, instance, truths);
432  }
433  else{
435 
436  std::vector<cheat::NeutrinoEffPur> eps =
438  fAllHits);
439 
440  if(!eps.empty()) truths = {eps.front().neutrinoInt.get()};
441  }
442 
443  return truths.size();
444  }
std::vector< art::Ptr< rb::Cluster > > fSlices
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
art::PtrVector< rb::CellHit > fAllHits
size_t GetProductsImpl(const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
std::vector< NeutrinoEffPur > SliceToMCTruth(const std::vector< const rb::CellHit * > &sliceHits, const std::vector< const rb::CellHit * > &allHits, bool sortPur=false) const
Given a collection of hits (often a slice), returns vector of structures of MCTruth, efficiency, and purity of that neutrino interaction relative to the slice. Efficiency is defined as FLS energy from neutrino interaction in slice / total FLS energy from neutrino interaction in event. This vector is sorted from the highest efficiency interaction to lowest. This function returns all MCTruth, including those without neutrino interactions, i.e. cosmics.
template<class T >
size_t evd::SliceNavigator::GetProductsImpl ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const T * > &  prods 
)
protected

Definition at line 229 of file SliceNavigator_service.cc.

References fFullEvent, GetProductsImplFull(), and GetProductsImplPart().

Referenced by DimOthers(), and GetProducts().

233  {
234  if(fFullEvent)
235  return GetProductsImplFull(evt, which, instance, prods);
236  else
237  return GetProductsImplPart(evt, which, instance, prods);
238  }
size_t GetProductsImplFull(const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
size_t GetProductsImplPart(const art::Event &evt, const std::string &which, const std::string &instance, std::vector< const T * > &prods)
template<class T >
size_t evd::SliceNavigator::GetProductsImplFull ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const T * > &  prods 
)
protected

Definition at line 266 of file SliceNavigator_service.cc.

References om::cerr, distance(), e, allTimeWatchdog::endl, fFilterResults, art::fill_ptr_vector(), fSliceInstance, fSliceLabel, art::DataViewImpl::getByLabel(), GetProductsImplPart(), MECModelEnuComparisons::i, rb::IsFiltered(), T, and APDHVSetting::temp.

Referenced by DimOthers(), GetProducts(), GetProductsImpl(), and GetProductsImplFull().

270  {
271 
272  art::Handle<std::vector<T> > tempHandle;
273 
274  std::vector<art::Ptr<T> > temp;
275 
276  try{
277  evt.getByLabel(art::InputTag(which, instance), tempHandle);
278  art::fill_ptr_vector( temp,tempHandle);
279  }
280  catch(cet::exception& e){
281  std::cerr << "Failed to get products of type " << typeid(T).name()
282  << " under label \"" << which << "\": "
283  << e << std::endl;
284  }
285 
286  std::vector<art::Ptr<T> > tempcopy;
287  // If fFilterResults is turned on, we don't want to
288  // draw anything from a slice that was filtered out
289  // So each product has to be mapped to its associated
290  // slice cluster and check if the slice was filtered out.
291  if( fFilterResults &&
292  typeid(T) != typeid(rb::CellHit) &&
293  typeid(T) != typeid(simb::MCTruth)){
294 
296  evt.getByLabel( art::InputTag(fSliceLabel, fSliceInstance), slicesHandle);
297  std::vector<art::Ptr<rb::Cluster> > slices;
298  art::fill_ptr_vector( slices, slicesHandle);
299  art::FindOneP<rb::Cluster> fot(temp, evt, which);
300 
301  if(!fot.isValid()){
302  std::cerr << "Nothing of type " << typeid(T).name()
303  << " with label \"" << which << "\" and instance \"" << instance
304  << "\" associated with slices" << std::endl;
305  return 0;
306  }
307 
308  int nT = temp.size();
309  for( int i = 0; i < nT; i++){
310 
311  art::Ptr<rb::Cluster> slice = fot.at( i );
312  std::vector< art::Ptr< rb::Cluster> >::iterator slicePos =
313  std::find(slices.begin(), slices.end(), slice) ;
314  int iSlice = std::distance( slices.begin(), slicePos );
315 
316  if( fFilterResults && rb::IsFiltered(evt,slicesHandle, iSlice ) )
317  continue;
318  tempcopy.push_back( temp[i] );
319 
320  }// end loop over temp
321  }
322  else
323  tempcopy.swap( temp );
324 
325  for( art::Ptr<T> p: tempcopy)
326  prods.push_back( p.get());
327 
328  return prods.size();
329  }
const XML_Char * name
Definition: expat.h:151
std::string fSliceLabel
const char * p
Definition: xmltok.h:285
OStream cerr
Definition: OStream.cxx:7
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
unsigned distance(const T &t1, const T &t2)
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
bool fFilterResults
Only navigate slices that aren&#39;t filtered out.
double T
Definition: Xdiff_gwt.C:5
std::string fSliceInstance
Event generator information.
Definition: MCTruth.h:32
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:35
template<>
size_t evd::SliceNavigator::GetProductsImplFull ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const rb::Cluster * > &  clusts 
)

Definition at line 246 of file SliceNavigator_service.cc.

References om::cerr, e, allTimeWatchdog::endl, GetProductsImplFull(), art::DataViewImpl::getView(), and APDHVSetting::temp.

250  {
251  std::vector<const rb::Cluster*> temp(clusts);
252  try{
253  evt.getView(which, instance, temp);
254  temp.swap(clusts);
255  }
256  catch(cet::exception& e){
257  std::cerr << "Failed to get products of type " << typeid(rb::Cluster).name()
258  << " under label \"" << which << "\": "
259  << e << std::endl;
260  }
261  return clusts.size();
262  }
const XML_Char * name
Definition: expat.h:151
A collection of associated CellHits.
Definition: Cluster.h:47
OStream cerr
Definition: OStream.cxx:7
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:474
Float_t e
Definition: plot.C:35
template<class T >
size_t evd::SliceNavigator::GetProductsImplPart ( const art::Event evt,
const std::string which,
const std::string instance,
std::vector< const T * > &  prods 
)
protected

Definition at line 334 of file SliceNavigator_service.cc.

References om::cerr, allTimeWatchdog::endl, art::Handle< T >::failedToGet(), fCurrentSlice, PandAna.Demos.pi0_spectra::fmt, fSliceInstance, fSliceLabel, fSlicesToNavigate, art::DataViewImpl::getByLabel(), GetProducts(), and T.

Referenced by DimOthers(), GetProductsImpl(), and GetProductsImplFull().

338  {
341 
342  if(slices.failedToGet()){
343  std::cerr << "Couldn't find any slices under label "
344  << fSliceLabel << std::endl;
345  return 0;
346  }
347 
348  art::FindManyP<T> fmt(slices, evt, art::InputTag(which, instance));
349  if(!fmt.isValid()){
350  std::cerr << "Nothing of type " << typeid(T).name()
351  << " with label \"" << which << "\" and instance \"" << instance
352  << "\" associated with slices" << std::endl;
353  return 0;
354  }
355 
356  std::vector<art::Ptr<T>> prodPtrs = fmt.at( fSlicesToNavigate[fCurrentSlice] );
357  prods.clear();
358  for(art::Ptr<T> p: prodPtrs) prods.push_back(p.get());
359  return prods.size();
360  }
const XML_Char * name
Definition: expat.h:151
std::string fSliceLabel
const char * p
Definition: xmltok.h:285
OStream cerr
Definition: OStream.cxx:7
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double T
Definition: Xdiff_gwt.C:5
std::string fSliceInstance
Definition: fwd.h:28
bool failedToGet() const
Definition: Handle.h:196
Bool_t evd::SliceNavigator::HandleTimer ( TTimer *  t)
protected

Definition at line 729 of file SliceNavigator_service.cc.

References Next().

Referenced by DimOthers().

730  {
731  // This is the auto-advance timer
732  Next();
733  return true;
734  }
int evd::SliceNavigator::MaxSlice ( ) const

Definition at line 550 of file SliceNavigator_service.cc.

References fMaxSliceId.

Referenced by evd::SliceButtonBar::Update().

551  {
552  return fMaxSliceId;
553  }
void evd::SliceNavigator::Next ( )

Definition at line 478 of file SliceNavigator_service.cc.

References fCurrentSlice, fSlicesToNavigate, evdb::kNEXT_EVENT, evdb::kRELOAD_EVENT, and evdb::NavState::Set().

Referenced by HandleTimer(), and evd::SliceButtonBar::Next().

479  {
480  ++fCurrentSlice;
481 
482  if(fCurrentSlice >= int(fSlicesToNavigate.size())){
483  fCurrentSlice = -2;
484  fSlicesToNavigate.clear();
486  }
487  else{
488  // Go to the slice requested
490  }
491  }
static void Set(int which)
Definition: NavState.cxx:24
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
void evd::SliceNavigator::ParseModuleInstanceString ( std::string mod,
std::string inst 
)
protected

Definition at line 88 of file SliceNavigator_service.cc.

Referenced by DimOthers(), and reconfigure().

90  {
91  const size_t splitPos = mod.find_first_of('_');
92  if(splitPos == std::string::npos){
93  inst = "";
94  return;
95  }
96  inst = mod.substr(splitPos+1);
97  mod.resize(splitPos);
98  }
void evd::SliceNavigator::postProcessEvent ( const art::Event evt)

Definition at line 107 of file SliceNavigator_service.cc.

References om::cerr, art::PtrVector< T >::clear(), om::cout, CurrentSlice(), allTimeWatchdog::endl, art::Event::event(), exit(), art::Handle< T >::failedToGet(), fAllHits, fAutoAdvanceInterval, fAutoPrintCount, fAutoPrintMax, fAutoPrintPattern, fCellHitInstance, fCellHitLabel, fCurrentSlice, fFilterResults, fFullEvent, shutoffs::filename, fInitialSlice, fMaxSliceId, fRun, fSliceInstance, fSliceLabel, fSlices, fSlicesToNavigate, fTimer, art::DataViewImpl::getByLabel(), evdb::Printable::GetPrintables(), GetProducts(), MECModelEnuComparisons::i, rb::IsFiltered(), it, evdb::kNEXT_EVENT, evdb::kPREV_EVENT, evdb::Printable::Print(), nd_projection_maker::ps, art::PtrVector< T >::push_back(), evdb::NavState::Set(), string, stringReplace(), and art::to_string().

Referenced by SliceNavigator().

108  {
109  // Clear the slices to navigate vector
110  fSlicesToNavigate.clear();
111 
113 
115 
116  evt.getByLabel( sliceTag, slices);
117 
118  if(slices.failedToGet()){
119  std::cerr << "Couldn't find any slices under label "
120  << fSliceLabel << std::endl;
121  fMaxSliceId = 0;
122  return;
123  }
124 
125  int nSli = slices->size();
126  for( int iSli = 0; iSli < nSli; ++iSli){
127  // if we only want to look at slices that
128  // survived filtering, throw the rest away
129  if(!fFullEvent && fFilterResults && rb::IsFiltered(evt,slices,iSli) )
130  continue;
131  if(!fFullEvent && (*slices)[iSli].IsNoise())
132  continue;
133 
134  fSlicesToNavigate.push_back( iSli );
135  if(iSli == fInitialSlice){
136  fCurrentSlice = fSlicesToNavigate.size()-1;
137  fInitialSlice = -1; // Don't do this again
138  }
139  }
140  if (fSlicesToNavigate.size() > 0) fMaxSliceId = fSlicesToNavigate.back();
141 
142  // Protecting against segfaults: If we've advanced to the next event
143  // with fCurrentSlice set to the max number of slices, and the next event
144  // has fewer slices than the previous, we need to make sure we don't
145  // suffer from an index out of range problem.
146  if( (fCurrentSlice + 1 > int(fSlicesToNavigate.size())) && !fSlicesToNavigate.empty() )
147  fCurrentSlice = fSlicesToNavigate.size() - 1;
148 
149  if(fCurrentSlice == -1){
150  if(!fSlicesToNavigate.empty())
151  // We pressed the prev slice button
152  fCurrentSlice = fSlicesToNavigate.size()-1;
153  else
155  }
156 
157  if(fCurrentSlice == -2 ){
158  if(!fSlicesToNavigate.empty())
159  // We pressed the next button, but there
160  // no more slices left in the previous event
161  fCurrentSlice = 0;
162  else
164  }
165 
167  evt.getByLabel(sliceTag, slicecol);
168  fSlices.clear();
169  for(unsigned int i = 0; i < slicecol->size(); ++i)
170  fSlices.push_back(art::Ptr<rb::Cluster>(slicecol, i));
171 
174  evt.getByLabel(cellTag, hitcol);
175  fAllHits.clear();
176  for(unsigned int i = 0; i < hitcol->size(); ++i)
178 
179  // Auto-printing
180  if (fAutoPrintMax > 0 || fAutoPrintMax == -1){
181  ++fAutoPrintCount;
182  std::map<std::string, evdb::Printable*>& ps = evdb::Printable::GetPrintables();
183  for(std::map<std::string, evdb::Printable*>::iterator it = ps.begin(); it != ps.end(); ++it){
184  evdb::Printable* p = it->second;
185 
187  // std::string filename = "evd-slice_r%r_e%e_s%s.gif";
188 
189  // Insert instances of run variable into filename
190  if (filename.find("%r") != std::string::npos)
191  stringReplace(filename, "%r", std::to_string(fRun));
192 
193  // Insert instances of event variable into filename
194  if (filename.find("%e") != std::string::npos)
195  stringReplace(filename, "%e", std::to_string(evt.event()));
196 
197  // Insert instances of slice variable into filename
198  if (filename.find("%s") != std::string::npos)
199  stringReplace(filename, "%s", std::to_string(this->CurrentSlice()));
200 
201  // Print file
202  p->Print(TString(filename));
203  }
204  if (fAutoPrintCount >= (fAutoPrintMax - 1) && fAutoPrintMax != -1)
205  {
206  std::cout << "Hit autoprint max and exiting." << std::endl;
207  exit(0);
208  }
209  }
210 
211  if(fTimer){
212  // Auto-advance is active. Fire off one more shot
213  fTimer->Start(fAutoAdvanceInterval, true);
214  }
215  }
int fAutoPrintMax
How many events to print (zero = disable printing)
static void Set(int which)
Definition: NavState.cxx:24
set< int >::iterator it
std::vector< art::Ptr< rb::Cluster > > fSlices
Base class for printable objects.
Definition: Printable.h:15
std::string fSliceLabel
const char * p
Definition: xmltok.h:285
int fInitialSlice
-1 afterwards
OStream cerr
Definition: OStream.cxx:7
string filename
Definition: shutoffs.py:106
std::string fCellHitLabel
static std::map< std::string, evdb::Printable * > & GetPrintables()
Definition: Printable.cxx:61
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
std::vector< int > fSlicesToNavigate
std::string fAutoPrintPattern
Pattern for constructing filename.
int fCurrentSlice
Index into fSlicesToNavigate.
bool IsFiltered(const art::Event &evt, art::Ptr< T > x, const std::vector< std::string > &labels)
Is this Ptr marked "filtered out"?
Definition: FilterList.h:96
EventNumber_t event() const
Definition: Event.h:67
OStream cout
Definition: OStream.cxx:6
int fAutoAdvanceInterval
Wait time in milliseconds.
std::string stringReplace(std::string &s, const std::string &toReplace, const std::string &replaceWith)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
art::PtrVector< rb::CellHit > fAllHits
bool fFilterResults
Only navigate slices that aren&#39;t filtered out.
exit(0)
std::string fSliceInstance
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void clear()
Definition: PtrVector.h:537
std::string fCellHitInstance
bool failedToGet() const
Definition: Handle.h:196
virtual void Print(const char *filename)=0
enum BeamMode string
void evd::SliceNavigator::preBeginRun ( art::Run const &  r)

Definition at line 101 of file SliceNavigator_service.cc.

References fRun, and art::Run::run().

Referenced by SliceNavigator().

102  {
103  fRun = r.run();
104  }
TRandom3 r(0)
void evd::SliceNavigator::Previous ( )

Definition at line 462 of file SliceNavigator_service.cc.

References fCurrentSlice, fSlicesToNavigate, evdb::kPREV_EVENT, evdb::kRELOAD_EVENT, and evdb::NavState::Set().

Referenced by evd::SliceButtonBar::Previous().

463  {
464  --fCurrentSlice;
465 
466  if(fCurrentSlice < 0){
467  fCurrentSlice = -1;
469  fSlicesToNavigate.clear();
470  }
471  else{
472  // Go to the slice requested
474  }
475  }
static void Set(int which)
Definition: NavState.cxx:24
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
void evd::SliceNavigator::reconfigure ( const fhicl::ParameterSet pset)
override

Definition at line 68 of file SliceNavigator_service.cc.

References fAutoAdvanceInterval, fAutoPrintMax, fAutoPrintPattern, fCellHitInstance, fCellHitLabel, fDimHits, fDimOthers, fFilterResults, fFullEvent, fInitialSlice, fSliceInstance, fSliceLabel, fhicl::ParameterSet::get(), ParseModuleInstanceString(), and string.

Referenced by SliceNavigator().

69  {
70  fSliceLabel = pset.get<std::string>("SliceLabel");
71  fCellHitLabel = pset.get<std::string>("CellHitLabel");
72  fAutoAdvanceInterval = pset.get<int>("AutoAdvanceInterval");
73  fAutoPrintPattern = pset.get<std::string>("AutoPrintPattern");
74  fAutoPrintMax = pset.get<int>("AutoPrintMax");
75  fFilterResults = (pset.get<int>("SliceOpt.val") & 1);
76  fDimHits = (pset.get<int>("SliceOpt.val") & 2);
77  fDimOthers = (pset.get<int>("SliceOpt.val") & 4);
78 
79  fFullEvent = !pset.get<bool>("InitiallyEnabled");
80  fInitialSlice = pset.get<int>("InitialSlice");
81 
83  this->ParseModuleInstanceString(fCellHitLabel, fCellHitInstance);
84 
85  }
int fAutoPrintMax
How many events to print (zero = disable printing)
void ParseModuleInstanceString(std::string &mod, std::string &inst)
std::string fSliceLabel
int fInitialSlice
-1 afterwards
std::string fCellHitLabel
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::string fAutoPrintPattern
Pattern for constructing filename.
int fAutoAdvanceInterval
Wait time in milliseconds.
bool fFilterResults
Only navigate slices that aren&#39;t filtered out.
std::string fSliceInstance
std::string fCellHitInstance
enum BeamMode string
void evd::SliceNavigator::SetCurrentSlice ( int  slice)

Definition at line 533 of file SliceNavigator_service.cc.

References fCurrentSlice, fSlicesToNavigate, it, evdb::kRELOAD_EVENT, and evdb::NavState::Set().

Referenced by evd::SliceButtonBar::GoTo().

534  {
535  auto it = std::find(fSlicesToNavigate.begin(),
536  fSlicesToNavigate.end(),
537  slice);
538  if(it != fSlicesToNavigate.end()){
541  }
542  else{
543  // What else can we do?
544  fCurrentSlice = 0;
546  }
547  }
static void Set(int which)
Definition: NavState.cxx:24
set< int >::iterator it
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
void evd::SliceNavigator::SetFullEventMode ( bool  mode)
std::vector< const rb::Cluster * > evd::SliceNavigator::SlicesToNavigate ( const art::Event evt)

Definition at line 707 of file SliceNavigator_service.cc.

References art::Handle< T >::failedToGet(), fSliceInstance, fSliceLabel, fSlicesToNavigate, art::DataViewImpl::getByLabel(), and MECModelEnuComparisons::i.

Referenced by evd::RecoBaseDrawer::CellHit2D(), evd::RawDataDrawer::RawDigit2D(), evd::RawDataDrawer::RawDigit3D(), and evd::RawDataDrawer::RawDigitHardware().

708  {
709  std::vector<const rb::Cluster*> clusts;
712  if(slices.failedToGet()) return {};
713 
714  for(unsigned int i = 0; i < fSlicesToNavigate.size(); ++i)
715  clusts.push_back(&(*slices)[fSlicesToNavigate[i]]);
716 
717  return clusts;
718  }// End of SlicesToNavigate
std::string fSliceLabel
std::vector< int > fSlicesToNavigate
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::string fSliceInstance
bool failedToGet() const
Definition: Handle.h:196
void evd::SliceNavigator::StopAutoAdvance ( )

Definition at line 504 of file SliceNavigator_service.cc.

References fTimer.

Referenced by evd::SliceButtonBar::AutoAdvance().

505  {
506  if(!fTimer) return;
507  fTimer->Stop();
508  delete fTimer;
509  fTimer = 0;
510  }
std::string evd::SliceNavigator::stringReplace ( std::string s,
const std::string toReplace,
const std::string replaceWith 
)
protected

Definition at line 721 of file SliceNavigator_service.cc.

Referenced by DimOthers(), and postProcessEvent().

724  {
725  return(s.replace(s.find(toReplace), toReplace.length(), replaceWith));
726  }
const XML_Char * s
Definition: expat.h:262

Member Data Documentation

art::PtrVector<rb::CellHit> evd::SliceNavigator::fAllHits
protected

Definition at line 127 of file SliceNavigator.h.

Referenced by GetProducts(), and postProcessEvent().

int evd::SliceNavigator::fAutoAdvanceInterval
protected

Wait time in milliseconds.

Definition at line 106 of file SliceNavigator.h.

Referenced by AutoAdvance(), postProcessEvent(), and reconfigure().

int evd::SliceNavigator::fAutoPrintCount
protected

Definition at line 110 of file SliceNavigator.h.

Referenced by postProcessEvent(), and SliceNavigator().

int evd::SliceNavigator::fAutoPrintMax
protected

How many events to print (zero = disable printing)

Definition at line 108 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evd::SliceNavigator::fAutoPrintPattern
protected

Pattern for constructing filename.

Definition at line 107 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evd::SliceNavigator::fCellHitInstance
protected

Definition at line 120 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evd::SliceNavigator::fCellHitLabel
protected

Definition at line 118 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

int evd::SliceNavigator::fCurrentSlice
protected
bool evd::SliceNavigator::fDimHits
protected

Definition at line 115 of file SliceNavigator.h.

Referenced by DimHits(), and reconfigure().

bool evd::SliceNavigator::fDimOthers
protected

Definition at line 116 of file SliceNavigator.h.

Referenced by DimOthers(), and reconfigure().

bool evd::SliceNavigator::fFilterResults
protected

Only navigate slices that aren't filtered out.

Definition at line 114 of file SliceNavigator.h.

Referenced by GetProducts(), GetProductsImplFull(), postProcessEvent(), and reconfigure().

bool evd::SliceNavigator::fFullEvent
protected
int evd::SliceNavigator::fInitialSlice
protected

-1 afterwards

Definition at line 129 of file SliceNavigator.h.

Referenced by postProcessEvent(), reconfigure(), and SliceNavigator().

int evd::SliceNavigator::fMaxSliceId
protected

Definition at line 123 of file SliceNavigator.h.

Referenced by MaxSlice(), postProcessEvent(), and SliceNavigator().

int evd::SliceNavigator::fRun
protected

Definition at line 112 of file SliceNavigator.h.

Referenced by postProcessEvent(), preBeginRun(), and SliceNavigator().

std::string evd::SliceNavigator::fSliceInstance
protected
std::string evd::SliceNavigator::fSliceLabel
protected
std::vector<art::Ptr<rb::Cluster> > evd::SliceNavigator::fSlices
protected

Definition at line 126 of file SliceNavigator.h.

Referenced by GetProducts(), and postProcessEvent().

std::vector<int> evd::SliceNavigator::fSlicesToNavigate
protected
TTimer* evd::SliceNavigator::fTimer
protected

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