File indexing completed on 2021-02-14 14:32:11
0001
0002 void ProcessSubDetDigi(TFile &ref_file, TFile &val_file, ifstream &digstr, const int nHist1, const int nHist2, const int nHistTot, TString ref_vers, TString val_vers);
0003
0004
0005 void CombinedDigis(TString ref_vers="220pre1",
0006 TString val_vers="220"){
0007
0008
0009
0010
0011
0012
0013 ifstream DigStream("InputDigis.txt");
0014
0015
0016 TFile Digi_ref_file("HcalDigisValidation_"+ref_vers+".root");
0017
0018 TFile Digi_val_file("HcalDigisValidation_"+val_vers+".root");
0019
0020
0021 const int Digi_nHist1 = 20;
0022 const int Digi_nHist2 = 6;
0023 const int Digi_nHistTot = 140;
0024
0025 ProcessSubDetDigi(Digi_ref_file, Digi_val_file, DigStream, Digi_nHist1, Digi_nHist2, Digi_nHistTot, ref_vers, val_vers);
0026
0027
0028 Digi_ref_file.Close();
0029
0030 Digi_val_file.Close();
0031
0032 return;
0033 }
0034
0035 void ProcessSubDetDigi(TFile &ref_file, TFile &val_file, ifstream &digstr, const int nHist1, const int nHist2, const int nHistTot, TString ref_vers, TString val_vers){
0036
0037 TCanvas *myc = new TCanvas("myc","",800,600);
0038 TLegend* leg = 0;
0039 TPaveText* ptchi2 = 0;
0040 TPaveStats *ptstats_r = 0;
0041 TPaveStats *ptstats_v = 0;
0042
0043 TH1F* ref_hist1[nHist1];
0044 TH1F* val_hist1[nHist1];
0045
0046 TH2F* ref_hist2[nHist2];
0047 TH2F* val_hist2[nHist2];
0048
0049 int i;
0050 int DrawSwitch;
0051 TString StatSwitch, Chi2Switch, LogSwitch, DimSwitch;
0052 int RefCol, ValCol;
0053 TString HistName;
0054 char xAxisTitle[200];
0055 float xAxisRange, yAxisRange;
0056 TString OutLabel;
0057 string xTitleCheck;
0058
0059 int nh1 = 0;
0060 int nh2 = 0;
0061
0062 for (i = 0; i < nHistTot; i++){
0063
0064
0065
0066 digstr>>HistName>>DrawSwitch;
0067 if (DrawSwitch == 0) continue;
0068
0069 digstr>>OutLabel>>xAxisRange>>yAxisRange;
0070 digstr>>DimSwitch>>StatSwitch>>Chi2Switch>>LogSwitch;
0071 digstr>>RefCol>>ValCol;
0072 digstr.getline(xAxisTitle,200);
0073
0074 xTitleCheck = xAxisTitle;
0075 xTitleCheck = xTitleCheck.substr(1,7);
0076
0077
0078 if (LogSwitch == "Log") myc->SetLogy();
0079 else myc->SetLogy(0);
0080
0081
0082 if (DimSwitch == "1D"){
0083
0084 ref_file.cd("DQMData/HcalDigisV/HcalDigiTask");
0085 ref_hist1[nh1] = (TH1F*) gDirectory->Get(HistName);
0086
0087 val_file.cd("DQMData/HcalDigisV/HcalDigiTask");
0088 val_hist1[nh1] = (TH1F*) gDirectory->Get(HistName);
0089
0090
0091 if (StatSwitch != "Stat" || StatSwitch != "Statrv"){
0092 ref_hist1[nh1]->SetStats(kTRUE);
0093 val_hist1[nh1]->SetStats(kTRUE);
0094 }
0095
0096 if (xAxisRange > 0) ref_hist1[nh1]->GetXaxis()->SetRangeUser(0.,xAxisRange);
0097 if (yAxisRange > 0) ref_hist1[nh1]->GetYaxis()->SetRangeUser(0.,yAxisRange);
0098
0099 double myxmax;
0100 if (xAxisRange == -1000){
0101 myxmax = ref_hist1[nh1]->GetXaxis()->GetXmax();
0102 ref_hist1[nh1]->GetXaxis()->SetRangeUser(10,myxmax);
0103 }
0104
0105 if (xTitleCheck != "NoTitle") ref_hist1[nh1]->GetXaxis()->SetTitle(xAxisTitle);
0106
0107
0108 ref_hist1[nh1]->SetTitle("");
0109 ref_hist1[nh1]->SetLineWidth(2);
0110 ref_hist1[nh1]->SetLineColor(RefCol);
0111 ref_hist1[nh1]->SetLineStyle(1);
0112
0113 val_hist1[nh1]->SetTitle("");
0114 val_hist1[nh1]->SetLineWidth(3);
0115 val_hist1[nh1]->SetLineColor(ValCol);
0116 val_hist1[nh1]->SetLineStyle(2);
0117
0118
0119 leg = new TLegend(0.58, 0.91, 0.84, 0.99, "","brNDC");
0120 leg->SetBorderSize(2);
0121 leg->SetFillStyle(1001);
0122 leg->AddEntry(ref_hist1[nh1],"CMSSW_"+ref_vers,"l");
0123 leg->AddEntry(val_hist1[nh1],"CMSSW_"+val_vers,"l");
0124
0125
0126 ref_hist1[nh1]->Draw("hist");
0127 if (StatSwitch == "Stat") val_hist1[nh1]->Draw("hist sames");
0128 else val_hist1[nh1]->Draw("hist same");
0129
0130
0131 if (Chi2Switch == "Chi2"){
0132
0133 const float NCHI2MIN = 0.01;
0134
0135 float pval;
0136 stringstream mystream;
0137 char tempbuff[30];
0138
0139 pval = ref_hist1[nh1]->Chi2Test(val_hist1[nh1]);
0140
0141 sprintf(tempbuff,"Chi2 p-value: %6.3E%c",pval,'\0');
0142 mystream<<tempbuff;
0143
0144 ptchi2 = new TPaveText(0.225,0.92,0.475,1.0, "NDC");
0145
0146 if (pval > NCHI2MIN) ptchi2->SetFillColor(kGreen);
0147 else ptchi2->SetFillColor(kRed);
0148
0149 ptchi2->SetTextSize(0.03);
0150 ptchi2->AddText(mystream.str().c_str());
0151 ptchi2->Draw();
0152 }
0153
0154
0155 if (StatSwitch == "Stat" || StatSwitch == "Statrv"){
0156 ptstats_r = new TPaveStats(0.85,0.86,0.98,0.98,"brNDC");
0157 ptstats_r->SetTextColor(RefCol);
0158 ref_hist1[nh1]->GetListOfFunctions()->Add(ptstats_r);
0159 ptstats_r->SetParent(ref_hist1[nh1]->GetListOfFunctions());
0160 ptstats_v = new TPaveStats(0.85,0.74,0.98,0.86,"brNDC");
0161 ptstats_v->SetTextColor(ValCol);
0162 val_hist1[nh1]->GetListOfFunctions()->Add(ptstats_v);
0163 ptstats_v->SetParent(val_hist1[nh1]->GetListOfFunctions());
0164
0165 ptstats_r->Draw();
0166 ptstats_v->Draw();
0167 }
0168
0169 leg->Draw();
0170
0171 myc->SaveAs(OutLabel);
0172 nh1++;
0173 }
0174
0175
0176 else if (DimSwitch == "2D"){
0177
0178 ref_file.cd("DQMData/HcalDigisV/HcalDigiTask");
0179 ref_hist2[nh2] = (TH2F*) gDirectory->Get(HistName);
0180
0181 val_file.cd("DQMData/HcalDigisV/HcalDigiTask");
0182 val_hist2[nh2] = (TH2F*) gDirectory->Get(HistName);
0183
0184
0185 if (StatSwitch != "Stat") ref_hist2[nh2]->SetStats(kFALSE);
0186
0187 if (xAxisRange > 0) ref_hist2[nh2]->GetXaxis()->SetRangeUser(0.,xAxisRange);
0188 if (yAxisRange > 0) ref_hist2[nh2]->GetYaxis()->SetRangeUser(0.,yAxisRange);
0189
0190 ref_hist2[nh2]->GetXaxis()->SetTitle(xAxisTitle);
0191
0192 ref_hist2[nh2]->SetTitle("");
0193 ref_hist2[nh2]->SetLineColor(2);
0194 ref_hist2[nh2]->SetLineWidth(2);
0195 ref_hist2[nh2]->SetMarkerColor(RefCol);
0196 ref_hist2[nh2]->SetMarkerStyle(20);
0197 ref_hist2[nh2]->SetMarkerSize(0.5);
0198
0199 val_hist2[nh2]->SetTitle("");
0200 val_hist2[nh2]->SetLineColor(3);
0201 val_hist2[nh2]->SetLineWidth(3);
0202 val_hist2[nh2]->SetMarkerColor(ValCol);
0203 val_hist2[nh2]->SetMarkerStyle(22);
0204 val_hist2[nh2]->SetMarkerSize(0.5);
0205
0206 ref_hist2[nh2]->Draw("P");
0207 val_hist2[nh2]->Draw("PSAME");
0208
0209
0210 leg = new TLegend(0.58, 0.91, 0.84, 0.99, "","brNDC");
0211 leg->SetBorderSize(2);
0212 leg->SetFillStyle(1001);
0213 leg->AddEntry(ref_hist2[nh2],"CMSSW_"+ref_vers,"pl");
0214 leg->AddEntry(val_hist2[nh2],"CMSSW_"+val_vers,"pl");
0215
0216 leg->Draw();
0217
0218
0219 if (Chi2Switch == "Chi2"){
0220
0221 const float NCHI2MIN = 0.01;
0222
0223 float pval;
0224 stringstream mystream;
0225 char tempbuff[30];
0226
0227 pval = ref_hist2[nh2]->Chi2Test(val_hist2[nh2]);
0228
0229 sprintf(tempbuff,"Chi2 p-value: %6.3E%c",pval,'\0');
0230 mystream<<tempbuff;
0231
0232 TPaveText* ptchi2 = new TPaveText(0.225,0.92,0.475,1.0, "NDC");
0233
0234 if (pval > NCHI2MIN) ptchi2->SetFillColor(kGreen);
0235 else ptchi2->SetFillColor(kRed);
0236
0237 ptchi2->SetTextSize(0.03);
0238 ptchi2->AddText(mystream.str().c_str());
0239 ptchi2->Draw();
0240 }
0241
0242 myc->SaveAs(OutLabel);
0243 nh2++;
0244 }
0245 if(leg) delete leg;
0246 if(ptchi2) delete ptchi2;
0247 if(ptstats_r) delete ptstats_r;
0248 if(ptstats_v) delete ptstats_v;
0249 }
0250 if(myc) delete myc;
0251 return;
0252 }