Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tut::RecoValidationTutorial Class Reference
Inheritance diagram for tut::RecoValidationTutorial:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 RecoValidationTutorial (const fhicl::ParameterSet &p)
 
 ~RecoValidationTutorial ()
 
void analyze (const art::Event &evt)
 
void reconfigure (const fhicl::ParameterSet &p)
 
void beginJob ()
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Protected Attributes

std::string fCellHitLabel
 module label for CellHit More...
 
std::string fClusterLabel
 module label for clusters More...
 
std::string fVertexLabel
 module label for vertices More...
 
art::ServiceHandle< cheat::BackTrackerbt
 
TH1 * fVertexX
 
TH1 * fVertexY
 
TH1 * fVertexZ
 

Detailed Description

Definition at line 35 of file RecoValidationTutorial_module.cc.

Member Typedef Documentation

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

tut::RecoValidationTutorial::RecoValidationTutorial ( const fhicl::ParameterSet p)
explicit

Definition at line 68 of file RecoValidationTutorial_module.cc.

References reconfigure().

69  : EDAnalyzer(pset)
70  {
71  reconfigure(pset);
72  }
EDAnalyzer(Table< Config > const &config)
Definition: EDAnalyzer.h:100
void reconfigure(const fhicl::ParameterSet &p)
tut::RecoValidationTutorial::~RecoValidationTutorial ( )

Definition at line 75 of file RecoValidationTutorial_module.cc.

76  {
77  }

Member Function Documentation

void tut::RecoValidationTutorial::analyze ( const art::Event evt)

Definition at line 96 of file RecoValidationTutorial_module.cc.

References cheat::BackTracker::allMCTruth(), bt, DEFINE_ART_MODULE(), cheat::EffMetric(), allTimeWatchdog::endl, fClusterLabel, fVertexLabel, fVertexX, fVertexY, fVertexZ, art::DataViewImpl::getByLabel(), simb::MCTruth::GetNeutrino(), MECModelEnuComparisons::i, rb::Cluster::IsNoise(), rb::Cluster::NCell(), simb::MCNeutrino::Nu(), art::PtrVector< T >::push_back(), art::PtrVector< T >::size(), cheat::BackTracker::SlicesToMCTruthsTable(), cheat::BackTracker::SliceToOrderedNuIds(), simb::MCParticle::Vx(), simb::MCParticle::Vy(), and simb::MCParticle::Vz().

