144 art::ServiceHandle<geo::Geometry const> geom;
148 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
154 for(
size_t i=0; i<sedArray.size(); ++i) {
157 auto const& sed = sedArray[i];
167 auto const mp = sed.MidPoint();
168 double const xyz[3] = { mp.X(), mp.Y(), mp.Z() };
172 unsigned int cryostat = 0;
174 geom->PositionToCryostat(xyz, cryostat);
176 catch(cet::exception &
e){
177 mf::LogWarning(
"SimDriftElectrons") <<
"step "
178 <<
"cannot be found in a cryostat\n"
182 unsigned int tpc = 0;
184 geom->PositionToTPC(xyz, tpc, cryostat);
186 catch(cet::exception &e){
187 mf::LogWarning(
"SimDriftElectrons") <<
"step "
188 <<
"cannot be found in a TPC\n"
192 const geo::TPCGeo& tpcGeo = geom->TPC(tpc, cryostat);
207 ch = geom->NearestChannel(xyz,
p, tpc, cryostat);
209 catch(cet::exception &e){
210 mf::LogWarning(
"SimDriftElectrons") <<
"step "
211 <<
"nearest wire not in TPC\n"
216 int track_id = sed.TrackID();
218 if(track_id < 0) track_id = track_id * (-1);
219 unsigned int real_track_id = track_id;
221 UniquePosition pos(xyz[0], xyz[1], xyz[2]);
224 auto key = std::make_pair(pos, real_track_id);
225 auto hit_index_track_iter = hit_index_m.find(key);
226 if(hit_index_track_iter == hit_index_m.end()) {
228 hit_index_m[key]= new_hit_index;
231 hit_index = (*hit_index_track_iter).second;
233 auto const pid = geom->ChannelToWire(ch)[0].planeID();
234 auto const channel_id = pindex[pid];
235 double charge = sed.NumElectrons();
239 this->
__GetEdepArray__(real_track_id).emplace_back(pos, pid, pindex.size(), sed.Energy(), charge, channel_id);
244 edep.deps[channel_id].charge += charge;
245 edep.deps[channel_id].energy += sed.Energy();
251 std::cout<< Form(
" Collected %zu particles' energy depositions...",
_mc_edeps.size()) << std::endl;
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< std::vector< sim::MCEdep > > _mc_edeps
std::vector< sim::MCEdep > & __GetEdepArray__(unsigned int track_id)
std::map< unsigned int, size_t > _track_index
unsigned int ChannelID_t
Type representing the ID of a readout channel.
BEGIN_PROLOG could also be cout