/** @file CbmTofDigiExp.cxx ** @author Pierre-Alain Loizeau ** @date 07.06.2013 ** ** Code for Data class for expanded digital TOF information **/ #include "CbmTofDigiExp.h" // ROOT Headers #include "TString.h" CbmTofDigiExp::CbmTofDigiExp() : CbmDigi(), fdTime(0.), fdTot(-1.), fuAddress(0), fMatch(nullptr) { } CbmTofDigiExp::CbmTofDigiExp( UInt_t address, Double_t time, Double_t tot) : CbmDigi(), fdTime(time), fdTot(tot), fuAddress(address), fMatch(nullptr) { } CbmTofDigiExp::CbmTofDigiExp( UInt_t Sm, UInt_t Rpc, UInt_t Channel, Double_t time, Double_t tot, UInt_t Side, UInt_t SmType ) : CbmDigi(), fdTime(time), fdTot(tot), fuAddress(0), fMatch(nullptr) { fuAddress = CbmTofAddress::GetUniqueAddress( Sm, Rpc, Channel, Side, SmType ); } // --- Copy constructor CbmTofDigiExp::CbmTofDigiExp(const CbmTofDigiExp& digiIn) : CbmDigi(digiIn), fdTime(digiIn.fdTime), fdTot(digiIn.fdTot), fuAddress(digiIn.fuAddress), fMatch(nullptr) { if (digiIn.fMatch) { fMatch = new CbmMatch(); fMatch->AddLinks( *(digiIn.fMatch) ); } } // ----- Move constructor ----------------------------------------------- CbmTofDigiExp::CbmTofDigiExp(CbmTofDigiExp&& other) : CbmDigi(std::forward(other)), fdTime(other.fdTime), fdTot(other.fdTot), fuAddress(other.fuAddress), fMatch(nullptr) { if ( other.fMatch ) { fMatch = other.fMatch; other.fMatch = nullptr; } } // ------------------------------------------------------------------------- // ----- Assignment operator ----------- -------------------------------- CbmTofDigiExp& CbmTofDigiExp::operator=(const CbmTofDigiExp& rhs) { if (this != &rhs) { CbmDigi::operator=(rhs); fdTime = rhs.fdTime; fdTot = rhs.fdTot; fuAddress = rhs.fuAddress; if ( rhs.fMatch ) { fMatch = new CbmMatch(); fMatch->AddLinks( *(rhs.fMatch) ); } else fMatch = nullptr; } return *this; } // ------------------------------------------------------------------------- // ----- Move Assignment operator -------------------------------------- CbmTofDigiExp& CbmTofDigiExp::operator=(CbmTofDigiExp&& other) { if (this != &other) { CbmDigi::operator=(std::forward(other)); fuAddress = other.fuAddress; fdTime = other.fdTime; fdTot = other.fdTot; if ( fMatch ) delete fMatch; fMatch = other.fMatch; other.fMatch = nullptr; } return *this; } // ------------------------------------------------------------------------- CbmTofDigiExp::~CbmTofDigiExp() { if ( fMatch ) delete fMatch; } std::string CbmTofDigiExp::ToString() const { TString string = Form( "CbmTofDigi: address = 0x%08X time = %f tot = %f", fuAddress, fdTime, fdTot); return string.Data(); } Bool_t CbmTofDigiExp::operator <( const CbmTofDigiExp& rhs) const { return (this->GetTime() < rhs.GetTime()) ? kTRUE : kFALSE; } Int_t CbmTofDigiExp::Compare( const TObject* obj) const { return Compare( (CbmTofDigiExp*) obj); } Int_t CbmTofDigiExp::Compare( const CbmTofDigiExp* obj) const { if( this->GetTime() < obj->GetTime() ) // hit ... obj return -1; else if( this->GetTime() > obj->GetTime() ) // obj ... hit return 1; // obj = hit else return 0; } void CbmTofDigiExp::SetAddress( UInt_t Sm, UInt_t Rpc, UInt_t Channel, UInt_t Side, UInt_t SmType ) { fuAddress = CbmTofAddress::GetUniqueAddress( Sm, Rpc, Channel, Side, SmType ); } ClassImp(CbmTofDigiExp)