97  {
98 
99  // ---------- Get data products ----------
100 
101  // Get all Slices in the event
103  evt.getByLabel(fClusterLabel, sliceHandle);
104 
106  for ( unsigned int i = 0; i < sliceHandle->size(); ++i ) {
107  art::Ptr<rb::Cluster> sliceptr(sliceHandle, i);
108  slices.push_back(sliceptr);
109  }
110 
111 
112  // Get vertices associated with the slices
113  art::FindManyP<rb::Vertex> fmVert(sliceHandle, evt, fVertexLabel);
114 
115 
116  // Get all truths related to this slice
117  std::vector<std::vector<cheat::NeutrinoEffPur>> slTruth = bt->SlicesToMCTruthsTable(slices);
118  // Get all neutrinos from the event
119  std::vector<cheat::NeutrinoWithIndex> nus = bt->allMCTruth();
120  std::vector<std::vector<cheat::NeutrinoEffPur>> sEffPur = bt->SlicesToMCTruthsTable(slices);
121  // and order them by purity
122  std::vector<int> sliceNuId = bt->SliceToOrderedNuIds(nus, slTruth,
125 
126 
127  // ---------- Loop Over Slices ----------
128  for ( unsigned int iSlice = 0; iSlice < slices.size(); ++iSlice ){
129 
130  // Simple example. Print number of cells in each slice.
131  const art::Ptr<rb::Cluster> slice = slices[iSlice];
132  unsigned int nCells = slice->NCell();
133 
134  mf::LogInfo("RecoValidationTutorial") << " Slice # " << iSlice
135  << " has " << nCells
136  << " cells." << std::endl;
137 
138  if ( slice->IsNoise() ) continue;
139 
140 
141  // ---------- Reco Vertex Info ----------
142 
143  // Always check the assns are ok
144  if( !fmVert.isValid() ) continue;
145 
146  const std::vector< art::Ptr<rb::Vertex> > vtx = fmVert.at(iSlice);
147  if ( vtx.size() != 1) continue;
148 
149  TVector3 vxyz = vtx[0]->GetXYZ();
150  mf::LogInfo("RecoValidationTutorial") << " It has Reco Vertex at "
151  << "( "<< vxyz.X()
152  << ", "<< vxyz.Y()
153  << ", "<< vxyz.Z()
154  << " ) " <<std::endl;
155 
156 
157  // ---------- True Vertex Info ----------
158 
159  // Check there are related nus
160  if ( sliceNuId[iSlice] == -1 ) return;
161 
162  // Get this slice's highest eff. neutrino
163  art::Ptr<simb::MCTruth> truth = slTruth[iSlice][sliceNuId[iSlice]].neutrinoInt;
164  simb::MCNeutrino thisNu = truth->GetNeutrino();
165 
166  //now get vertex info and make comparisons
167  fVertexX->Fill( vxyz.X() - thisNu.Nu().Vx() );
168  fVertexY->Fill( vxyz.Y() - thisNu.Nu().Vy() );
169  fVertexZ->Fill( vxyz.Z() - thisNu.Nu().Vz() );
170 
171  } //iSlice
172  }// analyze
unsigned int NCell(geo::View_t view) const
Number of cells in view view.
Definition: Cluster.cxx:134
const simb::MCNeutrino & GetNeutrino() const
Definition: MCTruth.h:76
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
const simb::MCParticle & Nu() const
Definition: MCNeutrino.h:146
std::vector< NeutrinoWithIndex > allMCTruth() const
art::ServiceHandle< cheat::BackTracker > bt
std::vector< std::vector< cheat::NeutrinoEffPur > > SlicesToMCTruthsTable(const std::vector< const rb::Cluster * > &sliceList) const
Given ALL the slices in an event, including the noise slice, returns a vector of vector of structures...
std::vector< int > SliceToOrderedNuIds(const std::vector< cheat::NeutrinoWithIndex > &nusWithIdx, const std::vector< std::vector< cheat::NeutrinoEffPur >> &slTruthTable, std::function< double(const cheat::NeutrinoEffPur &)> slMetric, std::function< double(const cheat::NeutrinoEffPur &)> nuMetric) const
Given a vector of indexed neutrino interaction and a vector of slice truth tables, returns a vector of neutrino interaction indices ordered by best match to the corresponding slice. Here, best match is determined according to the given cheat::NeutrinoEffPur functions for the slice and the nu.
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
std::string fClusterLabel
module label for clusters
size_type size() const
Definition: PtrVector.h:308
double Vx(const int i=0) const
Definition: MCParticle.h:220
std::string fVertexLabel
module label for vertices
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
double Vz(const int i=0) const
Definition: MCParticle.h:222
double EffMetric(const cheat::NeutrinoEffPur &ep)
Function for NeutrinoEffPur&#39;s nu interaction to slice efficiency.
bool IsNoise() const
Is the noise flag set?
Definition: Cluster.h:163
Event generator information.
Definition: MCNeutrino.h:18
double Vy(const int i=0) const
Definition: MCParticle.h:221
void tut::RecoValidationTutorial::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 87 of file RecoValidationTutorial_module.cc.

References fVertexX, fVertexY, fVertexZ, and art::TFileDirectory::make().

88  {
90  fVertexX = tfs->make<TH1F>("vertexXdiff", ";Reco - True Vertex X (cm)",80, -200, 200);
91  fVertexY = tfs->make<TH1F>("vertexYdiff", ";Reco - True Vertex Y (cm)",80, -200, 200);
92  fVertexZ = tfs->make<TH1F>("vertexZdiff", ";Reco - True Vertex Z (cm)",80, -200, 200);
93  }
T * make(ARGS...args) const
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited
base_engine_t& art::EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited
CurrentProcessingContext const* art::EDAnalyzer::currentContext ( ) const
protectedinherited
seed_t art::EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:35
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void tut::RecoValidationTutorial::reconfigure ( const fhicl::ParameterSet p)

Definition at line 80 of file RecoValidationTutorial_module.cc.

References fClusterLabel, fVertexLabel, fhicl::ParameterSet::get(), and string.

Referenced by RecoValidationTutorial().

81  {
82  fClusterLabel = pset.get<std::string>("ClusterLabel");
83  fVertexLabel = pset.get<std::string>("VertexLabel");
84  }
std::string fClusterLabel
module label for clusters
std::string fVertexLabel
module label for vertices
enum BeamMode string
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

References string.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited

Definition at line 46 of file EventObserverBase.h.

References art::EventObserverBase::wantAllEvents_.

Referenced by art::RootOutput::RootOutput().

47  {
48  return wantAllEvents_;
49  }
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited

Definition at line 51 of file EventObserverBase.h.

References art::EventObserverBase::selectors_, and art::detail::CachedProducts::wantEvent().

52  {
53  return selectors_.wantEvent(e);
54  }
detail::CachedProducts selectors_
Float_t e
Definition: plot.C:35
bool wantEvent(Event const &)
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

art::ServiceHandle<cheat::BackTracker> tut::RecoValidationTutorial::bt
protected

Definition at line 56 of file RecoValidationTutorial_module.cc.

Referenced by analyze().

std::string tut::RecoValidationTutorial::fCellHitLabel
protected

module label for CellHit

Definition at line 52 of file RecoValidationTutorial_module.cc.

std::string tut::RecoValidationTutorial::fClusterLabel
protected

module label for clusters

Definition at line 53 of file RecoValidationTutorial_module.cc.

Referenced by analyze(), and reconfigure().

std::string tut::RecoValidationTutorial::fVertexLabel
protected

module label for vertices

Definition at line 54 of file RecoValidationTutorial_module.cc.

Referenced by analyze(), and reconfigure().

TH1* tut::RecoValidationTutorial::fVertexX
protected

Definition at line 58 of file RecoValidationTutorial_module.cc.

Referenced by analyze(), and beginJob().

TH1* tut::RecoValidationTutorial::fVertexY
protected

Definition at line 59 of file RecoValidationTutorial_module.cc.

Referenced by analyze(), and beginJob().

TH1* tut::RecoValidationTutorial::fVertexZ
protected

Definition at line 60 of file RecoValidationTutorial_module.cc.

Referenced by analyze(), and beginJob().


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