diff --git a/src/THcHitList.h b/src/THcHitList.h index 099eb6abd7a7f3bb5b80f11b4314a724e2a156de..d96383bc1c1e70b4d1b976ea88fcf2b87c83e539 100644 --- a/src/THcHitList.h +++ b/src/THcHitList.h @@ -30,6 +30,8 @@ class THcHitList { void InitHitList(THaDetMap* detmap, const char *hitclass, Int_t maxhits); + TClonesArray* GetHitList() const {return fRawHitList; } + Int_t fNRawHits; Int_t fNMaxRawHits; TClonesArray* fRawHitList; // List of raw hits diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 24f1c38238f382342a5884baae8631707153ee9f..251f3381ad1cac5d2b41749df5b00a3dfc0ead02 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -78,14 +78,13 @@ void THcHodoscope::Setup(const char* name, const char* description) // 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(desc, description); strcat(desc, " Plane "); strcat(desc, fPlaneNames[i]); - fPlanes[i] = new THcScintillatorPlane(fPlaneNames[i], desc, this); + fPlanes[i] = new THcScintillatorPlane(fPlaneNames[i], desc, i+1, this); cout << "Created Scintillator Plane " << fPlaneNames[i] << ", " << desc << endl; } } @@ -112,13 +111,20 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date ) cout << "THcHodoscope::Init " << GetName() << endl; + // Should probably put this in ReadDatabase as we will know the + // maximum number of hits after setting up the detector map + // But it needs to happen before the sub detectors are initialized + // so that they can get the pointer to the hitlist. + + THcHitList::InitHitList(fDetMap, "THcHodoscopeHit", 100); + EStatus status; // This triggers call of ReadDatabase and DefineVariables if( (status = THaNonTrackingDetector::Init( date )) ) return fStatus=status; for(Int_t ip=0;ip<fNPlanes;ip++) { - if(status = fPlanes[ip]->Init( date )) { + if((status = fPlanes[ip]->Init( date ))) { return fStatus=status; } } @@ -130,11 +136,6 @@ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date ) // }; // memcpy( fDataDest, tmp, NDEST*sizeof(DataDest) ); - // Should probably put this in ReadDatabase as we will know the - // maximum number of hits after setting up the detector map - - THcHitList::InitHitList(fDetMap, "THcHodoscopeHit", 100); - // Will need to determine which apparatus it belongs to and use the // appropriate detector ID in the FillMap call if( gHcDetectorMap->FillMap(fDetMap, "HSCIN") < 0 ) { @@ -375,10 +376,11 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) // Let each plane get its hits Int_t nexthit = 0; for(Int_t ip=0;ip<fNPlanes;ip++) { - // nexthit = fPlanes[ip]->Fill(fRawHitList, nhits, nexthit); + nexthit = fPlanes[ip]->ProcessHits(fRawHitList, nexthit); } // fRawHitList is TClones array of THcHodoscopeHit objects +#if 0 for(Int_t ihit = 0; ihit < fNRawHits ; ihit++) { THcHodoscopeHit* hit = (THcHodoscopeHit *) fRawHitList->At(ihit); cout << ihit << " : " << hit->fPlane << ":" << hit->fCounter << " : " @@ -386,6 +388,7 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) << " " << hit->fTDC_neg << endl; } cout << endl; +#endif return nhits; } diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index ad10179a36ad4c82491569871596692ac6f9843e..e0937b89af863f4abdb727306d8315574f980726 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -26,8 +26,6 @@ public: virtual Int_t Decode( const THaEvData& ); virtual EStatus Init( const TDatime& run_time ); - // void SetApparatus( THaApparatus* ); - virtual Int_t CoarseProcess( TClonesArray& tracks ); virtual Int_t FineProcess( TClonesArray& tracks ); diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 096df9f1fc81baf1ebc27e3aac771cccca86213f..7353a92bc7d1177ebe02e46d609722d83e5bce62 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -11,6 +11,8 @@ #include "THcSignalHit.h" #include "THcGlobals.h" #include "THcParmList.h" +#include "THcHitList.h" +#include "THcHodoscope.h" #include <cstring> #include <cstdio> @@ -23,8 +25,9 @@ ClassImp(THcScintillatorPlane) //______________________________________________________________________________ THcScintillatorPlane::THcScintillatorPlane( const char* name, - const char* description, - THaDetectorBase* parent ) + const char* description, + const Int_t planenum, + THaDetectorBase* parent ) : THaSubDetector(name,description,parent) { // Normal constructor with name and description @@ -32,6 +35,7 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name, fNegTDCHits = new TClonesArray("THcSignalHit",16); fPosADCHits = new TClonesArray("THcSignalHit",16); fNegADCHits = new TClonesArray("THcSignalHit",16); + fPlaneNum = planenum; } //______________________________________________________________________________ @@ -61,6 +65,11 @@ THaAnalysisObject::EStatus THcScintillatorPlane::Init( const TDatime& date ) if( (status=THaSubDetector::Init( date )) ) return fStatus = status; + // Get the Hodoscope hitlist + // Can't seem to cast to THcHitList. What to do if we want to use + // THcScintillatorPlane as a subdetector to other than THcHodoscope? + // fParentHitList = static_cast<THcHodoscope*>(GetParent())->GetHitList(); + return fStatus = kOK; } @@ -125,13 +134,13 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode ) // Register variables in global list RVarDef vars[] = { {"postdchits", "List of Positive TDC hits", - "fPosTDCHits.THcSignalHit.GetPaddle()"}, + "fPosTDCHits.THcSignalHit.GetPaddleNumber()"}, {"negtdchits", "List of Negative TDC hits", - "fNegTDCHits.THcSignalHit.GetPaddle()"}, + "fNegTDCHits.THcSignalHit.GetPaddleNumber()"}, {"posadchits", "List of Positive ADC hits", - "fPosADCHits.THcSignalHit.GetPaddle()"}, + "fPosADCHits.THcSignalHit.GetPaddleNumber()"}, {"negadchits", "List of Negative ADC hits", - "fNegADCHits.THcSignalHit.GetPaddle()"}, + "fNegADCHits.THcSignalHit.GetPaddleNumber()"}, { 0 } }; @@ -141,7 +150,7 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode ) //_____________________________________________________________________________ void THcScintillatorPlane::Clear( Option_t* ) { - cout << " Calling THcScintillatorPlane::Clear " << GetName() << endl; + //cout << " Calling THcScintillatorPlane::Clear " << GetName() << endl; // Clears the hit lists fPosTDCHits->Clear(); fNegTDCHits->Clear(); @@ -171,3 +180,55 @@ Int_t THcScintillatorPlane::FineProcess( TClonesArray& tracks ) { return 0; } +Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) +{ + // Extract the data for this plane from hit list + // Assumes that the hit list is sorted by plane, so we stop when the + // plane doesn't agree and return the index for the next hit. + + Int_t nPosTDCHits=0; + Int_t nNegTDCHits=0; + Int_t nPosADCHits=0; + Int_t nNegADCHits=0; + fPosTDCHits->Clear(); + fNegTDCHits->Clear(); + fPosADCHits->Clear(); + fNegADCHits->Clear(); + + Int_t nrawhits = rawhits->GetLast()+1; + // cout << "THcScintillatorPlane::ProcessHits " << fPlaneNum << " " << nexthit << "/" << nrawhits << endl; + + Int_t ihit = nexthit; + while(ihit < nrawhits) { + THcHodoscopeHit* hit = (THcHodoscopeHit *) rawhits->At(ihit); + if(hit->fPlane > fPlaneNum) { + break; + } + + if(hit->fTDC_pos > 0) { + THcSignalHit *sighit = (THcSignalHit*) fPosTDCHits->ConstructedAt(nPosTDCHits++); + sighit->Set(hit->fCounter, hit->fTDC_pos); + } + + if(hit->fTDC_neg > 0) { + THcSignalHit *sighit = (THcSignalHit*) fNegTDCHits->ConstructedAt(nNegTDCHits++); + sighit->Set(hit->fCounter, hit->fTDC_neg); + } + + if(hit->fADC_pos > 0) { + THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++); + sighit->Set(hit->fCounter, hit->fADC_pos); + } + + if(hit->fADC_neg > 0) { + THcSignalHit *sighit = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++); + sighit->Set(hit->fCounter, hit->fADC_neg); + } + ihit++; + } + return(ihit); +} + + + + diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index 9629c3fd1916c6a98d25288a69a568cf6d83bd0d..ad3f6cb19df58196679bea56d712b3b389caf52c 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -22,7 +22,7 @@ class THcScintillatorPlane : public THaSubDetector { public: THcScintillatorPlane( const char* name, const char* description, - THaDetectorBase* parent = NULL); + Int_t planenum, THaDetectorBase* parent = NULL); virtual ~THcScintillatorPlane(); virtual void Clear( Option_t* opt="" ); @@ -34,8 +34,12 @@ class THcScintillatorPlane : public THaSubDetector { Bool_t IsTracking() { return kFALSE; } virtual Bool_t IsPid() { return kFALSE; } + virtual Int_t ProcessHits(TClonesArray* rawhits, Int_t nexthit); + Double_t fSpacing; + TClonesArray* fParentHitList; + protected: TClonesArray* fPosTDCHits; @@ -43,6 +47,8 @@ class THcScintillatorPlane : public THaSubDetector { TClonesArray* fPosADCHits; TClonesArray* fNegADCHits; + Int_t fPlaneNum; + virtual Int_t ReadDatabase( const TDatime& date ); virtual Int_t DefineVariables( EMode mode = kDefine ); diff --git a/src/THcSignalHit.h b/src/THcSignalHit.h index fed4b892691754dd30674a9970d0dc2d5185a790..da9d27bbacafefd96e8c1d401a2fd860adcfcb2e 100644 --- a/src/THcSignalHit.h +++ b/src/THcSignalHit.h @@ -20,6 +20,9 @@ class THcSignalHit : public TObject { Int_t GetPaddleNumber() {return fPaddleNumber;} Double_t GetData() {return fData;} + virtual void Set(Int_t paddle, Int_t data) + { fPaddleNumber=paddle; fData=data; } + private: Int_t fPaddleNumber; Double_t fData;