for (Int_t i = 0; i < fNCalibAPD; i++) {
AliEMCALCalibAPDData &t = fData[j];
if (!inputFile) {
- printf("AliEMCALCalibAPD::ReadCalibAPDInfo - Error while reading input file.\n");
+ printf("AliEMCALCalibAPD::ReadCalibAPDInfo - Error while reading input file; likely EOF..\n");
fNCalibAPD = j; // that's how many we actually read succesfully
printf("AliEMCALCalibAPD::ReadCalibAPDInfo - read %d OK\n", fNCalibAPD);
return;
Int_t fTestPos; // location of APD during test
Float_t fV30; // Catania/Houston Voltage V30 (V) at T = 25 deg C
- Float_t fV50; // Catania/Houston Voltage V30 (V) at T = 25 deg C
+ Float_t fV50; // Catania/Houston Voltage V50 (V) at T = 25 deg C
Float_t fVoltCoeff; // 1/M x dM/dV
Float_t fPar[3]; // fit parameters, p0,p1,p2 - for ADC vs bias measurement
Float_t fParErr[3]; // error on fit parameters
for (Int_t i = 0; i < fNSuperModule; i++) {
AliEMCALSuperModuleMapAPD &t = fSuperModuleData[i];
if (!inputFile) {
- printf("AliEMCALMapAPD::ReadMapAPDInfoStripBasis - Error while reading input file.\n");
+ printf("AliEMCALMapAPD::ReadMapAPDInfoStripBasis - Error while reading input file; likely EOF..\n");
return;
}
inputFile >> iSM;
for (Int_t j=0; j<nAPDPerStrip; j++) {
if (!inputFile) {
- printf("AliEMCALMapAPD::ReadMapAPDInfoSingleStripBasis - Error while reading input file.\n");
+ printf("AliEMCALMapAPD::ReadMapAPDInfoSingleStripBasis - Error while reading input file; likely EOF..\n");
return;
}
inputFile >> iStripCol >> iStripRow >> iAPD;
for (Int_t i = 0; i < fNSuperModule; i++) {
AliEMCALSuperModuleMapAPD &t = fSuperModuleData[i];
if (!inputFile) {
- printf("AliEMCALMapAPD::ReadMapAPDInfo - Error while reading input file.");
+ printf("AliEMCALMapAPD::ReadMapAPDInfo - Error while reading input file; likely EOF..");
return;
}
inputFile >> iSM;
const int NFEC = 9; // per branch, labelled 1..9
const int NCSP = 32; // per FEC
+// conversion between DAC (0-0x3ff) and HV values (V):
+// hv = hvmin + prop*DAC; values from PHOS manual, and used in Houston/Catania
+const float hvmin = 209.9;
+const float prop = 0.2022;
+
// some global variables
-int biasVoltage[NRCU][NBranch][NFEC][NCSP];
+Float_t biasVoltage[NRCU][NBranch][NFEC][NCSP];
int towerCol[NRCU][NBranch][NFEC][NCSP];
int towerRow[NRCU][NBranch][NFEC][NCSP];
void Tower2FEEBiasInfo(const char *inputFileName)
{
ifstream inputFile(inputFileName);
- int ic, ir,ival;
+ int ic, ir;
+ Float_t ival;
int ircu, ibranch, card, icsp;
for (int icol=0; icol<fgkEmCalCols; icol++) {
for (int irow=0; irow<fgkEmCalRows; irow++) {
const int read_header = 0x520000;
const int write_header = 0x620000;
- // hv = hvmin + prop*DAC; values fitted/measured by ZhongBao; correction with David K at SPS beamtest
- float hvmin = 207.9;
- float prop = 0.2022;
// resulting voltage settings should be good within a few volts
cout << " HV-DAC prop. constant = " << prop << endl;
char iv_dac_setting[100];
if (icsp >= 24) csp_addr += 0x20;
// what does the desired voltage (in V) correspond to in DAC?
- int iv_dac = (int)( (biasVoltage[rcu][branch][card][icsp] - hvmin)/prop );
+ int iv_dac = (int)( (biasVoltage[rcu][branch][card][icsp] - hvmin)/prop + 0.5); // round-off
if (iv_dac > 0x3FF) iv_dac = 0x3FF;
sprintf(iv_dac_setting,"700%03X",iv_dac);
word = write_header | (branch << 16) | (icard << 12) | (csp_addr);
// write a long comment with all info for this CSP
- sprintf(comment, "# RCU %d, Branch %s, FEC %d, CSP %d - Tower Col %d, Row %d ",
+ sprintf(comment, "# RCU %d, Branch %s, FEC %d, CSP %02d - Tower Col %02d, Row %02d ",
rcu, branch_str[branch], icard, icsp,
towerCol[rcu][branch][card][icsp],
towerRow[rcu][branch][card][icsp]
rcu_addr_card, word, comment);
rcu_addr_card++;
- fprintf(fout_setbias_card[rcu][branch][card], "w 0x%4X 0x%s # Set Voltage: %d V, DAC %d (hex: %03X)\n",
+ fprintf(fout_setbias_card[rcu][branch][card], "w 0x%4X 0x%s # Set Voltage: %4.1f V, DAC %d (hex: %03X)\n",
rcu_addr_card, iv_dac_setting,
biasVoltage[rcu][branch][card][icsp],
iv_dac, iv_dac
rcu_addr_card++;
// slighly modified comment for read command - include voltage info
- sprintf(comment, "# RCU %d, Branch %s, FEC %d, CSP %d - Tower Col %d, Row %d : %d V, DAC %d (hex: %03X)",
+ sprintf(comment, "# RCU %d, Branch %s, FEC %d, CSP %02d - Tower Col %02d, Row %02d : %4.1f V, DAC %d (hex: %03X)",
rcu, branch_str[branch], icard, icsp,
towerCol[rcu][branch][card][icsp],
towerRow[rcu][branch][card][icsp],
3) Optional - e.g. in case you don't have the whole SuperModule APD map or what not
Generating a file of the same bias value for each tower:
----------------------------------------------------------
-root -b 'WriteBiasFixVoltage(390, "Bias390.txt")' -q # aliroot also works..
+root -b 'WriteBiasFixVoltage.C(390, "Bias390.txt")' -q # aliroot also works..
4) Generating a file of new bias values for each tower:
- based on existing file, and a suggested gain factor change, to obtain a balanced setup
+++ /dev/null
-/*
-Implemented modes:
-0 - write the same value for all towers
-1 - use individual V30 settings
-*/
-
-int
-//____________________________________________________________________
-void WriteBiasFix(const int mode = 0, const int biasSetting = 390)
-{
-
- if (mode == 0) { // fixed values
- SetAll(390);
- }
- else if (mode == 1) {
- }
-
-}
-
- gSystem->Load("AliEMCALCalibAPD_cxx");
- AliEMCALCalibAPD *calibAPD = new AliEMCALCalibAPD();
-
- calibAPD->ReadCalibAPDInfo(10000, "dilan-APD-database.csv");
- //calibAPD->ReadCalibAPDInfo(10000, "paola-APD-database.csv");
- calibAPD->WriteCalibAPDInfo("dummy.txt");
-
- int fNCalibAPD = calibAPD->GetNCalibAPD();
- AliEMCALCalibAPD::AliEMCALCalibAPDData * fData = calibAPD->GetCalibAPDData();
- for (int i=0; i<fNCalibAPD; i++) {
- cout << " i " << i
- << " fAPDNum " << fData[i].fAPDNum
- << " fSerialNum " << fData[i].fSerialNum
- << " fDarkCurrent " << fData[i].fDarkCurrent << endl;
- }
-
- /*
- // 1: create a dummy file
- calibAPD->GenerateDummyAPDInfo(nAPD);
- */
-
- /*
- // 2: test I/O
- calibAPD->ReadCalibAPDInfo(nAPD, "dummy.txt");
- calibAPD->WriteCalibAPDInfo("dummy2.txt");
- */
-
- /*
- // 3: see if it works ok if we genarate values first, and then try to read others/overwriting
- calibAPD->GenerateDummyAPDInfo(2*nAPD); // some extra APDs
- calibAPD->ReadCalibAPDInfo(nAPD, "dummy.txt");
- calibAPD->WriteCalibAPDInfo("dummy3.txt");
- */
-
- /*
- // 4: other way around from #3
- calibAPD->ReadCalibAPDInfo(nAPD, "dummy.txt");
- calibAPD->GenerateDummyAPDInfo(2*nAPD);
- calibAPD->WriteCalibAPDInfo("dummy4.txt");
- */
-
-}
-
static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
-int biasVoltage[fgkEmCalCols][fgkEmCalRows];
+Float_t biasVoltage[fgkEmCalCols][fgkEmCalRows];
//____________________________________________________________________
void WriteBiasV30(const char * inputDBName, const char * inputMapName,
/*
*/
+const int debug = 0; // 0=quiet; 1=print some parameter info
-const int kMaxHV = 395;
+const int kMaxHV = 395; // default max voltage limit; could possibly be relaxed in future
+const int kBreakDownMargin = 5; // at least 5 V away from breakDown voltage..
static const int fgkEmCalRows = 24; // number of rows per module for EMCAL
static const int fgkEmCalCols = 48; // number of columns per module for EMCAL
-int previousVoltage[fgkEmCalCols][fgkEmCalRows];
+Float_t previousVoltage[fgkEmCalCols][fgkEmCalRows];
Float_t gainFactor[fgkEmCalCols][fgkEmCalRows];
-int biasVoltage[fgkEmCalCols][fgkEmCalRows];
+Float_t biasVoltage[fgkEmCalCols][fgkEmCalRows];
//____________________________________________________________________
void WriteNewBias(const char * inputDBName, const char * inputMapName,
int icolp, irowp;
int icolg, irowg;
Float_t gFactor;
- int pVoltage;
+ Float_t pVoltage;
for (int icol=0; icol<fgkEmCalCols; icol++) {
for (int irow=0; irow<fgkEmCalRows; irow++) {
gainFactor[icol][irow],
fCalib[i].fPar[0],
fCalib[i].fPar[1],
- fCalib[i].fPar[2]);
+ fCalib[i].fPar[2],
+ fCalib[i].fBreakDown);
nFound++;
}
else { // no calib info, just use old settings
}
//____________________________________________________________________
-int CalculateTargetHV(int initHV, Float_t gainChange,
- Float_t par0, Float_t par1, Float_t par2 )
+Float_t CalculateTargetHV(Float_t initialHV, Float_t gainChange,
+ Float_t par0, Float_t par1, Float_t par2, Int_t breakDown)
{
- printf("parameters p0:%g p1:%g p2:%g\n", par0, par1, par2);
+ if (debug) { printf("parameters p0:%g p1:%g p2:%g\n", par0, par1, par2); }
// figure out what new HV should be,
// if we want to adjust the gain by some factor
- Float_t initialHV = (Float_t) initHV;
Float_t initialGain = par0 + par1 * exp(par2*initialHV);
Float_t newGain = initialGain * gainChange; // = par0 + par1 * exp(par2*newHV);
- printf("initialGain:%g newGain:%g\n", initialGain, newGain);
+ if (debug) { printf("initialGain:%g newGain:%g\n", initialGain, newGain); }
- Float_t fNewHV = -1;
+ Float_t newHV = -1;
if ( par1>0 && par2>0 ) {
- fNewHV = log ( (newGain - par0)/par1 ) / par2;
+ newHV = log ( (newGain - par0)/par1 ) / par2;
}
- // round-off
- int newHV = (int) (fNewHV + 0.5);
// check results before returning..
- if (newHV == -1) {
+ if (newHV < 0) {
// conversion failed: let's just keep the old custom value then
newHV = initHV;
}
newHV = kMaxHV;
}
+ // in case we increase the kMaxHV limit some time in the future we could
+ // also enter get close to the Hamamatsu breakdown limit - let's avoid that
+ if (newHV>breakDown) {
+ newHV = breakDown - kBreakDownMargin;
+ }
+
return newHV;
}