@@ -11,7 +11,6 @@ TString prefix = "";
1111int correlationCase = 0 ; // at the moment I assume no error correlation ..
1212
1313
14-
1514struct results {
1615 bool passed ;
1716 double value ;
@@ -204,6 +203,8 @@ void ReleaseValidation(const TString filename1, const TString filename2,
204203 SelectCriticalHistos ();
205204 }
206205 fileSummaryOutput -> Close ();
206+
207+ WriteToJson (hSummaryCheck );
207208}
208209
209210// setting the labels of the Z axis for the colz plot
@@ -578,6 +579,7 @@ void CompareHistos(TH1* hA, TH1* hB, int whichTest, double valChi2, double valMe
578579 c -> Print ("plots.pdf[" );
579580 c -> Divide (2 , 1 );
580581 c -> cd (1 );
582+ gPad -> SetTitle (hA -> GetName ());
581583 TString hcln = hA -> ClassName ();
582584 TString optD = "" ;
583585 if (hcln .Contains ("TH2" ))
@@ -586,6 +588,7 @@ void CompareHistos(TH1* hA, TH1* hB, int whichTest, double valChi2, double valMe
586588 hA -> SetMarkerColor (1 );
587589 hA -> Scale (1. / hA -> GetEntries ()); // normalize to the number of entries
588590 TH1 * hAc = (TH1 * )hA -> DrawClone (optD .Data ());
591+ hAc -> SetTitle (hA -> GetName ());
589592 hAc -> SetStats (0 );
590593 hB -> SetLineColor (2 );
591594 hB -> SetMarkerColor (2 );
@@ -634,6 +637,7 @@ void CompareHistos(TH1* hA, TH1* hB, int whichTest, double valChi2, double valMe
634637 } else {
635638 TH1 * hArat = (TH1 * )hA -> Clone ("hArat" );
636639 hArat -> Divide (hB );
640+ hArat -> SetTitle (Form ("%s_ratio" ,hA -> GetName ()));
637641 for (int k = 1 ; k <= hArat -> GetNbinsX (); k ++ )
638642 hArat -> SetBinError (k , 0.000000001 );
639643 hArat -> SetMinimum (
@@ -686,6 +690,7 @@ void CompareHistos(TH1* hA, TH1* hB, int whichTest, double valChi2, double valMe
686690 TH1 * hDiff = (TH1 * )hACl -> Clone ("hDiff" );
687691 hDiff -> SetStats (0 );
688692 hDiff -> Add (hBCl , -1 );
693+ hDiff -> SetTitle (Form ("%s_diff" ,hA -> GetName ()));
689694 hDiff -> DrawClone (noptD .Data ());
690695
691696 TPaveStats * stACl =
@@ -720,14 +725,17 @@ void CompareHistos(TH1* hA, TH1* hB, int whichTest, double valChi2, double valMe
720725 } else {
721726 TH1 * hDiffRel = (TH1 * )hDiff -> Clone ("hDiffRel" );
722727 hDiffRel -> Divide (hBCl );
728+ hDiffRel -> SetTitle (Form ("%s_diffrel" ,hA -> GetName ()));
723729 for (int k = 1 ; k <= hDiffRel -> GetNbinsX (); k ++ )
724730 hDiffRel -> SetBinError (k , 0.000000001 );
731+ /*
725732 hDiffRel->SetMinimum(TMath::Max(
726733 0.98, 0.95 * hDiffRel->GetBinContent(hDiffRel->GetMinimumBin()) -
727734 hDiffRel->GetBinError(hDiffRel->GetMinimumBin())));
728735 hDiffRel->SetMaximum(TMath::Min(
729736 1.02, 1.05 * hDiffRel->GetBinContent(hDiffRel->GetMaximumBin()) +
730737 hDiffRel->GetBinError(hDiffRel->GetMaximumBin())));
738+ */
731739 hDiffRel -> SetStats (0 );
732740 TString hDiffRelcln = hDiffRel -> ClassName ();
733741 if (hDiffRelcln .Contains ("TH2" ))
@@ -774,10 +782,10 @@ void DrawRelativeDifference(TH1* hR)
774782 hR -> SetMarkerStyle (20 );
775783 hR -> SetMarkerSize (0.5 );
776784 hR -> SetMinimum (
777- TMath ::Max (0.98 , 0.95 * hR -> GetBinContent (hR -> GetMinimumBin ()) -
785+ TMath ::Max (-0.02 , 1.05 * hR -> GetBinContent (hR -> GetMinimumBin ()) -
778786 hR -> GetBinError (hR -> GetMinimumBin ())));
779787 hR -> SetMaximum (
780- TMath ::Min (1 .02 , 1.05 * hR -> GetBinContent (hR -> GetMaximumBin ()) +
788+ TMath ::Min (0 .02 , 1.05 * hR -> GetBinContent (hR -> GetMaximumBin ()) +
781789 hR -> GetBinError (hR -> GetMaximumBin ())));
782790 hR -> SetStats (0 );
783791 hR -> GetYaxis ()-> SetTitle ("RelativeDifference" );
@@ -831,7 +839,7 @@ void SelectCriticalHistos()
831839 TCanvas * ccc =
832840 static_cast < TCanvas * > (fileSummaryOutput -> Get (Oname .Data ()));
833841 // ccc->Draw();
834- ccc -> Print ("critical.pdf[ " );
842+ ccc -> Print ("critical.pdf" );
835843 }
836844 }
837845 }
@@ -1036,30 +1044,86 @@ struct results CompareNentr(TH1* hA, TH1* hB, double val){
10361044 return res ;
10371045}
10381046
1039- /*
1047+
10401048void WriteToJson (TH2F * hSum ){
10411049 std ::vector < std ::string > good , warning , bad , nc , critical_nc ;
10421050 int nhists = hSum -> GetYaxis ()-> GetNbins ();
1043- Json::Value json;
1044- Json::Value vec_good(Json::arrayValue),vec_warning(Json::arrayValue),vec_bad(Json::arrayValue),vec_nc(Json::arrayValue),vec_critical_nc(Json::arrayValue);
1051+
10451052 for (int i = 1 ;i <=nhists ;i ++ ){
10461053 double res = hSum -> GetBinContent (1 ,i );
10471054 const char * label = hSum -> GetYaxis ()-> GetBinLabel (i );
10481055 if (res == 0 )
1049- vec_bad.append(Json::Value( label) );
1056+ bad . push_back ( label );
10501057 if (res == 0.5 )
1051- vec_warning.append(Json::Value( label) );
1058+ warning . push_back ( label );
10521059 if (res == 1 )
1053- vec_good.append(Json::Value( label) );
1060+ good . push_back ( label );
10541061 if (res == -0.25 )
1055- vec_nc.append(Json::Value( label) );
1062+ nc . push_back ( label );
10561063 if (res == -0.5 )
1057- vec_critical_nc.append(Json::Value(label));
1064+ critical_nc .push_back (label );
1065+ }
1066+ auto good_json = TBufferJSON ::ToJSON (& good );
1067+ auto warning_json = TBufferJSON ::ToJSON (& warning );
1068+ auto bad_json = TBufferJSON ::ToJSON (& bad );
1069+ auto nc_json = TBufferJSON ::ToJSON (& nc );
1070+ auto critical_nc_json = TBufferJSON ::ToJSON (& critical_nc );
1071+
1072+
1073+ std ::map < std ::string ,std ::string > data ;
1074+ data ["GOOD" ] = good_json ;
1075+ data ["WARNING" ] = warning_json ;
1076+ data ["BAD" ] = bad_json ;
1077+ data ["NONCRIT_NC" ] = nc_json ;
1078+ data ["CRIT_NC" ] = critical_nc_json ;
1079+
1080+ auto json = TBufferJSON ::ToJSON (& data , TBufferJSON ::kMapAsObject );
1081+
1082+ std ::ofstream jsonout ("Summary.json" );
1083+ jsonout << json ;
1084+ jsonout .close ();
1085+
1086+ std ::ofstream jsonout2 ("Summary2.json" );
1087+ jsonout2 << "{\n" ;
1088+ jsonout2 << "\t\"GOOD\":[" ;
1089+ for (std ::string s : good ){
1090+ jsonout2 << "\"" << s <<"\"" ;
1091+ if (s != good .back ())
1092+ jsonout2 << "," ;
1093+ }
1094+ jsonout2 << "],\n" ;
1095+ jsonout2 << "\t\"WARNING\":[" ;
1096+ for (std ::string s : warning ){
1097+ jsonout2 << "\"" << s <<"\"" ;
1098+ if (s != warning .back ())
1099+ jsonout2 << "," ;
10581100 }
1059- json["GOOD"]=vec_good;
1060- json["BAD"]=vec_bad;
1061- json["WARNING"]=vec_warning;
1062- json["NC"]=vec_nc;
1063- json["NC_CRIT"]=vec_critical_nc;
1064- std::cout << json << std::endl;
1065- }*/
1101+ jsonout2 << "],\n" ;
1102+ jsonout2 << "\t\"BAD\":[" ;
1103+ for (std ::string s : bad ){
1104+ jsonout2 << "\"" << s <<"\"" ;
1105+ if (s != bad .back ())
1106+ jsonout2 << "," ;
1107+ }
1108+ jsonout2 << "],\n" ;
1109+ jsonout2 << "\t\"CRIT_NC\":[" ;
1110+ for (std ::string s : critical_nc ){
1111+ jsonout2 << "\"" << s <<"\"" ;
1112+ if (s != critical_nc .back ())
1113+ jsonout2 << "," ;
1114+ }
1115+ jsonout2 << "],\n" ;
1116+ jsonout2 << "\t\"NONCRIT_NC\":[" ;
1117+ for (std ::string s : nc ){
1118+ jsonout2 << "\"" << s <<"\"" ;
1119+ if (s != nc .back ())
1120+ jsonout2 << "," ;
1121+ }
1122+ jsonout2 << "]\n" ;
1123+ jsonout2 << "}" ;
1124+
1125+
1126+ jsonout2 .close ();
1127+
1128+
1129+ }
0 commit comments