11 #include "PixTestIV.hh"
37 PixTestIV::PixTestIV() :
PixTest() {}
44 std::transform(parName.begin(), parName.end(), parName.begin(), ::tolower);
45 for (
unsigned int i = 0; i <
fParameters.size(); ++i) {
48 sval.erase(
remove(sval.begin(), sval.end(),
' '), sval.end());
49 if(!parName.compare(
"voltagestart")) {
50 fParVoltageStart = atof(sval.c_str());
52 if(!parName.compare(
"voltagestop")) {
53 fParVoltageStop = atof(sval.c_str());
55 if(!parName.compare(
"voltagestep")) {
56 fParVoltageStep = fabs(atof(sval.c_str()));
58 if(!parName.compare(
"delay(seconds)")) {
59 fParDelay = atof(sval.c_str());
61 if(!parName.compare(
"port")) {
64 if(!parName.compare(
"compliance(ua)")) {
65 fParCompliance = atof(sval.c_str());
75 void PixTestIV::init() {
76 fDirectory = gFile->GetDirectory( fName.c_str() );
83 void PixTestIV::bookHist(
string ) {
88 void PixTestIV::stop() {
90 LOG(logINFO) <<
"Stop pressed. Ending test.";
95 PixTestIV::~PixTestIV() {
96 LOG(logDEBUG) <<
"PixTestIV dtor";
103 LOG(logERROR) <<
"Not built with HV supply support.";
109 int numMeasurements = ceil(fabs((fParVoltageStart - fParVoltageStop)/fParVoltageStep));
112 double vMin = min(fParVoltageStart, fParVoltageStop) - fParVoltageStep*.5;
113 double vMax = vMin + numMeasurements*fParVoltageStep;
114 h1 =
bookTH1D(
"IVcurve",
"IV curve", numMeasurements, vMin, vMax);
115 h1->SetMinimum(1.e-2);
116 h1->SetMarkerStyle(20);
117 h1->SetMarkerSize(1.3);
121 vector<double> voltageMeasurements;
122 vector<double> currentMeasurements;
123 vector<TTimeStamp> timeStamps;
124 double signedStep = (fParVoltageStart < fParVoltageStop) ? fParVoltageStep
127 if(gPad) gPad->SetLogy(
true);
129 LOG(logINFO) <<
"Starting IV curve measurement...";
130 double serialTimeout = (fParDelay > 1.0) ? fParDelay*5 : 5.0;
131 pxar::HVSupply *hv =
new pxar::HVSupply(fParPort.c_str(), serialTimeout);
132 hv->setMicroampsLimit(fParCompliance);
134 hv->sweepStart(-fParVoltageStart,-fParVoltageStop,-signedStep,fParDelay);
136 while(hv->sweepRunning()){
137 double voltSet, voltRead, current;
138 aborted = hv->sweepRead(voltSet, voltRead, current);
139 voltageMeasurements.push_back(voltRead);
140 currentMeasurements.push_back(current);
141 h1->Fill(-voltSet, -current*1E6);
145 timeStamps.push_back(ts);
147 LOG(logINFO) << Form(
"V = %4f (meas: %+7.2f) I = %4.2e uA %s",
148 voltSet, voltRead, current*1E6, ts.AsString(
"c"));
152 gSystem->ProcessEvents();
158 LOG(logWARNING) <<
"Sweep Aborted on Compliance!";
165 writeOutput(voltageMeasurements, currentMeasurements, timeStamps, aborted);
166 LOG(logINFO) <<
"PixTestIV::doTest() done ";
170 void PixTestIV::writeOutput(vector<double> &voltageMeasurements,
171 vector<double> ¤tMeasurements,
172 vector<TTimeStamp> &timeStamps,
175 OutputFile.open(Form(
"%s/ivCurve.log",
fPixSetup->getConfigParameters()->getDirectory().c_str()));
176 OutputFile <<
"# IV test from " << timeStamps[0].AsString(
"l") << endl;
177 OutputFile <<
"#Test Parameters:" << endl;
178 OutputFile <<
"# HV Supply: Keithley2410" << endl;
179 OutputFile <<
"# Voltage Start: " << fParVoltageStart << endl;
180 OutputFile <<
"# Voltage Stop: " << fParVoltageStop << endl;
181 OutputFile <<
"# Voltage Step: " << fParVoltageStep << endl;
182 OutputFile <<
"# Delay(s): " << fParDelay << endl;
183 OutputFile <<
"# Compliance(uA): " << fParCompliance << endl;
184 OutputFile <<
"#voltage(V)\tcurrent(A)\ttimestamp" << endl;
186 unsigned int numMeasurements = voltageMeasurements.size();
187 for (
unsigned int i = 0; i < numMeasurements; i++) {
188 OutputFile << Form(
"%+8.3f\t%+e\t%s", voltageMeasurements[i],
189 currentMeasurements[i],
190 timeStamps[i].AsString(
"c"))
194 OutputFile <<
"#Sweep was aborted on compliance" << endl;
196 OutputFile <<
"#Sweep completed Normally" << endl;
PixSetup * fPixSetup
all necessary stuff in one place
std::vector< std::pair< std::string, std::string > > fParameters
the parameters of this test
TDirectory * fDirectory
where the root histograms will end up
void doTest()
function connected to "DoTest" button of PixTab
std::list< TH1 * >::iterator fDisplayedHist
pointer to the histogram currently displayed
TH1D * bookTH1D(std::string sname, std::string title, int nbins, double xmin, double xmax)
book a TH1D, adding version information to the name and title
std::list< TH1 * > fHistList
list of histograms available in PixTab::next and PixTab::previous
void setTitles(TH1 *h, const char *sx, const char *sy, float size=0.05, float xoff=1.1, float yoff=1.1, float lsize=0.05, int font=42)
utility to set histogram titles
virtual void setToolTips()
implement this to provide updated tool tips if the user changes test parameters
void update()
signal to PixTab to update the canvas
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
void init()
sets all test parameters