Run disambiguation as currently configured.
69 std::vector<std::vector<art::Ptr<recob::Hit> > > hitsUV(2);
70 std::vector<art::Ptr<recob::Hit> > hitsZ;
76 for (
size_t i = 0; i<OrigHits.size(); ++i){
77 switch (OrigHits[i]->
View()){
79 hitsUV[0].push_back(OrigHits[i]);
88 hitsUV[1].push_back(OrigHits[i]);
97 hitsZ.push_back(OrigHits[i]);
107 <<
": hit view unkonw. \n";
114 std::vector<std::map<unsigned int, unsigned int> >fHasBeenDisambigedUV(2);
115 const unsigned int ntpc = geo->
NTPC();
117 std::vector<std::vector<art::Ptr<recob::Hit> > > allhitsu(ntpc);
118 std::vector<std::vector<art::Ptr<recob::Hit> > > allhitsv(ntpc);
119 std::vector<std::vector<art::Ptr<recob::Hit> > > allhitsz(ntpc);
120 std::vector<std::vector<geo::WireID> > wireidsu(ntpc);
121 std::vector<std::vector<geo::WireID> > wireidsv(ntpc);
123 std::vector<std::vector<unsigned int> > cluidu(ntpc);
124 std::vector<std::vector<unsigned int> > cluidv(ntpc);
125 std::vector<std::vector<unsigned int> > bestwireidu(ntpc);
126 std::vector<std::vector<unsigned int> > bestwireidv(ntpc);
131 for (
size_t z = 0;
z<hitsZ.size(); ++
z){
133 unsigned int apaz(0), cryoz(0);
136 double tz = hitsZ[
z]->PeakTime()
141 bool findmatch =
false;
142 for (
size_t u = 0; u<hitsUV[0].size() && !findmatch; ++u){
143 if (fHasBeenDisambigedUV[0].find(u)!=fHasBeenDisambigedUV[0].end())
continue;
144 unsigned int apau(0), cryou(0);
146 if (apau!=apaz)
continue;
147 double tu = hitsUV[0][u]->PeakTime()
148 - detProp.GetXTicksOffset(0,
154 for (
size_t v = 0; v<hitsUV[1].size(); ++v){
155 if (fHasBeenDisambigedUV[1].find(v)!=fHasBeenDisambigedUV[1].end())
continue;
156 unsigned int apav(0), cryov(0);
158 if (apav!=apaz)
continue;
159 double tv = hitsUV[1][v]->PeakTime()
160 - detProp.GetXTicksOffset(1,
168 std::vector<geo::WireID> uwires = geo->
ChannelToWire(hitsUV[0][u]->Channel());
169 std::vector<geo::WireID> vwires = geo->
ChannelToWire(hitsUV[1][v]->Channel());
171 unsigned int totalintersections = 0;
172 unsigned int bestu = 0;
173 unsigned int bestv = 0;
175 for (
size_t uw = 0; uw<uwires.size(); ++uw){
176 for (
size_t vw = 0; vw<vwires.size(); ++vw){
181 if (uwires[uw].
TPC!=vwires[vw].
TPC)
continue;
182 if (uwires[uw].TPC!=zwire.
TPC)
continue;
183 if (vwires[vw].TPC!=zwire.
TPC)
continue;
189 double dis1 = sqrt(
pow(widiuz.
y-widivz.
y,2)+
pow(widiuz.
z-widivz.
z,2));
190 double dis2 = sqrt(
pow(widiuz.
y-widiuv.
y,2)+
pow(widiuz.
z-widiuv.
z,2));
191 double dis3 = sqrt(
pow(widiuv.
y-widivz.
y,2)+
pow(widiuv.
z-widivz.
z,2));
192 double maxdis =
std::max(dis1,dis2);
196 ++totalintersections;
202 if (totalintersections==1){
203 allhitsu[uwires[bestu].TPC].push_back(hitsUV[0][u]);
204 allhitsv[vwires[bestv].TPC].push_back(hitsUV[1][v]);
205 allhitsz[hitsZ[
z]->WireID().TPC].push_back(hitsZ[
z]);
206 wireidsu[uwires[bestu].TPC].push_back(uwires[bestu]);
207 wireidsv[vwires[bestv].TPC].push_back(vwires[bestv]);
208 cluidu[uwires[bestu].TPC].push_back(u);
209 cluidv[vwires[bestv].TPC].push_back(v);
210 bestwireidu[uwires[bestu].TPC].push_back(1+bestu);
211 bestwireidv[vwires[bestv].TPC].push_back(1+bestv);
226 double CorrectedHitTime = 0;
227 int ChannelNumber = 0;
228 for (
size_t i = 0; i<ntpc; ++i){
229 if (!allhitsu[i].
size())
continue;
240 std::vector<unsigned int> hitstoaddu;
243 std::map<int, std::pair <double,double> > ClusterStartEndTime;
244 std::map<int, std::pair <int, int> > ClusterStartEndColChan;
251 CorrectedHitTime = allhitsu[i][j]->PeakTime() - detProp.GetXTicksOffset(allhitsu[i][j]->
WireID().
Plane, allhitsu[i][j]->
WireID().TPC, allhitsu[i][j]->
WireID().Cryostat);
257 ChannelNumber = allhitsz[i][j]->Channel();
272 for (
unsigned int ClusNum = 0; ClusNum <
fDBScan.
fclusters.size(); ++ClusNum ) {
273 for (
unsigned int ClusIt = 0; ClusIt <
fDBScan.
fclusters.size(); ++ClusIt ) {
274 if ( dbcluhits[ClusIt] > dbcluhits[ClusNum] ) {
276 if ( ClusterStartEndTime[ClusNum].first > ( ClusterStartEndTime[ClusIt].first +
fTimeWiggle )
277 && ClusterStartEndTime[ClusNum].first < ( ClusterStartEndTime[ClusIt].second +
fTimeWiggle ) ) {
278 if ( ClusterStartEndTime[ClusNum].
second > ( ClusterStartEndTime[ClusIt].first +
fTimeWiggle )
279 && ClusterStartEndTime[ClusNum].second < ( ClusterStartEndTime[ClusIt].second +
fTimeWiggle ) ) {
281 if ( ClusterStartEndColChan[ClusNum].first > ( ClusterStartEndColChan[ClusIt].first +
fColChanWiggle )
282 && ClusterStartEndColChan[ClusNum].first < ( ClusterStartEndColChan[ClusIt].second +
fColChanWiggle ) ) {
283 if ( ClusterStartEndColChan[ClusNum].
second > ( ClusterStartEndColChan[ClusIt].first +
fColChanWiggle )
284 && ClusterStartEndColChan[ClusNum].second < ( ClusterStartEndColChan[ClusIt].second +
fColChanWiggle ) ) {
286 boolVector[ClusNum] =
false;
316 std::vector<unsigned int> hitstoaddv;
319 ClusterStartEndTime.clear();
320 ClusterStartEndColChan.clear();
329 CorrectedHitTime = allhitsv[i][j]->PeakTime() - detProp.GetXTicksOffset(allhitsv[i][j]->
WireID().
Plane, allhitsv[i][j]->
WireID().TPC, allhitsv[i][j]->
WireID().Cryostat);
335 ChannelNumber = allhitsz[i][j]->Channel();
351 for (
unsigned int ClusNum = 0; ClusNum <
fDBScan.
fclusters.size(); ++ClusNum ) {
352 for (
unsigned int ClusIt = 0; ClusIt <
fDBScan.
fclusters.size(); ++ClusIt ) {
353 if ( dbcluhits[ClusIt] > dbcluhits[ClusNum] ) {
355 if ( ClusterStartEndTime[ClusNum].first > ( ClusterStartEndTime[ClusIt].first +
fTimeWiggle )
356 && ClusterStartEndTime[ClusNum].first < ( ClusterStartEndTime[ClusIt].second +
fTimeWiggle ) ) {
357 if ( ClusterStartEndTime[ClusNum].
second > ( ClusterStartEndTime[ClusIt].first +
fTimeWiggle )
358 && ClusterStartEndTime[ClusNum].second < ( ClusterStartEndTime[ClusIt].second +
fTimeWiggle ) ) {
360 if ( ClusterStartEndColChan[ClusNum].first > ( ClusterStartEndColChan[ClusIt].first +
fColChanWiggle )
361 && ClusterStartEndColChan[ClusNum].first < ( ClusterStartEndColChan[ClusIt].second +
fColChanWiggle ) ) {
362 if ( ClusterStartEndColChan[ClusNum].
second > ( ClusterStartEndColChan[ClusIt].first +
fColChanWiggle )
363 && ClusterStartEndColChan[ClusNum].second < ( ClusterStartEndColChan[ClusIt].second +
fColChanWiggle ) ) {
365 boolVector[ClusNum] =
false;
386 for (
size_t j = 0; j < allhitsu[i].size(); ++j){
389 for (
size_t k = 0;
k<hitstoaddu.size(); ++
k){
390 if (j==hitstoaddu[
k]) {
394 for (
size_t k = 0;
k<hitstoaddv.size(); ++
k){
395 if (j==hitstoaddv[
k]) {
401 if (fHasBeenDisambigedUV[0].find(cluidu[i][j])==fHasBeenDisambigedUV[0].end()){
403 fHasBeenDisambigedUV[0][cluidu[i][j]] = bestwireidu[i][j];
405 if (fHasBeenDisambigedUV[1].find(cluidv[i][j])==fHasBeenDisambigedUV[1].
end()){
408 fHasBeenDisambigedUV[1][cluidv[i][j]] = bestwireidv[i][j];
416 for (
size_t i = 0; i<ntpc; ++i){
417 for (
size_t j = 0; j < allhitsu[i].size(); ++j){
419 if (fHasBeenDisambigedUV[0].find(cluidu[i][j])==fHasBeenDisambigedUV[0].end()){
421 fHasBeenDisambigedUV[0][cluidu[i][j]] = bestwireidu[i][j];
423 if (fHasBeenDisambigedUV[1].find(cluidv[i][j])==fHasBeenDisambigedUV[1].
end()){
426 fHasBeenDisambigedUV[1][cluidv[i][j]] = bestwireidv[i][j];
433 for (
size_t i = 0; i<2; ++i){
434 for (
size_t hit = 0;
hit<hitsUV[i].size(); ++
hit){
435 if (fHasBeenDisambigedUV[i].find(
hit)!=fHasBeenDisambigedUV[i].end())
continue;
436 unsigned int apa1(0), cryo1(0);
440 std::vector<geo::WireID> wires = geo->
ChannelToWire(hitsUV[i][
hit]->Channel());
442 std::vector<int> nearbyhits(wires.size(),-1);
443 for (
auto& u2 : fHasBeenDisambigedUV[i]){
444 unsigned int apa2(0), cryo2(0);
446 if (apa1!=apa2)
continue;
449 for (
size_t w = 0;
w<wires.size(); ++
w){
450 if (wires[
w].TPC!= hitwire.
TPC)
continue;
451 if (nearbyhits[
w]<0) nearbyhits[
w] = 0;
452 double distance = sqrt(
pow((
double(hitwire.
Wire)-
double(wires[
w].Wire))*wire_pitch,2)+
pow(detProp.ConvertTicksToX(hitsUV[i][u2.first]->PeakTime(),hitwire.
Plane,hitwire.
TPC,hitwire.
Cryostat)-detProp.ConvertTicksToX(hitsUV[i][
hit]->PeakTime(),hitwire.
Plane,hitwire.
TPC,hitwire.
Cryostat),2));
456 unsigned bestwire = 0;
458 for (
size_t w = 0;
w<wires.size(); ++
w){
459 if (nearbyhits[
w]<0)
continue;
460 if (nearbyhits[
w]>maxnumhits){
462 maxnumhits = nearbyhits[
w];
467 fHasBeenDisambigedUV[i][
hit] = 1+bestwire;
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
double z
z position of intersection
dune::apa::APAGeometryAlg fAPAGeo
AdcChannelData::View View
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
CryostatID_t Cryostat
Index of cryostat.
Planes which measure Z direction.
WireID_t Wire
Index of the wire within its plane.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
std::vector< std::pair< art::Ptr< recob::Hit >, geo::WireID > > fDisambigHits
The final list of hits to pass back to be made.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::vector< unsigned int > fpointId_to_clusterId
mapping point_id -> clusterId
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
unsigned int ChannelToAPA(uint32_t chan)
Get number of the APA containing the given channel.
static int max(int a, int b)
PlaneID_t Plane
Index of the plane within its TPC.
Detector simulation of raw signals on wires.
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
bool WireIDsIntersect(WireID const &wid1, WireID const &wid2, geo::Point_t &intersection) const
Computes the intersection between two wires.
void InitScan(const detinfo::DetectorClocksData &clockData, const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &allhits, std::set< uint32_t > badChannels, const std::vector< geo::WireID > &wireids=std::vector< geo::WireID >())
std::vector< std::vector< unsigned int > > fclusters
collection of something
double y
y position of intersection
cluster::DBScanAlg fDBScan
object that implements the DB scan algorithm
TPCID_t TPC
Index of the TPC within its cryostat.
second_as<> second
Type of time stored in seconds, in double precision.
recob::tracking::Plane Plane
LArSoft geometry interface.
std::set< uint32_t > SetOfBadChannels() const
cet::coded_exception< error, detail::translate > exception