CMS 3D CMS Logo

DTDigi.cc

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

Generated on Tue Jun 9 17:30:41 2009 for CMSSW by  doxygen 1.5.4