#include <emcDB.h>
It can in particular be used to see the validity ranges for some specific calibrations, dump the raw content of the calibration banks, and upload things from ASCII files to the Pg databases.
This page will teach you how to use the emcDB program to write calibration data ASCII files into the PHENIX EMCAL Postgres databases, and to browse EMCAL databases content.
Disclaimer: the emcDB program is only a convenient tool to update/dump the EMCAL databases. It is not a bullet-proof program ! It can for sure be improved.
emcDB --help
where flavourName is one of those defined in General description. Note that flavours are case-sensitive.
The above command is an interactive one, i.e. for each bank header, you'll be asked if you want to dump also the content of this bank (type 0 to continue, -1 to abort program, or any number n in between to see n channels). This can be quite painful for databases with a lot of banks. To overcome this difficulty, you can either use the --batch option to not be prompted for any answer, and/or restrict the set of bank you'd like to inspect, using the --(inserted|start|end)(After|Before) and/or --bankID options, e.g.
which will show you only Gains banks for FEM 108, inserted into database after 2001, December, the 20th, at 12 h 36 m 45 s.
emcDB --update directory
The above command will read all calibration files to be found under directory and will put them into the relevant database. Special note on pedestals : depending on the number of pedestal-calibration files for one FEM (3 or 5), a different database will be filled (calib.emc.Pedestals or calib.emc.Pedestals5). It should be automatic.
31-Aug-2001 Due to a possible problem in PHTimeStamp::operator >> , please always use the --forceDate option (see below), as the timestamp specified in the ASCII files themselves is currently not properly read out.
22-Jan-2002 The above bug should be fixed. But still you might want to use the --forceDate option to bypass the date which is in the files (e.g. to insure that a set of banks has the same start-of-validity period).
Make a fresh somewhere/ToF directory Copy the relevant flavour you'd like to put in the DB, e.g. :
cp /yourplace/ToF/*WALK* somewhere/ToF
emcDB --forceDate "year,month,day,hour,minute,second" --update somewhere/ToF
emcDB --forceDate "2001,08,01,12,45,00" --update /afs/rhic/phenix/phnxemc/EMC/m_080701
Many Gains files are split over many directories in e.g. /phenix/data24/vikonnik/Gains/RunXXXX, each of those directories being a normal top directory for calibration flavours, i.e. :
/phenix/data24/vikonnik/Gains/Run31250/Gains /Run31250/QA /Run33350/Gains /Run33350/QA ...
The idea is to use each RunXXXX directory as a calibration set. For this, we need both start and end of validity period for each set (start=time stamp of first run of the set, end=time stamp of first run of the next set to avoid time-gaps).
So the first step is to get those time stamps. We do have a PHENIX Run Database, so we will use it for that purpose. We could have make it transparent, but a) some run used by PbGl are not in this database and hence the relationship runnumber<->time stamp can not be found using the Run DB and b) when we did use Objy as our database managment system (prior to Postgres), for testing purpose we'd like to be able to read PHENIX Run DB while writing Gains into a private Federation (and currently Objy is not able to open 2 Federations in one single process...). So we used an interim file, and this has not changed. This file is produced using the command :
cd some_dir emcDB --runtimes 90000
This will select Postgre (Pg) as the DataBase Management System from which to fetch runtimes, for runnumber greater or equal to 90000, and will produce a emc_runtimes_initfromfile.tmp.txt file, like :
36503,Sun Dec 16 15:10:53 2001,Sun Dec 16 15:11:22 2001 36504,Sun Dec 16 15:11:43 2001,Sun Dec 16 15:12:13 2001 36505,Sun Dec 16 15:12:34 2001,Sun Dec 16 15:13:02 2001 36506,Sun Dec 16 15:13:25 2001,Sun Dec 16 15:13:52 2001 36507,Sun Dec 16 15:14:14 2001,Sun Dec 16 15:14:42 2001 36508,Sun Dec 16 15:15:03 2001,Sun Dec 16 15:15:32 2001 36509,Sun Dec 16 15:15:59 2001,Sun Dec 16 15:16:26 2001
Then, using information contained in Viktor's files for the run missing in PHENIX Run DB, we completed this file to obtain a new one (emc_runtimes_initfromfile.tmp.txt), covering all the runs we need.
We then use the --updatePbGlGains option to actually read the Gains files and put them into the Gains database
cd some_dir (same as before !) emcDB --updatePbGlGains /phenix/data24/vikonnik/Gains
And that's it ! Please note that it might be a little long...
emcDB --dump calib.emc.Gains --bankID 0 --insertedAfter "2002,1,1,0,0,0" --compare /afs/rhic/phenix/phnxemc/EMC/m_091001 -------------------------------------------------------------------------------- emcDB 2.0 (10 June 2004) -------------------------------------------------------------------------------- Dumping calib.emc.Gains calibration database -------------------------------------------------------------------------------- BankID = 0 Insert : Mon Jan 14 13:05:22 2002 StartVal : Mon Sep 10 10:30:26 2001 EndVal : Mon Jan 18 22:14:07 2038 Calibration Description : User Name = Unknown [# of channels] Show channels [n] Next bank [q] Quit, [c] Compare to file(s) Please enter command >
MATCHES the one in /afs/rhic/phenix/phnxemc/EMC/m_091001
Please note that you can use several --compare options to compare the current database bank against several directories.
Please note also that for pedestals, you need to use the --config gdb.dat option (which is used to find the FEM absolutePosition to PinNumber relationship). The gdb.dat file you can probably get from CVS online_configuration directory.
Definition at line 225 of file emcDB.h.
Public Member Functions | |
emcDB (const char *dbms="Pg", const char *dbname="calibrations", bool interactive=false, PHTimeStamp *ts=0, PHTimeStamp *tsend=0) | |
default ctor. | |
~emcDB () | |
dtor. | |
void | Debug (bool value=true) |
Set debug to yes or no. | |
bool | Dump (const std::string fulldbname) |
Dump a given database, e.g. calib.emc.Gains. | |
bool | Dump (const char *fulldbname) |
same as above. | |
int | Compare (PdbCalBank &bank, const std::string &directory, const std::string &flavour) |
Compare a bank from Objy with the same object fetch from file. | |
void | MakeRunTimes (int minrunnumber) |
Generate a temporary file with runnumber->timestamps relationship. | |
void | SetBankID (int bankid) |
Set the bankID to be used for next searches. | |
void | SetConfigurationFile (const std::string &filename) |
Set configuration filename (only needed for pedestals). | |
void | SetConfigurationFile (const char *filename) |
Same as above. | |
void | SetDirectories (std::vector< std::string > &directories) |
Set the directories to look for comparisons. | |
void | SetEndInterval (const PHTimeStamp &endAfter, const PHTimeStamp &endBefore) |
Set the end-of-validity interval for next searches. | |
void | SetInsertInterval (const PHTimeStamp &insertAfter, const PHTimeStamp &insertBefore) |
Set the insert date interval for next searches. | |
void | SetStartInterval (const PHTimeStamp &startAfter, const PHTimeStamp &startBefore) |
Set the start-of-validity interval for next searches. | |
bool | Update (const std::string directory) |
Read a directory with calibration files and write them into DB. | |
bool | UpdatePbGlGains (const std::string top_directory) |
Special case of update for PbGl Gains. | |
bool | UpdateInitialCalibration (const std::string top_directory) |
Another special case for Initial Calibrations. | |
bool | UpdateRejectList (const std::string top_directory) |
Yet Another Special case for Reject List. | |
bool | UpdateTofSectorOffset (const std::string dir, int runnumber) |
Yet Another Special case for TofSectorOffset. | |
Static Public Member Functions | |
static std::string | Version (void) |
Get the version of this class. | |
Private Member Functions | |
int | AbsolutePosition (const std::string &femName) |
void | Abort (const std::string &method, const std::string &message) |
PdbBankManager * | BankManager () |
emcManageable::EStorage | destination () const |
void | DumpContent (PdbCalBank &, int nchannels) |
void | CompareToDirectories (PdbCalBank &, const std::string &) |
PHTimeStamp | EndOfValidity (void) const |
bool | Error (const std::string method, const std::string message) |
int | GetPinNumber (int absPosition) |
void | initDBMS (const char *dbms) |
void | ParseFileName (const std::string filename, size_t &ifem, size_t &pin) |
int | PedestalVersion (const std::string cdir) |
bool | Quit (void) |
bool | ReadConfiguration (bool debug) |
void | Split (const std::string &str, std::vector< std::string > &split) |
void | UpdateXValue (emcTracedFEM &fem, int value) |
Private Attributes | |
std::string | fDBMS |
std::string | fDbname |
bool | fInteractive |
PHTimeStamp * | fForceDate |
PHTimeStamp * | fForceEndDate |
int | fBankID |
bool | fDebug |
PHTimeStamp | fInsertAfter |
PHTimeStamp | fInsertBefore |
PHTimeStamp | fStartAfter |
PHTimeStamp | fStartBefore |
PHTimeStamp | fEndAfter |
PHTimeStamp | fEndBefore |
bool | fStartIntervalGiven |
bool | fEndIntervalGiven |
bool | fInsertIntervalGiven |
std::vector< std::string > | fDirectories |
std::string | fConfigurationFile |
std::vector< int > | fPinNumbers |
|
default ctor.
Definition at line 152 of file emcDB.C. References fDBMS, fDbname, fDebug, fEndAfter, fEndBefore, fEndIntervalGiven, fForceDate, fForceEndDate, fInsertAfter, fInsertBefore, fInsertIntervalGiven, fInteractive, fStartAfter, fStartBefore, fStartIntervalGiven, and initDBMS(). |
|
dtor.
|
|
|
|
Referenced by ReadConfiguration(). |
|
Definition at line 214 of file emcDB.C. References fDBMS. Referenced by Quit(). |
|
Compare a bank from Objy with the same object fetch from file.
|
|
|
|
Set debug to yes or no.
Definition at line 238 of file emcDB.h. References fDebug. |
|
Definition at line 379 of file emcDB.C. References fDBMS, emcManageable::kDB_Objy, emcManageable::kDB_Pg, and emcManageable::kFile_ASCII. |
|
same as above.
Definition at line 243 of file emcDB.h. References Dump(). |
|
Dump a given database, e.g. calib.emc.Gains.
Referenced by Dump(). |
|
|
|
Definition at line 540 of file emcDB.C. References fForceEndDate. |
|
|
|
Definition at line 564 of file emcDB.C. References EMC_ERROR_MSG, fPinNumbers, EmcIndexer::MaxNumberOfFEMs(), and ReadConfiguration(). |
|
Definition at line 584 of file emcDB.C. Referenced by emcDB(), and MakeRunTimes(). |
|
Generate a temporary file with runnumber->timestamps relationship.
Definition at line 1508 of file emcDB.C. References fDBMS, initDBMS(), RunTimes::MinRunNumber(), and RunTimes::Output(). |
|
|
|
|
|
Definition at line 723 of file emcDB.C. References BankManager(). |
|
Definition at line 1529 of file emcDB.C. References AbsolutePosition(), fConfigurationFile, fPinNumbers, EmcIndexer::MaxNumberOfFEMs(), Split(), and split(). Referenced by GetPinNumber(). |
|
Set the bankID to be used for next searches.
Definition at line 255 of file emcDB.h. References fBankID. |
|
Same as above.
Definition at line 262 of file emcDB.h. References SetConfigurationFile(). |
|
Set configuration filename (only needed for pedestals).
Definition at line 258 of file emcDB.h. References fConfigurationFile. Referenced by SetConfigurationFile(). |
|
Set the directories to look for comparisons.
Definition at line 267 of file emcDB.h. References fDirectories. |
|
Set the end-of-validity interval for next searches.
Definition at line 731 of file emcDB.C. References fEndAfter, fEndBefore, and fEndIntervalGiven. |
|
Set the insert date interval for next searches.
Definition at line 741 of file emcDB.C. References fInsertAfter, fInsertBefore, and fInsertIntervalGiven. |
|
Set the start-of-validity interval for next searches.
Definition at line 751 of file emcDB.C. References fStartAfter, fStartBefore, and fStartIntervalGiven. |
|
Referenced by ReadConfiguration(). |
|
Read a directory with calibration files and write them into DB.
|
|
Another special case for Initial Calibrations.
|
|
Special case of update for PbGl Gains. where directory structure is slightly more complicated. |
|
Yet Another Special case for Reject List.
|
|
Yet Another Special case for TofSectorOffset.
|
|
Definition at line 1052 of file emcDB.C. References emcTracedFEM::FirstItem(), emcTracedValue::GetConstant(), emcTracedFEM::GetNumberOfChannels(), emcTracedValue::GetSlope(), emcTracedFEM::NextItem(), and emcTracedValue::Set(). |
|
Get the version of this class.
|
|
Definition at line 335 of file emcDB.h. Referenced by SetBankID(). |
|
Definition at line 347 of file emcDB.h. Referenced by ReadConfiguration(), and SetConfigurationFile(). |
|
Definition at line 330 of file emcDB.h. Referenced by BankManager(), destination(), emcDB(), and MakeRunTimes(). |
|
Definition at line 331 of file emcDB.h. Referenced by emcDB(). |
|
|
|
Definition at line 346 of file emcDB.h. Referenced by SetDirectories(). |
|
Definition at line 341 of file emcDB.h. Referenced by emcDB(), and SetEndInterval(). |
|
Definition at line 342 of file emcDB.h. Referenced by emcDB(), and SetEndInterval(). |
|
Definition at line 344 of file emcDB.h. Referenced by emcDB(), and SetEndInterval(). |
|
Definition at line 333 of file emcDB.h. Referenced by emcDB(). |
|
Definition at line 334 of file emcDB.h. Referenced by emcDB(), and EndOfValidity(). |
|
Definition at line 337 of file emcDB.h. Referenced by emcDB(), and SetInsertInterval(). |
|
Definition at line 338 of file emcDB.h. Referenced by emcDB(), and SetInsertInterval(). |
|
Definition at line 345 of file emcDB.h. Referenced by emcDB(), and SetInsertInterval(). |
|
Definition at line 332 of file emcDB.h. Referenced by emcDB(). |
|
Definition at line 348 of file emcDB.h. Referenced by GetPinNumber(), and ReadConfiguration(). |
|
Definition at line 339 of file emcDB.h. Referenced by emcDB(), and SetStartInterval(). |
|
Definition at line 340 of file emcDB.h. Referenced by emcDB(), and SetStartInterval(). |
|
Definition at line 343 of file emcDB.h. Referenced by emcDB(), and SetStartInterval(). |