From 688b9ad0474c92e39e74f3f9b91c9006d9c15b87 Mon Sep 17 00:00:00 2001 From: Jacopo Cerasoli Date: Thu, 29 Oct 2020 14:35:47 +0100 Subject: [PATCH 1/3] Added possibility in cutapplier to add friend to tuple. --- src/cutapplier.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cutapplier.cc b/src/cutapplier.cc index ebd8fc5..9bb7fb3 100644 --- a/src/cutapplier.cc +++ b/src/cutapplier.cc @@ -21,10 +21,10 @@ using std::cout; using std::endl; int main(int argc, char *argv[]) { - if(argc != 5 ){ + if(argc != 5 && argc != 6){ cout << "cutapplier: Applies a cut to an input ntuple"<< endl; cout << "author: Conor Fitzpatrick, 2008"<< endl; - cout << "Syntax: " << argv[0] << " "<< endl; + cout << "Syntax: " << argv[0] << " []"<< endl; return EXIT_FAILURE; } @@ -38,6 +38,10 @@ int main(int argc, char *argv[]) { TString name = tpath; TString cname = argv[3]; TString soutname = argv[4]; + TString ffriend = ""; + if(argc==6){ + ffriend = argv[5]; + } Bool_t clerrs = false; Double_t accepted = 0, rejected = 0, total = 0; Double_t acceptedm = 0, rejectedm = 0, totalm = 0; @@ -65,6 +69,9 @@ int main(int argc, char *argv[]) { cout << "Error opening the specified ntuple- is the path you specified correct?" << endl; exit(1); } + if(ffriend!=""){ + inTree->AddFriend(tpath,ffriend); + } tpath.Resize(std::max(tpath.First(slash),0)); total = (Double_t)inTree->GetEntries(); if(total>10){ @@ -89,6 +96,9 @@ int main(int argc, char *argv[]) { cout << "applying cut..." << endl; sw.Start(); TTree *soutTree = inTree->CopyTree(cname); accepted = (Double_t)soutTree->GetEntries(); + if(argc==6){ + soutTree->GetListOfFriends()->Clear("nodelete"); + } sout->Write(); sout->Close(); }else{ From dfe07ee93844f41518b9d63c61f2845a5240170e Mon Sep 17 00:00:00 2001 From: Jacopo Cerasoli Date: Sat, 31 Oct 2020 00:17:45 +0100 Subject: [PATCH 2/3] Moved optional argument and added description. --- src/cutapplier.cc | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/cutapplier.cc b/src/cutapplier.cc index 9bb7fb3..ced053d 100644 --- a/src/cutapplier.cc +++ b/src/cutapplier.cc @@ -22,9 +22,10 @@ using std::endl; int main(int argc, char *argv[]) { if(argc != 5 && argc != 6){ - cout << "cutapplier: Applies a cut to an input ntuple"<< endl; - cout << "author: Conor Fitzpatrick, 2008"<< endl; - cout << "Syntax: " << argv[0] << " []"<< endl; + cout << "cutapplier: Applies a cut to an input ntuple"<< endl; + cout << "author: Conor Fitzpatrick, 2008"<< endl; + cout << "Syntax: " << argv[0] << " [] "<< endl; + cout << ": Optional, friend added to . Not merged into " << endl; return EXIT_FAILURE; } @@ -33,14 +34,28 @@ int main(int argc, char *argv[]) { Double_t cl95p[11] = {3.09,5.14,6.72,8.25,9.76,11.26,12.75,13.81,15.29,16.77,17.82}; - TString inname = argv[1]; - TString tpath = argv[2]; - TString name = tpath; - TString cname = argv[3]; - TString soutname = argv[4]; + TString inname = ""; TString ffriend = ""; - if(argc==6){ - ffriend = argv[5]; + TString tpath = ""; + TString name = ""; + TString cname = ""; + TString soutname = ""; + + if(argc == 5){ + inname = argv[1]; + ffriend = ""; + tpath = argv[2]; + name = tpath; + cname = argv[3]; + soutname = argv[4]; + } + else if(argc == 6){ + inname = argv[1]; + ffriend = argv[2]; + tpath = argv[3]; + name = tpath; + cname = argv[4]; + soutname = argv[5]; } Bool_t clerrs = false; Double_t accepted = 0, rejected = 0, total = 0; @@ -57,6 +72,7 @@ int main(int argc, char *argv[]) { cout << "applying cut: " << cname << endl; cout << "to ntuple: " << tpath << endl; cout << "in file: " << inname << endl; + cout << "friend (optional): " << ffriend << endl; cout << "output file: " << soutname << endl; cout << "-------------------------------------------------------" << endl; @@ -96,7 +112,7 @@ int main(int argc, char *argv[]) { cout << "applying cut..." << endl; sw.Start(); TTree *soutTree = inTree->CopyTree(cname); accepted = (Double_t)soutTree->GetEntries(); - if(argc==6){ + if(argc == 6){ soutTree->GetListOfFriends()->Clear("nodelete"); } sout->Write(); From ada5261118fd61f0b8e27b4f6d8581035e1ca963 Mon Sep 17 00:00:00 2001 From: cofitzpa Date: Mon, 2 Nov 2020 09:23:53 +0000 Subject: [PATCH 3/3] Update cutapplier.cc Added more verbose description of the friend tree argument --- src/cutapplier.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cutapplier.cc b/src/cutapplier.cc index ced053d..bdbad16 100644 --- a/src/cutapplier.cc +++ b/src/cutapplier.cc @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) { cout << "cutapplier: Applies a cut to an input ntuple"<< endl; cout << "author: Conor Fitzpatrick, 2008"<< endl; cout << "Syntax: " << argv[0] << " [] "<< endl; - cout << ": Optional, friend added to . Not merged into " << endl; + cout << " is an optional file containing a friend tree with the same path as to provide additional selection parameters. The contents of this tree is not propagated into " << endl; return EXIT_FAILURE; }