23 #ifndef GW_EGCONVERTER_H
35 #ifndef ROOT_TSystemDirectory
36 #include <TSystemDirectory.h>
39 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,15,0)
54 fStreamIN.clear();
fCycle =
'_';
82 void EGConverter::PrintHeader()
const
84 cout <<
"magic number : " << fHeader.magic_number <<
endl;
85 cout <<
"spectrum name : " << fHeader.spectrum_name <<
endl;
86 cout <<
"creation date : " << fHeader.creation_date <<
endl;
87 cout <<
"modifi. date : " << fHeader.modification_date <<
endl;
88 cout <<
"fold : " << fHeader.fold <<
endl;
89 cout <<
"size : " << fHeader.count_free_space <<
endl;
92 for(i=0; i < fHeader.fold; i++){
93 printf(
"dim %d : init = %4d range = %4d \n",
94 (
int)i,(
int)fHeader.base_info[i],(
int)fHeader.range[i]);
97 printf(
"layout = %1d type = %1d pointer %d \n",
98 (
int)fHeader.data_array_descriptor1[0],
99 (
int)fHeader.data_array_descriptor1[1],
100 (
int)fHeader.data_array_descriptor1[4]);
149 void EGConverter::InitHeader(
int dimx,
int dimy, HeaderEG &header,
const char *name,
int type)
155 header.magic_number = 0x189c5e39;
156 header.magic_number =
ULong((
char*)&header.magic_number);
158 header.version =
ULong((
char*)&header.version);
159 strncpy(header.spectrum_name,name,31);
160 header.spectrum_name[31] = 0;
167 header.fold =
ULong((
char*)&header.fold);
170 strcpy(str, ctime(&cl));
172 header.creation_date[0] = header.modification_date[0] =
'0';
174 header.creation_date[0] = header.modification_date[0] = str[8];
175 header.creation_date[1] = header.modification_date[1] = str[9];
176 header.creation_date[2] = header.modification_date[2] =
'-';
177 for (i = 3; i < 6; ++i)
178 header.creation_date[i] = header.modification_date[i] = str[i+1];
179 header.creation_date[6] = header.modification_date[6] =
'-';
180 for (i = 7; i < 11; ++i)
181 header.creation_date[i] = header.modification_date[i] = str[i+13];
182 header.creation_date[11] = header.modification_date[11] =
' ';
183 for (i = 12; i < 20; ++i)
184 header.creation_date[i] = header.modification_date[i] = str[i-1];
187 header.base_info[i] = 0xFFFFFFFF;
188 header.base_info[i] =
ULong((
char*)&header.base_info[i]);
189 header.range[i] = 0xFFFFFFFF;
190 header.range[i] =
ULong((
char*)&header.range[i]);
195 header.base_info[0] = 0;
196 header.base_info[0] =
ULong((
char*)&header.base_info[0]);
197 header.range[0] = dimx;
198 header.range[0] =
ULong((
char*)&header.range[0]);
201 header.base_info[0] = 0;
202 header.base_info[0] =
ULong((
char*)&header.base_info[0]);
203 header.range[0] = dimx;
204 header.range[0] =
ULong((
char*)&header.range[0]);
205 header.base_info[1] = 0;
206 header.base_info[1] =
ULong((
char*)&header.base_info[1]);
207 header.range[1] = dimy;
208 header.range[1] =
ULong((
char*)&header.range[1]);
212 header.fip[i] = 0xFFFFFFFF;
216 header.fip[i] =
ULong((
char*)&header.fip[i]);
219 header.anotation_pointer[i] = -1;
220 header.anotation_pointer[i] =
Long((
char*)&header.anotation_pointer[i]);
221 header.calibration_pointer[i] = -1;
222 header.calibration_pointer[i] =
Long((
char*)&header.calibration_pointer[i]);
223 header.efficiency_pointer[i] = -1;
224 header.efficiency_pointer[i] =
Long((
char*)&header.efficiency_pointer[i]);
227 header.data_array_descriptor1[0] = 0;
228 header.data_array_descriptor1[0] =
ULong((
char*)&header.data_array_descriptor1[0]);
229 header.data_array_descriptor1[1] = type;
230 header.data_array_descriptor1[1] =
ULong((
char*)&header.data_array_descriptor1[1]);
231 header.data_array_descriptor2[1] = type;
232 header.data_array_descriptor2[1] =
ULong((
char*)&header.data_array_descriptor2[1]);
233 header.data_array_descriptor2[4] = 0xFFFFFFFF;
234 header.data_array_descriptor2[4] =
ULong((
char*)&header.data_array_descriptor2[5]);
239 header.count_free_space = dimx*dimy;
240 header.top_count_space = dimx*dimy -1;
241 header.base_address_string_space = dimx*dimy + 512;
245 header.count_free_space = dimx*dimy*2;
246 header.top_count_space = dimx*dimy*2 -1;
247 header.base_address_string_space = dimx*dimy*2 + 512;
252 header.count_free_space = dimx*dimy*4;
253 header.top_count_space = dimx*dimy*4 -1;
254 header.base_address_string_space = dimx*dimy*4 + 512;
258 header.count_free_space =
ULong((
char*)&header.count_free_space);
259 header.top_count_space =
ULong((
char*)&header.top_count_space);
260 header.base_address_string_space =
Long((
char*)&header.base_address_string_space);
262 header.base_address_count_space = 512;
263 header.base_address_count_space =
ULong((
char*)&header.base_address_count_space);
264 header.top_string_space = 1023;
265 header.top_string_space =
ULong((
char*)&header.top_string_space);
266 header.string_free_space = 256;
267 header.string_free_space =
Long((
char*)&header.string_free_space);
272 void EGConverter::ReadHeader(
char *buffer, HeaderEG &header)
278 header.magic_number =
ULong(buffer+offset);
281 header.version =
ULong(buffer+offset);
284 for ( i = 0; i < 32; i++ )
285 header.spectrum_name[i] = buffer[offset+i];
288 header.fold =
ULong(buffer+offset);
291 for ( i = 0; i < 20; i++ )
292 header.creation_date[i] = buffer[offset+i];
295 for ( i = 0; i < 20; i++ )
296 header.modification_date[i] = buffer[offset+i];
299 for ( i = 0; i < 8; i++ )
300 header.base_info[i] =
ULong(buffer+offset+
sizeof(
unsigned long)*i);
303 for ( i = 0; i < 8; i++ )
304 header.range[i] =
ULong(buffer+offset+
sizeof(
unsigned long)*i);
307 for ( i = 0; i < 32; i++ )
308 header.fip[i] =
ULong(buffer+offset+
sizeof(
unsigned long)*i);
311 for ( i = 0; i < 8; i++ )
312 header.anotation_pointer[i] =
Int(buffer+offset+
sizeof(
int)*i);
315 for ( i = 0; i < 8; i++ )
316 header.calibration_pointer[i] =
Int(buffer+offset+
sizeof(
int)*i);
319 for ( i = 0; i < 8; i++ )
320 header.efficiency_pointer[i] =
Int(buffer+offset+
sizeof(
int)*i);
323 for ( i = 0; i < 5; i++ )
324 header.data_array_descriptor1[i] =
ULong(buffer+offset+
sizeof(
unsigned long)*i);
327 for ( i = 0; i < 5; i++ )
328 header.data_array_descriptor2[i] =
ULong(buffer+offset+
sizeof(
unsigned long)*i);
331 header.base_address_string_space =
Int(buffer+offset);
334 header.string_free_space =
Int(buffer+offset);
337 header.top_string_space =
ULong(buffer+offset);
340 header.base_address_count_space =
ULong(buffer+offset);
343 header.count_free_space =
ULong(buffer+offset);
346 header.top_count_space =
ULong(buffer+offset);
349 for ( i = 0; i < 20; i++ )
350 header.unused[i] =
ULong(buffer+offset+i*
sizeof(
unsigned long));
356 bool EGConverter::OpenEG(
const char *basename)
358 TString filename =
fName.Data(); filename += basename;
365 fStreamIN.open(filename.Data()); fStreamIN.clear();
366 if ( ! fStreamIN.is_open() ){
369 Form(
"Cannot open file %s",filename.Data()));
375 fStreamIN.read(buffer,512);
376 if ( ! fStreamIN.good() ) {
379 Form(
"Cannot read EG header in %s",filename.Data()));
380 fStreamIN.close();
return false;
384 unsigned long magic =
ULong(buffer);
385 if ( magic != 0x189c5e39 && magic != 0x395e9c18 ) {
387 Form(
"[EGConverter::OpenEG] %s is not an eg file",filename.Data()));
388 fStreamIN.close();
return false;
393 ReadHeader(buffer,fHeader);
return true;
397 bool EGConverter::IsEG(
const char *basename, Option_t *o)
const
399 TString filename =
fName.Data(), option = o; filename += basename;
406 file.open(filename.Data());
407 if ( ! file.is_open() ){
416 char buffer[512]; file.read(buffer,512);
417 if ( !file.good() ) {
422 file.close();
return false;
426 unsigned long *magic = (
unsigned long*)buffer, *fold = (
unsigned long*)(buffer+40);
427 if ( magic[0] != 0x189c5e39 && magic[0] != 0x395e9c18 ) {
432 file.close();
return false;
435 if ( magic[0] == 0x189c5e39 ) {
436 if ( option.Contains(
"1D") && (*fold) != 1 ) ok =
false;
437 if ( option.Contains(
"2D") && (*fold) != 2 ) ok =
false;
440 if ( option.Contains(
"1D") && (*fold) != 0x01000000 ) ok =
false;
441 if ( option.Contains(
"2D") && (*fold) != 0x02000000 ) ok =
false;
444 file.close();
return ok;
450 HistoConverter::ls(o);
451 TSystemDirectory dir; dir.SetDirectory(
fName.Data()); TList *list = dir.GetListOfFiles();
453 TIter iter(list); TObject *entry;
int count = 0;
454 while ( (entry = iter()) ) {
456 if ( IsEG(entry->GetName()) ) {
457 cout <<
" [" << count++ <<
"] " << entry->GetName() ;
459 if ( (count+1) % 5 == 0 ) cout <<
endl;
464 cout <<
endl;
if ( list )
delete list;
471 TSystemDirectory dir; dir.SetDirectory(
fName.Data()); TList *list = dir.GetListOfFiles();
473 TIter iter(list); TObject *entry;
int count = 0; TString result =
"_EMPTY_";
474 while ( (entry = iter()) ) {
475 if ( IsEG(entry->GetName()) ) {
476 if ( which == count ) result = entry->GetName(); count++;
479 if ( list )
delete list;
481 if ( result !=
"_EMPTY_" )
return Get(result.Data());
485 Form(
"Cannot find entry # %d",which));
496 if ( IsEG(name,
"1D") ) {
497 TH1F *h =
new TH1F();
500 if ( !
Read((*h)) ) {
delete h; h = NULL; }
504 if ( IsEG(name,
"2D") ) {
505 TH2F *h =
new TH2F();
508 if ( !
Read((*h)) ) {
delete h; h = NULL; }
519 if ( IsEG(h.GetName(),
"1D") ==
false ) {
522 Form(
"%s is not an EG 1D file",h.GetName()));
531 if ( gDebug > 0 ) PrintHeader();
533 char *buffer =
new char[fHeader.count_free_space];
536 fStreamIN.seekg(fHeader.base_address_count_space,ios::beg); fStreamIN.read(buffer,fHeader.count_free_space);
537 if ( fStreamIN.fail() ) {
540 Form(
"Cannot read array in the EG file %s",h.GetName()));
550 switch(fHeader.data_array_descriptor1[1]){
553 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
554 <<
" does not match EG array type 8 bit unsigned integer " <<
nline;
555 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
557 h.SetBins(fHeader.count_free_space,fHeader.base_info[0],fHeader.count_free_space);
558 for (i = 0; i < fHeader.count_free_space; i++)
562 if ( ! h.InheritsFrom(
"TH1C") ) {
564 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
565 <<
" does not match EG array type 8 bit signed integer " <<
nline;
566 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
568 h.SetBins(fHeader.count_free_space,fHeader.base_info[0],fHeader.count_free_space);
569 for (i = 0; i < fHeader.count_free_space; i++)
574 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
575 <<
" does not match EG array type 16 bit unsigned integer " <<
nline;
576 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
577 h.SetBins(fHeader.count_free_space/2,fHeader.base_info[0],fHeader.count_free_space/2);
578 for (i = 0; i < fHeader.count_free_space/2; i++)
579 h.Fill(i,
UShort(buffer+2*i));
582 if ( ! h.InheritsFrom(
"TH1S") ) {
584 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
585 <<
" does not match EG array type 16 bit signed integer " <<
nline;
586 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
588 h.SetBins(fHeader.count_free_space/2,fHeader.base_info[0],fHeader.count_free_space/2);
589 for (i = 0; i < fHeader.count_free_space/2; i++)
590 h.Fill(i,
Short(buffer+2*i));
594 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
595 <<
" does not match EG array type 32 bit unsigned integer " <<
nline;
596 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
597 h.SetBins(fHeader.count_free_space/4,fHeader.base_info[0],fHeader.count_free_space/4);
598 for (i = 0; i < fHeader.count_free_space/4; i++)
599 h.Fill(i,
UInt(buffer+4*i));
602 if ( ! h.InheritsFrom(
"TH1I") ) {
604 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
605 <<
" does not match EG array type 32 bit signed integer " <<
nline;
606 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
608 h.SetBins(fHeader.count_free_space/4,fHeader.base_info[0],fHeader.count_free_space/4);
609 for (i = 0; i < fHeader.count_free_space/4; i++)
610 h.Fill(i,
Int(buffer+4*i));
613 if ( ! h.InheritsFrom(
"TH1F") ) {
615 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
616 <<
" does not match EG array type 32 bit floating point " <<
nline ;
617 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
619 h.SetBins(fHeader.count_free_space/4,fHeader.base_info[0],fHeader.count_free_space/4);
620 for (i = 0; i < fHeader.count_free_space/4; i++)
621 h.Fill(i,
Float(buffer+4*i));
625 << fHeader.data_array_descriptor1[1] <<
" ! " <<
nline;
644 char string_end[1024];
646 #if defined(R__BYTESWAP)
651 if ( h.InheritsFrom(
"TH1C") )
655 if ( h.InheritsFrom(
"TH1S") )
659 if ( h.InheritsFrom(
"TH1I") )
663 if ( h.InheritsFrom(
"TH1F") )
666 if ( h.InheritsFrom(
"TH1D") ){
668 fLog <<
warning <<
"ROOT histogram type " << h.ClassName()
669 <<
" writen as float EG spectrum " <<
nline;
673 hname = h.GetName(); hname.ReplaceAll(
" ",
"");
675 InitHeader(h.GetNbinsX(), 1, fHeader, hname, type);
677 file_id = open(hname,O_WRONLY | O_CREAT, 0644);
681 Form(
"Error writing %s file",h.GetName()));
684 lseek(file_id, 0, SEEK_SET);
685 if (write(file_id, (
void *)&(fHeader), 512) != 512) {
688 Form(
"Error writing %s file",h.GetName()));
696 specc =
new char[h.GetNbinsX()];
697 for (i=0; i<h.GetNbinsX(); i++){
698 tmp = h.GetBinContent(i+1);
699 specc[i] = (char)tmp;
701 if (write(file_id, (
void *) specc, h.GetNbinsX()) != h.GetNbinsX())
706 specs =
new short[h.GetNbinsX()];
707 for (i=0; i<h.GetNbinsX(); i++){
708 tmp = h.GetBinContent(i+1);
709 specs[i] =
Short((
char*)&tmp);
711 if (write(file_id, (
void *) specs, h.GetNbinsX()*2) != h.GetNbinsX()*2)
716 speci =
new int[h.GetNbinsX()];
717 for (i=0; i<h.GetNbinsX(); i++){
718 tmp = h.GetBinContent(i+1);
719 speci[i] =
Int((
char*)&tmp);
721 if (write(file_id, (
void *) speci, h.GetNbinsX()*4) != h.GetNbinsX()*4)
726 specf =
new float[h.GetNbinsX()];
727 for (i=0; i<h.GetNbinsX(); i++){
728 tmp = h.GetBinContent(i+1);
729 specf[i] =
Float((
char*)&tmp);
731 if (write(file_id, (
void *) specf, h.GetNbinsX()*4) != h.GetNbinsX()*4)
740 Form(
"Error writing %s file",h.GetName()));
744 for(i=0; i<1024; i++)
747 strcpy(&string_end[4],
"Gammaware Spectrum");
748 string_end[3] = strlen(
"Gammaware Spectrum");
750 if (write(file_id, (
void *) string_end, 1024) != 1024) {
753 Form(
"Error writing %s file",h.GetName()));
767 if ( IsEG(h.GetName(),
"2D") ==
false ) {
770 Form(
"%s is not an EG 2D file",h.GetName()));
779 if ( gDebug > 0 ) PrintHeader();
781 char *buffer =
new char[fHeader.count_free_space];
784 fStreamIN.seekg(fHeader.base_address_count_space,ios::beg); fStreamIN.read(buffer,fHeader.count_free_space);
785 if ( fStreamIN.fail() ) {
787 Form(
"Cannot read array in the EG file %s",h.GetName()));
788 CloseEG();
delete buffer;
return false;
792 unsigned long i,j; Int_t cursor = 0;
795 switch(fHeader.data_array_descriptor1[1]) {
798 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
799 <<
" does not match EG array type 8 bit unsigned integer " <<
nline;
800 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
802 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
803 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
805 if ( fHeader.data_array_descriptor1[0] == 0 ) {
806 for (i = 0; i < fHeader.range[0]; i++)
807 for (j = 0; j < fHeader.range[1]; j++)
808 h.Fill(i,j,buffer[cursor++]);
811 for (i = 0; i < fHeader.range[0]; i++)
812 for (j = i; j < fHeader.range[1]; j++) {
814 h.Fill(i,j,buffer[cursor++]);
816 h.Fill(i,j,buffer[cursor]); h.Fill(j,i,buffer[cursor++]);
821 if ( ! h.InheritsFrom(
"TH2C") ) {
823 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
824 <<
" does not match EG array type 8 bit signed integer " <<
nline ;
825 fLog <<
" ---> there might be some problems during the convertion " <<
nline ;
827 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
828 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
830 if ( fHeader.data_array_descriptor1[0] == 0 ) {
831 for (i = 0; i < fHeader.range[0]; i++)
832 for (j = 0; j < fHeader.range[1]; j++)
833 h.Fill(i,j,buffer[cursor++]);
836 for (i = 0; i < fHeader.range[0]; i++)
837 for (j = i; j < fHeader.range[1]; j++) {
839 h.Fill(i,j,buffer[cursor++]);
841 h.Fill(i,j,buffer[cursor]); h.Fill(j,i,buffer[cursor++]);
847 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
848 <<
" does not match EG array type 16 bit unsigned integer " <<
nline ;
849 fLog <<
" ---> there might be some problems during the convertion " <<
nline ;
851 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
852 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
854 if ( fHeader.data_array_descriptor1[0] == 0 ) {
855 for (i = 0; i < fHeader.range[0]; i++)
856 for (j = 0; j < fHeader.range[1]; j++)
857 { h.Fill(i,j,
UShort(buffer+cursor)); cursor += 2; }
860 for (i = 0; i < fHeader.range[0]; i++)
861 for (j = i; j < fHeader.range[1]; j++) {
863 h.Fill(i,j,
UShort(buffer+cursor));
866 UShort_t v =
UShort(buffer+cursor);
867 h.Fill(i,j,v); h.Fill(j,i,v);
874 if ( ! h.InheritsFrom(
"TH2S") ) {
876 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
877 <<
" does not match EG array type 16 bit signed integer " <<
nline ;
878 fLog <<
" ---> there might be some problems during the convertion " <<
nline ;
881 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
882 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
884 if ( fHeader.data_array_descriptor1[0] == 0 ) {
885 for (i = 0; i < fHeader.range[0]; i++)
886 for (j = 0; j < fHeader.range[1]; j++)
887 { h.Fill(i,j,
Short(buffer+cursor)); cursor += 2; }
890 for (i = 0; i < fHeader.range[0]; i++)
891 for (j = i; j < fHeader.range[1]; j++) {
893 h.Fill(i,j,
Short(buffer+cursor));
896 Short_t v =
Short(buffer+cursor);
897 h.Fill(i,j,v); h.Fill(j,i,v);
905 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
906 <<
" does not match EG array type 32 bit unsigned integer " <<
nline ;
907 fLog <<
" ---> there might be some problems during the convertion " <<
nline ;
909 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
910 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
912 if ( fHeader.data_array_descriptor1[0] == 0 ) {
913 for (i = 0; i < fHeader.range[0]; i++)
914 for (j = 0; j < fHeader.range[1]; j++)
915 { h.Fill(i,j,
UInt(buffer+cursor)); cursor += 4; }
918 for (i = 0; i < fHeader.range[0]; i++)
919 for (j = i; j < fHeader.range[1]; j++) {
921 h.Fill(i,j,
UInt(buffer+cursor));
924 UInt_t v =
UInt(buffer+cursor);
925 h.Fill(i,j,v); h.Fill(j,i,v);
932 if ( ! h.InheritsFrom(
"TH2I") ) {
934 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
935 <<
" does not match EG array type 32 bit signed integer " <<
nline;
936 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
939 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
940 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
942 if ( fHeader.data_array_descriptor1[0] == 0 ) {
943 for (i = 0; i < fHeader.range[0]; i++)
944 for (j = 0; j < fHeader.range[1]; j++)
945 { h.Fill(i,j,
Int(buffer+cursor)); cursor += 4; }
948 for (i = 0; i < fHeader.range[0]; i++)
949 for (j = i; j < fHeader.range[1]; j++) {
951 h.Fill(i,j,
Int(buffer+cursor));
954 Int_t v =
Int(buffer+cursor);
955 h.Fill(i,j,v); h.Fill(j,i,v);
962 if ( ! h.InheritsFrom(
"TH2F") ) {
964 fLog <<
" Warning in [EGConverter::Read]: ROOT histogram type " << h.ClassName()
965 <<
" does not match EG array type 32 bit floating point " <<
nline;
966 fLog <<
" ---> there might be some problems during the convertion " <<
nline;
968 h.SetBins(fHeader.range[0],fHeader.base_info[0],fHeader.range[0],
969 fHeader.range[1],fHeader.base_info[1],fHeader.range[1]);
971 if ( fHeader.data_array_descriptor1[0] == 0 ) {
972 for (i = 0; i < fHeader.range[0]; i++)
973 for (j = 0; j < fHeader.range[1]; j++)
974 { h.Fill(i,j,
Float(buffer+cursor)); cursor += 4; }
977 for (i = 0; i < fHeader.range[0]; i++)
978 for (j = i; j < fHeader.range[1]; j++) {
980 h.Fill(i,j,
Float(buffer+cursor));
983 Float_t v =
Float(buffer+cursor);
984 h.Fill(i,j,v); h.Fill(j,i,v);
991 fLog <<
"Unknown type "
992 << fHeader.data_array_descriptor1[1] <<
" ! " <<
nline ;
994 delete buffer;
return true;
1001 SetError(HistoConverter::kFail,
"NO IMPLEMENTATION !!");
1008 TString hsname = hs.GetName();
1011 hsname.ReplaceAll(
" ",
"");
1014 Bool_t wildcard =
false;
1015 if ( hsname.Contains(
"*") )
1017 TRegexp all(
"*",kTRUE), pattern(hsname.Data(),wildcard);
1019 if ( pattern.Status() != TRegexp::kOK ) {
1020 if ( gDebug > 0 ) cerr <<
"pattern [*] intead of " << hsname <<
endl ;
1023 else {
if ( gDebug > 0 ) cerr <<
"pattern " << hsname <<
endl ; }
1026 TSystemDirectory dir; dir.SetDirectory(
fName.Data()); TList *list = dir.GetListOfFiles();
1028 TIter iter(list); TObject *entry;
1029 while ( (entry = iter()) ) {
1030 if ( IsEG(entry->GetName()) ) {
1031 TH1 *h =
Get(entry->GetName());
if ( h ) { hs.Add(h); }
1034 if ( list )
delete list;
1043 SetError(HistoConverter::kFail,
"NO IMPLEMENTATION !!");
virtual void ls(Option_t *) const
to show the spectra in this DB system on the standard output
void SetError(HistoConverter::EStatus status=kGood, const char *msgerror="")
to set/reset the status of this converter
printf("******************************************************************** \n")
virtual HistoConverter * NewDB(const char *) const
to creat a new DB system
LogMessage & error(LogMessage &)
static void AddPrototype(const char *, HistoConverter *)
to add a new type of database service
LogMessage & warning(LogMessage &)
LogMessage & nline(LogMessage &)
virtual bool Read(TH1 &)
to read an histogram
virtual TH1 * Get(int)
to get histo number i in the list
unsigned short UShort(char *buf)
LogMessage & dolog(LogMessage &)
virtual const char * GetType() const
to know what type of HistoConverter system it is
LogMessage & debug(LogMessage &)
virtual std::string & GetProcessName()
To get the Process name.
ADF::LogMessage & endl(ADF::LogMessage &log)
unsigned int UInt(char *buf)
virtual void SetProcessMethod(const char *)
To set the current method.
virtual void CheckDirectory(const char *name)
check if the given directory can be read/written
virtual std::string & GetProcessMethod()
To get the current method.
virtual bool Write(const TH1 &)
to write an histogram
unsigned long ULong(char *buf)