5 #include "PixTestPh.hh"
15 fParNtrig(-1), fParDAC("nada"), fParDacVal(100) {
22 PixTestPh::PixTestPh() :
PixTest() {
32 std::transform(parName.begin(), parName.end(), parName.begin(), ::tolower);
33 for (
unsigned int i = 0; i <
fParameters.size(); ++i) {
36 sval.erase(
remove(sval.begin(), sval.end(),
' '), sval.end());
37 if (!parName.compare(
"ntrig")) {
39 fParNtrig = atoi( sval.c_str() );
40 LOG(logDEBUG) <<
" setting fParNtrig ->" << fParNtrig
41 <<
"<- from sval = " << sval;
43 if (!parName.compare(
"dac")) {
46 LOG(logDEBUG) <<
" setting fParDAC ->" << fParDAC
47 <<
"<- from sval = " << sval;
50 if (!parName.compare(
"dacval")) {
52 fParDacVal = atoi(sval.c_str());
53 LOG(logDEBUG) <<
" setting fParDacVal ->" << fParDacVal
54 <<
"<- from sval = " << sval;
57 if (!parName.compare(
"pix")) {
59 if (string::npos != s1) {
60 str1 = sval.substr(0, s1);
61 pixc = atoi(str1.c_str());
62 str2 = sval.substr(s1+1);
63 pixr = atoi(str2.c_str());
65 fPIX.push_back(make_pair(pixc, pixr));
67 LOG(logDEBUG) <<
" adding to FPIX ->" << pixc <<
"/" << pixr <<
" fPIX.size() = " <<
fPIX.size() ;
71 LOG(logDEBUG) <<
" clear fPIX: " <<
fPIX.size();
81 void PixTestPh::init() {
82 fDirectory = gFile->GetDirectory(fName.c_str());
90 void PixTestPh::bookHist(
string name) {
91 LOG(logDEBUG) <<
"nothing done with " << name;
95 PixTestPh::~PixTestPh() {
105 uint16_t FLAGS = FLAG_FORCE_MASKED | FLAG_FORCE_SERIAL;
106 LOG(logDEBUG) <<
" using FLAGS = " << (int)FLAGS;
110 map<string, TH1D*> hists;
112 for (
unsigned int iroc = 0; iroc < rocIds.size(); ++iroc){
113 for (
unsigned int i = 0; i <
fPIX.size(); ++i) {
114 if (
fPIX[i].first > -1) {
115 name = Form(
"PH_c%d_r%d_C%d",
fPIX[i].first,
fPIX[i].second, rocIds[iroc]);
116 h1 =
bookTH1D(name, name, 256, 0., 256.);
118 setTitles(h1, Form(
"PH [ADC] for %s = %d", fParDAC.c_str(), fParDacVal),
"Entries/bin");
119 hists.insert(make_pair(name, h1));
129 vector<pair<uint8_t, vector<pixel> > > rresult, result;
130 for (
int ievt = 0; ievt < fParNtrig; ++ievt) {
131 for (
unsigned int i = 0; i <
fPIX.size(); ++i) {
132 if (
fPIX[i].first > -1) {
143 LOG(logCRITICAL) <<
"pXar execption: "<< e.what();
146 done = (cnt>5) || done;
149 copy(rresult.begin(), rresult.end(), back_inserter(result));
156 for (
unsigned int i = 0; i < result.size(); ++i) {
157 vector<pixel> vpix = result[i].second;
158 for (
unsigned int ipx = 0; ipx < vpix.size(); ++ipx) {
159 int roc = vpix[ipx].roc();
160 int ic = vpix[ipx].column();
161 int ir = vpix[ipx].row();
162 name = Form(
"PH_c%d_r%d_C%d", ic, ir, roc);
165 h1->Fill(vpix[ipx].value());
167 LOG(logDEBUG) <<
" histogram " << Form(
"PH_c%d_r%d_C%d", ic, ir, roc) <<
" not found";
std::vector< std::pair< uint8_t, std::vector< pixel > > > getPulseheightVsDAC(std::string dacName, uint8_t dacMin, uint8_t dacMax, uint16_t flags, uint16_t nTriggers)
bool setDAC(std::string dacName, uint8_t dacValue, uint8_t rocI2C)
void doTest()
function connected to "DoTest" button of PixTab
std::vector< std::pair< int, int > > fPIX
range of enabled pixels for time-consuming tests
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 maskAllPixels(bool mask, uint8_t rocid)
void clearSelectedPixels()
clear selected pixel list
TDirectory * fDirectory
where the root histograms will end up
void restoreDacs(bool verbose=false)
restore all DACs
void addSelectedPixels(std::string sval)
add a selected pixel to the internal parameter list
bool setTestParameter(std::string parname, std::string value)
change the local parameter
std::vector< uint8_t > getEnabledRocIDs()
void testAllPixels(bool enable)
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
void cacheDacs(bool verbose=false)
cache all DACs
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
void maskPixel(uint8_t column, uint8_t row, bool mask)
void update()
signal to PixTab to update the canvas
pxar::pxarCore * fApi
pointer to the API
void init()
sets all test parameters
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter