diff --git a/Makefile b/Makefile index 656d93838e6732c566b4250769cf468dfe889a90..64f1a3d269375b9f76850990abfe1f901cfa62a4 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ SRC = src/THcInterface.cxx src/THcParmList.cxx src/THcAnalyzer.cxx \ - src/THcHodoscopeHit.cxx src/THcRawHit.cxx src/THcRawHitList.cxx \ - src/THcDetectorMap.cxx + src/THcHodoscopeHit.cxx src/THcRawHit.cxx \ + src/THcDetectorBase.cxx # Name of your package. # The shared library that will be built will get the name lib$(PACKAGE).so diff --git a/podd b/podd index 9a47be4dc77822bd7af642d1b3ca962f09cf89f6..3f08eaebe0d0997888a9bf34ba90a211dd608a2d 160000 --- a/podd +++ b/podd @@ -1 +1 @@ -Subproject commit 9a47be4dc77822bd7af642d1b3ca962f09cf89f6 +Subproject commit 3f08eaebe0d0997888a9bf34ba90a211dd608a2d diff --git a/src/HallC_LinkDef.h b/src/HallC_LinkDef.h index cde866435b4e3e2a43d2bca9dc4af980f779a71b..b6d0a97bc6788f0276a5b4233746b482f4db49e1 100644 --- a/src/HallC_LinkDef.h +++ b/src/HallC_LinkDef.h @@ -11,7 +11,6 @@ #pragma link C++ class THcAnalyzer+; #pragma link C++ class THcRawHit+; #pragma link C++ class THcHodoscopeHit+; -#pragma link C++ class THcRawHitList+; -#pragma link C++ class THcDetectorMap+; +#pragma link C++ class THcDetectorBase+; #endif diff --git a/src/THcDetectorBase.cxx b/src/THcDetectorBase.cxx index 08224b4c010faff0e2dc2c054d5cac5d6937a5e3..a045a8a8514f14d7689d554d646994d759741786 100644 --- a/src/THcDetectorBase.cxx +++ b/src/THcDetectorBase.cxx @@ -5,10 +5,22 @@ // THcDetectorBase // // Add hitlist to the Hall A detector base +<<<<<<< HEAD // ////////////////////////////////////////////////////////////////////////// #include "ThcDetectorBase.h" +======= +// May not need to inherit from THaDetectorBase since we may end up +// replacing most of the methods +// +////////////////////////////////////////////////////////////////////////// + +#include "THcDetectorBase.h" +#include "THaEvData.h" +#include "THaDetMap.h" +#include "TClonesArray.h" +>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035 using namespace std; @@ -16,12 +28,88 @@ THcDetectorBase::THcDetectorBase( const char* name, const char* description ) : THaDetectorBase(name, description) { +<<<<<<< HEAD +======= + // Normal constructor. + + fRawHitList = NULL; + +>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035 } THcDetectorBase::THcDetectorBase() : THaDetectorBase() { } +<<<<<<< HEAD THcDetectorBase::~THcDetectorBase() : ~THaDetectorBase() { +======= +THcDetectorBase::~THcDetectorBase() { + // Destructor +} + +void THcDetectorBase::InitHitlist(const char *hitclass, Int_t maxhits) { + // Probably called by ReadDatabase + fRawHitList = new TClonesArray(hitclass, maxhits); + fRawHitClass = fRawHitList->GetClass(); + fNMaxRawHits = maxhits; + fNRawHits = 0; + for(Int_t i=0;i<maxhits;i++) { + fRawHitList->New(i); + } +} + + +Int_t THcDetectorBase::Decode( const THaEvData& evdata ) { + THcRawHit* rawhit; + fRawHitList->Clear("C"); + fNRawHits = 0; + + for ( Int_t i=0; i < fDetMap->GetSize(); i++ ) { + THaDetMap::Module* d = fDetMap->GetModule(i); + + // Loop over all channels that have a hit. + for ( Int_t j=0; j < evdata.GetNumChan( d->crate, d->slot); j++) { + + Int_t chan = evdata.GetNextChan( d->crate, d->slot, j ); + if( chan < d->lo || chan > d->hi ) continue; // Not one of my channels + + // Need to convert crate, slot, chan into plane, counter, signal + // Search hitlist for this plane,counter,signal + Int_t plane = d->plane; + Int_t signal = d->signal; + Int_t counter = d->reverse ? d->first + d->hi - chan : d->first + chan - d->lo; + + // Search hit list for plane and counter + // We could do sorting + Int_t thishit = 0; + while(thishit < fNRawHits) { + rawhit = (THcRawHit*) (*fRawHitList)[thishit]; + if (plane == rawhit->fPlane + && counter == rawhit->fCounter) { + break; + } + thishit++; + } + if(thishit == fNRawHits) { + fNRawHits++; + rawhit = (THcRawHit*) (*fRawHitList)[thishit]; + rawhit->fPlane = plane; + rawhit->fCounter = counter; + } + + // Get the data from this channel + // Allow for multiple hits + Int_t nMHits = evdata.GetNumHits(d->crate, d->slot, chan); + for (Int_t mhit = 0; mhit < nMHits; mhit++) { + Int_t data = evdata.GetData( d->crate, d->slot, chan, mhit); + rawhit->SetData(signal,data); + } + } + } + fRawHitList->Sort(fNRawHits); + + return fNRawHits; // Does anything care what is returned +>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035 } ClassImp(THcDetectorBase) diff --git a/src/THcDetectorBase.h b/src/THcDetectorBase.h index 91687beb036368db38cd9a8aebee3fcf0b9bdbec..b83a5c4e722a6ec1b2c1014a7303ec6cbaf0081b 100644 --- a/src/THcDetectorBase.h +++ b/src/THcDetectorBase.h @@ -2,6 +2,14 @@ #define ROOT_THcDetectorBase #include "THaDetectorBase.h" +<<<<<<< HEAD +======= +#include "THcRawHit.h" +#include "TClonesArray.h" + + +using namespace std; +>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035 ////////////////////////////////////////////////////////////////////////// // @@ -9,10 +17,16 @@ // ////////////////////////////////////////////////////////////////////////// +<<<<<<< HEAD +======= +//class THaDetMap; + +>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035 class THcDetectorBase : public THaDetectorBase { public: +<<<<<<< HEAD virtual ~THaDetectorBase(); THaDetectorBase(); // only for ROOT I/O @@ -20,5 +34,28 @@ class THcDetectorBase : public THaDetectorBase { protected: ClassDef(ThcDetectorBase,0) +======= + virtual ~THcDetectorBase(); + + THcDetectorBase(); // only for ROOT I/O + THcDetectorBase( const char* name, const char* description ); + + + virtual Int_t Decode( const THaEvData& ); + void InitHitlist(const char *hitclass, Int_t maxhits); + + // This is a list of pointers to hit objects + // Instead should we have a list of the actual objects so that we are + // no delting and creating objects all the time. + // + Int_t fNRawHits; + Int_t fNMaxRawHits; + TClonesArray* fRawHitList; // List of raw hits + TClass* fRawHitClass; // Class of raw hit object to use + + protected: + + ClassDef(THcDetectorBase,0) +>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035 }; #endif diff --git a/src/THcHodoscopeHit.cxx b/src/THcHodoscopeHit.cxx index bae4e82428dcd885b4202e88484d01170737e703..7e75328cc24d8ff45d43e30ebae68dd734c7c1f9 100644 --- a/src/THcHodoscopeHit.cxx +++ b/src/THcHodoscopeHit.cxx @@ -38,6 +38,25 @@ Int_t THcHodoscopeHit::GetData(Int_t signal) { return(-1); // Actually should throw exception } +Int_t THcHodoscopeHit::Compare(const TObject* obj) const +{ + // Compare to sort by plane and counter + + const THcHodoscopeHit* hit = dynamic_cast<const THcHodoscopeHit*>(obj); + + if(!hit) return -1; + Int_t p1 = fPlane; + Int_t p2 = hit->fPlane; + if(p1 < p2) return -1; + else if(p1 > p2) return 1; + else { + Int_t c1 = fCounter; + Int_t c2 = hit->fCounter; + if(c1 < c2) return -1; + else if (c1 == c2) return 0; + else return 1; + } +} //_____________________________________________________________________________ THcHodoscopeHit& THcHodoscopeHit::operator=( const THcHodoscopeHit& rhs ) { diff --git a/src/THcHodoscopeHit.h b/src/THcHodoscopeHit.h index 02081dd6b1e87ac64f403a83d515998db572b036..34a82612a5a7b9f42e588ae27454788aad26794d 100644 --- a/src/THcHodoscopeHit.h +++ b/src/THcHodoscopeHit.h @@ -9,14 +9,20 @@ class THcHodoscopeHit : public THcRawHit { THcHodoscopeHit(Int_t plane, Int_t counter) : THcRawHit(plane, counter), fADC_pos(-1), fADC_neg(-1), - fTDC_pos(-1), fTDC_neg(-1) {} + fTDC_pos(-1), fTDC_neg(-1) { + } THcHodoscopeHit& operator=( const THcHodoscopeHit& ); - virtual ~THcHodoscopeHit() {} + virtual void Clear( Option_t* opt="" ) + { fADC_pos = -1; fADC_neg = -1; fTDC_pos = -1; fTDC_neg = -1; } + void SetData(Int_t signal, Int_t data); Int_t GetData(Int_t signal); + virtual Bool_t IsSortable () const {return kTRUE; } + virtual Int_t Compare(const TObject* obj) const; + Int_t fADC_pos; Int_t fADC_neg; Int_t fTDC_pos; diff --git a/src/THcRawHit.h b/src/THcRawHit.h index 45287d405cad9c595f799c9804976f1ea9e74d5f..adfb730d38133939e349b9623a32c7c2a4d160ed 100644 --- a/src/THcRawHit.h +++ b/src/THcRawHit.h @@ -19,11 +19,17 @@ public: virtual ~THcRawHit(); + virtual void Clear( Option_t* opt="" )=0; + // virtual Bool_t operator==( const THcRawHit& ) = 0; // virtual Bool_t operator!=( const THcRawHit& ) = 0; virtual void SetData(Int_t signal, Int_t data) {}; - virtual Int_t GetData(Int_t signal) = 0; + virtual Int_t GetData(Int_t signal) {return 0;}; + + // Derived objects must be sortable and supply Compare method + virtual Bool_t IsSortable () const {return kFALSE; } + virtual Int_t Compare(const TObject* obj) const {return 0;} Int_t fPlane; Int_t fCounter; diff --git a/src/THcRawHitList.cxx b/src/THcRawHitList.cxx deleted file mode 100644 index 970608cee057864ecf42dd0417fc9a6ae8dc6c8b..0000000000000000000000000000000000000000 --- a/src/THcRawHitList.cxx +++ /dev/null @@ -1,37 +0,0 @@ -//*-- Author : Stephen Wood - -////////////////////////////////////////////////////////////////////////// -// -// THcRawHitList -// -// Class to build raw hit lists from data -// -////////////////////////////////////////////////////////////////////////// - -#include "THcRawHitList.h" - -using namespace std; - -THcRawHitList::THcRawHitList(const char* classname, Int_t detectorid, Int_t size=1000) { - fHits = new TClonesArray(classname, size); - fDetectorid = detectorid; -} - -THcRawHitList::~THcRawHitList() { - delete fHits; -} - -Int_t THcRawHitList::Fill(const THaEvData& evdata, const THcDetectorMap& dmap) -{ - // Zero out hit list - // Interate over list of channels belonging to detector, retrieving - // data that belongs to the detector -} - -void THcRawHitList::Clear( Option_t*) -{ - fHits->Clear(); -} - -////////////////////////////////////////////////////////////////////////// -ClassImp(THcRawHitList) diff --git a/src/THcRawHitList.h b/src/THcRawHitList.h deleted file mode 100644 index b548687c5c5bfbf7452c53ea969b80e223185217..0000000000000000000000000000000000000000 --- a/src/THcRawHitList.h +++ /dev/null @@ -1,50 +0,0 @@ - #ifndef ROOT_THcRawHitList - #define ROOT_THcRawHitList - -////////////////////////////////////////////////////////////////////////// -// -// THcRawHistList.h -// -////////////////////////////////////////////////////////////////////////// - -#include "TClonesArray.h" -#include "THcRawHit.h" -#include "THcDetectorMap.h" -#include "THaEvData.h" -#include <cassert> - -class THcRawHitList { - - public: - - THcRawHitList(const char* classname, Int_t detectorid, Int_t size); - virtual ~THcRawHitList(); - - Int_t Fill(const THaEvData& evdata, const THcDetectorMap& dmap); - // Should detector map be a member variable too? - - - TClonesArray* fHits; - Int_t fMaxhit; - - Int_t GetNHits() const { return fHits->GetLast()+1; } - TClonesArray* GetHits() const { return fHits; } - - // Should have a raw hit object so that certain methods are - // garuanteed to exist. (Like plane and counter) Because we may have - // methods to look up a certain plane or plane/counter, or sort etc. - - THcRawHit* GetHit(Int_t i) const - { assert(i >=0 && i<GetNHits() ); - return (THcRawHit*)fHits->UncheckedAt(i);} - - void Clear( Option_t*); - - protected: - Int_t fDetectorid; - - private: - ClassDef(THcRawHitList, 0); // Raw hit class -}; -#endif -