LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
sim::MergeSimSourcesUtility Class Reference

#include "MergeSimSources.h"

Public Member Functions

 MergeSimSourcesUtility (std::vector< int > const &)
 
void Reset ()
 
void MergeMCParticles (std::vector< simb::MCParticle > &, const std::vector< simb::MCParticle > &, size_t)
 
void MergeSimChannels (std::vector< sim::SimChannel > &, const std::vector< sim::SimChannel > &, size_t)
 
void MergeAuxDetSimChannels (std::vector< sim::AuxDetSimChannel > &, const std::vector< sim::AuxDetSimChannel > &, size_t)
 
void MergeSimPhotons (std::vector< sim::SimPhotons > &, const std::vector< sim::SimPhotons > &)
 
void MergeSimPhotonsLite (std::vector< sim::SimPhotonsLite > &, const std::vector< sim::SimPhotonsLite > &)
 
const std::vector< std::vector< size_t > > & GetMCParticleListMap ()
 

Private Member Functions

void UpdateG4TrackIDRange (std::pair< int, int >, size_t)
 

Private Attributes

std::vector< int > fG4TrackIDOffsets
 
std::vector< std::pair< int, int > > fG4TrackIDRanges
 
std::vector< std::vector< size_t > > fMCParticleListMap
 

Detailed Description

Definition at line 23 of file MergeSimSources.h.

Constructor & Destructor Documentation

sim::MergeSimSourcesUtility::MergeSimSourcesUtility ( std::vector< int > const &  )

Title: MergeSimSources Utility Class Author: Wes Ketchum (wketc.nosp@m.hum@.nosp@m.lanl..nosp@m.gov)

Description: Class that merges different simulation sources together to created a combined sim list. Typically just merges vectors/maps/etc together. But, if anything as a G4 trackID, applies a user-defined offset to those IDs.

Definition at line 18 of file MergeSimSources.cxx.

References fG4TrackIDOffsets, and Reset().

19 {
20  fG4TrackIDOffsets = offsets;
21  Reset();
22 }
std::vector< int > fG4TrackIDOffsets

Member Function Documentation

const std::vector< std::vector<size_t> >& sim::MergeSimSourcesUtility::GetMCParticleListMap ( )
inline

Definition at line 49 of file MergeSimSources.h.

References fMCParticleListMap.

Referenced by sim::MergeSimSources::produce().

49 { return fMCParticleListMap; }
std::vector< std::vector< size_t > > fMCParticleListMap
void sim::MergeSimSourcesUtility::MergeAuxDetSimChannels ( std::vector< sim::AuxDetSimChannel > &  merged_vector,
const std::vector< sim::AuxDetSimChannel > &  input_vector,
size_t  source_index 
)

Definition at line 90 of file MergeSimSources.cxx.

References fG4TrackIDOffsets, max, min, and UpdateG4TrackIDRange().

Referenced by sim::MergeSimSources::produce().

93 {
94  if(source_index >= fG4TrackIDOffsets.size())
95  std::runtime_error("ERROR in MergeSimSourcesUtility: Source index out of range!");
96 
97  merged_vector.reserve( merged_vector.size() + input_vector.size() );
98 
99  std::pair<int,int> range_trackID(std::numeric_limits<int>::max(),
101 
102  for(auto const& simchannel : input_vector){
103  std::vector<sim::AuxDetSimChannel>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simchannel);
104 
105  if(it==merged_vector.end()){
106  merged_vector.emplace_back(simchannel.AuxDetID(), simchannel.AuxDetSensitiveID());
107  it = merged_vector.end() - 1;
108  }
109 
110  std::pair<int,int> thisrange = it->MergeAuxDetSimChannel(simchannel,fG4TrackIDOffsets[source_index]);
111  if(thisrange.first < range_trackID.first) range_trackID.first = thisrange.first;
112  if(thisrange.second > range_trackID.second) range_trackID.second = thisrange.second;
113  }
114 
115  UpdateG4TrackIDRange(range_trackID,source_index);
116 }
void UpdateG4TrackIDRange(std::pair< int, int >, size_t)
intermediate_table::iterator iterator
Int_t max
Definition: plot.C:27
std::vector< int > fG4TrackIDOffsets
Int_t min
Definition: plot.C:26
void sim::MergeSimSourcesUtility::MergeMCParticles ( std::vector< simb::MCParticle > &  merged_vector,
const std::vector< simb::MCParticle > &  input_vector,
size_t  source_index 
)

