///////////////////////////////////////////////////////////////////////// // // This macro make makes some test plots of the quality of the META alignment. // As an input a file generated by "align.C" macro is taken. // // To get some plots use: // .L checkResults.C // checkResultsFunction(0, 0) // // M.Jaskula Fri Nov 30 00:23:06 CET 2001 // ///////////////////////////////////////////////////////////////////////// void checkResultsFunction(char *pOutFile = NULL, int iNoOutput = 1) { char pFileName[100]; TFile *pFile; strcpy(pFileName, "out.root"); while((pFile = (TFile *)gROOT->GetListOfFiles()->FindObject(pFileName)) != NULL) { pFile->Close(); delete pFile; } pFile = new TFile(pFileName); if( ! pFile->IsOpen()) { printf("File %s not opened !\n", pFileName); return; } gStyle->SetOptFit(10); gStyle->SetPalette(1); TCanvas *pCan; if(iNoOutput) pCan = new TCanvas("align", "align",120, 90); else pCan = new TCanvas("align", "align",1200, 900); pCan->Divide(4, 3, 0, 0, 0); pCan->cd(1); TNtuple *pRes = (TNtuple *)gFile->Get("res"); if(pRes == NULL) { printf("\nNo `res' in the file\n\n"); return; } const int iPar = 8; int i; TH1F *pH; char sN[100]; char sC[100]; char *pN[] = { "dy", "dy", "dy", "dy", "dx", "dx", "dx", "dx"}; char *pC0[] = { "", "ym>200", "ym<=200&&ym>=-200", "ym<-200", "", "ym>200", "ym<=200&&ym>=-200", "ym<-200"}; char *pC1[] = { "", "ym>50", "ym<=50&&ym>=-50", "ym<-50", "", "ym>50", "ym<=50&&ym>=-50", "ym<-50"}; Int_t iCond; Int_t iSys; iSys = pRes->Draw("sys", "sys==1"); iCond = pRes->Draw("dx", "cw>0"); char **pC = (iSys > 0) ? pC1: pC0; Double_t dM[iPar], dME[iPar], dS[iPar], dSE[iPar]; Float_t fGausRange; pRes->Draw("ym:xm", "", "contz"); pCan->cd(2); pRes->Draw("dy:dx", "", "contz"); pCan->cd(3); pRes->Draw("dy:ym", "", "contz"); pCan->cd(4); pRes->Draw("dx:xm", "", "contz"); for(i = 0; i < iPar; i++) { printf("%s %d\n", __FILE__, __LINE__); pCan->cd(i + 5); gPad->SetLogy(); sprintf(sN, "%s %s", pN[i], pC[i]); sprintf(sC, "pH_%d", i); pH = new TH1F(sC, sN, 100, -100, 100); sprintf(sN, "%s>>%s", pN[i], sC); if(iCond > 0) { if(strlen(pC[i]) > 0) sprintf(sC, "%s&&cw>=0", pC[i]); else sprintf(sC, "cw>=0", pC[i]); } else { strcpy(sC, pC[i]); } printf("\n\nPRINT: %s %s\n\n", sN, sC); pRes->Draw(sN, sC); pH->Print(); pH->SetLineColor(2); if((iSys > 0) && (i > 3)) fGausRange = 75.0f; else fGausRange = 45.0f; pH->Fit("gaus", "", "", -fGausRange, fGausRange); pH->GetFunction("gaus")->SetLineColor(4); dM[i] = gaus->GetParameter(1); dME[i] = gaus->GetParError(1); dS[i] = gaus->GetParameter(2); dSE[i] = gaus->GetParError(2); pRes->Draw(pN[i], pC[i], "same"); pH->Draw("same"); } printf("\n"); char s[10000]; char z[10000]; sprintf(s, "+-----------------------+-----------+-----------+-----------+" "-----------+\n" "| Name | Mean | ErrMean | Sigma |" " ErrSigma |\n" "+-----------------------+-----------+-----------+-----------+" "-----------+\n"); for(i = 0; i < iPar; i++) { sprintf(z, "| %2s %-18s |%10.4f |%10.4f |%10.4f |%10.4f |\n", pN[i], pC[i], dM[i], dME[i], dS[i], dSE[i]); strcat(s, z); } strcat(s, "+-----------------------+-----------+-----------+-----------+" "-----------+\n"); if(pOutFile != NULL) { FILE *pOutF; if((pOutF = fopen(pOutFile, "a")) == NULL) fprintf(stderr, "Cannot open file: %s\n", pOutFile); else { fprintf(pOutF, "%s", s); fclose(pOutF); } } printf("%s", s); printf("\nSystem: %d Cond: %d\n", iSys, iCond); if(iNoOutput) pCan->Close(); } // ----------------------------------------------------------------------------- void checkResults(void) { checkResultsFunction(); } // ----------------------------------------------------------------------------- void checkResults(char *pOut) { checkResultsFunction(pOut); }