using namespace std;

void draw (){
    TFile* tfile = TFile::Open("celltreeOVERLAY.root");
    TTree* Sim = (TTree*) tfile->Get("/Event/Sim");

    TClonesArray* g = new TClonesArray;
    Sim->SetBranchAddress("calibGaussian_wf", &g);
    // Sim->SetBranchAddress("cosmic_hg_wf", &g);
    Sim->GetEntry(0);
    auto hg = dynamic_cast<TH1*>(g->At(0));
    hg->SetLineColor(kRed);
    TCanvas* c = new TCanvas("cc","cc");
    // hg->Draw();
    cout << "hg: " << hg->Integral() << "\n";
    
    TClonesArray* w = new TClonesArray;
    Sim->SetBranchAddress("calibWiener_wf", &w);
    Sim->GetEntry(0);
    auto hw = dynamic_cast<TH1F*>(w->At(0));
    cout << "hw: " << hw->Integral() << "\n";

    // hg->Draw();
    // hw->Draw("same,e");

    std::vector<int>* badChannel = new std::vector<int>;
    std::vector<int>* badBegin = new std::vector<int>;
    std::vector<int>* badEnd = new std::vector<int>;

    Sim->SetBranchAddress("badChannel", &badChannel);
    Sim->SetBranchAddress("badBegin", &badBegin);
    Sim->SetBranchAddress("badEnd", &badEnd);
    Sim->GetEntry(0);
    cout << "badChannel->size(): " << badChannel->size() << "\n";
}