Back Midas Rome Roody Rootana
  Rome Analyzer Framework, Page 6 of 11  Not logged in ELOG logo
ID Dateup Author Topic Subject
  101   07 Oct 2005 Ryu SawadaForumDividing xml the definition xml file.
> I made a patch to enable it with mxml.
> Please test it.
> 
> If it is reliable, I will commit it.
> 
> ----
> cd $ROMESYS
> patch -p0 < mxml.diff  
> ----

I modified bugs, and commited.
Attachment 1: mxml.patch
? mxml.c
? mxml.h
? mxml.patch
? obj
? src/indent.txt
Index: include/mxml.h
===================================================================
RCS file: /usr/local/cvsroot/rome/include/mxml.h,v
retrieving revision 1.7
diff -u -r1.7 mxml.h
--- include/mxml.h	12 Jul 2005 09:04:15 -0000	1.7
+++ include/mxml.h	7 Oct 2005 13:15:53 -0000
@@ -43,6 +43,11 @@
 #define PROCESSING_INSTRUCTION_NODE   3
 #define COMMENT_NODE                  4
 #define DOCUMENT_NODE                 5
+#define ENTITY_NODE                   6
+
+#define INTERNAL_ENTITY               0
+#define EXTERNAL_ENTITY               1
+#define MXML_MAX_ENTITY            1000
 
 typedef struct {
    int  fh;
@@ -115,6 +120,7 @@
 PMXML_NODE mxml_create_root_node();
 PMXML_NODE mxml_parse_file(char *file_name, char *error, int error_size);
 PMXML_NODE mxml_parse_buffer(char *buffer, char *error, int error_size);
+PMXML_NODE mxml_parse_entity(char **buf, char *error, int error_size);
 int mxml_write_tree(char *file_name, PMXML_NODE tree);
 void mxml_debug_tree(PMXML_NODE tree, int level);
 void mxml_free_tree(PMXML_NODE tree);
Index: src/mxml.c
===================================================================
RCS file: /usr/local/cvsroot/rome/src/mxml.c,v
retrieving revision 1.8
diff -u -r1.8 mxml.c
--- src/mxml.c	11 May 2005 12:50:02 -0000	1.8
+++ src/mxml.c	7 Oct 2005 13:15:53 -0000
@@ -1209,6 +1209,30 @@
 
             p += 2;
 
+         } else if (strncmp(p, "!ENTITY", 7) == 0) {
+
+            /* found !ENTITY element */
+            pnew = mxml_add_special_node(ptree, ENTITY_NODE, "ENTYTY", NULL);
+            pv = p + 1;
+
+            p++;
+            if (strstr(p, ">") == NULL)
+               return read_error(HERE, "Unterminated !ENTITY element");
+
+            while (*p != '>') {
+               if (*p == '\n')
+                  line_number++;
+               p++;
+            }
+
+            len = (size_t)p - (size_t)pv;
+            pnew->value = (char *)malloc(len+1);
+            memcpy(pnew->value, pv, len);
+            pnew->value[len] = 0;
+            mxml_decode(pnew->value);
+
+            p ++;
+
          } else {
             
             /* found normal element */
@@ -1407,6 +1431,422 @@
 
 /*------------------------------------------------------------------*/
 
+PMXML_NODE mxml_parse_entity(char **buf, char *error, int error_size)
+/* parse !ENTYTY entries of XML files and replace with references. Return NULL
+   in case of error, return error description. Optional file_name is used
+   for error reporting if called from mxml_parse_file() */
+{
+   char *p;
+   char *pv;
+   char delimiter;
+   int i, j, k, line_number;
+   char *replacement;
+   char entity_name[MXML_MAX_ENTITY][256];
+   char entity_reference_name[MXML_MAX_ENTITY][256];
+   char *entity_value[MXML_MAX_ENTITY];
+   int entity_type[MXML_MAX_ENTITY];    /* internal or external */
+   int nentity;
+   int fh, length, len;
+   char *buffer;
+   PMXML_NODE root = mxml_create_root_node();   /* dummy for 'HERE' */
+   char *file_name = NULL;      /* dummy for 'HERE' */
+   int ip;                      /* counter for entity value */
+
+   for (ip = 0; ip < MXML_MAX_ENTITY; ip++)
+      entity_value[ip] = NULL;
+
+   line_number = 1;
+   nentity = -1;
+
+   /* copy string to temporary space */
+   buffer = (char *) malloc(strlen(*buf) + 1);
+   if (buffer == NULL) {
+      return read_error(HERE, "Cannot allocate memory.");
+   }
+
+   p = buffer;
+
+   strcpy(buffer, *buf);
+   free(*buf);
+
+   /* search !ENTITY */
+   do {
+      if (*p == '<') {
+
+         /* found new entity */
+         p++;
+         while (*p && isspace(*p)) {
+            if (*p == '\n')
+               line_number++;
+            p++;
+         }
+         if (!*p) {
+/*
+            free(buffer);
+            for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+               free(entity_value[ip]);
+*/
+            return read_error(HERE, "Unexpected end of file");
+         }
+
+         if (strncmp(p, "!ENTITY", 7) == 0) {
+
+            /* found entity */
+            nentity++;
+            if (nentity >= MXML_MAX_ENTITY) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Too much entities");
+            }
+
+            pv = p + 7;
+            while (*pv == ' ')
+               pv++;
+
+            /* extract entity name */
+            p = pv;
+
+            while (*p && isspace(*p) && *p != '<' && *p != '>') {
+               if (*p == '\n')
+                  line_number++;
+               p++;
+            }
+            if (!*p) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected end of file");
+            }
+            if (*p == '<' || *p == '>') {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected \'%c\' inside !ENTITY", *p);
+            }
+
+            pv = p;
+            while (*pv && !isspace(*pv) && *pv != '<' && *pv != '>')
+               pv++;
+
+            if (!*pv) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected end of file");
+            }
+            if (*pv == '<' || *pv == '>') {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected \'%c\' inside entity \"%s\"", *pv,
+                                 &entity_name[nentity][1]);
+            }
+
+            len = (size_t) pv - (size_t) p;
+
+            entity_name[nentity][0] = '&';
+            i = 1;
+            entity_name[nentity][i] = 0;
+            while (*p && !isspace(*p) && *p != '/' && *p != '>' && *p != '<' && i < 253)
+               entity_name[nentity][i++] = *p++;
+            entity_name[nentity][i++] = ';';
+            entity_name[nentity][i] = 0;
+
+            if (!*p) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected end of file");
+            }
+            if (*p == '<') {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected \'<\' inside entity \"%s\"", &entity_name[nentity][1]);
+            }
+
+            /* extract replacement or SYSTEM */
+            while (*p && isspace(*p)) {
+               if (*p == '\n')
+                  line_number++;
+               p++;
+            }
+            if (!*p) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected end of file");
+            }
+            if (*p == '>') {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected \'>\' inside entity \"%s\"", &entity_name[nentity][1]);
+            }
+
+            /* check if SYSTEM */
+            if (strncmp(p, "SYSTEM", 6) == 0) {
+               entity_type[nentity] = EXTERNAL_ENTITY;
+               p += 6;
+            } else {
+               entity_type[nentity] = INTERNAL_ENTITY;
+            }
+
+            /* extract replacement */
+            while (*p && isspace(*p)) {
+               if (*p == '\n')
+                  line_number++;
+               p++;
+            }
+            if (!*p) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected end of file");
+            }
+            if (*p == '>') {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected \'>\' inside entity \"%s\"", &entity_name[nentity][1]);
+            }
+
+            if (*p != '\"' && *p != '\'') {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Replacement was not found for entity \"%s\"",
+                                 &entity_name[nentity][1]);
+            }
+            delimiter = *p;
+            p++;
+            if (!*p) {
+/*
+               free(buffer);
+               for(ip=0;ip<MXML_MAX_ENTITY;ip++)
+                  free(entity_value[ip]);
+*/
+               return read_error(HERE, "Unexpected end of file");
+            }
+            pv = p;
+            while (*pv && *pv != delimiter)
+               pv++;
+
... 207 more lines ...
  102   14 Oct 2005 Ryu SawadaInfoEventID
