Public Member Functions | Private Member Functions | Private Attributes | List of all members
event::EventCheater Class Reference
Inheritance diagram for event::EventCheater:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 EventCheater (fhicl::ParameterSet const &pset)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &evt)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 33 of file EventCheater_module.cc.

Constructor & Destructor Documentation

event::EventCheater::EventCheater ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 50 of file EventCheater_module.cc.

51  : EDProducer{pset}
52  {
53  fCheatedVertexLabel = pset.get< std::string >("CheatedVertexLabel", "prong" );
54  fG4ModuleLabel = pset.get< std::string >("G4ModuleLabel", "largeant");
55 
56  produces< std::vector<recob::Event> >();
57  produces< art::Assns<recob::Event, recob::Vertex> >();
58  produces< art::Assns<recob::Event, recob::Hit> >();
59  }
std::string fCheatedVertexLabel
label for module creating recob::Vertex objects
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
std::string fG4ModuleLabel
label for module running G4 and making particles, etc

Member Function Documentation

void event::EventCheater::produce ( art::Event evt)
privatevirtual

Implements art::EDProducer.

Definition at line 62 of file EventCheater_module.cc.

63  {
64 
66  evt.getView(fG4ModuleLabel, pcol);
67 
68  art::FindOneP<simb::MCTruth> fo(pcol, evt, fG4ModuleLabel);
69 
70  // make a map of the track id for each sim::Particle to its entry in the
71  // collection of sim::Particles
72  std::map<int, int> trackIDToPColEntry;
73  for(size_t p = 0; p < pcol.vals().size(); ++p) trackIDToPColEntry[pcol.vals().at(p)->TrackId()] = p;
74 
75  // grab the vertices that have been reconstructed
77  evt.getByLabel(fCheatedVertexLabel, vertexcol);
78 
79  art::FindManyP<recob::Hit> fm(vertexcol, evt, fCheatedVertexLabel);
80 
81  // make a vector of them - we aren't writing anything out to a file
82  // so no need for a art::PtrVector here
83  std::vector< art::Ptr<recob::Vertex> > vertices;
84  art::fill_ptr_vector(vertices, vertexcol);
85 
86  // loop over the vertices and figure out which primaries they are associated with
87  std::vector< art::Ptr<recob::Vertex> >::iterator vertexitr = vertices.begin();
88 
89  // make a map of primary product id's to collections of vertices
90  std::map<art::Ptr<simb::MCTruth>, std::vector< art::Ptr<recob::Vertex> > > vertexMap;
91  std::map<art::Ptr<simb::MCTruth>, std::vector< art::Ptr<recob::Vertex> > >::iterator vertexMapItr = vertexMap.begin();
92 
93  // loop over all prongs
94  while( vertexitr != vertices.end() ){
95 
96  size_t pcolEntry = trackIDToPColEntry.find((*vertexitr)->ID())->second;
97  const art::Ptr<simb::MCTruth> primary = fo.at(pcolEntry);
98 
99  vertexMap[primary].push_back(*vertexitr);
100 
101  vertexitr++;
102  }// end loop over vertices
103 
104  std::unique_ptr< std::vector<recob::Event> > eventcol(new std::vector<recob::Event>);
105  std::unique_ptr< art::Assns<recob::Event, recob::Vertex> > evassn(new art::Assns<recob::Event, recob::Vertex>);
106  std::unique_ptr< art::Assns<recob::Event, recob::Hit> > ehassn(new art::Assns<recob::Event, recob::Hit>);
107 
108  // loop over the map and associate all vertex objects with an event
109  for(vertexMapItr = vertexMap.begin(); vertexMapItr != vertexMap.end(); vertexMapItr++){
110 
112 
113  std::vector< art::Ptr<recob::Vertex> > verts( (*vertexMapItr).second );
114 
115  // add an event to the collection.
116  eventcol->push_back(recob::Event(eventcol->size()-1));
117 
118  // associate the event with its vertices
119  util::CreateAssn(*this, evt, *eventcol, verts, *evassn);
120 
121  // get the hits associated with each vertex and associate those with the event
122  for(size_t p = 0; p < ptrvs.size(); ++p){
123  std::vector< art::Ptr<recob::Hit> > hits = fm.at(p);
124  util::CreateAssn(*this, evt, *eventcol, hits, *ehassn);
125  }
126 
127 
128  mf::LogInfo("EventCheater") << "adding event: \n"
129  << eventcol->back()
130  << "\nto collection";
131 
132  } // end loop over the map
133 
134  evt.put(std::move(eventcol));
135  evt.put(std::move(evassn));
136  evt.put(std::move(ehassn));
137 
138  return;
139 
140  } // end produce
std::string fCheatedVertexLabel
label for module creating recob::Vertex objects
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
auto & vals() noexcept
Definition: View.h:68
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
std::string fG4ModuleLabel
label for module running G4 and making particles, etc
def move(depos, offset)
Definition: depos.py:107
p
Definition: test.py:223
Definition: fwd.h:46
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
size_type size() const
Definition: PtrVector.h:302
static constexpr double fm
Definition: Units.h:75
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:500
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85

Member Data Documentation

std::string event::EventCheater::fCheatedVertexLabel
private

label for module creating recob::Vertex objects

Definition at line 41 of file EventCheater_module.cc.

std::string event::EventCheater::fG4ModuleLabel
private

label for module running G4 and making particles, etc

Definition at line 42 of file EventCheater_module.cc.


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