CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/CondTools/DT/src/DTHVHandler.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2009/03/26 14:11:04 $
00005  *  $Revision: 1.1 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //----------------------
00011 // This Class' Header --
00012 //----------------------
00013 #include "CondTools/DT/interface/DTHVHandler.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTHVStatus.h"
00019 #include "DataFormats/MuonDetId/interface/DTWireId.h"
00020 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00021 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
00022 //#include "Geometry/DTGeometry/interface/DTGeometry.h"
00023 //#include "Geometry/Records/interface/MuonGeometryRecord.h"
00024 
00025 //---------------
00026 // C++ Headers --
00027 //---------------
00028 
00029 
00030 //-------------------
00031 // Initializations --
00032 //-------------------
00033 
00034 
00035 //----------------
00036 // Constructors --
00037 //----------------
00038 DTHVHandler::DTHVHandler():
00039   objectPtr ( 0 ) {
00040 }
00041 
00042 
00043 /*
00044 DTHVHandler::DTHVHandler( const DTHVStatus* dbObject,
00045                           const DTGeometry* geometry ):
00046   objectPtr( dbObject ),
00047   dtGeomPtr( geometry ) {
00048 }
00049 */
00050 DTHVHandler::DTHVHandler( const DTHVStatus* dbObject ):
00051   objectPtr( dbObject ) {
00052 }
00053 
00054 
00055 //--------------
00056 // Destructor --
00057 //--------------
00058 DTHVHandler::~DTHVHandler() {
00059 }
00060 
00061 
00062 //--------------
00063 // Operations --
00064 //--------------
00065 int DTHVHandler::get( const DTWireId& id,
00066                       int&         flagA,
00067                       int&         flagC,
00068                       int&         flagS ) const {
00069 /*
00070   if ( objectPtr == 0 ) {
00071     flagA = flagC = flagS = 0;
00072     return 999;
00073   }
00074   return objectPtr->get( id.wheel(),
00075                          id.station(),
00076                          id.sector(),
00077                          id.superLayer(),
00078                          id.layer(),
00079                          findLayerPart( id ),
00080                          flagA, flagC, flagS );
00081 */
00082   flagA = flagC = flagS = 0;
00083   if ( objectPtr == 0 ) return 999;
00084   int iCell = id.wire();
00085   int fCell;
00086   int lCell;
00087   int
00088   fCheck = objectPtr->get( id.wheel(),
00089                            id.station(),
00090                            id.sector(),
00091                            id.superLayer(),
00092                            id.layer(),
00093                            0,     fCell, lCell,
00094                            flagA, flagC, flagS );
00095   if ( ( fCheck == 0 ) &&
00096        ( fCell <= iCell ) &&
00097        ( lCell >= iCell ) ) return 0;
00098   fCheck = objectPtr->get( id.wheel(),
00099                            id.station(),
00100                            id.sector(),
00101                            id.superLayer(),
00102                            id.layer(),
00103                            1,     fCell, lCell,
00104                            flagA, flagC, flagS );
00105   if ( ( fCheck == 0 ) &&
00106        ( fCell <= iCell ) &&
00107        ( lCell >= iCell ) ) return 0;
00108   flagA = flagC = flagS = 0;
00109   return 1;
00110 }
00111 
00112 
00113 int DTHVHandler::offChannelsNumber() const {
00114   int offNum = 0;
00115   DTHVStatus::const_iterator iter = objectPtr->begin();
00116   DTHVStatus::const_iterator iend = objectPtr->end();
00117   while ( iter != iend ) {
00118     const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
00119     DTHVStatusId   hvId = entry.first;
00120     DTHVStatusData data = entry.second;
00121     if (   data.flagA || data.flagC || data.flagS   )
00122            offNum += ( 1 + data.lCell - data.fCell );
00123   }
00124   return offNum;
00125 }
00126 
00127 
00128 int DTHVHandler::offChannelsNumber( const DTChamberId& id ) const {
00129   int offNum = 0;
00130   DTHVStatus::const_iterator iter = objectPtr->begin();
00131   DTHVStatus::const_iterator iend = objectPtr->end();
00132 /*
00133   while ( iter != iend ) {
00134     const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
00135     DTHVStatusId   idCh = entry.first;
00136     DTHVStatusData data = entry.second;
00137     DTLayerId idL( idCh.wheelId, idCh.stationId, idCh.sectorId,
00138                    idCh.slId,    idCh.layerId );
00139     int fCell;
00140     int lCell;
00141     getLayerEdges( idL, idCh.partId, fCell, lCell );
00142     if ( data.flagA || data.flagC || data.flagS )
00143          offNum += ( 1 + lCell - fCell );
00144   }
00145 */
00146   while ( iter != iend ) {
00147     const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
00148     DTHVStatusId   hvId = entry.first;
00149     DTHVStatusData data = entry.second;
00150     if ( ( hvId.  wheelId == id.  wheel() ) &&
00151          ( hvId.stationId == id.station() ) &&
00152          ( hvId. sectorId == id. sector() ) &&
00153          ( data.flagA || data.flagC || data.flagS ) )
00154            offNum += ( 1 + data.lCell - data.fCell );
00155   }
00156   return offNum;
00157 //  return 0;
00158 }
00159 
00160 
00161 /*
00162 int DTHVHandler::findLayerPart( const DTWireId& id ) const {
00163   int fc;
00164   int lc;
00165   getLayerEdges( id.layerId(), fc, lc );
00166   if ( id.wire() < ( lc / 2 ) ) return 1;
00167   return 2;
00168 }
00169 
00170 
00171 int DTHVHandler::getLayerEdges( const DTLayerId& id,
00172                                 int& fCell, int& lCell  ) const {
00173   const DTLayer* layPtr = dtGeomPtr->layer( id );
00174   const DTTopology& topo = layPtr->specificTopology();
00175   fCell = topo.firstChannel();
00176   lCell = topo. lastChannel();
00177   return 1;
00178 }
00179 
00180 
00181 int DTHVHandler::getLayerEdges( const DTLayerId& id, int part,
00182                                 int& fCell, int& lCell  ) const {
00183   int flc;
00184   int llc;
00185   getLayerEdges( id, flc, llc );
00186   int hlc = llc / 2;
00187   if ( part == 1 ) {
00188     fCell = flc;
00189     lCell = hlc;
00190   }
00191   else {
00192     fCell = hlc + 1;
00193     lCell = llc;
00194   }
00195   return 1;
00196 }
00197 */
00198