7 #include "PixTestDacScanThr.hh"
17 :
PixTest(a, name), fParNtrig(-1),
18 fParDAC("nada"), fParLoDAC(-1), fParHiDAC(-1),
24 for(
size_t i = 0; i < fPIX.size(); ++i )
25 LOG(logDEBUG) <<
" setting fPIX" << i
26 <<
" ->" << fPIX[i].first
27 <<
"/" << fPIX[i].second;
31 PixTestDacScanThr::PixTestDacScanThr() :
PixTest()
42 for( uint32_t i = 0; i <
fParameters.size(); ++i ) {
48 sval.erase(
remove(sval.begin(), sval.end(),
' '), sval.end());
50 if( !parName.compare(
"ntrig" ) ) {
51 fParNtrig = atoi( sval.c_str() );
52 LOG(logDEBUG) <<
" setting fParNtrig ->" << fParNtrig
53 <<
"<- from sval = " << sval;
55 if( !parName.compare(
"dac" ) ) {
57 LOG(logDEBUG) <<
" setting fParDAC ->" << fParDAC
58 <<
"<- from sval = " << sval;
60 if( !parName.compare(
"daclo" ) ) {
61 fParLoDAC = atoi(sval.c_str());
62 LOG(logDEBUG) <<
" setting fParLoDAC ->" << fParLoDAC
63 <<
"<- from sval = " << sval;
65 if( !parName.compare(
"dachi" ) ) {
66 fParHiDAC = atoi( sval.c_str() );
67 LOG(logDEBUG) <<
" setting fParHiDAC ->" << fParHiDAC
68 <<
"<- from sval = " << sval;
70 if( !parName.compare(
"cals" ) ) {
71 fParCals = atoi( sval.c_str() );
72 LOG(logDEBUG) <<
" setting fParCals ->" << fParCals
73 <<
"<- from sval = " << sval;
76 if( !parName.compare(
"pix1" ) ) {
77 s1 = sval.find(
"," );
78 if( string::npos != s1 ) {
79 string str1 = sval.substr(0, s1);
80 int pixc = atoi( str1.c_str() );
81 string str2 = sval.substr(s1+1);
82 int pixr = atoi( str2.c_str() );
83 fPIX.push_back( make_pair( pixc, pixr ) );
86 fPIX.push_back( make_pair( -1, -1 ) );
97 void PixTestDacScanThr::init()
99 fDirectory = gFile->GetDirectory(fName.c_str());
109 fTestTip = string(
"measure pixel threshold vs DAC");
110 fSummaryTip = string(
"summary plot to be implemented");
114 void PixTestDacScanThr::bookHist(
string name)
116 LOG(logDEBUG) <<
"nothing done with " << name;
120 PixTestDacScanThr::~PixTestDacScanThr()
123 std::list<TH1*>::iterator il;
126 LOG(logINFO) <<
"Write out " << (*il)->GetName();
139 LOG(logINFO) <<
"PixTestDacScanThr::doTest() DAC = " << fParDAC;
144 LOG(logINFO) <<
"ERROR: " << fParDAC <<
" is not a ROC register";
148 if( fParHiDAC > maxDac ) {
149 LOG(logINFO) << fParDAC <<
" range only " << maxDac;
153 LOG(logINFO) <<
"PixTestDacScanThr::doTest() ntrig = " << fParNtrig;
157 size_t nRocs =
fPixSetup->getConfigParameters()->getNrocs();
162 int32_t col = fPIX[fPIX.size()-1].first;
163 int32_t row = fPIX[fPIX.size()-1].second;
170 for( uint32_t roc = 0; roc < nRocs; ++roc )
176 LOG(logINFO) <<
"CtrlReg 4 (large Vcal)";
181 uint16_t flags = FLAG_RISING_EDGE;
182 if( fParCals ) flags |= FLAG_CALS;
183 LOG(logINFO) <<
"flag " << flags;
185 vector < pair < uint8_t, vector<pixel> > > result;
187 for( uint8_t idac = fParLoDAC; idac < fParHiDAC; ++idac ) {
193 pair < uint8_t, vector<pixel> > p;
202 for( uint32_t roc = 0; roc < nRocs; ++roc )
205 LOG(logINFO) <<
"back to Vcal " << int(cal);
209 LOG(logINFO) <<
"back to CtrlReg " << ctl;
217 for(
size_t roc = 0; roc < nRocs; ++roc ) {
219 h1 =
new TH1D( Form(
"PH_vs_%s_c%02d_r%02d_C%02d",
220 fParDAC.c_str(), col, row, int(roc) ),
221 Form(
"PH vs %s c%02d r%02d C%02d",
222 fParDAC.c_str(), col, row, int(roc) ),
227 setTitles( h1, Form(
"%s [DAC]", fParDAC.c_str() ),
"<PH> [ADC]" );
235 for(
size_t i = 0; i < result.size(); ++i ) {
237 int idac = result[i].first;
239 vector<pixel> vpix = result[i].second;
241 for(
size_t ipx = 0; ipx < vpix.size(); ++ipx ) {
243 uint8_t thr = (uint8_t)vpix[ipx].value();
244 if( thr == 255 )
continue;
246 uint8_t roc = vpix[ipx].roc();
249 vpix[ipx].column() == col &&
250 vpix[ipx].row() == row ) {
252 h1->Fill( idac, thr );
259 for(
size_t roc = 0; roc < nRocs; ++roc ) {
bool setDAC(std::string dacName, uint8_t dacValue, uint8_t rocI2C)
PixSetup * fPixSetup
all necessary stuff in one place
uint8_t getDACRange(std::string dacName)
void testPixel(uint8_t column, uint8_t row, bool enable)
std::vector< std::pair< std::string, std::string > > fParameters
the parameters of this test
void doTest()
function connected to "DoTest" button of PixTab
TDirectory * fDirectory
where the root histograms will end up
std::vector< pixel > getThresholdMap(std::string dacName, uint8_t dacStep, uint8_t dacMin, uint8_t dacMax, uint16_t flags, uint16_t nTriggers)
void testAllPixels(bool enable)
std::list< TH1 * >::iterator fDisplayedHist
pointer to the histogram currently displayed
std::list< TH1 * > fHistList
list of histograms available in PixTab::next and PixTab::previous
void setToolTips()
implement this to provide updated tool tips if the user changes test parameters
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
void update()
signal to PixTab to update the canvas
uint8_t getDAC(size_t rocId, std::string dacName)
pxar::pxarCore * fApi
pointer to the API
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
void init()
sets all test parameters