From 0ab46de3cebf48cf75f7f6e5db7d596b579e4ddb Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Fri, 13 Apr 2012 17:29:00 -0400 Subject: [PATCH] Checkin of days work. Starting to convert Hall C to Hall A detector map. --- src/HallC_LinkDef.h | 1 + src/THcDetectorMap.cxx | 82 ++++++++++++++++++++++++++++++++++++++---- src/THcDetectorMap.h | 45 +++++++++++++++++------ src/THcHodoscope.cxx | 1 + 4 files changed, 112 insertions(+), 17 deletions(-) diff --git a/src/HallC_LinkDef.h b/src/HallC_LinkDef.h index e0ceea5..7a5e99d 100644 --- a/src/HallC_LinkDef.h +++ b/src/HallC_LinkDef.h @@ -5,6 +5,7 @@ #pragma link off all functions; #pragma link C++ global gHcParms; +#pragma link C++ global gHcDetectorMap; #pragma link C++ class THcInterface+; #pragma link C++ class THcParmList+; diff --git a/src/THcDetectorMap.cxx b/src/THcDetectorMap.cxx index 710c5d2..7614167 100644 --- a/src/THcDetectorMap.cxx +++ b/src/THcDetectorMap.cxx @@ -32,11 +32,70 @@ inline static bool IsComment( const string& s, string::size_type pos ) (s[pos] == '!') ); } -virtual Int_t THcDetectorMap::FillMap(THaDetMap *detmap, string *detectorname) { - Int_t detectorid=3; // Get this from detectorname - - // Loop through the list looking for all hardware channels that - // are detectorid. Sort and try to minimize AddModule calls +//_____________________________________________________________________________ +THcDetectorMap::THcDetectorMap() : fNchans(0) +{ +} + +//_____________________________________________________________________________ +THcDetectorMap::~THcDetectorMap() +{ +} + +//bool THcDetectorMap::compare(const ChaninMod *first, const ChaninMod *second) { +// return((first->channel < second->channel)? true: false); +//} +struct Functor +{ + bool operator() (const THcDetectorMap::ChaninMod &first, const THcDetectorMap::ChaninMod &second) + { return((first.channel < second.channel)? true: false);} +}; +//_____________________________________________________________________________ +Int_t THcDetectorMap::FillMap(THaDetMap *detmap, const char *detectorname) +// Should probably return a status +{ + list<ModChanList>::iterator imod; + ChaninMod Achan; + ModChanList Amod; + + // Need one array of uniq crate/slot combos + + // Translate detector name into and ID + Int_t did=3; // Get this from detectorname + mlist.clear(); + + for(Int_t ich=0;ich<fNchans;ich++) { + if(fTable[ich].did == did) { + Int_t roc=fTable[ich].roc; + Int_t slot=fTable[ich].slot; + for(imod=mlist.begin(); imod!= mlist.end(); ++imod) { + Achan.channel = fTable[ich].channel; + Achan.plane = fTable[ich].plane; + Achan.counter = fTable[ich].counter; + Achan.signal = fTable[ich].signal; + if((*imod).roc == roc && (*imod).slot == slot) { + (*imod).clist.push_back(Achan); + } + } + if(imod == mlist.end()) { + Amod.roc = roc; + Amod.slot = slot; + Amod.clist.clear(); + Amod.clist.push_back(Achan); + mlist.push_back(Amod); + } + } + } + if(mlist.size() <= 0) { + return(-1); + } + Functor f; + for(imod=mlist.begin(); imod!= mlist.end(); ++imod) { + list<ChaninMod> *clistp = &((*imod).clist); + clistp->sort(f);//Sort by channel + } + + return(0); } void THcDetectorMap::Load(const char *fname) @@ -60,6 +119,8 @@ void THcDetectorMap::Load(const char *fname) Int_t detector=0; Int_t slot=0; + fNchans = 0; + string::size_type start, pos=0; char varname[100]; @@ -126,7 +187,16 @@ void THcDetectorMap::Load(const char *fname) signal= ((TObjString*)vararr->At(3))->GetString().Atoi(); } cout << channel << " " << plane << " " << counter << " " << signal << endl; - + + fTable[fNchans].roc=roc; + fTable[fNchans].roc=slot; + fTable[fNchans].channel=channel; + fTable[fNchans].did=detector; + fTable[fNchans].plane=plane; + fTable[fNchans].counter=counter; + fTable[fNchans].signal=signal; + + fNchans++; } } diff --git a/src/THcDetectorMap.h b/src/THcDetectorMap.h index 9d1b8c2..02c59c6 100644 --- a/src/THcDetectorMap.h +++ b/src/THcDetectorMap.h @@ -8,23 +8,46 @@ ////////////////////////////////////////////////////////////////////////// #include "TObject.h" +#include "THaDetMap.h" +#include <list> class THcDetectorMap : public TObject { public: - THcDetectorMap() {} - virtual ~THcDetectorMap() {} + THcDetectorMap(); + virtual ~THcDetectorMap(); virtual void Load(const char *fname); - - // Member variables needed - // List of detector IDs. - // Hardware to logical detector mapping for each detector - // Mapping between detector names and numbers - // Hardwire, but later configure - struct Detector { - UInt_t did; // Numberical Detector ID - TList* + virtual Int_t FillMap(THaDetMap* detmap, const char* detectorname); + + Int_t fNchans; // Number of hardware channels + + struct Channel { // Mapping for one hardware channel + Int_t roc; + Int_t slot; + Int_t channel; + Int_t did; + Int_t plane; + Int_t counter; + Int_t signal; + }; + Channel fTable[10000]; // Big ugly cache of the map file + + struct ChaninMod { + Int_t channel; + Int_t plane; + Int_t counter; + Int_t signal; + }; + struct ModChanList { + Int_t roc; + Int_t slot; + std::list<ChaninMod> clist; + + }; + std::list<ModChanList> mlist; + + bool compare(const ChaninMod *first, const ChaninMod *second); protected: diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 074c900..221dab6 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -53,6 +53,7 @@ THcHodoscope::THcHodoscope( ) : //_____________________________________________________________________________ THaAnalysisObject::EStatus THcHodoscope::Init( const TDatime& date ) { + static const char* const here = "Init()"; // Extra initialization for scintillators: set up DataDest map if( THaNonTrackingDetector::Init( date ) ) -- GitLab