00001 00002 // $Id: Lattice.cxx,v 1.3 2001/03/28 19:08:06 bv Exp $ 00003 // 00004 // Lattice 00005 // 00006 // Begin_Html<img src="../../pedestrians.gif" align=center> 00007 // <a href="../source_warning.html">Warning for beginners</a>.<br> 00008 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and 00009 // <a href="../index.html">The MINOS Class User Guide</a>End_Html 00010 // 00011 // N. West 03/2000 00012 // 00013 // Purpose: 00014 // 00016 00017 #include "Lattice/Lattice.h" 00018 #include "MessageService/MsgService.h" 00019 00020 // Definition of static data members 00021 // ********************************* 00022 00023 CVSID("$Id: Lattice.cxx,v 1.3 2001/03/28 19:08:06 bv Exp $"); 00024 00025 // Definition of member functions (alphabetical order) 00026 // *************************************************** 00027 00028 //..................................................................... 00029 00030 Lattice::Link* Lattice::ConnectLR(ID leftID, 00031 ID rightID) { 00032 00033 // Purpose: Connect left and right IDs forcing a new link 00034 // Arguments: 00035 // leftID in left ID 00036 // rightID in right ID 00037 // Return: Connecting link. 00038 00039 // Contact: N. West 00040 00041 00042 // If necessary create nodes corresponding to IDs. 00043 00044 if ( ! LatticeBase::leftNode(leftID) 00045 ) LatticeBase::newLeftNode(leftID); 00046 if ( ! LatticeBase::rightNode(rightID) 00047 ) LatticeBase::newRightNode(rightID); 00048 00049 00050 // Make the connection 00051 00052 return LatticeBase::connect( leftID, rightID ); 00053 00054 } 00055 //..................................................................... 00056 00057 Lattice::Link* Lattice::ConnectLR(ID leftID, 00058 Link* link, 00059 ID rightID) { 00060 00061 // Purpose: Connect left and right IDs reusing existing 00062 // link if possible. 00063 // Arguments: 00064 // leftID in left ID 00065 // link in link to be used. If =0 then reuse any 00066 // link from either side or create if none. 00067 // rightID in right ID 00068 // Return: Connecting link. 00069 00070 // Contact: N. West 00071 00072 00073 // If necessary create nodes corresponding to IDs. 00074 00075 LeftNode* pLN = LatticeBase::leftNode(leftID); 00076 LeftNode* lNode = (pLN)? pLN : LatticeBase::newLeftNode(leftID); 00077 00078 RightNode* pRN = LatticeBase::rightNode(rightID); 00079 RightNode* rNode = (pRN)? pRN : LatticeBase::newRightNode(rightID); 00080 00081 00082 // If user has not supplied a Link see if either node already 00083 // has a Link we can reuse. 00084 00085 if ( ! link ) { 00086 const Links& links = lNode->links(); 00087 if ( links.size() != 0 ) link = *links.begin(); 00088 } 00089 if ( ! link ) { 00090 const Links& links = rNode->links(); 00091 if ( links.size() != 0 ) link = *links.begin(); 00092 } 00093 00094 00095 // Make the connection (LatticeBase will create link if stll none). 00096 00097 return LatticeBase::connect( leftID, link, rightID ); 00098 00099 } 00100 //..................................................................... 00101 00102 Lattice::Link* Lattice::Connect(ESide side, 00103 ID nearID, 00104 ID farID) { 00105 00106 // Purpose: Starting from side connect near to far forcing a 00107 // new link 00108 // Arguments: 00109 // side in Start side (either kLeft or kRight) 00110 // nearID in ID of near side 00111 // farID in ID of far side 00112 // Return: Connecting link. 00113 00114 // Contact: N. West 00115 00116 00117 return ( side == kLeft ) ? ConnectLR( nearID, farID ) 00118 : ConnectLR( farID, nearID); 00119 00120 } 00121 00122 //..................................................................... 00123 00124 Lattice::Link* Lattice::Connect(ESide side, 00125 ID nearID, 00126 Link* link, 00127 ID farID) { 00128 00129 // Purpose: Starting from side connect near to far reusing existing 00130 // link if possible. 00131 // Arguments: 00132 // side in Start side (either kLeft or kRight) 00133 // nearID in ID of near side 00134 // link in link to be used. If =0 then reuse any 00135 // link from either side or create if none. 00136 // in farID ID of far side 00137 // Return: Connecting link. 00138 00139 // Contact: N. West 00140 00141 00142 return ( side == kLeft ) ? ConnectLR( nearID, link, farID ) 00143 : ConnectLR( farID, link, nearID); 00144 00145 } 00146 00147 //..................................................................... 00148 00149 void Lattice::GetAllIDs( ESide side, 00150 VectorID& ids ) const { 00151 00152 // Purpose: Get vector of all IDs. 00153 // Arguments: 00154 // side in Side whose IDs are required (either kLeft 00155 // or kRight). 00156 // ids in User supplied vector(contents ignored) 00157 // out Vector of all IDs. 00158 // Return: n/a 00159 00160 // Contact: N. West 00161 00162 if ( side == kLeft ) ids = LatticeBase::vLeftID(); 00163 else ids = LatticeBase::vRightID(); 00164 00165 } 00166 //..................................................................... 00167 00168 void Lattice::GetNearIDs( ESide side, 00169 ID startFrom, 00170 VectorID& ids ) const { 00171 00172 // Purpose: Get vector of IDs connected locally (i.e. on this side 00173 // of the lattice) to startForm. 00174 // Arguments: 00175 // side in Side of startFrom ID (either kLeft or kRight). 00176 // startFrom 00177 // in ID to start from. 00178 // ids in User supplied vector(contents ignored) 00179 // out Vector of IDs connected locally to startFrom. 00180 // Return: n/a 00181 00182 // Contact: N. West 00183 00184 if ( side == kLeft ) ids = *LatticeBase::vLeftGivenLeft(startFrom); 00185 else ids = *LatticeBase::vRightGivenRight(startFrom); 00186 00187 } 00188 00189 //..................................................................... 00190 00191 void Lattice::GetFarIDs( ESide side, 00192 ID startFrom, 00193 VectorID& ids ) const { 00194 00195 // Purpose: Get vector of IDs connected remotely (i.e. across the 00196 // lattice) to startForm. 00197 // Arguments: 00198 // side in Side of startFrom ID (either kLeft or kRight). 00199 // startFrom 00200 // in ID to start from. 00201 // ids in User supplied vector(contents ignored) 00202 // out Vector of IDs connected remotely to startFrom. 00203 // Return: 00204 00205 // Contact: N. West 00206 00207 const VectorID* idsPtr; 00208 if ( side == kLeft ) idsPtr = LatticeBase::vRightGivenLeft(startFrom); 00209 else idsPtr = LatticeBase::vLeftGivenRight(startFrom); 00210 if ( idsPtr ) ids = *idsPtr; 00211 else ids.clear(); 00212 } 00213 00214 //..................................................................... 00215 00216 Lattice::Lattice(const Text_t* lName, 00217 const Text_t* rName, 00218 Topology i /*= LatticeBase::Default*/, 00219 Topology j /*= LatticeBase::Default*/, 00220 Topology k /*= LatticeBase::Default*/, 00221 Topology l /*= LatticeBase::Default*/) : 00222 LatticeBase(i,j,k,l) 00223 00224 // Purpose: Constructor 00225 // Arguments: Lattice topology 00226 // 00227 // Return: n/a 00228 00229 // Contact: N. West 00230 00231 { 00232 fLeftName = *lName; 00233 fRightName = *rName; 00234 00235 MSG("Lat",Msg::kDebug) << "Creating lattice between " << lName 00236 << " and " << rName << endl; 00237 } 00238 00239 //..................................................................... 00240 00241 Lattice::~Lattice() {} 00242 00243 // Purpose: Destructor 00244 // Arguments: n/a 00245 // 00246 // Return: n/a 00247 00248 // Contact: N. West 00249 00250 00251 00252 // ******************************************************************** 00253 00254 //..................................................................... 00255 00256 00257 // Purpose: 00258 // Arguments: 00259 // 00260 // Return: 00261 00262 // Contact: N. West 00263 00264 //..................................................................... 00265 00266
1.3.9.1