Definition at line 33 of file MergeSimSources.cxx.

References fG4TrackIDOffsets, fMCParticleListMap, max, min, and UpdateG4TrackIDRange().

Referenced by sim::MergeSimSources::produce().

36 {
37 
38  if(source_index >= fG4TrackIDOffsets.size())
39  std::runtime_error("ERROR in MergeSimSourcesUtility: Source index out of range!");
40 
41  fMCParticleListMap[source_index].resize(input_vector.size());
42  merged_vector.reserve(merged_vector.size() + input_vector.size());
43 
44  std::pair<int,int> range_trackID(std::numeric_limits<int>::max(),
46 
47  for(size_t i_p=0; i_p<input_vector.size(); i_p++){
48  merged_vector.emplace_back(input_vector[i_p],fG4TrackIDOffsets[source_index]);
49 
50  fMCParticleListMap[source_index][i_p] = merged_vector.size() - 1;
51 
52  if(merged_vector.back().TrackId() < range_trackID.first)
53  range_trackID.first = merged_vector.back().TrackId();
54  if(merged_vector.back().TrackId() > range_trackID.second)
55  range_trackID.second = merged_vector.back().TrackId();
56 
57  }
58 
59  UpdateG4TrackIDRange(range_trackID,source_index);
60 }
void UpdateG4TrackIDRange(std::pair< int, int >, size_t)
Int_t max
Definition: plot.C:27
std::vector< int > fG4TrackIDOffsets
Int_t min
Definition: plot.C:26
std::vector< std::vector< size_t > > fMCParticleListMap
void sim::MergeSimSourcesUtility::MergeSimChannels ( std::vector< sim::SimChannel > &  merged_vector,
const std::vector< sim::SimChannel > &  input_vector,
size_t  source_index 
)

Definition at line 62 of file MergeSimSources.cxx.

References fG4TrackIDOffsets, max, min, and UpdateG4TrackIDRange().

Referenced by sim::MergeSimSources::produce().

65 {
66  if(source_index >= fG4TrackIDOffsets.size())
67  std::runtime_error("ERROR in MergeSimSourcesUtility: Source index out of range!");
68 
69  merged_vector.reserve( merged_vector.size() + input_vector.size() );
70 
71  std::pair<int,int> range_trackID(std::numeric_limits<int>::max(),
73 
74  for(auto const& simchannel : input_vector){
75  std::vector<sim::SimChannel>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simchannel);
76 
77  if(it==merged_vector.end()){
78  merged_vector.emplace_back(simchannel.Channel());
79  it = merged_vector.end() - 1;
80  }
81 
82  std::pair<int,int> thisrange = it->MergeSimChannel(simchannel,fG4TrackIDOffsets[source_index]);
83  if(thisrange.first < range_trackID.first) range_trackID.first = thisrange.first;
84  if(thisrange.second > range_trackID.second) range_trackID.second = thisrange.second;
85  }
86 
87  UpdateG4TrackIDRange(range_trackID,source_index);
88 }
void UpdateG4TrackIDRange(std::pair< int, int >, size_t)
intermediate_table::iterator iterator
Int_t max
Definition: plot.C:27
std::vector< int > fG4TrackIDOffsets
Int_t min
Definition: plot.C:26
void sim::MergeSimSourcesUtility::MergeSimPhotons ( std::vector< sim::SimPhotons > &  merged_vector,
const std::vector< sim::SimPhotons > &  input_vector 
)

Definition at line 118 of file MergeSimSources.cxx.

Referenced by sim::MergeSimSources::produce().

120 {
121 
122  merged_vector.reserve( merged_vector.size() + input_vector.size() );
123 
124  for(auto const& simphotons : input_vector){
125  std::vector<sim::SimPhotons>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simphotons);
126 
127  if(it==merged_vector.end()){
128  merged_vector.emplace_back(simphotons.OpChannel());
129  it = merged_vector.end() - 1;
130  }
131 
132  *it += simphotons;
133  }
134 }
intermediate_table::iterator iterator
void sim::MergeSimSourcesUtility::MergeSimPhotonsLite ( std::vector< sim::SimPhotonsLite > &  merged_vector,
const std::vector< sim::SimPhotonsLite > &  input_vector 
)

