24 std::map<geo::PlaneID, size_t>
m;
41 _debug_mode = pset.
get<
bool>(
"DebugMode");
42 _save_mchit = pset.
get<
bool>(
"SaveMCHit");
47 if(edep_index >= _mc_edeps.size())
48 throw cet::exception(__FUNCTION__) << Form(
"Track ID %zu not found!",edep_index);
49 return _mc_edeps.at(edep_index);
54 if(ExistTrack(track_id))
return _mc_edeps.at((*_track_index.find(track_id)).
second);
55 _track_index.insert(std::pair<unsigned int,size_t>(track_id,_mc_edeps.size()));
56 _mc_edeps.push_back(std::vector<sim::MCEdep>());
57 return (*(_mc_edeps.rbegin()));
69 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
73 if(_debug_mode) std::cout<<
"Processing "<<schArray.size()<<
" channels..."<<
std::endl;
75 for(
size_t i=0; i<schArray.size(); ++i) {
78 auto const& sch = schArray[i];
79 const auto &sch_map(sch.TDCIDEMap());
81 UInt_t ch = sch.Channel();
83 for(
auto tdc_iter = sch_map.begin(); tdc_iter!=sch_map.end(); ++tdc_iter) {
87 for(
auto const &ide : (*tdc_iter).second) {
89 int track_id = ide.trackID;
90 if(track_id < 0) track_id = track_id * (-1);
91 unsigned int real_track_id = track_id;
96 auto key = std::make_pair(pos, real_track_id);
97 auto hit_index_track_iter = hit_index_m.find(
key);
98 if(hit_index_track_iter == hit_index_m.end()) {
99 int new_hit_index = this->__GetEdepArray__(real_track_id).size();
100 hit_index_m[
key]= new_hit_index;
103 hit_index = (*hit_index_track_iter).second;
106 auto const channel_id = pindex[
pid];
107 double charge = ide.numElectrons;
111 this->__GetEdepArray__(real_track_id).emplace_back(pos,
pid, pindex.size(), ide.energy, charge, channel_id);
115 MCEdep &edep = this->__GetEdepArray__(real_track_id).at(hit_index);
116 edep.
deps[channel_id].charge += charge;
117 edep.
deps[channel_id].energy += ide.energy;
124 std::cout<< Form(
" Collected %zu particles' energy depositions...",_mc_edeps.size()) <<
std::endl;
138 _track_index.clear();
144 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
148 if(_debug_mode) std::cout<<
"Processing "<<sedArray.size()<<
" energy deposits..."<<
std::endl;
150 for(
size_t i=0; i<sedArray.size(); ++i) {
153 auto const& sed = sedArray[i];
163 auto const mp = sed.MidPoint();
164 double const xyz[3] = { mp.X(), mp.Y(), mp.Z() };
168 unsigned int cryostat = 0;
174 <<
"cannot be found in a cryostat\n" 178 unsigned int tpc = 0;
184 <<
"cannot be found in a TPC\n" 207 <<
"nearest wire not in TPC\n" 212 int track_id = sed.TrackID();
214 if(track_id < 0) track_id = track_id * (-1);
215 unsigned int real_track_id = track_id;
220 auto key = std::make_pair(pos, real_track_id);
221 auto hit_index_track_iter = hit_index_m.find(
key);
222 if(hit_index_track_iter == hit_index_m.end()) {
223 int new_hit_index = this->__GetEdepArray__(real_track_id).size();
224 hit_index_m[
key]= new_hit_index;
227 hit_index = (*hit_index_track_iter).second;
230 auto const channel_id = pindex[
pid];
231 double charge = sed.NumElectrons();
235 this->__GetEdepArray__(real_track_id).emplace_back(pos,
pid, pindex.size(), sed.Energy(), charge, channel_id);
239 MCEdep &edep = this->__GetEdepArray__(real_track_id).at(hit_index);
240 edep.
deps[channel_id].charge += charge;
241 edep.
deps[channel_id].energy += sed.Energy();
247 std::cout<< Form(
" Collected %zu particles' energy depositions...",_mc_edeps.size()) <<
std::endl;
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
CryostatGeo const & PositionToCryostat(geo::Point_t const &point) const
Returns the cryostat at specified location.
unsigned int Nplanes() const
Number of planes in this tpc.
Geometry information for a single TPC.
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.
art framework interface to geometry description
geo::TPCGeo const & PositionToTPC(geo::Point_t const &point) const
Returns the TPC at specified location.
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
Code to link reconstructed objects back to the MC truth information.
std::vector< sim::MCEdep > & __GetEdepArray__(unsigned int track_id)
contains information for a single step in the detector simulation
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< deposit > deps
Access the description of detector geometry.
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
raw::ChannelID_t NearestChannel(geo::Point_t const &worldLoc, geo::PlaneID const &planeid) const
Returns the ID of the channel nearest to the specified position.
second_as<> second
Type of time stored in seconds, in double precision.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)
Encapsulate the construction of a single detector plane.