5 #include "PixTestAlive.hh"
8 #include <TStopwatch.h>
20 LOG(logDEBUG) <<
"PixTestAlive ctor(PixSetup &a, string, TGTab *)";
25 PixTestAlive::PixTestAlive() :
PixTest() {
26 LOG(logDEBUG) <<
"PixTestAlive ctor()";
32 std::transform(parName.begin(), parName.end(), parName.begin(), ::tolower);
33 for (
unsigned int i = 0; i <
fParameters.size(); ++i) {
36 if (!parName.compare(
"ntrig")) {
37 fParNtrig =
static_cast<uint16_t
>(atoi(sval.c_str()));
40 if (!parName.compare(
"vcal")) {
41 fParVcal = atoi(sval.c_str());
54 std::transform(command.begin(), command.end(), command.begin(), ::tolower);
55 LOG(logDEBUG) <<
"running command: " << command;
56 if (!command.compare(
"masktest")) {
61 if (!command.compare(
"alivetest")) {
66 if (!command.compare(
"addressdecodingtest")) {
67 addressDecodingTest();
70 LOG(logDEBUG) <<
"did not find command ->" << command <<
"<-";
75 void PixTestAlive::init() {
76 LOG(logDEBUG) <<
"PixTestAlive::init()";
79 fDirectory = gFile->GetDirectory(fName.c_str());
89 fTestTip = string(
"send Ntrig \"calibrates\" and count how many hits were measured\n")
90 + string(
"the result is a hitmap, not an efficiency map\n")
91 + string(
"NOTE: VCAL is given in high range!")
93 fSummaryTip = string(
"all ROCs are displayed side-by-side. Note the orientation:\n")
94 + string(
"the canvas bottom corresponds to the narrow module side with the cable")
100 void PixTestAlive::bookHist(
string name) {
102 LOG(logDEBUG) <<
"nothing done with " << name;
107 PixTestAlive::~PixTestAlive() {
108 LOG(logDEBUG) <<
"PixTestAlive dtor";
119 bigBanner(Form(
"PixTestAlive::doTest()"));
122 TH1 *h1 = (*fDisplayedHist);
127 h1 = (*fDisplayedHist);
131 addressDecodingTest();
132 h1 = (*fDisplayedHist);
136 int seconds = t.RealTime();
137 LOG(logINFO) <<
"PixTestAlive::doTest() done, duration: " << seconds <<
" seconds";
143 void PixTestAlive::aliveTest() {
148 banner(Form(
"PixTestAlive::aliveTest() ntrig = %d, vcal = %d (ctrlreg = %s)",
149 static_cast<int>(fParNtrig), static_cast<int>(fParVcal), ctrlregstring.c_str()));
157 vector<TH2D*> test2 =
efficiencyMaps(
"PixelAlive", fParNtrig, FLAG_FORCE_MASKED);
158 vector<int> deadPixel(test2.size(), 0);
159 vector<int> probPixel(test2.size(), 0);
160 for (
unsigned int i = 0; i < test2.size(); ++i) {
163 for (
int ix = 0; ix < test2[i]->GetNbinsX(); ++ix) {
164 for (
int iy = 0; iy < test2[i]->GetNbinsY(); ++iy) {
165 if (test2[i]->GetBinContent(ix+1, iy+1) < fParNtrig) {
167 if (test2[i]->GetBinContent(ix+1, iy+1) < 1) {
175 copy(test2.begin(), test2.end(), back_inserter(
fHistList));
187 string deadPixelString, probPixelString;
188 for (
unsigned int i = 0; i < probPixel.size(); ++i) {
189 probPixelString += Form(
" %4d", probPixel[i]);
190 deadPixelString += Form(
" %4d", deadPixel[i]);
192 LOG(logINFO) <<
"PixTestAlive::aliveTest() done"
193 << (fNDaqErrors>0? Form(
" with %d decoding errors", static_cast<int>(fNDaqErrors)):
"");
194 LOG(logINFO) <<
"number of dead pixels (per ROC): " << deadPixelString;
195 LOG(logDEBUG) <<
"number of red-efficiency pixels: " << probPixelString;
203 void PixTestAlive::maskTest() {
210 banner(Form(
"PixTestAlive::maskTest() ntrig = %d, vcal = %d (ctrlreg = %s)",
211 static_cast<int>(fParNtrig), static_cast<int>(fParVcal), ctrlregstring.c_str()));
219 vector<TH2D*> test2 =
efficiencyMaps(
"MaskTest", fParNtrig, FLAG_FORCE_MASKED);
220 vector<int> maskPixel(test2.size(), 0);
221 for (
unsigned int i = 0; i < test2.size(); ++i) {
224 for (
int ix = 0; ix < test2[i]->GetNbinsX(); ++ix) {
225 for (
int iy = 0; iy < test2[i]->GetNbinsY(); ++iy) {
226 if (test2[i]->GetBinContent(ix+1, iy+1) > 0) {
229 if (test2[i]->GetBinContent(ix+1, iy+1) == 0) {
230 test2[i]->SetBinContent(ix+1, iy+1, 1);
232 test2[i]->SetBinContent(ix+1, iy+1, 0);
238 copy(test2.begin(), test2.end(), back_inserter(
fHistList));
248 string maskPixelString;
249 for (
unsigned int i = 0; i < maskPixel.size(); ++i) {
250 maskPixelString += Form(
" %4d", maskPixel[i]);
252 LOG(logINFO) <<
"PixTestAlive::maskTest() done"
253 << (fNDaqErrors>0? Form(
" with %d decoding errors", static_cast<int>(fNDaqErrors)):
"");
254 LOG(logINFO) <<
"number of mask-defect pixels (per ROC): " << maskPixelString;
259 void PixTestAlive::addressDecodingTest() {
265 banner(Form(
"PixTestAlive::addressDecodingTest() ntrig = %d, vcal = %d (ctrlreg = %s)",
266 static_cast<int>(fParNtrig), static_cast<int>(fParVcal), ctrlregstring.c_str()));
278 vector<TH2D*> test2 =
efficiencyMaps(
"AddressDecodingTest", fParNtrig, FLAG_CHECK_ORDER|FLAG_FORCE_MASKED);
279 vector<int> addrPixel(test2.size(), 0);
280 for (
unsigned int i = 0; i < test2.size(); ++i) {
283 for (
int ix = 0; ix < test2[i]->GetNbinsX(); ++ix) {
284 for (
int iy = 0; iy < test2[i]->GetNbinsY(); ++iy) {
285 if (test2[i]->GetBinContent(ix+1, iy+1) < 0) {
286 LOG(logDEBUG) <<
" read col/row = " << ix+1 <<
"/" << iy+1
287 <<
" address decoding error";
290 if (test2[i]->GetBinContent(ix+1, iy+1) <= 0) {
291 test2[i]->SetBinContent(ix+1, iy+1, 0);
293 test2[i]->SetBinContent(ix+1, iy+1, 1);
299 copy(test2.begin(), test2.end(), back_inserter(
fHistList));
309 string addrPixelString;
310 for (
unsigned int i = 0; i < addrPixel.size(); ++i) {
311 addrPixelString += Form(
" %4d", addrPixel[i]);
313 LOG(logINFO) <<
"PixTestAlive::addressDecodingTest() done"
314 << (fNDaqErrors>0? Form(
" with %d decoding errors", static_cast<int>(fNDaqErrors)):
"");
315 LOG(logINFO) <<
"number of address-decoding pixels (per ROC): " << addrPixelString;
std::vector< TH2D * > efficiencyMaps(std::string name, uint16_t ntrig=10, uint16_t FLAGS=FLAG_FORCE_MASKED)
returns TH2D's with hit maps
void runCommand(std::string)
allow execution of any button in the test
std::map< TH1 *, std::string > fHistOptions
options can be stored with each histogram
void doTest()
function connected to "DoTest" button of PixTab
bool setDAC(std::string dacName, uint8_t dacValue, uint8_t rocI2C)
std::vector< std::pair< std::string, std::string > > fParameters
the parameters of this test
void maskAllPixels(bool mask, uint8_t rocid)
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
TDirectory * fDirectory
where the root histograms will end up
void restoreDacs(bool verbose=false)
restore all DACs
std::vector< uint8_t > getEnabledRocIDs()
void testAllPixels(bool enable)
std::list< TH1 * >::iterator fDisplayedHist
pointer to the histogram currently displayed
virtual std::string getHistOption(TH1 *)
get the hist display options (if stored in fHistOptions)
void cacheDacs(bool verbose=false)
cache all DACs
std::string getDacsString(std::string dacName)
return from all ROCs the DAC dacName as a string
std::list< TH1 * > fHistList
list of histograms available in PixTab::next and PixTab::previous
void update()
signal to PixTab to update the canvas
pxar::pxarCore * fApi
pointer to the API
void init()
sets all test parameters
void setToolTips()
implement this to provide updated tool tips if the user changes test parameters