It seems that when tasks have different eventID from 'a', event methods are not executed.

I modified ROMETask.cpp for temporary solution like
else if ( strncmp(gROME->GetNameOfActiveDAQ(),"midas",5) ||
( !strncmp(&fEventID,"a",1) || !strncmp(option,&fEventID,1) )
) {
fCurrentEventMethod = "Event";
TimeStart();
if (gROME->isFillEvent())
Event();
TimeEnd();
}
By this change, eventID does not have meaning for DAQSystems other than midas.

If eventID should have meaning also in root mode, please impleament something to fill ROMEAnalyzer::fEventID in this mode.
  103   17 Oct 2005 Matthias SchneebeliInfoMoved ROME from cvs to subversion
ROME moved from the cvs repository to a subversion repository.

Subversion repositories are much easier to maintain.

For the user almost nothing changes.
'cvs checkout' translates to 'svn checkout' and so on.

Subversion can be downloaded from http://subversion.tigris.org/project_packages.html

I hope this will not cause much inconvenience.

Matthias
  104   16 Nov 2005 Matthias SchneebeliInfoChanged Root DAQ to Rome DAQ
I have changed the name of ROMEs input/output DAQ system from Root to Rome.
This has to implications for the user :

1. One has to select 'rome' intead of 'root' for the <DAQSystem> tag in the romeConfig file.

