Pulse::Pulse(const double bx, const double ratio): _bx(bx), _ratio(ratio) { TDatime now; char fname[300]; sprintf(fname,"%s_peak",now.AsString()); _peakfunc = new TF1(fname,this,&Pulse::peakpulse,-200e-9,500e-9,2); sprintf(fname,"%s_deco",now.AsString()); _decofunc = new TF1(fname,this,&Pulse::decopulse,-200e-9,500e-9,2); _peakfunc->SetParameter(0,bx*ratio); _decofunc->SetParameter(0,bx*ratio); _peakfunc->SetNpx(50000); _decofunc->SetNpx(50000); }
void annotation(Float_t a=10, Float_t d=5, Float_t x=0, Float_t y=0, Float_t z=0) { TEveManager::Create(); // add a box in scene TEveBox* b = new TEveBox("Box", "Test Title"); b->SetMainColor(kCyan); b->SetMainTransparency(0); b->SetVertex(0, x - a, y - a, z - a); b->SetVertex(1, x - a, y + a, z - a); b->SetVertex(2, x + a, y + a, z - a); b->SetVertex(3, x + a, y - a, z - a); b->SetVertex(4, x - a, y - a, z + a); b->SetVertex(5, x - a, y + a, z + a); b->SetVertex(6, x + a, y + a, z + a); b->SetVertex(7, x + a, y - a, z + a); gEve->AddElement(b); gEve->Redraw3D(kTRUE); // add overlay text TGLViewer* v = gEve->GetDefaultGLViewer(); TDatime time; TGLAnnotation* ann = new TGLAnnotation(v, time.AsString(), 0.1, 0.9); ann->SetTextSize(0.1);// % of window diagonal // set timer to update text every second MyTimer* timer = new MyTimer(ann); timer->SetTime(1000); timer->Reset(); timer->TurnOn(); }
void TT_generator::Report_progress() { if (f_total_accepted==f_event_display || !f_keep_going) { TDatime dt; std::cout << "(" << dt.AsString() << ") total accepted: " << f_total_accepted << std::endl; f_event_display*=2; } }
//========================== //========================== void plPanitkin(TString fname="./wrk/hist/run7067154.1.hist.root", int flag=0) { gROOT -> LoadMacro("StRoot/StEEmcPool/muEztPanitkin/EEqaPresenter.h"); gROOT -> LoadMacro("StRoot/StEEmcPool/muEztPanitkin/EEqaPresenter.cxx"); gStyle->SetPalette(1,0); eemcTwMaskFile = gEnv->GetValue("OnLine.eemcMask","eemcTwMask.dat"); printf("input Histo=%s=\n",fname.Data()); fd=new TFile(fname); if(!fd->IsOpen()) { printf(" faild to open file=%s=, exit\n",fname.Data()); return; } assert(fd->IsOpen()); // j1(); return; cc=new TCanvas("pani","pani",500,510); // cc=new TCanvas("pani","pani",700,710); cc->Range(0,0,1,1); TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.); pad0->Draw(); pad0->cd(); TPaveText *pt = new TPaveText(0,0.,1,1); pt->Draw(); TDatime dt; TString txt2="P-plot, "; txt2+=fname+" "; txt2+=dt.AsString(); pt->AddText(txt2); txt2="--"; pt->AddText(txt2); cc->cd(); pd1 = new TPad("pad1", "apd1",0.0,0.0,1,.95); pd1->Draw(); printf(" Ready. Type: plTw(1) ,... plSmd(1) ,... plDSM(1) ,... plAllps() flag=%d\n",flag); if(flag==1) plTw(1); //plSummary(); // plTw(1); // pd1->Print("tw.ps"); // pd1->Print("tw.gif"); }
virtual Bool_t Notify() { // stop timer TurnOff(); // so some action here TDatime d; m_label->SetText(d.AsString()); gEve->GetDefaultGLViewer()->RequestDraw(); // start timer SetTime(1000); Reset(); TurnOn(); return true; }
void KVEventSelector::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. // // This method call the user defined EndAnalysis // where user can do what she wants // TDatime now; Info("Terminate", "Analysis ends at %s", now.AsString()); if( fCombinedOutputFile!="" ){ Info("Terminate", "combine = %s", fCombinedOutputFile.Data()); // combine histograms and trees from analysis into one file TString file1,file2; file1.Form("HistoFileFrom%s.root", ClassName()); file2.Form("TreeFileFrom%s.root", ClassName()); if(GetOutputList()->FindObject("ThereAreHistos")){ if(GetOutputList()->FindObject(file2)){ Info("Terminate", "both"); SaveHistos(); KVBase::CombineFiles(file1,file2,fCombinedOutputFile,kFALSE); } else { // no trees - just rename histo file Info("Terminate", "histo"); SaveHistos(fCombinedOutputFile); } } else if(GetOutputList()->FindObject(file2)){ // no histos - just rename tree file Info("Terminate", "tree"); gSystem->Rename(file2, fCombinedOutputFile); } else Info("Terminate", "none"); } EndAnalysis(); //user end of analysis routine }
//------------------------ TPad *makeTitle(TCanvas *c,char *core, int page) { c->Range(0,0,1,1); TPad *pad0 = new TPad("pad0", "apd0",0.0,0.95,1.,1.); pad0->Draw(); pad0->cd(); TPaveText *pt = new TPaveText(0,0.,1,1,"br"); pt->Draw(); TDatime dt; TString txt2=core; txt2+=", page="; txt2+=page; txt2+=", "; txt2+=dt.AsString(); pt->AddText(txt2); txt2="--"; pt->AddText(txt2); c->cd(); pad = new TPad("pad1", "apd1",0.0,0.0,1,.95); pad->Draw(); return pad; }
void chipSummary(const char *dirName, int chipId) { directory = TString(dirName); if (f && f->IsOpen()) f->Close(); if (f1 && f1->IsOpen()) f1->Close(); if (g && g->IsOpen()) g->Close(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitle(0); gStyle->SetStatFont(132); gStyle->SetTextFont(132); gStyle->SetLabelFont(132, "X"); gStyle->SetLabelFont(132, "Y"); gStyle->SetLabelSize(0.08, "X"); gStyle->SetLabelSize(0.08, "Y"); gStyle->SetNdivisions(6, "X"); gStyle->SetNdivisions(8, "Y"); gStyle->SetTitleFont(132); gROOT->ForceStyle(); tl = new TLatex; tl->SetNDC(kTRUE); tl->SetTextSize(0.09); ts = new TLatex; ts->SetNDC(kTRUE); ts->SetTextSize(0.08); line = new TLine; line->SetLineColor(kRed); line->SetLineStyle(kSolid); box = new TBox; box->SetFillColor(kRed); box->SetFillStyle(3002); f = new TFile(Form("%s/%s", dirName, fileName), "READ"); if (strcmp(fileName, adFileName) == 0) f1 = f; else f1 = new TFile(Form("%s/%s", dirName, adFileName), "READ"); if (strcmp(fileName, trimFileName) == 0) g = f; else g = new TFile(Form("%s/%s", dirName, trimFileName), "READ"); sprintf(fname, "%s/../../macros/criteria-full.dat", dirName); if ( !readCriteria(fname) ) { printf("\nchipSummary> ----> COULD NOT READ GRADING CRITERIA !!!"); printf("chipSummary> ----> Aborting execution of chipgSummaryPage.C ... \n\n", fileName, dirName); break; } TH1D *h1; TH2D *h2; c1 = new TCanvas("c1", "", 800, 800); c1->Clear(); c1->Divide(4,4, 0.01, 0.04); // shrinkPad(0.1, 0.1, 0.1, 0.3); FILE *sCurveFile, *phLinearFile, *phTanhFile; TString noslash(dirName); noslash.ReplaceAll("/", " "); noslash.ReplaceAll(".. ", ""); char string[200]; int pixel_alive; int nDeadPixel(0); int nIneffPixel(0); int nMaskDefect(0); int nNoisy1Pixel(0); int nDeadBumps(0); int nDeadTrimbits(0); int nAddressProblems(0); int nNoisy2Pixel(0); int nThrDefect(0); int nGainDefect(0); int nPedDefect(0); int nPar1Defect(0); int nRootFileProblems(0); int nDoubleFunctCounts(0); int nDoublePerfCounts(0); int nDoubleCounts(0); int nDoubleTrims(0); int nDoublePHs(0); int vcal = dac_findParameter(dirName, "Vcal", chipId); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 1 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Dead pixels c1->cd(1); TH2D *hpm; hpm = (TH2D*)f->Get(Form("PixelMap_C%i", chipId)); if (hpm) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { hpm->SetTitle(""); hpm->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Pixel Map"); } } } else { ++nRootFileProblems; } // -- sCurve width and noise level TH1D *hw = new TH1D("hw", "", 100, 0., 600.); TH1D *hd = new TH1D("hd", "", 100, 0., 600.); // Noise in unbonded pixel (not displayed) TH2D *ht = new TH2D("ht", "", 52, 0., 52., 80, 0., 80.); TH1D *htmp; float mN(0.), sN(0.), nN(0.), nN_entries(0.); int over(0), under(0); double htmax(255.), htmin(0.); float thr, sig; int a,b; double minThrDiff(-5.); double maxThrDiff(5.); h2 = (TH2D*)f->Get(Form("vcals_xtalk_C%i", chipId)); sprintf(string, "%s/SCurve_C%i.dat", dirName, chipId); sCurveFile = fopen(string, "r"); if (!sCurveFile) { printf("chipSummary> !!!!!!!!! ----> SCurve: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, sCurveFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(sCurveFile, "%e %e %s %2i %2i", &thr, &sig, string, &a, &b); // printf("chipSummary> sig %e thr %e\n", sig, thr); hw->Fill(sig); thr = thr / 65.; ht->SetBinContent(icol+1, irow+1, thr); if ( h2 ) { if( h2->GetBinContent(icol+1, irow+1) >= minThrDiff) { hd->Fill(sig); } } } } fclose(sCurveFile); c1->cd(2); hw->Draw(); tl->DrawLatex(0.1, 0.92, "S-Curve widths: Noise (e^{-})"); /* c1->cd(15); hd->SetLineColor(kRed); hd->Draw(); tl->DrawLatex(0.1, 0.92, "S-Curve widths of dead bumps"); if ( hd->GetEntries() > 0 ) { ts->DrawLatex(0.55, 0.82, Form("entries: %4.0f", hd->GetEntries())); ts->DrawLatex(0.55, 0.74, Form("#mu:%4.2f", hd->GetMean())); ts->DrawLatex(0.55, 0.66, Form("#sigma: %4.2f", hd->GetRMS())); } */ mN = hw->GetMean(); sN = hw->GetRMS(); nN = hw->Integral(hw->GetXaxis()->GetFirst(), hw->GetXaxis()->GetLast()); nN_entries = hw->GetEntries(); under = hw->GetBinContent(0); over = hw->GetBinContent(hw->GetNbinsX()+1); ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nN)); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.1f", mN)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.1f", sN)); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); c1->cd(3); if ( ht->GetMaximum() < htmax ) { htmax = ht->GetMaximum(); } if ( ht->GetMinimum() > htmin ) { htmin = ht->GetMinimum(); } ht->GetZaxis()->SetRangeUser(htmin,htmax); ht->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Vcal Threshold Untrimmed"); } // -- Noise level map c1->cd(4); gPad->SetLogy(1); gStyle->SetOptStat(1); float mV(0.), sV(0.), nV(0.), nV_entries(0.); over = 0.; under = 0.; if (!g->IsZombie()) { h1 = (TH1D*)g->Get(Form("VcalThresholdMap_C%iDistribution;7", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(0., 100.); h1->Draw(); mV = h1->GetMean(); sV = h1->GetRMS(); nV = h1->Integral(h1->GetXaxis()->GetFirst(), h1->GetXaxis()->GetLast()); nV_entries = h1->GetEntries(); under = h1->GetBinContent(0); over = h1->GetBinContent(h1->GetNbinsX()+1); } else { ++nRootFileProblems; mV = 0.; sV = 0.; } ts->DrawLatex(0.15, 0.82, Form("N: %4.0f", nV)); ts->DrawLatex(0.15, 0.74, Form("#mu: %4.1f", mV)); ts->DrawLatex(0.15, 0.66, Form("#sigma: %4.1f", sV)); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); } tl->DrawLatex(0.1, 0.92, "Vcal Threshold Trimmed"); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 2 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Bump Map TH2D *hbm; c1->cd(5); gStyle->SetOptStat(0); hbm = (TH2D*)f->Get(Form("vcals_xtalk_C%i", chipId)); if (hbm) { h2->SetTitle(""); h2->GetZaxis()->SetRangeUser(minThrDiff, maxThrDiff); h2->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Bump Bonding Problems"); } else { ++nRootFileProblems; } // -- Bump Map c1->cd(6); gPad->SetLogy(1); //gStyle->SetOptStat(1); h1 = (TH1D*)f->Get(Form("vcals_xtalk_C%iDistribution", chipId)); if (h1) { h1->SetTitle(""); h1->GetXaxis()->SetRangeUser(-50., 50.); h1->GetYaxis()->SetRangeUser(0.5, 5.0*h1->GetMaximum()); h1->DrawCopy(); tl->DrawLatex(0.1, 0.92, "Bump Bonding"); } else { ++nRootFileProblems; } // -- Trim bits int trimbitbins(3); c1->cd(7); gPad->SetLogy(1); h1 = (TH1D*)f->Get(Form("TrimBit14_C%i", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(0., 60.); h1->SetMinimum(0.5); h1->Draw(""); tl->DrawLatex(0.1, 0.92, "Trim Bit Test"); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit13_C%i", chipId)); if (h1) { h1->SetLineColor(kRed); h1->Draw("same"); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit11_C%i", chipId)); if (h1) { h1->SetLineColor(kBlue); h1->Draw("same"); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit7_C%i", chipId)); if (h1) { h1->SetLineColor(kGreen); h1->Draw("same"); } else { ++nRootFileProblems; } // -- For numerics and titels see at end // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 3 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Address decoding // -------------------- TH2D *ham; ham = (TH2D*)f1->Get(Form("AddressDecoding_C%i", chipId)); c1->cd(9); gStyle->SetOptStat(0); if (ham) { ham->SetTitle(""); ham->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Address decoding"); } else { ++nRootFileProblems; } // -- Address levels c1->cd(10); gPad->SetLogy(1); h1 = (TH1D*)f1->Get(Form("AddressLevels_C%i", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(-1500., 1500.); h1->Draw(); tl->DrawLatex(0.1, 0.92, "Address Levels"); } else { ++nRootFileProblems; } // -- PHCalibration: Linear Fit (Gain & Pedesdtal) // ----------------------------------------------- TH1D *hg = new TH1D("hg", "", 300, -2.0, 5.5); TH2D *hgm = new TH2D("hgm", "", 52, 0., 52., 80, 0., 80.); TH1D *hp = new TH1D("hp", "", 900, -300., 600.); hp->StatOverflows(kTRUE); TH1D *rp = new TH1D("rp", "", 900, -300., 600.); rp->StatOverflows(kFALSE); TH1D *htmp; float par0, par1, par2, par3, par4, par5; // Parameters of Vcal vs. Pulse Height Fit float mG(0.), sG(0.), nG(0.), nG_entries(0.); float mP(0.), sP(0.), nP(0.), nP_entries(0.); over = 0.; under = 0.; float ped, gain; int a,b; int mPbin(0), xlow(-100), xup(255), extra(0); // for restricted RMS float pedMin(0), pedMax(1000); double integral(0.); sprintf(string, "%s/phCalibrationFit_C%i.dat", dirName, chipId); phLinearFile = fopen(string, "r"); if (!phLinearFile) { printf("chipSummary> !!!!!!!!! ----> phCal: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, phLinearFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(phLinearFile, "%e %e %e %e %e %e %s %2i %2i", &par0, &par1, &par2, &par3, &par4, &par5, string, &a, &b); if (par2 != 0.) { // dead pixels have par2 == 0. gain = 1./par2; ped = par3; hp->Fill(ped); hg->Fill(gain); hgm->SetBinContent(icol + 1, irow + 1, gain); } } } fclose(phLinearFile); // -- Gain c1->cd(11); mG = hg->GetMean(); sG = hg->GetRMS(); nG = hg->Integral(hg->GetXaxis()->GetFirst(), hg->GetXaxis()->GetLast()); nG_entries = hg->GetEntries(); under = hg->GetBinContent(0); over = hg->GetBinContent(hp->GetNbinsX()+1); gPad->SetLogy(1); hg->GetYaxis()->SetRangeUser(0.5, 5.0*hg->GetMaximum()); hg->Draw(); tl->DrawLatex(0.1, 0.92, "PH Calibration: Gain (ADC/DAC)"); if ( hg->GetMean() > 1.75 ) { ts->DrawLatex(0.15, 0.80, Form("N: %4.0f", nG)); ts->DrawLatex(0.15, 0.72, Form("#mu: %4.2f", mG)); ts->DrawLatex(0.15, 0.64, Form("#sigma: %4.2f", sG)); } else { ts->DrawLatex(0.65, 0.80, Form("N: %4.0f", nG)); ts->DrawLatex(0.65, 0.72, Form("#mu: %4.2f", mG)); ts->DrawLatex(0.65, 0.64, Form("#sigma: %4.2f", sG)); } if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); c1->cd(15); hgm->Draw("colz"); tl->DrawLatex(0.1, 0.92, "PH Calibration: Gain (ADC/DAC)"); // -- Pedestal c1->cd(12); mP = hp->GetMean(); sP = hp->GetRMS(); nP = hp->Integral(hp->GetXaxis()->GetFirst(), hp->GetXaxis()->GetLast()); nP_entries = hp->GetEntries(); if ( nP > 0 ) { // -- restricted RMS integral = 0.; mPbin = -1000; xlow = -1000; xup = 1000; over = 0.; under = 0.; mPbin = hp->GetXaxis()->FindBin(mP); for (int i = 0; integral < pedDistr; i++) { xlow = mPbin-i; xup = mPbin+i; integral = hp->Integral(xlow, xup)/nP; } extra = xup - xlow; } else { xlow = -300; xup = 600; extra = 0; over = 0.; under = 0.; } under = hp->Integral(0, xlow - extra); over = hp->Integral(xup + 1.5*extra, hp->GetNbinsX()); hp->GetXaxis()->SetRange(xlow - extra, xup + 1.5*extra); nP = hp->Integral(hp->GetXaxis()->GetFirst(), hp->GetXaxis()->GetLast()); pedMin = hp->GetBinCenter(xlow-extra); pedMax = hp->GetBinCenter(xup+1.5*extra); cout<< " ========> Ped min " << pedMin << " Ped max " << pedMax << ", over: " << over << " under: " << under << endl; hp->DrawCopy(); rp->Add(hp); rp->GetXaxis()->SetRange(xlow, xup); mP = rp->GetMean(); sP = rp->GetRMS(); // box->DrawBox( rp->GetBinCenter(xlow), 0, rp->GetBinCenter(xup), 1.05*rp->GetMaximum()); rp->SetFillColor(kRed); rp->SetFillStyle(3002); rp->Draw("same"); line->DrawLine(rp->GetBinCenter(xlow), 0, rp->GetBinCenter(xlow), 0.6*rp->GetMaximum()); line->DrawLine(rp->GetBinCenter(xup), 0, rp->GetBinCenter(xup), 0.6*rp->GetMaximum()); tl->DrawLatex(0.1, 0.92, "PH Calibration: Pedestal (DAC)"); if ( hp->GetMean() < 126. ) { ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nP)); ts->SetTextColor(kRed); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.1f", mP)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.1f", sP)); } else { ts->DrawLatex(0.16, 0.82, Form("N: %4.0f", nP)); ts->SetTextColor(kRed); ts->DrawLatex(0.16, 0.74, Form("#mu: %4.1f", mP)); ts->DrawLatex(0.16, 0.66, Form("#sigma: %4.1f", sP)); } if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); ts->SetTextColor(kBlack); } // -- PHCalibration: Tanh Fit (Parameter1) // ---------------------------------------- c1->cd(11); over = 0.; under = 0.; float nPar1(0.), nPar1_entries(0.), mPar1(0.), sPar1(0.); TH1D *hPar1 = new TH1D("par1", "", 350, -1., 6.); sprintf(string, "%s/phCalibrationFitTan_C%i.dat", dirName, chipId); phTanhFile = fopen(string, "r"); if (!phTanhFile) { printf("chipSummary> !!!!!!!!! ----> phCal: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, phTanhFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(phTanhFile, "%e %e %e %e %s %2i %2i", &par0, &par1, &par2, &par3, string, &a, &b); hPar1->Fill(par1); } } fclose(phTanhFile); // -- Parameter 1 hPar1->SetLineColor(kBlue); hPar1->Draw("same"); mPar1 = hPar1->GetMean(); sPar1 = hPar1->GetRMS(); nPar1 = hPar1->Integral(hPar1->GetXaxis()->GetFirst(), hPar1->GetXaxis()->GetLast()); nPar1_entries = hPar1->GetEntries(); under = hPar1->GetBinContent(0); over = hPar1->GetBinContent(hPar1->GetNbinsX()+1); ts->SetTextColor(kBlue); if ( hg->GetMean() > 1.75 ) { ts->DrawLatex(0.15, 0.40, "Par1:"); ts->DrawLatex(0.15, 0.30, Form("N: %4.0f", nPar1)); ts->DrawLatex(0.15, 0.22, Form("#mu: %4.2f", mPar1)); ts->DrawLatex(0.15, 0.14, Form("#sigma: %4.2f", sPar1)); } else { ts->DrawLatex(0.65, 0.40, "Par1:"); ts->DrawLatex(0.65, 0.30, Form("N: %4.0f", nPar1)); ts->DrawLatex(0.65, 0.22, Form("#mu: %4.2f", mPar1)); ts->DrawLatex(0.65, 0.14, Form("#sigma: %4.2f", sPar1)); } if ( under ) ts->DrawLatex(0.15, 0.48, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.48, Form("%i =>", over )); ts->SetTextColor(kBlack); } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 4 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Trim Bits // ---------- TH2D *htm = new TH2D("htm", "", 80, 0., 80., 52, 0., 52.); c1->cd(13); gStyle->SetOptStat(0); h2 = (TH2D*)f->Get(Form("TrimMap_C%i;8", chipId)); if (h2) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { htm->SetBinContent(irow+1, icol+1, h2->GetBinContent(icol+1, irow+1)); } } h2->SetTitle(""); h2->GetZaxis()->SetRangeUser(0., 16.); h2->Draw("colz"); } else { ++nRootFileProblems; } tl->DrawLatex(0.1, 0.92, "Trim Bits"); FILE *tCalFile; sprintf(string, "%s/../T-calibration/TemperatureCalibration_C%i.dat", dirName, chipId); tCalFile = fopen(string, "r"); char tCalDir[200]; sprintf(tCalDir, "%s/../T-calibration", dirName); if ( tCalFile ) { analyse(tCalDir, chipId); } else { c1->cd(14); TGraph *graph = (TGraph*)f->Get(Form("TempCalibration_C%i", chipId)); if ( graph ) { graph->Draw("A*"); } else { ++nRootFileProblems; } tl->DrawLatex(0.1, 0.92, "Temperature calibration"); } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Count defects and double counting // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% float fl0, fl1, fl2, fl3, fl4, fl5, tmp; int i1, i2; char hname[200]; // TH2D *get = 0, *hget = 0, *htb0 = 0, *htb1 = 0, *htb2 = 0, *htb3 = 0, *htb4 = 0; // for (int i = 1; i < 6; ++i) { // get = (TH2D*)f->Get(Form("CalThresholdMap_C%i;%i", chipId, i)); // if (get) { // hget = (TH2D*)get->Clone(); // hget->SetName(Form("TB0C%i", i)); // if (i == 1) htb0 = hget; // if (i == 2) htb1 = hget; // if (i == 3) htb2 = hget; // if (i == 4) htb3 = hget; // if (i == 5) htb4 = hget; // } // } TH2D *htb[5]; for (int i = 0; i < 5; ++i) { htb[i] = (TH2D*)f->Get(Form("CalThresholdMap_C%i;%i", chipId, i+1)); htb[i]->SetName(Form("tbC%i%i", chipId, i+1)); } TH2D *htthr = 0; htthr = (TH2D*)f->Get(Form("VcalThresholdMap_C%d;8", chipId)); sprintf(string, "%s/SCurve_C%i.dat", dirName, chipId); sCurveFile = fopen(string, "r"); sprintf(string, "%s/phCalibrationFit_C%i.dat", dirName, chipId); phLinearFile = fopen(string, "r"); sprintf(string, "%s/phCalibrationFitTan_C%i.dat", dirName, chipId); phTanhFile = fopen(string, "r"); if (sCurveFile) for (int i = 0; i < 2; i++) fgets(string, 200, sCurveFile); if (phLinearFile) for (int i = 0; i < 2; i++) fgets(string, 200, phLinearFile); if (phTanhFile) for (int i = 0; i < 2; i++) fgets(string, 200, phTanhFile); int px_counted = 0; int px_funct_counted = 0; int px_perf_counted = 0; int trim_counted = 0; int ph_counted = 0; float tb_diff = 0; float tb, tb0; for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { pixel_alive = 1; px_funct_counted = 0; px_perf_counted = 0; px_counted = 0; trim_counted = 0; ph_counted = 0; // -- Pixel alive if (hpm && hpm->GetBinContent(icol+1, irow+1) == 0) { pixel_alive = 0; ++nDeadPixel; cout << Form("chipSummary> dead pixel %3d %3d: %7.5f", icol, irow, hpm->GetBinContent(icol+1, irow+1)) << endl; } if (hpm && hpm->GetBinContent(icol+1,irow+1) > 10) { ++nNoisy1Pixel; px_counted = 1; px_funct_counted = 1;} if (hpm && hpm->GetBinContent(icol+1, irow+1) < 0) { ++nMaskDefect; px_counted = 1; px_funct_counted = 1;} if (hpm && (hpm->GetBinContent(icol+1, irow+1) < 10) && (hpm->GetBinContent(icol+1, irow+1) > 0) ) { ++nIneffPixel; px_counted = 1; px_funct_counted = 1;} // -- Bump bonding if ( pixel_alive && hbm ) { if ( hbm->GetBinContent(icol+1, irow+1) >= minThrDiff ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_funct_counted ) nDoubleFunctCounts++; px_funct_counted = 1; ++nDeadBumps; cout << Form("chipSummary> bump defect %3d %3d: %7.5f", icol, irow, hbm->GetBinContent(icol+1, irow+1)) << endl; } } // -- Trim bits 1 - 4 if ( pixel_alive && htb[0] ) { tb0 = htb[0]->GetBinContent(icol+1, irow+1); for ( int i = 1; i <= 4; i++ ) { if ( htb[i] ) { tb = htb[i]->GetBinContent(icol+1, irow+1); tb_diff = TMath::Abs(tb-tb0); if (tb_diff <= 2) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_funct_counted ) nDoubleFunctCounts++; px_funct_counted = 1; if ( trim_counted ) nDoubleTrims++; trim_counted = 1; ++nDeadTrimbits; cout << Form("chipSummary> trim bit defect %3d %3d: %4.2f", icol, irow, tb_diff) << endl; } } } } // -- Address decoding if (pixel_alive && ham) { if( ham->GetBinContent(icol+1, irow+1) < 1 ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_funct_counted ) nDoubleFunctCounts++; px_funct_counted = 1; ++nAddressProblems; cout << Form("chipSummary> address problem %3d %3d: %7.5f", icol, irow, ham->GetBinContent(icol+1, irow+1)) << endl; } } // -- Threshold if (pixel_alive && htthr) { if ( TMath::Abs(htthr->GetBinContent(icol+1, irow+1) - vcalTrim) > tthrTol ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; ++nThrDefect; cout << Form("chipSummary> threshold problem %3d %3d: %7.5f", icol, irow, htthr->GetBinContent(icol+1, irow+1)) << endl; } } // -- Noise fscanf(sCurveFile, "%e %e %s %2i %2i", &fl1, &fl2, string, &i1, &i2); if (pixel_alive) { if ( (fl2 < noiseMin) || (fl2 > noiseMax) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; ++nNoisy2Pixel; cout << Form("chipSummary> noise defect %3d %3d: %7.5f (%2i %2i)", icol, irow, fl2, i1, i2) << endl; } } // -- Gain & Pedestal fscanf(phLinearFile, "%e %e %e %e %e %e %s %2i %2i", &fl0, &fl1, &fl2, &fl3, &fl4, &fl5, string, &i1, &i2); if (pixel_alive) { if (fl2 != 0) gain = 1./fl2; ped = fl3; if ( (gain < gainMin) || (gain > gainMax) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; if ( ph_counted ) nDoublePHs++; ph_counted = 1; ++nGainDefect; cout << Form("chipSummary> gain defect %3d %3d: %7.5f (%2i %2i)", icol, irow, gain, i1, i2) << endl; } if ( (ped < pedMin) || (ped > pedMax) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; if ( ph_counted ) nDoublePHs++; ph_counted = 1; ++nPedDefect; cout << Form("chipSummary> pedestal defect %3d %3d: %7.5f (%2i %2i)", icol, irow, ped, i1, i2) << endl; } } // -- Par1 fscanf(phTanhFile, "%e %e %e %e %s %2i %2i", &fl0, &fl1, &fl2, &fl3, string, &i1, &i2); if (pixel_alive && phTanhFile) { if ( (fl1 < par1Min) || (fl1 > par1Max) ) { if ( px_counted ) nDoubleCounts++; px_counted = 1; if ( px_perf_counted ) nDoublePerfCounts++; px_perf_counted = 1; if ( ph_counted ) nDoublePHs++; ph_counted = 1; ++nPar1Defect; cout << Form("chipSummary> par1 defect %3d %3d: %7.5f (%2i %2i)", icol, irow, par1, i1, i2) << endl; } } } } fclose(sCurveFile); fclose(phLinearFile); fclose(phTanhFile); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Numerics and Titles // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Compute the final verdict on this chip //?? FIXME (below is pure randomness) float finalVerdict(0); if (nDeadTrimbits > 0) finalVerdict += 1; if (nDeadPixel > 0) finalVerdict += 10; if (nNoisy1Pixel > 0) finalVerdict += 10; if (nAddressProblems > 0) finalVerdict += 10; if (nDeadBumps > 0) finalVerdict += 100; if (nNoisy2Pixel > 0) finalVerdict += 1000; if (nThrDefect > 0) finalVerdict += 10000; if (nGainDefect > 0) finalVerdict += 100000; if (nPedDefect > 0) finalVerdict += 100000; if (nPar1Defect > 0) finalVerdict += 100000; // -- Defects c1->cd(8); tl->SetTextSize(0.10); tl->SetTextFont(22); double y = 0.98; y -= 0.11; tl->DrawLatex(0.1, y, "Summary"); // tl->DrawLatex(0.6, y, Form("%06d", finalVerdict)); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.11; tl->DrawLatex(0.1, y, Form("Dead Pixels: ")); tl->DrawLatex(0.7, y, Form("%4d", nDeadPixel)); // y -= 0.10; // tl->DrawLatex(0.1, y, Form("Noisy Pixels 1: ")); // tl->DrawLatex(0.7, y, Form("%4d", nNoisy1Pixel)); y -= 0.10; tl->DrawLatex(0.1, y, "Mask defects: "); tl->DrawLatex(0.7, y, Form("%4d", nMaskDefect)); y -= 0.10; tl->DrawLatex(0.1, y, "Dead Bumps: "); tl->DrawLatex(0.7, y, Form("%4d", nDeadBumps)); y -= 0.10; tl->DrawLatex(0.1, y, "Dead Trimbits: "); tl->DrawLatex(0.7, y, Form("%4d", nDeadTrimbits)); y -= 0.10; tl->DrawLatex(0.1, y, "Address Probl: "); tl->DrawLatex(0.7, y, Form("%4d", nAddressProblems)); y -= 0.10; tl->DrawLatex(0.1, y, Form("Noisy Pixels 2: ")); tl->DrawLatex(0.7, y, Form("%4d", nNoisy2Pixel)); y -= 0.10; tl->DrawLatex(0.1, y, Form("Trim Probl.: ")); tl->DrawLatex(0.7, y, Form("%4d", nThrDefect)); y -= 0.10; tl->DrawLatex(0.1, y, Form("PH defects: ")); tl->DrawLatex(0.5, y, Form("%4d/", nGainDefect)); tl->SetTextColor(kRed); tl->DrawLatex(0.6, y, Form("%4d/",nPedDefect)); tl->SetTextColor(kBlack); tl->SetTextColor(kBlue); tl->DrawLatex(0.7, y, Form("%4d",nPar1Defect)); tl->SetTextColor(kBlack); // y -= 0.10; // tl->DrawLatex(0.1, y, Form("Par1 defect: ")); // tl->DrawLatex(0.7, y, Form("%4d", nPar1Defect)); // -- Operation Parameters c1->cd(16); y = 0.92; tl->SetTextSize(0.10); tl->SetTextFont(22); y -= 0.11; tl->DrawLatex(0.1, y, Form("Op. Parameters")); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.11; int vana(-1.); vana = dac_findParameter(dirName, "Vana", chipId); tl->DrawLatex(0.1, y, "VANA: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3i DAC", vana)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int caldel(-1.); caldel = dac_findParameter(dirName, "CalDel", chipId); tl->DrawLatex(0.1, y, "CALDEL: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", caldel)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int vthrcomp(-1.); vthrcomp = dac_findParameter(dirName, "VthrComp", chipId); tl->DrawLatex(0.1, y, "VTHR: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", vthrcomp)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int vtrim(-1.); vtrim = dac_findParameter(dirName, "Vtrim", chipId); tl->DrawLatex(0.1, y, "VTRIM: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", vtrim)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int ibias(-1.); ibias = dac_findParameter(dirName, "Ibias_DAC", chipId); tl->DrawLatex(0.1, y, "IBIAS_DAC: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", ibias)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int voffset(-1.); voffset = dac_findParameter(dirName, "VoffsetOp", chipId); tl->DrawLatex(0.1, y, "VOFFSETOP: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", voffset)); else tl->DrawLatex(0.7, y, "N/A"); // -- Page title c1->cd(0); tl->SetTextSize(0.04); tl->SetTextFont(22); tl->DrawLatex(0.02, 0.97, Form("%s (C%i)", noslash.Data(), chipId)); TDatime date; tl->SetTextSize(0.02); tl->DrawLatex(0.75, 0.97, Form("%s", date.AsString())); c1->SaveAs(Form("%s/chipSummary_C%i.ps", dirName, chipId)); c1->SaveAs(Form("%s/C%i.png", dirName, chipId)); // -- Dump into logfile ofstream OUT(Form("%s/summary_C%i.txt", dirName, chipId)); OUT << "nDeadPixel: " << nDeadPixel << endl; OUT << "nNoisy1Pixel: " << nNoisy1Pixel << endl; OUT << "nDeadTrimbits: " << nDeadTrimbits << endl; OUT << "nDeadBumps: " << nDeadBumps << endl; OUT << "nMaskDefect: " << nMaskDefect << endl; OUT << "nAddressProblems: " << nAddressProblems << endl; OUT << "nNoisy2Pixel: " << nNoisy2Pixel << endl; OUT << "nTThrDefect: " << nThrDefect << endl; OUT << "nGainDefect: " << nGainDefect << endl; OUT << "nPedDefect: " << nPedDefect << endl; OUT << "nParDefect: " << nPar1Defect << endl; OUT << "nDoubleCounts: " << nDoubleCounts << endl; OUT << "nDoubleFunctCounts: " << nDoubleFunctCounts << endl; OUT << "nDoublePerfCounts: " << nDoublePerfCounts << endl; OUT << "nDoubleTrims: " << nDoubleTrims << endl; OUT << "nDoublePHs: " << nDoublePHs << endl; OUT << "nRootFileProblems: " << nRootFileProblems << endl; OUT << "SCurve " << nN_entries << " " << mN << " " << sN << endl; OUT << "Threshold " << nV_entries << " " << mV << " " << sV << endl; OUT << "Gain " << nG_entries << " " << mG << " " << sG << endl; OUT << "Pedestal " << nP_entries << " " << mP << " " << sP << endl; OUT << "Parameter1 " << nPar1_entries << " " << mPar1 << " " << sPar1 << endl; OUT.close(); }
// main method void LEDRef_evtdis(const int runno = 615, const int gainv = 0, /*0=low, 1=high*/ const int evtnum= -10, int ymax=1023, // set the scale of plots const int delay = 1) // -1=no delay, wait for input, X>=0 => sleep aprox. X sec. after making plot { // set ranges to plot const int strip_f = 0; // first const int strip_l = NSTRIPS - 1; const int nsamples = 65; // number of ADC time samples per channel and event const int saveplot = 0; const int numbering = 1; // 0: no numbering, 1: nubering on each plot const int dofit = 0; // 0: no fit, 1: try to fit the spectra const int debug = 0; const float gammaN = 2; // end of setup // Assume we are just interested in the 1st segment, _0.root below for fname* Char_t fname[256]; sprintf(fname, "/local/data/Run_%09d.Seq_1A.Stream_0.root",runno); cout << "TOTCHAN " << TOTCHAN << endl; // set up a raw reader of the data AliRawReader *rawReader = NULL; rawReader = new AliRawReaderRoot(fname); AliCaloRawStream *in = NULL; in = new AliCaloRawStream(rawReader,"EMCAL"); // set up histograms TH1F *hfit[TOTCHAN]; TF1 *f1[TOTCHAN]; char ch_label[TOTCHAN][100]; char buff1[100]; char name[80]; for(int i=0; i<TOTCHAN; i++) { sprintf(buff1,"hfit_%d",i); hfit[i] = new TH1F(buff1,"hfit", nsamples , -0.5, nsamples - 0.5); hfit[i]->SetDirectory(0); sprintf(name,"f1_%d",i); f1[i] = new TF1(name,fitfun,0,70,5); f1[i]->SetLineWidth(2); f1[i]->SetLineColor(2); // int idx = istrip + NSTRIPS * gain; // encoding used later int gain = i / (NSTRIPS); int istrip = i % NSTRIPS; sprintf(ch_label[i], "Strip%02d", istrip); } TCanvas *cc1 = new TCanvas("cc1","3 columns of 8 strips each",600,800); int numcol = NSETS; int numrow = NSTRIPS_IN_SET; cc1->Divide(numcol, numrow); TText *t = new TText; t->SetTextSize(0.17); int clr[2] = {4,2}; // colors // figure out which events we should look at int firstevent = evtnum; int lastevent = evtnum; if (evtnum < 0) { // get a bunch of events firstevent = 0; lastevent = - evtnum; } if (evtnum == 0) { // get all events firstevent = 0; lastevent = 1000000; } Int_t iev =0; AliRawEventHeaderBase *aliHeader=NULL; while ( rawReader->NextEvent() && iev < firstevent) { aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); iev++; } // loop over selected events while ( rawReader->NextEvent() && iev <= lastevent) { aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); int runNumber = aliHeader->Get("RunNb"); cout << "Found run number " << runNumber << endl; // reset histograms for(int i=0; i<TOTCHAN; i++) { hfit[i]->Reset(); } // get events (the "1" ensures that we actually select all events for now) if ( 1 || aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent ) { const UInt_t * evtId = aliHeader->GetP("Id"); int evno_raw = (int) evtId[0]; int timestamp = aliHeader->Get("Timestamp"); cout << " evno " << evno_raw << " size " << aliHeader->GetEventSize() << " type " << aliHeader->Get("Type") << " type name " << aliHeader->GetTypeName() << " timestamp " << timestamp << endl; /// process_event stream while ( in->Next() ) { int strip = in->GetColumn(); int gain = in->GetRow(); if (in->IsLEDMonData()) { int idx = strip + NSTRIPS*gain; //cout << "hist idx " << idx << endl; if (idx < 0 || idx > TOTCHAN) { cout << "Hist idx out of range: " << idx << endl; } else { // reasonable range of idx hfit[idx]->SetBinContent(in->GetTime(), in->GetSignal()); } } // LED Ref data only } // Raw data read // Next: let's actually plot the data.. for (Int_t strip = strip_f; strip <= strip_l; strip++) { int idx = strip + NSTRIPS*gainv; // which set/column does the strip belong in int iset = strip / NSTRIPS_IN_SET; int within_set = strip % NSTRIPS_IN_SET; // on which pad should we plot it? int pad_id = (NSTRIPS_IN_SET-1-within_set)*NSETS + iset + 1; cout << "strip " << strip << ". set="<< iset << ", within_set=" << within_set << ", pad=" << pad_id << endl; cc1->cd(pad_id); hfit[idx]->SetTitle(""); hfit[idx]->SetFillColor(5); hfit[idx]->SetMaximum(ymax); hfit[idx]->SetMinimum(0); // we may or may not decide to fit the data if (dofit) { f1[i]->SetParameter(0, 0); // initial guess; zero amplitude :=) hfit[idx]->Fit(f1[i]); } hfit[idx]->Draw(); if( numbering ) { t->SetTextColor(clr[gainv]); t->DrawTextNDC(0.65,0.65,ch_label[idx]); } } // add some extra text on the canvas // print a box showing run #, evt #, and timestamp cc1->cd(); // first draw transparent pad TPad *trans = new TPad("trans","",0,0,1,1); trans->SetFillStyle(4000); trans->Draw(); trans->cd(); // then draw text TPaveText *label = new TPaveText(.2,.11,.8,.14,"NDC"); // label->Clear(); label->SetBorderSize(1); label->SetFillColor(0); label->SetLineColor(clr[gainv]); label->SetTextColor(clr[gainv]); //label->SetFillStyle(0); TDatime d; d.Set(timestamp); sprintf(name,"Run %d, Event %d, Hist Max %d, %s",runno,iev,ymax,d.AsString()); label->AddText(name); label->Draw(); cc1->Update(); cout << "Done" << endl; // some shenanigans to hold the plotting, if requested if (firstevent != lastevent) { if (delay == -1) { // wait for character input before proceeding cout << " enter y to proceed " << endl; char dummy[2]; cin >> dummy; cout << " read " << dummy << endl; if (strcmp(dummy, "y")==0) { cout << " ok, continuing with event " << iev+1 << endl; } else { cout << " ok, exiting " << endl; //exit(1); } } else { cout << "Sleeping for " << delay * 500 << endl; gSystem->Sleep(delay * 500); } } // save plot, if setup/requested to do so char plotname[100]; if (saveplot==1) { sprintf(plotname,"Run_%d_LEDRef_Ev%d_Gain%d_MaxHist%d.gif", runno,iev,gainv,ymax); cout <<"SAVING plot:"<< plotname << endl; cc1->SaveAs(plotname); } } // event selection
void ParameterCache::cacheParameters(MethodAbsScan *scanner, TString fileName){ int totalCachedPoints=0; // cache default solutions // if ( m_arg->debug ) cout << "ParameterCache::cacheParameters() : "; cout << "saving parameters to: " << fileName << endl; ofstream outfile; outfile.open(fileName); vector<RooSlimFitResult*> solutions = scanner->getSolutions(); outfile << "##### auto-generated by ParameterCache ####### " << endl; TDatime d; outfile << "##### printed on " << d.AsString() << " ######" << endl; outfile << Form("%-25s","# ParameterName") << " " << Form("%12s","value") << " " << Form("%12s","errLow") << " " << Form("%12s","errHigh") << endl; for (unsigned int i=0; i<solutions.size(); i++){ outfile << endl; outfile << "----- SOLUTION " << totalCachedPoints << " -----" << endl; RooSlimFitResult *slimFitRes = solutions[i]; printFitResultToOutStream(outfile,slimFitRes); totalCachedPoints++; } if ( m_arg->debug )cout << "ParameterCache::cacheParameters() : cached " << solutions.size() << " solutions" << endl; // cache also any specifically requested points // // 1D if (m_arg->savenuisances1d.size()>0){ vector<float> &points = m_arg->savenuisances1d; for (int i=0; i<points.size(); i++){ int iBin = scanner->getHCL()->FindBin(points[i]); RooSlimFitResult *r = scanner->curveResults[iBin-1]; if (!r) { cout << "ParameterCache::cacheParameters() : ERROR : no fit result at this scan point!" << endl; return; } outfile << endl; outfile << "----- SOLUTION " << totalCachedPoints << " (--sn at " << scanner->getScanVar1Name() << " = " << Form("%10.5f",points[i]) << ") -----" << endl; printFitResultToOutStream(outfile,r); totalCachedPoints++; } if ( m_arg->debug ) cout << "ParameterCache::cacheParameters() : cached " << totalCachedPoints-solutions.size() << " further points" << endl; } // 2D if (m_arg->savenuisances2dx.size()>0){ vector<float> &pointsx = m_arg->savenuisances2dx; vector<float> &pointsy = m_arg->savenuisances2dy; if (pointsx.size() != pointsy.size() ) { cout << "ParameterCache::cacheParameters() : ERROR : vectors for savenuisances2dx(y) have different size" << endl; return; } for (int i=0; i<pointsx.size(); i++){ int xBin = scanner->getHCL2d()->GetXaxis()->FindBin(pointsx[i]); int yBin = scanner->getHCL2d()->GetYaxis()->FindBin(pointsy[i]); if ( xBin<1 || xBin>scanner->getNPoints2dx() || yBin<1 || yBin>scanner->getNPoints2dy() ){ cout << "ParameterCache::cacheParameters() : ERROR : specified point is out of scan range." << endl; continue; } RooSlimFitResult *r = scanner->curveResults2d[xBin-1][yBin-1]; if (!r) { cout << "ParameterCache::cacheParameters() : ERROR : no fit result at this scan point!" << endl; return; } outfile << endl; outfile << "----- SOLUTION " << totalCachedPoints << " (not glob min just min at " << scanner->getScanVar1Name() << " = " << pointsx[i] << " , " << scanner->getScanVar2Name() << " = " << pointsy[i] << " -----" << endl; printFitResultToOutStream(outfile,r); totalCachedPoints++; } if ( m_arg->debug ) cout << "ParameterCache::cacheParameters() : cached " << totalCachedPoints-solutions.size() << " further points" << endl; } outfile.close(); }
void chipSummary(const char *dirName, int chipId, int TrimVcal) { if (f && f->IsOpen()) f->Close(); // if (f1 && f1->IsOpen()) f1->Close(); if (g && g->IsOpen()) g->Close(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetOptStat(0); gStyle->SetTitle(0); gStyle->SetStatFont(132); gStyle->SetTextFont(132); gStyle->SetLabelFont(132, "X"); gStyle->SetLabelFont(132, "Y"); gStyle->SetLabelSize(0.08, "X"); gStyle->SetLabelSize(0.08, "Y"); gStyle->SetNdivisions(6, "X"); gStyle->SetNdivisions(8, "Y"); gStyle->SetTitleFont(132); gROOT->ForceStyle(); tl = new TLatex; tl->SetNDC(kTRUE); tl->SetTextSize(0.09); ts = new TLatex; ts->SetNDC(kTRUE); ts->SetTextSize(0.08); line = new TLine; line->SetLineColor(kRed); line->SetLineStyle(kSolid); box = new TBox; box->SetFillColor(kRed); box->SetFillStyle(3002); f = new TFile(Form("%s/%s", dirName, fileName), "READ"); // if (strcmp(fileName, adFileName) == 0) f1 = f; // else f1 = new TFile(Form("%s/%s", dirName, adFileName), "READ"); sprintf(trimFileName,"Trim%i.root",TrimVcal); if (strcmp(fileName, trimFileName) == 0) g = f; else g = new TFile(Form("%s/%s", dirName, trimFileName), "READ"); //sprintf(fname, "%s/../../criteria.dat", dirName); sprintf(fname, "criteria.dat", dirName); if ( !readCriteria(fname) ) { printf("\nchipSummary> ----> COULD NOT READ GRADING CRITERIA !!!"); printf("chipSummary> ----> Aborting execution of chipgSummaryPage.C ... \n\n", fileName, dirName); break; } TH1D *h1; TH2D *h2; c1 = new TCanvas("c1", "", 800, 800); c1->Clear(); c1->Divide(4,4, 0.01, 0.04); // shrinkPad(0.1, 0.1, 0.1, 0.3); TString noslash(dirName); noslash.ReplaceAll("/", " "); noslash.ReplaceAll(".. ", ""); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 1 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Dead pixels TH2D *hpm = new TH2D("hpm", "", 80, 0., 80., 52, 0., 52.); int nDeadPixel(0); int nMaskDefect(0); int nNoisyPixel(0); int nRootFileProblems(0); c1->cd(1); h2 = (TH2D*)f->Get(Form("PixelMap_C%i", chipId)); if (h2) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { hpm->SetBinContent(irow+1, icol+1, h2->GetBinContent(icol+1, irow+1)); if (h2->GetBinContent(icol+1, irow+1) == 0) { ++nDeadPixel; } if (h2->GetBinContent(icol+1, irow+1) > 10) { ++nNoisyPixel; } if (h2->GetBinContent(icol+1, irow+1) < 0) { ++nMaskDefect; } } } h2->SetTitle(""); h2->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Pixel Map"); } else { ++nRootFileProblems; } // -- sCurve width and noise level TH1D *hw = new TH1D("hw", "", 100, 0., 600.); TH1D *hd = new TH1D("hd", "", 100, 0., 600.); // Noise in unbonded pixel (not displayed) TH2D *ht = new TH2D("ht", "", 52, 0., 52., 80, 0., 80.); TH1D *htmp; float mN(0.), sN(0.), nN(0.), nN_entries(0.); int over(0), under(0); double htmax(255.), htmin(0.); float thr, sig; int a,b; FILE *inputFile; char string[200]; sprintf(string, "%s/SCurve_C0%i.dat", dirName, TrimVcal); inputFile = fopen(string, "r"); double minThrDiff(-5.); double maxThrDiff(5.); h2 = (TH2D*)f->Get(Form("vcals_xtalk_C%i", chipId)); if (!inputFile) { printf("chipSummary> !!!!!!!!! ----> SCurve: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, inputFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { fscanf(inputFile, "%e %e %s %2i %2i", &thr, &sig, string, &a, &b); //comment // printf("chipSummary> sig %e thr %e\n", sig, thr); hw->Fill(sig); thr = thr / 65; ht->SetBinContent(icol+1, irow+1, thr); if ( h2 ) { if( h2->GetBinContent(icol+1, irow+1) > minThrDiff) { hd->Fill(sig); } } } } c1->cd(2); hw->Draw(); tl->DrawLatex(0.1, 0.92, "S-Curve widths: Noise (e^{-})"); /* c1->cd(15); hd->SetLineColor(kRed); hd->Draw(); tl->DrawLatex(0.1, 0.92, "S-Curve widths of dead bumps"); if ( hd->GetEntries() > 0 ) { ts->DrawLatex(0.55, 0.82, Form("entries: %4.0f", hd->GetEntries())); ts->DrawLatex(0.55, 0.74, Form("#mu:%4.2f", hd->GetMean())); ts->DrawLatex(0.55, 0.66, Form("#sigma: %4.2f", hd->GetRMS())); } */ mN = hw->GetMean(); sN = hw->GetRMS(); nN = hw->Integral(hw->GetXaxis()->GetFirst(), hw->GetXaxis()->GetLast()); nN_entries = hw->GetEntries(); under = hw->GetBinContent(0); over = hw->GetBinContent(hw->GetNbinsX()+1); ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nN)); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.1f", mN)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.1f", sN)); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); c1->cd(3); if ( ht->GetMaximum() < htmax ) { htmax = ht->GetMaximum(); } if ( ht->GetMinimum() > htmin ) { htmin = ht->GetMinimum(); } ht->GetZaxis()->SetRangeUser(htmin,htmax); ht->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Vcal Threshold from SCurve"); } // -- Noise level map c1->cd(4); gPad->SetLogy(1); gStyle->SetOptStat(1); float mV(0.), sV(0.), nV(0.), nV_entries(0.); over = 0.; under = 0.; if (!g->IsZombie()) { h1 = (TH1D*)g->Get(Form("VcalThresholdMap_C%iDistribution;7", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(0., 100.); h1->Draw(); mV = h1->GetMean(); sV = h1->GetRMS(); nV = h1->Integral(h1->GetXaxis()->GetFirst(), h1->GetXaxis()->GetLast()); nV_entries = h1->GetEntries(); under = h1->GetBinContent(0); over = h1->GetBinContent(h1->GetNbinsX()+1); } else { ++nRootFileProblems; mV = 0.; sV = 0.; } ts->DrawLatex(0.15, 0.82, Form("N: %4.0f", nV)); ts->DrawLatex(0.15, 0.74, Form("#mu: %4.1f", mV)); ts->DrawLatex(0.15, 0.66, Form("#sigma: %4.1f", sV)); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); } tl->DrawLatex(0.1, 0.92, "Vcal Threshold Trimmed"); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 2 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Bump Map TH2D *hbm = new TH2D("hbm", "", 80, 0., 80., 52, 0., 52.); int nDeadBumps(0); c1->cd(5); gStyle->SetOptStat(0); h2 = (TH2D*)f->Get(Form("vcals_xtalk_C%i", chipId)); if (h2) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { hbm->SetBinContent(irow+1, icol+1, h2->GetBinContent(icol+1, irow+1)); if ( h2->GetBinContent(icol+1, irow+1) >= minThrDiff ) { cout << Form("chipSummary> dead %3d %3d: %7.5f", icol, irow, h2->GetBinContent(icol, irow)) << endl; ++nDeadBumps; } } } h2->SetTitle(""); h2->GetZaxis()->SetRangeUser(minThrDiff, maxThrDiff); h2->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Bump Bonding Problems"); } else { ++nRootFileProblems; } // -- Bump Map c1->cd(6); gPad->SetLogy(1); //gStyle->SetOptStat(1); h1 = (TH1D*)f->Get(Form("vcals_xtalk_C%iDistribution", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(-50., 50.); //DOES NOT WORK!!!??? h1->Draw(); tl->DrawLatex(0.1, 0.92, "Bump Bonding"); } else { ++nRootFileProblems; } // -- Trim bits int trimbitbins(3); int nDeadTrimbits(0); c1->cd(7); gPad->SetLogy(1); h1 = (TH1D*)f->Get(Form("TrimBit14_C%i", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(0., 60.); h1->SetMinimum(0.5); h1->Draw(""); tl->DrawLatex(0.1, 0.92, "Trim Bit Test"); for (int i = 1; i <= trimbitbins; ++i) nDeadTrimbits += h1->GetBinContent(i); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit13_C%i", chipId)); if (h1) { h1->SetLineColor(kRed); h1->Draw("same"); for (int i = 1; i <= trimbitbins; ++i) nDeadTrimbits += h1->GetBinContent(i); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit11_C%i", chipId)); if (h1) { h1->SetLineColor(kBlue); h1->Draw("same"); for (int i = 1; i <= trimbitbins; ++i) nDeadTrimbits += h1->GetBinContent(i); } else { ++nRootFileProblems; } h1 = (TH1D*)f->Get(Form("TrimBit7_C%i", chipId)); if (h1) { h1->SetLineColor(kGreen); h1->Draw("same"); for (int i = 1; i <= trimbitbins; ++i) nDeadTrimbits += h1->GetBinContent(i); } else { ++nRootFileProblems; } // -- For numerics and titels see at end // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 3 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Address decoding TH2D *ham = new TH2D("ham", "", 80, 0., 80., 52, 0., 52.); int nAddressProblems(0); c1->cd(9); gStyle->SetOptStat(0); h2 = (TH2D*)f->Get(Form("AddressDecoding_C%i", chipId)); if (h2) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { ham->SetBinContent(irow+1, icol+1, h2->GetBinContent(icol+1, irow+1)); if (h2 && h2->GetBinContent(icol+1, irow+1) < 1) { cout << Form("chipSummary> address problem %3d %3d: %7.5f", icol, irow, h2->GetBinContent(icol, irow)) << endl; ++nAddressProblems; } } } h2->SetTitle(""); h2->Draw("colz"); tl->DrawLatex(0.1, 0.92, "Address decoding"); } else { ++nRootFileProblems; } // -- Address levels c1->cd(10); gPad->SetLogy(1); h1 = (TH1D*)f->Get(Form("AddressLevels_C%i", chipId)); if (h1) { h1->SetTitle(""); h1->SetAxisRange(-1200., 1000.); h1->Draw(); tl->DrawLatex(0.1, 0.92, "Address Levels"); } else { ++nRootFileProblems; } // -- PHCalibration (Gain & Pedesdtal) TH1D *hg = new TH1D("hg", "", 250, -1., 5.5); TH2D *hgm = new TH2D("hgm", "", 52, 0., 52., 80, 0., 80.); TH1D *hp1 = new TH1D("hp", "", 100,0,5); TH1D *hp = new TH1D("hp", "", 900, -600., 600.); hp->StatOverflows(kTRUE); TH1D *rp = new TH1D("rp", "", 900, -600., 600.); rp->StatOverflows(kFALSE); TH1D *htmp; float mG(0.), sG(0.), nG(0.), nG_entries(0.); float mP(0.), sP(0.), nP(0.), nP_entries(0.); over = 0.; under = 0.; float par0, par1, par2, par3, par4, par5; // Parameters of Vcal vs. Pulse Height Fit float ped, gain; int a,b; int mPbin(0), xlow(-100), xup(255), extra(0); // for restricted RMS double integral(0.); FILE *inputFile; char string[200]; sprintf(string, "%s/phCalibrationFitTan_C0%i.dat", dirName, TrimVcal); inputFile = fopen(string, "r"); if (!inputFile) { printf("chipSummary> !!!!!!!!! ----> phCal: Could not open file %s to read fit results\n", string); } else { for (int i = 0; i < 2; i++) fgets(string, 200, inputFile); for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { // fscanf(inputFile, "%e %e %e %e %e %e %s %2i %2i", &par0, &par1, &par2, &par3, &par4, &par5, string, &a, &b); fscanf(inputFile, "%e %e %e %e %s %2i %2i", &par0, &par1, &par2, &par3, string, &a, &b); if (par2 != 0.) // dead pixels have par2 == 0. { // ped = -par3/par2; gain = 1./par2; // ped = par3; ped=par3+par2*(tanh(-par1)); hp->Fill(ped); hg->Fill(gain); hp1->Fill(par1); // cout <<gain<<" " << ped<<endl; hgm->SetBinContent(icol + 1, irow + 1, gain); } } } mG = hg->GetMean(); sG = hg->GetRMS(); nG = hg->Integral(hg->GetXaxis()->GetFirst(), hg->GetXaxis()->GetLast()); nG_entries = hg->GetEntries(); under = hg->GetBinContent(0); over = hg->GetBinContent(hp->GetNbinsX()+1); c1->cd(11); // hg->Draw(); tl->DrawLatex(0.1, 0.92, "PH Calibration: Gain (ADC/DAC)"); if ( hg->GetMean() > 1.75 ) { ts->DrawLatex(0.15, 0.82, Form("N: %4.0f", nG)); ts->DrawLatex(0.15, 0.74, Form("#mu: %4.2f", mG)); ts->DrawLatex(0.15, 0.66, Form("#sigma: %4.2f", sG)); if ( under ) ts->DrawLatex(0.15, 0.82, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.82, Form("%i =>", over )); } else { ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nG)); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.2f", mG)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.2f", sG)); if ( under ) ts->DrawLatex(0.15, 0.82, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.82, Form("%i =>", over )); } mP = hp->GetMean(); sP = hp->GetRMS(); nP = hp->Integral(hp->GetXaxis()->GetFirst(), hp->GetXaxis()->GetLast()); nP_entries = hp->GetEntries(); if ( nP > 0 ) { // -- restricted RMS integral = 0.; mPbin = -1000; xlow = -1000; xup = 1000; over = 0.; under = 0.; mPbin = hp->GetXaxis()->FindBin(mP); for (int i = 0; integral < pedDistr; i++) { xlow = mPbin-i; xup = mPbin+i; integral = hp->Integral(xlow, xup)/nP; } extra = xup - xlow; } else { xlow = -300; xup = 600; extra = 0; over = 0.; under = 0.; } hp->GetXaxis()->SetRange(xlow - extra, xup + extra); nP = hp->Integral(hp->GetXaxis()->GetFirst(), hp->GetXaxis()->GetLast()); under = hp->GetBinContent(0); over = hp->GetBinContent(hp->GetNbinsX()+1); c1->cd(15); // hgm->Draw("colz"); hp1->Draw(); tl->DrawLatex(0.1, 0.92, "PH Calibration: P1"); c1->cd(12); hp->DrawCopy(); rp->Add(hp); rp->GetXaxis()->SetRange(xlow, xup); mP = rp->GetMean(); sP = rp->GetRMS(); // box->DrawBox( rp->GetBinCenter(xlow), 0, rp->GetBinCenter(xup), 1.05*rp->GetMaximum()); rp->SetFillColor(kRed); rp->SetFillStyle(3002); rp->Draw("same"); line->DrawLine(rp->GetBinCenter(xlow), 0, rp->GetBinCenter(xlow), 0.6*rp->GetMaximum()); line->DrawLine(rp->GetBinCenter(xup), 0, rp->GetBinCenter(xup), 0.6*rp->GetMaximum()); tl->DrawLatex(0.1, 0.92, "PH Calibration: Pedestal (DAC)"); if ( hp->GetMean() < 126. ) { ts->DrawLatex(0.65, 0.82, Form("N: %4.0f", nP)); ts->SetTextColor(kRed); ts->DrawLatex(0.65, 0.74, Form("#mu: %4.1f", mP)); ts->DrawLatex(0.65, 0.66, Form("#sigma: %4.1f", sP)); ts->SetTextColor(kBlack); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); } else { ts->DrawLatex(0.16, 0.82, Form("N: %4.0f", nP)); ts->SetTextColor(kRed); ts->DrawLatex(0.16, 0.74, Form("#mu: %4.1f", mP)); ts->DrawLatex(0.16, 0.66, Form("#sigma: %4.1f", sP)); ts->SetTextColor(kBlack); if ( under ) ts->DrawLatex(0.15, 0.55, Form("<= %i", under)); if ( over ) ts->DrawLatex(0.75, 0.55, Form("%i =>", over )); } } // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Numerics and Titles // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // -- Compute the final verdict on this chip //?? FIXME (below is pure randomness) char finalVerdict(0); if (nDeadTrimbits > 40) finalVerdict += 1; if (nDeadPixel > 40) finalVerdict += 10; if (nNoisyPixel > 40) finalVerdict += 10; if (nAddressProblems > 40) finalVerdict += 10; if (nDeadBumps > 40) finalVerdict += 100; // -- Defects c1->cd(8); tl->SetTextSize(0.10); tl->SetTextFont(22); double y = 0.92; y -= 0.11; tl->DrawLatex(0.1, y, "Summary"); tl->DrawLatex(0.7, y, Form("%d", finalVerdict)); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.11; tl->DrawLatex(0.1, y, Form("Dead Pixels: ")); tl->DrawLatex(0.7, y, Form("%4d", nDeadPixel)); y -= 0.10; tl->DrawLatex(0.1, y, Form("Noisy Pixels: ")); tl->DrawLatex(0.7, y, Form("%4d", nNoisyPixel)); y -= 0.10; tl->DrawLatex(0.1, y, "Mask defects: "); tl->DrawLatex(0.7, y, Form("%4d", nMaskDefect)); y -= 0.10; tl->DrawLatex(0.1, y, "Dead Bumps: "); tl->DrawLatex(0.7, y, Form("%4d", nDeadBumps)); y -= 0.10; tl->DrawLatex(0.1, y, "Dead Trimbits: "); tl->DrawLatex(0.7, y, Form("%4d", nDeadTrimbits)); y -= 0.10; tl->DrawLatex(0.1, y, "Address Probl: "); tl->DrawLatex(0.7, y, Form("%4d", nAddressProblems)); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // Row 4 // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TH2D *htm = new TH2D("htm", "", 80, 0., 80., 52, 0., 52.); c1->cd(13); gStyle->SetOptStat(0); h2 = (TH2D*)g->Get(Form("TrimMap_C%i;8", chipId)); if (h2) { for (int icol = 0; icol < 52; ++icol) { for (int irow = 0; irow < 80; ++irow) { htm->SetBinContent(irow+1, icol+1, h2->GetBinContent(icol+1, irow+1)); } } h2->SetTitle(""); h2->GetZaxis()->SetRangeUser(0., 16.); h2->Draw("colz"); } else { ++nRootFileProblems; } tl->DrawLatex(0.1, 0.92, "Trim Bits"); FILE *tCalFile; sprintf(string, "%s/../T-calibration/TemperatureCalibration_C%i.dat", dirName, chipId); tCalFile = fopen(string, "r"); char tCalDir[200]; sprintf(tCalDir, "%s/../T-calibration", dirName); if ( tCalFile ) { analyse(tCalDir, chipId); } else { c1->cd(14); TGraph *graph = (TGraph*)f->Get(Form("TempCalibration_C%i", chipId)); if ( graph ) { graph->Draw("A*"); } else { ++nRootFileProblems; } tl->DrawLatex(0.1, 0.92, "Temperature calibration"); } // -- Operation Parameters c1->cd(16); y = 0.92; tl->SetTextSize(0.10); tl->SetTextFont(22); y -= 0.11; tl->DrawLatex(0.1, y, Form("Op. Parameters")); tl->SetTextFont(132); tl->SetTextSize(0.09); y -= 0.11; int vana(-1.); vana = dac_findParameter(dirName, "Vana", chipId); tl->DrawLatex(0.1, y, "VANA: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3i DAC", vana)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int caldel(-1.); caldel = dac_findParameter(dirName, "CalDel", chipId); tl->DrawLatex(0.1, y, "CALDEL: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", caldel)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int vthrcomp(-1.); vthrcomp = dac_findParameter(dirName, "VthrComp", chipId); tl->DrawLatex(0.1, y, "VTHR: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", vthrcomp)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int vtrim(-1.); vtrim = dac_findParameter(dirName, "Vtrim", chipId); tl->DrawLatex(0.1, y, "VTRIM: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", vtrim)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int ibias(-1.); ibias = dac_findParameter(dirName, "Ibias_DAC", chipId); tl->DrawLatex(0.1, y, "IBIAS_DAC: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", ibias)); else tl->DrawLatex(0.7, y, "N/A"); y -= 0.10; int voffset(-1.); voffset = dac_findParameter(dirName, "VoffsetOp", chipId); tl->DrawLatex(0.1, y, "VOFFSETOP: "); if (vana >= 0.) tl->DrawLatex(0.6, y, Form("%3d DAC", voffset)); else tl->DrawLatex(0.7, y, "N/A"); // -- Page title c1->cd(0); tl->SetTextSize(0.025); tl->SetTextFont(22); tl->DrawLatex(0.02, 0.97, Form("%s (Trim%i)", noslash.Data(),TrimVcal)); TDatime date; tl->SetTextSize(0.02); tl->DrawLatex(0.75, 0.97, Form("%s", date.AsString())); c1->SaveAs(Form("%s/chipSummary_C%i_%i.ps", dirName, chipId,TrimVcal)); c1->SaveAs(Form("%s/C%i_%i.gif", dirName, chipId,TrimVcal)); // -- Dump into logfile ofstream OUT(Form("%s/summary_C%i_%i.txt", dirName, chipId,TrimVcal)); OUT << "nDeadPixel: " << nDeadPixel << endl; OUT << "nNoisyPixel: " << nNoisyPixel << endl; OUT << "nDeadTrimbits: " << nDeadTrimbits << endl; OUT << "nDeadBumps: " << nDeadBumps << endl; OUT << "nMaskDefect: " << nMaskDefect << endl; OUT << "nAddressProblems: " << nAddressProblems << endl; OUT << "nRootFileProblems: " << nRootFileProblems << endl; OUT << "SCurve " << nN_entries << " " << mN << " " << sN << endl; OUT << "Threshold " << nV_entries << " " << mV << " " << sV << endl; OUT << "Gain " << nG_entries << " " << mG << " " << sG << endl; OUT << "Pedestal " << nP_entries << " " << mP << " " << sP << endl; OUT.close(); }
void KVINDRAOnlineDataAnalyser::ProcessRun() { // Perform treatment of a given run //Open data file fRunFile = (KVRawDataReader*)gDataSet->OpenRunfile(GetDataType().Data() , fRunNumber); if (fRunFile->GetStatus() == KVGRUNetClientGanilReader::kSTATUS_NOHOST) { // cannot connect to ACQ host Error("ProcessRun", "Cannot connect to acquisition host machine. Check KVGRUNetClientGanilReader.AcqHostName"); return; } //warning! real number of run may be different from that deduced from file name //we get the real run number from gMultiDetArray and use it to name any new files fRunNumber = gMultiDetArray->GetCurrentRunNumber(); fEventNumber = 0; //event number cout << endl << "Reading ONLINE events from RUN# " << fRunNumber << endl; cout << "Starting analysis of data on : "; TDatime now; cout << now.AsString() << endl << endl; preInitRun(); //call user's beginning of run InitRun(); postInitRun(); fDetEv = new KVDetectorEvent; //loop over events in file fGoEventLoop = kTRUE; fDumpEvents = kFALSE; while (fGoEventLoop) { Bool_t gotevent = fRunFile->GetNextEvent(); if (gotevent) { fEventNumber++; //reconstruct hit groups KVSeqCollection* fired = fRunFile->GetFiredDataParameters(); gMultiDetArray->GetDetectorEvent(fDetEv, fired); preAnalysis(); //call user's analysis. stop if returns kFALSE. if (!Analysis()) break; postAnalysis(); fDetEv->Clear(); if (!((fEventNumber) % 10000)) cout << " ++++ " << fEventNumber << " events read ++++ " << endl; } else { // got no event - why ? Int_t status = fRunFile->GetStatus(); switch (status) { case KVGRUNetClientGanilReader::kSTATUS_NOBUFF: Warning("ProcessRun", "Got no buffer from ACQHOST. Sleeping for 2 seconds."); gSystem->Sleep(2000); break; case KVGRUNetClientGanilReader::kSTATUS_NOEVENT: Warning("ProcessRun", "Got no event from ACQHOST. Sleeping for 2 seconds."); gSystem->Sleep(2000); break; case KVGRUNetClientGanilReader::kSTATUS_NOACQ: Warning("ProcessRun", "Acquisition is stopped. Sleeping for 5 seconds."); gSystem->Sleep(5000); break; } } } delete fDetEv; cout << "Ending analysis of run " << fRunNumber << " on : "; TDatime now2; cout << now2.AsString() << endl << endl; cout << endl << "Finished reading " << fEventNumber << " events" << endl << endl; preEndRun(); //call user's end of run function EndRun(); postEndRun(); if (fMessageThread) { fMessageThread->Kill(); TThread::Delete(fMessageThread); delete fMessageThread; fMessageThread = 0; } }