ScanInfo.cpp

00001 #include "ScanInfo.h"
00002 #include "Sct/SctParameters.h"
00003 #include <iostream>
00004 
00005 using namespace std;
00006 using namespace Sct;
00007 
00008 namespace SctTest {
00009     
00010 //Return cal charge in fC assuming first chip.
00011 double calcCharge(const ABCDModule& config) {
00012     return 0.0625 * config.chip[0].caldata.c_factor*config.chip[0].basic.vcal;
00013 }
00014 
00015 //Return threshold in fC assuming first chip
00016 double calcThreshold(const ABCDModule& config) {
00017     const ABCDCaldata &calPtr = config.chip[0].caldata;
00018     
00019     double v = 2.5 * config.chip[0].basic.vthr;
00020     double vv = 0
00021         ;
00022     switch(calPtr.rc_function){
00023     case 1: /* polynomial but assume linear*/
00024     return (v - calPtr.rc_params[0]) / calPtr.rc_params[1];
00025     case 2: /* grillo */
00026     vv = calPtr.rc_params[2]/(v-calPtr.rc_params[0]);
00027         return calPtr.rc_params[2]/(calPtr.rc_params[1] * sqrt(vv*vv-1));
00028     case 3: /* exp */
00029         return -calPtr.rc_params[1]* log(calPtr.rc_params[0]/(v-calPtr.rc_params[2])-1);
00030     case 4: /* linear fit */
00031         return (v - calPtr.rc_params[0]) / calPtr.rc_params[1];
00032     default:
00033         return 0;
00034     }
00035 }
00036     
00037 ThresholdScanDetails::ThresholdScanDetails(const ABCDModule& config) {
00038     //charge
00039     charge = calcCharge(config);
00040     
00041     //range - check they are all the same
00042     range = config.chip[0].basic.config.trimRange;
00043     cout << range << "  " << flush;
00044     for (int i=1; i<nChipModule; ++i) {
00045     cout << config.chip[i].basic.config.trimRange << " " << flush;
00046     if (config.chip[i].basic.config.trimRange != range) {
00047         range = -1;
00048         break;
00049     }
00050     }
00051     cout << endl << range << endl;
00052     
00053     //trims - check the first 10
00054     trims = config.chip[0].trim[0];
00055     for (int i=1; i<nChipModule; ++i) {
00056     for (int channel = 0; channel < 10; ++channel) {
00057         if (config.chip[i].trim[channel] != trims) trims = -1;
00058     }
00059     }
00060     
00061     //If trims aren't all the same, set range to -1
00062     //Fixs problem where are chips are optimally trimed in same range
00063     if (trims == -1) range = -1;
00064 }
00065 
00066 StrobeDelayScanDetails::StrobeDelayScanDetails(const ABCDModule& config) {
00067     charge = calcCharge(config);
00068     threshold = calcThreshold(config);
00069 }
00070 }

Generated on Mon Feb 6 14:01:27 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6