2. To access this DAQ system one has to call GetRome() instead of GetRoot()

Matthias
  105   07 Dec 2005 Ryu SawadaSuggestionProposal reorganiztion directory structure
*) Currently, builder makes many files in the top directory.

XXXFolderDict.cpp
XXXFrameworkDict.cpp
XXXROMEDict.cpp
XXXTaskDict.cpp
XXXUserDict.cpp
XXXFolderDict.h
XXXFrameworkDict.h
XXXROMEDict.h
XXXTaskDict.h
XXXUserDict.h
xxxproject.exe
XXXProject.html
XXXUserHTML.html
libXXXProject.so
(romeConfig.xml)
Makefile
Makefile.usr

But I think it makes hard to find important files. And I'm afraid people feel ROME difficult.
Really important files are romeConfig.xml, Makefile and xxxproject.exe. So I propose followings
1) make "dict" directory and put all dictionary related files in it.
2) I have proposed to make XXXUserHTML.html before. But I started to feel this feature is not necessary any more.
3) remove libXXXProject.so from "all:" in Makefile. Users need to type "make so" to create shared library.
Makefile will look like
.
.
all: obj blank.d xxxproject.exe
.
.
so: libxxxproject.so
libxxxproject.so: $(objects)
g++ $(Flags) $(soflags) -o libxxxproject.so $(objects) $(Libraries)

*) There are still some complains that it is not easy to know which files are overwritten by builder
For instance, there is no warning messages in the header of XXXProject.html and Makefile.
And some files under "framework" directory are persistent. For instance user defined DAQ, user defined
database and folders with "editable class" flag are persistent. So I propose to separate them
at the first level instead of separating "framework" and "task". It will look like

top
|-- framework
`-- user
|-- daqs
|-- databases
|-- folders
`-- tasks

daqs, databases and folders may appear only when necessary.

All files which will be overwritten are put in framework. And others go under user.
When a task does not have "editable class" flag. the .cpp will go to user/tasks/ and
the .h file will go to framework/

This change is more like matter of favor.
And there are disadvantages.
.h will be various places, and it becomes difficult to find a .h file to know the class structure.
And the file with the same name can be in different places.
For instance, normally .h file of folder will be put in framework, but if it has "editable class" flag it will be put in user/folders/.
And if one changes "editable class" flag meanwhile, there can be two files with the same name. It may cause problem

With this change all ROME users need to move their files, so we have to think carefully.

( Anoter possibility is preparing nice document on ROME homepage instead of changing directory structure. )

P.S.
This is a very small point and is not related to directory structure.
Normally people associate online data taking with the word "DAQ". But in ROME, DAQSystem is something like input data format. ROME and database are not clearly DAQ.
When we have chanse, it may be good to rename nicer.
  106   18 Dec 2005 Ryu SawadaInfoRe-organization of directory structure
I and Matthias discussed about directory structure. In previous structure, files which can be overwritten and others were placed in the same directory.

We thought it would be better to separate two kinds of files clearly. So I modified directory structure like following.
|-- include
|   |-- daqs       : include files of user defined DAQs.
|   |-- databases  : include files of user defined databases.
|   |-- folders    : include files of folders come when 'ChangeableClassFile" is true.
|   |-- generated  : include files which can be overwritten by builder.
|   `-- tasks      : include files of tasks come when 'ChangeableClassFile" is true.
`-- src
    |-- daqs       : source files of user defined DAQs.
    |-- databases  : source files of user defined databases.
    |-- folders    : source files of folders come when 'ChangeableClassFile" is true.
    |-- generated  : source files which can be overwritten by builder.
    `-- tasks      : source files of tasks.         

All ROME user need to modify the place of files and also #include statement.
  107   06 Jan 2006 Steven SheetsForumTNetFolder.h
I just downloaded ROME v 2.0, I think. After running the make file I try and use romebuilder.exe
on the example stepbystep given in the download. When running romebuilder.exe
on stepbystep.xml I found it could not locate the file TNetFolder.h.

I googled this file and found a version of it which I copied to rome/include but still the builder will not build the analyzer. At this point I'm not sure how to get around this problem. If you have suggestions I'd appreciate it.

thanks,
Steven Sheets
  108   06 Jan 2006 Ryu SawadaForumTNetFolder.h
You can download the latest TNetFolder.h from the repository with web browser.

http://savannah.psi.ch/websvn/listing.php?repname=rome&path=%2Ftrunk%2Frome%2F&rev=0&sc=0


TNetFolder.h was added to "rome/include" in two weeks ago. Please make sure you have recent version.
If your copy is old, please update your copy with "svn update" command.


If the problem is not still fixed, could you paste error message from compiler ?
  109   09 Jan 2006 Ryu SawadaSuggestionConfiguration file
About configuration XML files.

Now we merged ROME and ARGUS.
So I expect that users often have several configuration files for one project.

But I realized many people don't know that they can specify configuration file.

So I propose following scheme.

* When a program starts, it searches all XML files located in current directory which has <Configuration> tag at the top.
* If it does not find any XML file, it asks user to generate new one.
   * ask configuration type [R/A/M/N]
   * ask filename. Default is romeConfig.xml
* If it find only one XML file, it reads the XML file.
* If it find several XML files, it asks user which file should be used with a prompt like,
     Which configuration file do you use ?
      [1] filename1.xml
      [2] romeConfig.xml
      [3] filename2.xml
      [q] quit program
* When user starts program with option -c, it asks creates new configuration anyway.
* When user starts program with option -i, it uses specified file.
  110   09 Jan 2006 Ryu SawadaSuggestionQuit mode
Sometimes I hear that going to interactive session after end of analysis is uncomfortable. In fact it is possible to quit program immediately with -b option.
But -b is not only for that, It suppresses print. So I propose to make QuidMode in which program exit without going interactive session.
-q option is good, because ROOT has same option which means quit program just after macro is executed.
  111   13 Jan 2006 Ryu SawadaSuggestionConfiguration file
done.
Program searches configuration XML file in ./ and ./config
  112   13 Jan 2006 Ryu SawadaSuggestionQuit mode
done.
Users can specify quit mode with option -q or configuration file.
  113   08 Feb 2006 Ryu SawadaBug ReportROMEEventLoop:Update
Recently the place to call ROMEEventLoop:Update was moved.
Probably because of this, in MIDAS online mode, event number is always incremented even when DAQ is not running.
  114   08 Feb 2006 Ryu SawadaBug ReportROMENetFolderServer
When I run ROME analyzer in online MIDAS mode.
It stopps with making core (segmentation fault).

It seems it makes core after "return" in main.cpp, namely finishing all code.

When I comment out following line in ROMEAnalyzer.cpp, it works propery.
tnet->StartServer(gROME->GetApplication(),gROME->GetPortNumber());

Probably it is relating to ROMENetServer or thread for this.
  115   09 Feb 2006 Ryu SawadaBug ReportROMENetFolderServer
I investigated the problem.

On my machine (Scientific Linux 4.2, gcc3.3.2, glibc2.3.2, ROOT5.08.00), following simple program reproduced the problem.
There was no probelm with ROOT version4.
Is it bug of ROOT ?

When I put -lpthread at the last. This problem stopped.
Actually without this option, my analyzer workes.
I guess -lpthread is not necessary.

I will check more and if not necessary, I will remove -lpthread.

--- Makefile ---
rootlibs := $(shell $(ROOTSYS)/bin/root-config --libs)
rootcflags := $(shell  $(ROOTSYS)/bin/root-config --cflags)

test: main.cpp
	g++ $(rootcflags) -o $@ $< -lpthread $(rootlibs) -lThread
------
--- main.cpp ---
#include <Riostream.h>
#include <TThread.h>

void* TestLoop(void *arg)
{
   return NULL;
}

int main(int argc, char *argv[])
{
   TThread *thread = new TThread("TestLoop", TestLoop);

   cout<<"OK"<<endl;
   return 0;
}  
------
  116   22 Feb 2006 Giovanni SignorelliSuggestionText database suggestion
This is maybe a bug report that happens reading long lines in a text database.
I am currently handling large data base files for linear fit analysis, basically I have to handle a 828 x 828 
matrix. Writing in the text db 828 lines containing each 828 comma separated values with a single 
new-line at the end does not work, maybe the read buffer is too large. 
So I propose the following modification to ROMETextDataBase.cpp:
Suppose you have a field named "coefficients" which is declared "array", say of four numbers,  in the 
xml file. In the text data base it appears as:

<coefficients>
one,two,three,four
one,two,three,four
one,two,three,four
...
</coefficients>

One should be able to write the same code as follows:

<coefficients>
one,
two,
three,
four                  <----- note there is NO COMMA here!
one,
two,
three,
four
one,two,three,four
...
</coefficients>

or

<coefficients>
one,two,
three,four
one,two,three,
four
one,
two,three,four
...
</coefficients>

In this way I can write a single column of (comma separated) values. Can somebody (Ryu?) take care of 
this (I hope simple) modification?
Thanks.

 
  117   22 Feb 2006 Stefan RittSuggestionText database suggestion
> This is maybe a bug report that happens reading long lines in a text database.

This does not only affect ROME, but also the MXML library which has to read the long lines. I haven't carefully
checked, but I presume that MXML can handle long lines. So it might maybe be better to keep the long lines in a
text database, and modify ROME such that there is no buffer overflow. This maybe makes it easier to read the
database and to import it in programs like a spreadsheet.
  118   22 Feb 2006 Ryu SawadaSuggestionText database suggestion
I improved TextDataBase as Giovanni suggested.
  119   08 Mar 2006 Giovanni SignorelliBug ReportgAnalyzer->GetEventID() fails if EventID>127-48
This bug happened when reading a .MID file containing events with event_id=99.
The ReadMidas task is not able to read the event because it is not recognized.
This event_id, when recovered with GetEventID() method was transformed to a negative value. This probably happened because there is a +48 addition at some place (in SetEventID) and a -48 on GetEventID. This casuses the unsigned char to be recovered as a signed number (lots of FFFF in front of it).

Furthermore it is not writtenanywhere that EventID<0xFF.

I could solve the problem
1) by setting EventID = 16, for instance
2) by modifying ROMEAnalyzer.h as follows
// Event ID
Int_t GetEventID() { return (fEventID-48)&0xFF; }
char GetEventIDChar() { return (fEventID)&0xFF; }
  120   02 Apr 2006 Matthias SchneebeliBug ReportgAnalyzer->GetEventID() fails if EventID>127-48

Giovanni Signorelli wrote:
This bug happened when reading a .MID file containing events with event_id=99.
The ReadMidas task is not able to read the event because it is not recognized.
This event_id, when recovered with GetEventID() method was transformed to a negative value. This probably happened because there is a +48 addition at some place (in SetEventID) and a -48 on GetEventID. This casuses the unsigned char to be recovered as a signed number (lots of FFFF in front of it).

Furthermore it is not writtenanywhere that EventID<0xFF.

I could solve the problem
1) by setting EventID = 16, for instance
2) by modifying ROMEAnalyzer.h as follows
// Event ID
Int_t GetEventID() { return (fEventID-48)&0xFF; }
char GetEventIDChar() { return (fEventID)&0xFF; }




This should be fixed now.
ELOG V3.1.4-2e1708b5