125 double Angle = geom->
Plane(1).
Wire(0).
ThetaZ(
false) - TMath::Pi() / 2.;
133 double Efield_drift = detProp.Efield();
134 double Temperature = detProp.Temperature();
137 double driftvelocity = detProp.DriftVelocity(Efield_drift, Temperature);
140 double timepitch = driftvelocity * timetick;
146 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii) {
154 std::unique_ptr<std::vector<recob::Vertex>> vcol(
new std::vector<recob::Vertex>);
155 std::unique_ptr<std::vector<recob::EndPoint2D>> epcol(
156 new std::vector<recob::EndPoint2D>);
157 std::unique_ptr<art::Assns<recob::EndPoint2D, recob::Hit>> assnep(
159 std::unique_ptr<art::Assns<recob::Vertex, recob::Shower>> assnsh(
161 std::unique_ptr<art::Assns<recob::Vertex, recob::Track>> assntr(
163 std::unique_ptr<art::Assns<recob::Vertex, recob::Hit>> assnh(
168 int nplanes = geom->
Views().size();
170 std::vector<std::vector<int>> Cls(nplanes);
171 std::vector<std::vector<CluLen>> clulens(nplanes);
173 std::vector<double> dtdwstart;
176 for (
size_t iclu = 0; iclu < clusters.
size(); ++iclu) {
178 float w0 = clusters[iclu]->StartWire();
179 float w1 = clusters[iclu]->EndWire();
180 float t0 = clusters[iclu]->StartTick();
181 float t1 = clusters[iclu]->EndTick();
185 clulen.length =
std::hypot((w0 - w1) * wire_pitch,
186 detProp.ConvertTicksToX(t0, clusters[iclu]->View(), 0, 0) -
187 detProp.ConvertTicksToX(t1, clusters[iclu]->View(), 0, 0));
189 switch (clusters[iclu]->
View()) {
191 case geo::kU: clulens[0].push_back(clulen);
break;
192 case geo::kV: clulens[1].push_back(clulen);
break;
193 case geo::kZ: clulens[2].push_back(clulen);
break;
197 std::vector<double> wires;
198 std::vector<double> times;
200 std::vector<art::Ptr<recob::Hit>>
hit = fmh.at(iclu);
201 std::sort(hit.begin(), hit.end(),
SortByWire());
203 for (
size_t i = 0; i < hit.size(); ++i) {
205 times.push_back(hit[i]->PeakTime());
209 TGraph* the2Dtrack =
new TGraph(
std::min(10, n), &wires[0], ×[0]);
211 the2Dtrack->Fit(
"pol1",
"Q");
212 TF1* pol1 = (TF1*)the2Dtrack->GetFunction(
"pol1");
214 pol1->GetParameters(par);
215 dtdwstart.push_back(par[1]);
220 dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
226 dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
230 for (
size_t i = 0; i < clulens.size(); ++i) {
231 std::sort(clulens[i].
begin(), clulens[i].
end(), myfunction);
232 for (
size_t j = 0; j < clulens[i].size(); ++j) {
233 Cls[i].push_back(clulens[i][j].
index);
237 std::vector<std::vector<int>> cluvtx(nplanes);
238 std::vector<double> vtx_w;
239 std::vector<double> vtx_t;
241 for (
int i = 0; i < nplanes; ++i) {
242 if (Cls[i].
size() >= 1) {
258 for (
unsigned j = 0; j < Cls[i].size(); ++j) {
259 double lclu = std::sqrt(
260 pow((clusters[Cls[i][j]]->StartWire() - clusters[Cls[i][j]]->EndWire()) * 13.5, 2) +
261 pow(clusters[Cls[i][j]]->StartTick() - clusters[Cls[i][j]]->EndTick(), 2));
263 bool deltaraylike =
false;
264 bool enoughhits =
false;
266 double wb = clusters[Cls[i][j]]->StartWire();
267 double we = clusters[Cls[i][j]]->EndWire();
268 double tt = clusters[Cls[i][j]]->StartTick();
269 double dtdw = dtdwstart[Cls[i][j]];
270 int nhits = fmh.at(Cls[i][j]).size();
271 ww0 = (tt - tt1 + dtdw1 * wb1 - dtdw *
wb) / (dtdw1 - dtdw);
273 if ((!rev && ww0 > wb1 + 15) || (rev && ww0 < we1 - 15)) deltaraylike =
true;
274 if (((!rev && ww0 > wb1 + 10) || (rev && ww0 < we1 - 10)) && nhits < 5)
276 if (wb > wb1 + 20 && nhits < 20) deltaraylike =
true;
277 if (wb > wb1 + 50 && nhits < 20) deltaraylike =
true;
278 if (wb > wb1 + 8 && TMath::Abs(dtdw1 - dtdw) < 0.15) deltaraylike =
true;
279 if (
std::abs(wb - wb1) > 30 &&
std::abs(we - we1) > 30) deltaraylike =
true;
284 double alpha = std::atan(dtdw);
285 if (nhits >=
int(2 + 3 * (1 -
std::abs(std::cos(alpha))))) enoughhits =
true;
286 if (nhits < 5 && (ww0 < wb1 - 20 || ww0 > we1 + 20)) enoughhits =
false;
290 if (c1 != -1 && c2 != -1) {
291 double wb = clusters[Cls[i][j]]->StartWire();
292 double we = clusters[Cls[i][j]]->EndWire();
293 ww0 = (tt2 - tt1 + dtdw1 * wb1 - dtdw2 * wb2) / (dtdw1 - dtdw2);
300 if (c1 != -1 && !deltaraylike && enoughhits) {
310 wb1 = clusters[Cls[i][j]]->StartWire();
311 we1 = clusters[Cls[i][j]]->EndWire();
312 tt1 = clusters[Cls[i][j]]->StartTick();
314 wb1 = clusters[Cls[i][j]]->EndWire();
315 we1 = clusters[Cls[i][j]]->StartWire();
316 tt1 = clusters[Cls[i][j]]->EndTick();
318 dtdw1 = dtdwstart[Cls[i][j]];
320 else if (lclu2 < lclu) {
321 if (!deltaraylike && enoughhits && replace) {
324 wb2 = clusters[Cls[i][j]]->StartWire();
325 we2 = clusters[Cls[i][j]]->EndWire();
326 tt2 = clusters[Cls[i][j]]->StartTick();
327 dtdw2 = dtdwstart[Cls[i][j]];
331 if (c1 != -1 && c2 != -1) {
332 cluvtx[i].push_back(c1);
333 cluvtx[i].push_back(c2);
335 double w1 = clusters[
c1]->StartWire();
336 double t1 = clusters[
c1]->StartTick();
337 if (clusters[c1]->StartWire() > clusters[c1]->EndWire()) {
338 w1 = clusters[
c1]->EndWire();
339 t1 = clusters[
c1]->EndTick();
341 double k1 = dtdwstart[
c1];
342 double w2 = clusters[c2]->StartWire();
343 double t2 = clusters[c2]->StartTick();
344 if (clusters[c2]->StartWire() > clusters[c2]->EndWire()) {
345 w1 = clusters[c2]->EndWire();
346 t1 = clusters[c2]->EndTick();
348 double k2 = dtdwstart[c2];
355 double t0 = (k1 * k2 * (w1 - w2) + k1 * t2 - k2 * t1) / (k1 - k2);
356 double w0 = (t2 - t1 + k1 * w1 - k2 * w2) / (k1 - k2);
361 else if (Cls[i].
size() >= 1) {
363 cluvtx[i].push_back(c1);
364 vtx_w.push_back(wb1);
365 vtx_t.push_back(tt1);
368 cluvtx[i].push_back(Cls[i][0]);
369 vtx_w.push_back(clusters[Cls[i][0]]->StartWire());
370 vtx_t.push_back(clusters[Cls[i][0]]->StartTick());
377 std::vector<art::Ptr<recob::Hit>> hits = fmh.at(Cls[i][0]);
379 for (
size_t h = 0;
h < hits.size(); ++
h)
380 totalQ += hits[
h]->Integral();
385 (
unsigned int)vtx_w.back());
391 clusters[Cls[i][0]]->View(),
405 Double_t vtxcoord[3];
406 if (Cls[0].
size() > 0 && Cls[1].
size() > 0) {
407 double Iw0 = (vtx_w[0] + 3.95) * wire_pitch;
408 double Cw0 = (vtx_w[1] + 1.84) * wire_pitch;
410 double It0 = vtx_t[0] - presamplings;
412 double Ct0 = vtx_t[1] - presamplings;
414 vtxcoord[0] = detProp.ConvertTicksToX(vtx_t[1], 1, 0, 0);
415 vtxcoord[1] = (Cw0 - Iw0) / (2. * std::sin(Angle));
416 vtxcoord[2] = (Cw0 + Iw0) / (2. * std::cos(Angle)) - YC / 2. * std::tan(Angle);
419 if (vtx_w[0] >= 0 && vtx_w[0] <= 239 && vtx_w[1] >= 0 && vtx_w[1] <= 239) {
430 vtxcoord[0] = -99999;
431 vtxcoord[1] = -99999;
432 vtxcoord[2] = -99999;
435 dtIC->Fill(It0 - Ct0);
438 vtxcoord[0] = -99999;
439 vtxcoord[1] = -99999;
440 vtxcoord[2] = -99999;
449 vcol->push_back(the3Dvertex);
457 for (
size_t i = 0; i < epcol->size(); ++i)
459 for (
size_t i = 0; i < vcol->size(); ++i)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
code to link reconstructed objects back to the MC truth information
std::string fClusterModuleLabel
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
AdcChannelData::View View
WireGeo const & Wire(unsigned int iwire) const
std::set< geo::View_t > const & Views() const
Returns a list of possible views in the detector.
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
Planes which measure Z direction.
Definition of vertex object for LArSoft.
double ThetaZ() const
Returns angle of wire with respect to z axis in the Y-Z plane in radians.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void push_back(Ptr< U > const &p)
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
Detector simulation of raw signals on wires.
Q_EXPORT QTSManip setw(int w)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
#define MF_LOG_VERBATIM(category)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
int trigger_offset(DetectorClocksData const &data)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
recob::tracking::Plane Plane
Q_EXPORT QTSManip setfill(int f)
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.