]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
use same DAC-HV value relation as for calibrations + voltage values stored as floats...
authordsilverm <dsilverm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Oct 2008 09:15:24 +0000 (09:15 +0000)
committerdsilverm <dsilverm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 Oct 2008 09:15:24 +0000 (09:15 +0000)
EMCAL/SMcalib/AliEMCALCalibAPD.cxx
EMCAL/SMcalib/AliEMCALCalibAPD.h
EMCAL/SMcalib/AliEMCALMapAPD.cxx
EMCAL/SMcalib/DCSGenerateAPD.C
EMCAL/SMcalib/README
EMCAL/SMcalib/WriteBias.C [deleted file]
EMCAL/SMcalib/WriteBiasV30.C
EMCAL/SMcalib/WriteNewBias.C

index 84a08b1c4813bddc292d6dbaec180ed6a2aed7f0..33c19e12650c3a0a277355d3cabed1b61de0c8b8 100644 (file)
@@ -70,7 +70,7 @@ void AliEMCALCalibAPD::ReadCalibAPDInfo(Int_t nAPD, const TString &txtFileName)
   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;
index 425a90573585b8541c5ab36b95e88072a53d62b3..6ed1969159b3b848b5630bfa653c594495f2687c 100644 (file)
@@ -32,7 +32,7 @@ public:
     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     
index 8689da29c32177667f619cf8d7945e831600c28c..9fa530085f02ef003cdcbeb7d882746c420e74df 100644 (file)
@@ -66,7 +66,7 @@ void AliEMCALMapAPD::ReadMapAPDInfoStripBasis(Int_t nSM, const TString &txtFileN
   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;
@@ -136,7 +136,7 @@ void AliEMCALMapAPD::ReadMapAPDInfoSingleStripBasis(Int_t iSM, Int_t iStrip, con
 
   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;
@@ -190,7 +190,7 @@ void AliEMCALMapAPD::ReadMapAPDInfo(Int_t nSM, const TString &txtFileName)
   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;
index d44a2c0e76b8b52910cf007d9ff23efd71337836..0bdefc3455845b9e0a08e5b29fd4c97c92d66da5 100644 (file)
@@ -7,8 +7,13 @@ const int NBranch = 2; // per RCU
 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]; 
 
@@ -16,7 +21,8 @@ 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++) {
@@ -92,9 +98,6 @@ void DCSGenerateAPD(const char *inputFileName,
   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]; 
@@ -145,7 +148,7 @@ void DCSGenerateAPD(const char *inputFileName,
          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);
 
@@ -154,7 +157,7 @@ void DCSGenerateAPD(const char *inputFileName,
          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]
@@ -164,7 +167,7 @@ void DCSGenerateAPD(const char *inputFileName,
                  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
@@ -172,7 +175,7 @@ void DCSGenerateAPD(const char *inputFileName,
          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],
index af1c965810f7412b9649164a82706240adbbb14f..14b803988076f861422e0f252c9dd1395d2b1672 100644 (file)
@@ -53,7 +53,7 @@ root -b 'WriteBiasV30.C("APD-database.csv", "DummySuperModAPDMap.txt", 390, "Bia
 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
diff --git a/EMCAL/SMcalib/WriteBias.C b/EMCAL/SMcalib/WriteBias.C
deleted file mode 100644 (file)
index 479ed8e..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-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");
-  */
-  
-}
-
index 1ff95e5eba6044248f2ba0b33394f3013a26feb5..2053eb06eec920972accd3de201a86cd89b41977 100644 (file)
@@ -4,7 +4,7 @@
 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,
index cc99189b4f42536cdb2a52072e8e6ad6578f3cf8..2fd42226b86f357cd8e474f13a5f58f07994d604 100644 (file)
@@ -1,14 +1,16 @@
 /*
 */
+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,
@@ -40,7 +42,7 @@ void ReadFiles(const char * previousVoltageFileName,
   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++) {
@@ -96,7 +98,8 @@ void SetBiasVoltage(const char * inputDBName, const char * inputMapName)
                                                    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
@@ -111,28 +114,25 @@ void SetBiasVoltage(const char * inputDBName, const char * inputMapName)
 }
 
 //____________________________________________________________________
-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;
   }
@@ -141,5 +141,11 @@ int CalculateTargetHV(int initHV, Float_t gainChange,
    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;
 }