File indexing completed on 2023-03-17 10:49:38
0001
0002
0003
0004
0005
0006
0007 #include <DataFormats/DTDigi/interface/DTDigi.h>
0008 #include <FWCore/Utilities/interface/Exception.h>
0009
0010 using namespace std;
0011
0012 DTDigi::DTDigi(int wire, int nTDC, int number, int base)
0013 : theCounts(nTDC), theWire(wire), theNumber(number), theTDCBase(base) {
0014 if (number > 255 || number < 0 || !(base == 30 || base == 32)) {
0015 throw cms::Exception("BadConfig") << "DTDigi ctor: invalid parameters: number: " << number << " base: " << base;
0016 }
0017 }
0018
0019 DTDigi::DTDigi(int wire, double tdrift, int number, int base)
0020 : theCounts(static_cast<int>(tdrift / 25. * base)), theWire(wire), theNumber(number), theTDCBase(base) {
0021 if (number > 255 || number < 0 || !(base == 30 || base == 32)) {
0022 throw cms::Exception("BadConfig") << "DTDigi ctor: invalid parameters: number: " << number << " base: " << base;
0023 }
0024 }
0025
0026 DTDigi::DTDigi() : theCounts(0), theWire(0), theNumber(0), theTDCBase(32) {}
0027
0028
0029 bool DTDigi::operator==(const DTDigi& digi) const {
0030 if (theWire != digi.wire() ||
0031
0032 theCounts != digi.countsTDC())
0033 return false;
0034 return true;
0035 }
0036
0037 double DTDigi::time() const { return theCounts * 25. / theTDCBase; }
0038
0039 int32_t DTDigi::countsTDC() const { return theCounts; }
0040
0041 int DTDigi::wire() const { return theWire; }
0042
0043 int DTDigi::number() const { return theNumber; }
0044
0045 double DTDigi::tdcUnit() const { return 25. / theTDCBase; }
0046
0047 int DTDigi::tdcBase() const { return theTDCBase; }
0048
0049 void DTDigi::print() const {
0050 cout << "Wire " << wire() << " Digi # " << number() << " Drift time (ns) " << time() << endl;
0051 }