G0Analysis Release 0.14 Paul King; 2003/05/21, 19:39. This is the production release for the "second pass" analysis. Changes since release 0.13: =========================== * Implemented code to write EPICS variables directly into v0.7 of the G0 database. * Added a buddy ntuple. * Several changes: 1. Implemented Kaz's linear regression class G0LinearRegression. This class calculates the detector yield vs beam parameter slopes in the first pass of the replay. In the 2nd pass the slope correction will be applied. Added the newly calibrated x_targ, y_targ, theta_x, theta_y, engery, q_targ in G0BeamMonitor class. 2. Modifications on G0Scintillator class: a) Added "proton","pion","inelastics","bkg" and "total" data member in G0Scintillator to ease Kaz's yield correction. Also defined the corresponding proton_low, proton_high, etc, in G0Scintillator to store the PID cuts. Removed the obsolete window_low, window_high from G0NADetector and G0FrenchDetector. Removed the PID weight calculation in the histogramming and ntupling routine. b) Moved the DNL timebin width fWidth[] from individual NA and French detector classes into G0Scintillator. c) As an effort of code clean-up, defined the overloaded operators "+", "-", "=", "+=", Divide()" "MeanValue()", "Sigma()", "Normalize()" , etc at this level. These operators are involved in the asymmetry and yield calculation by G0NADetector and G0FrenchDetector objects. d) Removed obsolete data structures from G0Scintillator. 3. Implemented three more replay flags for Kaz's linear regression analysis: "--calcslope", calculates the slopes during the replay "--linregcorr", applies the slope corrections to the detector yield "--writelinregprms", writes the slopes to an output file. Updated the flags for the database interface: "--cut_id <>", to specify the cut_id "--calib_id <>" to specify the calibration_id "--dt_rates_id <>" to specify the deadtime_rate_id. 4. Moved french_config structure from G0CodaEvent to G0FrenchDetector. Also move the decoding routines into G0FrenchDetector. Added a structure to store all the DAC settings for later filling into the database. 5. As Julie previously suggested, removed the timebin by timebin entries of the yield and asymmetry from the quartet ntuple. Replace them with the "proton" yield and asymmetry for each detector (8*16). 6. Added database input retrieval hooks for the following parameter sets: a) PID cuts (G0NADetector, G0FrenchDetector) b) DNL (G0NADetector, G0FrenchDetector) c) French NPN cutoffs (G0FrenchDetector) d) Single rates needed for the deadtime correction (NA: tartan rates, French: MT and CFD single rates) e) Length of the deadtimes (G0NADetector, G0FrenchDetector) f) beam monitor calibration constants (G0BeamMonitor) g) linear regression slopes and means (G0LinearRegression) h) fastbus TDC calibration (G0Fastbus) i) global cuts (on beam current, etc.) (G0Cuts) 7. Updated the database filling routines WriteToSQLDB() etc a) updated measurement table filling. b) updated beam table filling. c) slopes table filling (new). d) french electronics tables filling (new). 8. Modifications in G0SQL class: a) Besides detectors and monitors tables, also load particles table and slope_types table in the c-tors. b) Coded two selection routines to retrieve the default calibration_id and deadtime_rates_id (SelectCalibID() and SelectDTRatesID()) if nothing is specified. Otherwise take the values from command line input c) Implement the filling of flag columns in the analysis table during the replay. * Corrected table names for magnet variables in G0EPICSEvent::DefineEPICSVariables(). * A few bugs were found and fixed. 1. I forgot to put the "total" key word parsing in G0FrenchDetector. 2. The new FillFrenchCfgBuffer() was offset by two words. 3. NA DNL file was not implemented yet so the time bin widths were zeros. Consequently the deadtime correction created "nan". So took a dummy routine to assign bin widths --- 6.5ns, 1ns, 1ns, ... instead. 4. This bug came from the (newly implemented) overloaded G0Scintillator operators. The copy c-tor of G0Scintillator took kTimeBin (a global non-const) to resize the timebin vector and kTimeBin changes from 24 to 128 globally in the G0NADetector and G0FrenchDetector c-tors to take into account the difference between NA and French. This trick had bad effects when the "+" and "-" operators of G0Scintillator were called to do the asymmetry calculation, since kTimeBin was always reset to 24 after the French c-tor. So defined an internal variable fNumberOfTimeBins in G0Scintillator so that when the copy c-tor is called, it knows the right size to ensure the asymmetry calculation be performed on ALL the time bins. 5. In this new version I stick to a Divide() function when doing the dividing between numbers. Set the output value to +100,000.0, if the denominator = 0, to be consistent with the old engine. 6. Cross-check the asymmetry output file with the one produced by the old engine (02-18-2003 version). Differences were found on the French timebins. I just realized in this new version we have had Guillaume's modification of the French deadtime correction. Put this into the old engine and ran the check again. indeed it solved the discrepancy. 7. Small fixs of the headers of TEtClientBuffer.C and G0OnlineEvent.C to quiet gcc 3.2. * Found an error in the decoding of the French configuration event when the event limits flag was used to skip the file segment containing the event (such as using "-e 470000:490000"). Resolved the error by moving the processing of the French configuration event and the EPICS events outside of the test on the event number, so that these events are processed even if they are not within the event limits. * Calibrations: 1. Put Aamer's new BCM calibrations into the relevant pedestal files of January runs. 2. Added the "q_targ" entry in the global cuts (g0cuts.in). 3. Added Retief's new PID calibrations files (detBinRange.XXX.work) into the repository. These new calibrations should be applied to the January runs. The "proton" and "pion" cuts were carefully checked. Defined "inelastics" window between pion_high and proton_low, and "background" window between proton_high and the end of ToF. Modified inputfile_lookup.in to reflect this. I will talk to Paul to remove the old calibration files. 4. Modified the default NA deadtime correction flag to "dog_only" in replayflags.in. * More modifications related to the upcoming production replay. 1. Bugs fixed during the database filling test (most in sql query string compositions) a) NA&French:: LoadPIDBins(), LoadDNL(). b) Commented NA::LoadDNL(sql). No final calibration values available yet. In NA class, added array structures fDTRateFitP1[] and fDTRateFitP2[] to store the quadratic fit parameters of tartan rates vs beam current. Renamed NA&French::LoadDTValues(sql) to LoadDTPrms(sql) and implemented the retrieving of quadratic fit parameters in NA::LoadDTPrms(). Commented NA&French->LoadDTRates() and sql->SelectDTRatesID() in GetInputData(). c) To follow CMU convention, modified tartan axis definition in NA class in terms of left and right instead of front and back. d) Added LoadTDCCalibPrms() in fastbus class to retrieve the gain and offset of the TDCs from the database. To keep the backward compatibility, still fill the fastbus ntuples with the raw data. Might change it later. e) Modified FillAnalysisTable() and FillRunTable in the sql class for properly filling. In the main code, added sql->FillRunTable(). f) Small bugs fixed in WriteToBeamTable() and WriteToFrenchElectronicsTable() and G0EPICS::WriteToDatabase(). g) Modified LoadLinRegPrms() method in the linear correction class to properly retrieve the slopes and means from the 1st pass replay. Moved sql->StoreReplayFlags() in GetInputData() to ensure the knowledge of all the relevant flags before sql->FillAnalysisTable() is called. 2. Implemented Silviu's beam trip cut (we throw away the first 2000 MPS after the beam recovers from a trip) in G0BeamMonitors and PassedCuts. 3. Expanded the NA deadtime correction option list ("--na_dt <>") to "off", "70ns", "dog_singles" and "dog_only" to switch between different correction approaches. * The function: SlopeError() was changed to correctly include all the off diagonal matrix elements in the covariance matrix for the error calculation. * Another bug fix from Kaz in G0LinearRegression. This corrects the array indices for the variable "xvarsum" (should be one-dimensional, but was indexed as multi-dimensional). * Added a "good_event" flag for the fastbus events. This flag is set by the "goodness" of the most recent 30Hz event so effectively the beam current and beam trip cuts will apply to those fastbus events. * Added a constructor method for G0SQL which takes the MySQL server host name, user name, and database name as string arguements. This was done to simplify development of scripts which extract data from the database. The default contructor now calles this new constructor with empty strings as the arguements. * Updated the G0 sql query translator according to the new database structure in G0SQL class. * Added Damon's new G0Database lookup file, v0.7 into the repository. * Fixed bug that caused 'sms' and 'target' tables in the database to be filled twice. * Added code to fill polarized source tables from EPICS data stream. * Modified the database lookup table to indicate the calibration_id and cut_id variables are included in the analysis table. * Squashed the following bugs: 1) Column name in 'measurement' table of G0 database changed from 'measurement_type' to 'measurement_type_id'. Corrected code in G0SQL::Translate() appropriately. 2) G0 database table relationships in lookup table are order sensitive, i.e. run.run_id:analysis.run_id appears in the table but analysis.run_id:run.run_id does not. Corrected code in G0SQL::GetTableRelations() appropriately. 3) Fixed G0SQLResult::GetArrayF() to return NULL if the array corresponding to the desired column could not be found. Implemented the following feature: G0SQLResult can be used to store query results that were not generated from SQL created by G0SQL::Translate(). Added code to G0SQL::Process() to get column names from the returned TSQLResult in this case. * More changes for deadtime: 1. Implemented the retrieving of DT correction parameters in G0FB_deadtime class. Basically copied LoadDTPrms() method from G0NADetector. 2. Added WriteDTRatesTables() routine in WriteToSQLDB to fill the tartan rates into the database at the end of the replay. 3. Fixed the unit conversion of NA and French asymmetries before writing to the database. Coded the base method in G0Scintillator instead. 4. Fixed one more bug in G0SQL::GetTableRelations(). * Squashed bug that caused all of the French TOF results to be written into octant 7 detector 16 in the database. * Added G0SQLResult::GetArrayName(UInt_t index) in order to retrieve the array name for a given column index. * Modifications to allow the use of G0SQL and G0SQLResult classes at the ROOT command line and in interpreted scripts. 1) Added ClassImp and ClassDef macros to header and implementation files of G0SQL and G0SQLResult in order to get ROOT dictionary generation. 2) Added LinkDef files for G0SQL and G0SQLResult to control dictionary generation. 3) The dictionary generation (rootcint) really does not like vector<> in G0SQL. Used __CINT__ macro to to prevent vector<> declarations and functions from being included in the dictionary. 4) ROOT interpreter has a lot of problems with the C++ string class. Have overloaded various G0SQL and G0SQLResult member functions that took or returned string to make Char_t* versions. Important Note: It is necessary to delete the pointer returned by G0SQL::Translate(const Char_t* selection, const Char_t* cuts). 5) As a consequence of 4) the G0SQL constructors now call an Init function to load up lookup tables and the like. * Changed member variable sql_query to fSQL_Query. Store the whole SQL string into it at the end of ComposeQuery(). * Dominique's fix of the French electronics configuration struct. * Added the filling of "Buddy marker delays" into the G0 database. * Some database filling tests and bug fixing before the production replay. 1) Some modifications according to the recent change of "tartan_axis_id". Added a tartan_axis table loader at the initilization and an id getter. Fixed G0FB_deadtime::LoadDTPrms() and WriteToDTRatesTable() routine for NA deadtime correction accordingly. 2) Fixed a small big in updating the polarized_source table. * Some cleanups of G0SQL class definition. Moved all the internal functions related to the translator into "private". * Modifications from Angela to fix a bug regarding the namefile of the tartan table written in the $G0SCRATCH/tmp directory.