CMS 3D CMS Logo

DTDeadFlag.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2008/07/15 15:57:23 $
00005  *  $Revision: 1.5 $
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 }
00033 
00034 
00035 DTDeadFlag::DTDeadFlag( const std::string& version ):
00036   dataVersion( version ) {
00037   dataList.reserve( 1000 );
00038 }
00039 
00040 
00041 DTDeadFlagId::DTDeadFlagId() :
00042     wheelId( 0 ),
00043   stationId( 0 ),
00044    sectorId( 0 ),
00045        slId( 0 ),
00046     layerId( 0 ),
00047      cellId( 0 ) {
00048 }
00049 
00050 
00051 DTDeadFlagData::DTDeadFlagData() :
00052    dead_HV( false ),
00053    dead_TP( false ),
00054    dead_RO( false ),
00055    discCat( false ) {
00056 }
00057 
00058 
00059 //--------------
00060 // Destructor --
00061 //--------------
00062 DTDeadFlag::~DTDeadFlag() {
00063   DTDataBuffer<int,int>::dropBuffer( mapName() );
00064 }
00065 
00066 
00067 DTDeadFlagId::~DTDeadFlagId() {
00068 }
00069 
00070 
00071 DTDeadFlagData::~DTDeadFlagData() {
00072 }
00073 
00074 
00075 //--------------
00076 // Operations --
00077 //--------------
00078 int DTDeadFlag::get( int   wheelId,
00079                      int stationId,
00080                      int  sectorId,
00081                      int      slId,
00082                      int   layerId,
00083                      int    cellId,
00084                      bool& dead_HV,
00085                      bool& dead_TP,
00086                      bool& dead_RO,
00087                      bool& discCat ) const {
00088 
00089   dead_HV =
00090   dead_TP =
00091   dead_RO =
00092   discCat = false;
00093 
00094   std::string mName = mapName();
00095   DTBufferTree<int,int>* dBuf =
00096   DTDataBuffer<int,int>::findBuffer( mName );
00097   if ( dBuf == 0 ) {
00098     cacheMap();
00099     dBuf =
00100     DTDataBuffer<int,int>::findBuffer( mName );
00101   }
00102   std::vector<int> chanKey;
00103   chanKey.reserve(6);
00104   chanKey.push_back(   wheelId );
00105   chanKey.push_back( stationId );
00106   chanKey.push_back(  sectorId );
00107   chanKey.push_back(      slId );
00108   chanKey.push_back(   layerId );
00109   chanKey.push_back(    cellId );
00110   int ientry;
00111   int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
00112   if ( !searchStatus ) {
00113     const DTDeadFlagData& data( dataList[ientry].second );
00114     dead_HV = data.dead_HV;
00115     dead_TP = data.dead_TP;
00116     dead_RO = data.dead_RO;
00117     discCat = data.discCat;
00118   }
00119 
00120   return searchStatus;
00121 
00122 }
00123 
00124 
00125 int DTDeadFlag::get( const DTWireId& id,
00126                      bool& dead_HV,
00127                      bool& dead_TP,
00128                      bool& dead_RO,
00129                      bool& discCat ) const {
00130   return get( id.wheel(),
00131               id.station(),
00132               id.sector(),
00133               id.superLayer(),
00134               id.layer(),
00135               id.wire(),
00136               dead_HV, dead_TP, dead_RO, discCat );
00137 }
00138 
00139 
00140 const
00141 std::string& DTDeadFlag::version() const {
00142   return dataVersion;
00143 }
00144 
00145 
00146 std::string& DTDeadFlag::version() {
00147   return dataVersion;
00148 }
00149 
00150 
00151 void DTDeadFlag::clear() {
00152   DTDataBuffer<int,int>::dropBuffer( mapName() );
00153   dataList.clear();
00154   return;
00155 }
00156 
00157 
00158 int DTDeadFlag::setCellStatus( int   wheelId,
00159                                int stationId,
00160                                int  sectorId,
00161                                int      slId,
00162                                int   layerId,
00163                                int    cellId,
00164                                bool dead_HV,
00165                                bool dead_TP,
00166                                bool dead_RO,
00167                                bool discCat ) {
00168 
00169   std::string mName = mapName();
00170   DTBufferTree<int,int>* dBuf =
00171   DTDataBuffer<int,int>::findBuffer( mName );
00172   if ( dBuf == 0 ) {
00173     cacheMap();
00174     dBuf =
00175     DTDataBuffer<int,int>::findBuffer( mName );
00176   }
00177   std::vector<int> chanKey;
00178   chanKey.reserve(6);
00179   chanKey.push_back(   wheelId );
00180   chanKey.push_back( stationId );
00181   chanKey.push_back(  sectorId );
00182   chanKey.push_back(      slId );
00183   chanKey.push_back(   layerId );
00184   chanKey.push_back(    cellId );
00185   int ientry;
00186   int searchStatus = dBuf->find( chanKey.begin(), chanKey.end(), ientry );
00187 
00188   if ( !searchStatus ) {
00189     DTDeadFlagData& data( dataList[ientry].second );
00190     data.dead_HV = dead_HV;
00191     data.dead_TP = dead_TP;
00192     data.dead_RO = dead_RO;
00193     data.discCat = discCat;
00194     return -1;
00195   }
00196   else {
00197     DTDeadFlagId key;
00198     key.  wheelId =   wheelId;
00199     key.stationId = stationId;
00200     key. sectorId =  sectorId;
00201     key.     slId =      slId;
00202     key.  layerId =   layerId;
00203     key.   cellId =    cellId;
00204     DTDeadFlagData data;
00205     data.dead_HV = dead_HV;
00206     data.dead_TP = dead_TP;
00207     data.dead_RO = dead_RO;
00208     data.discCat = discCat;
00209     ientry = dataList.size();
00210     dataList.push_back( std::pair<const DTDeadFlagId,
00211                                         DTDeadFlagData>( key, data ) );
00212     dBuf->insert( chanKey.begin(), chanKey.end(), ientry );
00213     return 0;
00214   }
00215 
00216   return 99;
00217 
00218 }
00219 
00220 
00221 int DTDeadFlag::setCellStatus( const DTWireId& id,
00222                                bool dead_HV,
00223                                bool dead_TP,
00224                                bool dead_RO,
00225                                bool discCat ) {
00226   return setCellStatus( id.wheel(),
00227                         id.station(),
00228                         id.sector(),
00229                         id.superLayer(),
00230                         id.layer(),
00231                         id.wire(),
00232                         dead_HV, dead_TP, dead_RO, discCat );
00233 }
00234 
00235 
00236 int DTDeadFlag::setCellDead_HV( int   wheelId,
00237                                 int stationId,
00238                                 int  sectorId,
00239                                 int      slId,
00240                                 int   layerId,
00241                                 int    cellId,
00242                                 bool flag ) {
00243 
00244   bool dead_HV;
00245   bool dead_TP;
00246   bool dead_RO;
00247   bool discCat;
00248   int status = cellStatus(   wheelId,
00249                            stationId,
00250                             sectorId,
00251                                 slId,
00252                              layerId,
00253                               cellId,
00254                              dead_HV, dead_TP, dead_RO, discCat );
00255   setCellStatus(   wheelId,
00256                  stationId,
00257                   sectorId,
00258                       slId,
00259                    layerId,
00260                     cellId,
00261                       flag, dead_TP, dead_RO, discCat );
00262   return status;
00263 
00264 }
00265 
00266 
00267 int DTDeadFlag::setCellDead_HV( const DTWireId& id,
00268                                 bool flag ) {
00269   return setCellDead_HV( id.wheel(),
00270                          id.station(),
00271                          id.sector(),
00272                          id.superLayer(),
00273                          id.layer(),
00274                          id.wire(),
00275                          flag );
00276 }
00277 
00278 
00279 int DTDeadFlag::setCellDead_TP( int   wheelId,
00280                                 int stationId,
00281                                 int  sectorId,
00282                                 int      slId,
00283                                 int   layerId,
00284                                 int    cellId,
00285                                 bool flag ) {
00286 
00287   bool dead_HV;
00288   bool dead_TP;
00289   bool dead_RO;
00290   bool discCat;
00291   int status = cellStatus(   wheelId,
00292                            stationId,
00293                             sectorId,
00294                                 slId,
00295                              layerId,
00296                               cellId,
00297                              dead_HV, dead_TP, dead_RO, discCat );
00298   setCellStatus(   wheelId,
00299                  stationId,
00300                   sectorId,
00301                       slId,
00302                    layerId,
00303                     cellId,
00304                    dead_HV, flag, dead_RO, discCat );
00305   return status;
00306 
00307 }
00308 
00309 
00310 int DTDeadFlag::setCellDead_TP( const DTWireId& id,
00311                                 bool flag ) {
00312   return setCellDead_TP( id.wheel(),
00313                          id.station(),
00314                          id.sector(),
00315                          id.superLayer(),
00316                          id.layer(),
00317                          id.wire(),
00318                          flag );
00319 }
00320 
00321 
00322 int DTDeadFlag::setCellDead_RO( int   wheelId,
00323                                 int stationId,
00324                                 int  sectorId,
00325                                 int      slId,
00326                                 int   layerId,
00327                                 int    cellId,
00328                                 bool flag ) {
00329 
00330   bool dead_HV;
00331   bool dead_TP;
00332   bool dead_RO;
00333   bool discCat;
00334   int status = cellStatus(   wheelId,
00335                            stationId,
00336                             sectorId,
00337                                 slId,
00338                              layerId,
00339                               cellId,
00340                              dead_HV, dead_TP, dead_RO, discCat );
00341   setCellStatus(   wheelId,
00342                  stationId,
00343                   sectorId,
00344                       slId,
00345                    layerId,
00346                     cellId,
00347                    dead_HV, dead_TP, flag, discCat );
00348   return status;
00349 
00350 }
00351 
00352 
00353 int DTDeadFlag::setCellDead_RO( const DTWireId& id,
00354                                 bool flag ) {
00355   return setCellDead_RO( id.wheel(),
00356                          id.station(),
00357                          id.sector(),
00358                          id.superLayer(),
00359                          id.layer(),
00360                          id.wire(),
00361                          flag );
00362 }
00363 
00364 
00365 int DTDeadFlag::setCellDiscCat( int   wheelId,
00366                                 int stationId,
00367                                 int  sectorId,
00368                                 int      slId,
00369                                 int   layerId,
00370                                 int    cellId,
00371                                 bool flag ) {
00372 
00373   bool dead_HV;
00374   bool dead_TP;
00375   bool dead_RO;
00376   bool discCat;
00377   int status = cellStatus(   wheelId,
00378                            stationId,
00379                             sectorId,
00380                                 slId,
00381                              layerId,
00382                               cellId,
00383                              dead_HV, dead_TP, dead_RO, discCat );
00384   setCellStatus(   wheelId,
00385                  stationId,
00386                   sectorId,
00387                       slId,
00388                    layerId,
00389                     cellId,
00390                    dead_HV, dead_TP, dead_RO, flag );
00391   return status;
00392 
00393 }
00394 
00395 
00396 int DTDeadFlag::setCellDiscCat( const DTWireId& id,
00397                                 bool flag ) {
00398   return setCellDiscCat( id.wheel(),
00399                          id.station(),
00400                          id.sector(),
00401                          id.superLayer(),
00402                          id.layer(),
00403                          id.wire(),
00404                          flag );
00405 }
00406 
00407 
00408 DTDeadFlag::const_iterator DTDeadFlag::begin() const {
00409   return dataList.begin();
00410 }
00411 
00412 
00413 DTDeadFlag::const_iterator DTDeadFlag::end() const {
00414   return dataList.end();
00415 }
00416 
00417 
00418 std::string DTDeadFlag::mapName() const {
00419   std::stringstream name;
00420   name << dataVersion << "_map_DeadFlag" << this;
00421   return name.str();
00422 }
00423 
00424 
00425 void DTDeadFlag::cacheMap() const {
00426 
00427   std::string mName = mapName();
00428   DTBufferTree<int,int>* dBuf =
00429   DTDataBuffer<int,int>::openBuffer( mName );
00430 
00431   int entryNum = 0;
00432   int entryMax = dataList.size();
00433   std::vector<int> chanKey;
00434   chanKey.reserve(6);
00435   while ( entryNum < entryMax ) {
00436 
00437     const DTDeadFlagId& chan = dataList[entryNum].first;
00438 
00439     chanKey.clear();
00440     chanKey.push_back( chan.  wheelId );
00441     chanKey.push_back( chan.stationId );
00442     chanKey.push_back( chan. sectorId );
00443     chanKey.push_back( chan.     slId );
00444     chanKey.push_back( chan.  layerId );
00445     chanKey.push_back( chan.   cellId );
00446     dBuf->insert( chanKey.begin(), chanKey.end(), entryNum++ );
00447 
00448   }
00449 
00450   return;
00451 
00452 }
00453 

Generated on Tue Jun 9 17:26:26 2009 for CMSSW by  doxygen 1.5.4