7 #include "art/Framework/Services/Registry/ServiceHandle.h"
8 #include "messagefacility/MessageLogger/MessageLogger.h"
9 #include "fhiclcpp/ParameterSet.h"
27 art::ServiceHandle<geo::Geometry const> geom;
28 std::map<geo::PlaneID, size_t>
m;
30 for(
auto const& pid : geom->IteratePlaneIDs()){
52 throw cet::exception(__FUNCTION__) << Form(
"Track ID %zu not found!",edep_index);
60 _mc_edeps.push_back(std::vector<sim::MCEdep>());
69 art::ServiceHandle<geo::Geometry const> geom;
73 std::map<std::pair<UniquePosition, unsigned int>,
int> hit_index_m;
79 for(
size_t i=0; i<schArray.size(); ++i) {
82 auto const& sch = schArray[i];
83 const auto &sch_map(sch.TDCIDEMap());
85 UInt_t ch = sch.Channel();
87 for(
auto tdc_iter = sch_map.begin(); tdc_iter!=sch_map.end(); ++tdc_iter) {
91 for(
auto const &ide : (*tdc_iter).second) {
93 int track_id = ide.trackID;
94 if(track_id < 0) track_id = track_id * (-1);
95 unsigned int real_track_id = track_id;
100 auto key = std::make_pair(pos, real_track_id);
101 auto hit_index_track_iter = hit_index_m.find(key);
102 if(hit_index_track_iter == hit_index_m.end()) {
104 hit_index_m[key]= new_hit_index;
107 hit_index = (*hit_index_track_iter).second;
109 auto const pid = geom->ChannelToWire(ch)[0].planeID();
110 auto const channel_id = pindex[pid];
111 double charge = ide.numElectrons;
115 this->
__GetEdepArray__(real_track_id).emplace_back(pos, pid, pindex.size(), ide.energy, charge, channel_id);
120 edep.
deps[channel_id].charge += charge;
121 edep.
deps[channel_id].energy += ide.energy;
128 std::cout<< Form(
" Collected %zu particles' energy depositions...",
_mc_edeps.size()) << std::endl;
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;
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;
269 std::vector<sim::SimEnergyDeposit> new_sedArray(sedArray.begin(), sedArray.end());
void MakeMCEdep(const std::vector< sim::SimChannel > &schArray)
unsigned int Nplanes() const
Number of planes in this tpc.
Geometry information for a single TPC.
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.
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
Access the description of detector geometry.
MCRecoEdep(fhicl::ParameterSet const &pset)
Default constructor with fhicl parameters.
bool ExistTrack(const unsigned int track_id) const
std::vector< std::vector< sim::MCEdep > > _mc_edeps
std::vector< sim::MCEdep > & __GetEdepArray__(unsigned int track_id)
std::vector< deposit > deps
std::map< unsigned int, size_t > _track_index
unsigned int ChannelID_t
Type representing the ID of a readout channel.
art framework interface to geometry description
BEGIN_PROLOG could also be cout
Encapsulate the construction of a single detector plane.