58 art::ServiceHandle<geo::Geometry const> geo;
60 const unsigned int nch = geo->Nchannels();
62 std::unique_ptr< std::vector<sim::MCHitCollection> > hits_v (
new std::vector<sim::MCHitCollection>() );
63 std::unique_ptr< std::vector<sim::MCWireCollection> > wires_v (
new std::vector<sim::MCWireCollection>() );
66 wires_v->reserve(nch);
67 for(
size_t ch=0; ch<nch; ++ch) {
74 art::Handle< std::vector<sim::SimChannel> > simchArray;
76 if(!simchArray.isValid())
77 throw cet::exception(__PRETTY_FUNCTION__)
78 <<
"Did not find sim::SimChannel with a label: " <<
fLArG4ModuleName.c_str() << std::endl;
81 for(
size_t simch_index=0; simch_index<simchArray->size(); ++simch_index) {
83 const art::Ptr<sim::SimChannel> simch_ptr(simchArray,simch_index);
85 size_t ch = simch_ptr->Channel();
87 if(ch >= hits_v->size())
89 throw cet::exception(__PRETTY_FUNCTION__)
90 <<
"Channel number " << ch <<
" exceeds total # of channels: " << nch << std::endl;
92 auto &mchits = hits_v->at(ch);
93 auto &mcwires = wires_v->at(ch);
95 std::map<sim::MCEnDep,sim::MCWire> edep_wire_map;
96 auto tdc_ide_map = simch_ptr->TDCIDEMap();
106 std::cout<<std::endl<<
"Processing Ch: "<<ch<<std::endl;
108 for(
auto const& tdc_ide_pair : tdc_ide_map) {
110 auto const& tdc = tdc_ide_pair.first;
111 auto const& ide_v = tdc_ide_pair.second;
113 for(
auto const& ide : ide_v) {
122 auto edep_iter = edep_wire_map.insert(std::make_pair(edep,wire));
126 auto last_tdc = (edep_iter).
first->second.StartTDC() + (edep_iter).
first->second.size() - 1;
130 if( edep_iter.second )
std::cout<<std::endl;
133 <<
" Vtx: " <<ide.x <<
" " << ide.y <<
" " <<ide.z <<
" " <<ide.energy
134 <<
" ... @ TDC = "<<tdc<<
" ... "<<ide.numElectrons << std::endl;
137 if( !(edep_iter.second) ) {
139 if( last_tdc+1 != tdc ) {
151 (edep_iter).
first->second.push_back(ide.numElectrons);
158 for(
auto const& edep_wire_pair : edep_wire_map) {
160 auto const& edep = edep_wire_pair.first;
161 auto const& wire = edep_wire_pair.second;
165 float vtx[3] = {float(edep.
Vertex()[0]),
173 for(
size_t wire_index=0; wire_index < wire.size(); ++wire_index) {
175 auto q = wire.at(wire_index);
179 if(
q > qmax) { qmax =
q; max_time = wire.
StartTDC() + wire_index; }
185 mchits.push_back(hit);
189 mcwires.push_back(wire);
193 e.removeCachedProduct(simchArray);
195 std::sort((*hits_v).begin(),(*hits_v).end());
196 e.put(std::move(hits_v));
199 std::sort((*wires_v).begin(),(*wires_v).end());
200 e.put(std::move(wires_v));
void SetCharge(float qsum, float amp)
Setter function for charge/amplitude.
void SetParticleInfo(const float vtx[], const float energy, const int trackId)
Setter function for partile info.
void SetTime(const float peak, const float width)
Setter function for time.
void SetStartTDC(const unsigned int start)
Setter function for time.
void SetTrackId(unsigned int id)
unsigned int StartTDC() const
Getter for start time.
unsigned int TrackId() const
void SetVertex(float x, float y, float z)
std::string fLArG4ModuleName
BEGIN_PROLOG could also be cout
const std::array< float, 3 > & Vertex() const