diff --git a/src/THcDriftChamberPlane.cxx b/src/THcDriftChamberPlane.cxx index 3df5a7bd50a2b073a5f6f7cbbe76f705cab3cbec..b83cae3291b75ffea903fc1a5e50b00d7d12822e 100644 --- a/src/THcDriftChamberPlane.cxx +++ b/src/THcDriftChamberPlane.cxx @@ -313,13 +313,14 @@ Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Int_t wireNum = hit->fCounter; THcDCWire* wire = GetWire(wireNum); Int_t wire_last = -1; + Int_t reftime = hit->GetReference(0); for(UInt_t mhit=0; mhit<hit->fNHits; mhit++) { fNRawhits++; /* Sort into early, late and ontime */ Int_t rawtdc = hit->fTDC[mhit]; - if(rawtdc < fTdcWinMin) { + if((rawtdc-reftime) < fTdcWinMin) { // Increment early counter (Actually late because TDC is backward) - } else if (rawtdc > fTdcWinMax) { + } else if ((rawtdc-reftime) > fTdcWinMax) { // Increment late count } else { // A good hit @@ -330,7 +331,7 @@ Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) // cout << "Extra hit " << fPlaneNum << " " << wireNum << " " << rawtdc << endl; } else { Double_t time = -StartTime // (comes from h_trans_scin - - rawtdc*fNSperChan + fPlaneTimeZero; + - (rawtdc-reftime)*fNSperChan + fPlaneTimeZero; // How do we get this start time from the hodoscope to here // (or at least have it ready by coarse process) new( (*fHits)[nextHit++] ) THcDCHit(wire, rawtdc, time, this); diff --git a/src/THcHitList.cxx b/src/THcHitList.cxx index 4d8a396a298dace9f7e2ad1ef808fa1f784946ed..bbac90412e3914ab28ee947ba581da87ef54fdb0 100644 --- a/src/THcHitList.cxx +++ b/src/THcHitList.cxx @@ -103,6 +103,13 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata ) { // cout << "Signal " << signal << "=" << data << endl; rawhit->SetData(signal,data); } + // Get the reference time. Only take the first hit + if(d->refchan >= 0) { + if( evdata.GetNumHits(d->crate,d->slot,d->refchan) > 0) { + Int_t reftime = evdata.GetData(d->crate, d->slot, d->refchan, 0); + rawhit->SetReference(signal, reftime); + } + } } } fRawHitList->Sort(fNRawHits); diff --git a/src/THcRawDCHit.cxx b/src/THcRawDCHit.cxx index 46ce22abc87269a4290f7af7888264e624adaf38..6032b1592642b1ca379f1e5c72ac37f40fc86371 100644 --- a/src/THcRawDCHit.cxx +++ b/src/THcRawDCHit.cxx @@ -34,6 +34,20 @@ Int_t THcRawDCHit::GetData(Int_t signal, UInt_t ihit) { } } +// Set the reference time +void THcRawDCHit::SetReference(Int_t signal, Int_t reference) { + fReferenceTime = reference; + fHasRef = kTRUE; +} + +// Get the reference time +Int_t THcRawDCHit::GetReference(Int_t signal) { + if(fHasRef) { + return(fReferenceTime); + } else { + return(0); + } +} Int_t THcRawDCHit::Compare(const TObject* obj) const { diff --git a/src/THcRawDCHit.h b/src/THcRawDCHit.h index 18668d65a5ebd7464b2b1bb856f832d405b0fbef..305a89b9d3d0c4ef5d8faabe0c0434fba6660b42 100644 --- a/src/THcRawDCHit.h +++ b/src/THcRawDCHit.h @@ -20,8 +20,11 @@ public: virtual void Clear( Option_t* opt="" ) { fNHits=0; } void SetData(Int_t signal, Int_t data); + void SetReference(Int_t signal, Int_t reference); Int_t GetData(Int_t signal); Int_t GetData(Int_t signal, UInt_t ihit); + Int_t GetReference(Int_t signal); + virtual Bool_t IsSortable () const {return kTRUE; } virtual Int_t Compare(const TObject* obj) const; @@ -30,6 +33,7 @@ public: protected: UInt_t fNHits; Int_t fTDC[MAXHITS]; + Int_t fReferenceTime; private: diff --git a/src/THcRawHit.h b/src/THcRawHit.h index 1ee7d16431cc7d2d6e95b32e2750e5ccdabdf3f4..dc0cbd3196578f807cc29337f65896beb2bc55d6 100644 --- a/src/THcRawHit.h +++ b/src/THcRawHit.h @@ -11,8 +11,8 @@ class THcRawHit : public TObject { public: - THcRawHit(Int_t plane=0, Int_t counter=0) : - fPlane(plane), fCounter(counter) {}; + THcRawHit(Int_t plane=0, Int_t counter=0) : + fPlane(plane), fCounter(counter), fHasRef(kFALSE) {}; THcRawHit( const THcRawHit& rhs ) : TObject(rhs) {} THcRawHit& operator=( const THcRawHit& rhs ) { TObject::operator=(rhs); return *this; }; @@ -27,6 +27,9 @@ public: virtual void SetData(Int_t signal, Int_t data) {}; virtual Int_t GetData(Int_t signal) {return 0;}; + virtual void SetReference(Int_t signal, Int_t reference) {}; + virtual Bool_t HasReference(Int_t signal) {return fHasRef;}; + virtual Int_t GetReference(Int_t signal) {return 0;}; // Derived objects must be sortable and supply Compare method // virtual Bool_t IsSortable () const {return kFALSE; } @@ -36,6 +39,7 @@ public: Int_t fPlane; Int_t fCounter; + Bool_t fHasRef; private: