Re: [ROOT] detector mapping in root

From: Valeri Fine (fine@bnl.gov)
Date: Sun Jun 24 2001 - 18:43:34 MEST


> Hi Valery,
>
> TTable is a possibility, but far less efficient that the simple solution
> I posted yesterday with a simple TTree.


 The efficiency of either approach depends of the concrete task and the
volume of
  the information involved.
  In the case of TTree one needs to loop over the file resident TTree each
time one needs
  to find the value via GetEntry(i)

Rene> Int_t MyClass::GetWireID(Int_t board, Int_t module, Int_t channel) {
Rene>    for (Int_t i=0;i<tree->GetEntries();i++) {
Rene>      tree->GetEntry(i);
Rene>       if (BoardID   != board)   continue;
Rene>       if (ModuleID  != module)  continue;
Rene>       if (ChannelID != channel) continue;
Rene>       return WireID;
Rene>    }
Rene> }

 You are right if one needs to call MyClass::GetWireID one time per session.
  In my case one has to read the whole table in to the memory at once sort
it at once and then use
  as many times as the task logic needs.
  Myself  can not say in advance which approach is better.
  I can image third way, namely creating some sort of sorted index for TTree
branches.
  This way there is no need to loop over the entire TTree structure.
  The only problem with TTree to create that index one has to loop over the
entire TTree
  as many times as many index arrays one needs. This means twice at least.

  For this particular example the structure in question is 5 words long. One
needs to map
 2 "columns". This means if the task requires calling GetWireID  more then 2
times
  to map IDs it would be wise to read and keep the whole structure in memory
anyway.
 The last means one have to  create TTable-like  object in memory and apply
the sorting to be
 as efficient as possible. It is separate issue what is the persistent
representation of that table.
  It could be TTree (TTable class has the method to build TTree branches)
  From the first glance for the task present I/O is no an issue at all.

> With a TTable, you have to read
> all the elements of an entry to sort the table. With a simple TTree,
> you have the possibility to read only the branches (Board, then Module,
> etc). In case of a large table, this will make a substantial difference in
> time.

  Yes you are right if the table doesn't fit the real memeory and one needs
looping
  over the data a few times per session.

   Valeri Fine

>
> Rene Brun
>
> On Sat, 23 Jun 2001, Valeri Fine wrote:
>
> > You can do this either with TTree or TTable.
> >
> > With TTable approach create the class derived  from TTable and apply
> > TTableSorter as many times as you need  to get all  your mappings. (I
fact
> > this is the canonical approach that works with ROOT I/O).
> > http://root.cern.ch/root/htmldoc/TTable.html#TTable:description
> > I'd like to call your attention the class TTableSorter doesn't change
the
> > table it is applied agaist of.
> > Neither it copies that table data.
> >
> > Since TTable class allocates the continuous memory block internally this
> > block can be mapped
> >  to some hardware registries and populated by "electronics" directly or
by
> > parallel process via
> > "real" share memory (Just in case);
> >
> >
> >  #include "TTable.h"
> >
> >  typedef struct detector_t  {
> >    int  BoardID;    /* Board ID */
> >    int  ModuleID; /* Module ID */
> >    int ChannelID;  /* Channel ID */
> >    int  WireNumber; /* Wire number */
> >    int  WireType; /* Wire type */
> > };
> >   class  TDetector : public TTable
> >   {
> >    public:
> >      ClassDefTable(TDetector,detector_t)
> >      ClassDef(TDetector,2) //C++ wrapper for <dst_track> StAF table
> >   };
> >   #endif
> >
> >  At the moment the TTable object can be stored with "root" I/O, MySQL,
> > XDF (Corba-like) and ASCII( via SavePrimitive) formats.
> >
> >  I wonder if you need further exaplanations. Let me know.
> >   Best regrads, Valeri
> >
> > ----- Original Message -----
> > From: "Jacek M. Holeczek" <holeczek@us.edu.pl>
> > To: "roottalk" <roottalk@pcroot.cern.ch>
> > Sent: Friday, June 22, 2001 7:35 PM
> > Subject: [ROOT] detector mapping in root
> >
> >
> > > Hi,
> > > Assume one has a set of numbers (describing the wire mapping) in form
:
> > > BoardID ModuleID ChannelID WireNumber WireType
> > > ...
> > >   34      12       0         121         4
> > >   34      12       1         126         1
> > > ...
> > >   55      15       7         121         4
> > >   55      37       288       5878        2
> > > ...
> > > Now I would like to have functions like :
> > > GetWireID(BoardID,ModuleID,ChannelID)
> > > GetBoardID(WireNumber,WireType)
> > > The canonical approach would be to create a "database", feed it with
this
> > > table, and then make queries. But ... I would like to do this without
any
> > > database connection. Just "pure" root.
> > > I can't seem to have any good idea how to do this (mapping in both
> > > directions between "electronic" channels and detector wires).
> > > Any help appreciated.
> > > Thanks in advance,
> > > Jacek.
> > >
> > >
> >
>
>



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:50 MET