Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

NavGenLattice.cxx

Go to the documentation of this file.
00001 
00002 // $Id: NavGenLattice.cxx,v 1.6 2000/11/06 12:33:52 west Exp $
00003 //
00004 // NavGenLattice
00005 //
00006 // Package: Nav (Navigational Model).
00007 
00008 // Begin_Html<img src="../../pedestrians.gif" align=center>
00009 // <a href="../source_warning.html">Warning for beginners</a>.<br>
00010 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and
00011 // <a href="../index.html">The MINOS Class User Guide</a>End_Html
00012 //
00013 // N. West 03/20000
00014 //
00015 //   
00016 // Purpose: Encapsulates a Root container derived Lattice and creates 
00017 //          it on demand. The Lattice type is (left) 1 : n (right).
00018 //
00019 //
00021 
00022 #include "LeakChecker/Lea.h"
00023 #include "Lattice/Lattice.h"
00024 #include "Lattice/LatticeBuilder.h"
00025 #include "Navigation/NavGenLattice.h"
00026 #include "Navigation/NavPrimer.h"
00027 #include "Navigation/NavKey.h"
00028 #include "MessageService/MsgService.h"
00029 #include "TCollection.h"
00030 
00031 class TObject;
00032 
00033 ClassImp(NavGenLattice)
00034 
00035 //   Definition of static data members
00036 //   *********************************
00037 
00038 CVSID("$Id: NavGenLattice.cxx,v 1.6 2000/11/06 12:33:52 west Exp $");
00039 
00040 // Definition of member functions (alphabetical order)
00041 // ***************************************************
00042 
00043 
00044 //.....................................................................
00045 
00046 void NavGenLattice::Clear(){
00047 //
00048 //
00049 //  Purpose:  Clear any dynamic data.
00050 //
00051 //  Arguments: None
00052 //
00053 //  Return:    n/a
00054 //
00055 //  Contact:   N. West
00056 //
00057 //  Specification:-
00058 //  =============
00059 //
00060 //  o Drop Lattice.
00061 //
00062 
00063 //  Program Notes:-
00064 //  =============
00065 
00066 //  None.
00067 
00068   if ( fLattice ) delete fLattice;
00069   fLattice = 0;
00070 
00071 }
00072 
00073 //.....................................................................
00074 
00075 NavGenLattice::NavGenLattice(const Char_t* leftClass,
00076                              KeyFunc leftKey,
00077                              const Char_t* rightClass,
00078                              KeyFunc rightKey,
00079                              Int_t rship ) :
00080 
00081 NavPrimerGenerator(leftClass,rightClass,rship),
00082 fLattice(0),
00083 fLeftKey(leftKey),
00084 fRightKey(rightKey)
00085 
00086 
00087 {
00088 //
00089 //
00090 //  Purpose:  Constructor
00091 //
00092 //  Arguments: 
00093 //    leftClass    in    Name of left class.
00094 //    leftKey      in    Key function for left class 
00095 //    rightClass   in    Name of right class.
00096 //    rightKey     in    Key function for right class 
00097 //    rship        in    Relationship number.
00098 //
00099 //  Return:    n/a
00100 //
00101 //  Contact:   N. West
00102 //
00103 //  Specification:-
00104 //  =============
00105 //
00106 //  o Create a NavGenLattice.
00107 
00108 //  Program Notes:-
00109 //  =============
00110 
00111 //  None.
00112 
00113   LEA_CTOR  //Leak Checker
00114 
00115 }
00116 //.....................................................................
00117 
00118 NavGenLattice::~NavGenLattice()
00119 {
00120 //
00121 //
00122 //  Purpose:  Destructor
00123 //
00124 //  Arguments: 
00125 //    None.
00126 //
00127 //  Return:    n/a
00128 //
00129 //  Contact:   N. West
00130 //
00131 //  Specification:-
00132 //  =============
00133 //
00134 //  o Destroy a NavGenLattice.
00135 
00136 //  Program Notes:-
00137 //  =============
00138 
00139 //  None.
00140 
00141   LEA_DTOR  //Leak Checker
00142 
00143   Clear();
00144 
00145 }
00146 //.....................................................................
00147 
00148 void NavGenLattice::Rebuild() {
00149 //
00150 //
00151 //  Purpose:  Rebuild Lattice.
00152 //
00153 //  Arguments: None.
00154 //
00155 //  Return:    n/a
00156 //
00157 //  Contact:   N. West
00158 //
00159 //  Specification:-
00160 //  =============
00161 //
00162 //  o Rebuild Lattice.
00163 
00164 //  Program Notes:-
00165 //  =============
00166 
00167 //  None.
00168 
00169 
00170 //  Remove old Lattice.
00171 
00172   Clear();
00173 
00174 //  Create new empty Lattice for current event.
00175 
00176   const Char_t* leftClass  = LeftClass();
00177   const Char_t* rightClass = RightClass();
00178 
00179   fLattice = new Lattice(leftClass,
00180                          rightClass,
00181                          LatticeBase::RLinkMulti);
00182 
00183 //  Make sure we can find both ROOT containers.
00184 
00185   const TCollection* leftCol  = NavPrimer::Instance()
00186                           ->FindTCollection(leftClass);
00187   const TCollection* rightCol = NavPrimer::Instance()
00188                           ->FindTCollection(rightClass);
00189 
00190   if ( ! leftCol )  MSG("Nav",Msg::kError) 
00191         << "Cannot find  ROOT container for: " << leftClass  << endl;
00192   if ( ! rightCol )  MSG("Nav",Msg::kError) 
00193         << "Cannot find  ROOT container for: " << rightClass  << endl;
00194 
00195   if ( ! leftCol || ! rightCol ) return;
00196 
00197 
00198 
00199 //  Prepare a builder.
00200 
00201   LatticeBuilder builder( fLattice, Lattice::kLeft );
00202 
00203 
00204 // Iterate over left class objects and give their keys to the builder.
00205 
00206   TIter leftItr(leftCol);
00207   while ( TObject* leftObj = leftItr() ) {
00208     NavKey key = (*fLeftKey)(leftObj);
00209 
00210     builder.AddPrimary(key.ForceLong_t(), leftObj);
00211   }
00212 
00213 // Iterate over right class objects and give their associated keys
00214 // to the builder.
00215 
00216   TIter rightItr(rightCol);
00217   while ( TObject* rightObj = rightItr() ) {
00218     NavKey key = (*fRightKey)(rightObj);
00219     builder.AddSecondary(key.ForceLong_t(), rightObj);
00220   }
00221 
00222 
00223 }
00224 
00225 /*    Template for New Member Function
00226 
00227 //.....................................................................
00228 
00229 NavGenLattice:: {
00230 //
00231 //
00232 //  Purpose:  
00233 //
00234 //  Arguments: 
00235 //    xxxxxxxxx    in    yyyyyy
00236 //
00237 //  Return:    
00238 //
00239 //  Contact:   N. West
00240 //
00241 //  Specification:-
00242 //  =============
00243 //
00244 //  o 
00245 
00246 //  Program Notes:-
00247 //  =============
00248 
00249 //  None.
00250 
00251 
00252 }
00253 
00254 */
00255 

Generated on Mon Feb 15 11:07:02 2010 for loon by  doxygen 1.3.9.1