Public Member Functions | Public Attributes | 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/N20-12-03/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 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)
 

Public 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
 

Protected Member Functions

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

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 38 of file SliceNavigator_service.cc.

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

40  : evdb::Reconfigurable{pset},
41  fAutoPrintCount(0),
42  fRun(0),
43  fFullEvent(true),
44  fCurrentSlice(0),
45  fMaxSliceId(0),
46  fInitialSlice(-1)
47  {
48  reconfigure(pset);
49 
50  evdb::ServiceTable::OverrideCategory("SliceNavigator",
52 
54  reg.sPreBeginRun.watch(this, &SliceNavigator::preBeginRun);
55  }
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 58 of file SliceNavigator_service.cc.

References fSlicesToNavigate.

59  {
60  fSlicesToNavigate.clear();
61  }
std::vector< int > fSlicesToNavigate

Member Function Documentation

int evd::SliceNavigator::CurrentSlice ( ) const

Definition at line 481 of file SliceNavigator_service.cc.

References fCurrentSlice, and fSlicesToNavigate.

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

482  {
483  if(fSlicesToNavigate.empty() || fCurrentSlice < 0) return 0;
484 
486  }
std::vector< int > fSlicesToNavigate
int fCurrentSlice
Index into fSlicesToNavigate.
int evd::SliceNavigator::CurrentSliceIndex ( ) const

Definition at line 489 of file SliceNavigator_service.cc.

References fCurrentSlice.

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

490  {
491  return fCurrentSlice;
492  }
int fCurrentSlice
Index into fSlicesToNavigate.
bool evd::SliceNavigator::DimHits ( ) const
inline

Definition at line 71 of file SliceNavigator.h.

References fDimHits.

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

71 {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 518 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().

523  {
524  // Fallback to the whole detector in case we don't get values below
526  xmin = -geom->DetHalfWidth();
527  xmax = +geom->DetHalfWidth();
528  ymin = -geom->DetHalfHeight();
529  ymax = +geom->DetHalfHeight();
530  zmin = 0;
531  zmax = geom->DetLength();
532 
535 
536  if(slices.failedToGet()){
537  std::cerr << "Couldn't find any slices under label "
538  << fSliceLabel << std::endl;
539  return;
540  }
541 
542  if(fCurrentSlice >= 0 && fCurrentSlice < int(slices->size())){
543  const rb::Cluster& slice = (*slices)[fSlicesToNavigate[fCurrentSlice]];
544 
545  if(trimfrac == 0){
546  const TVector3 r0 = slice.MinXYZ();
547  const TVector3 r1 = slice.MaxXYZ();
548  xmin = r0.X(); xmax = r1.X();
549  ymin = r0.Y(); ymax = r1.Y();
550  zmin = r0.Z(); zmax = r1.Z();
551  return;
552  }
553 
554  std::vector<double> xs, ys, zs;
555 
556  for(unsigned int i = 0; i < slice.NCell(); ++i){
557  const art::Ptr<rb::CellHit>& chit = slice.Cell(i);
558  double xyz[3];
559  geom->Plane(chit->Plane())->Cell(chit->Cell())->GetCenter(xyz);
560  zs.push_back(xyz[2]);
561  if(chit->View() == geo::kX)
562  xs.push_back(xyz[0]);
563  else
564  ys.push_back(xyz[1]);
565  }
566 
567  std::sort(xs.begin(), xs.end());
568  std::sort(ys.begin(), ys.end());
569  std::sort(zs.begin(), zs.end());
570 
571  xmin = xs[xs.size()*trimfrac];
572  ymin = ys[ys.size()*trimfrac];
573  zmin = zs[zs.size()*trimfrac];
574 
575  // For small events we want to pick up the last hit, not the N-1th hit
576  xmax = xs[(xs.size()-1)*(1-trimfrac)+1];
577  ymax = ys[(ys.size()-1)*(1-trimfrac)+1];
578  zmax = zs[(zs.size()-1)*(1-trimfrac)+1];
579  }
580  }
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 583 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().

588  {
589  // Fallback to the whole detector in case we don't get values below
591  xmin = -geom->DetHalfWidth();
592  xmax = +geom->DetHalfWidth();
593  ymin = -geom->DetHalfHeight();
594  ymax = +geom->DetHalfHeight();
595  zmin = 0;
596  zmax = geom->DetLength();
597 
598  // Use Fiducial dimensions if smaller than slice
600 
601  float xbox=0;
602  float ybox=0;
603  float zbox=0;
604  if ( (drawopt->fSliceBoxSize).size() == 3 ) {
605  std::vector< float > sizes = drawopt->fSliceBoxSize;
606  xbox = sizes[0];
607  ybox = sizes[1];
608  zbox = sizes[2];
609  }
612 
613  if(slices.failedToGet()){
614  std::cerr << "Couldn't find any slices under label "
615  << fSliceLabel << std::endl;
616  return;
617  }
618 
619  if(fCurrentSlice >= 0 && fCurrentSlice < int(slices->size())){
620  const rb::Cluster& slice = (*slices)[fSlicesToNavigate[fCurrentSlice]];
621 
622  if(trimfrac == 0){
623  const TVector3 r0 = slice.MinXYZ();
624  const TVector3 r1 = slice.MaxXYZ();
625  xmin = r0.X(); xmax = r1.X();
626  ymin = r0.Y(); ymax = r1.Y();
627  zmin = r0.Z(); zmax = r1.Z();
628  return;
629  }
630 
631  std::vector<double> xs, ys, zs;
632 
633  for(unsigned int i = 0; i < slice.NCell(); ++i){
634  const art::Ptr<rb::CellHit>& chit = slice.Cell(i);
635  double xyz[3];
636  geom->Plane(chit->Plane())->Cell(chit->Cell())->GetCenter(xyz);
637  zs.push_back(xyz[2]);
638  if(chit->View() == geo::kX)
639  xs.push_back(xyz[0]);
640  else
641  ys.push_back(xyz[1]);
642  }
643  std::sort(xs.begin(), xs.end());
644  std::sort(ys.begin(), ys.end());
645  std::sort(zs.begin(), zs.end());
646 
647  xmin = xs[xs.size()*trimfrac];
648  ymin = ys[ys.size()*trimfrac];
649  zmin = zs[zs.size()*trimfrac];
650 
651  // For small events we want to pick up the last hit, not the N-1th hit
652  xmax = xs[(xs.size()-1)*(1-trimfrac)+1];
653  ymax = ys[(ys.size()-1)*(1-trimfrac)+1];
654  zmax = zs[(zs.size()-1)*(1-trimfrac)+1];
655 
656  double xmid=(xmax+xmin)/2;
657  double ymid=(ymax+ymin)/2;
658  double zmid=(zmax+zmin)/2;
659  xmax= ( xbox==0 ) ? xmax : xmid+xbox/2;
660  ymax= ( ybox==0 ) ? ymax : ymid+ybox/2;
661  zmax= ( zbox==0 ) ? zmax : zmid+zbox/2;
662  xmin= ( xbox==0 ) ? xmin : xmid-xbox/2;
663  ymin= ( ybox==0 ) ? ymin : ymid-ybox/2;
664  zmin= ( zbox==0 ) ? zmin : zmid-zbox/2;
665  }
666  }
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 352 of file SliceNavigator_service.cc.

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

357  {
358  std::vector<const me::TrkME*> clusts;
359  GetProductsImpl(evt, whichTrack, instance, tracks);
360  GetProductsImpl(evt, whichMichel, instance, clusts);
361 
362  for(const me::TrkME* c: clusts)
363  tracks.push_back(c->ParentTrk().get());
364 
365  return tracks.size();
366  }
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 371 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().

375  {
376  // If it's the actual slices, look them up by index.
377  // Otherwise we'll get nothing
378  // (not possible to associate Cluster with Cluster)
379  if(which == fSliceLabel && instance == ""){
381  evt.getByLabel(fSliceLabel, slices);
382  if(slices.failedToGet()){
383  std::cerr << "Couldn't find any slices under label "
384  << fSliceLabel << std::endl;
385  return 0;
386  }
387  if( fFullEvent ){
388  int nSli = slices->size();
389  for( int iSli=0; iSli < nSli; ++iSli){
390  if ( fFilterResults && rb::IsFiltered(evt,slices, iSli ) )
391  continue;
392  clusts.push_back((art::Ptr<rb::Cluster>(slices, iSli).get())) ;
393  }
394  }// if full event
395  else{
397  if( fCurrentSlice >=0 )
398  clusts.push_back( (art::Ptr<rb::Cluster>(slices, idx)).get() );
399  }
400  }
401  else
402  GetProductsImplFull(evt, which, instance, clusts);
403 
404  return clusts.size();
405  }
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 410 of file SliceNavigator_service.cc.

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

414  {
415  truths.clear();
416 
417  if(fFullEvent){
418  GetProductsImpl(evt, which, instance, truths);
419  }
420  else{
422 
423  std::vector<cheat::NeutrinoEffPur> eps =
425  fAllHits);
426 
427  if(!eps.empty()) truths = {eps.front().neutrinoInt.get()};
428  }
429 
430  return truths.size();
431  }
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 216 of file SliceNavigator_service.cc.

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

Referenced by GetProducts().

220  {
221  if(fFullEvent)
222  return GetProductsImplFull(evt, which, instance, prods);
223  else
224  return GetProductsImplPart(evt, which, instance, prods);
225  }
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 253 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 GetProducts(), GetProductsImpl(), and GetProductsImplFull().

257  {
258 
259  art::Handle<std::vector<T> > tempHandle;
260 
261  std::vector<art::Ptr<T> > temp;
262 
263  try{
264  evt.getByLabel(art::InputTag(which, instance), tempHandle);
265  art::fill_ptr_vector( temp,tempHandle);
266  }
267  catch(cet::exception& e){
268  std::cerr << "Failed to get products of type " << typeid(T).name()
269  << " under label \"" << which << "\": "
270  << e << std::endl;
271  }
272 
273  std::vector<art::Ptr<T> > tempcopy;
274  // If fFilterResults is turned on, we don't want to
275  // draw anything from a slice that was filtered out
276  // So each product has to be mapped to its associated
277  // slice cluster and check if the slice was filtered out.
278  if( fFilterResults &&
279  typeid(T) != typeid(rb::CellHit) &&
280  typeid(T) != typeid(simb::MCTruth)){
281 
283  evt.getByLabel( art::InputTag(fSliceLabel, fSliceInstance), slicesHandle);
284  std::vector<art::Ptr<rb::Cluster> > slices;
285  art::fill_ptr_vector( slices, slicesHandle);
286  art::FindOneP<rb::Cluster> fot(temp, evt, which);
287 
288  if(!fot.isValid()){
289  std::cerr << "Nothing of type " << typeid(T).name()
290  << " with label \"" << which << "\" and instance \"" << instance
291  << "\" associated with slices" << std::endl;
292  return 0;
293  }
294 
295  int nT = temp.size();
296  for( int i = 0; i < nT; i++){
297 
298  art::Ptr<rb::Cluster> slice = fot.at( i );
299  std::vector< art::Ptr< rb::Cluster> >::iterator slicePos =
300  std::find(slices.begin(), slices.end(), slice) ;
301  int iSlice = std::distance( slices.begin(), slicePos );
302 
303  if( fFilterResults && rb::IsFiltered(evt,slicesHandle, iSlice ) )
304  continue;
305  tempcopy.push_back( temp[i] );
306 
307  }// end loop over temp
308  }
309  else
310  tempcopy.swap( temp );
311 
312  for( art::Ptr<T> p: tempcopy)
313  prods.push_back( p.get());
314 
315  return prods.size();
316  }
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 233 of file SliceNavigator_service.cc.

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

237  {
238  std::vector<const rb::Cluster*> temp(clusts);
239  try{
240  evt.getView(which, instance, temp);
241  temp.swap(clusts);
242  }
243  catch(cet::exception& e){
244  std::cerr << "Failed to get products of type " << typeid(rb::Cluster).name()
245  << " under label \"" << which << "\": "
246  << e << std::endl;
247  }
248  return clusts.size();
249  }
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 321 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 GetProductsImpl(), and GetProductsImplFull().

325  {
328 
329  if(slices.failedToGet()){
330  std::cerr << "Couldn't find any slices under label "
331  << fSliceLabel << std::endl;
332  return 0;
333  }
334 
335  art::FindManyP<T> fmt(slices, evt, art::InputTag(which, instance));
336  if(!fmt.isValid()){
337  std::cerr << "Nothing of type " << typeid(T).name()
338  << " with label \"" << which << "\" and instance \"" << instance
339  << "\" associated with slices" << std::endl;
340  return 0;
341  }
342 
343  std::vector<art::Ptr<T>> prodPtrs = fmt.at( fSlicesToNavigate[fCurrentSlice] );
344  prods.clear();
345  for(art::Ptr<T> p: prodPtrs) prods.push_back(p.get());
346  return prods.size();
347  }
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
int evd::SliceNavigator::MaxSlice ( ) const

Definition at line 512 of file SliceNavigator_service.cc.

References fMaxSliceId.

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

513  {
514  return fMaxSliceId;
515  }
void evd::SliceNavigator::Next ( )

Definition at line 465 of file SliceNavigator_service.cc.

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

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

466  {
467  ++fCurrentSlice;
468 
469  if(fCurrentSlice >= int(fSlicesToNavigate.size())){
470  fCurrentSlice = -2;
471  fSlicesToNavigate.clear();
473  }
474  else{
475  // Go to the slice requested
477  }
478  }
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 84 of file SliceNavigator_service.cc.

Referenced by reconfigure().

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

Definition at line 103 of file SliceNavigator_service.cc.

References om::cerr, art::PtrVector< T >::clear(), CurrentSlice(), allTimeWatchdog::endl, art::Event::event(), exit(), art::Handle< T >::failedToGet(), fAllHits, fAutoPrintCount, fAutoPrintMax, fCellHitInstance, fCellHitLabel, fCurrentSlice, fFilterResults, fFullEvent, shutoffs::filename, fInitialSlice, fMaxSliceId, fRun, fSliceInstance, fSliceLabel, fSlices, fSlicesToNavigate, 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().

104  {
105  // Clear the slices to navigate vector
106  fSlicesToNavigate.clear();
107 
109 
111 
112  evt.getByLabel( sliceTag, slices);
113 
114  if(slices.failedToGet()){
115  std::cerr << "Couldn't find any slices under label "
116  << fSliceLabel << std::endl;
117  fMaxSliceId = 0;
118  return;
119  }
120 
121  int nSli = slices->size();
122  for( int iSli = 0; iSli < nSli; ++iSli){
123  // if we only want to look at slices that
124  // survived filtering, throw the rest away
125  if(!fFullEvent && fFilterResults && rb::IsFiltered(evt,slices,iSli) )
126  continue;
127  if(!fFullEvent && (*slices)[iSli].IsNoise())
128  continue;
129 
130  fSlicesToNavigate.push_back( iSli );
131  if(iSli == fInitialSlice){
132  fCurrentSlice = fSlicesToNavigate.size()-1;
133  fInitialSlice = -1; // Don't do this again
134  }
135  }
136  if (fSlicesToNavigate.size() > 0) fMaxSliceId = fSlicesToNavigate.back();
137 
138  // Protecting against segfaults: If we've advanced to the next event
139  // with fCurrentSlice set to the max number of slices, and the next event
140  // has fewer slices than the previous, we need to make sure we don't
141  // suffer from an index out of range problem.
142  if( (fCurrentSlice + 1 > int(fSlicesToNavigate.size())) && !fSlicesToNavigate.empty() )
143  fCurrentSlice = fSlicesToNavigate.size() - 1;
144 
145  if(fCurrentSlice == -1){
146  if(!fSlicesToNavigate.empty())
147  // We pressed the prev slice button
148  fCurrentSlice = fSlicesToNavigate.size()-1;
149  else
151  }
152 
153  if(fCurrentSlice == -2 ){
154  if(!fSlicesToNavigate.empty())
155  // We pressed the next button, but there
156  // no more slices left in the previous event
157  fCurrentSlice = 0;
158  else
160  }
161 
163  evt.getByLabel(sliceTag, slicecol);
164  fSlices.clear();
165  for(unsigned int i = 0; i < slicecol->size(); ++i)
166  fSlices.push_back(art::Ptr<rb::Cluster>(slicecol, i));
167 
170  evt.getByLabel(cellTag, hitcol);
171  fAllHits.clear();
172  for(unsigned int i = 0; i < hitcol->size(); ++i)
174 
175  // Auto-printing
176  if (fAutoPrintMax > 0 || fAutoPrintMax == -1){
177  ++fAutoPrintCount;
178  std::map<std::string, evdb::Printable*>& ps = evdb::Printable::GetPrintables();
179  for(std::map<std::string, evdb::Printable*>::iterator it = ps.begin(); it != ps.end(); ++it){
180  evdb::Printable* p = it->second;
181 
182  // std::string filename = fAutoPrintPattern;
183  std::string filename = "evd-slice_r%r_e%e_s%s.gif";
184 
185  // Insert instances of run variable into filename
186  if (filename.find("%r") != std::string::npos)
187  stringReplace(filename, "%r", std::to_string(fRun));
188 
189  // Insert instances of event variable into filename
190  if (filename.find("%e") != std::string::npos)
191  stringReplace(filename, "%e", std::to_string(evt.event()));
192 
193  // Insert instances of slice variable into filename
194  if (filename.find("%s") != std::string::npos)
195  stringReplace(filename, "%s", std::to_string(this->CurrentSlice()));
196 
197  // Print file
198  p->Print(TString(filename));
199  }
200  if (fCurrentSlice >= (fAutoPrintMax - 1) && fAutoPrintMax != -1) exit(0);
201  }
202  }
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
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
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 97 of file SliceNavigator_service.cc.

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

Referenced by SliceNavigator().

98  {
99  fRun = r.run();
100  }
TRandom3 r(0)
void evd::SliceNavigator::Previous ( )

Definition at line 449 of file SliceNavigator_service.cc.

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

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

450  {
451  --fCurrentSlice;
452 
453  if(fCurrentSlice < 0){
454  fCurrentSlice = -1;
456  fSlicesToNavigate.clear();
457  }
458  else{
459  // Go to the slice requested
461  }
462  }
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 64 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().

65  {
66  fSliceLabel = pset.get<std::string>("SliceLabel");
67  fCellHitLabel = pset.get<std::string>("CellHitLabel");
68  fAutoAdvanceInterval = pset.get<int>("AutoAdvanceInterval");
69  fAutoPrintPattern = pset.get<std::string>("AutoPrintPattern");
70  fAutoPrintMax = pset.get<int>("AutoPrintMax");
71  fFilterResults = (pset.get<int>("SliceOpt.val") & 1);
72  fDimHits = (pset.get<int>("SliceOpt.val") & 2);
73  fDimOthers = (pset.get<int>("SliceOpt.val") & 4);
74 
75  fFullEvent = !pset.get<bool>("InitiallyEnabled");
76  fInitialSlice = pset.get<int>("InitialSlice");
77 
79  this->ParseModuleInstanceString(fCellHitLabel, fCellHitInstance);
80 
81  }
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 495 of file SliceNavigator_service.cc.

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

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

496  {
497  auto it = std::find(fSlicesToNavigate.begin(),
498  fSlicesToNavigate.end(),
499  slice);
500  if(it != fSlicesToNavigate.end()){
503  }
504  else{
505  // What else can we do?
506  fCurrentSlice = 0;
508  }
509  }
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 669 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().

670  {
671  std::vector<const rb::Cluster*> clusts;
674  if(slices.failedToGet()) return {};
675 
676  for(unsigned int i = 0; i < fSlicesToNavigate.size(); ++i)
677  clusts.push_back(&(*slices)[fSlicesToNavigate[i]]);
678 
679  return clusts;
680  }// 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
std::string evd::SliceNavigator::stringReplace ( std::string s,
const std::string toReplace,
const std::string replaceWith 
)
protected

Definition at line 683 of file SliceNavigator_service.cc.

Referenced by postProcessEvent().

686  {
687  return(s.replace(s.find(toReplace), toReplace.length(), replaceWith));
688  }
const XML_Char * s
Definition: expat.h:262

Member Data Documentation

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

Definition at line 121 of file SliceNavigator.h.

Referenced by GetProducts(), and postProcessEvent().

int evd::SliceNavigator::fAutoAdvanceInterval

Wait time in milliseconds.

Definition at line 74 of file SliceNavigator.h.

Referenced by evd::SliceButtonBar::AutoAdvance(), evd::SliceButtonBar::HandleTimer(), and reconfigure().

int evd::SliceNavigator::fAutoPrintCount

Definition at line 78 of file SliceNavigator.h.

Referenced by postProcessEvent(), and SliceNavigator().

int evd::SliceNavigator::fAutoPrintMax

How many events to print (zero = disable printing)

Definition at line 76 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evd::SliceNavigator::fAutoPrintPattern

Pattern for constructing filename.

Definition at line 75 of file SliceNavigator.h.

Referenced by reconfigure().

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

Definition at line 114 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

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

Definition at line 112 of file SliceNavigator.h.

Referenced by postProcessEvent(), and reconfigure().

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

Definition at line 109 of file SliceNavigator.h.

Referenced by DimHits(), and reconfigure().

bool evd::SliceNavigator::fDimOthers
protected

Definition at line 110 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 108 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 123 of file SliceNavigator.h.

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

int evd::SliceNavigator::fMaxSliceId
protected

Definition at line 117 of file SliceNavigator.h.

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

int evd::SliceNavigator::fRun
protected

Definition at line 106 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 120 of file SliceNavigator.h.

Referenced by GetProducts(), and postProcessEvent().

std::vector<int> evd::SliceNavigator::fSlicesToNavigate
protected

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