Skip to content
Snippets Groups Projects
Commit dc485710 authored by Stephen A. Wood's avatar Stephen A. Wood
Browse files

Fill Root tree with data for scintillator hit map

parent 758093d3
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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);
}
......@@ -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 );
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment