#include #include #include #include #include #include #include #include #include void PIDCutChecker(TH2F* hist, TString saveFileName = "PIDCuts.root", bool isLogz = false ){ printf("================ Graphic Cut Checker for PID ============== \n"); gStyle->SetOptStat("neiou"); TCanvas * cCutCreator = new TCanvas("cCutCreator", "PID Cut Creator", 100, 100, 800, 800); if( !cCutCreator->GetShowToolBar() ) cCutCreator->ToggleToolBar(); cCutCreator->Update(); if( isLogz ) cCutCreator->cd()->SetLogz(); hist->Draw("colz"); TFile * cutFile; TCutG * cut = NULL; TObjArray * cutList; ///===================== load the cutFile and load the cutList int numCut = 0; cutFile = new TFile(saveFileName, "UPDATE"); bool listExist = cutFile->GetListOfKeys()->Contains("cutList"); if( !listExist ) { cutList = new TObjArray(); }else{ cutList = (TObjArray*) cutFile->FindObjectAny("cutList"); numCut = cutList->GetLast()+1; printf("----- found %d cuts \n", numCut); for( int k = 0; k < numCut; k++){ if( cutList->At(k) != NULL ){ printf("found a cut at %2d \n", k); cut = (TCutG*) cutList->At(k); cut->Draw("same"); }else{ printf(" No cut at %2d \n", k); } } } cCutCreator->Modified(); cCutCreator->Update(); }