diff --git a/readRawTrace.C b/readRawTrace.C index 7ce8572..a6b911c 100644 --- a/readRawTrace.C +++ b/readRawTrace.C @@ -10,6 +10,7 @@ #include #include #include +#include #include void readRawTrace(TString fileName, int minDetID = 0, int maxDetID = 1000){ @@ -41,15 +42,17 @@ void readRawTrace(TString fileName, int minDetID = 0, int maxDetID = 1000){ UShort_t trace[1024]; UShort_t traceLength; Int_t QDC[8]; + ULong64_t time; tree->SetBranchAddress("detID", &detID); tree->SetBranchAddress("trace", trace); tree->SetBranchAddress("trace_length", &traceLength); tree->SetBranchAddress("qdc", QDC); + tree->SetBranchAddress("e_t", &time); TLatex text ; text.SetNDC(); text.SetTextFont(62); - text.SetTextSize(0.06); + text.SetTextSize(0.05); text.SetTextColor(2); bool breakFlag = false; @@ -57,6 +60,11 @@ void readRawTrace(TString fileName, int minDetID = 0, int maxDetID = 1000){ int oldEv = 0; TGraph * g = new TGraph(); + + int QDCsum[8] = {0}; ///directly sum from trace + double x[9] = {0, 31, 60, 75, 95, 105, 160, 175, 200}; + Color_t color[8] = {4, kGreen+2, 4, kGreen+2, 4, kGreen+2, 4, kGreen+2}; + for( int ev = 0; ev < totnumEntry; ev++){ @@ -66,25 +74,41 @@ void readRawTrace(TString fileName, int minDetID = 0, int maxDetID = 1000){ } tree->GetEntry(ev); - if( !(minDetID <= detID && detID <= maxDetID ) ) continue; printf("-------------------------------- ev : %d \n", ev); - printf("id : %d, trace Length : %u ( enter = next , q = stop, w = last)\n", detID, traceLength); + printf("id : %d, trace Length : %u, time: %16llu ( enter = next , q = stop, w = last)\n", detID, traceLength, time); g->Clear(); - g->Set(traceLength); - for( int k = 0; k < traceLength ; k++) g->SetPoint(k, k, trace[k]); + g->Set(traceLength); + + int minY = 9999, maxY = 0; + for( int i = 0 ; i < 8; i++) QDCsum[i] = 0; - g->SetTitle(Form("ev: %d, id : %d, trace Length : %u\n", ev, detID, traceLength)); + for( int k = 0; k < traceLength ; k++) { + g->SetPoint(k, k, trace[k]); + for( int i = 0; i < 8; i++) if( x[i] <= k && k < x[i+1] ) QDCsum[i] += trace[k]; + if( trace[k] > maxY ) maxY = trace[k]; + if( trace[k] < minY ) minY = trace[k]; + } + + g->SetTitle(Form("ev: %d, id : %d, trace Length : %u, time: %16llu\n", ev, detID, traceLength, time)); cRead->cd(1); cRead->Clear(); g->Draw("AL"); - - for( int i = 0; i < 8; i++) text.DrawLatex(0.2, 0.8-0.05*i, Form("%d", QDC[i])); - + + text.SetTextColor(kRed); + text.DrawLatex(0.12, 0.85, Form("QDC, QDCtrace (diff)")); + for( int i = 0; i < 8; i++) { + text.SetTextColor(color[i]); + text.DrawLatex(0.12, 0.8-0.05*i, Form("%d, %d (%+-d)", QDC[i], QDCsum[i], QDC[i]-QDCsum[i])); + + TBox * box = new TBox(x[i], minY, x[i+1], maxY); + box->SetFillColorAlpha(color[i], 0.1); + box->Draw("same"); + } cRead->Update(); gSystem->ProcessEvents();