Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
cheat::TrackCheater Class Reference
Inheritance diagram for cheat::TrackCheater:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 TrackCheater (fhicl::ParameterSet const &pset)
 
virtual ~TrackCheater ()
 
void produce (art::Event &evt)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () 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
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Attributes

std::string fCheatedClusterLabel
 label for module creating recob::Cluster objects More...
 
std::string fG4ModuleLabel
 label for module running G4 and making particles, etc More...
 

Detailed Description

Definition at line 32 of file TrackCheater_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

cheat::TrackCheater::TrackCheater ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 52 of file TrackCheater_module.cc.

References reconfigure().

53  {
54  this->reconfigure(pset);
55 
56  produces< std::vector<rb::Track> >();
57  produces< art::Assns<rb::Track, rb::CellHit> >();
58  produces< art::Assns<rb::Track, rb::Cluster> >();
59  }
void reconfigure(fhicl::ParameterSet const &pset)
cheat::TrackCheater::~TrackCheater ( )
virtual

Definition at line 62 of file TrackCheater_module.cc.

63  {
64  }

Member Function Documentation

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::EDProducer::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
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

Referenced by skim::NueSkimmer::CopyMichelSlice(), and skim::NueSkimmer::CopyMichelTrack().

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
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::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID(), and string.

41  {
42  return true;
43  }
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
void cheat::TrackCheater::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 76 of file TrackCheater_module.cc.

References std::abs(), plot_validation_datamc::c, util::CreateAssn(), DEFINE_ART_MODULE(), geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), geo::GeometryBase::DetLength(), dir, fCheatedClusterLabel, art::fill_ptr_vector(), stan::math::floor(), art::PtrVector< T >::front(), art::DataViewImpl::getByLabel(), make_syst_table_plots::h, hits(), compare_h5_caf::idx, LOG_DEBUG, LOG_WARNING, cheat::BackTracker::ParticleNavigator(), art::PtrVector< T >::push_back(), art::Event::put(), and confusionMatrixTree::t.

