7 #include "PixTestDacScan.hh"
25 PixTestDacScan::PixTestDacScan() :
PixTest() {
35 std::transform(parName.begin(), parName.end(), parName.begin(), ::tolower);
36 for (
unsigned int i = 0; i <
fParameters.size(); ++i) {
39 sval.erase(
remove(sval.begin(), sval.end(),
' '), sval.end());
40 if (!parName.compare(
"phmap")) {
43 fParPHmap = atoi(sval.c_str());
46 if (!parName.compare(
"ntrig")) {
47 fParNtrig = atoi(sval.c_str());
50 if (!parName.compare(
"dac")) {
54 if (!parName.compare(
"daclo")) {
55 fParLoDAC = atoi(sval.c_str());
58 if (!parName.compare(
"dachi")) {
59 fParHiDAC = atoi(sval.c_str());
62 if (!parName.compare(
"pix")) {
64 if (string::npos != s1) {
65 str1 = sval.substr(0, s1);
66 pixc = atoi(str1.c_str());
67 str2 = sval.substr(s1+1);
68 pixr = atoi(str2.c_str());
70 fPIX.push_back(make_pair(pixc, pixr));
74 fPIX.push_back(make_pair(-1, -1));
87 void PixTestDacScan::init() {
89 fDirectory = gFile->GetDirectory(fName.c_str());
100 fTestTip = string(Form(
"scan the DAC %s and determine the number of hits vs DAC value\n", fParDAC.c_str()))
102 fSummaryTip = string(
"summary plot to be implemented")
108 void PixTestDacScan::bookHist(
string ) {
114 PixTestDacScan::~PixTestDacScan() {
115 LOG(logDEBUG) <<
"PixTestDacScan dtor";
121 uint16_t FLAGS = FLAG_FORCE_MASKED;
126 map<string, TH1D*> hmap;
127 string name(fParPHmap?
"ph":
"nhits");
129 for (
unsigned int iroc = 0; iroc < rocIds.size(); ++iroc){
130 for (
unsigned int ip = 0; ip <
fPIX.size(); ++ip) {
131 hname = Form(
"%s_%s_c%d_r%d_C%d", name.c_str(), fParDAC.c_str(),
fPIX[ip].first,
fPIX[ip].second, rocIds[iroc]);
132 h1 =
bookTH1D(hname.c_str(), hname.c_str(), 256, 0., 256.);
134 setTitles(h1, Form(
"%s [DAC]", fParDAC.c_str()), (fParPHmap?
"average PH":
"readouts"));
143 LOG(logINFO) <<
"PixTestDacScan: " << fParDAC <<
"[" << fParLoDAC <<
", " << fParHiDAC <<
"]"
144 << (fParPHmap?
" average PH":
" readouts")
145 <<
", ntrig = " << fParNtrig
146 <<
", npixels = " <<
fPIX.size();
150 vector<pair<uint8_t, vector<pixel> > > rresults, results;
153 for (
unsigned int i = 0; i <
fPIX.size(); ++i) {
154 if (
fPIX[i].first > -1) {
162 if (0 == fParPHmap) {
172 LOG(logCRITICAL) <<
"problem with readout: "<< e.what() <<
" missing " << e.numberMissing <<
" events";
173 fNDaqErrors = 666666;
175 if (e.numberMissing > 10) done =
true;
177 fNDaqErrors = 666667;
178 LOG(logCRITICAL) <<
"pXar execption: "<< e.what();
181 done = (cnt>5) || done;
184 if (fNDaqErrors > 0) problems = fNDaqErrors;
185 copy(rresults.begin(), rresults.end(), back_inserter(results));
191 LOG(logDEBUG) <<
" dacscandata.size(): " << results.size();
193 for (
unsigned int iroc = 0; iroc < rocIds.size(); ++iroc){
194 for (
unsigned int i = 0; i < results.size(); ++i) {
195 pair<uint8_t, vector<pixel> > v = results[i];
198 vector<pixel> vpix = v.second;
199 for (
unsigned int ipix = 0; ipix < vpix.size(); ++ipix) {
200 if (vpix[ipix].roc() == rocIds[iroc]) {
201 hname = Form(
"%s_%s_c%d_r%d_C%d", name.c_str(), fParDAC.c_str(), vpix[ipix].column(), vpix[ipix].row(), rocIds[iroc]);
204 h->Fill(idac, vpix[ipix].value());
206 LOG(logDEBUG) <<
"XX did not find " << hname;
215 LOG(logINFO) <<
"dac scan done" << (problems > 0? Form(
" problems observed: %d", problems):
" no problems seen");
227 LOG(logDEBUG) <<
"PixTestDacScan::moduleMap histname: " << histname;
228 TH1* h0 = (*fDisplayedHist);
229 if (!h0->InheritsFrom(TH1::Class())) {
233 TH1D *h1 = (TH1D*)h0;
234 string h1name = h1->GetName();
235 string::size_type s1 = h1name.rfind(
"_c");
236 string barename = h1name.substr(0, s1);
237 LOG(logDEBUG) <<
"h1->GetName() = " << h1name <<
" -> " << barename;
243 for (
unsigned int iroc = 0; iroc < rocIds.size(); ++iroc){
245 h1 =
bookTH1D(Form(
"%s_C%d", barename.c_str(), rocIds[iroc]), Form(
"%s_C%d", barename.c_str(), rocIds[iroc]),
246 h0->GetNbinsX(), h0->GetBinLowEdge(1), h0->GetBinLowEdge(h0->GetNbinsX()+1));
247 if (0 == iroc) cycle = -1 +
histCycle(Form(
"%s_C%d", barename.c_str(), rocIds[iroc]));
249 list<TH1*>::iterator hbeg =
fHistList.begin();
250 list<TH1*>::iterator hend =
fHistList.end();
251 for (list<TH1*>::iterator il = hbeg; il != hend; ++il) {
253 hname = h->GetName();
254 if (string::npos != hname.find(Form(
"%s", barename.c_str()))) {
255 if (string::npos != hname.find(Form(
"_C%d", rocIds[iroc]))) {
256 if (string::npos != hname.find(Form(
"_V%d", cycle))) {
257 for (
int i = 1; i < h->GetNbinsX(); ++i) {
258 h1->Fill(h->GetBinCenter(i), h->GetBinContent(i));
static void replaceAll(std::string &str, const std::string &from, const std::string &to)
in str, replace all occurences of from to to
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)
int histCycle(std::string hname)
determine histogram cycle
statistics getStatistics()
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
std::vector< std::pair< uint8_t, std::vector< pixel > > > getEfficiencyVsDAC(std::string dacName, uint8_t dacMin, uint8_t dacMax, uint16_t flags, uint16_t nTriggers)
void addSelectedPixels(std::string sval)
add a selected pixel to the internal parameter list
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
virtual std::string getHistOption(TH1 *)
get the hist display options (if stored in fHistOptions)
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
TH1 * moduleMap(std::string histname)
combine all available ROC maps into a module map
void maskPixel(uint8_t column, uint8_t row, bool mask)
void update()
signal to PixTab to update the canvas
void doTest()
function connected to "DoTest" button of PixTab
pxar::pxarCore * fApi
pointer to the API
void setToolTips()
implement this to provide updated tool tips if the user changes test parameters
void init()
sets all test parameters
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter