Re: [ROOT] map i/o problem

From: Susan Kasahara (schubert@physics.umn.edu)
Date: Tue May 20 2003 - 20:33:43 MEST


Hi Rene,
I've done as you suggest, and what I find is that the
void R__CandTrack_fTime(TBuffer &R__b, void *R__p, int)
method does not appear to be invoked on output.  (I haven't
tested it on input yet).  I am attaching the modified version of
this method so that you can see where I've placed the cout
debug statements.
I placed similar cout debug statements in some of the Cint methods provided
to stream other data members of the same CandTrack
class, e.g. I added cout statements to the method:
  R__CandTrack_fRange(TBuffer &R__b, void *R__p, int)
that streams data member:
 mutable map<Int_t,Float_t> fRange;  // this data member i/o's okay
and found that these streamer methods were being invoked.
  So, perhaps the problem is related to the fixed size array
map fTime somehow not being associated correctly with the Cint method
to stream it's data?
-Sue

void R__CandTrack_fTime(TBuffer &R__b, void *R__p, int)
{
  cout << "In R__CandTrack_fTime" << endl;
   map<Int_t,Double_t>* fTime = (map<Int_t,Double_t>*)R__p;
   if (R__b.IsReading()) {
     cout << "Buffer is Reading" << endl;
      {
         for (Int_t R__l = 0; R__l < 2; R__l++) {
    cout << "R__l = " << R__l << endl;
         map<Int_t,Double_t> &R__stl =  fTime[R__l];
         R__stl.clear();
         int R__i, R__n;
         R__b >> R__n;
         cout << "R__n = " << R__n << endl;
         for (R__i = 0; R__i < R__n; R__i++) {
            int R__t;
            R__b >> R__t;
            double R__t2;
            R__b >> R__t2;
     cout << "R__i = " << R__i << "R__t = " << R__t << "R__t2 = "
                 << R__t2 << endl;
            R__stl.insert(make_pair(R__t,R__t2));
         }
      }
    }
   } else {
     cout << "Buffer is Writing" << endl;
         for (Int_t R__l = 0; R__l < 2; R__l++) {
    cout << "R__l = " << R__l << endl;
      {
         map<Int_t,Double_t> &R__stl =  fTime[R__l];
         int R__n=(&R__stl) ? int(R__stl.size()) : 0;
         R__b << R__n;
         cout << "R__n = " << R__n << endl;
         if(R__n) {
            map<Int_t,Double_t>::iterator R__k;
            int iloop = 0;
            for (R__k = R__stl.begin(); R__k != R__stl.end(); ++R__k) {
     cout << "iloop = " << iloop++ << "R__k.first = " << (*R__k).first
                 << "R__k.second = " << (*R__k).second << endl;
            R__b << ((*R__k).first );
            R__b << ((*R__k).second);
            }
         }
      }
    }
   }
}

Rene Brun wrote:

> Hi Susan,
>
> In the dictionary file for your class, you should see a function
> that looks like the one in the attachement.
> Could you add debug info to this file in writing/reading
> to dump the values of the pair(int,double)?
>
> Let me know
>
> Rene
>
> On Tue, 20
> May 2003, Susan Kasahara wrote:
>
> > Hi roottalk,
> > I've noticed that a data member in one of our root persistable classes,
> > a fixed size array of mutable map<Int_t,Double_t> objects, does not
> > i/o correctly.  The class is of the form:
> >
> > class CandTrack: public CandReco {
> > ...
> > protected:
> >    ...
> >    mutable map<Int_t,Float_t> fdS;  // this data member i/o's okay
> >    mutable map<Int_t,Double_t> fTime[2];  // problematic data member
> >
> > ClassDef(CandTrack,1)
> > };
> > In this example,  the fdS data member i/o's okay, but the fTime[2]
> > data member is read back in with 0 entries in both the fTime[0]
> > and fTime[1] maps, despite these maps having non-zero entries on
> > output.
> > I can prepare a simple example to demonstrate this if necessary, but
> > I'm wondering if this is a known limitation or if there is some sort of
> > expression that needs to go in the comment field following the fTime[2]
> > data member, e.g.:
> >   mutable map<Int_t,Double_t> fTime[2]; //?something needs to go here?
> > to make this work?
> > I am using root cvs 5/12/03 with gcc 3.2 on rh. linux 8.0.
> > Thanks in advance for your help.
> > -Sue
> >
>
>   --------------------------------------------------------------------------------------------------------------------------------------------
>                Name: dict.cxx
>    dict.cxx    Type: Plain Text (TEXT/PLAIN)
>            Encoding: BASE64



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:11 MET