29 std::map<geo::PlaneID, size_t> m;
43 _debug_mode = pset.
get<
bool>(
"DebugMode");
44 _save_mchit = pset.
get<
bool>(
"SaveMCHit");
49 if (edep_index >= _mc_edeps.size())
50 throw cet::exception(__FUNCTION__) << Form(
"Track ID %zu not found!", edep_index);
51 return _mc_edeps.at(edep_index);
56 if (ExistTrack(track_id))
return _mc_edeps.at((*_track_index.find(track_id)).
second);
57 _track_index.insert(std::pair<unsigned int, size_t>(track_id, _mc_edeps.size()));
58 _mc_edeps.push_back(std::vector<sim::MCEdep>());
59 return (*(_mc_edeps.rbegin()));
70 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
74 if (_debug_mode) std::cout <<
"Processing " << schArray.size() <<
" channels..." << std::endl;
76 for (
size_t i = 0; i < schArray.size(); ++i) {
79 auto const& sch = schArray[i];
80 const auto& sch_map(sch.TDCIDEMap());
82 UInt_t ch = sch.Channel();
84 for (
auto tdc_iter = sch_map.begin(); tdc_iter != sch_map.end(); ++tdc_iter) {
86 for (
auto const& ide : (*tdc_iter).second) {
88 int track_id = ide.trackID;
89 if (track_id < 0) track_id = track_id * (-1);
90 unsigned int real_track_id = track_id;
95 auto key = std::make_pair(pos, real_track_id);
96 auto hit_index_track_iter = hit_index_m.find(key);
97 if (hit_index_track_iter == hit_index_m.end()) {
98 int new_hit_index = this->__GetEdepArray__(real_track_id).size();
99 hit_index_m[key] = new_hit_index;
102 hit_index = (*hit_index_track_iter).second;
105 auto const channel_id = pindex[
pid];
106 double charge = ide.numElectrons;
110 this->__GetEdepArray__(real_track_id)
111 .emplace_back(pos,
pid, pindex.size(), ide.energy, charge, channel_id);
116 MCEdep&
edep = this->__GetEdepArray__(real_track_id).at(hit_index);
117 edep.
deps[channel_id].charge += charge;
118 edep.
deps[channel_id].energy += ide.energy;
125 std::cout << Form(
" Collected %zu particles' energy depositions...", _mc_edeps.size())
133 _track_index.clear();
138 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
143 std::cout <<
"Processing " << sedArray.size() <<
" energy deposits..." << std::endl;
145 for (
size_t i = 0; i < sedArray.size(); ++i) {
148 auto const& sed = sedArray[i];
158 auto const mp = sed.MidPoint();
162 unsigned int cryostat = 0;
168 <<
"cannot be found in a cryostat\n" 172 unsigned int tpc = 0;
178 <<
"cannot be found in a TPC\n" 201 <<
"nearest wire not in TPC\n" 206 int track_id = sed.TrackID();
208 if (track_id < 0) track_id = track_id * (-1);
209 unsigned int real_track_id = track_id;
214 auto key = std::make_pair(pos, real_track_id);
215 auto hit_index_track_iter = hit_index_m.find(key);
216 if (hit_index_track_iter == hit_index_m.end()) {
217 int new_hit_index = this->__GetEdepArray__(real_track_id).size();
218 hit_index_m[key] = new_hit_index;
221 hit_index = (*hit_index_track_iter).second;
224 auto const channel_id = pindex[
pid];
225 double charge = sed.NumElectrons();
229 this->__GetEdepArray__(real_track_id)
230 .emplace_back(pos,
pid, pindex.size(), sed.Energy(), charge, channel_id);
235 MCEdep&
edep = this->__GetEdepArray__(real_track_id).at(hit_index);
236 edep.
deps[channel_id].charge += charge;
237 edep.
deps[channel_id].energy += sed.Energy();
243 std::cout << Form(
" Collected %zu particles' energy depositions...", _mc_edeps.size())
254 std::vector<sim::SimEnergyDeposit> new_sedArray(sedArray.begin(), sedArray.end());
255 MakeMCEdep(new_sedArray);
details::range_type< T > Iterate() const
Initializes the specified ID with the ID of the first cryostat.
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
The data type to uniquely identify a Plane.
std::map< geo::PlaneID, size_t > createPlaneIndexMap()
const std::vector< sim::MCEdep > & GetEdepArrayAt(size_t edep_index) const
Returns a vector of MCEdep object at the given index.
Access the description of detector geometry.
MCRecoEdep(fhicl::ParameterSet const &pset)
Default constructor with fhicl parameters.
T get(std::string const &key) const
The data type to uniquely identify a TPC.
CryostatID PositionToCryostatID(Point_t const &point) const
Returns the ID of the cryostat at specified location.
std::vector< sim::MCEdep > & __GetEdepArray__(unsigned int track_id)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
raw::ChannelID_t NearestChannel(Point_t const &worldLoc, PlaneID const &planeid) const
Returns the ID of the channel nearest to the specified position.
std::vector< deposit > deps
unsigned int ChannelID_t
Type representing the ID of a readout channel.
second_as<> second
Type of time stored in seconds, in double precision.
TPCID PositionToTPCID(Point_t const &point) const
Returns the ID of the TPC at specified location.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
Encapsulate the construction of a single detector plane.