CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/CondFormats/DTObjects/src/DTT0.cc

Go to the documentation of this file.
00001 /*
00002  *  See header file for a description of this class.
00003  *
00004  *  $Date: 2012/02/18 10:46:36 $
00005  *  $Revision: 1.22 $
00006  *  \author Paolo Ronchese INFN Padova
00007  *
00008  */
00009 
00010 //----------------------
00011 // This Class' Header --
00012 //----------------------
00013 #include "CondFormats/DTObjects/interface/DTT0.h"
00014 
00015 //-------------------------------
00016 // Collaborating Class Headers --
00017 //-------------------------------
00018 #include "CondFormats/DTObjects/interface/DTSequentialCellNumber.h"
00019 
00020 //---------------
00021 // C++ Headers --
00022 //---------------
00023 #include <iostream>
00024 #include <sstream>
00025 
00026 //-------------------
00027 // Initializations --
00028 //-------------------
00029 
00030 
00031 //----------------
00032 // Constructors --
00033 //----------------
00034 DTT0::DTT0():
00035   dataVersion( " " ),
00036   nsPerCount( 25.0 / 32.0 ),
00037   dataList( DTSequentialCellNumber::max() + 10 ) {
00038 }
00039 
00040 
00041 DTT0::DTT0( const std::string& version ):
00042   dataVersion( version ),
00043   nsPerCount( 25.0 / 32.0 ),
00044   dataList( DTSequentialCellNumber::max() + 10 ) {
00045 }
00046 
00047 
00048 DTT0Data::DTT0Data() :
00049   channelId( 0 ),
00050   t0mean( 0.0 ),
00051   t0rms(  0.0 ) {
00052 }
00053 
00054 
00055 //--------------
00056 // Destructor --
00057 //--------------
00058 DTT0::~DTT0() {
00059 }
00060 
00061 
00062 DTT0Data::~DTT0Data() {
00063 }
00064 
00065 
00066 //--------------
00067 // Operations --
00068 //--------------
00069 int DTT0::get( int   wheelId,
00070                int stationId,
00071                int  sectorId,
00072                int      slId,
00073                int   layerId,
00074                int    cellId,
00075                float& t0mean,
00076                float& t0rms,
00077                DTTimeUnits::type unit ) const {
00078 
00079   t0mean =
00080   t0rms  = 0.0;
00081 
00082   int seqNum = DTSequentialCellNumber::id( wheelId, stationId, sectorId,
00083                                               slId,   layerId,   cellId );
00084   if ( seqNum < 0 ) return seqNum;
00085 
00086   const DTT0Data& data = dataList[seqNum];
00087   if ( data.channelId == 0 ) return -999999999;
00088 
00089   t0mean = data.t0mean;
00090   t0rms  = data.t0rms;
00091   if ( unit == DTTimeUnits::ns ) {
00092     t0mean *= nsPerCount;
00093     t0rms  *= nsPerCount;
00094   }
00095   return 0;
00096 
00097 }
00098 
00099 
00100 int DTT0::get( const DTWireId& id,
00101                float& t0mean,
00102                float& t0rms,
00103                DTTimeUnits::type unit ) const {
00104   return get( id.wheel(),
00105               id.station(),
00106               id.sector(),
00107               id.superLayer(),
00108               id.layer(),
00109               id.wire(),
00110               t0mean, t0rms, unit );
00111 }
00112 
00113 
00114 float DTT0::unit() const {
00115   return nsPerCount;
00116 }
00117 
00118 
00119 const
00120 std::string& DTT0::version() const {
00121   return dataVersion;
00122 }
00123 
00124 
00125 std::string& DTT0::version() {
00126   return dataVersion;
00127 }
00128 
00129 
00130 void DTT0::clear() {
00131   int i;
00132   int n = dataList.size();
00133   for ( i = 0; i < n; ++i ) {
00134     DTT0Data& data = dataList[i];
00135     data.channelId = 0;
00136     data.t0mean = data.t0rms;
00137   }
00138   return;
00139 }
00140 
00141 
00142 int DTT0::set( int   wheelId,
00143                int stationId,
00144                int  sectorId,
00145                int      slId,
00146                int   layerId,
00147                int    cellId,
00148                float t0mean,
00149                float t0rms,
00150                DTTimeUnits::type unit ) {
00151 
00152   if ( unit == DTTimeUnits::ns ) {
00153     t0mean /= nsPerCount;
00154     t0rms  /= nsPerCount;
00155   }
00156 
00157   int seqNum = DTSequentialCellNumber::id( wheelId, stationId, sectorId,
00158                                               slId,   layerId,   cellId );
00159   if ( seqNum < 0 ) return seqNum;
00160 
00161   DTWireId id(  wheelId, stationId, sectorId,
00162                    slId,   layerId,   cellId );
00163   DTT0Data& data = dataList[seqNum];
00164   data.channelId = id.rawId();
00165   data.t0mean    = t0mean;
00166   data.t0rms     = t0rms;
00167 
00168   return 0;
00169 
00170 }
00171 
00172 
00173 int DTT0::set( const DTWireId& id,
00174                float t0mean,
00175                float t0rms,
00176                DTTimeUnits::type unit ) {
00177 
00178   if ( unit == DTTimeUnits::ns ) {
00179     t0mean /= nsPerCount;
00180     t0rms  /= nsPerCount;
00181   }
00182 
00183   int seqNum = DTSequentialCellNumber::id( id.wheel(),
00184                                            id.station(),
00185                                            id.sector(),
00186                                            id.superLayer(),
00187                                            id.layer(),
00188                                            id.wire() );
00189   if ( seqNum < 0 ) return seqNum;
00190 
00191   DTT0Data& data = dataList[seqNum];
00192   data.channelId = id.rawId();
00193   data.t0mean    = t0mean;
00194   data.t0rms     = t0rms;
00195 
00196   return 0;
00197 
00198 }
00199 
00200 
00201 void DTT0::setUnit( float unit ) {
00202   nsPerCount = unit;
00203 }
00204 
00205 
00206 DTT0::const_iterator DTT0::begin() const {
00207   return dataList.begin();
00208 }
00209 
00210 
00211 DTT0::const_iterator DTT0::end() const {
00212   return dataList.end();
00213 }
00214