54 #include "TGeoManager.h" 103 this->reconfigure(pset);
104 produces< std::vector<recob::Vertex> >();
105 produces< std::vector<recob::EndPoint2D> >();
106 produces< art::Assns<recob::EndPoint2D, recob::Hit> >();
107 produces< art::Assns<recob::Vertex, recob::Hit> >();
108 produces< art::Assns<recob::Vertex, recob::Shower> >();
109 produces< art::Assns<recob::Vertex, recob::Track> >();
112 VertexFinder2D::~VertexFinder2D()
119 fClusterModuleLabel = p.
get< std::string >(
"ClusterModuleLabel");
126 dtIC = tfs->
make<TH1D>(
"dtIC",
"It0-Ct0",100,-5,5);
150 double Efield_drift = detprop->
Efield();
154 double driftvelocity = detprop->
DriftVelocity(Efield_drift,Temperature);
157 double timepitch = driftvelocity*timetick;
160 evt.
getByLabel(fClusterModuleLabel,clusterListHandle);
163 for (
unsigned int ii = 0; ii < clusterListHandle->size(); ++ii){
171 std::unique_ptr<std::vector<recob::Vertex> > vcol(
new std::vector<recob::Vertex>);
172 std::unique_ptr<std::vector<recob::EndPoint2D> > epcol(
new std::vector<recob::EndPoint2D>);
180 int nplanes = geom->
Views().size();
182 std::vector< std::vector<int> > Cls(nplanes);
183 std::vector< std::vector<CluLen> > clulens(nplanes);
185 std::vector<double> dtdwstart;
188 for(
size_t iclu = 0; iclu < clusters.
size(); ++iclu){
190 float w0 = clusters[iclu]->StartWire();
191 float w1 = clusters[iclu]->EndWire();
192 float t0 = clusters[iclu]->StartTick();
193 float t1 = clusters[iclu]->EndTick();
201 switch(clusters[iclu]->View()){
204 clulens[0].push_back(clulen);
207 clulens[1].push_back(clulen);
210 clulens[2].push_back(clulen);
216 std::vector<double> wires;
217 std::vector<double> times;
219 std::vector< art::Ptr<recob::Hit> >
hit = fmh.at(iclu);
220 std::sort(hit.begin(), hit.end(),
SortByWire());
222 for(
size_t i = 0; i < hit.size(); ++i){
223 wires.push_back(hit[i]->WireID().Wire);
224 times.push_back(hit[i]->PeakTime());
228 TGraph *the2Dtrack =
new TGraph(
std::min(10,n),&wires[0],×[0]);
230 the2Dtrack->Fit(
"pol1",
"Q");
231 TF1 *pol1=(TF1*) the2Dtrack->GetFunction(
"pol1");
233 pol1->GetParameters(par);
235 dtdwstart.push_back(par[1]);
240 dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
245 else dtdwstart.push_back(std::tan(clusters[iclu]->StartAngle()));
250 for (
size_t i = 0; i<clulens.size(); ++i){
252 for (
size_t j = 0; j<clulens[i].size(); ++j){
253 Cls[i].push_back(clulens[i][j].
index);
257 std::vector< std::vector<int> > cluvtx(nplanes);
258 std::vector<double> vtx_w;
259 std::vector<double> vtx_t;
261 for (
int i = 0; i < nplanes; ++i){
262 if (Cls[i].size() >= 1){
278 for (
unsigned j = 0; j<Cls[i].size(); ++j){
279 double lclu = std::sqrt(pow((clusters[Cls[i][j]]->StartWire()-clusters[Cls[i][j]]->EndWire())*13.5,2)
280 +pow(clusters[Cls[i][j]]->StartTick()-clusters[Cls[i][j]]->EndTick(),2));
282 bool deltaraylike =
false;
283 bool enoughhits =
false;
285 double wb = clusters[Cls[i][j]]->StartWire();
286 double we = clusters[Cls[i][j]]->EndWire();
287 double tt = clusters[Cls[i][j]]->StartTick();
288 double dtdw = dtdwstart[Cls[i][j]];
289 int nhits = fmh.at(Cls[i][j]).size();
290 ww0 = (tt-tt1+dtdw1*wb1-dtdw*wb)/(dtdw1-dtdw);
291 if (std::abs(wb1-ww0) > std::abs(we1-ww0)) rev =
true;
292 if ((!rev && ww0 > wb1+15)||(rev && ww0 < we1-15)) deltaraylike =
true;
293 if (((!rev && ww0 > wb1+10)||(rev && ww0 < we1-10)) && nhits < 5) deltaraylike =
true;
294 if (wb > wb1+20 && nhits < 20) deltaraylike =
true;
295 if (wb > wb1+50 && nhits < 20) deltaraylike =
true;
296 if (wb > wb1+8 && TMath::Abs(dtdw1-dtdw) < 0.15) deltaraylike =
true;
297 if (std::abs(wb-wb1) > 30 && std::abs(we-we1) > 30) deltaraylike =
true;
298 if (std::abs(tt-tt1) > 100) deltaraylike =
true;
301 double alpha = std::atan(dtdw);
302 if (nhits >=
int(2+3*(1-std::abs(std::cos(alpha))))) enoughhits =
true;
303 if (nhits < 5 && (ww0 < wb1-20 || ww0 > we1+20)) enoughhits =
false;
308 if (c1 != -1 && c2 != -1){
309 double wb = clusters[Cls[i][j]]->StartWire();
310 double we = clusters[Cls[i][j]]->EndWire();
311 ww0 = (tt2-tt1+dtdw1*wb1-dtdw2*wb2)/(dtdw1-dtdw2);
312 if ((std::abs(ww0-wb1) < 10 || std::abs(ww0-we1) < 10) &&
313 (std::abs(ww0-wb2) < 10 || std::abs(ww0-we2) < 10)){
314 if (std::abs(ww0-wb) > 15 && std::abs(ww0-we) > 15) replace =
false;
319 if (c1 != -1 && !deltaraylike && enoughhits){
329 wb1 = clusters[Cls[i][j]]->StartWire();
330 we1 = clusters[Cls[i][j]]->EndWire();
331 tt1 = clusters[Cls[i][j]]->StartTick();
333 wb1 = clusters[Cls[i][j]]->EndWire();
334 we1 = clusters[Cls[i][j]]->StartWire();
335 tt1 = clusters[Cls[i][j]]->EndTick();
337 dtdw1 = dtdwstart[Cls[i][j]];
339 else if (lclu2 < lclu){
340 if (!deltaraylike && enoughhits && replace){
343 wb2 = clusters[Cls[i][j]]->StartWire();
344 we2 = clusters[Cls[i][j]]->EndWire();
345 tt2 = clusters[Cls[i][j]]->StartTick();
346 dtdw2 = dtdwstart[Cls[i][j]];
350 if (c1 != -1 && c2 != -1){
351 cluvtx[i].push_back(c1);
352 cluvtx[i].push_back(c2);
354 double w1 = clusters[
c1]->StartWire();
355 double t1 = clusters[
c1]->StartTick();
356 if (clusters[c1]->StartWire()>clusters[c1]->EndWire()){
357 w1 = clusters[
c1]->EndWire();
358 t1 = clusters[
c1]->EndTick();
360 double k1 = dtdwstart[
c1];
361 double w2 = clusters[
c2]->StartWire();
362 double t2 = clusters[
c2]->StartTick();
363 if (clusters[c2]->StartWire()>clusters[c2]->EndWire()){
364 w1 = clusters[
c2]->EndWire();
365 t1 = clusters[
c2]->EndTick();
367 double k2 = dtdwstart[
c2];
371 if (std::abs(k1-k2) < 0.5){
376 double t0 = (k1*k2*(w1-w2)+k1*t2-k2*t1)/(k1-k2);
377 double w0 = (t2-t1+k1*w1-k2*w2)/(k1-k2);
382 else if (Cls[i].size() >= 1){
384 cluvtx[i].push_back(c1);
385 vtx_w.push_back(wb1);
386 vtx_t.push_back(tt1);
389 cluvtx[i].push_back(Cls[i][0]);
390 vtx_w.push_back(clusters[Cls[i][0]]->StartWire());
391 vtx_t.push_back(clusters[Cls[i][0]]->StartTick());
398 std::vector< art::Ptr<recob::Hit> >
hits = fmh.at(Cls[i][0]);
400 for(
size_t h = 0; h < hits.size(); ++h) totalQ += hits[h]->Integral();
403 hits[0]->WireID().TPC,
404 hits[0]->WireID().
Plane,
405 (
unsigned int)vtx_w.back());
411 clusters[Cls[i][0]]->View(),
426 Double_t vtxcoord[3];
427 if (Cls[0].size()>0&&Cls[1].size()>0){
428 double Iw0 = (vtx_w[0]+3.95)*wire_pitch;
429 double Cw0 = (vtx_w[1]+1.84)*wire_pitch;
431 double It0 = vtx_t[0] - presamplings;
433 double Ct0 = vtx_t[1] - presamplings ;
436 vtxcoord[1] = (Cw0-Iw0)/(2.*std::sin(Angle));
437 vtxcoord[2] = (Cw0+Iw0)/(2.*std::cos(Angle))-YC/2.*std::tan(Angle);
440 if(vtx_w[0]>=0&&vtx_w[0]<=239&&vtx_w[1]>=0&&vtx_w[1]<=239){
450 vtxcoord[0] = -99999;
451 vtxcoord[1] = -99999;
452 vtxcoord[2] = -99999;
458 vtxcoord[0] = -99999;
459 vtxcoord[1] = -99999;
460 vtxcoord[2] = -99999;
469 vcol->push_back(the3Dvertex);
471 if(vShowers_vec.
size() > 0){
481 if(vTracks_vec.
size() > 0){
491 LOG_VERBATIM(
"Summary") << std::setfill(
'-') << std::setw(175) <<
"-" << std::setfill(
' ');
493 for(
size_t i = 0; i<epcol->size(); ++i)
LOG_VERBATIM(
"Summary") << epcol->at(i) ;
494 for(
size_t i = 0; i<vcol->size(); ++i)
LOG_VERBATIM(
"Summary") << vcol->at(i) ;
496 evt.
put(std::move(epcol));
497 evt.
put(std::move(vcol));
498 evt.
put(std::move(assnep));
499 evt.
put(std::move(assntr));
500 evt.
put(std::move(assnsh));
501 evt.
put(std::move(assnh));
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.
Encapsulate the construction of a single cyostat.
virtual int TriggerOffset() const =0
WireGeo const & Wire(unsigned int iwire) const
Declaration of signal hit object.
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.
virtual double SamplingRate() const =0
Returns the period of the TPC readout electronics clock.
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.
bool myfunction(CluLen c1, CluLen c2)
ProductID put(std::unique_ptr< PROD > &&product)
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
#define DEFINE_ART_MODULE(klass)
Provides recob::Track data product.
void push_back(Ptr< U > const &p)
virtual double Temperature() const =0
T get(std::string const &key) const
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
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.
Declaration of cluster object.
bool SortByWire(art::Ptr< recob::Hit > const &h1, art::Ptr< recob::Hit > const &h2)
Detector simulation of raw signals on wires.
Encapsulate the geometry of a wire.
virtual double ConvertTicksToX(double ticks, int p, int t, int c) const =0
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
T * make(ARGS...args) const
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
#define LOG_VERBATIM(category)
virtual double Efield(unsigned int planegap=0) const =0
Returns the nominal electric field in the specified volume.
recob::tracking::Plane Plane
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
art framework interface to geometry description
Encapsulate the construction of a single detector plane.
std::string GetLArTPCVolumeName(geo::TPCID const &tpcid) const
Return the name of specified LAr TPC volume.