19 : fG4TrackIDOffsets(offsets)
26 fG4TrackIDRanges.clear();
27 fG4TrackIDRanges.resize(fG4TrackIDOffsets.size(),
28 std::make_pair(std::numeric_limits<int>::max(),
29 std::numeric_limits<int>::min()));
30 fMCParticleListMap.clear();
31 fMCParticleListMap.resize(fG4TrackIDOffsets.size(),
32 std::vector<size_t>());
36 const std::vector<simb::MCParticle>& input_vector,
40 if(source_index >= fG4TrackIDOffsets.size())
41 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
43 fMCParticleListMap[source_index].resize(input_vector.size());
44 merged_vector.reserve(merged_vector.size() + input_vector.size());
46 std::pair<int,int> range_trackID(std::numeric_limits<int>::max(),
47 std::numeric_limits<int>::min());
49 for(
size_t i_p=0; i_p<input_vector.size(); i_p++){
50 merged_vector.emplace_back(input_vector[i_p],fG4TrackIDOffsets[source_index]);
52 fMCParticleListMap[source_index][i_p] = merged_vector.size() - 1;
54 if(
std::abs(merged_vector.back().TrackId()) < range_trackID.first)
55 range_trackID.first =
std::abs(merged_vector.back().TrackId());
56 if(
std::abs(merged_vector.back().TrackId()) > range_trackID.second)
57 range_trackID.second =
std::abs(merged_vector.back().TrackId());
61 UpdateG4TrackIDRange(range_trackID,source_index);
65 const std::vector<sim::SimChannel>& input_vector,
68 if(source_index >= fG4TrackIDOffsets.size())
69 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
71 merged_vector.reserve( merged_vector.size() + input_vector.size() );
73 std::pair<int,int> range_trackID(std::numeric_limits<int>::max(),
74 std::numeric_limits<int>::min());
76 for(
auto const& simchannel : input_vector){
77 std::vector<sim::SimChannel>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simchannel);
79 if(it==merged_vector.end()){
80 merged_vector.emplace_back(simchannel.Channel());
81 it = merged_vector.end() - 1;
84 std::pair<int,int> thisrange = it->MergeSimChannel(simchannel,fG4TrackIDOffsets[source_index]);
86 range_trackID.first =
std::abs(thisrange.first);
88 range_trackID.second =
std::abs(thisrange.second);
91 UpdateG4TrackIDRange(range_trackID,source_index);
95 const std::vector<sim::AuxDetSimChannel>& input_vector,
98 if(source_index >= fG4TrackIDOffsets.size())
99 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
101 merged_vector.reserve( merged_vector.size() + input_vector.size() );
103 std::pair<int,int> range_trackID(std::numeric_limits<int>::max(),
104 std::numeric_limits<int>::min());
106 for(
auto const& simchannel : input_vector){
107 std::vector<sim::AuxDetSimChannel>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simchannel);
109 if(it==merged_vector.end()){
110 merged_vector.emplace_back(simchannel.AuxDetID(), simchannel.AuxDetSensitiveID());
111 it = merged_vector.end() - 1;
115 int offset = fG4TrackIDOffsets[source_index];
116 std::vector<sim::AuxDetIDE> all_ides = it->AuxDetIDEs();
118 all_ides.emplace_back(ide, offset);
122 if( tid < range_trackID.first )
123 range_trackID.first = tid;
124 if( tid > range_trackID.second )
125 range_trackID.second = tid;
129 *it =
sim::AuxDetSimChannel(simchannel.AuxDetID(), std::move(all_ides), simchannel.AuxDetSensitiveID());
132 UpdateG4TrackIDRange(range_trackID,source_index);
136 const std::vector<sim::SimPhotons>& input_vector)
139 merged_vector.reserve( merged_vector.size() + input_vector.size() );
141 for(
auto const& simphotons : input_vector){
142 std::vector<sim::SimPhotons>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simphotons);
144 if(it==merged_vector.end()){
145 merged_vector.emplace_back(simphotons.OpChannel());
146 it = merged_vector.end() - 1;
154 const std::vector<sim::SimPhotonsLite>& input_vector)
157 merged_vector.reserve( merged_vector.size() + input_vector.size() );
159 for(
auto const& simphotons : input_vector){
160 std::vector<sim::SimPhotonsLite>::iterator it = std::find(merged_vector.begin(),merged_vector.end(),simphotons);
162 if(it==merged_vector.end()){
163 merged_vector.emplace_back(simphotons.OpChannel);
164 it = merged_vector.end() - 1;
173 std::vector<sim::SimEnergyDeposit>& dest,
174 const std::vector<sim::SimEnergyDeposit>& src,
175 std::size_t source_index
178 int const offset = fG4TrackIDOffsets.at(source_index);
182 dest.reserve(dest.size() + src.size());
189 std::vector<sim::AuxDetHit>& dest,
190 const std::vector<sim::AuxDetHit>& src,
191 std::size_t source_index
194 int const offset = fG4TrackIDOffsets.at(source_index);
198 dest.reserve(dest.size() + src.size());
206 if(source_index >= fG4TrackIDOffsets.size())
207 std::runtime_error(
"ERROR in MergeSimSourcesUtility: Source index out of range!");
209 if( newrange.first >= fG4TrackIDRanges[source_index].first &&
210 newrange.second <= fG4TrackIDRanges[source_index].second)
213 for(
size_t i=0; i<fG4TrackIDRanges.size(); i++){
214 if(i==source_index)
continue;
216 if( (newrange.first >= fG4TrackIDRanges[i].first && newrange.first <= fG4TrackIDRanges[i].second) ||
217 (newrange.second >= fG4TrackIDRanges[i].first && newrange.second <= fG4TrackIDRanges[i].second) )
219 std::stringstream ss;
220 ss <<
"ERROR in MergeSimSourcesUtility: Source trackIDs overlap!"
221 <<
"\n\t" << i <<
"\t" << fG4TrackIDRanges[i].first <<
" " << fG4TrackIDRanges[i].second
222 <<
"\n\t" <<
"n\t" << newrange.first <<
" " << newrange.second;
223 throw std::runtime_error(ss.str());
227 if(newrange.first < fG4TrackIDRanges[source_index].first)
228 fG4TrackIDRanges[source_index].first = newrange.first;
229 if(newrange.second > fG4TrackIDRanges[source_index].second)
230 fG4TrackIDRanges[source_index].second = newrange.second;
unsigned int GetTrackID() const
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
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 UpdateG4TrackIDRange(std::pair< int, int >, size_t)
MergeSimSourcesUtility(std::vector< int > const &)
void MergeSimPhotons(std::vector< sim::SimPhotons > &, const std::vector< sim::SimPhotons > &)
static sim::SimEnergyDeposit offsetSimEnergyDepositTrackID(sim::SimEnergyDeposit const &, int)
void MergeAuxDetSimChannels(std::vector< sim::AuxDetSimChannel > &, const std::vector< sim::AuxDetSimChannel > &, size_t)
float GetExitMomentumY() const
void MergeAuxDetHits(std::vector< sim::AuxDetHit > &, const std::vector< sim::AuxDetHit > &, size_t) const
Collection of particles crossing one auxiliary detector cell.
geo::Point_t Start() const
auto end(FixedBins< T, C > const &) noexcept
float GetEnergyDeposited() const
unsigned int GetID() const
auto begin(FixedBins< T, C > const &) noexcept
void MergeMCParticles(std::vector< simb::MCParticle > &, const std::vector< simb::MCParticle > &, size_t)
float GetExitMomentumX() const
MC truth information to make RawDigits and do back tracking.
static sim::AuxDetHit offsetAuxDetHitTrackID(sim::AuxDetHit const &, int)
Energy deposition in the active material.
void MergeSimEnergyDeposits(std::vector< sim::SimEnergyDeposit > &, const std::vector< sim::SimEnergyDeposit > &, size_t) const
float GetExitMomentumZ() const
double ScintYieldRatio() const