9 #include "TStopwatch.h"
11 #include "PixTestBBMap.hh"
14 #include "constants.h"
23 fParNtrig(-1), fParVcalS(200), fDumpAll(-1), fDumpProblematic(-1) {
26 LOG(logDEBUG) <<
"PixTestBBMap ctor(PixSetup &a, string, TGTab *)";
31 PixTestBBMap::PixTestBBMap():
PixTest() {
32 LOG(logDEBUG) <<
"PixTestBBMap ctor()";
40 std::transform(parName.begin(), parName.end(), parName.begin(), ::tolower);
43 sval.erase(
remove(sval.begin(), sval.end(),
' '), sval.end());
46 if (!parName.compare(
"ntrig")) {
51 if (!parName.compare(
"vcals")) {
57 if (!parName.compare(
"dumpall")) {
60 fDumpAll = atoi(sval.c_str());
64 if (!parName.compare(
"dumpallproblematic")) {
67 fDumpProblematic = atoi(sval.c_str());
77 void PixTestBBMap::init() {
78 LOG(logDEBUG) <<
"PixTestBBMap::init()";
80 fDirectory = gFile->GetDirectory(
"BumpBonding");
89 fTestTip = string(
"Bump Bonding Test = threshold map for CalS");
90 fSummaryTip = string(
"module summary");
95 PixTestBBMap::~PixTestBBMap() {
96 LOG(logDEBUG) <<
"PixTestBBMap dtor";
106 bigBanner(Form(
"PixTestBBMap::doTest() Ntrig = %d, VcalS = %d (high range)", fParNtrig, fParVcalS));
118 if (fDumpAll) result |= 0x20;
119 if (fDumpProblematic) result |= 0x10;
122 vector<TH1*> thrmapsCals =
scurveMaps(
"VthrComp",
"calSMap", fParNtrig, 0, 149, 50, result, 1, flag);
127 for (
unsigned int i = 0; i < thrmapsCals.size(); ++i) {
128 for (
int ix = 0; ix < thrmapsCals[i]->GetNbinsX(); ++ix) {
129 for (
int iy = 0; iy < thrmapsCals[i]->GetNbinsY(); ++iy) {
130 if (thrmapsCals[i]->GetBinContent(ix+1, iy+1) < 0) thrmapsCals[i]->SetBinContent(ix+1, iy+1, 255.);
142 string bbString(
""), bbCuts(
"");
144 int nPeaks(0), cutDead(0);
146 for (
unsigned int i = 0; i < dlist.size(); ++i) {
148 nPeaks = s.Search(h, 5,
"", 0.01);
149 LOG(logDEBUG) <<
"found " << nPeaks <<
" peaks in " << h->GetName();
150 cutDead = fitPeaks(h, s, nPeaks);
152 bbprob =
static_cast<int>(h->Integral(cutDead, h->FindBin(255)));
153 bbString += Form(
" %4d", bbprob);
154 bbCuts += Form(
" %4d", cutDead);
156 TArrow *pa =
new TArrow(cutDead, 0.5*h->GetMaximum(), cutDead, 0., 0.06,
"|>");
157 pa->SetArrowSize(0.1);
160 h->GetListOfFunctions()->Add(pa);
170 int seconds = t.RealTime();
171 LOG(logINFO) <<
"PixTestBBMap::doTest() done"
172 << (fNDaqErrors>0? Form(
" with %d decoding errors: ", static_cast<int>(fNDaqErrors)):
"")
173 <<
", duration: " << seconds <<
" seconds";
174 LOG(logINFO) <<
"number of dead bumps (per ROC): " << bbString;
175 LOG(logINFO) <<
"separation cut (per ROC): " << bbCuts;
182 int PixTestBBMap::fitPeaks(TH1D *h, TSpectrum &s,
int npeaks) {
184 Float_t *xpeaks = s.GetPositionX();
186 double lcuts[3]; lcuts[0] = lcuts[1] = lcuts[2] = 255.;
190 for (
int p = 0; p < npeaks; ++p) {
191 double xp = xpeaks[p];
199 name = Form(
"gauss_%d", p);
200 f =
new TF1(name.c_str(),
"gaus(0)", 0., 256.);
201 int bin = h->GetXaxis()->FindBin(xp);
202 double yp = h->GetBinContent(bin);
203 f->SetParameters(yp, xp, 2.);
206 peak = h->GetFunction(name.c_str())->GetParameter(1);
207 sigma = h->GetFunction(name.c_str())->GetParameter(2);
209 lcuts[0] = peak + 3*sigma;
210 if (h->Integral(h->FindBin(peak + 10.*sigma), 250) > 10.) {
211 lcuts[1] = peak + 5*sigma;
213 lcuts[1] = peak + 10*sigma;
216 lcuts[1] = peak - 3*sigma;
217 lcuts[2] = peak - sigma;
222 int startbin = (int)(0.5*(lcuts[0] + lcuts[1]));
223 int endbin = (int)(lcuts[1]);
224 if (endbin <= startbin) {
225 endbin = (int)(lcuts[2]);
226 if (endbin < startbin) {
234 for (
int i = startbin; i <= endbin; ++i) {
235 if (h->GetBinContent(i) < minval) {
236 if (1 == fittedPeaks) {
237 if (0 == h->Integral(i, i+4)) {
238 minval = h->GetBinContent(i);
244 minval = h->GetBinContent(i);
250 LOG(logDEBUG) <<
"cut for dead bump bonds: " << minbin <<
" (obtained for minval = " << minval <<
")"
251 <<
" start: " << startbin <<
" .. " << endbin
252 <<
" last peak: " << peak <<
" last sigma: " << sigma
253 <<
" lcuts[0] = " << lcuts[0] <<
" lcuts[1] = " << lcuts[1];
static void replaceAll(std::string &str, const std::string &from, const std::string &to)
in str, replace all occurences of from to to
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)
TDirectory * fDirectory
where the root histograms will end up
void setToolTips()
implement this to provide updated tool tips if the user changes test parameters
void restoreDacs(bool verbose=false)
restore all DACs
TH1D * distribution(TH2D *, int nbins, double xmin, double xmax)
creates a 1D distribution of a map
void testAllPixels(bool enable)
std::list< TH1 * >::iterator fDisplayedHist
pointer to the histogram currently displayed
void cacheDacs(bool verbose=false)
cache all DACs
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
std::vector< TH1 * > scurveMaps(std::string dac, std::string name, int ntrig=10, int daclo=0, int dachi=255, int dacsperstep=-1, int result=15, int ihit=1, int flag=FLAG_FORCE_MASKED)
void init()
sets all test parameters
virtual bool setParameter(std::string parName, std::string sval)
set the string value of a parameter
void doTest()
function connected to "DoTest" button of PixTab