10 #include "cstructs/eemcConstDB.hh"
12 #include "EEmcDbItem.h"
16 EEmcDbItem::EEmcDbItem() {
22 bool EEmcDbItem::isEmpty()
const{
28 bool EEmcDbItem::isTower()
const{
29 if (isEmpty())
return false;
30 return (
name[2]==
'T');
36 void EEmcDbItem::print()
const{
37 LOG_INFO<<
"EEmcDbItem::print() "<<endm;
40 LOG_WARN<<
" item not defined ???"<<endm;
44 LOG_INFO<<Form(
"EEmcDbItem::SMD %s crate=%d chan=%3d sec=%2d plane=%c strip=%3d gain=%.3f ped=%.2f sPed=%.2f ADC_thr=%.2f stat=0x%4.4x fail=0x%4.4x pix=%s key=%d\n",
name,crate,
chan,sec,plane,strip,gain,ped,sigPed,thr,stat,fail,
tube,key)<<endm;
46 LOG_INFO<<Form(
"EEmcDbItem::Tail %s crate=%d chan=%3d sec=%2d sub=%c eta=%2d gain=%.3f ped=%.2f sPed=%.2f ADC_thr=%.2f stat=0x%4.4x fail=0x%4.4x tube=%s key=%d\n",
name,crate,
chan,sec,sub,eta,gain,ped,sigPed,thr,stat,fail,
tube,key)<<endm;
53 EEmcDbItem::print( ostream &out )
const
55 out <<
"EEmcDbItem: ";
57 out <<
"item not defined";
60 out << Form(
"%s crate=%d chan=%3d sec=%2d plane=%c strip=%3d gain=%.3f ped=%.2f sPed=%.2f ADC_thr=%.2f stat=0x%4.4x fail=0x%4.4x pix=%s key=%d\n",
name,crate,
chan,sec,plane,strip,gain,ped,sigPed,thr,stat,fail,
tube,key);
63 out << Form(
" %s crate=%d chan=%3d sec=%2d sub=%c eta=%2d gain=%.3f ped=%.2f sPed=%.2f ADC_thr=%.2f stat=0x%4.4x fail=0x%4.4x tube=%s key=%d\n",
name,crate,
chan,sec,sub,eta,gain,ped,sigPed,thr,stat,fail,
tube,key);
70 ostream &operator<<(ostream &out,
const EEmcDbItem &item )
72 return item.print(out);
77 void EEmcDbItem::exportAscii(FILE *fd)
const{
79 if(
name[0]==0)
return;
81 if(strchr(
name,
'U') || strchr(
name,
'V') ) {
82 fprintf(fd,
"%s %3d %3d %2d %c %4d %.3f %.2f %.2f 0x%4.4x 0x%4.4x %s %d\n",
name,crate,
chan,sec,plane,strip,gain,ped,thr,stat,fail,
tube,key);
84 fprintf(fd,
"%s %d %3d %2d %c %2d %.3f %.2f %.2f 0x%4.4x 0x%4.4x %s %d\n",
name,crate,
chan,sec,sub,eta,gain,ped,thr,stat,fail,
tube,key);
92 int EEmcDbItem::importAscii(FILE *fd){
104 char * ret=fgets(buf,mx,fd);
108 if(buf[0]==
'#')
return 1;
111 int ret1=sscanf(buf,
"%s",name0);
114 if(ret1==0)
return -1;
118 if(name0[2]==
'U' || name0[2]==
'V') {
119 n=sscanf(buf,
"%s %d %d %d %c %d %f %f %f %x %x %s %d",
name,&crate,&
chan,&sec,&plane,&strip,&gain,&ped,&thr,&stat,&fail,
tube,&key);
121 else if (name0[2]==
'T' || name0[2]==
'P' || name0[2]==
'Q' || name0[2]==
'R' ) {
122 n=sscanf(buf,
"%s %d %d %d %c %d %f %f %f %x %x %s %d",
name,&crate,&
chan,&sec,&sub,&eta,&gain,&ped,&thr,&stat,&fail,
tube,&key);
129 if(n!=13)
return -1000-n;
137 void EEmcDbItem::clear() {
158 EEmcDbItem::mapmtId()
const{
159 if(isTower())
return 0;
160 if(chan<0 || chan>=192)
return 0;
162 int tubeID=(iTube<=5) ? 2*iTube+1 :14- 2*(iTube-5);
169 void EEmcDbItem::setDefaultTube(
int cr_off) {
170 if(
name[2]==
'T')
return;
172 int ch2pix[16]={13, 14, 15, 16, 9, 10, 11, 12, 5, 6, 7, 8, 1,2,3,4};
174 int iCrate=crate-cr_off;
176 int tubeID=mapmtId();
179 int secID=1 + ((iCrate/4)+11)%12;
184 int pixID=ch2pix[iPix];
185 char text[100], boxName[100];
186 sprintf(boxName,
"S%d",iBox+1);
187 if (iBox==3)sprintf(boxName,
"P1");
188 sprintf(text,
"%2.2d%2s-%2.2d:%2.2d%c",secID,boxName,tubeID,pixID,EEMCDbStringDelim);
193 void EEmcDbItem::setTube(
char *text) {
194 strncpy(
tube,text,StEEmcNameLen-1);
197 for(i=0;i<StEEmcNameLen;i++) {
198 if(
tube[i]==EEMCDbStringDelim) {
203 LOG_WARN<<Form(
"Error in EEmcDbItem::setTube(%s), no terminating '%c'\n",text,EEMCDbStringDelim)<<endm;
209 void EEmcDbItem::setName(
char *text) {
210 strncpy(
name,text,StEEmcNameLen-1);
222 for(i=0;i<StEEmcNameLen;i++) {
223 if(
name[i]==EEMCDbStringDelim) {
228 LOG_WARN<<Form(
"Error in EEmcDbItem::setName(%s), no terminating '%c'\n",text,EEMCDbStringDelim)<<endm;
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
char tube[StEEmcNameLen]
name of PMT or MAPMT pixel