77  {
80  const sim::ParticleNavigator& pnav = bt->ParticleNavigator();
81 
82  // grab the clusters that have been reconstructed
84  evt.getByLabel(fCheatedClusterLabel, clustercol);
85 
86  // make a vector of them - we aren't writing anything out to a file
87  // so no need for a art::PtrVector here
88  std::vector< art::Ptr<rb::Cluster> > clusters;
89  art::fill_ptr_vector(clusters, clustercol);
90 
91  // get the hits associated with each cluster and associate those with the track
93 
94  // make a map of vectors of art::Ptrs keyed by trackID values
95  std::map< int, std::vector< art::Ptr<rb::Cluster> > > tidClusterMap;
96  std::map< int, std::vector< size_t > > tidClusterIdxMap;
97 
98  // loop over all clusters and fill in the map
99  size_t idx = 0;
100  for(auto const& itr : clusters){
101 
102  // in the ClusterCheater module we set the cluster ID to be
103  // the particle track ID*1000 + view*10. The
104  // floor function on the cluster ID / 1000 will give us
105  // the track ID
106  int tID = floor(itr->ID()/1000.);
107 
108  tidClusterMap[tID].push_back(itr);
109  tidClusterIdxMap[tID].push_back(idx);
110 
111  ++idx;
112  }// end loop over clusters
113 
114 
115  // loop over the map and make prongs
116  std::unique_ptr< std::vector<rb::Track> > trackcol(new std::vector<rb::Track>);
117  std::unique_ptr< art::Assns<rb::Track, rb::CellHit> > assnHit(new art::Assns<rb::Track, rb::CellHit>);
118  std::unique_ptr< art::Assns<rb::Track, rb::Cluster> > assnCluster(new art::Assns<rb::Track, rb::Cluster>);
119 
120  for(auto clusterMapItr : tidClusterMap){
121 
122  // is this prong electro-magnetic in nature or
123  // hadronic/muonic? EM --> shower, everything else is a track
124  if( std::abs(pnav[clusterMapItr.first]->PdgCode()) != 11 &&
125  std::abs(pnav[clusterMapItr.first]->PdgCode()) != 22 &&
126  std::abs(pnav[clusterMapItr.first]->PdgCode()) != 111 ){
127 
128  LOG_DEBUG("TrackCheater") << "prong of " << clusterMapItr.first
129  << " is a track with pdg code "
130  << pnav[clusterMapItr.first]->PdgCode();
131 
132  // separate out the hits for each particle into the different views
133  std::vector< art::Ptr<rb::Cluster> > tidClusters( clusterMapItr.second );
134  std::vector< size_t> tidClusterIdx( tidClusterIdxMap.find(clusterMapItr.first)->second );
135 
136  if(tidClusters.size() != 2)
137  LOG_WARNING("TrackCheater") << "attempting to make a track with a number of "
138  << "clusters other than 2: " << tidClusters.size()
139  << " true particle is \n"
140  << *(pnav[clusterMapItr.first]);
141 
142  // get the hits from the different clusters
144  for(size_t c = 0; c < tidClusters.size(); ++c){
145  for(size_t h = 0; h < tidClusters[c]->NCell(); ++h)
146  ptrvs.push_back(tidClusters[c]->Cell(h));
147  }
148 
149  // get the initial position and direction of the particle
150  std::vector<TVector3> trajPoints;
151  // need the trajectory points for this track - get them using
152  // the MCParticle
153  unsigned int numTraj = pnav[clusterMapItr.first]->NumberTrajectoryPoints();
154  for(unsigned int t = 1; t < numTraj; ++t){
155  if(std::abs(pnav[clusterMapItr.first]->Vx(t)) < geo->DetHalfWidth() &&
156  std::abs(pnav[clusterMapItr.first]->Vy(t)) < geo->DetHalfHeight() &&
157  pnav[clusterMapItr.first]->Vz(t) > 0 && pnav[clusterMapItr.first]->Vz(t) < geo->DetLength()){
158  trajPoints.push_back(TVector3(pnav[clusterMapItr.first]->Vx(t),
159  pnav[clusterMapItr.first]->Vy(t),
160  pnav[clusterMapItr.first]->Vz(t)));
161  }
162  }// end loop over trajectory points
163 
164  TVector3 dir(pnav[clusterMapItr.first]->Px()/pnav[clusterMapItr.first]->P(),
165  pnav[clusterMapItr.first]->Py()/pnav[clusterMapItr.first]->P(),
166  pnav[clusterMapItr.first]->Pz()/pnav[clusterMapItr.first]->P());
167 
168  // add a prong to the collection. Make the prong
169  // ID be the same as the track ID for the eve particle
170  trackcol->push_back(rb::Track(ptrvs, trajPoints.front(), dir, clusterMapItr.first));
171 
172  for(auto const& traj : trajPoints) trackcol->back().AppendTrajectoryPoint(traj);
173 
174  for(size_t c = 0; c < tidClusterIdx.size(); ++c){
175  std::vector< art::Ptr<rb::CellHit> > hits = fmh.at(tidClusterIdx[c]);
176  util::CreateAssn(*this, evt, *trackcol, hits, *assnHit);
177  util::CreateAssn(*this, evt, *trackcol, tidClusters[c], *assnCluster);
178  }
179 
180  LOG_DEBUG("TrackCheater") << "adding track: \n"
181  << trackcol->back()
182  << "\nto collection.";
183 
184  }//end if this is a track
185 
186  } // end loop over the map
187 
188  evt.put(std::move(trackcol));
189  evt.put(std::move(assnHit));
190  evt.put(std::move(assnCluster));
191 
192  return;
193 
194  } // end produce
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
static bool CreateAssn(art::EDProducer const &prod, art::Event &evt, std::vector< T > &a, art::Ptr< U > b, art::Assns< T, U > &assn, size_t indx=UINT_MAX, std::string const &instance=std::string())
Create a 1 to 1 association between a new product and one already in the event.
const sim::ParticleNavigator & ParticleNavigator() const
Get a reference to the ParticleNavigator.
Definition: BackTracker.h:744
double DetLength() const
A rb::Prong with full reconstructed trajectory.
Definition: Track.h:20
float abs(float number)
Definition: d0nt_math.hpp:39
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
void hits()
Definition: readHits.C:15
void push_back(Ptr< U > const &p)
Definition: PtrVector.h:441
double DetHalfHeight() const
#define LOG_WARNING(category)
reference front()
Definition: PtrVector.h:379
double DetHalfWidth() const
TDirectory * dir
Definition: macro.C:5
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
fvar< T > floor(const fvar< T > &x)
Definition: floor.hpp:11
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Helper for AttenCurve.
Definition: Path.h:10
std::string fCheatedClusterLabel
label for module creating recob::Cluster objects
void cheat::TrackCheater::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 67 of file TrackCheater_module.cc.

References fCheatedClusterLabel, fG4ModuleLabel, fhicl::ParameterSet::get(), and string.

Referenced by TrackCheater().

68  {
69  fCheatedClusterLabel = pset.get< std::string >("CheatedClusterLabel", "cluster" );
70  fG4ModuleLabel = pset.get< std::string >("G4ModuleLabel", "geantgen");
71 
72  return;
73  }
std::string fG4ModuleLabel
label for module running G4 and making particles, etc
std::string fCheatedClusterLabel
label for module creating recob::Cluster objects
enum BeamMode string
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

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

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Member Data Documentation

std::string cheat::TrackCheater::fCheatedClusterLabel
private

label for module creating recob::Cluster objects

Definition at line 43 of file TrackCheater_module.cc.

Referenced by produce(), and reconfigure().

std::string cheat::TrackCheater::fG4ModuleLabel
private

label for module running G4 and making particles, etc

Definition at line 44 of file TrackCheater_module.cc.

Referenced by reconfigure().


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