#include <AlgMSTClusterList.h>
Inheritance diagram for AlgMSTClusterList:

Public Member Functions | |
| AlgMSTClusterList () | |
| virtual | ~AlgMSTClusterList () |
| virtual void | Trace (const char *c) const |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
Private Member Functions | |
| Bool_t | IsCloseZ (const ClusterBox &b1, const ClusterBox &b2, Int_t sep) const |
| Bool_t | IsInCross (const ClusterBox &b1, const ClusterBox &b2, Float_t hol, Float_t dist) const |
| Bool_t | IsOutCross (const ClusterBox &b1, const ClusterBox &b2, Float_t hol, Float_t dist) const |
| Bool_t | IsOverlap (const ClusterBox &b1, const ClusterBox &b2, Float_t dist) const |
| void | RunAlgOnSlice (AlgConfig &ac, CandHandle &ch, CandContext &cx, CandSliceHandle *csh) |
| void | RunCloseZAlg (Int_t sep, TObjArray *&toay) |
| void | RunHoleCrossAlg (Float_t hole, Float_t dist, TObjArray *&toayU, TObjArray *&toayV) |
| void | RunMSTAlg (Float_t dist, TObjArray *&toay) |
|
|
Definition at line 46 of file AlgMSTClusterList.cxx. 00047 {
00048 //
00049 // Purpose: Default constructor.
00050 //
00051 // Arguments: n/a
00052 //
00053 // Return: n/a
00054 //
00055 }
|
|
|
Definition at line 59 of file AlgMSTClusterList.cxx. 00060 {
00061 //
00062 // Purpose: Default destructor.
00063 //
00064 // Arguments: n/a
00065 //
00066 // Return: n/a
00067 //
00068 }
|
|
||||||||||||||||
|
Definition at line 72 of file AlgMSTClusterList.cxx. References ClusterBox::GetPhi(), and ClusterBox::GetPlo(). Referenced by RunCloseZAlg(). 00074 {
00075 //
00076 // Purpose: Determine whether two boxes are close in plane number.
00077 // Used primarily to bridge the gap between super-modules.
00078 //
00079 // Arguments:
00080 // b1,b2 in The boxes to compare.
00081 // sep in Max separation in plane number between box ends.
00082 //
00083 // Return: kTRUE if box ends are within sep
00084 // kFALSE otherwise
00085 //
00086
00087 Int_t diff1 = b1.GetPlo() - b2.GetPhi();
00088 Int_t diff2 = b2.GetPlo() - b1.GetPhi();
00089 return (diff1 <= sep && diff1 > 0) || (diff2 <= sep && diff2 > 0);
00090 }
|
|
||||||||||||||||||||
|
Definition at line 94 of file AlgMSTClusterList.cxx. References ClusterBox::GetXin(), and ClusterBox::GetYhi(). Referenced by RunHoleCrossAlg(). 00096 {
00097 //
00098 // Purpose: Determine whether the two boxes are an inward crossing.
00099 //
00100 // Arguments:
00101 // b1,b2 in The boxes to compare.
00102 // hol in Max radius at inward crossing end.
00103 // dist in Max separation between inward ends of boxes
00104 //
00105 // Return: kTRUE if the clusters form an inward crossing
00106 // kFALSE if not
00107 //
00108 // Notes: Assumes that the digit pair clusters are filled with
00109 // strips of opposite orientation.
00110 //
00111
00112 // Check whether inward end of clusters overlap.
00113 if (TMath::Abs(b1.GetYhi() - b2.GetYhi()) < dist) {
00114
00115 // Get transverse positions of inward ends of each cluster.
00116 Float_t xmin = b1.GetXin();
00117 Float_t ymin = b2.GetXin();
00118
00119 // Check radius.
00120 Float_t rad2 = xmin * xmin + ymin * ymin;
00121 Float_t hol2 = hol * hol;
00122 return (rad2 < hol2);
00123 }
00124
00125 // No overlap.
00126 else return kFALSE;
00127 }
|
|
||||||||||||||||||||
|
Definition at line 131 of file AlgMSTClusterList.cxx. References ClusterBox::GetXout(), and ClusterBox::GetYlo(). Referenced by RunHoleCrossAlg(). 00133 {
00134 //
00135 // Purpose: Determine whether the two boxes are an outward crossing.
00136 //
00137 // Arguments:
00138 // b1,b2 in The boxes to compare.
00139 // hol in Max radius at outward crossing end.
00140 // dist in Max separation between outward ends of boxes
00141 //
00142 // Return: kTRUE if the clusters form an outward crossing
00143 // kFALSE if not
00144 //
00145 // Notes: Assumes that the digit pair clusters are filled with
00146 // strips of opposite orientation.
00147 //
00148
00149 // Check whether outward end of clusters overlap.
00150 if (TMath::Abs(b1.GetYlo() - b2.GetYlo()) < dist) {
00151
00152 // Get transverse positions of outward ends of each cluster.
00153 Float_t xmin = b1.GetXout();
00154 Float_t ymin = b2.GetXout();
00155
00156 // Check radius.
00157 Float_t rad2 = xmin * xmin + ymin * ymin;
00158 Float_t hol2 = hol * hol;
00159 return (rad2 < hol2);
00160 }
00161
00162 // No overlap.
00163 else return kFALSE;
00164 }
|
|
||||||||||||||||
|
Definition at line 168 of file AlgMSTClusterList.cxx. References CandStripHandle::GetTPos(), ClusterBox::GetXhi(), ClusterBox::GetXlo(), ClusterBox::GetYhi(), ClusterBox::GetYlo(), and CandStripHandle::GetZPos(). Referenced by RunMSTAlg(). 00170 {
00171 //
00172 // Purpose: Determine whether the digit pairs in two boxes overlap.
00173 //
00174 // Arguments:
00175 // b1,b2 in The boxes to compare.
00176 // dist in Max separation between digit pairs for boxes to
00177 // overlap.
00178 //
00179 // Return: kTRUE if any digit pairs of this box are within dist of
00180 // any digit pairs of the other box
00181 // kFALSE otherwise
00182 //
00183
00184 // Check whether envelopes overlap.
00185 if (((b1.GetXlo() - b2.GetXhi()) > dist)
00186 || ((b2.GetXlo() - b1.GetXhi()) > dist)
00187 || ((b1.GetYlo() - b2.GetYhi()) > dist)
00188 || ((b2.GetYlo() - b1.GetYhi()) > dist)) {
00189 return kFALSE; // No envelope overlap.
00190 }
00191
00192 // Check whether any digit pairs overlap.
00193 TIter b1Itr(&b1);
00194 TIter b2Itr(&b2);
00195 while (CandDigiPairHandle *b1Chh =
00196 dynamic_cast<CandDigiPairHandle *>(b1Itr())) {
00197 Float_t dist2 = dist * dist;
00198 while (CandDigiPairHandle *b2Chh =
00199 dynamic_cast<CandDigiPairHandle *>(b2Itr())) {
00200 Float_t sepX = b1Chh->GetTPos() - b2Chh->GetTPos();
00201 Float_t sepY = b1Chh->GetZPos() - b2Chh->GetZPos();
00202 Float_t sep2 = sepX * sepX + sepY * sepY;
00203 if (sep2 <= dist2) return kTRUE; // Overlap found.
00204 }
00205 b2Itr.Reset();
00206 }
00207 return kFALSE; // No overlap.
00208 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 212 of file AlgMSTClusterList.cxx. References CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), MSG, and RunAlgOnSlice(). 00214 {
00215 //
00216 // Purpose: Group together CandDigiPairs into MSTClusters that are
00217 // stored in a new CandMSTClusterList.
00218 //
00219 // Argument:
00220 // ac in AlgConfig containing cluster parameters.
00221 // ch in Handle to the new CandMSTClusterList to fill.
00222 // cx in CandContext containing the CandSliceList to
00223 // cluster.
00224 //
00225 // Return: n/a
00226 //
00227
00228 MSG("BubAlg", Msg::kVerbose)
00229 << "Starting AlgMSTClusterList::RunAlg()" << endl;
00230
00231 // Check for CandSliceListHandle input.
00232 assert(cx.GetDataIn());
00233 assert(cx.GetDataIn()->InheritsFrom("CandSliceListHandle"));
00234 const CandSliceListHandle *cslh =
00235 dynamic_cast<const CandSliceListHandle*>(cx.GetDataIn());
00236
00237 // Iterate over CandSlices.
00238 TIter cshItr(cslh->GetDaughterIterator());
00239 while (CandSliceHandle *csh =
00240 dynamic_cast<CandSliceHandle *>(cshItr())) {
00241 RunAlgOnSlice(ac, ch, cx, csh);
00242 }
00243 }
|
|
||||||||||||||||||||
|
Definition at line 247 of file AlgMSTClusterList.cxx. References CandHandle::AddDaughterLink(), AlgFactory::GetAlgHandle(), CandContext::GetCandRecord(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStripEndId(), PlexPlaneId::IsVetoShield(), CandMSTCluster::MakeCandidate(), MSG, RunCloseZAlg(), RunHoleCrossAlg(), RunMSTAlg(), and CandClusterHandle::SetCandSlice(). Referenced by RunAlg(). 00249 {
00250 //
00251 // Purpose: Group together CandDigiPairs into MSTClusters that are
00252 // stored in a new CandMSTClusterList.
00253 //
00254 // Argument:
00255 // ac in AlgConfig containing cluster parameters.
00256 // ch in Handle to the new CandMSTClusterList to fill.
00257 // cx in CandContext containing information needed for call
00258 // to AlgMSTCluster.
00259 // csh in CandSlice containing CandDigiPairs to group into a
00260 // CandMSTCluster.
00261 //
00262 // Return: n/a
00263 //
00264
00265 MSG("BubAlg", Msg::kVerbose)
00266 << "Starting AlgMSTClusterList::RunAlgOnSlice()" << endl;
00267
00268 // Save config parameters.
00269 Double_t distmax = ac.GetDouble("DistMax");
00270 Double_t holemax = ac.GetDouble("HoleMax");
00271 Int_t planemax = ac.GetInt("PlaneMax");
00272
00273 // Initialize cluster boxes.
00274 TObjArray *cbayU = new TObjArray();
00275 TObjArray *cbayV = new TObjArray();
00276 TObjArray *arrayA = 0;
00277 TObjArray *arrayB = 0;
00278 TObjArray *shield = 0;
00279 assert(csh);
00280 TIter chhItr(csh->GetDaughterIterator());
00281 while (CandDigiPairHandle *chh =
00282 dynamic_cast<CandDigiPairHandle *>(chhItr())) {
00283
00284 // Check for digits from veto shield.
00285 if (chh->GetStripEndId().IsVetoShield()) {
00286 if (!shield) shield = new TObjArray();
00287 shield->Add(chh);
00288 continue;
00289 }
00290
00291 // Separate by strip orientation.
00292 switch (chh->GetPlaneView()) {
00293 case PlaneView::kU:
00294 cbayU->Add(new ClusterBox(chh));
00295 break;
00296 case PlaneView::kV:
00297 cbayV->Add(new ClusterBox(chh));
00298 break;
00299 case PlaneView::kA:
00300 if (!arrayA) arrayA = new TObjArray();
00301 arrayA->Add(chh);
00302 break;
00303 case PlaneView::kB:
00304 if (!arrayB) arrayB = new TObjArray();
00305 arrayB->Add(chh);
00306 break;
00307 default:
00308 MSG("BubAlg", Msg::kWarning)
00309 << "Invalid plane orientation." << endl;
00310 }
00311 }
00312
00313 // MSTCluster using MST algorithm.
00314 RunMSTAlg(distmax, cbayU);
00315 RunMSTAlg(distmax, cbayV);
00316
00317 // Join clusters across super-modules.
00318 RunCloseZAlg(planemax, cbayU);
00319 RunCloseZAlg(planemax, cbayV);
00320
00321 // Join clusters across the coil hole.
00322 RunHoleCrossAlg(holemax, distmax, cbayU, cbayV);
00323
00324 // General setup for creating new CandMSTClusters.
00325 MSG("BubAlg", Msg::kVerbose)
00326 << "AlgFactory &af = AlgFactory::GetInstance();" << endl;
00327 AlgFactory &af = AlgFactory::GetInstance();
00328
00329 MSG("BubAlg", Msg::kVerbose)
00330 << "AlgHandle ah = af.GetAlgHandle(\"AlgMSTCluster\","
00331 << "\"default\");" << endl;
00332 AlgHandle ah = af.GetAlgHandle("AlgMSTCluster", "default");
00333
00334 MSG("BubAlg", Msg::kVerbose)
00335 << "Create CandContext instance." << endl;
00336 CandContext cxx(this, cx.GetMom());
00337 cxx.SetCandRecord(cx.GetCandRecord());
00338
00339 // Iterate over ClusterBoxes to create CandMSTClusters.
00340 // U-view clusters
00341 TIter cbUItr(cbayU);
00342 while (ClusterBox *cb = dynamic_cast<ClusterBox *>(cbUItr())) {
00343 cxx.SetDataIn(cb);
00344 CandMSTClusterHandle clh = CandMSTCluster::MakeCandidate(ah, cxx);
00345 clh.SetCandSlice(csh);
00346 ch.AddDaughterLink(clh);
00347 }
00348 cbayU->Delete();
00349 delete cbayU;
00350 cbayU = 0;
00351
00352 // V-view clusters
00353 TIter cbVItr(cbayV);
00354 while (ClusterBox *cb = dynamic_cast<ClusterBox *>(cbVItr())) {
00355 cxx.SetDataIn(cb);
00356 CandMSTClusterHandle clh = CandMSTCluster::MakeCandidate(ah, cxx);
00357 clh.SetCandSlice(csh);
00358 ch.AddDaughterLink(clh);
00359 }
00360 cbayV->Delete();
00361 delete cbayV;
00362 cbayV = 0;
00363
00364 // A-view clusters
00365 if (arrayA) {
00366 cxx.SetDataIn(arrayA);
00367 CandMSTClusterHandle clh = CandMSTCluster::MakeCandidate(ah, cxx);
00368 clh.SetCandSlice(csh);
00369 ch.AddDaughterLink(clh);
00370 delete arrayA;
00371 arrayA = 0;
00372 }
00373
00374 // B-view clusters
00375 if (arrayB) {
00376 cxx.SetDataIn(arrayB);
00377 CandMSTClusterHandle clh = CandMSTCluster::MakeCandidate(ah, cxx);
00378 clh.SetCandSlice(csh);
00379 ch.AddDaughterLink(clh);
00380 delete arrayB;
00381 arrayB = 0;
00382 }
00383
00384 // Veto shield clusters
00385 if (shield) {
00386 cxx.SetDataIn(shield);
00387 CandMSTClusterHandle clh = CandMSTCluster::MakeCandidate(ah, cxx);
00388 clh.SetCandSlice(csh);
00389 ch.AddDaughterLink(clh);
00390 delete shield;
00391 shield = 0;
00392 }
00393 }
|
|
||||||||||||
|
Definition at line 397 of file AlgMSTClusterList.cxx. References ClusterBox::Add(), IsCloseZ(), ClusterBox::Join(), and MSG. Referenced by RunAlgOnSlice(). 00398 {
00399 //
00400 // Purpose: Group clusters together across the gap between super-
00401 // modules using plane number.
00402 //
00403 // Arguments:
00404 // sep in Maximum plane number separation between clusters.
00405 // toay in/out Array with initial cluster boxes. It is replaced
00406 // by an array with final cluster boxes.
00407 //
00408 // Return: n/a
00409 //
00410
00411 MSG("BubAlg", Msg::kVerbose)
00412 << "Starting AlgMSTClusterList::RunCloseZAlg()" << endl;
00413
00414 // Check for single cluster.
00415 Int_t nboxnew = toay->GetEntries();
00416 if (nboxnew <= 1) return;
00417
00418 Int_t nboxold;
00419
00420 // Loop until no clusters are joined.
00421 do {
00422
00423 // Save start number of boxes for later check.
00424 nboxold = nboxnew;
00425
00426 // Create new array to store ClusterBoxes.
00427 TObjArray *cbay = new TObjArray();
00428
00429 // Store first ClusterBox in new array.
00430 TIter tyItr(toay);
00431 cbay->Add(toay->Remove(tyItr()));
00432
00433 // Iterate over remaining ClusterBoxes
00434 while (ClusterBox *ty = dynamic_cast<ClusterBox *>(tyItr())) {
00435 toay->Remove(ty);
00436
00437 // Iterate over new ClusterBoxes to search for overlap.
00438 TIter cbItr(cbay);
00439 while (ClusterBox *cb = dynamic_cast<ClusterBox *>(cbItr())) {
00440 if (IsCloseZ(*cb, *ty, sep)) {
00441 cb->Join(*ty);
00442 delete ty;
00443 ty = 0;
00444 break;
00445 }
00446 }
00447
00448 // No overlap found, so add as new ClusterBox.
00449 cbay->Add(ty);
00450 }
00451
00452 // Clean-up for next loop.
00453 toay->Delete();
00454 delete toay;
00455 toay = cbay;
00456 nboxnew = toay->GetEntries();
00457 } while (nboxnew != nboxold);
00458 }
|
|
||||||||||||||||||||
|
Definition at line 462 of file AlgMSTClusterList.cxx. References ClusterBox::Add(), ClusterBox::GetYhi(), ClusterBox::GetYlo(), IsInCross(), IsOutCross(), ClusterBox::Join(), and MSG. Referenced by RunAlgOnSlice(). 00464 {
00465 //
00466 // Purpose: Join clusters across the coil hole.
00467 //
00468 // Arguments:
00469 // hole in Maximum hole crossing radius in std length units.
00470 // dist in Maximum separation between ends of cluster boxes.
00471 // toayU in/out Array with digit pair clusters of U-view strips.
00472 // toayV in/out Array with digit pair clusters of V-view strips.
00473 //
00474 // Return: n/a
00475 //
00476 // Notes: Current implementation allows only clusters in particular
00477 // direction to be joined.
00478 //
00479
00480 MSG("BubAlg", Msg::kVerbose)
00481 << "Starting AlgMSTClusterList::RunHoleCrossAlg()" << endl;
00482
00483 TObjArray outay;
00484 TObjArray inay;
00485
00486 // Iterate over clusters in both sets.
00487 TIter cbUItr(toayU);
00488 TIter cbVItr(toayV);
00489 while (ClusterBox *cbU = dynamic_cast<ClusterBox *>(cbUItr())) {
00490 while (ClusterBox *cbV = dynamic_cast<ClusterBox *>(cbVItr())) {
00491
00492 // Check whether outward crossing.
00493 if (IsOutCross(*cbU, *cbV, hole, dist)) {
00494 TObjArray *outpair = new TObjArray(2);
00495 outpair->AddAt(cbU, 0);
00496 outpair->AddAt(cbV, 1);
00497 outay.Add(outpair);
00498 }
00499
00500 // Check whether inward crossing.
00501 if (IsInCross(*cbU, *cbV, hole, dist)) {
00502 TObjArray *inpair = new TObjArray(2);
00503 inpair->AddAt(cbU, 0);
00504 inpair->AddAt(cbV, 1);
00505 inay.Add(inpair);
00506 }
00507 }
00508 cbVItr.Reset();
00509 }
00510
00511 // Iterate over all outward crossing clusters.
00512 TIter outItr(&outay);
00513 while (TObjArray *outpair = dynamic_cast<TObjArray*>(outItr())) {
00514 ClusterBox *outU = dynamic_cast<ClusterBox*>(outpair->At(0));
00515 if (!outU) continue;
00516 ClusterBox *outV = dynamic_cast<ClusterBox*>(outpair->At(1));
00517 if (!outV) continue;
00518
00519 // Iterate over all inward crossing clusters.
00520 TIter inItr(&inay);
00521 while (TObjArray *inpair = dynamic_cast<TObjArray*>(inItr())) {
00522 ClusterBox *inU = dynamic_cast<ClusterBox*>(inpair->At(0));
00523 if (!inU) continue;
00524 ClusterBox *inV = dynamic_cast<ClusterBox*>(inpair->At(1));
00525 if (!inV) continue;
00526
00527 // Join matching clusters.
00528 if ((inU->GetYhi() < outU->GetYlo())
00529 && (inV->GetYhi() < outV->GetYlo())) {
00530 inU->Join(*outU);
00531 inV->Join(*outV);
00532 delete toayU->Remove(outU);
00533 outU = 0;
00534 delete toayV->Remove(outV);
00535 outV = 0;
00536 delete outay.Remove(outpair);
00537 outpair = 0;
00538 delete inay.Remove(inpair);
00539 inpair = 0;
00540 break;
00541 }
00542 }
00543 }
00544 }
|
|
||||||||||||
|
Definition at line 548 of file AlgMSTClusterList.cxx. References ClusterBox::Add(), IsOverlap(), ClusterBox::Join(), and MSG. Referenced by RunAlgOnSlice(). 00549 {
00550 //
00551 // Purpose: Group CandDigiPairs into cluster using a minimum spanning
00552 // tree algorithm.
00553 //
00554 // Arguments:
00555 // dist in Maximum separation between digit pairs within a
00556 // cluster
00557 // toay in/out Array with initial cluster boxes. It is replaced
00558 // by an array with final cluster boxes.
00559 //
00560 // Return: n/a
00561 //
00562
00563 MSG("BubAlg", Msg::kVerbose)
00564 << "Starting AlgMSTClusterList::RunMSTAlg()" << endl;
00565
00566 // Check for empty array or single cluster.
00567 Int_t nboxnew = toay->GetEntries();
00568 if (nboxnew <= 1) return;
00569
00570 Int_t nboxold;
00571
00572 // Loop until no clusters are joined.
00573 do {
00574
00575 // Save start number of boxes for later check.
00576 nboxold = nboxnew;
00577
00578 // Create new array to store ClusterBoxes.
00579 TObjArray *cbay = new TObjArray();
00580
00581 // Store first ClusterBox in new array.
00582 TIter tyItr(toay);
00583 cbay->Add(toay->Remove(tyItr()));
00584
00585 // Iterate over remaining ClusterBoxes
00586 while (ClusterBox *ty = dynamic_cast<ClusterBox *>(tyItr())) {
00587 toay->Remove(ty);
00588
00589 // Iterate over new ClusterBoxes to search for overlap.
00590 TIter cbItr(cbay);
00591 while (ClusterBox *cb = dynamic_cast<ClusterBox *>(cbItr())) {
00592 if (IsOverlap(*cb, *ty, dist)) {
00593 cb->Join(*ty);
00594 delete ty;
00595 ty = 0;
00596 break;
00597 }
00598 }
00599
00600 // No overlap found, so add as new ClusterBox.
00601 cbay->Add(ty);
00602 }
00603
00604 // Clean-up for next loop.
00605 toay->Delete();
00606 delete toay;
00607 toay = cbay;
00608 nboxnew = toay->GetEntries();
00609 } while (nboxnew != nboxold);
00610 }
|
|
|
Reimplemented from AlgBase. Definition at line 614 of file AlgMSTClusterList.cxx. References MSG. 00615 {
00616 //
00617 // Purpose: Trace the AlgMSTClusterList.
00618 //
00619 // Arguments:
00620 // c in String tag for the trace.
00621 //
00622 // Return: n/a
00623 //
00624
00625 MSG("BubCand", Msg::kDebug)
00626 << "**********Begin AlgMSTClusterList::Trace(\"" << c << "\")"
00627 << endl
00628 << "**********End AlgMSTClusterList::Trace(\"" << c << "\")"
00629 << endl;
00630 }
|
1.3.9.1