CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CondFormats/DTObjects/src/DTReadOutMapping.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2011/02/08 15:49:28 $
00005  *  $Revision: 1.24 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //----------------------
00011 // This Class' Header --
00012 //----------------------
00013 #include "CondFormats/DTObjects/interface/DTReadOutMapping.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 //#include "CondFormats/DTObjects/interface/DTDataBuffer.h"
00019 #include "CondFormats/DTObjects/interface/DTCompactMapAbstractHandler.h"
00020 
00021 //---------------
00022 // C++ Headers --
00023 //---------------
00024 #include <iostream>
00025 #include <sstream>
00026 #include <map>
00027 
00028 //-------------------
00029 // Initializations --
00030 //-------------------
00031 
00032 
00033 //----------------
00034 // Constructors --
00035 //----------------
00036 DTReadOutMapping::DTReadOutMapping():
00037   cellMapVersion( " " ),
00038    robMapVersion( " " ) {
00039   readOutChannelDriftTubeMap.reserve( 2000 );
00040   mType = rgBuf = rgROB = rgROS = rgDDU = grBuf = 0;
00041   grROB = grROS = grDDU = 0;
00042 }
00043 
00044 
00045 DTReadOutMapping::DTReadOutMapping( const std::string& cell_map_version,
00046                                     const std::string&  rob_map_version ):
00047   cellMapVersion( cell_map_version ),
00048    robMapVersion(  rob_map_version ) {
00049   readOutChannelDriftTubeMap.reserve( 2000 );
00050   mType = rgBuf = rgROB = rgROS = rgDDU = grBuf = 0;
00051   grROB = grROS = grDDU = 0;
00052 }
00053 
00054 
00055 DTReadOutGeometryLink::DTReadOutGeometryLink():
00056      dduId( 0 ),
00057      rosId( 0 ),
00058      robId( 0 ),
00059      tdcId( 0 ),
00060  channelId( 0 ),
00061    wheelId( 0 ),
00062  stationId( 0 ),
00063   sectorId( 0 ),
00064       slId( 0 ),
00065    layerId( 0 ),
00066     cellId( 0 ) {
00067 }
00068 
00069 //--------------
00070 // Destructor --
00071 //--------------
00072 DTReadOutMapping::~DTReadOutMapping() {
00073 
00074   delete mType;
00075   delete rgBuf;
00076 
00077   delete rgROB;
00078   delete rgROS;
00079   delete rgDDU;
00080   delete grBuf;
00081 
00082   if ( grROB != 0 ) {
00083     std::vector<std::vector<int>*> gr_list = grROB->contList();
00084     std::vector<std::vector<int>*>::const_iterator gr_iter = gr_list.begin();
00085     std::vector<std::vector<int>*>::const_iterator gr_iend = gr_list.end();
00086     while ( gr_iter != gr_iend ) delete *gr_iter++;
00087   }
00088   if ( grROS != 0 ) {
00089     std::vector<std::vector<int>*> gr_list = grROS->contList();
00090     std::vector<std::vector<int>*>::const_iterator gr_iter = gr_list.begin();
00091     std::vector<std::vector<int>*>::const_iterator gr_iend = gr_list.end();
00092     while ( gr_iter != gr_iend ) delete *gr_iter++;
00093   }
00094   if ( grDDU != 0 ) {
00095     std::vector<std::vector<int>*> gr_list = grDDU->contList();
00096     std::vector<std::vector<int>*>::const_iterator gr_iter = gr_list.begin();
00097     std::vector<std::vector<int>*>::const_iterator gr_iend = gr_list.end();
00098     while ( gr_iter != gr_iend ) delete *gr_iter++;
00099   }
00100 
00101   delete grROB;
00102   delete grROS;
00103   delete grDDU;
00104 
00105 }
00106 
00107 DTReadOutGeometryLink::~DTReadOutGeometryLink() {
00108 }
00109 
00110 //--------------
00111 // Operations --
00112 //--------------
00113 int DTReadOutMapping::readOutToGeometry( int      dduId,
00114                                          int      rosId,
00115                                          int      robId,
00116                                          int      tdcId,
00117                                          int  channelId,
00118                                          DTWireId& wireId ) const {
00119 
00120   int   wheelId;
00121   int stationId;
00122   int  sectorId;
00123   int      slId;
00124   int   layerId;
00125   int    cellId;
00126 
00127   int status = readOutToGeometry(      dduId,
00128                                        rosId,
00129                                        robId,
00130                                        tdcId,
00131                                    channelId,
00132                                      wheelId,
00133                                    stationId,
00134                                     sectorId,
00135                                         slId,
00136                                      layerId,
00137                                       cellId );
00138 
00139   wireId = DTWireId( wheelId, stationId, sectorId, slId, layerId, cellId );
00140   return status;
00141 
00142 }
00143 
00144 
00145 int DTReadOutMapping::readOutToGeometry( int      dduId,
00146                                          int      rosId,
00147                                          int      robId,
00148                                          int      tdcId,
00149                                          int  channelId,
00150                                          int&   wheelId,
00151                                          int& stationId,
00152                                          int&  sectorId,
00153                                          int&      slId,
00154                                          int&   layerId,
00155                                          int&    cellId ) const {
00156 
00157   wheelId   =
00158   stationId =
00159   sectorId  =
00160   slId      =
00161   layerId   =
00162   cellId    = 0;
00163 
00164   if ( ( mType == 0 ) ||
00165        ( rgBuf == 0 ) ||
00166        ( rgROB == 0 ) ||
00167        ( rgROS == 0 ) ||
00168        ( rgDDU == 0 ) ) cacheMap();
00169 
00170   int defaultValue;
00171   mType->find( 0, defaultValue );
00172   if ( defaultValue ) {
00173 
00174     int searchStatus;
00175     int ientry;
00176 
00177     std::vector<int> dduKey;
00178     dduKey.reserve( 5 );
00179     dduKey.push_back( dduId );
00180     dduKey.push_back( rosId );
00181     searchStatus = rgDDU->find( dduKey.begin(), dduKey.end(), ientry );
00182     if ( searchStatus ) return searchStatus;
00183     const DTReadOutGeometryLink& lros( readOutChannelDriftTubeMap[ientry] );
00184       wheelId = lros.  wheelId;
00185      sectorId = lros. sectorId;
00186 
00187     std::vector<int> rosKey;
00188     rosKey.reserve( 5 );
00189     rosKey.push_back( lros. cellId );
00190     rosKey.push_back( robId );
00191     searchStatus = rgROS->find( rosKey.begin(), rosKey.end(), ientry );
00192     if ( searchStatus ) return searchStatus;
00193     const DTReadOutGeometryLink& lrob( readOutChannelDriftTubeMap[ientry] );
00194     if ( lrob.  wheelId != defaultValue )  wheelId = lrob.  wheelId;
00195     stationId = lrob.stationId;
00196     if ( lrob. sectorId != defaultValue ) sectorId = lrob. sectorId;
00197 
00198     std::vector<int> robKey;
00199     robKey.reserve( 5 );
00200     robKey.push_back( lrob. cellId );
00201     robKey.push_back(     tdcId );
00202     robKey.push_back( channelId );
00203     searchStatus = rgROB->find( robKey.begin(), robKey.end(), ientry );
00204     if ( searchStatus ) return searchStatus;
00205     const DTReadOutGeometryLink& ltdc( readOutChannelDriftTubeMap[ientry] );
00206          slId = ltdc.     slId;
00207       layerId = ltdc.  layerId;
00208        cellId = ltdc.   cellId;
00209     return 0;
00210 
00211   }
00212 
00213   std::vector<int> chanKey;
00214   chanKey.reserve(5);
00215   chanKey.push_back(     dduId );
00216   chanKey.push_back(     rosId );
00217   chanKey.push_back(     robId );
00218   chanKey.push_back(     tdcId );
00219   chanKey.push_back( channelId );
00220   int ientry;
00221   int searchStatus = rgBuf->find( chanKey.begin(), chanKey.end(), ientry );
00222   if ( !searchStatus ) {
00223     const DTReadOutGeometryLink& link( readOutChannelDriftTubeMap[ientry] );
00224       wheelId = link.  wheelId;
00225     stationId = link.stationId;
00226      sectorId = link. sectorId;
00227          slId = link.     slId;
00228       layerId = link.  layerId;
00229        cellId = link.   cellId;
00230   }
00231 
00232   return searchStatus;
00233 
00234 }
00235 
00236 
00237 int DTReadOutMapping::geometryToReadOut( const DTWireId& wireId,
00238                                          int&     dduId,
00239                                          int&     rosId,
00240                                          int&     robId,
00241                                          int&     tdcId,
00242                                          int& channelId ) const {
00243   return geometryToReadOut( wireId.wheel(),
00244                   wireId.station(),
00245                   wireId.sector(),
00246                   wireId.superLayer(),
00247                   wireId.layer(),
00248                   wireId.wire(),
00249                                        dduId,
00250                                        rosId,
00251                                        robId,
00252                                        tdcId,
00253                                    channelId);
00254 }
00255 
00256 
00257 int DTReadOutMapping::geometryToReadOut( int    wheelId,
00258                                          int  stationId,
00259                                          int   sectorId,
00260                                          int       slId,
00261                                          int    layerId,
00262                                          int     cellId,
00263                                          int&     dduId,
00264                                          int&     rosId,
00265                                          int&     robId,
00266                                          int&     tdcId,
00267                                          int& channelId ) const {
00268 
00269   dduId =
00270   rosId =
00271   robId =
00272   tdcId =
00273   channelId = 0;
00274 
00275   if ( ( mType == 0 ) ||
00276        ( grBuf == 0 ) ||
00277        ( grROB == 0 ) ||
00278        ( grROS == 0 ) ||
00279        ( grDDU == 0 ) ) cacheMap();
00280 
00281   int defaultValue;
00282   mType->find( 0, defaultValue );
00283   if ( defaultValue ) {
00284 
00285     int loop1 = 0;
00286     int loop2 = 0;
00287     int loop3 = 0;
00288     int loop0 = 0;
00289 
00290     int searchStatus;
00291     int mapId = 0;
00292     std::vector<int>* robMLgr;
00293     std::vector<int>* rosMLgr;
00294     std::vector<int>* dduMLgr;
00295 
00296     std::vector<int> cellKey;
00297     cellKey.reserve(6);
00298     cellKey.push_back(  cellId );
00299     cellKey.push_back( layerId );
00300     cellKey.push_back(    slId );
00301     std::vector<int> stdcKey = cellKey;
00302     searchStatus = grROB->find( cellKey.begin(), cellKey.end(), robMLgr );
00303     if ( searchStatus ) return searchStatus;
00304     if ( !( robMLgr->size() ) ) return 1;
00305     std::vector<int>::const_iterator tdc_iter = robMLgr->begin();
00306     std::vector<int>::const_iterator tdc_iend = robMLgr->end();
00307     while( tdc_iter != tdc_iend ) {
00308       loop1++;
00309       const DTReadOutGeometryLink& ltdc(
00310             readOutChannelDriftTubeMap[*tdc_iter++] );
00311       channelId = ltdc.channelId;
00312           tdcId = ltdc.    tdcId;
00313       mapId = ltdc.rosId;
00314       cellKey.clear();
00315       cellKey.push_back( mapId );
00316       cellKey.push_back( stationId );
00317       std::vector<int> srosKey = cellKey;
00318       searchStatus = grROS->find( cellKey.begin(), cellKey.end(), rosMLgr );
00319       if ( searchStatus ) continue;
00320       if ( !( rosMLgr->size() ) ) continue;
00321       std::vector<int>::const_iterator ros_iter = rosMLgr->begin();
00322       std::vector<int>::const_iterator ros_iend = rosMLgr->end();
00323       while( ros_iter != ros_iend ) {
00324         loop2++;
00325         const DTReadOutGeometryLink& lros(
00326               readOutChannelDriftTubeMap[*ros_iter++] );
00327         int secCk = lros.sectorId;
00328         int wheCk = lros. wheelId;
00329         if ( ( secCk != defaultValue ) && 
00330              ( secCk != sectorId     ) ) continue;
00331         if ( ( wheCk != defaultValue ) && 
00332              ( wheCk !=  wheelId     ) ) continue;
00333         robId = lros.robId;
00334         mapId = lros.rosId;
00335         cellKey.clear();
00336         cellKey.push_back(    mapId );
00337         cellKey.push_back(  wheelId );
00338         cellKey.push_back( sectorId );
00339         std::vector<int> sdduKey = cellKey;
00340         searchStatus = grDDU->find( cellKey.begin(), cellKey.end(), dduMLgr );
00341         if ( searchStatus ) continue;
00342         if ( !( dduMLgr->size() ) ) continue;
00343         if ( searchStatus ) return searchStatus;
00344         if ( !( dduMLgr->size() ) ) return 1;
00345         loop0++;
00346         std::vector<int>::const_iterator ddu_iter = dduMLgr->begin();
00347         std::vector<int>::const_iterator ddu_iend = dduMLgr->end();
00348         while( ddu_iter != ddu_iend ) {
00349           loop3++;
00350           const DTReadOutGeometryLink& lddu(
00351                 readOutChannelDriftTubeMap[*ddu_iter++] );
00352           mapId = lros.rosId;
00353           if ( ( ( sectorId == secCk ) || 
00354                  ( sectorId == lddu.sectorId ) ) &&
00355                ( (  wheelId == wheCk ) || 
00356                  (  wheelId == lddu.wheelId ) ) ) {
00357             rosId = lddu.rosId;
00358             dduId = lddu.dduId;
00359             return 0;
00360           }
00361         }
00362       }
00363     }
00364 
00365     return 1;
00366 
00367   }
00368 
00369   std::vector<int> cellKey;
00370   cellKey.reserve(6);
00371   cellKey.push_back(   wheelId );
00372   cellKey.push_back( stationId );
00373   cellKey.push_back(  sectorId );
00374   cellKey.push_back(      slId );
00375   cellKey.push_back(   layerId );
00376   cellKey.push_back(    cellId );
00377   int ientry;
00378   int searchStatus = grBuf->find( cellKey.begin(), cellKey.end(), ientry );
00379   if ( !searchStatus ) {
00380     const DTReadOutGeometryLink& link( readOutChannelDriftTubeMap[ientry] );
00381         dduId = link.    dduId;
00382         rosId = link.    rosId;
00383         robId = link.    robId;
00384         tdcId = link.    tdcId;
00385     channelId = link.channelId;
00386   }
00387 
00388   return searchStatus;
00389 
00390 }
00391 
00392 
00393 DTReadOutMapping::type DTReadOutMapping::mapType() const {
00394   if ( mType == 0 ) cacheMap();
00395   int defaultValue;
00396   mType->find( 0, defaultValue );
00397   if ( defaultValue ) return compact;
00398   else                return plain;
00399 }
00400 
00401 
00402 const
00403 std::string& DTReadOutMapping::mapCellTdc() const {
00404   return cellMapVersion;
00405 }
00406 
00407 
00408 std::string& DTReadOutMapping::mapCellTdc() {
00409   return cellMapVersion;
00410 }
00411 
00412 
00413 const
00414 std::string& DTReadOutMapping::mapRobRos() const {
00415   return robMapVersion;
00416 }
00417 
00418 
00419 std::string& DTReadOutMapping::mapRobRos() {
00420   return robMapVersion;
00421 }
00422 
00423 
00424 void DTReadOutMapping::clear() {
00425   delete rgBuf;
00426   delete grBuf;
00427   delete mType;
00428   rgBuf = grBuf = mType = 0;
00429   readOutChannelDriftTubeMap.clear();
00430   return;
00431 }
00432 
00433 
00434 int DTReadOutMapping::insertReadOutGeometryLink( int     dduId,
00435                                                  int     rosId,
00436                                                  int     robId,
00437                                                  int     tdcId,
00438                                                  int channelId,
00439                                                  int   wheelId,
00440                                                  int stationId,
00441                                                  int  sectorId,
00442                                                  int      slId,
00443                                                  int   layerId,
00444                                                  int    cellId ) {
00445   DTReadOutGeometryLink link;
00446   link.    dduId =     dduId;
00447   link.    rosId =     rosId;
00448   link.    robId =     robId;
00449   link.    tdcId =     tdcId;
00450   link.channelId = channelId;
00451   link.  wheelId =   wheelId;
00452   link.stationId = stationId;
00453   link. sectorId =  sectorId;
00454   link.     slId =      slId;
00455   link.  layerId =   layerId;
00456   link.   cellId =    cellId;
00457 
00458   int ientry = readOutChannelDriftTubeMap.size();
00459   readOutChannelDriftTubeMap.push_back( link );
00460 
00461   if ( rgBuf == 0 ) {
00462     DTBufferTree<int,int>** prgBuf;
00463     prgBuf = const_cast<DTBufferTree<int,int>**>( &rgBuf );
00464     *prgBuf = new DTBufferTree<int,int>;
00465   }
00466   if ( grBuf == 0 ) {
00467     DTBufferTree<int,int>** pgrBuf;
00468     pgrBuf = const_cast<DTBufferTree<int,int>**>( &grBuf );
00469     *pgrBuf = new DTBufferTree<int,int>;
00470   }
00471 
00472   std::vector<int> cellKey;
00473   cellKey.reserve(6);
00474   cellKey.push_back(   wheelId );
00475   cellKey.push_back( stationId );
00476   cellKey.push_back(  sectorId );
00477   cellKey.push_back(      slId );
00478   cellKey.push_back(   layerId );
00479   cellKey.push_back(    cellId );
00480   int grStatus =
00481   grBuf->insert( cellKey.begin(), cellKey.end(), ientry );
00482   std::vector<int> chanKey;
00483   chanKey.reserve(5);
00484   chanKey.push_back(     dduId );
00485   chanKey.push_back(     rosId );
00486   chanKey.push_back(     robId );
00487   chanKey.push_back(     tdcId );
00488   chanKey.push_back( channelId );
00489   int rgStatus =
00490   rgBuf->insert( chanKey.begin(), chanKey.end(), ientry );
00491 
00492   if ( grStatus || rgStatus ) return 1;
00493   else                        return 0;
00494 
00495 }
00496 
00497 
00498 DTReadOutMapping::const_iterator DTReadOutMapping::begin() const {
00499   return readOutChannelDriftTubeMap.begin();
00500 }
00501 
00502 
00503 DTReadOutMapping::const_iterator DTReadOutMapping::end() const {
00504   return readOutChannelDriftTubeMap.end();
00505 }
00506 
00507 
00508 const DTReadOutMapping* DTReadOutMapping::fullMap() const {
00509   if ( mapType() == plain ) return this;
00510   DTCompactMapAbstractHandler* cmHandler =
00511                                DTCompactMapAbstractHandler::getInstance();
00512   if ( cmHandler == 0 ) {
00513       std::cout << "CondCoreDTPlugins library not loaded, "
00514                 << "compactMapHandler plugin missing" << std::endl;
00515     return 0;
00516   }
00517   return cmHandler->expandMap( *this );
00518 }
00519 
00520 
00521 std::string DTReadOutMapping::mapNameGR() const {
00522   std::stringstream name;
00523   name << cellMapVersion << "_" << robMapVersion << "_map_GR" << this;
00524   return name.str();
00525 }
00526 
00527 
00528 std::string DTReadOutMapping::mapNameRG() const {
00529   std::stringstream name;
00530   name << cellMapVersion << "_" << robMapVersion << "_map_RG" << this;
00531   return name.str();
00532 }
00533 
00534 
00535 void DTReadOutMapping::cacheMap() const {
00536 
00537   DTBufferTree<int,int>** pmType;
00538   pmType = const_cast<DTBufferTree<int,int>**>( &mType );
00539   *pmType = new DTBufferTree<int,int>;
00540 
00541   mType->insert( 0, 0 );
00542 
00543   DTBufferTree<int,int>** prgBuf;
00544   prgBuf = const_cast<DTBufferTree<int,int>**>( &rgBuf );
00545   *prgBuf = new DTBufferTree<int,int>;
00546   DTBufferTree<int,int>** pgrBuf;
00547   pgrBuf = const_cast<DTBufferTree<int,int>**>( &grBuf );
00548   *pgrBuf = new DTBufferTree<int,int>;
00549 
00550   DTBufferTree<int,int>** prgROB;
00551   prgROB = const_cast<DTBufferTree<int,int>**>( &rgROB );
00552   *prgROB = new DTBufferTree<int,int>;
00553   DTBufferTree<int,int>** prgROS;
00554   prgROS = const_cast<DTBufferTree<int,int>**>( &rgROS );
00555   *prgROS = new DTBufferTree<int,int>;
00556   DTBufferTree<int,int>** prgDDU;
00557   prgDDU = const_cast<DTBufferTree<int,int>**>( &rgDDU );
00558   *prgDDU = new DTBufferTree<int,int>;
00559   rgROB->setDefault( 0 );
00560   rgROS->setDefault( 0 );
00561   rgDDU->setDefault( 0 );
00562 
00563   DTBufferTree<int,std::vector<int>*>** pgrROB;
00564   pgrROB = const_cast<DTBufferTree<int,std::vector<int>*>**>( &grROB );
00565   *pgrROB = new DTBufferTree<int,std::vector<int>*>;
00566   DTBufferTree<int,std::vector<int>*>** pgrROS;
00567   pgrROS = const_cast<DTBufferTree<int,std::vector<int>*>**>( &grROS );
00568   *pgrROS = new DTBufferTree<int,std::vector<int>*>;
00569   DTBufferTree<int,std::vector<int>*>** pgrDDU;
00570   pgrDDU = const_cast<DTBufferTree<int,std::vector<int>*>**>( &grDDU );
00571   *pgrDDU = new DTBufferTree<int,std::vector<int>*>;
00572   grROB->setDefault( 0 );
00573   grROS->setDefault( 0 );
00574   grDDU->setDefault( 0 );
00575 
00576   int entryNum = 0;
00577   int entryMax = readOutChannelDriftTubeMap.size();
00578   std::vector<int> cellKey;
00579   cellKey.reserve(6);
00580   std::vector<int> chanKey;
00581   chanKey.reserve(5);
00582   int defaultValue = 0;
00583   int key;
00584   int val;
00585   int rosMapKey = 0;
00586   int robMapKey = 0;
00587   std::map<int,std::vector<int>*> dduEntries;
00588   for ( entryNum = 0; entryNum < entryMax; entryNum++ ) {
00589 
00590     const DTReadOutGeometryLink& link( readOutChannelDriftTubeMap[entryNum] );
00591 
00592     key = link.dduId;
00593     val = link.stationId;
00594     if ( key > 0x3fffffff ) {
00595       if ( link.  tdcId > 0x3fffffff ) {
00596         mType->insert( 0, defaultValue = link.  tdcId );
00597         rosMapKey = key;
00598       }
00599       else {
00600         mType->insert( 0, defaultValue = link.wheelId );
00601         robMapKey = key;
00602       }
00603     }
00604 
00605     if ( defaultValue == 0 ) {
00606 
00607       chanKey.clear();
00608       chanKey.push_back( link.    dduId );
00609       chanKey.push_back( link.    rosId );
00610       chanKey.push_back( link.    robId );
00611       chanKey.push_back( link.    tdcId );
00612       chanKey.push_back( link.channelId );
00613 
00614       rgBuf->insert( chanKey.begin(), chanKey.end(), entryNum );
00615 
00616       cellKey.clear();
00617       cellKey.push_back( link.  wheelId );
00618       cellKey.push_back( link.stationId );
00619       cellKey.push_back( link. sectorId );
00620       cellKey.push_back( link.     slId );
00621       cellKey.push_back( link.  layerId );
00622       cellKey.push_back( link.   cellId );
00623 
00624       grBuf->insert( cellKey.begin(), cellKey.end(), entryNum );
00625 
00626     }
00627 
00628     if ( key == robMapKey ) {
00629 
00630       chanKey.clear();
00631       chanKey.push_back( link.    rosId );
00632       chanKey.push_back( link.    tdcId );
00633       chanKey.push_back( link.channelId );
00634       rgROB->insert( chanKey.begin(), chanKey.end(), entryNum );
00635 
00636       cellKey.clear();
00637       cellKey.push_back( link. cellId );
00638       cellKey.push_back( link.layerId );
00639       cellKey.push_back( link.   slId );
00640       std::vector<int>* robMLgr;
00641       grROB->find( cellKey.begin(), cellKey.end(), robMLgr );
00642       if ( robMLgr == 0 ) grROB->insert( cellKey.begin(), cellKey.end(),
00643                                          robMLgr = new std::vector<int> );
00644       robMLgr->push_back( entryNum );
00645 
00646     }
00647 
00648     if ( key == rosMapKey ) {
00649 
00650       chanKey.clear();
00651       chanKey.push_back( link.rosId );
00652       chanKey.push_back( link.robId );
00653       rgROS->insert( chanKey.begin(), chanKey.end(), entryNum );
00654 
00655       cellKey.clear();
00656       cellKey.push_back( link.   cellId );
00657       cellKey.push_back( link.stationId );
00658       std::vector<int>* rosMLgr;
00659       grROS->find( cellKey.begin(), cellKey.end(), rosMLgr );
00660       if ( rosMLgr == 0 ) grROS->insert( cellKey.begin(), cellKey.end(),
00661                                          rosMLgr = new std::vector<int> );
00662       rosMLgr->push_back( entryNum );
00663 
00664     }
00665 
00666     if ( ( key < 0x3fffffff ) &&
00667          ( val > 0x3fffffff ) ) {
00668 
00669       chanKey.clear();
00670       chanKey.push_back( link.dduId );
00671       chanKey.push_back( link.rosId );
00672       rgDDU->insert( chanKey.begin(), chanKey.end(), entryNum );
00673 
00674       int mapId = link.cellId;
00675       std::vector<int>* dduMLgr;
00676       std::map<int,std::vector<int>*>::const_iterator dduEntIter =
00677                                        dduEntries.find( mapId );
00678       if ( dduEntIter == dduEntries.end() )
00679            dduEntries.insert( std::pair<int,std::vector<int>*>( mapId,
00680                                dduMLgr = new std::vector<int> ) );
00681       else                     dduMLgr = dduEntIter->second;
00682       dduMLgr->push_back( entryNum );
00683 
00684     }
00685 
00686   }
00687 
00688   if ( defaultValue != 0 ) {
00689     for ( entryNum = 0; entryNum < entryMax; entryNum++ ) {
00690       const DTReadOutGeometryLink& link( 
00691             readOutChannelDriftTubeMap[entryNum] );
00692       key = link.dduId;
00693       if ( key != rosMapKey ) continue;
00694       int    mapId = link.   rosId;
00695       int  whchkId = link. wheelId;
00696       int secchkId = link.sectorId;
00697 
00698       std::vector<int>* dduMLgr;
00699       std::map<int,std::vector<int>*>::const_iterator dduEntIter =
00700                                        dduEntries.find( mapId );
00701       if ( dduEntIter != dduEntries.end() ) dduMLgr = dduEntIter->second;
00702       else                                  continue;
00703       std::vector<int>::const_iterator dduIter = dduMLgr->begin();
00704       std::vector<int>::const_iterator dduIend = dduMLgr->end();
00705       while( dduIter != dduIend ) {
00706         int ientry = *dduIter++;
00707         const DTReadOutGeometryLink& lros(
00708               readOutChannelDriftTubeMap[ientry] );
00709         int  wheelId =  whchkId;
00710         int sectorId = secchkId;
00711         if (  wheelId == defaultValue )  wheelId = lros. wheelId;
00712         if ( sectorId == defaultValue ) sectorId = lros.sectorId;
00713         cellKey.clear();
00714         cellKey.push_back(    mapId );
00715         cellKey.push_back(  wheelId );
00716         cellKey.push_back( sectorId );
00717         std::vector<int>* dduMLgr = 0;
00718         grDDU->find( cellKey.begin(), cellKey.end(), dduMLgr );
00719         if ( dduMLgr == 0 ) grDDU->insert( cellKey.begin(), cellKey.end(),
00720                                            dduMLgr = new std::vector<int> );
00721         dduMLgr->push_back( ientry );
00722       }
00723 
00724     }
00725 
00726     std::map<int,std::vector<int>*>::const_iterator dduEntIter =
00727                                                     dduEntries.begin();
00728     std::map<int,std::vector<int>*>::const_iterator dduEntIend =
00729                                                     dduEntries.end();
00730     while ( dduEntIter != dduEntIend ) {
00731       const std::pair<int,std::vector<int>*>& dduEntry = *dduEntIter++;
00732       delete dduEntry.second;
00733     }
00734 
00735     delete rgBuf;
00736     delete grBuf;
00737   *prgBuf = new DTBufferTree<int,int>;
00738   *pgrBuf = new DTBufferTree<int,int>;
00739 
00740   }
00741 
00742   return;
00743 
00744 }
00745