// created: 25 March 2014 // last modif: 25 March 2014 // Author: Creusot Alexandre #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; void comparisonHits() { gROOT->Reset(); gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetNumberContours(99); gStyle->SetOptFit(0000); TStopwatch watch; const int binTot = 1000; const int binDeltat = 1000; const int pmtnb = 31; TH1D* hTot1[pmtnb]; TH1D* hTot2[pmtnb]; TH1D* hDiffTot[pmtnb]; TH1D* hDeltat1[pmtnb]; TH1D* hDeltat2[pmtnb]; TH1D* hDiffDeltat[pmtnb]; string line; int oldTime1[pmtnb]; int oldTime2[pmtnb]; for (int i = 0; i < pmtnb; ++i) { oldTime1[i] = 0; oldTime2[i] = 0; char plotname[1024]; sprintf(plotname, "hTot1-pmt%d", i); hTot1[i] = new TH1D(plotname, plotname, binTot, 0, binTot); sprintf(plotname, "hTot2-pmt%d", i); hTot2[i] = new TH1D(plotname, plotname, binTot, 0, binTot); sprintf(plotname, "hDiffTot-pmt%d", i); hDiffTot[i] = new TH1D(plotname, plotname, binTot, 0, binTot); sprintf(plotname, "hDeltat1-pmt%d", i); hDeltat1[i] = new TH1D(plotname, plotname, binDeltat, 0, 1e6); sprintf(plotname, "hDeltat2-pmt%d", i); hDeltat2[i] = new TH1D(plotname, plotname, binDeltat, 0, 1e6); sprintf(plotname, "hDiffDeltat-pmt%d", i); hDiffDeltat[i] = new TH1D(plotname, plotname, 1000, 0, 1e6); } //ifstream in3("../../../../../data/run915-rdatv1-hits.dat"); ifstream in3("test-v1.dat"); while (getline(in3, line)) { istringstream iss; iss.clear(); iss.str(line); int temp[3]; if (iss >> temp[0] >> temp[1] >> temp[2]) { hTot1[temp[0]]->Fill(temp[2]); hDeltat1[temp[0]]->Fill(temp[1] - oldTime1[temp[0]]); oldTime1[temp[0]] = temp[1]; } } in3.close(); //ifstream in4("../../../../../data/run915-rdatv2-hits.dat"); ifstream in4("test-v2.dat"); while (getline(in4, line)) { istringstream iss; iss.clear(); iss.str(line); int temp[3]; if (iss >> temp[0] >> temp[1] >> temp[2]) { hTot2[temp[0]]->Fill(temp[2]); hDeltat2[temp[0]]->Fill(temp[1] - oldTime2[temp[0]]); oldTime2[temp[0]] = temp[1]; } } in4.close(); for (int i = 0; i < pmtnb; ++i) { for (int j = 0; j < binTot; ++j) { const int tot1 = hTot1[i]->GetBinContent(j); const int tot2 = hTot2[i]->GetBinContent(j); hDiffTot[i]->SetBinContent(j, tot1 - tot2); } for (int j = 0; j < binDeltat; ++j) { const int deltat1 = hDeltat1[i]->GetBinContent(j); const int deltat2 = hDeltat2[i]->GetBinContent(j); hDiffDeltat[i]->SetBinContent(j, deltat1 - deltat2); } } TCanvas* cDiffDeltat[pmtnb]; TCanvas* cDiffTot[pmtnb]; for (int i = 0; i < pmtnb; ++i) { /* TCanvas* cTot = new TCanvas("cTot", "cTot", 800, 600); hTot1->SetTitle(""); hTot1->GetXaxis()->SetTitle("ToT duration [ns]"); hTot1->GetXaxis()->CenterTitle(); hTot1->GetXaxis()->SetTitleOffset(1.2); hTot1->SetLineColor(kBlack); hTot1->SetLineWidth(4); hTot1->Draw(); hTot2->SetLineColor(kRed); hTot2->SetLineWidth(0.2); hTot2->Draw("same"); cTot->SaveAs("../../../../../figs/tot-v1v2-run915.png"); TCanvas* cDeltat = new TCanvas("cDeltat", "cDeltat", 800, 600); hDeltat1->SetTitle(""); hDeltat1->GetXaxis()->SetTitle("time difference [ns]"); hDeltat1->GetXaxis()->CenterTitle(); hDeltat1->GetXaxis()->SetTitleOffset(1.2); hDeltat1->SetLineColor(kBlack); hDeltat1->SetLineWidth(4); hDeltat1->Draw(); hDeltat2->SetLineColor(kRed); hDeltat2->SetLineWidth(0.2); hDeltat2->Draw("same"); cDeltat->SaveAs("../../../../../figs/deltat-v1v2-run915.png"); */ char plotname[1024]; sprintf(plotname, "cDiffDeltat-pmt%d", i); cDiffDeltat[i] = new TCanvas(plotname, plotname, 800, 600); hDiffDeltat[i]->SetTitle(""); hDiffDeltat[i]->GetXaxis()->SetTitle("time difference [ns]"); hDiffDeltat[i]->GetXaxis()->CenterTitle(); hDiffDeltat[i]->GetXaxis()->SetTitleOffset(1.2); hDiffDeltat[i]->SetLineColor(kBlack); hDiffDeltat[i]->SetLineWidth(1); hDiffDeltat[i]->Draw(); sprintf(plotname, "../../../../../figs/diffDeltat-v1v2-run915-pmt%d.png", i); cDiffDeltat[i]->SaveAs(plotname); sprintf(plotname, "cDiffTot-pmt%d", i); cDiffTot[i] = new TCanvas(plotname, plotname, 800, 600); hDiffTot[i]->SetTitle(""); hDiffTot[i]->GetXaxis()->SetTitle("ToT duration [ns]"); hDiffTot[i]->GetXaxis()->CenterTitle(); hDiffTot[i]->GetXaxis()->SetTitleOffset(1.2); hDiffTot[i]->SetLineColor(kBlack); hDiffTot[i]->SetLineWidth(1); hDiffTot[i]->Draw(); sprintf(plotname, "../../../../../figs/diffTot-v1v2-run915-pmt%d.png", i); cDiffTot[i]->SaveAs(plotname); } cout << "time: " << watch.CpuTime() << " s" << endl; }