Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | List of all members
cheat::ClusterCheater Class Reference
Inheritance diagram for cheat::ClusterCheater:
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

 ClusterCheater (fhicl::ParameterSet const &pset)
 
virtual ~ClusterCheater ()
 
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 fHitModuleLabel
 label for module creating rb::CellHit objects More...
 
std::string fG4ModuleLabel
 label for module running G4 and making particles, etc More...
 

Detailed Description

Definition at line 30 of file ClusterCheater_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::ClusterCheater::ClusterCheater ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 50 of file ClusterCheater_module.cc.

References reconfigure().

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

Definition at line 59 of file ClusterCheater_module.cc.

60  {
61  }

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::ClusterCheater::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 73 of file ClusterCheater_module.cc.

References std::abs(), util::CreateAssn(), DEFINE_ART_MODULE(), e, sim::ParticleNavigator::end(), fHitModuleLabel, art::fill_ptr_vector(), sim::ParticleNavigator::find(), art::DataViewImpl::getByLabel(), make_syst_table_plots::h, hits(), cheat::BackTracker::HitToTrackIDE(), geo::kX, geo::kY, LOG_DEBUG, LOG_WARNING, cheat::BackTracker::ParticleNavigator(), art::PtrVector< T >::push_back(), art::Event::put(), and art::PtrVector< T >::size().

74  {
75  // get a back tracker
77 
78  const sim::ParticleNavigator& pnav = bt->ParticleNavigator();
79 
80  // grab the hits that have been reconstructed
82  evt.getByLabel(fHitModuleLabel, hitcol);
83 
84  // make a vector of them
85  std::vector< art::Ptr<rb::CellHit> > hits;
86  art::fill_ptr_vector(hits, hitcol);
87 
88  // loop over the hits and figure out which particle contributed to each one
89  // make a map of vectors of art::Ptrs keyed by trackID values
90  std::map< int, std::vector< art::Ptr<rb::CellHit> > > trackHitMap;
91 
92  // loop over all hits and fill in the map
93  for(auto itr : hits ){
94 
95  std::vector<cheat::TrackIDE> trackides = bt->HitToTrackIDE(itr);
96 
97  // loop over all trackides for this hit
98  for(auto const& e : trackides){
99 
100  // don't worry about eve particles that contribute less than 10% of the
101  // energy in the current hit
102  if( e.energyFrac < 0.1) continue;
103 
104  trackHitMap[e.trackID].push_back(itr);
105 
106  } // end loop over eve IDs for this hit
107  }// end loop over hits
108 
109  // loop over the map and make clusters
110  std::unique_ptr< std::vector<rb::Cluster> > clustercol(new std::vector<rb::Cluster>);
111  std::unique_ptr< art::Assns<rb::Cluster, rb::CellHit> > assn(new art::Assns<rb::Cluster, rb::CellHit>);
112 
113  for(auto hitMapItr : trackHitMap){
114 
115  // separate out the hits for each particle into the different views
116  std::vector< art::Ptr<rb::CellHit> > trackHits( hitMapItr.second );
117 
120 
121  for(auto h : trackHits){
122 
123  if(h->View() == geo::kX) ptrvsX.push_back(h);
124  if(h->View() == geo::kY) ptrvsY.push_back(h);
125 
126  } // end loop over hits for this particle
127 
128  // check to see if the particle id for this cluster lives in the
129  // ParticleNavigator, if not, don't make a cluster and spew a warning
130  if( pnav.find(hitMapItr.first) == pnav.end() ){
131  mf::LogWarning("ClusterCheater") << " no particle in ParticleNavigator has track id "
132  << hitMapItr.first
133  << " this could be a problem. Certainly won't make a"
134  << " Cluster for it.";
135  continue;
136  }
137 
138  if( std::abs(pnav[hitMapItr.first]->PdgCode()) != 11 &&
139  std::abs(pnav[hitMapItr.first]->PdgCode()) != 22 &&
140  std::abs(pnav[hitMapItr.first]->PdgCode()) != 111 )
141  if(ptrvsX.size() < 1 || ptrvsY.size() < 1)
142  LOG_WARNING("ClusterCheater") << "no cluster in a view, " << ptrvsX.size()
143  << ", " << ptrvsY.size() << " for particle\n"
144  << *(pnav[hitMapItr.first]);
145 
146  if(ptrvsX.size() > 0 ){
147  clustercol->push_back(rb::Cluster(geo::kX,
148  ptrvsX,
149  (hitMapItr.first * 1000) + geo::kX*10));
150  // associate the hits to this cluster
151  util::CreateAssn(*this, evt, *clustercol, ptrvsX, *assn);
152  }
153 
154  LOG_DEBUG("ClusterCheater") << "adding cluster: \n"
155  << clustercol->back()
156  << "\nto collection.";
157 
158  if(ptrvsY.size() > 0){
159  clustercol->push_back(rb::Cluster(geo::kY,
160  ptrvsY,
161  (hitMapItr.first * 1000) + geo::kY*10));
162  // associate the hits to this cluster
163  util::CreateAssn(*this, evt, *clustercol, ptrvsY, *assn);
164  }
165 
166  LOG_DEBUG("ClusterCheater") << "adding cluster: \n"
167  << clustercol->back()
168  << "\nto collection.";
169 
170  } // end loop over the map
171 
172  evt.put(std::move(clustercol));
173  evt.put(std::move(assn));
174 
175  return;
176 
177  } // 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.
std::vector< TrackIDE > HitToTrackIDE(const rb::CellHit &hit, bool useBirksE=false) const
Convenience function. HitsToTrackIDE but for a single hit.
const sim::ParticleNavigator & ParticleNavigator() const
Get a reference to the ParticleNavigator.
Definition: BackTracker.h:744
Vertical planes which measure X.
Definition: PlaneGeo.h:28
A collection of associated CellHits.
Definition: Cluster.h:47
std::string fHitModuleLabel
label for module creating rb::CellHit objects
float abs(float number)
Definition: d0nt_math.hpp:39
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
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
size_type size() const
Definition: PtrVector.h:308
#define LOG_WARNING(category)
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:464
Float_t e
Definition: plot.C:35
iterator find(const key_type &key)
void cheat::ClusterCheater::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 64 of file ClusterCheater_module.cc.

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

Referenced by ClusterCheater().

65  {
66  fHitModuleLabel = pset.get< std::string >("HitModuleLabel", "calhit" );
67  fG4ModuleLabel = pset.get< std::string >("G4ModuleLabel", "geantgen");
68 
69  return;
70  }
std::string fG4ModuleLabel
label for module running G4 and making particles, etc
std::string fHitModuleLabel
label for module creating rb::CellHit 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::ClusterCheater::fG4ModuleLabel
private

label for module running G4 and making particles, etc

Definition at line 42 of file ClusterCheater_module.cc.

Referenced by reconfigure().

std::string cheat::ClusterCheater::fHitModuleLabel
private

label for module creating rb::CellHit objects

Definition at line 41 of file ClusterCheater_module.cc.

Referenced by produce(), and reconfigure().


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