From 4b251dee5f9b46ca82c3fb540de6cca9104cee1d Mon Sep 17 00:00:00 2001
From: "Stephen A. Wood" <zviwood@gmail.com>
Date: Sun, 8 Apr 2012 21:19:55 -0400
Subject: [PATCH] THcDetector is identical to THaDetector except that it
 inherits from THcDetectorBase

---
 Makefile            |  2 +-
 src/HallC_LinkDef.h |  1 +
 src/THcDetector.cxx | 67 +++++++++++++++++++++++++++++++++++++++++++++
 src/THcDetector.h   | 46 +++++++++++++++++++++++++++++++
 4 files changed, 115 insertions(+), 1 deletion(-)
 create mode 100644 src/THcDetector.cxx
 create mode 100644 src/THcDetector.h

diff --git a/Makefile b/Makefile
index 64f1a3d..f6ac927 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 b6d0a97..fe969ab 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 0000000..546a2c3
--- /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 0000000..d048ebd
--- /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
-- 
GitLab