X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONDigit.cxx;h=f78a5d46b40311d12b579c657549c7d430fdecf5;hb=3b7f2f857b8c6f05a9eec38d847ffa0a057a9696;hp=7f2ee3cc4572f101667a59068b1a3591f2a97017;hpb=a450cfad875fac80c89db0c776fcda96cc240800;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONDigit.cxx b/MUON/AliMUONDigit.cxx index 7f2ee3cc457..f78a5d46b40 100644 --- a/MUON/AliMUONDigit.cxx +++ b/MUON/AliMUONDigit.cxx @@ -13,53 +13,408 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* -$Log$ -Revision 1.2 2000/06/15 07:58:48 morsch -Code from MUON-dev joined - -Revision 1.1.2.1 2000/06/09 22:03:22 morsch -Was before in DataStructures.cxx - -*/ +/* $Id$ */ #include "AliMUONDigit.h" +//----------------------------------------------------------------------------- +/// \class AliMUONDigit +/// A class representing a digit (with MC information if possible) +/// in the MUON spectrometer either in tracking or trigger chambers. +/// +/// A digit holds the signal (proportional to a charge) on a pad +/// (or strip). +/// +/// This class is used to represent either sdigits (purely simulated digit, +/// with no electronic noise whatsoever) or digits (simulated ones but +/// including electronic noise and de-calibration, to closely ressemble real ones). +//----------------------------------------------------------------------------- + +/// \cond CLASSIMP ClassImp(AliMUONDigit) +/// \endcond + //_____________________________________________________________________________ -AliMUONDigit::AliMUONDigit(Int_t *digits) +AliMUONDigit::AliMUONDigit() +: +AliMUONVDigit(), +fDetElemId(0), +fManuId(0), +fManuChannel(0), +fSignal(0.0), +fPadX(-1), +fPadY(-1), +fCathode(0), +fADC(0), +fFlags(0), +fNtracks(0), +fTcharges(0x0), +fTracks(0x0), +fHit(0), +fStatusMap(0) { - // - // Creates a MUON digit object to be updated - // - fPadX = digits[0]; - fPadY = digits[1]; - fCathode = digits[2]; - fSignal = digits[3]; - fPhysics = digits[4]; - fHit = digits[5]; + /// Default constructor +} +//_____________________________________________________________________________ +AliMUONDigit::AliMUONDigit(Int_t detElemId, Int_t manuId, + Int_t manuChannel, Int_t cathode) +: +AliMUONVDigit(detElemId,manuId,manuChannel,cathode), +fDetElemId(detElemId), +fManuId(manuId), +fManuChannel(manuChannel), +fSignal(0.0), +fPadX(-1), +fPadY(-1), +fCathode(cathode), +fADC(0), +fFlags(0), +fNtracks(0), +fTcharges(0x0), +fTracks(0x0), +fHit(0), +fStatusMap(0) +{ + /// Normal constructor } + + //_____________________________________________________________________________ -AliMUONDigit::AliMUONDigit(Int_t *tracks, Int_t *charges, Int_t *digits) +AliMUONDigit::AliMUONDigit(const AliMUONDigit& digit) +: AliMUONVDigit(), +fDetElemId(0), +fManuId(0), +fManuChannel(0), +fSignal(0.0), +fPadX(-1), +fPadY(-1), +fCathode(0), +fADC(0), +fFlags(0), +fNtracks(0), +fTcharges(0x0), +fTracks(0x0), +fHit(0), +fStatusMap(0) { - // - // Creates a MUON digit object - // - fPadX = digits[0]; - fPadY = digits[1]; - fCathode = digits[2]; - fSignal = digits[3]; - fPhysics = digits[4]; - fHit = digits[5]; + /// Copy constructor - for(Int_t i=0; i<10; i++) { - fTcharges[i] = charges[i]; - fTracks[i] = tracks[i]; - } + (static_cast(digit)).Copy(*this); } +//_____________________________________________________________________________ AliMUONDigit::~AliMUONDigit() { - // Destructor + /// Destructor + + delete[] fTcharges; + delete[] fTracks; +} + +//_____________________________________________________________________________ +void +AliMUONDigit::AddTrack(Int_t trackNumber, Float_t trackCharge) +{ + /// Add 1 track information to the track list we keep. + /// The implementation below is dumb, you've been warned ! + + // First check if track is already there, in which + // case we simply increment its charge. + for ( Int_t i = 0; i < Ntracks(); ++i ) + { + if ( Track(i) == trackNumber ) + { + fTcharges[i] += trackCharge; + return; + } + } + + // Nope. It's a brand new track. Make a new array to get space + // for it, copy the old array into new one, and add the track. + Int_t* newTracks = new Int_t[fNtracks+1]; + Float_t* newTcharges = new Float_t[fNtracks+1]; + + for ( Int_t i = 0; i < fNtracks; ++i ) + { + newTracks[i] = fTracks[i]; + newTcharges[i] = fTcharges[i]; + } + + newTracks[fNtracks] = trackNumber; + newTcharges[fNtracks] = trackCharge; + + delete[] fTracks; + delete[] fTcharges; + + fTracks = newTracks; + fTcharges = newTcharges; + + ++fNtracks; +} + +//_____________________________________________________________________________ +void +AliMUONDigit::Clear(Option_t*) +{ + /// Reset this digit, in particular the internal arrays are deleted. + + delete[] fTracks; + delete[] fTcharges; + fTracks=0x0; + fTcharges=0x0; + fNtracks=0; +} + +//______________________________________________________________________________ +void +AliMUONDigit::Copy(TObject& obj) const +{ + /// Copy this line to line. + + TObject::Copy(obj); + AliMUONDigit& digit = static_cast(obj); + + digit.fDetElemId = fDetElemId; + digit.fManuId = fManuId; + digit.fManuChannel = fManuChannel; + digit.fSignal = fSignal; + + digit.fPadX = fPadX; + digit.fPadY = fPadY; + digit.fCathode = fCathode; + digit.fADC = fADC; + digit.fFlags = fFlags; + + digit.fNtracks = fNtracks; + + delete[] digit.fTcharges; + delete[] digit.fTracks; + + if ( fNtracks ) + { + digit.fTcharges = new Float_t[fNtracks]; + digit.fTracks = new Int_t[fNtracks]; + } + + for ( Int_t i=0; i=0 and < Ntracks()) or -1. + + if ( i >= 0 && i < fNtracks ) + { + return fTracks[i]; + } + + return -1; +} + +//_____________________________________________________________________________ +Float_t +AliMUONDigit::TrackCharge(Int_t i) const +{ + /// Return the i-th track charge (if i is >=0 and < Ntracjs()) or -1. + + if ( i >= 0 && i < fNtracks ) + { + return fTcharges[i]; + } + + return -1; +} + +//_____________________________________________________________________________ +UInt_t +AliMUONDigit::GetUniqueID() const +{ + /// Return a single integer with id information + + return BuildUniqueID(DetElemId(),ManuId(),ManuChannel(),Cathode()); }