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

Merge branch 'saw_decoding' of ssh://wood/home/saw/ROOT/hcana into saw_decoding

Conflicts:
	src/THcDetectorBase.cxx
	src/THcDetectorBase.h
parents b9a7a3a8 d715b602
No related branches found
No related tags found
No related merge requests found
......@@ -9,8 +9,8 @@
SRC = src/THcInterface.cxx src/THcParmList.cxx src/THcAnalyzer.cxx \
src/THcHodoscopeHit.cxx src/THcRawHit.cxx src/THcRawHitList.cxx \
src/THcDetectorMap.cxx
src/THcHodoscopeHit.cxx src/THcRawHit.cxx \
src/THcDetectorBase.cxx
# Name of your package.
# The shared library that will be built will get the name lib$(PACKAGE).so
......
podd @ 3f08eaeb
Subproject commit 9a47be4dc77822bd7af642d1b3ca962f09cf89f6
Subproject commit 3f08eaebe0d0997888a9bf34ba90a211dd608a2d
......@@ -11,7 +11,6 @@
#pragma link C++ class THcAnalyzer+;
#pragma link C++ class THcRawHit+;
#pragma link C++ class THcHodoscopeHit+;
#pragma link C++ class THcRawHitList+;
#pragma link C++ class THcDetectorMap+;
#pragma link C++ class THcDetectorBase+;
#endif
......@@ -5,10 +5,22 @@
// THcDetectorBase
//
// Add hitlist to the Hall A detector base
<<<<<<< HEAD
//
//////////////////////////////////////////////////////////////////////////
#include "ThcDetectorBase.h"
=======
// May not need to inherit from THaDetectorBase since we may end up
// replacing most of the methods
//
//////////////////////////////////////////////////////////////////////////
#include "THcDetectorBase.h"
#include "THaEvData.h"
#include "THaDetMap.h"
#include "TClonesArray.h"
>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035
using namespace std;
......@@ -16,12 +28,88 @@ THcDetectorBase::THcDetectorBase( const char* name,
const char* description ) :
THaDetectorBase(name, description)
{
<<<<<<< HEAD
=======
// Normal constructor.
fRawHitList = NULL;
>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035
}
THcDetectorBase::THcDetectorBase() : THaDetectorBase() {
}
<<<<<<< HEAD
THcDetectorBase::~THcDetectorBase() : ~THaDetectorBase() {
=======
THcDetectorBase::~THcDetectorBase() {
// Destructor
}
void THcDetectorBase::InitHitlist(const char *hitclass, Int_t maxhits) {
// Probably called by ReadDatabase
fRawHitList = new TClonesArray(hitclass, maxhits);
fRawHitClass = fRawHitList->GetClass();
fNMaxRawHits = maxhits;
fNRawHits = 0;
for(Int_t i=0;i<maxhits;i++) {
fRawHitList->New(i);
}
}
Int_t THcDetectorBase::Decode( const THaEvData& evdata ) {
THcRawHit* rawhit;
fRawHitList->Clear("C");
fNRawHits = 0;
for ( Int_t i=0; i < fDetMap->GetSize(); i++ ) {
THaDetMap::Module* d = fDetMap->GetModule(i);
// Loop over all channels that have a hit.
for ( Int_t j=0; j < evdata.GetNumChan( d->crate, d->slot); j++) {
Int_t chan = evdata.GetNextChan( d->crate, d->slot, j );
if( chan < d->lo || chan > d->hi ) continue; // Not one of my channels
// Need to convert crate, slot, chan into plane, counter, signal
// Search hitlist for this plane,counter,signal
Int_t plane = d->plane;
Int_t signal = d->signal;
Int_t counter = d->reverse ? d->first + d->hi - chan : d->first + chan - d->lo;
// Search hit list for plane and counter
// We could do sorting
Int_t thishit = 0;
while(thishit < fNRawHits) {
rawhit = (THcRawHit*) (*fRawHitList)[thishit];
if (plane == rawhit->fPlane
&& counter == rawhit->fCounter) {
break;
}
thishit++;
}
if(thishit == fNRawHits) {
fNRawHits++;
rawhit = (THcRawHit*) (*fRawHitList)[thishit];
rawhit->fPlane = plane;
rawhit->fCounter = counter;
}
// Get the data from this channel
// Allow for multiple hits
Int_t nMHits = evdata.GetNumHits(d->crate, d->slot, chan);
for (Int_t mhit = 0; mhit < nMHits; mhit++) {
Int_t data = evdata.GetData( d->crate, d->slot, chan, mhit);
rawhit->SetData(signal,data);
}
}
}
fRawHitList->Sort(fNRawHits);
return fNRawHits; // Does anything care what is returned
>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035
}
ClassImp(THcDetectorBase)
......@@ -2,6 +2,14 @@
#define ROOT_THcDetectorBase
#include "THaDetectorBase.h"
<<<<<<< HEAD
=======
#include "THcRawHit.h"
#include "TClonesArray.h"
using namespace std;
>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035
//////////////////////////////////////////////////////////////////////////
//
......@@ -9,10 +17,16 @@
//
//////////////////////////////////////////////////////////////////////////
<<<<<<< HEAD
=======
//class THaDetMap;
>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035
class THcDetectorBase : public THaDetectorBase {
public:
<<<<<<< HEAD
virtual ~THaDetectorBase();
THaDetectorBase(); // only for ROOT I/O
......@@ -20,5 +34,28 @@ class THcDetectorBase : public THaDetectorBase {
protected:
ClassDef(ThcDetectorBase,0)
=======
virtual ~THcDetectorBase();
THcDetectorBase(); // only for ROOT I/O
THcDetectorBase( const char* name, const char* description );
virtual Int_t Decode( const THaEvData& );
void InitHitlist(const char *hitclass, Int_t maxhits);
// This is a list of pointers to hit objects
// Instead should we have a list of the actual objects so that we are
// no delting and creating objects all the time.
//
Int_t fNRawHits;
Int_t fNMaxRawHits;
TClonesArray* fRawHitList; // List of raw hits
TClass* fRawHitClass; // Class of raw hit object to use
protected:
ClassDef(THcDetectorBase,0)
>>>>>>> d715b6024d14d1acc253ad0eef3926e5d9f69035
};
#endif
......@@ -38,6 +38,25 @@ Int_t THcHodoscopeHit::GetData(Int_t signal) {
return(-1); // Actually should throw exception
}
Int_t THcHodoscopeHit::Compare(const TObject* obj) const
{
// Compare to sort by plane and counter
const THcHodoscopeHit* hit = dynamic_cast<const THcHodoscopeHit*>(obj);
if(!hit) return -1;
Int_t p1 = fPlane;
Int_t p2 = hit->fPlane;
if(p1 < p2) return -1;
else if(p1 > p2) return 1;
else {
Int_t c1 = fCounter;
Int_t c2 = hit->fCounter;
if(c1 < c2) return -1;
else if (c1 == c2) return 0;
else return 1;
}
}
//_____________________________________________________________________________
THcHodoscopeHit& THcHodoscopeHit::operator=( const THcHodoscopeHit& rhs )
{
......
......@@ -9,14 +9,20 @@ class THcHodoscopeHit : public THcRawHit {
THcHodoscopeHit(Int_t plane, Int_t counter) : THcRawHit(plane, counter),
fADC_pos(-1), fADC_neg(-1),
fTDC_pos(-1), fTDC_neg(-1) {}
fTDC_pos(-1), fTDC_neg(-1) {
}
THcHodoscopeHit& operator=( const THcHodoscopeHit& );
virtual ~THcHodoscopeHit() {}
virtual void Clear( Option_t* opt="" )
{ fADC_pos = -1; fADC_neg = -1; fTDC_pos = -1; fTDC_neg = -1; }
void SetData(Int_t signal, Int_t data);
Int_t GetData(Int_t signal);
virtual Bool_t IsSortable () const {return kTRUE; }
virtual Int_t Compare(const TObject* obj) const;
Int_t fADC_pos;
Int_t fADC_neg;
Int_t fTDC_pos;
......
......@@ -19,11 +19,17 @@ public:
virtual ~THcRawHit();
virtual void Clear( Option_t* opt="" )=0;
// virtual Bool_t operator==( const THcRawHit& ) = 0;
// virtual Bool_t operator!=( const THcRawHit& ) = 0;
virtual void SetData(Int_t signal, Int_t data) {};
virtual Int_t GetData(Int_t signal) = 0;
virtual Int_t GetData(Int_t signal) {return 0;};
// Derived objects must be sortable and supply Compare method
virtual Bool_t IsSortable () const {return kFALSE; }
virtual Int_t Compare(const TObject* obj) const {return 0;}
Int_t fPlane;
Int_t fCounter;
......
//*-- Author : Stephen Wood
//////////////////////////////////////////////////////////////////////////
//
// THcRawHitList
//
// Class to build raw hit lists from data
//
//////////////////////////////////////////////////////////////////////////
#include "THcRawHitList.h"
using namespace std;
THcRawHitList::THcRawHitList(const char* classname, Int_t detectorid, Int_t size=1000) {
fHits = new TClonesArray(classname, size);
fDetectorid = detectorid;
}
THcRawHitList::~THcRawHitList() {
delete fHits;
}
Int_t THcRawHitList::Fill(const THaEvData& evdata, const THcDetectorMap& dmap)
{
// Zero out hit list
// Interate over list of channels belonging to detector, retrieving
// data that belongs to the detector
}
void THcRawHitList::Clear( Option_t*)
{
fHits->Clear();
}
//////////////////////////////////////////////////////////////////////////
ClassImp(THcRawHitList)
#ifndef ROOT_THcRawHitList
#define ROOT_THcRawHitList
//////////////////////////////////////////////////////////////////////////
//
// THcRawHistList.h
//
//////////////////////////////////////////////////////////////////////////
#include "TClonesArray.h"
#include "THcRawHit.h"
#include "THcDetectorMap.h"
#include "THaEvData.h"
#include <cassert>
class THcRawHitList {
public:
THcRawHitList(const char* classname, Int_t detectorid, Int_t size);
virtual ~THcRawHitList();
Int_t Fill(const THaEvData& evdata, const THcDetectorMap& dmap);
// Should detector map be a member variable too?
TClonesArray* fHits;
Int_t fMaxhit;
Int_t GetNHits() const { return fHits->GetLast()+1; }
TClonesArray* GetHits() const { return fHits; }
// Should have a raw hit object so that certain methods are
// garuanteed to exist. (Like plane and counter) Because we may have
// methods to look up a certain plane or plane/counter, or sort etc.
THcRawHit* GetHit(Int_t i) const
{ assert(i >=0 && i<GetNHits() );
return (THcRawHit*)fHits->UncheckedAt(i);}
void Clear( Option_t*);
protected:
Int_t fDetectorid;
private:
ClassDef(THcRawHitList, 0); // Raw hit class
};
#endif
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