50 auto ROIs = fWire.SignalROI();
51 if (!(ROIs.get_ranges().size()))
return ret;
53 for (
auto iROI = ROIs.begin_range(); iROI != ROIs.end_range(); ++iROI) {
55 std::map<double, double> pulse;
56 for (
int tick = ROI.begin_index();
tick < (int)ROI.end_index();
tick++) {
58 pulse.insert(std::pair<double, double>((
double)
tick, (
double)ROI[tick]));
69 if (!wireids.size())
return ret;
72 if (wireids.size() > 1) {
73 for (
auto iwire : wireids)
74 if (iwire.Plane == fWire.View()) ret = iwire;
83 auto& ROIs = fSimchan.TDCIDEMap();
84 if (!(ROIs.size()))
return ret;
86 for (
auto iROI = ROIs.begin(); iROI != ROIs.end(); ++iROI) {
88 auto tick = ROI.first;
89 double charge = 0.005 * fSimchan.Charge(
tick);
92 ret.push_back(std::map<double, double>({{(double)
tick, charge}}));
101 if (!wireids.size())
return ret;
106 template <
class T,
class U>
111 : fNWire(nWire), fNTdc(nTdc), fTRes(tRes),
fThreshold(threshold), fMultipleDrifts(false)
117 template <
class T,
class U>
123 template <
class T,
class U>
125 :
fNWire(pset.
get<unsigned int>(
"WireLength"))
126 ,
fNTdc(pset.
get<unsigned int>(
"TdcWidth"))
127 ,
fTRes(pset.
get<double>(
"TimeResolution"))
134 template <
class T,
class U>
138 std::vector<const T*> newCluster;
140 newCluster.push_back(
hit.get());
145 template <
class T,
class U>
147 const std::vector<const T*>&
cluster)
153 template <
class T,
class U>
156 const std::vector<const T*>&
cluster,
162 for (
size_t iHit = 0; iHit < cluster.size(); ++iHit) {
165 Waveform wf = wraphit.GetWaveform();
168 unsigned int tempWire = wireid.
Wire;
169 unsigned int tempPlane = wireid.
Plane;
173 for (
auto& pulse : wf) {
175 for (
auto& i : pulse) {
176 const double pe = i.second;
177 double temptdc = i.first;
181 const unsigned int wire = tempWire;
182 const unsigned int wirePlane = tempPlane;
183 const double tdc = temptdc;
185 pm.
Add(wire, tdc, wirePlane, pe);
193 template <
class T,
class U>
194 std::ostream& operator<<(std::ostream& os, const PixelMapProducer<T, U>& p)
196 os <<
"PixelMapProducer: " << p.
NTdc() <<
" tdcs X " << p.NWire() <<
" wires";
200 template <
class T,
class U>
202 const std::vector<const T*>&
cluster)
205 std::vector<double> tmin_0;
206 std::vector<double> tmin_1;
207 std::vector<double> tmin_2;
209 std::vector<int> wire_0, bwire_0;
210 std::vector<int> wire_1, bwire_1;
211 std::vector<int> wire_2, bwire_2;
213 std::vector<double> tsum = {0., 0., 0.};
214 std::vector<double> tsize = {0., 0., 0.};
216 for (
size_t iHit = 0; iHit < cluster.size(); ++iHit) {
218 Waveform wf = wraphit.GetWaveform();
221 unsigned int tempWire = wireid.
Wire;
222 unsigned int tempPlane = wireid.
Plane;
226 for (
auto& pulse : wf) {
227 double min_tick = (double)INT_MAX;
228 for (
auto& i : pulse) {
229 double temptdc = i.first;
234 if (temptdc < min_tick) min_tick = temptdc;
236 tsum[tempPlane] += temptdc;
237 tsize[tempPlane] += 1.;
240 if (!(pulse.empty())) {
241 if (tempPlane == 0) {
242 tmin_0.push_back(min_tick);
243 wire_0.push_back(tempWire);
245 if (tempPlane == 1) {
246 tmin_1.push_back(min_tick);
247 wire_0.push_back(tempWire);
249 if (tempPlane == 2) {
250 tmin_2.push_back(min_tick);
251 wire_0.push_back(tempWire);
257 double tmean_0 = tsum[0] / tsize[0];
258 double tmean_1 = tsum[1] / tsize[1];
259 double tmean_2 = tsum[2] / tsize[2];
261 for (
int i = 0; i < (int)wire_0.size(); i++) {
262 if (
std::abs(tmin_0[i] - tmean_0) < (double)
fTRes) bwire_0.push_back(wire_0[i]);
264 for (
int i = 0; i < (int)wire_1.size(); i++) {
265 if (
std::abs(tmin_1[i] - tmean_1) < (double)
fTRes) bwire_1.push_back(wire_1[i]);
267 for (
int i = 0; i < (int)wire_2.size(); i++) {
268 if (
std::abs(tmin_2[i] - tmean_2) < (double)
fTRes) bwire_2.push_back(wire_2[i]);
271 std::cout <<
"Boundary wire vector sizes: " << bwire_0.size() <<
", " << bwire_1.size() <<
", " 272 << bwire_2.size() << std::endl;
277 auto minwireelement_0 = std::min_element(bwire_0.begin(), bwire_0.end());
278 auto minwireelement_1 = std::min_element(bwire_1.begin(), bwire_1.end());
279 auto minwireelement_2 = std::min_element(bwire_2.begin(), bwire_2.end());
281 if (bwire_0.size() > 0) {
282 minwire_0 = *minwireelement_0 - 1;
283 std::cout <<
"minwire 0: " << (*minwireelement_0 - 1) << std::endl;
285 if (bwire_1.size() > 0) {
286 minwire_1 = *minwireelement_1 - 1;
287 std::cout <<
"minwire 1: " << (*minwireelement_1 - 1) << std::endl;
289 if (bwire_2.size() > 0) {
290 minwire_2 = *minwireelement_2 - 1;
291 std::cout <<
"minwire 2: " << (*minwireelement_2 - 1) << std::endl;
294 fTotHits = bwire_0.size() + bwire_1.size() + bwire_2.size();
301 template <
class T,
class U>
303 unsigned int& globalWire,
304 unsigned int& globalPlane)
const 306 globalWire = wireid.
Wire;
307 globalPlane = wireid.
Plane;
310 template <
class T,
class U>
313 unsigned int& globalWire,
314 unsigned int& globalPlane,
315 double& globalTDC)
const 317 globalWire = wireid.
Wire;
318 globalPlane = wireid.
Plane;
319 globalTDC = localTDC;
virtual PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< T >> &cluster)
virtual geo::WireID GetID()
std::vector< WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
virtual Waveform GetWaveform()
Declaration of signal hit object.
void SetTotHits(unsigned int tothits)
constexpr auto abs(T v)
Returns the absolute value of the argument.
PixelMap, basic input to CVN neural net.
Utility class for truth labels.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
WireID_t Wire
Index of the wire within its plane.
geo::WireID const & WireID() const
Initial tdc tick for hit.
Cluster finding and building.
virtual Waveform GetWaveform()
virtual Waveform GetWaveform()
Producer algorithm for PixelMap, input to CVN neural net.
virtual PixelMap CreateMapGivenBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster, const Boundary &bound)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Access the description of detector geometry.
virtual void ConvertLocaltoGlobalTDC(geo::WireID wireid, double localTDC, unsigned int &globalWire, unsigned int &globalPlane, double &globalTDC) const
virtual Boundary DefineBoundary(detinfo::DetectorPropertiesData const &detProp, const std::vector< const T * > &cluster)
Get boundaries for pixel map representation of cluster.
tick_as<> tick
Tick number, represented by std::ptrdiff_t.
virtual geo::WireID GetID()
PlaneID_t Plane
Index of the plane within its TPC.
virtual geo::WireID GetID()
Detector simulation of raw signals on wires.
geo::GeometryCore const * fGeometry
double fThreshold
Charge threshold to consider for hits/waveforms etc.
unsigned int fNTdc
Number of tdcs, width of pixel map.
float PeakTime() const
Time of the signal peak, in tick units.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
virtual void ConvertLocaltoGlobal(geo::WireID wireid, unsigned int &globalWire, unsigned int &globalPlane) const
PixelMapProducer for CVN.
unsigned int fNWire
Number of wires, length for pixel maps.
unsigned int fTotHits
Total hits in the pixel map.
void Add(const unsigned int &wire, const double &tdc, const unsigned int &view, const double &pe)
double fTRes
Timing resolution for pixel map.
unsigned int NTdc() const
Width in tdcs.
geo::GeometryCore const * fGeometry
std::vector< std::map< double, double > > Waveform
art framework interface to geometry description
bool fMultipleDrifts
True if making the pixel map requires handling for multiple drift regions.