19 std::map<geo::PlaneID, size_t> m;
36 _debug_mode = pset.
get<
bool>(
"DebugMode");
37 _save_mchit = pset.
get<
bool>(
"SaveMCHit");
42 if(edep_index >= _mc_edeps.size())
43 throw cet::exception(__FUNCTION__) << Form(
"Track ID %zu not found!",edep_index);
44 return _mc_edeps.at(edep_index);
49 if(ExistTrack(track_id))
return _mc_edeps.at((*_track_index.find(track_id)).second);
50 _track_index.insert(std::pair<unsigned int,size_t>(track_id,_mc_edeps.size()));
51 _mc_edeps.push_back(std::vector<sim::MCEdep>());
52 return (*(_mc_edeps.rbegin()));
64 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
68 if(_debug_mode) std::cout<<
"Processing "<<schArray.size()<<
" channels..."<<std::endl;
70 for(
size_t i=0; i<schArray.size(); ++i) {
73 auto const& sch = schArray[i];
74 const auto &sch_map(sch.TDCIDEMap());
76 UInt_t ch = sch.Channel();
78 for(
auto tdc_iter = sch_map.begin(); tdc_iter!=sch_map.end(); ++tdc_iter) {
82 for(
auto const &ide : (*tdc_iter).second) {
84 int track_id = ide.trackID;
85 if(track_id < 0) track_id = track_id * (-1);
86 unsigned int real_track_id = track_id;
91 auto key = std::make_pair(pos, real_track_id);
92 auto hit_index_track_iter = hit_index_m.find(key);
93 if(hit_index_track_iter == hit_index_m.end()) {
94 int new_hit_index = this->__GetEdepArray__(real_track_id).size();
95 hit_index_m[key]= new_hit_index;
98 hit_index = (*hit_index_track_iter).second;
101 auto const channel_id = pindex[
pid];
102 double charge = ide.numElectrons;
106 this->__GetEdepArray__(real_track_id).emplace_back(pos,
pid, pindex.size(), ide.energy, charge, channel_id);
110 MCEdep &
edep = this->__GetEdepArray__(real_track_id).at(hit_index);
111 edep.
deps[channel_id].charge += charge;
112 edep.
deps[channel_id].energy += ide.energy;
119 std::cout<< Form(
" Collected %zu particles' energy depositions...",_mc_edeps.size()) << std::endl;
126 std::cout<<std::endl;
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
std::map< geo::PlaneID, size_t > createPlaneIndexMap()
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
const std::vector< sim::MCEdep > & GetEdepArrayAt(size_t edep_index) const
Returns a vector of MCEdep object at the given index.
IteratorBox< plane_id_iterator,&GeometryCore::begin_plane_id,&GeometryCore::end_plane_id > IteratePlaneIDs() const
Enables ranged-for loops on all plane IDs of the detector.
MCRecoEdep(fhicl::ParameterSet const &pset)
Default constructor with fhicl parameters.
T get(std::string const &key) const
std::vector< sim::MCEdep > & __GetEdepArray__(unsigned int track_id)
std::vector< deposit > deps
cet::coded_exception< error, detail::translate > exception