CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DataFormats/DTDigi/src/DTDigi.cc

Go to the documentation of this file.
00001 
00010 #include <DataFormats/DTDigi/interface/DTDigi.h>
00011 
00012 
00013 using namespace std;
00014 
00015 
00016 const double DTDigi::reso =  25./32.; //ns
00017 
00018 
00019 DTDigi::DTDigi (int wire, int nTDC, int number) : 
00020   theWire(wire),
00021   theCounts(nTDC),
00022   theNumber(number)
00023 {}
00024 
00025 
00026 DTDigi::DTDigi (int wire, double tdrift, int number): 
00027   theWire(wire),
00028   theCounts(static_cast<int>(tdrift/reso)),
00029   theNumber(number)
00030 {}
00031 
00032 
00033 // DTDigi::DTDigi (ChannelType channel, int nTDC):
00034 //   theWire(0),
00035 //   theCounts(nTDC),
00036 //   theNumber(0)
00037 // {
00038 //   theNumber = channel&number_mask;
00039 //   theWire   = (channel&wire_mask)>>wire_offset;
00040 // }
00041 
00042 
00043 DTDigi::DTDigi ():
00044   theWire(0),
00045   theCounts(0), 
00046   theNumber(0)
00047 {}
00048 
00049 
00050 // Comparison
00051 bool
00052 DTDigi::operator == (const DTDigi& digi) const {
00053   if ( theWire != digi.wire() ||
00054        //       theNumber != digi.number() || //FIXME required ??
00055        theCounts != digi.countsTDC() ) return false;
00056   return true;
00057 }
00058 
00059 // Getters
00060 // DTDigi::ChannelType
00061 // DTDigi::channel() const {
00062 //   return  (theNumber & number_mask) | (theWire<<wire_offset)&wire_mask;
00063 // }
00064 
00065 double DTDigi::time() const { return theCounts*reso; }
00066 
00067 uint32_t DTDigi::countsTDC() const { return theCounts; }
00068 
00069 int DTDigi::wire() const { return theWire; }
00070 
00071 int DTDigi::number() const { return theNumber; }
00072 
00073 // Setters
00074 
00075 void DTDigi::setTime(double time){
00076   theCounts = static_cast<int>(time/reso);
00077 }
00078 
00079 void DTDigi::setCountsTDC (int nTDC) {
00080   if (nTDC<0) cout << "WARNING: DTDigi::setCountsTDC: negative TDC count not supported "
00081                    << nTDC << endl;
00082   theCounts = nTDC;
00083 }
00084 
00085 
00086 // Debug
00087 
00088 void
00089 DTDigi::print() const {
00090   cout << "Wire " << wire() 
00091        << " Digi # " << number()
00092        << " Drift time (ns) " << time() << endl;
00093 }
00094