Re: db question

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Thu Feb 14 2002 - 09:42:47 EST

  • Next message: Christian Holm Christensen: "Re: db question"

    Hi Andrei, Djam, et al, 
    
    On Wed, 13 Feb 2002 21:43:30 +0100 (CET)
    Djamel Ouerdane <ouerdane@nbi.dk> wrote
    concerning "Re: db question":
    > Hi Andrei,
    > 
    > Great to hear from you!
    > 
    > I'm personnaly drowned into many things!! But for your problem, I'm
    > not the expert, the database setup is beyond my knowledge. Christian
    > would be more appropriate for this (he set up our local db server)
    > but like me, he's overbusy!!
    
    First off, I'd like to point out that mails like this should be sent
    to brahms-dev-l, _not_ to individuals.  Hence, a copy of this mail to
    brahms-dev-l. 
    
    > Concerning the software for the ZDC, if you did exactly what was
    > done for the BB, it shouldn't be the problem. 
    
    Unless, ofcourse, the ZDCs has some other requirements than the BBs
    :-) 
    
    > Now, when you try to read by hand the numbers you introduced in the
    > calib. db, as far as I know, you'll see numbers in the format you
    > noticed. 
    
    I'll comment on that further down. 
    
    > I wrote an application which is in brahms_app/do_app/db called
    > BbDbBrowser to read the stuff that is in the DB given a run number :
    >
    >   BbDbBrowser -r <run> -c <calibration parameter>
    
    At some point, it'd be nice if we had a generalised DB browser -
    preferably a GUI/ASCII thing.  I started a small project - called
    brdbbrowser - but got derailed. 
    
    > Check it out and write the same kind of thing for the ZDC. If you
    > still get some weird thing then I cannot be of great help for you
    > unfortunately.
    >
    > PS: I'll forward your message to Christian but don't expect a prompt
    > reply from him.
    
    Well, here's my reply :-) 
    
    > ---------- Forwarded message ----------
    > Date: Wed, 13 Feb 2002 14:29:37 -0600
    > From: Andrei Makeev <makeev@comp.tamu.edu>
    > To: ouerdane@nbi.dk
    > Cc: murray@cyclotronmail.tamu.edu
    > Subject: db question
    > 
    > Hello Djamel!
    > 
    > This is Andrei Makeev, from Texas A&M. I need some help on
    > database, may be you can help me:
    > 
    > There is a local MySQL server, where I created (for test) "local"
    > versions of BrahmsMain and BrahmsCalib databases, I also added two
    > ZDC detectors, say "ZDCLeft" and "ZDCRight" and each one has 12
    > parameters (like pedestals, widths, gains, etc.) in
    > BrahmsCalib.Parameters table.
    
    Good thing to set up a test DB :-)
    
    > Then I try to commit some dummy numbers into DB, using bratmain
    > script, say, CommitPedestal.C. This script uses BrZdcPedCalModule
    > class which is inherited from BrZdcCalModule class - I just copy
    > everything from your code for BB countres and made appropriate
    > changes up to ZDC detector. 
    
    Not a bad start. 
     
    > I do:
    > 
    > > bratmain CommitPedestal.C -r 4610 -f 4610
    > > ...
    > 
    > At that stage I get many messages like:
    > 
    > > Warning in <BrRdbmDb::GetSingle>: Too many or too few matches on query
    > > SELECT * FROM RevisionType WHERE name LIKE 'standard': 0
    
    This means, that you're commiting stuff in regions of time [start,end]
    that has overlapping existing calibrations.   This means, that you'll
    effectively shadow the old calibrations, which may or may not be what
    you want.  To have true parallel calibrations, you should assign a
    different RevisionType (BRAT class BrDbRevisionType) to the
    calibration.   Unfortunately, there's no really nice provision for
    doing this in the BrCalibrationManager interface.  It's on the TODO
    list (far down though).  All this is documented [1]. 
     
    > then I read:
    > 
    > > Max events reached
    > > Max runs reached
    
    This is a message from BrMainModule - it should really be protected by
    a verbosity level, but isn't :-) 
     
    > and after this, again many warnings like (what probably is not important):
    > 
    > > BrRdbmCalibrationsDb::AddRevision: Comment string lesss then 16 characters 
    > > - investigate!
    
    No, that _is_ important.  You _must_ provide amble documentation of
    the revision you submit to the database.  The comments serves as a
    information for the end-user.  In particular, this is where you add
    stuff like `This channel is odd,' `that channel is dead,' `maybe the
    calibration should be redone,' `The nessecary cuts have been applied
    to obtain the desired result,' and so on.  This is the only place the
    end-users can look for additional information on the revision.  Hence,
    the comments _must_ not be filled with `default' values, but must
    _always_ be filled with something of relevance.  The information there
    is just as important as the actual numbers! 
    
    
    > My biggest confusion is - where in the DB should I look for my
    > "dummy" numbers I tried to write into it. I opened a "Revision"
    > table which has a lot of fields, but the only filed, I suspect,
    > could be useful to me called "array". There are some numbers in that
    > field for 2 detectors (24 entries), but those look approximately
    > like 419A00000 (??), which is not what I would except (I put
    > something like 11.0).
    
    I think this has been commented on previously on brahms-dev-l (where
    the bloody hell is that search engine?) - in essence, the numbers in
    the BrahmsCalib.Revision.Array entry are encoded, so that we may put
    floating point number, etc. into the database in a architecture (big
    vs. little endian) independent way.  This is important, because we use
    many different kind of chips in the collaboration, like Alpha (Digital
    Unix and Linux), i386 (Linux), Motorola (MacOSX and Linux), and SPARC
    (Solaris and Linux).   
    
    Hence, you can not inspect the numbers directly using the `mysql' or
    other `normal' clients.  This is also why Djam implemented
    `BbDbBrowser'.  That client uses the BRAT classes to access the data,
    which gives you the right numbers _and_ eases the task considerably. 
    
    > If you could give me some idea what's wrong, or may be I just don't
    > look at the right place? 
    
    Nothing is wrong. You're looking in the right place, but using the
    wrong tool :-)  
    
    > Is there any way to "check" manually what I've written to
    > BrahmsCalib (my actual numbers)? 
    
    Yes, implement something like `BbDbBrowser' or use interactive
    `bratroot' to get the numbers: 
    
      prompt% bratroot 
      brat [0] BrMainDb* mainDb = BrMainDb::Instance()
      brat [1] mainDb->SetHostName("rcas0005.rcf.bnl.gov")
      brat [2] mainDb->SetUserName("query")
      brat [3] mainDb->Connect()
      brat [4] mainDb->ConnectToCalib()
      brat [5] BrCalibrationManager* calibMan = BrCalibrationManager::Instance()
      brat [6] BrBbCalibration* bbl = \
    	   (BrBbCalibration*)calibMan->Register("BrBbCalibration", "BBL")
      brat [7] bbl->Use("pedestal") 
      brat [8] calibMan->Init() 
      brat [9] calibMan->Update(1005714869, -1)  
      brat [10] bbl->Print("BDLPRD")
    
    These are essentially the steps you need to take in a browser too.
    You can also use the low-level interface, which however requires a bit
    more thought and care:
    
      prompt% bratroot 
      brat [0] BrMainDb* mainDb = BrMainDb::Instance()
      brat [1] mainDb->SetHostName("rcas0005.rcf.bnl.gov")
      brat [2] mainDb->SetUserName("query")
      brat [3] mainDb->Connect()
      brat [4] BrCalibrationsDb* calibDb = mainDb->ConnectToCalib()
      brat [5] BrDbDetector* bbl = mainDb->GetDetectorByName("BBL")
      brat [6] BrDbParameter* ped = \
    	   calibDb->GetParameter("pedestal", bbl->GetDBID())
      brat [7] TObjArray* revs = \
    	   calibDb->GetXRevision(Form("parameterId = %d", ped->GetDBID()))
      brat [8] TIter next(revs)
      brat [9] BrDbRevision* rev = 0
      brat [10] while((rev = (BrDbRevision*)next())) rev->Print()
    
    Again, you get approximantly the same kind of output on the same
    number of lines, though the first version is perhaps a bit more
    intuitive. 
    
    > When I use either command line  mysql or MyCC GUI browser I got the
    > same wierd numbers in "array" :((  
    
    As I said, you're using the wrong tool (Don't use a jackhammer to nail
    a picture to the wall :-) 
     
    
    > Thank you in advance,		Andrei Makeev.
    
    You're welcome. 
    
    How is the ZDC stuff coming along?  You know, if you want to make a
    pre-release for people to look through and comment on, you can make
    your own CVS are under brahms_app (say makeev_app) and put your stuff
    there.  Suppose you have the stuff in a directory called zdc, then
    simply do 
    
      cvs -d /afs/rhic/brahms/BRAHMS_CVS checkout brahms_app/do_app 
      cd brahms_app 
      mkdir makeev_app 
      cvs add makeev_app  
      cp ../zdc makeev_app 
      cvs add makeev_app/* 
      cvs add makeev_app/zdc/*
      cvs add makeev_app/zdc/*/*
      cvs add makeev_app/zdc/*/*/*
      cvs add makeev_app/zdc/*/*/*/*
      cvs ci -m "Added a section for Andrei Makeev's stuff" makeev_app
    
    A nice benefiet of this, is that the CVS is backed up.   However, do
    not put a full BRAT source tree into you CVS area.  Only put the code
    you're working on in there.  Look in cholm_app/jobs for ideas on how
    to use Autotools, etc.. 
    
    Yours, 
    
    Christian Holm Christensen -------------------------------------------
    Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
             DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
             Denmark                             Office: (+45) 353  25 305 
    Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm
        
    
    [1] http://www4.rcf.bnl.gov/~cholm/db/KObratdb/index.html
    



    This archive was generated by hypermail 2b30 : Thu Feb 14 2002 - 09:43:57 EST