void ReduceLeaves(string infiledir = "./mergedroot2/", string infilename="MCEventsPhysicsWeightedMerged7"){ gROOT->Reset(); gSystem->Load("libweighting-module"); /* string infiledir = "./mergedroot2/"; string infilename="MCEventsPhysicsWeightedMerged7" ; */ string outfilename = infilename; infilename = infiledir + infilename; infilename += ".root"; outfilename += "reduced.root"; cout << "infilename:" << infilename << endl; cout << "outfilename:" << outfilename << endl; //Get old file, old tree and set top branch address TFile *oldfile = new TFile(infilename.c_str()); TTree *oldtree = (TTree*)oldfile->Get("JulietTree"); SimulationCheckerTree *thisevent = new SimulationCheckerTree(); oldtree->SetBranchAddress("branch",&thisevent); //oldtree->SetBranchStatus("*",0); oldtree->SetBranchStatus("RomeoChannels_",0); oldtree->SetBranchStatus("RomeoChannels_.fUniqueID",0); oldtree->SetBranchStatus("RomeoChannels_.fBits",0); oldtree->SetBranchStatus("RomeoChannels_.nPulse_",0); /// oldtree->SetBranchStatus("McHitChannels_",0); oldtree->SetBranchStatus("McHitChannels_.fUniqueID",0); oldtree->SetBranchStatus("McHitChannels_.fBits",0); oldtree->SetBranchStatus("McHitChannels_.string_",0); oldtree->SetBranchStatus("McHitChannels_.omNumber_",0); oldtree->SetBranchStatus("McHitChannels_.mcNpe_",0); oldtree->SetBranchStatus("McHitChannels_.firstMcHitTime_",0); oldtree->SetBranchStatus("AtwdResponseChannels_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.fUniqueID",0); oldtree->SetBranchStatus("AtwdResponseChannels_.fBits",0); oldtree->SetBranchStatus("AtwdResponseChannels_.string_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.omNumber_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.integratedCharge_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulseTime_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulseAmplitude_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulsePosition_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.estimatedNPE_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulsePeakTime_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulseTime50_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulseTime80_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.launchTime_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.leTime_",0); oldtree->SetBranchStatus("AtwdResponseChannels_.pulseBaseLine_",0); oldtree->SetBranchStatus("FadcResponseChannels_",0); oldtree->SetBranchStatus("FadcResponseChannels_.fUniqueID",0); oldtree->SetBranchStatus("FadcResponseChannels_.fBits",0); oldtree->SetBranchStatus("FadcResponseChannels_.string_",0); oldtree->SetBranchStatus("FadcResponseChannels_.omNumber_",0); oldtree->SetBranchStatus("FadcResponseChannels_.integratedCharge_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulseTime_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulseAmplitude_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulsePosition_",0); oldtree->SetBranchStatus("FadcResponseChannels_.estimatedNPE_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulsePeakTime_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulseTime50_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulseTime80_",0); oldtree->SetBranchStatus("FadcResponseChannels_.launchTime_",0); oldtree->SetBranchStatus("FadcResponseChannels_.leTime_",0); oldtree->SetBranchStatus("FadcResponseChannels_.pulseBaseLine_",0); oldtree->SetBranchStatus("PulseInfoChannels_",0); oldtree->SetBranchStatus("PulseInfoChannels_.fUniqueID",0); oldtree->SetBranchStatus("PulseInfoChannels_.fBits",0); oldtree->SetBranchStatus("PulseInfoChannels_.largerAtwdCharge_",0); oldtree->SetBranchStatus("PulseInfoChannels_.largerFadcCharge_",0); oldtree->SetBranchStatus("PulseInfoChannels_.flagLC_",0); oldtree->SetBranchStatus("generatorWeight_.initialEnergy_",0); oldtree->SetBranchStatus("generatorWeight_.initialEnergyLog_",0); oldtree->SetBranchStatus("generatorWeight_.initialCosZenith_",0); oldtree->SetBranchStatus("generatorWeight_.anisAtmosphericFlux_",0); oldtree->SetBranchStatus("generatorWeight_.detectionLength_",0); oldtree->SetBranchStatus("generatorWeight_.finalInteractionProbabilityWeight_",0); //Create a new file + a clone of old tree in new file TFile *newfile = new TFile(outfilename.c_str(),"recreate"); TTree *newtree = oldtree->CloneTree(); newtree->Print(); newfile->Write(); //delete oldfile; //delete newfile; }