#include #include void pedestal() { const char* pedestal00 = "pedestal00.root"; const char* subtractped = "subtractped.root"; TFile* inputFile = new TFile("pedestal00.root", "READ"); TFile* outputFile = new TFile("subtractped.root", "RECREATE"); TTree* inputTree = (TTree*)inputFile->Get("tree"); TTree* outputTree = inputTree->CloneTree(0); Double_t inputBranch; / TBranch* inputBranchPtr = inputTree->GetBranch("x3"); TBranch* outputBranchPtr = outputTree->Branch("x33", &inputBranch); Double_t pedestalValue = 42.0; Long64_t nEntries = inputTree->GetEntries(); for (Long64_t iEntry = 0; iEntry < nEntries; ++iEntry) { inputTree->GetEntry(iEntry); inputBranch -= pedestalValue; outputBranchPtr->Fill(); outputTree->Fill(); } outputFile->Write(); cout << "Entries: " << nEntries << endl; inputFile->Close(); outputFile->Close(); printf("Pedestal subtraction completed. Output saved to %s\n", "subtractped.root"); }