diff --git a/src/HallC_LinkDef.h b/src/HallC_LinkDef.h index e0ceea5f38f10322fbb8163b9079858f0e0c4b9d..7a5e99db8d6d02eb19039c5cacb0f73c088530e3 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 710c5d282e9b072c65f0bbe7b9aac55f9ba1dabf..76141676e1013d2d67829d58333ee7282faccae4 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 9d1b8c2d70913b52cea0fb884505604504f45329..02c59c650a3b8134bd7ef58a4554404b5bad3345 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 074c90010537dbf26c0bc25504bae7f548c70671..221dab60bccb6f0a166106a30d8732f44a1cffab 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 ) )