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..55431e68aa246c072e0da1bd6ef20e1218c0fdc9 160000 --- a/podd +++ b/podd @@ -1 +1 @@ -Subproject commit 9a47be4dc77822bd7af642d1b3ca962f09cf89f6 +Subproject commit 55431e68aa246c072e0da1bd6ef20e1218c0fdc9 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/THcDetMap.cxx b/src/THcDetMap.cxx deleted file mode 100644 index da3b15ab19e8fa515f550aa12e6b2f0a7b36701a..0000000000000000000000000000000000000000 --- a/src/THcDetMap.cxx +++ /dev/null @@ -1,41 +0,0 @@ -//*-- Author : Ole Hansen 16/05/00 - -////////////////////////////////////////////////////////////////////////// -// -// THcDetMap -// -// The standard detector map for a Hall A detector. -// -////////////////////////////////////////////////////////////////////////// - -#include "THcDetMap.h" -#include <iostream> -#include <iomanip> -#include <cstring> -#include <cstdlib> - -using namespace std; - -//_____________________________________________________________________________ -THcDetMap::THcDetMap() : THaDetMap() -{ - // Default constructor. Creates an empty detector map. -} - -//_____________________________________________________________________________ -THcDetMap::THcDetMap( const THcDetMap& rhs ) : THaDetMap( rhs ) -{ - // Copy constructor - -} - -//_____________________________________________________________________________ -THcDetMap::~THcDetMap() -{ - // Destructor - - delete [] fMap; -} - -//_____________________________________________________________________________ -ClassImp(THcDetMap) diff --git a/src/THcDetMap.h b/src/THcDetMap.h deleted file mode 100644 index 47d4d0f27fa1bea0e28ee27e7af88626ac2a1a88..0000000000000000000000000000000000000000 --- a/src/THcDetMap.h +++ /dev/null @@ -1,66 +0,0 @@ - -#ifndef ROOT_THcDetMap -#define ROOT_THcDetMap - -////////////////////////////////////////////////////////////////////////// -// -// THcDetMap -// -// Standard detector map. -// -// Add plane and signal information to Hall A standard. -// -////////////////////////////////////////////////////////////////////////// - -//FIXME: Several things here are duplicates of information that already is -// (or should be) available from the cratemap: specifically "model" and -// "resolution", as well as the "model map" in AddModule. We should get it from -// there - to ensure consistency and have one less maintenance headache. - -#include "THaDetMap.h" - -class THcDetMap : public THaDetMap { - -public: - struct Module { - UShort_t crate; - UShort_t slot; - UShort_t lo; - UShort_t hi; - UInt_t first; // logical number of first channel - UInt_t plane; // Plane of detector - UInt_t signal; // Signal type (ADC/TDC/Left/Right) - UInt_t model; // model number of module (for ADC/TDC identification). - Int_t refchan; // for pipeline TDCs: reference channel number - Int_t refindex; // for pipeline TDCs: index into reference channel map - Double_t resolution; // Resolution (s/chan) for TDCs - Bool_t reverse; // Indicates that "first" corresponds to hi, not lo - - bool operator==( const Module& rhs ) const - { return crate == rhs.crate && slot == rhs.slot; } - bool operator!=( const Module& rhs ) const - { return !(*this==rhs); } - Int_t GetNchan() const { return hi-lo+1; } - UInt_t GetModel() const { return model & kModelMask; } - Bool_t IsTDC() const { return model & kTDCBit; } - Bool_t IsADC() const { return model & kADCBit; } - void SetModel( UInt_t model ); - void SetResolution( Double_t resolution ); - void MakeTDC() { model |= kTDCBit; } - void MakeADC() { model |= kADCBit; } - }; - - THcDetMap(); - THcDetMap( const THcDetMap& ); - THcDetMap& operator=( const THcDetMap& ); - virtual ~THcDetMap(); - -protected: - Module* fMap; // Array of modules, each module is a 7-tuple - // (create,slot,chan_lo,chan_hi,first_logical, - // model,refindex) - - ClassDef(THcDetMap,0) //The standard detector map -}; - -#endif diff --git a/src/THcDetectorBase.cxx b/src/THcDetectorBase.cxx index f3adde0c649559888127f4803783693a18d41555..26e30419cfccae411efe30fd79783bb2973b838b 100644 --- a/src/THcDetectorBase.cxx +++ b/src/THcDetectorBase.cxx @@ -10,21 +10,19 @@ // ////////////////////////////////////////////////////////////////////////// -#include "ThcDetectorBase.h" -#include "THcDetMap.h" +#include "THcDetectorBase.h" +#include "THaEvData.h" +#include "THaDetMap.h" +#include "TClonesArray.h" using namespace std; THcDetectorBase::THcDetectorBase( const char* name, const char* description ) : - THaAnalysisObject(name, description), fNelem(0) + THaDetectorBase(name, description) { - // Normal constructor. Creates an empty detector map. - // Later can use THaDetectorBase if signal and plane info - // is added to the THaDetMap in podd. + // Normal constructor. - fSize[0] = fSize[1] = fSize[2] = 0.0; - fDetMap = new THcDetMap; fRawHitList = NULL; } @@ -32,17 +30,19 @@ THcDetectorBase::THcDetectorBase( const char* name, THcDetectorBase::THcDetectorBase() : THaDetectorBase() { } -THcDetectorBase::~THcDetectorBase() : ~THaDetectorBase() { +THcDetectorBase::~THcDetectorBase() { + // Destructor } -THcDetectorBase::InitHitlist(const char *hitclass, Int_T maxhits) { +void THcDetectorBase::InitHitlist(const char *hitclass, Int_t maxhits) { // Probably called by ReadDatabase fRawHitList = new TClonesArray(hitclass, maxhits); + fNMaxRawHits = maxhits; + fNRawHits = 0; } -THcDetectorBase::Decode( THaEvData& evdata ) -{ +Int_t THcDetectorBase::Decode( const THaEvData& evdata ) { THcRawHit* rawhit; fRawHitList->Clear("C"); @@ -62,13 +62,21 @@ THcDetectorBase::Decode( THaEvData& evdata ) Int_t counter = d->reverse ? d->first + d->hi - chan : d->first + chan - d->lo; // Allow for multiple hits - Int_t nHits = evData.GetNumHits(d->crate, d->slot, chan); + + // Search hit list for plane and counter + for (Int_t hit = 0; hit < n + // Get the data. Scintillators are assumed to have only single hit (hit=0) + 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); + + - - for (Int_t hit = 0; hit < nHits; hit++) { - Int_t data = evdata.GetData( d->crate, d->slot, chan, hit); + THcRawHit* GetHit(Int_t i) const + { assert(i >=0 && i<GetNHits() ); + return (THcRawHit*)fHits->UncheckedAt(i);} while( raw data) { diff --git a/src/THcDetectorBase.h b/src/THcDetectorBase.h index a735568a73aba4caca75da7fb10e68f8dbfc0fa2..9b02568b82b899dd6e9b00ca18a8ea8bea741590 100644 --- a/src/THcDetectorBase.h +++ b/src/THcDetectorBase.h @@ -14,25 +14,32 @@ using namespace std; // ////////////////////////////////////////////////////////////////////////// -class THcDetMap; +//class THaDetMap; class THcDetectorBase : public THaDetectorBase { public: - virtual ~THaDetectorBase(); + virtual ~THcDetectorBase(); - THaDetectorBase(); // only for ROOT I/O + 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) + ClassDef(THcDetectorBase,0) }; #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;