129 art::ServiceHandle<geo::Geometry const> geom;
130 auto const clock_data = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(
evt);
131 auto const det_prop =
132 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(
evt, clock_data);
135 std::vector<art::Ptr<recob::Hit>>
hit;
137 art::FindManyP<recob::Hit> fmh(clusIn,
evt, label);
146 unsigned int numberwires = 0;
147 const unsigned int numbertimesamples = det_prop.ReadOutWindowSize();
148 const float TicksPerBin = numbertimesamples /
fTimeBins;
150 double MatrixAAsum = 0.;
151 double MatrixBBsum = 0.;
152 double MatrixCCsum = 0.;
153 std::vector<double> Cornerness2;
156 double wx[49] = {0.};
157 double wy[49] = {0.};
159 for (
int i = -3; i < 4; ++i) {
160 for (
int j = 3; j > -4; --j) {
168 unsigned int wire = 0;
169 unsigned int wire2 = 0;
170 for (
auto view : geom->Views()) {
171 art::PtrVector<recob::Hit> vHits;
172 art::PtrVector<recob::Cluster>::const_iterator clusterIter = clusIn.begin();
175 while (clusterIter != clusIn.end()) {
176 if ((*clusterIter)->View() == view) {
177 hit = fmh.at(cinctr);
183 if (hit.size() == 0)
continue;
186 numberwires = geom->Cryostat(wid.
Cryostat).TPC(wid.
TPC).Plane(wid.
Plane).Nwires();
187 mf::LogInfo(
"EndPointAlg") <<
" --- endpoints check " << numberwires <<
" " << numbertimesamples
190 std::vector<std::vector<double>> MatrixAsum(numberwires);
191 std::vector<std::vector<double>> MatrixBsum(numberwires);
192 std::vector<std::vector<double>> hit_map(numberwires);
195 std::vector<std::vector<int>> hit_loc(numberwires);
197 std::vector<std::vector<double>> Cornerness(numberwires);
199 for (
unsigned int wi = 0; wi < numberwires; ++wi) {
200 hit_map[wi].resize(fTimeBins, 0);
201 hit_loc[wi].resize(fTimeBins, -1);
202 Cornerness[wi].resize(fTimeBins, 0);
203 MatrixAsum[wi].resize(fTimeBins, 0);
204 MatrixBsum[wi].resize(fTimeBins, 0);
206 for (
unsigned int i = 0; i < hit.size(); ++i) {
207 wire = hit[i]->WireID().Wire;
208 const float center = hit[i]->PeakTime(), sigma = hit[i]->RMS();
209 const int iFirstBin = int((center - 3 * sigma) / TicksPerBin),
210 iLastBin = int((center + 3 * sigma) / TicksPerBin);
211 for (
int iBin = iFirstBin; iBin <= iLastBin; ++iBin) {
212 const float bin_center = iBin * TicksPerBin;
213 hit_map[wire][iBin] +=
Gaussian(bin_center, center, sigma);
218 for (
unsigned int wire = 1; wire < numberwires - 1; ++wire) {
220 for (
int timebin = 1; timebin < fTimeBins - 1; ++timebin) {
221 MatrixAsum[wire][timebin] = 0.;
222 MatrixBsum[wire][timebin] = 0.;
224 for (
int i = -3; i <= 3; ++i) {
226 if (windex < 0) windex = 0;
228 else if ((
unsigned int)windex >= numberwires)
229 windex = numberwires - 1;
231 for (
int j = -3; j <= 3; ++j) {
232 tindex = timebin + j;
235 else if (tindex >= fTimeBins)
236 tindex = fTimeBins - 1;
238 MatrixAsum[wire][timebin] += wx[
n] * hit_map[windex][tindex];
239 MatrixBsum[wire][timebin] += wy[
n] * hit_map[windex][tindex];
247 for (
unsigned int wire = 1; wire < numberwires - 1; ++wire) {
249 for (
int timebin = 1; timebin < fTimeBins - 1; ++timebin) {
255 for (
int i = -3; i <= 3; ++i) {
257 if (windex < 0) windex = 0;
259 else if ((
unsigned int)windex >= numberwires)
260 windex = numberwires - 1;
262 for (
int j = -3; j <= 3; ++j) {
263 tindex = timebin + j;
266 else if (tindex >= fTimeBins)
267 tindex = fTimeBins - 1;
269 MatrixAAsum += w[
n] * pow(MatrixAsum[windex][tindex], 2);
270 MatrixBBsum += w[
n] * pow(MatrixBsum[windex][tindex], 2);
271 MatrixCCsum += w[
n] * MatrixAsum[windex][tindex] * MatrixBsum[windex][tindex];
276 if ((MatrixAAsum + MatrixBBsum) > 0)
277 Cornerness[wire][timebin] =
278 (MatrixAAsum * MatrixBBsum - pow(MatrixCCsum, 2)) / (MatrixAAsum + MatrixBBsum);
280 Cornerness[wire][timebin] = 0;
282 if (Cornerness[wire][timebin] > 0) {
283 for (
unsigned int i = 0; i < hit.size(); ++i) {
284 wire2 = hit[i]->WireID().Wire;
286 if (wire == wire2 &&
std::abs(hit[i]->TimeDistanceAsRMS(
287 timebin * (numbertimesamples / fTimeBins))) < 1.) {
289 hit_loc[wire][timebin] = i;
290 Cornerness2.push_back(Cornerness[wire][timebin]);
298 std::sort(Cornerness2.rbegin(), Cornerness2.rend());
300 for (
int vertexnum = 0; vertexnum <
fMaxCorners; ++vertexnum) {
302 for (
unsigned int wire = 0; wire < numberwires && flag == 0; ++wire) {
303 for (
int timebin = 0; timebin < fTimeBins && flag == 0; ++timebin) {
304 if (Cornerness2.size() > (
unsigned int)vertexnum)
305 if (Cornerness[wire][timebin] == Cornerness2[vertexnum] &&
306 Cornerness[wire][timebin] > 0. && hit_loc[wire][timebin] > -1) {
310 if (Cornerness2.size())
311 if (Cornerness[wire][timebin] < (
fThreshold * Cornerness2[0]))
312 vertexnum = fMaxCorners;
313 vHits.push_back(hit[hit_loc[wire][timebin]]);
317 for (
size_t vh = 0; vh < vHits.size(); ++vh)
318 totalQ += vHits[vh]->Integral();
321 hit[hit_loc[wire][timebin]]->
WireID(),
322 Cornerness[wire][timebin],
326 vtxcol.push_back(endpoint);
327 vtxHitsOut.push_back(vHits);
335 double drifttick = det_prop.DriftVelocity(det_prop.Efield(), det_prop.Temperature());
337 double wirepitch = geom->WirePitch();
338 double corrfactor = drifttick / wirepitch;
342 (
int)((
fWindow * (numbertimesamples / fTimeBins) * corrfactor) + .5);
344 (int)wire + (
int)((
fWindow * (numbertimesamples /
fTimeBins) * corrfactor) + .5);
346 for (
int timebinout = timebin -
fWindow; timebinout <= timebin +
fWindow;
348 if (std::sqrt(pow(wire - wireout, 2) + pow(timebin - timebinout, 2)) <
350 Cornerness[wireout][timebinout] = 0;
359 if (clusterIter != clusIn.end()) clusterIter++;
362 unsigned char* outPix =
new unsigned char[fTimeBins * numberwires];
369 for (
unsigned int x = 0;
x < numberwires; ++
x) {
370 cell = (int)(hit_map[
x][
y] * 1000);
371 if (cell > maxCell) { maxCell = cell; }
375 for (
unsigned int x = 0;
x < numberwires; ++
x) {
377 if (maxCell > 0) pix = (int)((1500000 * hit_map[
x][
y]) / maxCell);
378 outPix[y * numberwires +
x] = pix;
384 for (
unsigned int ii = 0; ii < vtxcol.size(); ++ii) {
385 if (vtxcol[ii].View() == (
unsigned int)view) {
387 outPix[(int)(vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) * numberwires +
388 vtxcol[ii].WireID().Wire] = pix;
389 outPix[(int)(vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) * numberwires +
390 vtxcol[ii].WireID().Wire - 1] = pix;
391 outPix[(int)(vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) * numberwires +
392 vtxcol[ii].WireID().Wire + 1] = pix;
393 outPix[(int)((vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) - 1) *
395 vtxcol[ii].
WireID().Wire] = pix;
396 outPix[(int)((vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) + 1) *
398 vtxcol[ii].
WireID().Wire] = pix;
399 outPix[(int)((vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) - 1) *
401 vtxcol[ii].
WireID().Wire - 1] = pix;
402 outPix[(int)((vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) - 1) *
404 vtxcol[ii].
WireID().Wire - 2] = pix;
405 outPix[(int)((vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) + 1) *
407 vtxcol[ii].
WireID().Wire + 1] = pix;
408 outPix[(int)((vtxcol[ii].DriftTime() * (fTimeBins / numbertimesamples)) + 1) *
410 vtxcol[ii].
WireID().Wire + 2] = pix;
422 return vtxcol.size();
process_name opflash particleana ie x
then echo unknown compiler flag
CryostatID_t Cryostat
Index of cryostat.
void VSSaveBMPFile(const char *fileName, unsigned char *pix, int dx, int dy) const
process_name opflash particleana ie ie y
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
PlaneID_t Plane
Index of the plane within its TPC.
double GaussianDerivativeY(int x, int y) const
double Gaussian(int x, int y, double sigma) const
double GaussianDerivativeX(int x, int y) const
TPCID_t TPC
Index of the TPC within its cryostat.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.