Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:23:56

0001 // add up to slew calibrations
0002 #include <mbd/MbdCalib.h>
0003 #include <mbd/MbdDefs.h>
0004 #include <mbd/MbdGeomV1.h>
0005 
0006 #include <TString.h>
0007 
0008 #include <fstream>
0009 
0010 R__LOAD_LIBRARY(libmbd.so)
0011 
0012 const int NPOINTS = 16000;  // number of points in correction LUT
0013 const int MINADC = 0;       // subtracted adc
0014 const int MAXADC = 15999;
0015 
0016 void addslew(const char *calfile1 = "results/0/mbd_slewcorr_pass1.calib",
0017              const char *calfile2 = "results/0/mbd_slewcorr_pass2.calib")
0018 {
0019   MbdGeom *mbdgeom = new MbdGeomV1();
0020 
0021   MbdCalib *mcal1 = new MbdCalib();
0022   mcal1->Download_SlewCorr(calfile1);
0023 
0024   MbdCalib *mcal2 = new MbdCalib();
0025   mcal2->Download_SlewCorr(calfile2);
0026 
0027   // std::cout << mcal1->get_scorr(0,100) << std::endl;
0028   // std::cout << mcal2->get_scorr(0,0) << std::endl;
0029 
0030   // Write out slew curves to temp calib file
0031   TString scorr_fname = "add_mbd_slewcorr.calib";
0032   std::cout << scorr_fname << std::endl;
0033   std::ofstream scorr_file(scorr_fname);
0034   for (int ifeech = 0; ifeech < MbdDefs::MBD_N_FEECH; ifeech++)
0035   {
0036     if (mbdgeom->get_type(ifeech) == 1)
0037     {
0038       continue;  // skip q-channels
0039     }
0040     //    int pmtch = mbdgeom->get_pmt(ifeech);
0041 
0042     scorr_file << ifeech << "\t" << NPOINTS << "\t" << MINADC << "\t" << MAXADC << std::endl;
0043     int step = (MAXADC - MINADC) / (NPOINTS - 1);
0044     // std::cout << "STEP " << step << std::endl;
0045     for (int iadc = MINADC; iadc <= MAXADC; iadc += step)
0046     {
0047       float dt1 = mcal1->get_scorr(ifeech, iadc);
0048       float dt2 = mcal2->get_scorr(ifeech, iadc);
0049       float slewcorr = dt1 + dt2;
0050       scorr_file << slewcorr << " ";
0051       if (iadc % 10 == 9)
0052       {
0053         scorr_file << std::endl;
0054       }
0055     }
0056   }
0057   scorr_file.close();
0058 }