30 std::map<geo::PlaneID, size_t> m;
44 _debug_mode = pset.
get<
bool>(
"DebugMode");
45 _save_mchit = pset.
get<
bool>(
"SaveMCHit");
50 if (edep_index >= _mc_edeps.size())
51 throw cet::exception(__FUNCTION__) << Form(
"Track ID %zu not found!", edep_index);
52 return _mc_edeps.at(edep_index);
57 if (ExistTrack(track_id))
return _mc_edeps.at((*_track_index.find(track_id)).
second);
58 _track_index.insert(std::pair<unsigned int, size_t>(track_id, _mc_edeps.size()));
59 _mc_edeps.push_back(std::vector<sim::MCEdep>());
60 return (*(_mc_edeps.rbegin()));
71 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
75 if (_debug_mode) std::cout <<
"Processing " << schArray.size() <<
" channels..." << std::endl;
77 for (
size_t i = 0; i < schArray.size(); ++i) {
80 auto const& sch = schArray[i];
81 const auto& sch_map(sch.TDCIDEMap());
83 UInt_t ch = sch.Channel();
85 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 = __GetEdepArray__(real_track_id).size();
100 hit_index_m[key] = new_hit_index;
103 hit_index = (*hit_index_track_iter).second;
105 auto const pid = wireReadoutGeom.ChannelToWire(ch)[0].planeID();
106 auto const channel_id = pindex[
pid];
107 double charge = ide.numElectrons;
110 __GetEdepArray__(real_track_id)
111 .emplace_back(pos,
pid, pindex.size(), ide.energy, charge, channel_id);
115 MCEdep&
edep = __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())
132 _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];
156 auto const mp = sed.MidPoint();
160 unsigned int cryostat = 0;
166 <<
"cannot be found in a cryostat\n" 170 unsigned int tpc = 0;
176 <<
"cannot be found in a TPC\n" 186 for (
auto const& planeid : wireReadoutGeom.Iterate<
geo::PlaneID>()) {
195 ch = wireReadoutGeom.NearestChannel(mp, planeid);
199 <<
"nearest wire not in TPC\n" 204 int track_id = sed.TrackID();
206 if (track_id < 0) track_id = track_id * (-1);
207 unsigned int real_track_id = track_id;
212 auto key = std::make_pair(pos, real_track_id);
213 auto hit_index_track_iter = hit_index_m.find(key);
214 if (hit_index_track_iter == hit_index_m.end()) {
215 int new_hit_index = __GetEdepArray__(real_track_id).size();
216 hit_index_m[key] = new_hit_index;
219 hit_index = (*hit_index_track_iter).second;
221 auto const pid = wireReadoutGeom.ChannelToWire(ch)[0].planeID();
222 auto const channel_id = pindex[
pid];
223 double charge = sed.NumElectrons();
226 __GetEdepArray__(real_track_id)
227 .emplace_back(pos,
pid, pindex.size(), sed.Energy(), charge, channel_id);
231 MCEdep&
edep = __GetEdepArray__(real_track_id).at(hit_index);
232 edep.
deps[channel_id].charge += charge;
233 edep.
deps[channel_id].energy += sed.Energy();
239 std::cout << Form(
" Collected %zu particles' energy depositions...", _mc_edeps.size())
250 std::vector<sim::SimEnergyDeposit> new_sedArray(sedArray.begin(), sedArray.end());
251 MakeMCEdep(new_sedArray);
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
The data type to uniquely identify a Plane.
std::map< geo::PlaneID, size_t > createPlaneIndexMap()
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
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 the physical 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
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 .