1 #ifndef RECOTOOL_CFALGOSTARTTIMECOMPAT_CXX 2 #define RECOTOOL_CFALGOSTARTTIMECOMPAT_CXX 34 if(clusters.size()==2)
return -1;
41 if ( clusters.size() != 3 )
47 double startWirecm0 = clusters.at(0)->GetParams().start_point.w;
48 double startTimecm0 = clusters.at(0)->GetParams().start_point.t;
49 int startWire0 = int( startWirecm0 /
_w2cm );
50 unsigned char Pl0 = clusters.at(0)->GetParams().start_point.plane;
53 double startWirecm1 = clusters.at(1)->GetParams().start_point.w;
54 double startTimecm1 = clusters.at(1)->GetParams().start_point.t;
55 int startWire1 = int( startWirecm1 /
_w2cm );
56 unsigned char Pl1 = clusters.at(1)->GetParams().start_point.plane;
59 double startWirecm2 = clusters.at(2)->GetParams().start_point.w;
60 double startTimecm2 = clusters.at(2)->GetParams().start_point.t;
61 int startWire2 = int( startWirecm2 /
_w2cm );
62 unsigned char Pl2 = clusters.at(2)->GetParams().start_point.plane;
68 double yS01, zS01, yS02, zS02, yS12, zS12;
71 bool WireIntersect01 = geo->
ChannelsIntersect( startChan0, startChan1, yS01, zS01);
72 bool WireIntersect02 = geo->
ChannelsIntersect( startChan0, startChan2, yS02, zS02);
73 bool WireIntersect12 = geo->
ChannelsIntersect( startChan1, startChan2, yS12, zS12);
79 double compat01 = 9999, compat02 = 9999, compat12 = 9999;
80 if ( (abs(startTimecm0 - startTimecm1) <
_timeDist)
82 compat01 = 0.01*abs(100*(startTimecm0-startTimecm1));
83 if ( (abs(startTimecm1 - startTimecm2) <
_timeDist)
85 compat12 = 0.01*abs(100*(startTimecm1-startTimecm2));
86 if ( (abs(startTimecm0 - startTimecm2) <
_timeDist)
88 compat02 = 0.01*abs(100*(startTimecm0-startTimecm2));
91 if ( (compat01 > 1000) and (compat02 > 1000) and (compat12 > 1000) ){
92 if (
_verbose ) { std::cout <<
"No compatibility among any 2 planes..." << std::endl; }
99 double bestcompatVal=0;
100 if ( (compat01 < compat02) and (compat01 < compat12) and (compat01 < 9999) ){
102 bestcompatVal = compat01;
104 if ( (compat02 < compat01) and (compat02 < compat12) and (compat02 < 9999) ){
106 bestcompatVal = compat02;
108 if ( (compat12 < compat02) and (compat12 < compat01) and (compat12 < 9999) ){
110 bestcompatVal = compat12;
118 double minWire3rdClus = 9999, minTime3rdClus = 9999;
119 double maxWire3rdClus = 0, maxTime3rdClus = 0;
120 double hitWireTMP, hitTimeTMP;
121 Double_t Start[3] = {-100., 0., 0.};
122 double StartT3rdPlane = 0;
123 double wireStart3rdPlane = 0;
125 std::vector<util::PxHit>
hits;
127 if ( bestcompat == 2 ){
128 StartT3rdPlane = startTimecm2;
132 hits = clusters.at(2)->GetHitVector();
134 if ( bestcompat == 0 ){
135 StartT3rdPlane = startTimecm0;
139 hits = clusters.at(0)->GetHitVector();
141 if ( bestcompat == 1 ){
142 StartT3rdPlane = startTimecm1;
146 hits = clusters.at(1)->GetHitVector();
150 hitWireTMP = h.w/
_w2cm;
152 if ( hitWireTMP < minWire3rdClus ) { minWire3rdClus = hitWireTMP; }
153 if ( hitWireTMP > maxWire3rdClus ) { maxWire3rdClus = hitWireTMP; }
154 if ( hitTimeTMP < minTime3rdClus ) { minTime3rdClus = hitTimeTMP; }
155 if ( hitTimeTMP > maxTime3rdClus ) { maxTime3rdClus = hitTimeTMP; }
157 try { wireStart3rdPlane = geo->
NearestWire( Start, Pl3rd); }
160 std::cout << e.what() << std::endl;
161 std::cout <<
"Exception caught!" << std::endl;
162 wireStart3rdPlane = -1;
166 std::cout <<
"Cluster Start Times:" << std::endl;
167 std::cout <<
"Pl0: " << startTimecm0 <<
"\tPl1: " << startTimecm1 <<
"\tPl2: " << startTimecm2 << std::endl;
168 std::cout <<
"Best Time Separation: " << bestcompatVal << std::endl;
169 std::cout <<
"Third Plane: " << Pl3rd << std::endl;
170 std::cout <<
"Time Range for 3rd plane: [ " << minTime3rdClus <<
", " << maxTime3rdClus <<
" ]" << std::endl;
171 std::cout <<
"Start Time for 3rd Plane: " << StartT3rdPlane << std::endl;
172 std::cout <<
"Reco z,y start point: [ " << Start[2] <<
", " << Start[1] <<
" ]" << std::endl;
173 std::cout <<
"Nearest Wire on 3rd Plane: " << wireStart3rdPlane << std::endl;
174 std::cout <<
"Wire range 3rd Plane: [ " << minWire3rdClus <<
", " << maxWire3rdClus <<
" ]" << std::endl;
178 if ( wireStart3rdPlane == -1 )
181 if ( (wireStart3rdPlane <= maxWire3rdClus) and (wireStart3rdPlane >= minWire3rdClus) and
182 (StartT3rdPlane <= maxTime3rdClus) and (StartT3rdPlane >= minTime3rdClus) ){
183 if (
_verbose) { std::cout <<
"Match OK. Return: " << bestcompatVal << std::endl; }
184 return 1./bestcompatVal;
187 if (
_verbose) { std::cout <<
"\n\n***************************\n" << std::endl; }
Class def header for a class CFAlgoStartTimeCompat.
Double_t TimeToCm() const
bool ChannelsIntersect(raw::ChannelID_t c1, raw::ChannelID_t c2, double &y, double &z) const
Returns an intersection point of two channels.
Double_t WireToCm() const
geo::WireID::WireID_t NearestWire(geo::Point_t const &point, geo::PlaneID const &planeid) const
Returns the index of wire closest to position in the specified TPC.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception