55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
#include <TH2F.h>
|
|
#include <TFile.h>
|
|
#include <TChain.h>
|
|
#include <TROOT.h>
|
|
#include <TStyle.h>
|
|
#include <TCanvas.h>
|
|
#include <TCutG.h>
|
|
#include <TString.h>
|
|
#include <TObjArray.h>
|
|
|
|
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();
|
|
|
|
}
|