/** \class PesCorrections Holds the calibrations constants from the database for the PESD->PlugStrip conversion \author Benn Tannenbaum benn@physics.ucla.edu \date 11 April 2000 This class holds the various constants from the database. It also calculates the corrections for linearity, attenuation, laser calibration and source tube calibration. It uses PESLaser for the calibrations from the laser runs and PESSrc for all other corrections. \date 30 May 2001 Benn Tannenbaum Changed the DB accesss to only use "keyless" mode. This is necessary for production, as one can only use the defaults when production is run. Since all data have ValidSets defined as they are taken, this is appropriate. \todo At present I force the all DB access to by "keyless". I need to add some switches to the code to allow the user to select either a specific DB set or use the ValidSet for that run. \17 Sep. 2002 Alon Attal - Added status function that returns strip status from dead strip DB. 2/14/05 Brian Mohr: Made changes to dead strip database so that it now contains not just dead strips, but all status/quality info. This includes dead strips, cable swaps and "low count" channels. Also added code to read in these flags from a text file for testing new constants or debugging. */ #ifndef PesCorrections_hh #define PesCorrections_hh #include #include #include "CalorObjects/PesConstants.hh" #include "CalorObjects/PesStripDefs.hh" // --> Classes defining a row & managers of TIMESTAMP & the Key //#include "DBObjects/TimeStampDefs.hh" // --> Classes defining a row & managers of CALIBRUNLISTS + the Key //#include "CalibDB/RunListDefs.hh" // --> The actual calibration table definition -- code generated from java // this table contains the tube to tube variations as determined by the // laser flasher calibrationruns. #include "ShMaxCalibDBTables/PESLaser.Defs.hh" // this table contains the calibrations from the source runs, i.e. pixel gain // gain corrections and everything else not in the previous table. #include "ShMaxCalibDBTables/PESCalib.Defs.hh" #include "ShMaxCalibDBTables/PESDeadChannels.Defs.hh" class PesCorrections { public: /** default constructor. Nothing exciting. */ PesCorrections(RunListKey * key = NULL); /** finds the correction due to the relative gain of this pixel, relative to the highest gain of any pixel in this tube. */ float gain(float counts); /** finds the correction due to pixel drift by normalizing to the source calibration */ float source(float counts); /** returns the RMS source measurement for this pixel */ float sourceRMS(){return theConstants[theAddress].theSourceRMS;}; /** finds the correction due to tube drift by normalizing to the laser calibration*/ float laser(float counts); /** returns the RMS laser measurement for this tube*/ float laserRMS(){return theConstants[theAddress].theLaserRMS;}; /** returns the strip status. */ int status(); /** converts from measured ADC counts to reference tube. The formula used is reference = (measured - a) / (b - c*(measured-a)) where a,b,c are from the database and measured is the recorded number of ADC counts.*/ float linearity(float counts); /** returns the pedestal for this strip*/ float pedestal(){return theConstants[theAddress].thePedestal;}; /** calculates the attenuation of the light due to travel in the fiber. the intensity of light in a fiber is given roughly by I = I_0 * exp(-x/lambda) where I_0 is the original intensity, x is the position of the injection of the light and lambda is the attenuation length of the fiber. Note that we have I and want I_0. For this fiber, the attenuation length is 3.4 meters. However, this will likely change during the run as the fiber is radiation damaged.*/ float attenuation(float position, float energy); /** return the high voltage at which this tube was run.*/ int highVoltage(){return theConstants[theAddress].theHighVoltage;}; /** removes the pedestal*/ float pedestal(float counts); /** prepare the database for contact*/ bool getConstants(const int runNumber, const int version, std::string status); /** fill the DB with constants*/ bool fillDB(int runNumber); /** retrieve the database constants for this particular strip*/ bool setAddress(const int address); // for debugging/testing fill quality flag from text files static void FillFromText(const bool value); private: int theAddress; void _FillFakeConstants(int _fillType); enum CALIBRATIONS {CALIB, LASER}; void newConstants(); PesConstants theConstants[6400];//there are 6400 strips in the system PESLaser_mgr LaserMgr; PESLaserContainer_ptr LaserData; PESCalib_mgr CalibMgr; PESCalibContainer_ptr CalibData; PESDeadChannels_mgr DeadChannelsMgr; PESDeadChannelsContainer_ptr DeadChannelData; RunListKey *_runListKey; const std::string cvstag() {return std::string("$Id: PesCorrections.hh,v 1.20 2005/02/15 05:22:10 mohr Exp $");}; //* not sure what to do about the cross talk yet. // static member boolian to turn on use of text files static bool sm_useText; // arrays contain quality info read in from text file char dead[2][2][NUM_STRIPS]; char swap[2][2][NUM_STRIPS]; char lowC[2][2][NUM_STRIPS]; // private member functions to fill quality arrays void fillDeadText(); void fillSwapText(); void fillLowCountText(); // sets PesConstants status bits with values from text files void SetStatusText(); }; #endif