CMS 3D CMS Logo

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