Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  *  See header file for a description of this class.
0003  *
0004  *  \author Paolo Ronchese INFN Padova
0005  *
0006  */
0007 
0008 //----------------------
0009 // This Class' Header --
0010 //----------------------
0011 #include "CondFormats/DTObjects/interface/DTT0.h"
0012 
0013 //-------------------------------
0014 // Collaborating Class Headers --
0015 //-------------------------------
0016 #include "CondFormats/DTObjects/interface/DTSequentialCellNumber.h"
0017 
0018 //---------------
0019 // C++ Headers --
0020 //---------------
0021 #include <iostream>
0022 #include <sstream>
0023 
0024 //-------------------
0025 // Initializations --
0026 //-------------------
0027 
0028 //----------------
0029 // Constructors --
0030 //----------------
0031 DTT0::DTT0() : dataVersion(" "), nsPerCount(25.0 / 32.0), dataList(DTSequentialCellNumber::max() + 10) {}
0032 
0033 DTT0::DTT0(const std::string& version)
0034     : dataVersion(version), nsPerCount(25.0 / 32.0), dataList(DTSequentialCellNumber::max() + 10) {}
0035 
0036 DTT0Data::DTT0Data() : channelId(0), t0mean(0.0), t0rms(0.0) {}
0037 
0038 //--------------
0039 // Destructor --
0040 //--------------
0041 DTT0::~DTT0() {}
0042 
0043 DTT0Data::~DTT0Data() {}
0044 
0045 //--------------
0046 // Operations --
0047 //--------------
0048 int DTT0::get(int wheelId,
0049               int stationId,
0050               int sectorId,
0051               int slId,
0052               int layerId,
0053               int cellId,
0054               float& t0mean,
0055               float& t0rms,
0056               DTTimeUnits::type unit) const {
0057   t0mean = t0rms = 0.0;
0058 
0059   int seqNum = DTSequentialCellNumber::id(wheelId, stationId, sectorId, slId, layerId, cellId);
0060   if (seqNum < 0)
0061     return seqNum;
0062 
0063   const DTT0Data& data = dataList[seqNum];
0064   if (data.channelId == 0)
0065     return -999999999;
0066 
0067   t0mean = data.t0mean;
0068   t0rms = data.t0rms;
0069   if (unit == DTTimeUnits::ns) {
0070     t0mean *= nsPerCount;
0071     t0rms *= nsPerCount;
0072   }
0073   return 0;
0074 }
0075 
0076 int DTT0::get(const DTWireId& id, float& t0mean, float& t0rms, DTTimeUnits::type unit) const {
0077   return get(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), t0mean, t0rms, unit);
0078 }
0079 
0080 float DTT0::unit() const { return nsPerCount; }
0081 
0082 const std::string& DTT0::version() const { return dataVersion; }
0083 
0084 std::string& DTT0::version() { return dataVersion; }
0085 
0086 void DTT0::clear() {
0087   int i;
0088   int n = dataList.size();
0089   for (i = 0; i < n; ++i) {
0090     DTT0Data& data = dataList[i];
0091     data.channelId = 0;
0092     data.t0mean = data.t0rms;
0093   }
0094   return;
0095 }
0096 
0097 int DTT0::set(int wheelId,
0098               int stationId,
0099               int sectorId,
0100               int slId,
0101               int layerId,
0102               int cellId,
0103               float t0mean,
0104               float t0rms,
0105               DTTimeUnits::type unit) {
0106   if (unit == DTTimeUnits::ns) {
0107     t0mean /= nsPerCount;
0108     t0rms /= nsPerCount;
0109   }
0110 
0111   int seqNum = DTSequentialCellNumber::id(wheelId, stationId, sectorId, slId, layerId, cellId);
0112   if (seqNum < 0)
0113     return seqNum;
0114 
0115   DTWireId id(wheelId, stationId, sectorId, slId, layerId, cellId);
0116   DTT0Data& data = dataList[seqNum];
0117   data.channelId = id.rawId();
0118   data.t0mean = t0mean;
0119   data.t0rms = t0rms;
0120 
0121   return 0;
0122 }
0123 
0124 int DTT0::set(const DTWireId& id, float t0mean, float t0rms, DTTimeUnits::type unit) {
0125   if (unit == DTTimeUnits::ns) {
0126     t0mean /= nsPerCount;
0127     t0rms /= nsPerCount;
0128   }
0129 
0130   int seqNum =
0131       DTSequentialCellNumber::id(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire());
0132   if (seqNum < 0)
0133     return seqNum;
0134 
0135   DTT0Data& data = dataList[seqNum];
0136   data.channelId = id.rawId();
0137   data.t0mean = t0mean;
0138   data.t0rms = t0rms;
0139 
0140   return 0;
0141 }
0142 
0143 void DTT0::setUnit(float unit) { nsPerCount = unit; }
0144 
0145 DTT0::const_iterator DTT0::begin() const { return dataList.begin(); }
0146 
0147 DTT0::const_iterator DTT0::end() const { return dataList.end(); }