24 inline static
bool IsComment( const
string& s,
string::size_type
pos )
26 return ( pos != string::npos && pos < s.length() &&
61 list<ModChanList>::iterator imod;
62 list<ChaninMod>::iterator ichan;
71 if(strcasecmp(detectorname,
fIDMap[i].
name) == 0) {
77 cout <<
"FillMap Error: No detector ID registered for " << detectorname << endl;
78 cout <<
" Using detector id of 0" << endl;
85 if(
fTable[ich].did == did) {
97 for(imod=
mlist.begin(); imod!=
mlist.end(); ++imod) {
98 if((*imod).roc == roc && (*imod).slot == slot) {
101 (*imod).clist.push_back(Achan);
105 if(imod ==
mlist.end()) {
110 Amod.
clist.push_back(Achan);
111 mlist.push_back(Amod);
122 for(imod=
mlist.begin(); imod!=
mlist.end(); ++imod) {
124 list<ChaninMod> *clistp = &((*imod).clist);
130 for(imod=
mlist.begin(); imod!=
mlist.end(); ++imod) {
135 list<ChaninMod> *clistp = &((*imod).clist);
136 Int_t first_chan = -1;
137 Int_t last_chan = -1;
138 Int_t last_plane = -1;
139 Int_t last_signal = -1;
140 Int_t first_counter = -1;
141 Int_t last_counter = -1;
142 Int_t last_refchan = -1;
143 Int_t last_refindex = -1;
144 for(ichan=clistp->begin(); ichan!=clistp->end(); ++ichan) {
145 Int_t this_chan = (*ichan).channel;
146 Int_t this_counter = (*ichan).counter;
147 Int_t this_signal = (*ichan).signal;
148 Int_t this_plane = (*ichan).plane;
149 Int_t this_refchan = (*ichan).refchan;
150 Int_t this_refindex = (*ichan).refindex;
151 if(last_chan+1!=this_chan || last_counter+1 != this_counter
152 || last_plane != this_plane || last_signal!=this_signal
153 || last_refchan != this_refchan || last_refindex != this_refindex) {
155 if(ichan != clistp->begin()) {
160 (
UInt_t) first_counter, model, (
Int_t) last_refindex,
164 first_chan = this_chan;
165 first_counter = this_counter;
167 last_chan = this_chan;
168 last_refchan = this_refchan;
169 last_refindex = this_refindex;
170 last_counter = this_counter;
171 last_plane = this_plane;
172 last_signal = this_signal;
178 (
UInt_t) first_counter, model, (
Int_t) last_refindex,
247 static const char*
const whtspc =
" \t";
252 if(!ifile.is_open()) {
253 static const char*
const here =
"THcDetectorMap::Load";
254 Error(here,
"error opening detector map file %s",fname);
271 string::size_type start,
pos=0;
275 while(getline(ifile,line)) {
277 if(line.empty())
continue;
278 if((start = line.find_first_not_of( whtspc )) == string::npos)
continue;
281 while((pos=line.find_first_of(whtspc)) != string::npos) {
285 if(! ((pos=line.find(
"_ID=")) == string::npos)) {
286 string::size_type llen = line.length();
292 if(isdigit(line.at(pos))) {
298 fIDMap[
fNIDs++].
id = atoi(line.substr(start,pos-start).c_str());
306 while ((pos = line.find_first_of(
"!", pos+1)) != string::npos) {
314 while((pos=line.find_first_of(whtspc)) != string::npos) {
324 if((pos=line.find_first_of(
"=")) != string::npos) {
325 strcpy(varname, (line.substr(0,pos)).c_str());
326 size_t valuestartpos = pos+1;
327 size_t commapos = line.find_first_of(
",");
330 if(commapos != string::npos) {
333 value = atoi(line.substr(valuestartpos,commapos-valuestartpos).c_str());
334 value2 = atoi(line.substr(commapos+1).c_str());
336 value = atoi(line.substr(valuestartpos).c_str());
339 if(strcasecmp(varname,
"detector")==0) {
343 }
else if (strcasecmp(varname,
"roc")==0) {
347 }
else if (strcasecmp(varname,
"nsubadd")==0) {
349 }
else if (strcasecmp(varname,
"mask")==0) {
351 }
else if (strcasecmp(varname,
"bsub")==0) {
353 }
else if (strcasecmp(varname,
"slot")==0) {
357 }
else if (strcasecmp(varname,
"refchan")==0) {
359 }
else if (strcasecmp(varname,
"refindex")==0) {
364 }
else if (nsubadd == 64) {
367 }
else if(bsub == 17) {
377 TObjArray *vararr = values.Tokenize(
",");
379 if(nvals<3 || nvals>4) {
381 cout <<
"Map file: Invalid value count: " << line << endl;
390 signal= ((
TObjString*)vararr->At(3))->GetString().Atoi();
408 cout << endl <<
" Detector ID Map" << endl << endl;
virtual Int_t FillMap(THaDetMap *detmap, const char *detectorname)
std::list< ChaninMod > clist
bool operator()(const THcDetectorMap::ChaninMod &first, const THcDetectorMap::ChaninMod &second)
Class to read and hold a Hall C style detector map.
virtual void Error(const char *method, const char *msgfmt,...) const
std::list< ModChanList > mlist
virtual ~THcDetectorMap()
static bool IsComment(const string &s, string::size_type pos)
virtual void Load(const char *fname)
ClassImp(THcDetectorMap) inline static bool IsComment(const string &s
bool compare(const ChaninMod *first, const ChaninMod *second)