diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 7606f76074a360de5a0c12d71d8aff3066f17459..b6769caf625fc7ed0d8f26fd032b5ba2bbd5f39e 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -37,7 +37,52 @@ THcHodoscope::THcHodoscope( const char* name, const char* description, { // Constructor - fTrackProj = new TClonesArray( "THaTrackProj", 5 ); + //fTrackProj = new TClonesArray( "THaTrackProj", 5 ); + // Construct the planes + + Setup(name, description); + +} +//_____________________________________________________________________________ +void THcHodoscope::Setup(const char* name, const char* description) +{ + + static const char* const here = "Setup()"; + static const char* const message = + "Must construct %s detector with valid name! Object construction failed."; + + // Base class constructor failed? + if( IsZombie()) return; + + fNPlanes = 4; // Eventually get # planes and plane names from a DB + fPlaneNames = new char* [fNPlanes]; + for(Int_t i=0;i<fNPlanes;i++) {fPlaneNames[i] = new char[3];} + strcpy(fPlaneNames[0],"1x"); + strcpy(fPlaneNames[1],"1y"); + strcpy(fPlaneNames[2],"2x"); + strcpy(fPlaneNames[3],"2y"); + + size_t nlen = strlen(name); + size_t slen = 0; + for(Int_t i=0;i < fNPlanes;i++) + {slen = TMath::Max(slen,strlen(fPlaneNames[i]));} + size_t len = nlen+slen+1; + + // Probably shouldn't assume that description is defined + char* desc = new char[strlen(description)+50+slen]; + char* subname = new char[len+1]; + fPlanes = new THcScintillatorPlane* [fNPlanes]; + for(Int_t i=0;i < fNPlanes;i++) { + strcpy(subname, name); + strcat(subname, "."); + strcat(subname, fPlaneNames[i]); + + strcpy(desc, description); + strcpy(desc, " Hodoscope Plane "); + strcpy(desc, fPlaneNames[i]); + + fPlanes[i] = new THcScintillatorPlane(subname, desc); + } } //_____________________________________________________________________________ @@ -55,19 +100,6 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date ) if( THaNonTrackingDetector::Init( date ) ) return fStatus; - // Construct the planes - fPlane = new THcScintillatorPlane* [fNPlanes]; - for(Int_t ip=0; ip<fNPlanes; ip++) { - // Create a name and description - // Is it going to be a problem that I create these object in init? - // I could actually do it in the constructor, since the parameters - // will already have been read. Then I don't have to manually call - // ReadDatabase for each plane - GetTitle() - fPlane[ip] = THcScintillatorPlane( name, description); - } - - // Replace with what we need for Hall C // const DataDest tmp[NDEST] = { // { &fRTNhit, &fRANhit, fRT, fRT_c, fRA, fRA_p, fRA_c, fROff, fRPed, fRGain }, @@ -131,20 +163,20 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) fNPlanes = 4; // Hardwire for now - fNPaddle = new Int_t [4]; + fNPaddle = new Int_t [fNPlanes]; fNPaddle[0] = *(Int_t *)gHcParms->Find("hscin_1x_nr")->GetValuePointer(); fNPaddle[1] = *(Int_t *)gHcParms->Find("hscin_1y_nr")->GetValuePointer(); fNPaddle[2] = *(Int_t *)gHcParms->Find("hscin_2x_nr")->GetValuePointer(); fNPaddle[3] = *(Int_t *)gHcParms->Find("hscin_2y_nr")->GetValuePointer(); - fSpacing = new Double_t [4]; + fSpacing = new Double_t [fNPlanes]; fSpacing[0] = gHcParms->Find("hscin_1x_spacing")->GetValue(0); fSpacing[1] = gHcParms->Find("hscin_1y_spacing")->GetValue(0); fSpacing[2] = gHcParms->Find("hscin_2x_spacing")->GetValue(0); fSpacing[3] = gHcParms->Find("hscin_2y_spacing")->GetValue(0); - fCenter = new Double_t* [4]; + fCenter = new Double_t* [fNPlanes]; Double_t* p; Int_t iplane; diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index df56b5376606de6b139ca51eafc5514e3f828beb..88c9483d53469f6dbe16958b21efca19b277d33b 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -46,11 +46,12 @@ protected: // Potential Hall C parameters. Mostly here for demonstration Int_t fNPlanes; + char** fPlaneNames; Int_t* fNPaddle; // Number of paddles per plane Double_t* fSpacing; // Paddle spacing in cm Double_t** fCenter; // Center position of each paddle - THcScintillatorPlane** fPlane; // List of plane objects + THcScintillatorPlane** fPlanes; // List of plane objects TClonesArray* fTrackProj; // projection of track onto scintillator plane // and estimated match to TOF paddle @@ -81,6 +82,8 @@ protected: virtual Double_t TimeWalkCorrection(const Int_t& paddle, const ESide side); + void Setup(const char* name, const char* description); + ClassDef(THcHodoscope,0) // Generic hodoscope class }; diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index a2b30d01727ee7741520c2c852c94ea9864870d3..87aeb5f0f4abac104110d7864c658f613e2b6e48 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -26,3 +26,22 @@ THcScintillatorPlane::~THcScintillatorPlane() // Destructor } +//_____________________________________________________________________________ +Int_t THcScintillatorPlane::Decode( const THaEvData& evdata ) +{ + return 0; +} +//_____________________________________________________________________________ +Int_t THcScintillatorPlane::CoarseProcess( TClonesArray& tracks ) +{ + + // HitCount(); + + return 0; +} + +//_____________________________________________________________________________ +Int_t THcScintillatorPlane::FineProcess( TClonesArray& tracks ) +{ + return 0; +} diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index ce546684471fefb9bc8a518b01ef22f4a7bba198..0930c865b853cb513eecb383aea37a3586839b7e 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -17,13 +17,15 @@ class THcScintillatorPlane : public THaNonTrackingDetector { public: - virtual ~THcScintillatorPlane(); - THcScintillatorPlane( const char* name, const char* description, THaApparatus* a = NULL); + virtual ~THcScintillatorPlane(); + + virtual Int_t Decode( const THaEvData& ); + - virtual Int_t CoarseProcess( TClonesArray& tracks ) = 0; - virtual Int_t FineProcess( TClonesArray& tracks ) = 0; + virtual Int_t CoarseProcess( TClonesArray& tracks ); + virtual Int_t FineProcess( TClonesArray& tracks ); Bool_t IsTracking() { return kFALSE; } virtual Bool_t IsPid() { return kFALSE; }