#include #include #include #include #include #include using namespace std; void splitfiles(TString FileName) // int main(int argc, char* argv[]) { // TApplication *rootapp = new TApplication("example",&argc, argv); // TString FileName = argv[1]; TFile *inf = new TFile("/mnt/storage/8TeV/FastSimulation/0900_300_090/CMGtuples/"+FileName+".root"); TFile *outf1 = new TFile("/mnt/storage/8TeV/FastSimulation/0900_300_090/CMGtuples/"+FileName+"_splitted_0000_0500.root","recreate"); TFile *outf2 = new TFile("/mnt/storage/8TeV/FastSimulation/0900_300_090/CMGtuples/"+FileName+"_splitted_0500_1000.root","recreate"); TFile *outf3 = new TFile("/mnt/storage/8TeV/FastSimulation/0900_300_090/CMGtuples/"+FileName+"_splitted_1000_1500.root","recreate"); TFile *outf4 = new TFile("/mnt/storage/8TeV/FastSimulation/0900_300_090/CMGtuples/"+FileName+"_splitted_1500_2000.root","recreate"); TFile *outf5 = new TFile("/mnt/storage/8TeV/FastSimulation/0900_300_090/CMGtuples/"+FileName+"_splitted_2000_2500.root","recreate"); TFile *out_file[5]; out_file[0] = outf1; out_file[1] = outf2; out_file[2] = outf3; out_file[3] = outf4; out_file[4] = outf5; for(int c=0; c<5; c++) { int s = 500*c; TTree *old_MetaData = (TTree*)inf->Get("MetaData"); TTree *old_ParameterSets = (TTree*)inf->Get("ParameterSets"); TTree *old_Parentage = (TTree*)inf->Get("Parentage"); TTree *old_Events = (TTree*)inf->Get("Events"); TTree *old_LuminosityBlocks = (TTree*)inf->Get("LuminosityBlocks"); TTree *old_Runs = (TTree*)inf->Get("Runs"); TTree *new_MetaData = old_MetaData->CloneTree(0); TTree *new_ParameterSets = old_ParameterSets->CloneTree(0); TTree *new_Parentage = old_Parentage->CloneTree(0); TTree *new_LuminosityBlocks = old_LuminosityBlocks->CloneTree(0); TTree *new_Events = old_Events->CloneTree(0); TTree *new_Runs = old_Runs->CloneTree(0); for (int i=s;iGetEntry(i); old_ParameterSets->GetEntry(i); old_Parentage->GetEntry(i); old_LuminosityBlocks->GetEntry(i); old_Events->GetEntry(i); old_Runs->GetEntry(i); new_MetaData->Fill(); new_ParameterSets->Fill(); new_Parentage->Fill(); new_LuminosityBlocks->Fill(); new_Events->Fill(); new_Runs->Fill(); } // newtree->Print(); out_file[c]->cd(); new_MetaData->AutoSave(); new_ParameterSets->AutoSave(); new_Parentage->AutoSave(); new_LuminosityBlocks->AutoSave(); new_Events->AutoSave(); new_Runs->AutoSave(); delete old_MetaData; delete old_ParameterSets; delete old_Parentage; delete old_LuminosityBlocks; delete old_Events; delete old_Runs; delete new_MetaData; delete new_ParameterSets; delete new_Parentage; delete new_LuminosityBlocks; delete new_Events; delete new_Runs; } // rootapp->Run(); // rootapp->Terminate(); gApplication->Terminate(); }