|
@@ -47,10 +47,12 @@ template<typename TREE_CLASS>
|
|
class TreeDataSet : public DataSet{
|
|
class TreeDataSet : public DataSet{
|
|
private:
|
|
private:
|
|
// Maps filenames to data category. Either "signal" or "background"
|
|
// Maps filenames to data category. Either "signal" or "background"
|
|
- std::map<std::string,std::string> input_categories;
|
|
|
|
|
|
+ /* std::map<std::string,std::string> input_categories; */
|
|
// Maps filenames to data label, eg. "TTTT", or "TTZ"
|
|
// Maps filenames to data label, eg. "TTTT", or "TTZ"
|
|
std::map<std::string,std::string> input_labels;
|
|
std::map<std::string,std::string> input_labels;
|
|
|
|
+ std::map<std::string,std::string> input_categories;
|
|
std::string output_filename;
|
|
std::string output_filename;
|
|
|
|
+ std::vector<fv::util::DataFileDescriptor> dfds;
|
|
TFile* output_file;
|
|
TFile* output_file;
|
|
TREE_CLASS* tree_obj;
|
|
TREE_CLASS* tree_obj;
|
|
long next_entry;
|
|
long next_entry;
|
|
@@ -96,58 +98,57 @@ class TreeDataSet : public DataSet{
|
|
}
|
|
}
|
|
|
|
|
|
public:
|
|
public:
|
|
- TreeDataSet(const std::string& output_filename,
|
|
|
|
- const std::string& input_filename,
|
|
|
|
- const std::string& data_label,
|
|
|
|
- const std::string& tree_name="tree")
|
|
|
|
|
|
+
|
|
|
|
+ /* TreeDataSet(const std::string& output_filename, */
|
|
|
|
+ /* const std::vector<std::string>& input_filenames, */
|
|
|
|
+ /* const std::string& data_label, */
|
|
|
|
+ /* const std::string& tree_name="tree") */
|
|
|
|
+ /* :DataSet(), */
|
|
|
|
+ /* input_labels({ {input_filename, data_label} }), */
|
|
|
|
+ /* output_filename(output_filename), */
|
|
|
|
+ /* next_entry(0) { */
|
|
|
|
+ /* TChain* chain = new TChain(tree_name.c_str()); */
|
|
|
|
+ /* chain->Add(input_filename.c_str()); */
|
|
|
|
+ /* tree_obj = new TREE_CLASS(chain); */
|
|
|
|
+ /* nentries = tree_obj->fChain->GetEntries(); */
|
|
|
|
+ /* output_file = TFile::Open(output_filename.c_str(), "RECREATE"); */
|
|
|
|
+ /* tree_obj->fChain->SetBranchStatus("*", false); */
|
|
|
|
+ /* } */
|
|
|
|
+
|
|
|
|
+ /* void print_branch_statuses(){ */
|
|
|
|
+ /* TObjArray* obj_arr = tree_obj->fChain->GetListOfBranches(); */
|
|
|
|
+ /* for(TIter iter=obj_arr->begin(); iter!= obj_arr->end(); ++iter){ */
|
|
|
|
+ /* TBranch* br = (TBranch*)*iter; */
|
|
|
|
+ /* std::cout << br->GetName() << ": " */
|
|
|
|
+ /* << tree_obj->fChain->GetBranchStatus(br->GetName()) << std::endl; */
|
|
|
|
+ /* } */
|
|
|
|
+
|
|
|
|
+ /* } */
|
|
|
|
+
|
|
|
|
+ TreeDataSet(const std::string& output_filename, const std::vector<fv::util::DataFileDescriptor>& dfds,
|
|
|
|
+ const std::string& tree_name)
|
|
:DataSet(),
|
|
:DataSet(),
|
|
- input_categories({ {input_filename, "signal"} }),
|
|
|
|
- input_labels({ {input_filename, data_label} }),
|
|
|
|
|
|
+ dfds(dfds),
|
|
output_filename(output_filename),
|
|
output_filename(output_filename),
|
|
next_entry(0) {
|
|
next_entry(0) {
|
|
TChain* chain = new TChain(tree_name.c_str());
|
|
TChain* chain = new TChain(tree_name.c_str());
|
|
- chain->Add(input_filename.c_str());
|
|
|
|
|
|
+ for(auto& dfd : dfds){
|
|
|
|
+ chain->Add(dfd.filename.c_str());
|
|
|
|
+ input_labels[dfd.filename] = dfd.label;
|
|
|
|
+ input_categories[dfd.filename] = dfd.category;
|
|
|
|
+ }
|
|
tree_obj = new TREE_CLASS(chain);
|
|
tree_obj = new TREE_CLASS(chain);
|
|
nentries = tree_obj->fChain->GetEntries();
|
|
nentries = tree_obj->fChain->GetEntries();
|
|
output_file = TFile::Open(output_filename.c_str(), "RECREATE");
|
|
output_file = TFile::Open(output_filename.c_str(), "RECREATE");
|
|
tree_obj->fChain->SetBranchStatus("*", false);
|
|
tree_obj->fChain->SetBranchStatus("*", false);
|
|
- /* print_branch_statuses(); */
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- void print_branch_statuses(){
|
|
|
|
- TObjArray* obj_arr = tree_obj->fChain->GetListOfBranches();
|
|
|
|
- for(TIter iter=obj_arr->begin(); iter!= obj_arr->end(); ++iter){
|
|
|
|
- TBranch* br = (TBranch*)*iter;
|
|
|
|
- std::cout << br->GetName() << ": "
|
|
|
|
- << tree_obj->fChain->GetBranchStatus(br->GetName()) << std::endl;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // TODO: Rewrite this constructor
|
|
|
|
- /* MiniTreeDataSet(const std::string& output_filename, const std::map<std::string,std::string>& filenames_with_labels) */
|
|
|
|
- /* :DataSet(), */
|
|
|
|
- /* input_categories(filenames_with_labels), */
|
|
|
|
- /* output_filename(output_filename), */
|
|
|
|
- /* next_entry(0) { */
|
|
|
|
- /* TChain* chain = new TChain("tree"); */
|
|
|
|
- /* for(auto& p : filenames_with_labels){ */
|
|
|
|
- /* std::string filename; */
|
|
|
|
- /* std::tie(filename, std::ignore) = p; */
|
|
|
|
- /* chain->Add(filename.c_str()); */
|
|
|
|
- /* } */
|
|
|
|
- /* Init(chain); */
|
|
|
|
- /* nentries = fChain->GetEntries(); */
|
|
|
|
- /* output_file = TFile::Open(output_filename.c_str(), "RECREATE"); */
|
|
|
|
- /* this->fChain->SetBranchStatus("*", false); */
|
|
|
|
- /* } */
|
|
|
|
-
|
|
|
|
~TreeDataSet(){
|
|
~TreeDataSet(){
|
|
save_event_count_and_xsection();
|
|
save_event_count_and_xsection();
|
|
output_file->Close();
|
|
output_file->Close();
|
|
}
|
|
}
|
|
|
|
|
|
- const std::string& get_current_event_label() const{
|
|
|
|
|
|
+ const std::string& get_current_event_category() const{
|
|
TFile* file = tree_obj->fChain->GetFile();
|
|
TFile* file = tree_obj->fChain->GetFile();
|
|
std::string filename = file->GetName();
|
|
std::string filename = file->GetName();
|
|
return input_categories.at(filename);
|
|
return input_categories.at(filename);
|