CMS 3D CMS Logo

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