48 auto ROIs = fWire.SignalROI();
49 if (!(ROIs.get_ranges().size()))
return ret;
51 for (
auto iROI = ROIs.begin_range(); iROI != ROIs.end_range(); ++iROI) {
53 std::map<double, double> pulse;
54 for (
int tick = ROI.begin_index();
tick < (int)ROI.end_index();
tick++) {
56 pulse.insert(std::pair<double, double>((
double)
tick, (
double)ROI[tick]));
66 std::vector<geo::WireID> wireids = fWireReadoutGeom->ChannelToWire(fWire.Channel());
67 if (!wireids.size())
return ret;
70 if (wireids.size() > 1) {
71 for (
auto iwire : wireids)
72 if (iwire.Plane == fWire.View()) ret = iwire;
80 auto& ROIs = fSimchan.TDCIDEMap();
81 if (!(ROIs.size()))
return ret;
83 for (
auto iROI = ROIs.begin(); iROI != ROIs.end(); ++iROI) {
85 auto tick = ROI.first;
86 double charge = 0.005 * fSimchan.Charge(
tick);
89 ret.push_back(std::map<double, double>({{(double)
tick, charge}}));
96 std::vector<geo::WireID> wireids = fWireReadoutGeom->ChannelToWire(fSimchan.Channel());
97 if (wireids.empty())
return {};
101 template <
class T,
class U>
106 : fNWire(nWire), fNTdc(nTdc), fTRes(tRes),
fThreshold(threshold), fMultipleDrifts(false)
109 template <
class T,
class U>
111 :
fNWire(pset.
get<unsigned int>(
"WireLength"))
112 ,
fNTdc(pset.
get<unsigned int>(
"TdcWidth"))
113 ,
fTRes(pset.
get<double>(
"TimeResolution"))
118 template <
class T,
class U>
122 std::vector<const T*> newCluster;
124 newCluster.push_back(
hit.get());
129 template <
class T,
class U>
131 const std::vector<const T*>&
cluster)
137 template <
class T,
class U>
140 const std::vector<const T*>&
cluster,
145 for (
size_t iHit = 0; iHit < cluster.size(); ++iHit) {
148 Waveform wf = wraphit.GetWaveform();
151 unsigned int tempWire = wireid.
Wire;
152 unsigned int tempPlane = wireid.
Plane;
156 for (
auto& pulse : wf) {
158 for (
auto& i : pulse) {
159 const double pe = i.second;
160 double temptdc = i.first;
164 const unsigned int wire = tempWire;
165 const unsigned int wirePlane = tempPlane;
166 const double tdc = temptdc;
168 pm.
Add(wire, tdc, wirePlane, pe);
176 template <
class T,
class U>
177 std::ostream& operator<<(std::ostream& os, const PixelMapProducer<T, U>& p)
179 os <<
"PixelMapProducer: " << p.
NTdc() <<
" tdcs X " << p.NWire() <<
" wires";
183 template <
class T,
class U>
185 const std::vector<const T*>&
cluster)
187 std::vector<double> tmin_0;
188 std::vector<double> tmin_1;
189 std::vector<double> tmin_2;
191 std::vector<int> wire_0, bwire_0;
192 std::vector<int> wire_1, bwire_1;
193 std::vector<int> wire_2, bwire_2;
195 std::vector<double> tsum = {0., 0., 0.};
196 std::vector<double> tsize = {0., 0., 0.};
198 for (
size_t iHit = 0; iHit < cluster.size(); ++iHit) {
200 Waveform wf = wraphit.GetWaveform();
203 unsigned int tempWire = wireid.
Wire;
204 unsigned int tempPlane = wireid.
Plane;
208 for (
auto& pulse : wf) {
209 double min_tick = (double)INT_MAX;
210 for (
auto& i : pulse) {
211 double temptdc = i.first;
216 if (temptdc < min_tick) min_tick = temptdc;
218 tsum[tempPlane] += temptdc;
219 tsize[tempPlane] += 1.;
222 if (!(pulse.empty())) {
223 if (tempPlane == 0) {
224 tmin_0.push_back(min_tick);
225 wire_0.push_back(tempWire);
227 if (tempPlane == 1) {
228 tmin_1.push_back(min_tick);
229 wire_0.push_back(tempWire);
231 if (tempPlane == 2) {
232 tmin_2.push_back(min_tick);
233 wire_0.push_back(tempWire);
239 double tmean_0 = tsum[0] / tsize[0];
240 double tmean_1 = tsum[1] / tsize[1];
241 double tmean_2 = tsum[2] / tsize[2];
243 for (
int i = 0; i < (int)wire_0.size(); i++) {
244 if (
std::abs(tmin_0[i] - tmean_0) < (double)
fTRes) bwire_0.push_back(wire_0[i]);
246 for (
int i = 0; i < (int)wire_1.size(); i++) {
247 if (
std::abs(tmin_1[i] - tmean_1) < (double)
fTRes) bwire_1.push_back(wire_1[i]);
249 for (
int i = 0; i < (int)wire_2.size(); i++) {
250 if (
std::abs(tmin_2[i] - tmean_2) < (double)
fTRes) bwire_2.push_back(wire_2[i]);
253 std::cout <<
"Boundary wire vector sizes: " << bwire_0.size() <<
", " << bwire_1.size() <<
", " 254 << bwire_2.size() << std::endl;
259 auto minwireelement_0 = std::min_element(bwire_0.begin(), bwire_0.end());
260 auto minwireelement_1 = std::min_element(bwire_1.begin(), bwire_1.end());
261 auto minwireelement_2 = std::min_element(bwire_2.begin(), bwire_2.end());
263 if (bwire_0.size() > 0) {
264 minwire_0 = *minwireelement_0 - 1;
265 std::cout <<
"minwire 0: " << (*minwireelement_0 - 1) << std::endl;
267 if (bwire_1.size() > 0) {
268 minwire_1 = *minwireelement_1 - 1;
269 std::cout <<
"minwire 1: " << (*minwireelement_1 - 1) << std::endl;
271 if (bwire_2.size() > 0) {
272 minwire_2 = *minwireelement_2 - 1;
273 std::cout <<
"minwire 2: " << (*minwireelement_2 - 1) << std::endl;
276 fTotHits = bwire_0.size() + bwire_1.size() + bwire_2.size();
278 return Boundary(
fNWire,
fTRes, minwire_0, minwire_1, minwire_2, tmean_0, tmean_1, tmean_2);
281 template <
class T,
class U>
283 unsigned int& globalWire,
284 unsigned int& globalPlane)
const 286 globalWire = wireid.
Wire;
287 globalPlane = wireid.
Plane;
290 template <
class T,
class U>
293 unsigned int& globalWire,
294 unsigned int& globalPlane,
295 double& globalTDC)
const 297 globalWire = wireid.
Wire;
298 globalPlane = wireid.
Plane;
299 globalTDC = localTDC;
virtual PixelMap CreateMap(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< T >> &cluster)
virtual geo::WireID GetID()
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 the physical detector geometry.
static constexpr auto first()
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()
PixelMapProducer()=default
PlaneID_t Plane
Index of the plane within its TPC.
virtual geo::WireID GetID()
Detector simulation of raw signals on wires.
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.
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.