Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:46

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  $Date: 2008/11/20 12:00:00 $
0005  *  $Revision: 1.1 $
0006  *  \author Paolo Ronchese INFN Padova
0007  *
0008  */
0009 
0010 //----------------------
0011 // This Class' Header --
0012 //----------------------
0013 #include "CondTools/DT/interface/DTHVHandler.h"
0014 
0015 //-------------------------------
0016 // Collaborating Class Headers --
0017 //-------------------------------
0018 #include "CondFormats/DTObjects/interface/DTHVStatus.h"
0019 #include "DataFormats/MuonDetId/interface/DTWireId.h"
0020 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
0021 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0022 //#include "Geometry/DTGeometry/interface/DTGeometry.h"
0023 //#include "Geometry/Records/interface/MuonGeometryRecord.h"
0024 
0025 //---------------
0026 // C++ Headers --
0027 //---------------
0028 
0029 //-------------------
0030 // Initializations --
0031 //-------------------
0032 
0033 //----------------
0034 // Constructors --
0035 //----------------
0036 DTHVHandler::DTHVHandler() : objectPtr(nullptr) {}
0037 
0038 /*
0039 DTHVHandler::DTHVHandler( const DTHVStatus* dbObject,
0040                           const DTGeometry* geometry ):
0041   objectPtr( dbObject ),
0042   dtGeomPtr( geometry ) {
0043 }
0044 */
0045 DTHVHandler::DTHVHandler(const DTHVStatus* dbObject) : objectPtr(dbObject) {}
0046 
0047 //--------------
0048 // Destructor --
0049 //--------------
0050 DTHVHandler::~DTHVHandler() {}
0051 
0052 //--------------
0053 // Operations --
0054 //--------------
0055 int DTHVHandler::get(const DTWireId& id, int& flagA, int& flagC, int& flagS) const {
0056   /*
0057   if ( objectPtr == 0 ) {
0058     flagA = flagC = flagS = 0;
0059     return 999;
0060   }
0061   return objectPtr->get( id.wheel(),
0062                          id.station(),
0063                          id.sector(),
0064                          id.superLayer(),
0065                          id.layer(),
0066                          findLayerPart( id ),
0067                          flagA, flagC, flagS );
0068 */
0069   flagA = flagC = flagS = 0;
0070   if (objectPtr == nullptr)
0071     return 999;
0072   int iCell = id.wire();
0073   int fCell;
0074   int lCell;
0075   int fCheck = objectPtr->get(
0076       id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), 0, fCell, lCell, flagA, flagC, flagS);
0077   if ((fCheck == 0) && (fCell <= iCell) && (lCell >= iCell))
0078     return 0;
0079   fCheck = objectPtr->get(
0080       id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), 1, fCell, lCell, flagA, flagC, flagS);
0081   if ((fCheck == 0) && (fCell <= iCell) && (lCell >= iCell))
0082     return 0;
0083   flagA = flagC = flagS = 0;
0084   return 1;
0085 }
0086 
0087 int DTHVHandler::offChannelsNumber() const {
0088   int offNum = 0;
0089   DTHVStatus::const_iterator iter = objectPtr->begin();
0090   DTHVStatus::const_iterator iend = objectPtr->end();
0091   while (iter != iend) {
0092     const std::pair<DTHVStatusId, DTHVStatusData>& entry = *iter++;
0093     DTHVStatusId hvId = entry.first;
0094     DTHVStatusData data = entry.second;
0095     if (data.flagA || data.flagC || data.flagS)
0096       offNum += (1 + data.lCell - data.fCell);
0097   }
0098   return offNum;
0099 }
0100 
0101 int DTHVHandler::offChannelsNumber(const DTChamberId& id) const {
0102   int offNum = 0;
0103   DTHVStatus::const_iterator iter = objectPtr->begin();
0104   DTHVStatus::const_iterator iend = objectPtr->end();
0105   /*
0106   while ( iter != iend ) {
0107     const std::pair<DTHVStatusId,DTHVStatusData>& entry = *iter++;
0108     DTHVStatusId   idCh = entry.first;
0109     DTHVStatusData data = entry.second;
0110     DTLayerId idL( idCh.wheelId, idCh.stationId, idCh.sectorId,
0111                    idCh.slId,    idCh.layerId );
0112     int fCell;
0113     int lCell;
0114     getLayerEdges( idL, idCh.partId, fCell, lCell );
0115     if ( data.flagA || data.flagC || data.flagS )
0116          offNum += ( 1 + lCell - fCell );
0117   }
0118 */
0119   while (iter != iend) {
0120     const std::pair<DTHVStatusId, DTHVStatusData>& entry = *iter++;
0121     DTHVStatusId hvId = entry.first;
0122     DTHVStatusData data = entry.second;
0123     if ((hvId.wheelId == id.wheel()) && (hvId.stationId == id.station()) && (hvId.sectorId == id.sector()) &&
0124         (data.flagA || data.flagC || data.flagS))
0125       offNum += (1 + data.lCell - data.fCell);
0126   }
0127   return offNum;
0128   //  return 0;
0129 }
0130 
0131 /*
0132 int DTHVHandler::findLayerPart( const DTWireId& id ) const {
0133   int fc;
0134   int lc;
0135   getLayerEdges( id.layerId(), fc, lc );
0136   if ( id.wire() < ( lc / 2 ) ) return 1;
0137   return 2;
0138 }
0139 
0140 
0141 int DTHVHandler::getLayerEdges( const DTLayerId& id,
0142                                 int& fCell, int& lCell  ) const {
0143   const DTLayer* layPtr = dtGeomPtr->layer( id );
0144   const DTTopology& topo = layPtr->specificTopology();
0145   fCell = topo.firstChannel();
0146   lCell = topo. lastChannel();
0147   return 1;
0148 }
0149 
0150 
0151 int DTHVHandler::getLayerEdges( const DTLayerId& id, int part,
0152                                 int& fCell, int& lCell  ) const {
0153   int flc;
0154   int llc;
0155   getLayerEdges( id, flc, llc );
0156   int hlc = llc / 2;
0157   if ( part == 1 ) {
0158     fCell = flc;
0159     lCell = hlc;
0160   }
0161   else {
0162     fCell = hlc + 1;
0163     lCell = llc;
0164   }
0165   return 1;
0166 }
0167 */