Definition at line 136 of file MergeSimSources.cxx.

Referenced by sim::MergeSimSources::produce().

138 {
139 
140  merged_vector.reserve( merged_vector.size() + input_vector.size() );
141 
142  for(auto const& simphotons : input_vector){
143  std::vector<sim::SimPhotonsLite>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simphotons);
144 
145  if(it==merged_vector.end()){
146  merged_vector.emplace_back(simphotons.OpChannel);
147  it = merged_vector.end() - 1;
148  }
149 
150  *it += simphotons;
151  }
152 }
intermediate_table::iterator iterator
void sim::MergeSimSourcesUtility::Reset ( )

Definition at line 24 of file MergeSimSources.cxx.

References fG4TrackIDOffsets, fG4TrackIDRanges, fMCParticleListMap, max, and min.

Referenced by MergeSimSourcesUtility(), and sim::MergeSimSources::produce().

25 {
26  fG4TrackIDRanges.resize(fG4TrackIDOffsets.size(),
27  std::make_pair(std::numeric_limits<int>::max(),
30  std::vector<size_t>());
31 }
Int_t max
Definition: plot.C:27
std::vector< int > fG4TrackIDOffsets
std::vector< std::pair< int, int > > fG4TrackIDRanges
Int_t min
Definition: plot.C:26
std::vector< std::vector< size_t > > fMCParticleListMap
void sim::MergeSimSourcesUtility::UpdateG4TrackIDRange ( std::pair< int, int >  newrange,
size_t  source_index 
)
private

Definition at line 154 of file MergeSimSources.cxx.

References fG4TrackIDOffsets, fG4TrackIDRanges, and ss.

Referenced by MergeAuxDetSimChannels(), MergeMCParticles(), and MergeSimChannels().

155 {
156  if(source_index >= fG4TrackIDOffsets.size())
157  std::runtime_error("ERROR in MergeSimSourcesUtility: Source index out of range!");
158 
159  if( newrange.first >= fG4TrackIDRanges[source_index].first &&
160  newrange.second <= fG4TrackIDRanges[source_index].second)
161  return;
162 
163  for(size_t i=0; i<fG4TrackIDRanges.size(); i++){
164  if(i==source_index) continue;
165 
166  if( (newrange.first >= fG4TrackIDRanges[i].first && newrange.first <= fG4TrackIDRanges[i].second) ||
167  (newrange.second >= fG4TrackIDRanges[i].first && newrange.second <= fG4TrackIDRanges[i].second) )
168  {
169  std::stringstream ss;
170  ss << "ERROR in MergeSimSourcesUtility: Source trackIDs overlap!"
171  << "\n\t" << i << "\t" << fG4TrackIDRanges[i].first << " " << fG4TrackIDRanges[i].second
172  << "\n\t" << "n\t" << newrange.first << " " << newrange.second;
173  throw std::runtime_error(ss.str());
174  }
175  }
176 
177  if(newrange.first < fG4TrackIDRanges[source_index].first)
178  fG4TrackIDRanges[source_index].first = newrange.first;
179  if(newrange.second > fG4TrackIDRanges[source_index].second)
180  fG4TrackIDRanges[source_index].second = newrange.second;
181 
182 
183 }
Float_t ss
Definition: plot.C:23
std::vector< int > fG4TrackIDOffsets
std::vector< std::pair< int, int > > fG4TrackIDRanges

Member Data Documentation

std::vector<int> sim::MergeSimSourcesUtility::fG4TrackIDOffsets
private
std::vector< std::pair<int,int> > sim::MergeSimSourcesUtility::fG4TrackIDRanges
private

Definition at line 54 of file MergeSimSources.h.

Referenced by Reset(), and UpdateG4TrackIDRange().

std::vector< std::vector<size_t> > sim::MergeSimSourcesUtility::fMCParticleListMap
private

Definition at line 56 of file MergeSimSources.h.

Referenced by GetMCParticleListMap(), MergeMCParticles(), and Reset().


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