diff --git a/Makefile b/Makefile index 64f1a3d269375b9f76850990abfe1f901cfa62a4..f6ac9270e73a405a6765bbbdae0151b999060ef0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ SRC = src/THcInterface.cxx src/THcParmList.cxx src/THcAnalyzer.cxx \ src/THcHodoscopeHit.cxx src/THcRawHit.cxx \ - src/THcDetectorBase.cxx + src/THcDetectorBase.cxx src/THcDetector.cxx # Name of your package. # The shared library that will be built will get the name lib$(PACKAGE).so diff --git a/src/HallC_LinkDef.h b/src/HallC_LinkDef.h index b6d0a97bc6788f0276a5b4233746b482f4db49e1..fe969aba42679a86b3b72b1d4d35fc7f2c7234a3 100644 --- a/src/HallC_LinkDef.h +++ b/src/HallC_LinkDef.h @@ -12,5 +12,6 @@ #pragma link C++ class THcRawHit+; #pragma link C++ class THcHodoscopeHit+; #pragma link C++ class THcDetectorBase+; +#pragma link C++ class THcDetector+; #endif diff --git a/src/THcDetector.cxx b/src/THcDetector.cxx new file mode 100644 index 0000000000000000000000000000000000000000..546a2c3970c2217ccb13622c999253997f7ca714 --- /dev/null +++ b/src/THcDetector.cxx @@ -0,0 +1,67 @@ +//*-- Author : Ole Hansen 15-May-00 + +////////////////////////////////////////////////////////////////////////// +// +// THcDetector +// +////////////////////////////////////////////////////////////////////////// + +#include "THcDetector.h" +#include "THaApparatus.h" + +ClassImp(THcDetector) + +//_____________________________________________________________________________ +THcDetector::THcDetector( const char* name, const char* description, + THaApparatus* apparatus ) + : THcDetectorBase(name,description), fApparatus(apparatus) +{ + // Constructor + + if( !name || !*name ) { + Error( "THcDetector()", "Must construct detector with valid name! " + "Object construction failed." ); + MakeZombie(); + return; + } +} + +//_____________________________________________________________________________ +THcDetector::THcDetector( ) : fApparatus(0) { + // for ROOT I/O only +} + +//_____________________________________________________________________________ +THcDetector::~THcDetector() +{ + // Destructor +} + +//_____________________________________________________________________________ +void THcDetector::SetApparatus( THaApparatus* apparatus ) +{ + // Associate this detector with the given apparatus. + // Only possible before initialization. + + if( IsInit() ) { + Warning( Here("SetApparatus()"), "Cannot set apparatus. " + "Object already initialized."); + return; + } + fApparatus = apparatus; +} + +//_____________________________________________________________________________ +void THcDetector::MakePrefix() +{ + // Set up name prefix for global variables. Internal function called + // during initialization. + + const char* basename = NULL; + THaApparatus *app = GetApparatus(); + if( app ) + basename = app->GetName(); + THcDetectorBase::MakePrefix( basename ); + +} + diff --git a/src/THcDetector.h b/src/THcDetector.h new file mode 100644 index 0000000000000000000000000000000000000000..d048ebdffc1aa4132cecfafd5b4dde393fd5aca9 --- /dev/null +++ b/src/THcDetector.h @@ -0,0 +1,46 @@ +#ifndef ROOT_THcDetector +#define ROOT_THcDetector + +////////////////////////////////////////////////////////////////////////// +// +// THcDetector +// +// Abstract base class for a generic Hall C detector. This class +// describes an actual detector (not subdetector) and can be added to +// an apparatus. +// +////////////////////////////////////////////////////////////////////////// + +#include "THcDetectorBase.h" +#include <TRef.h> +#include "THaApparatus.h" + +//class THaApparatus; + +class THcDetector : public THcDetectorBase { + +public: + virtual ~THcDetector(); + THaApparatus* GetApparatus() const { + return static_cast<THaApparatus*>(fApparatus.GetObject()); + } + + virtual void SetApparatus( THaApparatus* ); + + THcDetector(); // for ROOT I/O only + +protected: + + virtual void MakePrefix(); + + //Only derived classes may construct me + THcDetector( const char* name, const char* description, + THaApparatus* apparatus = NULL ); + +private: + TRef fApparatus; // Apparatus containing this detector + + ClassDef(THcDetector,0) //Abstract base class for a Hall C detector +}; + +#endif