349 #include "PhysicalConstants.h"
352 #include "TObjString.h"
356 #include "TPaveLabel.h"
357 #include "TPaveText.h"
362 #include "StMessMgr.h"
364 #include "St_DataSetIter.h"
368 #include "TProfile.h"
370 #include "StHistUtil.h"
373 typedef const char* charptr;
375 const char* possibleQAPrefixes[10] = {
"",
"LM",
"MM",
"HM",
"HP",
"XX",
"MB",
"CL",
"HT",
"JP"};
376 const char* possibleQASuffixes[10] = {
389 enum QAprintModes {QAprintSet,
395 int sizeOfCharPtr =
sizeof(Char_t*);
396 int sizeOfTH1Ptr =
sizeof(TH1*);
401 Double_t StdEdxY2Maker_gaus2(Double_t *x, Double_t *p) {
402 Double_t NormL = p[0];
404 Double_t muP = mu + p[4];
405 Double_t sigma = p[2];
406 Double_t sigmaP = TMath::Sqrt(sigma*sigma + 0.101741*0.101741);
408 Double_t frac = TMath::Sin(phi);
410 return TMath::Exp(NormL)*((1 - frac)*TMath::Gaus(x[0],mu ,sigma ,kTRUE) +
411 frac *TMath::Gaus(x[0],muP,sigmaP,kTRUE));
413 TF1 *StdEdxY2Maker_Gaus2() {
414 TF1 *f =
new TF1(
"Gaus2",StdEdxY2Maker_gaus2,-3,3,5);
415 f->SetParName(0,
"NormL"); f->SetParLimits(0,-10.,10.);
416 f->SetParName(1,
"mu"); f->SetParLimits(1,-0.5,0.5);
417 f->SetParName(2,
"sigma"); f->SetParLimits(2, 0.2,0.5);
418 f->SetParName(3,
"phiP"); f->SetParLimits(3, 0.0,TMath::Pi()/4);
419 f->SetParName(4,
"muP");
420 f->SetParameters(10,0,0.3,0.1,1.315);
434 numOfPosPrefixes = 10;
435 possiblePrefixes = possibleQAPrefixes;
436 possibleSuffixes = possibleQASuffixes;
450 m_OutMultiPage = kTRUE;
451 m_OutIndividuals =
"";
452 m_QAShiftMode = kFALSE;
459 newHist =
new TH1ptr[maxHistCopy];
460 memset(newHist,0,maxHistCopy*sizeOfTH1Ptr);
463 ignorePrefixes = kFALSE;
466 m_refResultsFile[0] = 0;
471 m_PntrToPlainFile = 0;
480 m_ItemsToClear =
new TList();
481 m_ItemsToClear->SetOwner();
487 StHistUtil::~StHistUtil(){
488 SafeDelete(m_HistCanvas);
489 SafeDelete(m_HistCanvasR);
491 m_ListOfLogY->Delete();
492 SafeDelete(m_ListOfLogY);
495 m_ListOfLogX->Delete();
496 SafeDelete(m_ListOfLogX);
499 m_ListOfPrint->Delete();
500 SafeDelete(m_ListOfPrint);
503 for (
int ijk=0; ijk<maxHistCopy; ijk++)
delete newHist[ijk];
506 delete m_ItemsToClear;
509 void StHistUtil::Clear() {
510 m_ItemsToClear->Clear();
513 void StHistUtil::SetOutFile(
const Char_t *fileName,
const Char_t* type) {
514 m_OutFileName = fileName;
515 if (m_OutFileName.EndsWith(
"+")) {
516 m_OutIndividuals =
".eps";
517 m_PrintMode |= QAU1<<QAprintIndiv;
518 if (m_OutFileName.EndsWith(
"++")) m_PrintMode |= QAU1<<QAprintIndivRef;
519 while (m_OutFileName.EndsWith(
"+")) m_OutFileName.Chop();
524 if (m_OutFileName.EndsWith(
".ps")) m_OutType=
"ps";
525 else if (m_OutFileName.EndsWith(
".eps")) m_OutType=
"eps";
526 else if (m_OutFileName.EndsWith(
".epsf")) m_OutType=
"Preview";
527 else if (m_OutFileName.EndsWith(
".pdf")) m_OutType=
"pdf";
528 else if (m_OutFileName.EndsWith(
".jpg")) m_OutType=
"jpg";
529 else if (m_OutFileName.EndsWith(
".jpeg")) m_OutType=
"jpg";
530 else if (m_OutFileName.EndsWith(
".gif")) m_OutType=
"gif";
531 else if (m_OutFileName.EndsWith(
".tif")) m_OutType=
"tiff";
532 else if (m_OutFileName.EndsWith(
".tiff")) m_OutType=
"tiff";
533 else if (m_OutFileName.EndsWith(
".svg")) m_OutType=
"svg";
534 else if (m_OutFileName.EndsWith(
".xpm")) m_OutType=
"xpm";
535 else if (m_OutFileName.EndsWith(
".png")) m_OutType=
"png";
536 else if (m_OutFileName.EndsWith(
".CC")) m_OutType=
"CC";
537 else if (m_OutFileName.EndsWith(
".C")) m_OutType=
"C";
538 else if (m_OutFileName.EndsWith(
".root")) m_OutType=
"root";
539 else if (m_OutFileName.EndsWith(
"none")) m_OutType=
"none";
540 else if (m_OutFileName.EndsWith(
".qas")) m_OutType=
"qas";
542 LOG_INFO <<
"SetHistUtil::SetOutFile(): unknown type, assuming ps" << endm;
544 m_OutFileName.Append(
".ps");
547 if (!m_OutType.CompareTo(
"qas")) {
548 m_QAShiftMode = kTRUE;
549 m_OutIndividuals =
".svg";
550 m_PrintMode |= QAU1<<QAprintIndiv;
551 m_PrintMode |= QAU1<<QAprintIndivRef;
554 if (m_OutType.CompareTo(
"none")) {
555 m_PrintMode |= QAU1<<QAprintSet;
556 m_PrintMode |= QAU1<<QAprintSetRef;
560 m_OutMultiPage = !(m_OutType.CompareTo(
"ps")
561 && m_OutType.CompareTo(
"pdf") );
562 if (m_OutMultiPage) {
563 LOG_INFO <<
"StHistUtil::SetOutFile(): Multipage output" << endm;
565 LOG_INFO <<
"StHistUtil::SetOutFile(): Single page output" << endm;
569 void StHistUtil::CloseOutFile() {
570 m_HistCanvas->Modified();
571 m_HistCanvas->Update();
572 if (!m_CurFileName.IsNull()) {
573 if (m_OutMultiPage) m_CurFileName.Append(
")");
574 if (m_OutType.CompareTo(
"CC")) {
576 if (m_CurPage==1) m_CurFileName.Chop().Chop();
577 if (m_PrintMode & QAU1<<QAprintSet)
578 m_HistCanvas->Print(m_CurFileName.Data(),m_OutType.Data());
580 m_HistCanvas->SaveSource(m_CurFileName.Data());
582 m_HistCanvasR->Modified();
583 m_HistCanvasR->Update();
584 m_CurFileNameR.Append(
")");
586 if (m_CurPage==1) m_CurFileNameR.Chop().Chop();
587 if (m_PrintMode & QAU1<<QAprintSetRef)
588 m_HistCanvasR->Print(m_CurFileNameR.Data(),m_OutType.Data());
592 LOG_INFO <<
"StHistUtil::CloseOutFile(): No output file" << endm;
596 TString StHistUtil::StripPrefixes(
const Char_t* histName, Int_t& prenum, Int_t mode) {
601 TString hName(histName);
602 Char_t makerBuffer[4];
603 memset(makerBuffer,0,4);
604 if ((hName.BeginsWith(
"Tab")) || (hName.BeginsWith(
"StE"))) {
605 memcpy(makerBuffer,histName,3);
610 for (Int_t i=1; i<numOfPosPrefixes; i++) {
611 if (hName.BeginsWith(possiblePrefixes[i])) {
613 hName.Remove(0,strlen(possiblePrefixes[i]));
617 if (mode>0) hName.Prepend(makerBuffer);
622 Bool_t StHistUtil::CheckOutFile(
const Char_t *histName) {
626 Int_t newPrefix = -1;
627 StripPrefixes(histName,newPrefix);
629 if (newPrefix == m_CurPrefix)
return kFALSE;
632 m_CurPrefix = newPrefix;
633 if (m_OutType.CompareTo(
"C") && m_OutType.CompareTo(
"root")) {
634 m_CurFileName = m_OutFileName;
635 Ssiz_t insertPos = m_CurFileName.Last(
'.');
636 if (insertPos<0) insertPos = m_CurFileName.Length();
637 if (m_OutMultiPage) m_CurFileName.Append(
"(");
638 else m_CurFileName.Insert(insertPos,
"_");
639 m_CurFileName.Insert(insertPos,possiblePrefixes[m_CurPrefix]);
641 (m_CurFileNameR =
"Ref_") += m_CurFileName;
645 Ldesc->AddText(possibleSuffixes[m_CurPrefix]);
646 Ldesc->AddText(
"Hists");
651 Int_t StHistUtil::DrawHists(
const Char_t *dirName) {
655 LOG_INFO <<
" **** Now in StHistUtil::DrawHists **** " << endm;
657 Int_t canvasWidth,canvasHeight;
660 LOG_INFO <<
"In QA Shift Mode - overriding other inputs" << endm;
667 gStyle->SetPaperSize(m_PaperWidth,m_PaperHeight);
676 const Int_t numPads = m_PadColumns*m_PadRows;
677 gStyle->SetStatStyle(0);
678 gStyle->SetOptDate(0);
679 gStyle->SetPalette(1);
683 SafeDelete(m_HistCanvas);
684 SafeDelete(m_HistCanvasR);
687 m_HistCanvasR =
new TCanvas(
"CanvasNameR",
" STAR Reference Histogram Canvas",20,20,canvasWidth,canvasHeight);
689 m_HistCanvas =
new TCanvas(
"CanvasName",
" STAR Maker Histogram Canvas",0,0,canvasWidth,canvasHeight);
692 TPad *graphPad = m_HistCanvas;
693 TPad *graphPadR = m_HistCanvasR;
694 TPaveLabel* LtitleR = 0;
695 TPaveLabel *Ldatetime = 0;
696 TPaveLabel *Lpage = 0;
699 if (!m_QAShiftMode) {
703 Ltitle =
new TPaveLabel(0.08,0.96,0.88,1.0,m_GlobalTitle.Data(),
"br");
704 Ltitle->SetFillColor(18);
705 Ltitle->SetTextFont(32);
706 Ltitle->SetTextSize(0.5);
710 LtitleR =
new TPaveLabel(0.08,0.96,0.88,1.0,m_refInFile->GetName(),
"br");
711 LtitleR->SetFillColor(18);
712 LtitleR->SetTextFont(32);
713 LtitleR->SetTextSize(0.5);
719 Ldesc =
new TPaveText(0.90,0.96,0.99,1.0,
"br");
720 Ldesc->SetFillColor(18);
721 Ldesc->SetTextFont(32);
731 const Char_t *myTime = HistTime.AsString();
732 Ldatetime =
new TPaveLabel(0.7,0.01,0.95,0.03,myTime,
"br");
733 Ldatetime->SetTextSize(0.6);
743 Lpage =
new TPaveLabel(0.1,0.01,0.16,0.03,Form(
"%d",m_CurPage),
"br");
744 Lpage->SetTextSize(0.6);
755 graphPad =
new TPad(
"PadName",
"Pad Title",0.0,0.05,1.00,0.95);
758 graphPad->Divide(m_PadColumns,m_PadRows);
761 graphPadR =
new TPad(
"PadNameR",
"Pad TitleR",0.0,0.05,1.00,0.95);
764 graphPadR->Divide(m_PadColumns,m_PadRows);
771 Bool_t padAdvance = kTRUE;
776 PathCopy(m_dirName,dirName);
777 TList* dirList = (m_PntrToMaker ? FindHists(m_dirName) : FindHists(m_PntrToPlainFile));
778 if (!dirList) { LOG_INFO <<
" DrawHists - histograms not available! " << endm; }
780 TIter nextHist(dirList);
781 Int_t histCounter = 0;
782 Int_t histReadCounter = 0;
783 Bool_t started = kFALSE;
793 ofstream* C_ostr = 0;
794 TFile* root_ofile = 0;
795 if (!m_OutType.CompareTo(
"C")) {
796 C_ostr =
new ofstream(m_OutFileName);
797 (*C_ostr) <<
" gSystem->Load(\"St_base\");" << endl;
798 (*C_ostr) <<
" gSystem->Load(\"StUtilities\");" << endl;
800 }
else if (!m_OutType.CompareTo(
"root"))
801 root_ofile =
new TFile(m_OutFileName,
"RECREATE");
805 ofstream* R_ostr = 0;
807 dirListR = FindHists(m_refInFile);
809 if (!root_ofile) root_ofile =
new TFile(m_refOutFile,
"RECREATE");
813 static TF1* fitFRS = 0;
814 if (!fitFRS) fitFRS =
new TF1(
"fitFRS",
"[0]*(x<[1]-[2])+([0]+([3]-[0])*(x-([1]-[2]))/(2*[2]))*(x>[1]-[2])*(x<[1]+[2])+[3]*(x>[1]+[2])",6.5, 9.0);
816 while ((obj = nextHist())) {
818 if (!obj->InheritsFrom(
"TH1"))
continue;
820 TH1* hobj = (TH1*) obj;
821 const char* oname = hobj->GetName();
822 const char* otitle = hobj->GetTitle();
823 TString oName = oname;
824 oName.ReplaceAll(
' ',
'_');
826 LOG_INFO << Form(
" %d. Reading ... %s::%s; Title=\"%s\"\n",
827 histReadCounter,hobj->ClassName(),oname, otitle) << endm;
828 if (!started && (m_FirstHistName.CompareTo(
"*")==0 ||
829 m_FirstHistName.CompareTo(oName)==0))
834 if (oName.CompareTo(m_LastHistName)==0) started = kFALSE;
841 if (!m_ListOfPrint || (m_ListOfPrint->FindObject(oname))) {
849 hobj->SavePrimitive(*C_ostr);
854 LOG_INFO << Form(
" - %d. Drawing ... %s::%s; Title=\"%s\"\n",
855 histCounter,hobj->ClassName(),oname, otitle) << endm;
858 if (CheckOutFile(oname)) {
864 if (m_refInFile) graphPadR->Clear();
867 }
else if (padCount == numPads) {
869 m_HistCanvas->Modified();
870 m_HistCanvas->Update();
871 if (m_PrintMode & QAU1<<QAprintSet &&
872 m_CurPage>0 && !m_CurFileName.IsNull()) {
873 if (m_OutType.CompareTo(
"CC")) {
874 m_HistCanvas->Print(m_CurFileName.Data(),m_OutType.Data());
876 m_HistCanvas->SaveSource(m_CurFileName.Data());
877 m_CurFileName.ReplaceAll(
"(",0);
879 m_HistCanvas->Draw();
882 while (padCount > 0) graphPad->GetPad(padCount--)->Clear();
885 m_HistCanvasR->Modified();
886 m_HistCanvasR->Update();
887 if (m_PrintMode & QAU1<<QAprintSetRef &&
888 m_CurPage>0 && !m_CurFileName.IsNull()) {
889 m_HistCanvasR->Print(m_CurFileNameR.Data(),m_OutType.Data());
890 m_CurFileNameR.ReplaceAll(
"(",0);
891 }
else m_HistCanvasR->Draw();
893 while (padCount > 0) graphPadR->GetPad(padCount--)->Clear();
898 if (Lpage) Lpage->SetLabel(Form(
"%d",m_CurPage));
900 if (!m_OutMultiPage && !m_CurFileName.IsNull()) {
901 Ssiz_t last_us = m_CurFileName.Last(
'_') + 1;
902 Ssiz_t lastdot = m_CurFileName.Last(
'.') - last_us;
903 m_CurFileName.Replace(last_us,lastdot,Form(
"%d",m_CurPage));
908 Int_t chkdim = hobj->GetDimension();
911 int curPad = (++padCount);
919 TString onamebase = oname;
920 #define SingleTpcSectorReference false
921 if (SingleTpcSectorReference && onamebase.Contains(
"iTpcSector")) {
924 onamebase.Replace(onamebase.Index(
"iTpcSector")+10,2,
"16");
925 }
else if (SingleTpcSectorReference && onamebase.Contains(
"TpcSector")) {
928 onamebase.Replace(onamebase.Index(
"TpcSector")+9,2,
"9");
930 hobjR = (TH1*) (dirListR->FindObject(onamebase.Data()));
933 onamebase = StripPrefixes(oname,tempint,-1);
934 hobjR = (TH1*) (dirListR->FindObject(onamebase.Data()));
937 onamebase = StripPrefixes(oname,tempint,1);
938 hobjR = (TH1*) (dirListR->FindObject(onamebase.Data()));
941 onamebase = StripPrefixes(oname,tempint,0);
942 hobjR = (TH1*) (dirListR->FindObject(onamebase.Data()));
947 TString htitle = StripPrefixes(hobjR->GetTitle(),tempint,0);
948 if (!htitle.BeginsWith(
"Ref:")) htitle.Prepend(
"Ref:");
949 hobjR->SetTitle(htitle.Data());
952 TVirtualPad* objPad = 0;
953 for (
int analRepeat = 0;analRepeat < (hobjR ? 2 : 1); analRepeat++) {
958 graphPadR->cd(m_QAShiftMode ? 0 : curPad);
960 }
else graphPad->cd(m_QAShiftMode ? 0 : curPad);
963 TRegexp bsmdPerModule(
"bsmd.*PerModule");
965 if (oName.Contains(
"H_matchCand")) {
967 gStyle->SetGridStyle(6);
968 gStyle->SetGridColor(kOrange);
969 }
else if (oName.Contains(bsmdPerModule)) {
970 hobj->GetXaxis()->SetNdivisions(15);
971 hobj->GetXaxis()->SetLabelSize(0.03);
972 hobj->GetXaxis()->SetTitle(
"Module Number");
976 gStyle->SetGridStyle(3);
977 gStyle->SetGridColor(kGray);
981 TRegexp bsmd2DPerModule(
"bsmd.*Strip.*PerModule");
982 if (oName.Contains(
"TpcSector") ||
983 oName.Contains(
"PointRPTpc") ||
984 oName.Contains(
"PointXYTpc") ||
985 oName.Contains(
"TrigBits")) {
986 gStyle->SetOptStat(11);
987 }
else if (oName.Contains(
"NullPrim")) {
988 gStyle->SetOptStat(1111);
989 }
else if (oName.Contains(bsmd2DPerModule)) {
990 gStyle->SetOptStat(0);
991 hobj->GetYaxis()->SetTitle(
"Strip Within Module");
992 hobj->GetYaxis()->SetTitleOffset(1.4);
994 gStyle->SetOptStat(111111);
998 if (oName.Contains(
"TrigBits")) {
999 gPad->SetBottomMargin(0.35);
1000 hobj->GetXaxis()->SetLabelSize(0.03);
1001 hobj->GetXaxis()->SetLabelFont(42);
1003 gPad->SetBottomMargin(0.10);
1006 if (oName.Contains(
"GtrkPadfT")) hobj->SetMinimum(0.8);
1011 Float_t BinCont0 = hobj->GetBinContent(0);
1013 LOG_INFO <<
" -- Will normalize by 1/" << -BinCont0 <<
": " << oname << endm;
1014 hobj->Scale(-1.0/BinCont0);
1020 if (m_ListOfLogY && m_ListOfLogY->FindObject(oname) &&
1021 hobj->GetEntries() && hobj->GetMaximum() ) {
1023 if (!analRepeat) {LOG_INFO <<
" -- Will draw in logY scale: " << oname <<endm;}
1024 }
else gPad->SetLogy(0);
1029 if (m_ListOfLogX && m_ListOfLogX->FindObject(oname) &&
1030 hobj->GetEntries() && hobj->GetMaximum() ) {
1032 if (!analRepeat) {LOG_INFO <<
" -- Will draw in logX scale: " << oname <<endm;}
1033 }
else gPad->SetLogx(0);
1036 if (oName.EndsWith(
"PVsDedx") ||
1037 oName.Contains(
"fms_qt_") ||
1038 oName.Contains(
"fpd_channel_") ||
1039 oName.Contains(
"TofPID") ||
1040 oName.Contains(
"multiplicity_etofHits") ||
1041 oName.Contains(
"eTofHits") ||
1042 oName.Contains(
"etofMult") ||
1043 oName.Contains(
"G_matchCand_") ||
1044 oName.Contains(
"RP_cluster_xy") ||
1045 oName.Contains(
"TpcSector") ||
1046 oName.Contains(
"PointRPTpc") ||
1047 oName.Contains(
"PointXYTpc")) {
1049 if (!analRepeat) {LOG_INFO <<
" -- Will draw in logZ scale: " << oname <<endm;}
1050 }
else gPad->SetLogz(0);
1053 if (oName.EndsWith(
"QaPointTpc") ||
1054 oName.EndsWith(
"QaPointSvt") ||
1055 oName.Contains(
"QaPointSvtLaser") ||
1056 oName.EndsWith(
"QaPointSsd") ||
1057 oName.EndsWith(
"QaPointFtpc") ||
1058 oName.EndsWith(
"QaRichTot") ||
1059 oName.EndsWith(
"QaV0Vtx") ||
1060 oName.EndsWith(
"QaXiVtxTot") ||
1061 oName.Contains(
"QaPmdTotal") ||
1062 oName.Contains(
"QaCpvTotal") ||
1063 oName.EndsWith(
"SImpactTime") ||
1064 oName.EndsWith(
"trkGoodTTS")) {
1065 Float_t mean = hobj->GetMean(1);
1066 Float_t window = hobj->GetRMS(1);
1067 Float_t bwid = hobj->GetXaxis()->GetBinWidth(1);
1068 if (window < bwid) window = bwid;
1069 hobj->SetAxisRange(mean-5*window,mean+5*window,
"X");
1073 if (oName.EndsWith(
"trkGoodF")) {
1074 Float_t mean1 = hobj->GetMean(1);
1075 Float_t mean2 = hobj->GetMean(2);
1076 Float_t window1 = hobj->GetRMS(1);
1077 Float_t window2 = hobj->GetRMS(2);
1078 Float_t bwid = hobj->GetXaxis()->GetBinWidth(1);
1079 if (window1 < bwid) window1 = bwid;
1080 if (window2 < bwid) window2 = bwid;
1081 Float_t lo = TMath::Min(mean1-5*window1,mean2-5*window2);
1082 Float_t hi = TMath::Max(mean1+5*window1,mean2+5*window2);
1083 hobj->SetAxisRange(lo,hi,
"X");
1084 hobj->SetAxisRange(lo,hi,
"Y");
1088 if (oName.Contains(
"VtxFtpc")&&oName.Contains(
"TpcXY")&&m_RunYear!=7){
1089 hobj->GetXaxis()->SetRangeUser(-2.0,2.0);
1090 hobj->GetYaxis()->SetRangeUser(-2.0,2.0);
1094 if (oName.Contains(
"Diff_etofHits")) {
1095 hobj->GetXaxis()->SetRangeUser(0.0,100.0);
1099 if ((chkdim == 3) && (hobj->InheritsFrom(
"StMultiH2F"))) {
1101 }
else if ((chkdim == 3) && (oName.Contains(
"Z3A"))) {
1102 latex.SetTextAngle(0);
1103 latex.SetTextAlign(12);
1104 TH3F* Z3A = (TH3F*) hobj;
1105 Bool_t noneYet = kTRUE;
1108 Double_t slope = 1.7502e-6;
1109 const Char_t *
IO[2] = {
"Inner",
"Outer"};
1110 Double_t xmin[2] = { 40, 40};
1111 Double_t xmax[2] = {200,180};
1112 TF1 *gg = StdEdxY2Maker_Gaus2();
1113 float histmiddle = 0;
1114 for (Int_t io = 1; io <= 2; io++) {
1115 Z3A->GetXaxis()->SetRange(io,io);
1116 TH2 *I = (TH2 *) Z3A->Project3D(Form(
"zy%i",io));
1119 TH1D *proj = (TH1D*) gDirectory->Get(Form(
"%s_1",I->GetName()));
1121 proj->Fit(
"pol1",
"erq",(noneYet ?
"" :
"same"),xmin[io-1],xmax[io-1]);
1122 proj->SetLineColor(8-io);
1123 proj->SetMarkerColor(8-io);
1124 proj->SetMarkerStyle(24-io);
1126 proj->SetTitle(otitle);
1127 TF1 *f = (TF1 *) proj->GetListOfFunctions()->FindObject(
"pol1");
1129 gMessMgr->Info() <<
"StHistUtil: Estimated content of O2 (ppm) "
1130 <<
"from slope in drift distance for "
1131 << Form(
"%s = %10.2f +/- %10.2f", IO[io-1],
1132 -f->GetParameter(1)/slope, f->GetParError(1)/slope)
1134 if (noneYet) histmiddle = f->Eval(100.0);
1135 f->SetLineColor(6-2*io);
1136 latex.SetTextColor(6-2*io);
1137 latex.DrawLatex(20,histmiddle+0.9-0.6*io,Form(
"%s : %10.2f +/- %10.2f\n",
1138 IO[io-1],-f->GetParameter(1)/slope,f->GetParError(1)/slope));
1141 proj->SetMinimum(histmiddle-0.4);
1142 proj->SetMaximum(histmiddle+0.4);
1148 latex.SetTextColor(1);
1149 }
else if ((chkdim==2) && (oName.Contains(
"PointRPTpc") ||
1150 (oName.Contains(
"PointXYTpc") &&
1151 TMath::Abs((hobj->GetYaxis()->GetXmax()/TMath::Pi())-2)<1e-5))) {
1152 TH2F* htmp =
new TH2F(Form(
"%s.",hobj->GetName()),hobj->GetTitle(),1,-200,200,1,-200,200);
1153 float hmin = (oName.Contains(
"PointRPTpcQ") ? 1e-4 : 1.0);
1154 htmp->Fill(0.,0.,hmin); htmp->SetMinimum(hmin);
1155 htmp->SetStats(kFALSE);
1157 hobj->SetMinimum(0.9*hmin);
1158 if (gROOT->GetVersionInt() < 52800) {
1159 hobj->Draw(
"Pol ZCol Same");
1165 FlipAxes(hobj)->Draw(
"Pol ZCol Same");
1167 }
else if ((chkdim == 2) &&
1168 (oName.EndsWith(
"SImpactTime"))) {
1169 hobj->SetMarkerStyle(7);
1170 ((TH2F*) hobj)->Rebin2D(100,1,0);
1171 hobj->SetXTitle(
"Time in run [sec]");
1172 hobj->SetYTitle(
"signed impact (sDCA) [cm]");
1173 ((TH2F*) hobj)->ProfileX()->Draw();
1174 }
else if ((chkdim == 2) &&
1175 (oName.EndsWith(
"SvtLoc") ||
1176 oName.EndsWith(
"PVsDedx") ||
1177 oName.EndsWith(
"VtxPrXY") ||
1178 oName.EndsWith(
"SSD") ||
1179 oName.EndsWith(
"PointXYSvt") ||
1180 oName.Contains(
"TpcSector") ||
1181 oName.Contains(
"PointXYTpc") ||
1182 oName.Contains(
"SectorvsSensor") ||
1183 oName.Contains(
"LaddervsSensor"))) {
1184 if (oName.Contains(
"TpcSector")) {
1186 Double_t max1 = hobj->GetMaximum();
1187 Double_t max2 = hobj->GetMaximum(max1);
1188 if (max1/max2 > 5) hobj->SetBinContent(hobj->GetMaximumBin(),max2);
1191 }
else if ((chkdim == 2) && (!hobj->InheritsFrom(
"StMultiH1F"))) {
1193 if ((oName.EndsWith(
"trkGoodF"))||(oName.EndsWith(
"VtxSvtvsTpc"))) {
1194 ruler.SetLineColor(46);
1195 ruler.SetLineWidth(2);
1196 ruler.DrawLineNDC(0.1,0.1,0.9,0.9);
1199 if (oName.Contains(
"QaBbc") ||
1200 (oName.Contains(
"QaPmd") && !oName.Contains(
"Total")) ||
1201 (oName.Contains(
"QaFpd") && !oName.Contains(
"Sums"))) {
1202 hobj->SetBarOffset();
1204 if (oName.Contains(
"TrigBits")) {
1205 hobj->SetLineWidth(1);
1207 hobj->SetLineWidth(2);
1209 if (oName.EndsWith(
"Mass")) hobj->Draw(
"e");
1211 if (oName.BeginsWith(
"fcl_radial") && (hobj->GetEntries() > 0)) {
1213 hobj->GetXaxis()->SetRangeUser(6.5,9.0);
1214 hobj->Fit(
"pol0",
"",
"", 6.5, 7.2);
1215 double n1= hobj->GetFunction(
"pol0")->GetParameter(0);
1216 hobj->Fit(
"pol0",
"",
"",8.3,9.0);
1217 double n2= hobj->GetFunction(
"pol0")->GetParameter(0);
1218 fitFRS->SetParameters(n1, 7.85, 0.35, n2);
1219 hobj->Fit(fitFRS,
"R");
1221 double rstep = fitFRS->GetParameter(1);
1222 double erstep = fitFRS->GetParError(1);
1223 float hmin = hobj->GetMinimum();
1224 float hmax = hobj->GetMaximum();
1225 ruler.SetLineColor(kBlack);
1226 ruler.SetLineWidth(2);
1227 ruler.DrawLine(7.8,hmin,7.8,hmax);
1228 ruler.SetLineColor(kGreen);
1229 ruler.SetLineWidth(3);
1230 ruler.DrawLine(rstep,hmin,rstep,hmax);
1231 ruler.SetLineWidth(1);
1232 ruler.DrawLine(rstep-erstep,hmin,rstep-erstep,hmax);
1233 ruler.DrawLine(rstep+erstep,hmin,rstep+erstep,hmax);
1239 if (oName.Contains(
"NullPrimVtx")) {
1240 int msdVtx = (int) (hobj->GetBinContent(hobj->FindBin(-1.)));
1241 int qstVtx = (int) (hobj->GetBinContent(hobj->FindBin(0.)));
1242 int goodVtx = (int) (hobj->GetBinContent(hobj->FindBin(1.)));
1243 int fndVtx = qstVtx + goodVtx;
1244 int totVtx = fndVtx + msdVtx;
1245 Float_t txtSiz = latex.GetTextSize();
1246 latex.SetTextSize(txtSiz*1.5);
1247 latex.SetTextAngle(90);
1248 latex.SetTextAlign(3);
1249 latex.SetTextColor(4);
1250 latex.DrawLatex(-0.8,0,Form(
" missed: %d",msdVtx));
1251 latex.DrawLatex(0.2,0,Form(
" questionable: %d",qstVtx));
1252 latex.DrawLatex(1.2,0,Form(
" good: %d",goodVtx));
1253 latex.SetTextSize(txtSiz*2);
1254 latex.SetTextColor(2);
1255 latex.DrawLatex(-1.8,0,Form(
" total: %d",totVtx));
1256 latex.SetTextAlign(1);
1257 latex.SetTextColor(kGreen+3);
1258 latex.DrawLatex(-1.1,0,Form(
" found: %d",fndVtx));
1260 latex.SetTextColor(1);
1261 latex.SetTextSize(txtSiz);
1262 LOG_INFO << (m_CurPrefix ? possiblePrefixes[m_CurPrefix] :
"GE")
1263 << (analRepeat ?
" Ref" :
"")
1264 <<
" QA Events (found vtx/total) "
1265 << fndVtx <<
" / " << totVtx << endm;
1268 if (oName.Contains(
"h1_inv_mass_cluster")) {
1269 ruler.SetLineColor(2);
1270 ruler.SetLineWidth(1);
1271 ruler.DrawLine(0.135,0.,0.135,hobj->GetMaximum());
1274 if (oName.Contains(
"h2_cluster_dgg_vs_E1pE2")) {
1276 fcsFunc1=
new TF1(
"Zgg=0",
"156.20/x",4,30);
1277 fcsFunc1->SetTitle(
"Z_{gg}=0");
1278 fcsFunc2=
new TF1(
"Zgg=0.35",
"166.747/x",4,30);
1279 fcsFunc2->SetTitle(
"Z_{gg}=0.35");
1280 fcsFunc3=
new TF1(
"Zgg=0.70",
"218.72/x",4,30);
1281 fcsFunc3->SetTitle(
"Z_{gg}=0.7");
1282 fcsFunc1->SetLineColor(2);
1283 fcsFunc2->SetLineColor(6);
1284 fcsFunc3->SetLineColor(28);
1286 fcsFunc1->Draw(
"same");
1287 fcsFunc2->Draw(
"same");
1288 fcsFunc3->Draw(
"same");
1291 if (oName.Contains(
"iTpcSector")) {
1293 ruler.SetLineColor(1);
1294 ruler.SetLineWidth(1);
1296 float pitch = 0.67/2.0;
1297 ruler.DrawLine(-137*pitch,64.5,137*pitch,64.5);
1298 ruler.DrawLine(-123*pitch,56.5,123*pitch,56.5);
1299 ruler.DrawLine(-111*pitch,48.5,111*pitch,48.5);
1300 ruler.DrawLine( -97*pitch,40.5, 97*pitch,40.5);
1303 int row_width = 70;
int in_step1 = 52;
int in_step2 = 54;
1304 float row1=10.5;
float row2 = row1+1.0;
float row3 = row1+2.0;
1305 ruler.DrawLine(-(row_width-in_step2)*pitch,row3,(row_width-in_step2)*pitch,row3);
1306 ruler.DrawLine(-(row_width-in_step2)*pitch,row2,-(row_width-in_step1)*pitch,row2);
1307 ruler.DrawLine((row_width-in_step2)*pitch,row2,(row_width-in_step1)*pitch,row2);
1308 ruler.DrawLine(-row_width*pitch,row1,-(row_width-in_step1)*pitch,row1);
1309 ruler.DrawLine((row_width-in_step1)*pitch,row1,row_width*pitch,row1);
1310 ruler.DrawLine(-(row_width-in_step1)*pitch,row1,-(row_width-in_step1)*pitch,row2);
1311 ruler.DrawLine((row_width-in_step1)*pitch,row1,(row_width-in_step1)*pitch,row2);
1312 ruler.DrawLine(-(row_width-in_step2)*pitch,row3,-(row_width-in_step2)*pitch,row2);
1313 ruler.DrawLine((row_width-in_step2)*pitch,row3,(row_width-in_step2)*pitch,row2);
1315 bool east = (atoi(&(oName.Data()[oName.Last(
'r')+1])) > 12);
1316 pitch = (east ? 0.50 : -0.50);
1317 float p01 = 46*pitch;
float row01 = 22.5;
1318 float p02 = 36*pitch;
float row02 = 22.5;
1319 float p03 = 36*pitch;
float row03 = 21.5;
1320 float p04 = 39*pitch;
float row04 = 21.5;
1321 float p05 = 39*pitch;
float row05 = 20.5;
1322 float p06 = 19*pitch;
float row06 = 20.5;
1323 float p07 = 19*pitch;
float row07 = 22.5;
1324 float p08 = 9*pitch;
float row08 = 22.5;
1325 float p09 = 9*pitch;
float row09 = 23.5;
1326 float p10 = 2*pitch;
float row10 = 23.5;
1327 float p11 = 2*pitch;
float row11 = 24.5;
1328 ruler.DrawLine( p01,row01, p02,row02);
1329 ruler.DrawLine( p02,row02, p03,row03);
1330 ruler.DrawLine( p03,row03, p04,row04);
1331 ruler.DrawLine( p04,row04, p05,row05);
1332 ruler.DrawLine( p05,row05, p06,row06);
1333 ruler.DrawLine( p06,row06, p07,row07);
1334 ruler.DrawLine( p07,row07, p08,row08);
1335 ruler.DrawLine( p08,row08, p09,row09);
1336 ruler.DrawLine( p09,row09, p10,row10);
1337 ruler.DrawLine( p10,row10, p11,row11);
1338 ruler.DrawLine(-p01,row01,-p02,row02);
1339 ruler.DrawLine(-p02,row02,-p03,row03);
1340 ruler.DrawLine(-p03,row03,-p04,row04);
1341 ruler.DrawLine(-p04,row04,-p05,row05);
1342 ruler.DrawLine(-p05,row05,-p06,row06);
1343 ruler.DrawLine(-p06,row06,-p07,row07);
1344 ruler.DrawLine(-p07,row07,-p08,row08);
1345 ruler.DrawLine(-p08,row08,-p09,row09);
1346 ruler.DrawLine(-p09,row09,-p10,row10);
1347 ruler.DrawLine(-p10,row10,-p11,row11);
1348 ruler.DrawLine(-p11,row11, p11,row11);
1350 p01 = 0*pitch; row01 = 24.5;
1351 p02 = 0*pitch; row02 = 26.5;
1352 p03 = -7*pitch; row03 = 26.5;
1353 p04 = -7*pitch; row04 = 28.5;
1354 p05 = -8*pitch; row05 = 28.5;
1355 p06 = -8*pitch; row06 = 30.5;
1356 p07 = 10*pitch; row07 = 30.5;
1357 p08 = 10*pitch; row08 = 32.5;
1358 p09 = 11*pitch; row09 = 32.5;
1359 p10 = 11*pitch; row10 = 35.5;
1360 p11 = 10*pitch; row11 = 35.5;
1361 float p12 = 10*pitch;
float row12 = 36.5;
1362 float p13 = 0*pitch;
float row13 = 36.5;
1363 float p14 = 0*pitch;
float row14 = 40.5;
1364 ruler.DrawLine(p01,row01,p02,row02);
1365 ruler.DrawLine(p02,row02,p03,row03);
1366 ruler.DrawLine(p03,row03,p04,row04);
1367 ruler.DrawLine(p04,row04,p05,row05);
1368 ruler.DrawLine(p05,row05,p06,row06);
1369 ruler.DrawLine(p06,row06,p07,row07);
1370 ruler.DrawLine(p07,row07,p08,row08);
1371 ruler.DrawLine(p08,row08,p09,row09);
1372 ruler.DrawLine(p09,row09,p10,row10);
1373 ruler.DrawLine(p10,row10,p11,row11);
1374 ruler.DrawLine(p11,row11,p12,row12);
1375 ruler.DrawLine(p12,row12,p13,row13);
1376 ruler.DrawLine(p13,row13,p14,row14);
1377 latex.SetTextAngle(0);
1378 latex.SetTextAlign(32);
1379 latex.DrawLatex(50,5,
"RDO 1");
1380 latex.DrawLatex(50,18,
"2");
1381 latex.DrawLatex(50,33,(east ?
"4 , 3" :
"3 , 4"));
1382 latex.DrawLatex(50,44,
"5");
1383 latex.DrawLatex(50,52,
"6");
1384 latex.DrawLatex(50,60,
"7");
1385 latex.DrawLatex(50,68,
"8");
1388 ruler.SetLineColor(2);
1389 ruler.DrawLine(-52,10.5,-47,10.5);
1390 ruler.DrawLine(-52,20.5,-47,20.5);
1391 ruler.DrawLine(-52,30.5,-47,30.5);
1392 ruler.DrawLine(-52,40.5,-47,40.5);
1393 ruler.DrawLine(-52,48.1,-47,48.1);
1394 ruler.DrawLine(-52,56.1,-47,56.1);
1395 ruler.DrawLine(-52,64.1,-47,64.1);
1396 latex.SetTextAlign(12);
1397 latex.SetTextColor(2);
1398 latex.DrawLatex(-50, 5.1,
"1 Anode");
1399 latex.DrawLatex(-50,15.1,
"2");
1400 latex.DrawLatex(-50,25.1,
"3");
1401 latex.DrawLatex(-50,35.1,
"4");
1402 latex.DrawLatex(-50,44.1,
"5");
1403 latex.DrawLatex(-50,52.1,
"6");
1404 latex.DrawLatex(-50,60.1,
"7");
1405 latex.DrawLatex(-50,68.1,
"8");
1406 latex.SetTextColor(1);
1407 }
else if (oName.Contains(
"TpcSector")) {
1409 ruler.SetLineColor(1);
1410 ruler.SetLineWidth(1);
1412 float pitch = 0.67/2.0;
1413 ruler.DrawLine(-137*pitch,37.5,137*pitch,37.5);
1414 ruler.DrawLine(-123*pitch,29.5,123*pitch,29.5);
1415 ruler.DrawLine(-111*pitch,21.5,111*pitch,21.5);
1416 ruler.DrawLine( -97*pitch,13.5, 97*pitch,13.5);
1419 int row_width = 134;
int in_step = 68;
float row1=6.5;
1421 float row2 = row1+1.0;
1422 ruler.DrawLine(-(row_width-in_step)*pitch,row2,(row_width-in_step)*pitch,row2);
1423 ruler.DrawLine(-row_width*pitch,row1,-(row_width-in_step)*pitch,row1);
1424 ruler.DrawLine((row_width-in_step)*pitch,row1,row_width*pitch,row1);
1425 ruler.DrawLine(-(row_width-in_step)*pitch,row1,-(row_width-in_step)*pitch,row2);
1426 ruler.DrawLine((row_width-in_step)*pitch,row1,(row_width-in_step)*pitch,row2);
1427 latex.SetTextAngle(0);
1428 latex.SetTextAlign(32);
1429 latex.DrawLatex(50,4,
"RDO 1");
1430 latex.DrawLatex(50,10,
"2");
1431 latex.DrawLatex(50,17,
"3");
1432 latex.DrawLatex(50,25,
"4");
1433 latex.DrawLatex(50,33,
"5");
1434 latex.DrawLatex(50,41,
"6");
1437 ruler.SetLineColor(2);
1438 ruler.DrawLine(-52,2.9,-47,2.9);
1439 ruler.DrawLine(-52,6.2,-47,6.2);
1440 ruler.DrawLine(-52,9.4,-47,9.4);
1441 ruler.DrawLine(-52,13.5,-47,13.5);
1442 ruler.DrawLine(-52,21.1,-47,21.1);
1443 ruler.DrawLine(-52,29.1,-47,29.1);
1444 ruler.DrawLine(-52,37.1,-47,37.1);
1445 latex.SetTextAlign(12);
1446 latex.SetTextColor(2);
1447 latex.DrawLatex(-50,1.5,
"1 Anode");
1448 latex.DrawLatex(-50,4.6,
"2");
1449 latex.DrawLatex(-50,7.8,
"3");
1450 latex.DrawLatex(-50,11.4,
"4");
1451 latex.DrawLatex(-50,17.1,
"5");
1452 latex.DrawLatex(-50,25.1,
"6");
1453 latex.DrawLatex(-50,33.1,
"7");
1454 latex.DrawLatex(-50,41.1,
"8");
1455 latex.SetTextColor(1);
1458 if (oName.Contains(
"PointRPTpc") ||
1459 oName.Contains(
"PointXYTpc") ) {
1461 int eastsec = (oName.Contains(
"TpcE") || oName.Contains(
"TpcQE") ? 12 : 0);
1462 ruler.SetLineColor(0);
1463 ruler.SetLineStyle(2);
1464 float sz = latex.GetTextSize();
1465 latex.SetTextAlign(32);
1466 latex.SetTextSize(0.032);
1467 int secn = (eastsec ? 21 : 13);
1468 float phistep = TMath::Pi()/12;
1469 for (
float phi=phistep; phi<6.2; phi+=phistep) {
1470 float xsec = TMath::Cos(phi);
1471 float ysec = TMath::Sin(phi);
1472 ruler.DrawLine(50*xsec,50*ysec,199*xsec,199*ysec);
1474 xsec = TMath::Cos(phi);
1475 ysec = TMath::Sin(phi);
1476 latex.SetTextAngle(phi*180/TMath::Pi()+1);
1477 latex.DrawLatex(52*xsec,52*ysec,Form(
"%d",secn%12 + eastsec + 1));
1478 secn += (eastsec ? 1 : -1);
1480 latex.SetTextSize(sz);
1481 ruler.SetLineStyle(1);
1484 if (oName.EndsWith(
"QaPointPhiT")) {
1485 float hmin = hobj->GetMinimum() ;
1486 float hmax = hobj->GetMaximum() ;
1487 float hmid = hmin+0.12*(hmax-hmin);
1488 float sz = latex.GetTextSize();
1489 latex.SetTextSize(0.045);
1490 latex.SetTextColor(2);
1491 latex.SetTextAngle(90);
1492 latex.SetTextAlign(22);
1493 for (
int secn = 1; secn < 13; secn++) {
1494 float phisec = 87 - secn*30;
1495 while (phisec < 1) phisec += 360;
1496 latex.DrawLatex(phisec,hmid,Form(
"%d / %d",secn,(23-secn)%12 + 13));
1498 latex.SetTextSize(sz);
1499 latex.SetTextColor(1);
1500 latex.SetTextAngle(0);
1503 if ((chkdim == 2) && (oName.Contains(
"TPC_charge"))) {
1504 TH2F* hobj_TPC_charge = (TH2F*) hobj;
1506 TProfile *prof_hobjTPC = (TProfile*) hobj_TPC_charge->ProfileX();
1507 prof_hobjTPC->SetMarkerStyle(20);
1508 prof_hobjTPC->SetMarkerSize(0.6);
1509 prof_hobjTPC->SetMarkerColor(6);
1510 prof_hobjTPC->SetLineColor(6);
1513 static TF1 *flandau = 0;
1514 if (!flandau) flandau =
new TF1(
"flandau",
"[0]*TMath::Landau(x,[1],[2])",0,200);
1515 flandau->SetParameters(2e-3*(hobj->GetEntries()), 125, 30);
1516 hobj_TPC_charge->FitSlicesY(flandau);
1518 TH1D *mean_landau = (TH1D*) (gDirectory->Get(Form(
"%s_1",hobj_TPC_charge->GetName())));
1520 mean_landau->SetMarkerStyle(20);
1521 mean_landau->SetMarkerSize(0.6);
1522 mean_landau->SetMarkerColor(1);
1523 mean_landau->Draw(
"same p");
1525 LOG_WARN <<
"TPC_charge Landau FitSlicesY failed for " << hobj->GetName() << endm;
1537 prof_hobjTPC->Draw(
"same p");
1540 TLegend *ilegend =
new TLegend(0.15,0.80,0.38,0.90);
1541 ilegend->SetFillColor(0);
1542 ilegend->SetHeader(
"Legend");
1543 ilegend->SetMargin(0.25);
1544 ilegend->AddEntry(prof_hobjTPC,
"Profile mean",
"pz");
1545 ilegend->AddEntry(mean_landau,
"Landau MPV",
"pz");
1549 if (padAdvance) {
if (gPad) gPad->Update();}
1550 else {
if (!analRepeat) padCount--;}
1563 TString onamebase = StripPrefixes(oname,tempint,-1);
1564 huR = (
StHistUtilRef*) (m_refCuts->FindObject(onamebase.Data()));
1567 onamebase = StripPrefixes(oname,tempint,1);
1568 huR = (
StHistUtilRef*) (m_refCuts->FindObject(onamebase.Data()));
1571 onamebase = StripPrefixes(oname,tempint,0);
1572 huR = (
StHistUtilRef*) (m_refCuts->FindObject(onamebase.Data()));
1580 int mode = ( huR ? huR->Mode : 2 );
1581 double cut = ( huR ? huR->Cut : 0);
1586 result = hobjO->Chi2Test(hobjR,(huR ? huR->Options() :
"WW"));
1594 result = hobjO->KolmogorovTest(hobjR,(huR ? huR->Options() :
""));
1598 TString analOpts = (huR ? huR->Options() :
"");
1600 if (! analOpts.Contains(
'M')) analOpts +=
'M';
1601 result = 1.0 - hobjO->KolmogorovTest(hobjR,analOpts.Data());
1604 bool analPass = (result >= cut);
1606 TString score = Form(
"Score: %4.2f (%s vs. %4.2f)",result,
1607 (analPass ?
"PASS" :
"FAIL"),cut);
1609 if (m_PrintMode & QAU1<<QAprintIndivRef)
1610 gPad->Print(Form(
"Ref_%s%s",oName.Data(),m_OutIndividuals.Data()));
1612 gPad->Print(Form(
"Ref_%s.png",oName.Data()));
1616 float sz = latex.GetTextSize();
1617 latex.SetTextSize(0.038);
1618 latex.SetTextAngle(90);
1619 latex.SetTextAlign(11);
1620 latex.SetTextColor(analPass ? kGreen+4 : kRed+2);
1621 latex.DrawTextNDC(0.999,0.001,score.Data());
1623 latex.SetTextColor(1);
1624 latex.SetTextSize(sz);
1625 if (m_PrintMode & QAU1<<QAprintIndiv)
1626 gPad->Print(Form(
"%s%s",oName.Data(),m_OutIndividuals.Data()));
1628 gPad->Print(Form(
"%s.png",oName.Data()));
1632 LOG_INFO << Form(
" - %d. Reference Test (mode=%d) %s",
1633 histReadCounter,mode,score.Data()) << endm;
1634 if (strlen(m_refResultsFile)) {
1635 if (!R_ostr) R_ostr =
new ofstream(m_refResultsFile);
1636 (*R_ostr) << m_CurPage <<
" " << curPad <<
" " << oName <<
" " << result << endl;
1639 if (m_PrintMode & QAU1<<QAprintIndiv)
1640 gPad->Print(Form(
"%s%s",oName.Data(),m_OutIndividuals.Data()));
1642 gPad->Print(Form(
"%s.png",oName.Data()));
1643 if (strlen(m_refResultsFile)) {
1644 if (!R_ostr) R_ostr =
new ofstream(m_refResultsFile);
1645 (*R_ostr) << m_CurPage <<
" " << curPad <<
" " << oName <<
" 1.0" << endl;
1660 if (C_ostr)
delete C_ostr;
1661 if (R_ostr)
delete R_ostr;
1662 if (root_ofile)
delete root_ofile;
1671 TList* StHistUtil::FindHists(
const Char_t *dirName,
const Char_t *withPrefix)
1684 LOG_INFO <<
" Beg: FindHists, dList pointer = " << dList << endm;
1694 PathCopy(m_dirName,dirName);
1695 StMaker *temp = m_PntrToMaker->GetMaker(m_dirName);
1698 LOG_INFO <<
"FindHists - found pointer to maker" << endm;
1699 dList = temp->Histograms();
1705 if (dList) test = dList->First();
1707 LOG_INFO <<
" FindHists - found hist. in Maker-Branch " << endm;
1710 LOG_INFO <<
" Mid: FindHists, dList pointer = " << dList << endm;
1711 LOG_INFO <<
" Mid: FindHists, test pointer = " << test << endm;
1715 if (!test) dList = 0;
1717 LOG_INFO <<
" Mid2: FindHists, dList pointer = " << dList << endm;
1718 LOG_INFO <<
" Mid2: FindHists, test pointer = " << test << endm;
1729 hist = m_PntrToMaker->GetDataSet(
"hist");
1737 TString hBN(m_dirName);
1742 QAH = hist->
Find(hBN.Data());
1754 LOG_INFO <<
" FindHists - found hist. in histBranch, with name: "
1755 << m_dirName << endm;
1758 LOG_INFO <<
" FindHists - histogram branch has not been found for branch --> "
1759 << m_dirName << endm;
1764 if (dList && (withPrefix || m_ListOfPrint)) dList = TrimListByPrefix(dList,withPrefix);
1766 LOG_INFO <<
" FindHists, dList pointer = " << dList << endm;
1773 TList* StHistUtil::FindHists(TFile* histFile,
const Char_t* withPrefix) {
1774 if (!histFile)
return 0;
1775 TList* dList = histFile->GetList();
1776 if (dList->GetSize() == 0) {
1777 histFile->ReadAll();
1778 dList = histFile->GetList();
1781 TObject* test = (dList ? dList->First() : 0);
1782 LOG_INFO <<
" Mid5: FindHists, dList pointer = " << dList << endm;
1783 LOG_INFO <<
" Mid5: FindHists, test pointer = " << test << endm;
1784 if (!test) dList = 0;
1786 if (dList && (withPrefix || m_ListOfPrint)) dList = TrimListByPrefix(dList,withPrefix);
1791 TList* StHistUtil::TrimListByPrefix(TList* dList,
const Char_t* withPrefix) {
1792 TList* dList2 =
new TList;
1796 TIter nextObj(dList);
1798 int withPrefixNumber = -1;
1799 int prefixNumber = -1;
1800 if (withPrefix) StripPrefixes(withPrefix,withPrefixNumber);
1801 while ((obj = nextObj())) {
1802 Bool_t addIt = kTRUE;
1804 StripPrefixes(obj->GetName(),prefixNumber);
1805 if (prefixNumber != withPrefixNumber) addIt = kFALSE;
1807 if (addIt && ((!m_ListOfPrint) ||
1808 (obj->InheritsFrom(
"TH1") &&
1809 m_ListOfPrint->FindObject(obj->GetName())))) dList2->AddLast(obj);
1811 m_ItemsToClear->Add(dList2);
1817 Int_t StHistUtil::ListHists(
const Char_t *dirName)
1823 LOG_INFO <<
" **** Now in StHistUtil::ListHists **** " << endm;
1827 TList* dirList = (m_PntrToMaker ? FindHists(dirName) : FindHists(m_PntrToPlainFile));
1829 if (!dirList) { LOG_INFO <<
" ListHists - histograms not available! " << endm; }
1833 TIter nextObj(dirList);
1834 Int_t histReadCount = 0;
1838 while ((obj = nextObj())) {
1841 if (obj->InheritsFrom(
"TH1")) {
1846 LOG_INFO <<
" ListHists: Hist No. " << histReadCount <<
", Type: " << obj->ClassName()
1847 <<
", Name: " << obj->GetName() <<
", Title \"" << obj->GetTitle() <<
"\" "<< endm;
1851 LOG_INFO <<
" ListHists: Total No. Histograms Booked = " << histReadCount <<endm;
1852 return histReadCount;
1858 Int_t StHistUtil::PrintInfoHists(TList *dirList,
const Char_t *fname )
1861 LOG_INFO <<
" **** Now in StHistUtil::PrintInfoHists **** " << endm;
1862 LOG_INFO <<
" output file = " << fname << endm;
1864 ofstream fout(fname);
1866 if (!dirList) { LOG_INFO <<
" PrintInfoHists - histograms not available! " << endm; }
1868 Int_t histInfoCount = 0;
1874 TIter nextObj(dirList);
1877 LOG_INFO <<
" Hist #, Name, #Entries, Mean, RMS " << endm;
1878 fout <<
" Hist #, Name, #Entries, Mean, RMS " << endl;
1882 while ((obj = nextObj())) {
1885 if (obj->InheritsFrom(
"TH1")) {
1890 histInfoCount <<
" " <<
1891 obj->GetName() <<
" " <<
1892 ((TH1 *)obj)->GetEntries() <<
" " <<
1893 ((TH1 *)obj)->GetMean() <<
" " <<
1894 ((TH1 *)obj)->GetRMS() <<
" " <<
1898 histInfoCount <<
" " <<
1899 obj->GetName() <<
" " <<
1900 ((TH1 *)obj)->GetEntries() <<
" " <<
1901 ((TH1 *)obj)->GetMean() <<
" " <<
1902 ((TH1 *)obj)->GetRMS() <<
" " <<
1909 LOG_INFO <<
" PrintInfoHists: # hist read = " << histInfoCount <<endm;
1911 return histInfoCount;
1918 Int_t StHistUtil::CopyHists(TList *dirList)
1921 LOG_INFO <<
" **** Now in StHistUtil::CopyHists **** " << endm;
1924 if (!dirList) { LOG_INFO <<
" StHistUtil::CopyHists - histogram Pointer not set! " << endm; }
1928 Int_t tempint,ijk=0;
1929 Int_t histCopyCount = 0;
1932 TIter nextObj(dirList);
1934 while ((obj = nextObj())) {
1935 if (obj->InheritsFrom(
"TH1") &&
1936 (!m_ListOfPrint || (m_ListOfPrint->FindObject(obj->GetName())))) {
1938 if (ijk >= maxHistCopy - 1){
1939 Int_t newMaxHistCopy = maxHistCopy * 4;
1940 TH1** temp1 =
new TH1ptr[newMaxHistCopy];
1941 memset(temp1,0,newMaxHistCopy*sizeOfTH1Ptr);
1942 memcpy(temp1,newHist,maxHistCopy*sizeOfTH1Ptr);
1945 maxHistCopy = newMaxHistCopy;
1947 newHist[ijk] = ((TH1 *)obj->Clone());
1948 if (ignorePrefixes) {
1949 newHist[ijk]->SetName (StripPrefixes(newHist[ijk]->GetName (),tempint).Data());
1950 newHist[ijk]->SetTitle(StripPrefixes(newHist[ijk]->GetTitle(),tempint).Data());
1957 LOG_INFO <<
" ListHists: Total No. Histograms Copied = " <<
1958 histCopyCount <<endm;
1971 return histCopyCount;
1981 Int_t StHistUtil::AddHists(TList *dirList,Int_t numHistCopy)
1984 LOG_INFO <<
" **** Now in StHistUtil::AddHists **** " << endm;
1988 if (!dirList) { LOG_INFO <<
1989 " StHistUtil::AddHists - histogram Pointer not set! " << endm; }
1991 Int_t histAddCount = 0;
1995 if (numHistCopy < 0) numHistCopy = dirList->GetSize();
1996 TIter nextObj(dirList);
1999 while ((obj = nextObj())) {
2000 if (obj->InheritsFrom(
"TH1")) {
2001 TString oName = obj->GetName();
2002 if (ignorePrefixes) oName = StripPrefixes(oName.Data(),tempInt);
2004 Int_t tempint,imk = 0;
2005 Bool_t notfound =
true;
2006 for (imk=0;imk<maxHistCopy;imk++) {
2008 TString nName = newHist[imk]->GetName();
2009 if (ignorePrefixes) nName = StripPrefixes(nName.Data(),tempInt);
2010 if (! (nName.CompareTo(oName))) {
2012 newHist[imk]->Add((TH1 *)obj);
2022 if (imk >= maxHistCopy-1){
2023 Int_t newMaxHistCopy = maxHistCopy * 4;
2024 TH1** temp1 =
new TH1ptr[newMaxHistCopy];
2025 memset(temp1,0,newMaxHistCopy*sizeOfTH1Ptr);
2026 memcpy(temp1,newHist,maxHistCopy*sizeOfTH1Ptr);
2029 maxHistCopy = newMaxHistCopy;
2031 newHist[imk] = ((TH1 *)obj->Clone());
2032 if (ignorePrefixes) {
2033 newHist[imk]->SetName (StripPrefixes(newHist[imk]->GetName (),tempint).Data());
2034 newHist[imk]->SetTitle(StripPrefixes(newHist[imk]->GetTitle(),tempint).Data());
2044 LOG_INFO <<
" StHistUtil::AddHists: Total No. Histograms Added = " <<
2045 histAddCount <<endm;
2048 return histAddCount;
2054 Int_t StHistUtil::ExamineLogYList()
2060 LOG_INFO <<
" **** Now in StHistUtil::ExamineLogYList **** " << endm;
2067 TIter nextObj(m_ListOfLogY);
2068 Int_t LogYCount = 0;
2071 while ((obj = nextObj())) {
2073 if (Debug()) { LOG_INFO <<
" StHistUtil::ExamineLogYList has hist " << obj->GetName() << endm; }
2078 LOG_INFO <<
" Now in StHistUtil::ExamineLogYList, No. Hist. in LogY scale = " << LogYCount <<endm;
2085 Int_t StHistUtil::ExamineLogXList()
2091 LOG_INFO <<
" **** Now in StHistUtil::ExamineLogXList **** " << endm;
2098 TIter nextObj(m_ListOfLogX);
2099 Int_t LogXCount = 0;
2102 while ((obj = nextObj())) {
2105 LOG_INFO <<
" StHistUtil::ExamineLogXList has hist " << obj->GetName() << endm;
2111 LOG_INFO <<
" Now in StHistUtil::ExamineLogXList, No. Hist. in LogX scale = " << LogXCount <<endm;
2118 Int_t StHistUtil::ExaminePrintList()
2124 LOG_INFO <<
" **** Now in StHistUtil::ExaminePrintList **** " << endm;
2130 if (!m_ListOfPrint){
2131 LOG_INFO <<
" no subset print list was setup - all hist in directory will be printed " << endm;
2140 TIter nextObj(m_ListOfPrint);
2141 Int_t PrintCount = 0;
2144 while ((obj = nextObj())) {
2147 LOG_INFO <<
" StHistUtil::ExaminePrintList has hist " << obj->GetName() << endm;
2153 LOG_INFO <<
" Now in StHistUtil::ExaminePrintList, No. Hist. to Print,Draw = " << PrintCount <<endm;
2154 return m_ListOfPrint->GetSize();
2160 Int_t StHistUtil::AddToLogYList(
const Char_t *HistName){
2165 LOG_INFO <<
" **** Now in StHistUtil::AddToLogYList **** " << endm;
2170 if (!m_ListOfLogY) m_ListOfLogY =
new TList;
2174 TObjString *HistNameObj =
new TObjString(HistName);
2178 lobj = m_ListOfLogY->FindObject(HistName);
2181 m_ListOfLogY->Add(HistNameObj);
2183 LOG_INFO <<
" StHistUtil::AddToLogYList: " << HistName <<endm;
2186 LOG_INFO <<
" StHistUtil::AddToLogYList: " << HistName <<
" already in list - not added" <<endm;
2190 return m_ListOfLogY->GetSize();
2197 Int_t StHistUtil::AddToLogXList(
const Char_t *HistName){
2202 LOG_INFO <<
" **** Now in StHistUtil::AddToLogXList **** " << endm;
2207 if (!m_ListOfLogX) m_ListOfLogX =
new TList;
2211 TObjString *HistNameObj =
new TObjString(HistName);
2215 lobj = m_ListOfLogX->FindObject(HistName);
2218 m_ListOfLogX->Add(HistNameObj);
2220 LOG_INFO <<
" StHistUtil::AddToLogXList: " << HistName <<endm;
2223 LOG_INFO <<
" StHistUtil::AddToLogXList: " << HistName <<
" already in list - not added" <<endm;
2227 return m_ListOfLogX->GetSize();
2234 Int_t StHistUtil::AddToPrintList(
const Char_t *HistName){
2240 LOG_INFO <<
" **** Now in StHistUtil::AddToPrintList **** " << endm;
2245 if (!m_ListOfPrint) m_ListOfPrint =
new TList;
2249 TObjString *HistNameObj =
new TObjString(HistName);
2252 if (!m_ListOfPrint->Contains(HistName)) {
2253 m_ListOfPrint->Add(HistNameObj);
2255 LOG_INFO <<
" StHistUtil::AddToPrintList: " << HistName <<endm;
2258 LOG_INFO <<
" StHistUtil::AddToPrintList: " << HistName <<
" already in list - not added" <<endm;
2262 return m_ListOfPrint->GetSize();
2268 Int_t StHistUtil::RemoveFromLogYList(
const Char_t *HistName){
2273 LOG_INFO <<
" **** Now in StHistUtil::RemoveFromLogYList **** " << endm;
2282 lobj = m_ListOfLogY->FindObject(HistName);
2285 m_ListOfLogY->Remove(lobj);
2287 LOG_INFO <<
" RemoveLogYList: " << HistName <<
" has been removed from list" <<endm;
2290 LOG_INFO <<
" RemoveLogYList: " << HistName <<
" not on list - not removing" <<endm;
2294 return m_ListOfLogY->GetSize();
2297 LOG_INFO <<
" RemoveLogYList: " << HistName <<
" not on list - not removing" <<endm;
2304 Int_t StHistUtil::RemoveFromLogXList(
const Char_t *HistName){
2309 LOG_INFO <<
" **** Now in StHistUtil::RemoveFromLogXList **** " << endm;
2318 lobj = m_ListOfLogX->FindObject(HistName);
2321 m_ListOfLogX->Remove(lobj);
2323 LOG_INFO <<
" RemoveLogXList: " << HistName <<
" has been removed from list" <<endm;
2326 LOG_INFO <<
" RemoveLogXList: " << HistName <<
" not on list - not removing" <<endm;
2330 return m_ListOfLogX->GetSize();
2333 LOG_INFO <<
" RemoveLogXList: " << HistName <<
" not on list - not removing" <<endm;
2340 Int_t StHistUtil::RemoveFromPrintList(
const Char_t *HistName){
2345 LOG_INFO <<
" **** Now in StHistUtil::RemoveFromPrintList **** " << endm;
2349 if (m_ListOfPrint) {
2354 lobj = m_ListOfPrint->FindObject(HistName);
2357 m_ListOfPrint->Remove(lobj);
2359 LOG_INFO <<
" RemovePrintList: " << HistName <<
" has been removed from list" <<endm;
2362 LOG_INFO <<
" RemovePrintList: " << HistName <<
" not on list - not removing" <<endm;
2366 return m_ListOfPrint->GetSize();
2369 LOG_INFO <<
" RemovePrintList: " << HistName <<
" not on list - not removing" <<endm;
2378 void StHistUtil::SetDefaultLogYList(
const Char_t *dirName)
2384 LOG_INFO <<
" **** Now in StHistUtil::SetDefaultLogYList **** " << endm;
2388 PathCopy(m_dirName,dirName);
2390 if (!strcmp(m_dirName,
"QA"))
2392 else if (!strcmp(m_dirName,
"EventQA"))
2397 const Char_t* sdefList[] = {
2398 #include "St_QA_Maker/QAhlist_logy.h"
2401 Int_t lengofList =
sizeof(sdefList)/sizeOfCharPtr;
2404 for (ilg=0;ilg<lengofList;ilg++) {
2405 TString listString = sdefList[ilg];
2406 if (!(listString.BeginsWith(
"fcl") ||
2407 listString.BeginsWith(
"fms_qt_") ||
2408 listString.BeginsWith(
"fpd_channel_"))) {
2409 for (Int_t k=0; k<numOfPosPrefixes; k++) {
2410 ((listString = type) += possiblePrefixes[k]) += sdefList[ilg];
2411 numLog = AddToLogYList(listString.Data());
2413 }
else numLog = AddToLogYList(listString.Data());
2416 LOG_INFO <<
" !!! StHistUtil::SetDefaultLogYList, # histogram put in list " << numLog << endm;
2424 void StHistUtil::SetDefaultLogXList(
const Char_t *dirName)
2430 LOG_INFO <<
" **** Now in StHistUtil::SetDefaultLogXList **** " << endm;
2433 PathCopy(m_dirName,dirName);
2435 if (!strcmp(m_dirName,
"QA"))
2437 else if (!strcmp(m_dirName,
"EventQA"))
2442 const Char_t* sdefList[] = {
2443 #include "St_QA_Maker/QAhlist_logx.h"
2446 Int_t lengofList =
sizeof(sdefList)/sizeOfCharPtr;
2449 for (ilg=0;ilg<lengofList;ilg++) {
2450 TString listString = sdefList[ilg];
2451 if (!(listString.BeginsWith(
"fcl") ||
2452 listString.BeginsWith(
"fms_qt_") ||
2453 listString.BeginsWith(
"fpd_channel_"))) {
2454 for (Int_t k=0; k<numOfPosPrefixes; k++) {
2455 ((listString = type) += possiblePrefixes[k]) += sdefList[ilg];
2456 numLog = AddToLogXList(listString.Data());
2458 }
else numLog = AddToLogXList(listString.Data());
2461 LOG_INFO <<
" !!! StHistUtil::SetDefaultLogXList, # histogram put in list " << numLog << endm;
2474 void StHistUtil::SetDefaultPrintList(
const Char_t *dirName,
const Char_t *analType)
2477 LOG_INFO <<
" **** Now in StHistUtil::SetDefaultPrintList **** " << endm;
2479 const Char_t **sdefList=0;
2480 Int_t lengofList = 0;
2481 bool mustDeleteList =
false;
2483 PathCopy(m_dirName,dirName);
2485 if (!strcmp(m_dirName,
"QA"))
2487 else if (!strcmp(m_dirName,
"EventQA"))
2494 if ((!strcmp(analType,
"")) || (!strcmp(analType,
"All")) ) {
2495 LOG_INFO <<
" All histograms in directory will be printed/drawn, no list set" << endm;
2500 const Char_t* sdefList1[] = {
2501 #include "St_QA_Maker/QAhlist_QA_Cosmic.h"
2503 if ((!strcmp(m_dirName,
"QA")) && (!strcmp(analType,
"Cosmic"))) {
2504 sdefList = sdefList1; lengofList =
sizeof(sdefList1)/sizeOfCharPtr;
2508 const Char_t* sdefList2[] = {
2509 #include "St_QA_Maker/QAhlist_QA_TestQATable.h"
2511 if ((!strcmp(m_dirName,
"QA")) && (!strcmp(analType,
"TestQATable"))) {
2512 sdefList = sdefList2; lengofList =
sizeof(sdefList2)/sizeOfCharPtr;
2516 const Char_t* sdefList3[] = {
2517 #include "St_QA_Maker/QAhlist_QA_Ftpc.h"
2519 if ((!strcmp(m_dirName,
"QA")) && (!strcmp(analType,
"Ftpc"))) {
2520 sdefList = sdefList3; lengofList =
sizeof(sdefList3)/sizeOfCharPtr;
2524 const Char_t* sdefList4[] = {
2525 #include "St_QA_Maker/QAhlist_QA_MDC3.h"
2527 if ((!strcmp(m_dirName,
"FlowTag")) && (!strcmp(analType,
"MDC3"))) {
2528 sdefList = sdefList4; lengofList =
sizeof(sdefList4)/sizeOfCharPtr;
2532 const Char_t* sdefList5[] = {
2533 #include "St_QA_Maker/QAhlist_QA_year1.h"
2535 if ((!strcmp(m_dirName,
"QA")) && (!strcmp(analType,
"year1"))) {
2536 sdefList = sdefList5; lengofList =
sizeof(sdefList5)/sizeOfCharPtr;
2540 const Char_t* sdefList6[] = {
2541 #include "St_QA_Maker/QAhlist_EventQA_year1.h"
2543 if ((!strcmp(m_dirName,
"EventQA")) && (!strcmp(analType,
"year1"))) {
2544 sdefList = sdefList6; lengofList =
sizeof(sdefList6)/sizeOfCharPtr;
2548 const Char_t* sdefList7[] = {
2549 #include "St_QA_Maker/QAhlist_QA_qa_shift.h"
2551 if ((!strcmp(m_dirName,
"QA")) && (!strcmp(analType,
"qa_shift"))) {
2552 sdefList = sdefList7; lengofList =
sizeof(sdefList7)/sizeOfCharPtr;
2556 const Char_t* sdefList8[] = {
2557 #include "St_QA_Maker/QAhlist_EventQA_qa_shift.h"
2559 if ((!strcmp(m_dirName,
"EventQA")) && (!strcmp(analType,
"qa_shift"))) {
2560 sdefList = sdefList8; lengofList =
sizeof(sdefList8)/sizeOfCharPtr;
2564 const Char_t* sdefList9[] = {
2565 #include "St_QA_Maker/QAhlist_tpcSectors.h"
2567 if ((!strcmp(m_dirName,
"EventQA")) && (!strcmp(analType,
"tpcSectors"))) {
2568 sdefList = sdefList9; lengofList =
sizeof(sdefList9)/sizeOfCharPtr;
2572 const Char_t* sdefList10[] = {
2573 #include "St_QA_Maker/QAhlist_Svt.h"
2575 if (!strcmp(analType,
"Svt")) {
2576 sdefList = sdefList10; lengofList =
sizeof(sdefList10)/sizeOfCharPtr;
2580 const Char_t* sdefList11[] = {
2581 #include "St_QA_Maker/QAhlist_subsystems.h"
2583 if (!strcmp(analType,
"subsys")) {
2584 sdefList = sdefList11; lengofList =
sizeof(sdefList11)/sizeOfCharPtr;
2589 ifstream analFile(analType);
2590 if (analFile.good()) {
2591 LOG_INFO <<
"Reading print list from: " << analType << endm;
2592 sdefList =
new charptr[4096];
2593 mustDeleteList =
true;
2594 char analBuffer[256];
2596 Bool_t commenting = kFALSE;
2597 Int_t commentIdx = -1;
2598 while (analFile.getline(analBuffer,255)) {
2599 analString = analBuffer;
2601 commentIdx = analString.Index(
"*/");
2602 if (commentIdx>=0) {
2603 analString.Remove(0,commentIdx+2);
2604 commenting = kFALSE;
2608 commentIdx = analString.Index(
"/*");
2609 if (commentIdx>=0) {
2610 analString.Remove(commentIdx);
2614 commentIdx = analString.Index(
"//");
2615 if (commentIdx>=0) analString.Remove(commentIdx);
2616 analString.Remove(TString::kBoth,
' ').Remove(TString::kBoth,
',').Remove(TString::kBoth,
' ').Remove(TString::kBoth,
'"');
2617 Int_t alen = analString.Length();
2618 if (alen<1)
continue;
2619 Char_t* tempc =
new Char_t[alen+1];
2620 strcpy(tempc,analString.Data());
2621 sdefList[lengofList] = tempc;
2625 LOG_WARN <<
"Could not find list of histograms specified by: " << analType << endm;
2631 for (ilg=0;ilg<lengofList;ilg++) {
2632 TString ilgString = sdefList[ilg];
2633 if (mustDeleteList)
delete [] sdefList[ilg];
2634 Bool_t addIt = kTRUE;
2635 if (ilgString.BeginsWith(
":")) {
2636 Ssiz_t endDetSpec = ilgString.Index(
":",1) + 1;
2637 TString detSpec = ilgString(0,endDetSpec);
2638 addIt = DetectorIn(detSpec.Data());
2639 if (addIt) ilgString.Remove(0,endDetSpec);
2642 TRegexp fcsPattern(
"^h[12]_.+"); Ssiz_t ext=0;
2643 if (!(ilgString.BeginsWith(
"fcl") ||
2644 ilgString.BeginsWith(
"fms_qt_") ||
2645 ilgString.BeginsWith(
"Z3A") ||
2646 ilgString.Contains(
"etof",TString::ECaseCompare::kIgnoreCase) ||
2647 ilgString.Contains(
"_matchCand_") ||
2648 ilgString.BeginsWith(
"G_primary") ||
2649 ilgString.Index(fcsPattern,&ext)==0 ||
2650 ilgString.BeginsWith(
"fpd_channel_"))) {
2651 for (Int_t k=0; k<numOfPosPrefixes; k++) {
2652 TString listString = type;
2653 (listString += possiblePrefixes[k]) += ilgString;
2654 numPrt = AddToPrintList(listString.Data());
2656 }
else numPrt = AddToPrintList(ilgString.Data());
2658 LOG_INFO <<
" !!! adding histogram " << ilgString <<
" to print list " << endm ;
2662 if (mustDeleteList)
delete [] sdefList;
2664 LOG_INFO <<
" !!! StHistUtil::SetDefaultPrintList, # histogram put in list " << numPrt << endm;
2673 Int_t StHistUtil::Overlay1D(Char_t *dirName,Char_t *inHist1,
2676 LOG_INFO <<
" **** Now in StHistUtil::Overlay1D **** " << endm;
2679 PathCopy(m_dirName,dirName);
2682 TList* dirList = (m_PntrToMaker ? FindHists(m_dirName) : FindHists(m_PntrToPlainFile));
2688 LOG_INFO <<
"Histogram directory exists -> Find and overlay histograms" << endm;
2691 TIter nextObj(dirList);
2695 TH1F *hist1f1 =
new TH1F;
2696 TH1F *hist1f2 =
new TH1F;
2700 while ((obj = nextObj())) {
2703 if (obj->InheritsFrom(
"TH1")) {
2704 if (obj->GetName() == (TString)inHist1 ||
2705 obj->GetName() == (TString)inHist2) {
2706 LOG_INFO <<
" Found Histogram: Type '" << obj->ClassName() <<
"', Name '"
2707 << obj->GetName() <<
"', Title '" << obj->GetTitle() <<
"'"
2711 if (obj->ClassName() == (TString)
"TH1F") {
2712 if (obj->GetName() == (TString)inHist1) {
2713 *hist1f1 = *(TH1F *)obj;
2716 if (obj->GetName() == (TString)inHist2) {
2717 *hist1f2 = *(TH1F *)obj;
2721 LOG_INFO <<
" ERROR: histogram not of type TH1F !!!" << endm;
2728 if (n1dHists == 2) {
2729 hist1f1->SetLineColor(4);
2730 hist1f1->SetLineStyle(1);
2731 hist1f2->SetLineColor(2);
2732 hist1f2->SetLineStyle(2);
2734 hist1f1->SetStats(kFALSE);
2735 hist1f2->SetStats(kFALSE);
2737 hist1f1->SetTitle(hist1f1->GetTitle()+(TString)
" and "+hist1f2->GetTitle());
2738 hist1f2->SetTitle(hist1f1->GetTitle());
2740 TCanvas *newCanvas =
new TCanvas(
"c1d",
"Combined 1D Histogram",600,780);
2744 Ltitle =
new TPaveLabel(0.1,0.96,0.9,1.0,m_GlobalTitle.Data(),
"br");
2745 Ltitle->SetFillColor(18);
2746 Ltitle->SetTextFont(32);
2747 Ltitle->SetTextSize(0.5);
2752 const Char_t *myTime = HistTime.AsString();
2753 TPaveLabel *Ldatetime =
new TPaveLabel(0.7,0.01,0.95,0.03,myTime,
"br");
2754 Ldatetime->SetTextSize(0.6);
2758 TPad *newPad =
new TPad(
"p1d",
"Combined 1D Histogram",0.02,0.04,0.98,0.93);
2763 if (hist1f1->GetMaximum() >= hist1f2->GetMaximum()) {
2765 hist1f2->Draw(
"Same");
2769 hist1f1->Draw(
"Same");
2773 TLegend *legend =
new TLegend(0.75,0.85,0.98,0.95);
2774 legend->SetFillColor(0);
2775 legend->SetHeader(
"Legend");
2776 legend->SetMargin(0.25);
2777 legend->AddEntry(hist1f1,inHist1,
"l");
2778 legend->AddEntry(hist1f2,inHist2,
"l");
2781 newCanvas->Update();
2794 Int_t StHistUtil::Overlay2D(Char_t *dirName,Char_t *inHist1,
2797 LOG_INFO <<
" **** Now in StHistUtil::Overlay2D **** " << endm;
2800 PathCopy(m_dirName,dirName);
2803 TList* dirList = (m_PntrToMaker ? FindHists(m_dirName) : FindHists(m_PntrToPlainFile));
2809 LOG_INFO <<
"Histogram directory exists -> Find and overlay histograms" << endm;
2812 TIter nextObj(dirList);
2816 TH2F *hist2f1 =
new TH2F;
2817 TH2F *hist2f2 =
new TH2F;
2821 while ((obj = nextObj())) {
2824 if (obj->InheritsFrom(
"TH1")) {
2825 if (obj->GetName() == (TString)inHist1 ||
2826 obj->GetName() == (TString)inHist2) {
2827 LOG_INFO <<
" Found Histogram: Type '" << obj->ClassName() <<
"', Name '"
2828 << obj->GetName() <<
"', Title '" << obj->GetTitle() <<
"'"
2832 if (obj->ClassName() == (TString)
"TH2F") {
2833 if (obj->GetName() == (TString)inHist1) {
2834 *hist2f1 = *(TH2F *)obj;
2837 if (obj->GetName() == (TString)inHist2) {
2838 *hist2f2 = *(TH2F *)obj;
2842 LOG_INFO <<
" ERROR: histogram is not of type TH2F !!!" << endm;
2849 if (n2dHists == 2) {
2850 hist2f1->SetLineColor(4);
2851 hist2f2->SetLineColor(2);
2853 hist2f1->SetStats(kFALSE);
2854 hist2f2->SetStats(kFALSE);
2856 hist2f1->SetTitle(hist2f1->GetTitle()+(TString)
" and "+hist2f2->GetTitle());
2857 hist2f2->SetTitle(hist2f1->GetTitle());
2860 TCanvas *newCanvas =
new TCanvas(
"c2d",
"Combined 2D Histogram",600,780);
2864 Ltitle =
new TPaveLabel(0.1,0.96,0.9,1.0,m_GlobalTitle.Data(),
"br");
2865 Ltitle->SetFillColor(18);
2866 Ltitle->SetTextFont(32);
2867 Ltitle->SetTextSize(0.5);
2872 const Char_t *myTime = HistTime.AsString();
2873 TPaveLabel *Ldatetime =
new TPaveLabel(0.7,0.01,0.95,0.03,myTime,
"br");
2874 Ldatetime->SetTextSize(0.6);
2878 TPad *newPad =
new TPad(
"p2d",
"Combined 2D Histogram",0.02,0.04,0.98,0.93);
2883 if (hist2f1->GetMaximum() >= hist2f2->GetMaximum()) {
2884 hist2f1->Draw(
"Box");
2885 hist2f2->Draw(
"BoxSame");
2888 hist2f2->Draw(
"Box");
2889 hist2f1->Draw(
"BoxSame");
2893 TLegend *legend =
new TLegend(0.75,0.85,0.98,0.95);
2894 legend->SetFillColor(0);
2895 legend->SetHeader(
"Legend");
2896 legend->SetMargin(0.25);
2897 legend->AddEntry(hist2f1,inHist1,
"f");
2898 legend->AddEntry(hist2f2,inHist2,
"f");
2901 newCanvas->Update();
2916 Int_t StHistUtil::GetRunYear(
const Char_t *filename) {
2919 TString FileName = filename;
2920 TString delim =
"_";
2921 TObjArray* tokens = FileName.Tokenize(delim);
2922 for (
int tk=2; tk<tokens->GetEntries(); tk++) {
2923 TString& tok = ((TObjString*) (tokens->At(tk)))->String();
2924 if (tok.IsDigit()) {
2925 Ssiz_t loc = tok.Length()-6;
2926 if (loc>0) m_RunYear = atoi(tok.Remove(loc).Data());
2939 void StHistUtil::SetRefAnalysis(
const Char_t* refOutFile,
const Char_t* refResultsFile,
2940 const Char_t* refCutsFile,
const Char_t* refInFile) {
2942 LOG_INFO <<
"StHistUtil: Will run in reference histogram analysis mode." << endm;
2945 if (refInFile && strlen(refInFile)) {
2946 LOG_INFO <<
"StHistUtil: Using reference histogram file " << refInFile << endm;
2947 m_refInFile =
new TFile(refInFile);
2948 if (!m_refInFile) {LOG_ERROR <<
"file not found: " << refInFile << endm;}
2950 if (refCutsFile && strlen(refCutsFile)) {
2951 LOG_INFO <<
"StHistUtil: Using reference cuts file " << refCutsFile << endm;
2952 m_refCuts =
new TList;
2953 ifstream refCuts(refCutsFile);
2954 if (!refCuts.is_open()) {
2955 LOG_ERROR <<
"StHistUtil: Unable to open cuts file! Proceeding with no cuts..." << endm;
2960 while (refCuts.good()) {
2961 refCuts >> buf_name;
2962 if (!refCuts.good())
break;
2965 refCuts >> mode >> cut >> buf_opts;
2966 if (!refCuts.good())
break;
2967 if (buf_opts[0] ==
'!') buf_opts[0] = 0;
2969 LOG_INFO <<
"StHistUtil: Loading cut : " << buf_name <<
" : " << mode
2970 <<
" : " << cut <<
" : " << buf_opts <<
" :" << endm;
2972 m_refCuts->AddLast(
new StHistUtilRef(buf_name,buf_opts,mode,cut));
2977 PathCopy(m_refResultsFile,refResultsFile);
2979 PathCopy(m_refOutFile,refOutFile);
2984 void StHistUtil::SetDetectors(
const Char_t *detectors) {
2988 m_Detectors = detectors;
2990 m_Detectors.ReplaceAll(
" ",
":");
2991 m_Detectors.ReplaceAll(
",",
":");
2992 m_Detectors.Prepend(
":");
2993 m_Detectors.Append(
":");
2994 while (m_Detectors.Index(
"::") >= 0) m_Detectors.ReplaceAll(
"::",
":");
2995 LOG_INFO <<
"StHistUtil::SetDetectors(): using detectors " << m_Detectors << endm;
2998 LOG_INFO <<
"StHistUtil::SetDetectors(): using all detectors" << endm;
3004 Bool_t StHistUtil::DetectorIn(
const Char_t *detector) {
3009 Bool_t isIn = kFALSE;
3010 if (m_Detectors.Length()) {
3012 TString detOpts = detector;
3013 TString curDetSet =
"";
3014 TString curDet =
"";
3015 while (idx < detOpts.Length() && ! isIn) {
3016 Ssiz_t D1 = detOpts.Index(
";",idx);
3017 Ssiz_t setLength = (D1 < idx ? detOpts.Length() : D1+1) - idx;
3018 curDetSet = detOpts(idx,setLength);
3021 while (idx2 < curDetSet.Length() && isIn) {
3022 Ssiz_t D2 = curDetSet.Index(
",",idx2);
3023 Ssiz_t detLength = (D2 < idx2 ? curDetSet.Length() : D2+1) - idx2;
3024 curDet = curDetSet(idx2,detLength);
3025 curDet.ReplaceAll(
";",
":");
3026 curDet.ReplaceAll(
",",
":");
3027 curDet.Prepend(
":");
3029 while (curDet.Index(
"::") >= 0) curDet.ReplaceAll(
"::",
":");
3030 if (m_Detectors.Index(curDet.Data()) < 0) isIn = kFALSE;
3031 else idx2 += detLength;
3044 TH1* StHistUtil::FlipAxes(TH1* hist) {
3045 if (!(hist->InheritsFrom(
"TH2")))
return hist;
3048 Int_t xbins = hist->GetNbinsX();
3049 Int_t ybins = hist->GetNbinsY();
3050 TH2D* newhist =
new TH2D(Form(
"%s_flip",hist->GetName()),hist->GetTitle(),
3051 ybins,hist->GetYaxis()->GetXmin(),hist->GetYaxis()->GetXmax(),
3052 xbins,hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax());
3053 for (
int xbin=1; xbin<=xbins; xbin++) {
3054 for (
int ybin=1; ybin<=ybins; ybin++) {
3055 newhist->SetBinContent(ybin,xbin,hist->GetBinContent(xbin,ybin));
3056 newhist->SetBinError(ybin,xbin,hist->GetBinError(xbin,ybin));
3059 newhist->SetMinimum(hist->GetMinimumStored());
3060 newhist->SetMaximum(hist->GetMaximumStored());
3066 void StHistUtil::PathCopy(
char* destination,
const char* source) {
3068 if (source && strcmp(destination,source)) {
3069 if (strlen(source) < maxPathLen) {
3070 strncpy(destination,source,maxPathLen-1);
3071 destination[maxPathLen-1] = 0;
3073 LOG_ERROR <<
" source path too long: " << source << endm;
3085 const
int mode, const
double cut):
3086 TNamed(name,opts),Mode(mode),
Cut(cut) {}
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
virtual TDataSet * Find(const char *path) const