CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondFormats/DTObjects/src/DTDeadFlag.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2010/01/20 18:20:08 $
00005  *  $Revision: 1.7 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //----------------------
00011 // This Class' Header --
00012 //----------------------
00013 #include "CondFormats/DTObjects/interface/DTDeadFlag.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 
00026 //----------------
00027 // Constructors --
00028 //----------------
00029 DTDeadFlag::DTDeadFlag():
00030   dataVersion( " " ) {
00031   dataList.reserve( 1000 );
00032   dBuf = 0;
00033 }
00034 
00035 
00036 DTDeadFlag::DTDeadFlag( const std::string& version ):
00037   dataVersion( version ) {
00038   dataList.reserve( 1000 );
00039   dBuf = 0;
00040 }
00041 
00042 
00043 DTDeadFlagId::DTDeadFlagId() :
00044     wheelId( 0 ),
00045   stationId( 0 ),
00046    sectorId( 0 ),
00047        slId( 0 ),
00048     layerId( 0 ),
00049      cellId( 0 ) {
00050 }
00051 
00052 
00053 DTDeadFlagData::DTDeadFlagData() :
00054    dead_HV( false ),
00055    dead_TP( false ),
00056    dead_RO( false ),
00057    discCat( false ) {
00058 }
00059 
00060 
00061 //--------------
00062 // Destructor --
00063 //--------------
00064 DTDeadFlag::~DTDeadFlag() {
00065 //  DTDataBuffer<int,int>::dropBuffer( mapName() );
00066   delete dBuf;
00067 }
00068 
00069 
00070 DTDeadFlagId::~DTDeadFlagId() {
00071 }
00072 
00073 
00074 DTDeadFlagData::~DTDeadFlagData() {
00075 }
00076 
00077 
00078 //--------------
00079 // Operations --
00080 //--------------
00081 int DTDeadFlag::get( int   wheelId,
00082                      int stationId,
00083                      int  sectorId,
00084                      int      slId,
00085                      int   layerId,
00086                      int    cellId,
00087                      bool& dead_HV,
00088                      bool& dead_TP,
00089                      bool& dead_RO,
00090                      bool& discCat ) const {
00091 
00092   dead_HV =
00093   dead_TP =
00094   dead_RO =
00095   discCat = false;
00096 
00097 //  std::string mName = mapName();
00098 //  DTBufferTree<int,int>* dBuf =
00099 //  DTDataBuffer<int,int>::findBuffer( mName );
00100 //  if ( dBuf == 0 ) {
00101 //    cacheMap();
00102 //    dBuf =
00103 //    DTDataBuffer<int,int>::findBuffer( mName );
00104 //  }
00105   if ( dBuf == 0 ) cacheMap();
00106   std::vector<int> chanKey;
00107   chanKey.reserve(6);
00108   chanKey.push_back(   wheelId );
00109   chanKey.push_back( stationId );
00110   chanKey.push_back(  sectorId );
00111   chanKey.push_back(      slId );
00112   chanKey.push_back(   layerId );
00113   chanKey.push_back(    cellId );
00114   int ientry;
00115   int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
00116   if ( !searchStatus ) {
00117     const DTDeadFlagData& data( dataList[ientry].second );
00118     dead_HV = data.dead_HV;
00119     dead_TP = data.dead_TP;
00120     dead_RO = data.dead_RO;
00121     discCat = data.discCat;
00122   }
00123 
00124   return searchStatus;
00125 
00126 }
00127 
00128 
00129 int DTDeadFlag::get( const DTWireId& id,
00130                      bool& dead_HV,
00131                      bool& dead_TP,
00132                      bool& dead_RO,
00133                      bool& discCat ) const {
00134   return get( id.wheel(),
00135               id.station(),
00136               id.sector(),
00137               id.superLayer(),
00138               id.layer(),
00139               id.wire(),
00140               dead_HV, dead_TP, dead_RO, discCat );
00141 }
00142 
00143 
00144 bool DTDeadFlag::getCellDead_HV( int   wheelId,
00145                                  int stationId,
00146                                  int  sectorId,
00147                                  int      slId,
00148                                  int   layerId,
00149                                  int    cellId ) const {
00150 
00151   bool dead_HV;
00152   bool dead_TP;
00153   bool dead_RO;
00154   bool discCat;
00155   get(   wheelId,
00156        stationId,
00157         sectorId,
00158             slId,
00159          layerId,
00160           cellId,
00161          dead_HV, dead_TP, dead_RO, discCat );
00162   return dead_HV;
00163 
00164 }
00165 
00166 
00167 bool DTDeadFlag::getCellDead_HV( const DTWireId& id ) const {
00168   return getCellDead_HV( id.wheel(),
00169                          id.station(),
00170                          id.sector(),
00171                          id.superLayer(),
00172                          id.layer(),
00173                          id.wire() );
00174 }
00175 
00176 
00177 bool DTDeadFlag::getCellDead_TP( int   wheelId,
00178                                  int stationId,
00179                                  int  sectorId,
00180                                  int      slId,
00181                                  int   layerId,
00182                                  int    cellId ) const {
00183 
00184   bool dead_HV;
00185   bool dead_TP;
00186   bool dead_RO;
00187   bool discCat;
00188   get(   wheelId,
00189        stationId,
00190         sectorId,
00191             slId,
00192          layerId,
00193           cellId,
00194          dead_HV, dead_TP, dead_RO, discCat );
00195   return dead_TP;
00196 
00197 }
00198 
00199 
00200 bool DTDeadFlag::getCellDead_TP( const DTWireId& id ) const {
00201   return getCellDead_TP( id.wheel(),
00202                          id.station(),
00203                          id.sector(),
00204                          id.superLayer(),
00205                          id.layer(),
00206                          id.wire() );
00207 }
00208 
00209 
00210 bool DTDeadFlag::getCellDead_RO( int   wheelId,
00211                                  int stationId,
00212                                  int  sectorId,
00213                                  int      slId,
00214                                  int   layerId,
00215                                  int    cellId ) const {
00216 
00217   bool dead_HV;
00218   bool dead_TP;
00219   bool dead_RO;
00220   bool discCat;
00221   get(   wheelId,
00222        stationId,
00223         sectorId,
00224             slId,
00225          layerId,
00226           cellId,
00227          dead_HV, dead_TP, dead_RO, discCat );
00228   return dead_RO;
00229 
00230 }
00231 
00232 
00233 bool DTDeadFlag::getCellDead_RO( const DTWireId& id ) const {
00234   return getCellDead_RO( id.wheel(),
00235                          id.station(),
00236                          id.sector(),
00237                          id.superLayer(),
00238                          id.layer(),
00239                          id.wire() );
00240 }
00241 
00242 
00243 bool DTDeadFlag::getCellDiscCat( int   wheelId,
00244                                  int stationId,
00245                                  int  sectorId,
00246                                  int      slId,
00247                                  int   layerId,
00248                                  int    cellId ) const {
00249 
00250   bool dead_HV;
00251   bool dead_TP;
00252   bool dead_RO;
00253   bool discCat;
00254   get(   wheelId,
00255        stationId,
00256         sectorId,
00257             slId,
00258          layerId,
00259           cellId,
00260          dead_HV, dead_TP, dead_RO, discCat );
00261   return discCat;
00262 
00263 }
00264 
00265 
00266 bool DTDeadFlag::getCellDiscCat( const DTWireId& id ) const {
00267   return getCellDiscCat( id.wheel(),
00268                          id.station(),
00269                          id.sector(),
00270                          id.superLayer(),
00271                          id.layer(),
00272                          id.wire() );
00273 }
00274 
00275 
00276 const
00277 std::string& DTDeadFlag::version() const {
00278   return dataVersion;
00279 }
00280 
00281 
00282 std::string& DTDeadFlag::version() {
00283   return dataVersion;
00284 }
00285 
00286 
00287 void DTDeadFlag::clear() {
00288 //  DTDataBuffer<int,int>::dropBuffer( mapName() );
00289   delete dBuf;
00290   dBuf = 0;
00291   dataList.clear();
00292   return;
00293 }
00294 
00295 
00296 int DTDeadFlag::set( int   wheelId,
00297                      int stationId,
00298                      int  sectorId,
00299                      int      slId,
00300                      int   layerId,
00301                      int    cellId,
00302                      bool dead_HV,
00303                      bool dead_TP,
00304                      bool dead_RO,
00305                      bool discCat ) {
00306 
00307 //  std::string mName = mapName();
00308 //  DTBufferTree<int,int>* dBuf =
00309 //  DTDataBuffer<int,int>::findBuffer( mName );
00310 //  if ( dBuf == 0 ) {
00311 //    cacheMap();
00312 //    dBuf =
00313 //    DTDataBuffer<int,int>::findBuffer( mName );
00314 //  }
00315   if ( dBuf == 0 ) cacheMap();
00316   std::vector<int> chanKey;
00317   chanKey.reserve(6);
00318   chanKey.push_back(   wheelId );
00319   chanKey.push_back( stationId );
00320   chanKey.push_back(  sectorId );
00321   chanKey.push_back(      slId );
00322   chanKey.push_back(   layerId );
00323   chanKey.push_back(    cellId );
00324   int ientry;
00325   int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
00326 
00327   if ( !searchStatus ) {
00328     DTDeadFlagData& data( dataList[ientry].second );
00329     data.dead_HV = dead_HV;
00330     data.dead_TP = dead_TP;
00331     data.dead_RO = dead_RO;
00332     data.discCat = discCat;
00333     return -1;
00334   }
00335   else {
00336     DTDeadFlagId key;
00337     key.  wheelId =   wheelId;
00338     key.stationId = stationId;
00339     key. sectorId =  sectorId;
00340     key.     slId =      slId;
00341     key.  layerId =   layerId;
00342     key.   cellId =    cellId;
00343     DTDeadFlagData data;
00344     data.dead_HV = dead_HV;
00345     data.dead_TP = dead_TP;
00346     data.dead_RO = dead_RO;
00347     data.discCat = discCat;
00348     ientry = dataList.size();
00349     dataList.push_back( std::pair<const DTDeadFlagId,
00350                                         DTDeadFlagData>( key, data ) );
00351     dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
00352     return 0;
00353   }
00354 
00355   return 99;
00356 
00357 }
00358 
00359 
00360 int DTDeadFlag::set( const DTWireId& id,
00361                      bool dead_HV,
00362                      bool dead_TP,
00363                      bool dead_RO,
00364                      bool discCat ) {
00365   return set( id.wheel(),
00366               id.station(),
00367               id.sector(),
00368               id.superLayer(),
00369               id.layer(),
00370               id.wire(),
00371               dead_HV, dead_TP, dead_RO, discCat );
00372 }
00373 
00374 
00375 int DTDeadFlag::setCellDead_HV( int   wheelId,
00376                                 int stationId,
00377                                 int  sectorId,
00378                                 int      slId,
00379                                 int   layerId,
00380                                 int    cellId,
00381                                 bool flag ) {
00382 
00383   bool dead_HV;
00384   bool dead_TP;
00385   bool dead_RO;
00386   bool discCat;
00387   int status = cellStatus(   wheelId,
00388                            stationId,
00389                             sectorId,
00390                                 slId,
00391                              layerId,
00392                               cellId,
00393                              dead_HV, dead_TP, dead_RO, discCat );
00394   setCellStatus(   wheelId,
00395                  stationId,
00396                   sectorId,
00397                       slId,
00398                    layerId,
00399                     cellId,
00400                       flag, dead_TP, dead_RO, discCat );
00401   return status;
00402 
00403 }
00404 
00405 
00406 int DTDeadFlag::setCellDead_HV( const DTWireId& id,
00407                                 bool flag ) {
00408   return setCellDead_HV( id.wheel(),
00409                          id.station(),
00410                          id.sector(),
00411                          id.superLayer(),
00412                          id.layer(),
00413                          id.wire(),
00414                          flag );
00415 }
00416 
00417 
00418 int DTDeadFlag::setCellDead_TP( int   wheelId,
00419                                 int stationId,
00420                                 int  sectorId,
00421                                 int      slId,
00422                                 int   layerId,
00423                                 int    cellId,
00424                                 bool flag ) {
00425 
00426   bool dead_HV;
00427   bool dead_TP;
00428   bool dead_RO;
00429   bool discCat;
00430   int status = cellStatus(   wheelId,
00431                            stationId,
00432                             sectorId,
00433                                 slId,
00434                              layerId,
00435                               cellId,
00436                              dead_HV, dead_TP, dead_RO, discCat );
00437   setCellStatus(   wheelId,
00438                  stationId,
00439                   sectorId,
00440                       slId,
00441                    layerId,
00442                     cellId,
00443                    dead_HV, flag, dead_RO, discCat );
00444   return status;
00445 
00446 }
00447 
00448 
00449 int DTDeadFlag::setCellDead_TP( const DTWireId& id,
00450                                 bool flag ) {
00451   return setCellDead_TP( id.wheel(),
00452                          id.station(),
00453                          id.sector(),
00454                          id.superLayer(),
00455                          id.layer(),
00456                          id.wire(),
00457                          flag );
00458 }
00459 
00460 
00461 int DTDeadFlag::setCellDead_RO( int   wheelId,
00462                                 int stationId,
00463                                 int  sectorId,
00464                                 int      slId,
00465                                 int   layerId,
00466                                 int    cellId,
00467                                 bool flag ) {
00468 
00469   bool dead_HV;
00470   bool dead_TP;
00471   bool dead_RO;
00472   bool discCat;
00473   int status = cellStatus(   wheelId,
00474                            stationId,
00475                             sectorId,
00476                                 slId,
00477                              layerId,
00478                               cellId,
00479                              dead_HV, dead_TP, dead_RO, discCat );
00480   setCellStatus(   wheelId,
00481                  stationId,
00482                   sectorId,
00483                       slId,
00484                    layerId,
00485                     cellId,
00486                    dead_HV, dead_TP, flag, discCat );
00487   return status;
00488 
00489 }
00490 
00491 
00492 int DTDeadFlag::setCellDead_RO( const DTWireId& id,
00493                                 bool flag ) {
00494   return setCellDead_RO( id.wheel(),
00495                          id.station(),
00496                          id.sector(),
00497                          id.superLayer(),
00498                          id.layer(),
00499                          id.wire(),
00500                          flag );
00501 }
00502 
00503 
00504 int DTDeadFlag::setCellDiscCat( int   wheelId,
00505                                 int stationId,
00506                                 int  sectorId,
00507                                 int      slId,
00508                                 int   layerId,
00509                                 int    cellId,
00510                                 bool flag ) {
00511 
00512   bool dead_HV;
00513   bool dead_TP;
00514   bool dead_RO;
00515   bool discCat;
00516   int status = cellStatus(   wheelId,
00517                            stationId,
00518                             sectorId,
00519                                 slId,
00520                              layerId,
00521                               cellId,
00522                              dead_HV, dead_TP, dead_RO, discCat );
00523   setCellStatus(   wheelId,
00524                  stationId,
00525                   sectorId,
00526                       slId,
00527                    layerId,
00528                     cellId,
00529                    dead_HV, dead_TP, dead_RO, flag );
00530   return status;
00531 
00532 }
00533 
00534 
00535 int DTDeadFlag::setCellDiscCat( const DTWireId& id,
00536                                 bool flag ) {
00537   return setCellDiscCat( id.wheel(),
00538                          id.station(),
00539                          id.sector(),
00540                          id.superLayer(),
00541                          id.layer(),
00542                          id.wire(),
00543                          flag );
00544 }
00545 
00546 
00547 DTDeadFlag::const_iterator DTDeadFlag::begin() const {
00548   return dataList.begin();
00549 }
00550 
00551 
00552 DTDeadFlag::const_iterator DTDeadFlag::end() const {
00553   return dataList.end();
00554 }
00555 
00556 
00557 std::string DTDeadFlag::mapName() const {
00558   std::stringstream name;
00559   name << dataVersion << "_map_DeadFlag" << this;
00560   return name.str();
00561 }
00562 
00563 
00564 void DTDeadFlag::cacheMap() const {
00565 
00566 //  std::string mName = mapName();
00567 //  DTBufferTree<int,int>* dBuf =
00568 //  DTDataBuffer<int,int>::openBuffer( mName );
00569   DTBufferTree<int,int>** pBuf;
00570   pBuf = const_cast<DTBufferTree<int,int>**>( &dBuf );
00571   *pBuf = new DTBufferTree<int,int>;
00572 
00573   int entryNum = 0;
00574   int entryMax = dataList.size();
00575   std::vector<int> chanKey;
00576   chanKey.reserve(6);
00577   while ( entryNum < entryMax ) {
00578 
00579     const DTDeadFlagId& chan = dataList[entryNum].first;
00580 
00581     chanKey.clear();
00582     chanKey.push_back( chan.  wheelId );
00583     chanKey.push_back( chan.stationId );
00584     chanKey.push_back( chan. sectorId );
00585     chanKey.push_back( chan.     slId );
00586     chanKey.push_back( chan.  layerId );
00587     chanKey.push_back( chan.   cellId );
00588     dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
00589 
00590   }
00591 
00592   return;
00593 
00594 }
00595