LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
MergeSimSources_module.cc
Go to the documentation of this file.
1 // Class: MergeSimSources
3 // Module Type: producer
4 // File: MergeSimSources_module.cc
5 //
6 // Generated at Tue Feb 17 12:16:35 2015 by Wesley Ketchum using artmod
7 // from cetpkgsupport v1_08_02.
9 
17 #include "fhiclcpp/ParameterSet.h"
19 
24 
25 #include <memory>
26 
29 #include "MergeSimSources.h"
30 
31 namespace sim {
32  class MergeSimSources;
33 }
34 
36 public:
37  explicit MergeSimSources(fhicl::ParameterSet const & p);
38  // The destructor generated by the compiler is fine for classes
39  // without bare pointers or other resource use.
40 
41  // Plugins should not be copied or assigned.
42  MergeSimSources(MergeSimSources const &) = delete;
43  MergeSimSources(MergeSimSources &&) = delete;
44  MergeSimSources & operator = (MergeSimSources const &) = delete;
46 
47  // Required functions.
48  void produce(art::Event & e) override;
49 
50 private:
51 
52  std::vector<std::string> fInputSourcesLabels;
53  std::vector<int> fTrackIDOffsets;
55 
57 
58 };
59 
60 
62  : fInputSourcesLabels(p.get< std::vector<std::string> >("InputSourcesLabels"))
63  , fTrackIDOffsets(p.get< std::vector<int> >("TrackIDOffsets"))
65 {
66 
67  if(fInputSourcesLabels.size() != fTrackIDOffsets.size())
68  throw std::runtime_error("ERROR in MergeSimSources: Unequal input vector sizes.");
69 
72 
73  if(!fUseLitePhotons) produces< std::vector<sim::SimPhotons> >();
74  else produces< std::vector<sim::SimPhotonsLite> >();
75 
76  produces< std::vector<simb::MCParticle> >();
77  produces< std::vector<sim::SimChannel> >();
78  produces< std::vector<sim::AuxDetSimChannel> >();
79  produces< art::Assns<simb::MCTruth, simb::MCParticle> >();
80 }
81 
83 {
85 
86  std::unique_ptr< std::vector<simb::MCParticle> > partCol (new std::vector<simb::MCParticle >);
87  std::unique_ptr< std::vector<sim::SimChannel> > scCol (new std::vector<sim::SimChannel>);
88  std::unique_ptr< std::vector<sim::SimPhotons> > PhotonCol(new std::vector<sim::SimPhotons>);
89  std::unique_ptr< std::vector<sim::SimPhotonsLite> > LitePhotonCol(new std::vector<sim::SimPhotonsLite>);
90  std::unique_ptr< art::Assns<simb::MCTruth, simb::MCParticle> > tpassn(new art::Assns<simb::MCTruth, simb::MCParticle>);
91  std::unique_ptr< std::vector< sim::AuxDetSimChannel > > adCol (new std::vector<sim::AuxDetSimChannel> );
92 
94 
95  for(size_t i_source=0; i_source<fInputSourcesLabels.size(); i_source++){
96 
97  std::string const& input_label = fInputSourcesLabels[i_source];
98 
100  e.getByLabel(input_label,input_partCol);
101  std::vector<simb::MCParticle> const& input_partColVector(*input_partCol);
102  fMergeUtility.MergeMCParticles(*partCol,input_partColVector,i_source);
103 
104  const std::vector< std::vector<size_t> >& assocVectorPrimitive(fMergeUtility.GetMCParticleListMap());
105  art::FindOneP<simb::MCTruth> mctAssn(input_partCol,e,input_label);
106  for(size_t i_p=0; i_p<mctAssn.size(); i_p++)
107  util::CreateAssn(*this,e,
108  *(partCol.get()),mctAssn.at(i_p),*(tpassn.get()),
109  assocVectorPrimitive[i_source][i_p]);
110 
111 
113  e.getByLabel(input_label,input_scCol);
114  fMergeUtility.MergeSimChannels(*scCol,*input_scCol,i_source);
115 
117  e.getByLabel(input_label,input_adCol);
118  fMergeUtility.MergeAuxDetSimChannels(*adCol,*input_adCol,i_source);
119 
120  if(!fUseLitePhotons){
122  e.getByLabel(input_label,input_PhotonCol);
123  fMergeUtility.MergeSimPhotons(*PhotonCol,*input_PhotonCol);
124  }
125  else{
126  art::Handle< std::vector<sim::SimPhotonsLite> > input_LitePhotonCol;
127  e.getByLabel(input_label,input_LitePhotonCol);
128  fMergeUtility.MergeSimPhotonsLite(*LitePhotonCol,*input_LitePhotonCol);
129  }
130 
131  //truth-->particle assoc stuff here
132 
133  }
134 
135  e.put(std::move(partCol));
136  e.put(std::move(scCol));
137  e.put(std::move(adCol));
138  if(!fUseLitePhotons) e.put(std::move(PhotonCol));
139  else e.put(std::move(LitePhotonCol));
140  e.put(std::move(tpassn));
141 
142 }
143 
Store parameters for running LArG4.
void MergeSimPhotonsLite(std::vector< sim::SimPhotonsLite > &, const std::vector< sim::SimPhotonsLite > &)
void MergeSimChannels(std::vector< sim::SimChannel > &, const std::vector< sim::SimChannel > &, size_t)
void MergeSimPhotons(std::vector< sim::SimPhotons > &, const std::vector< sim::SimPhotons > &)
MergeSimSources & operator=(MergeSimSources const &)=delete
STL namespace.
void MergeAuxDetSimChannels(std::vector< sim::AuxDetSimChannel > &, const std::vector< sim::AuxDetSimChannel > &, size_t)
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
const std::vector< std::vector< size_t > > & GetMCParticleListMap()
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:42
MergeSimSources(fhicl::ParameterSet const &p)
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.
Monte Carlo Simulation.
void produce(art::Event &e) override
void MergeMCParticles(std::vector< simb::MCParticle > &, const std::vector< simb::MCParticle > &, size_t)
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
std::vector< int > fTrackIDOffsets
Float_t e
Definition: plot.C:34
bool UseLitePhotons() const
std::vector< std::string > fInputSourcesLabels
MergeSimSourcesUtility fMergeUtility