MaCh3  2.8.0
Reference Guide
CombineModule.hpp
Go to the documentation of this file.
1 
4 #pragma once
5 #include "CLI/API/plugin.hpp"
6 // C++ includes
7 #include <unistd.h>
8 
9 // MaCh3 includes
10 #include "Manager/Manager.h"
11 #include "Samples/SampleStructs.h"
12 #include "Utils/HistogramUtils.h"
13 
15 // ROOT includes
16 #include "TList.h"
17 #include "TFile.h"
18 #include "TMacro.h"
19 #include "TTree.h"
20 #include "TMD5.h"
21 #include "TFileMerger.h"
22 #include "TKey.h"
23 #include "TROOT.h"
25 
26 namespace M3{
29 class CombineModule: public IModuleBase{
30  public:
32  virtual ~CombineModule();
33 
36  MaCh3ArgumentParser* get_parser() override;
37 
40  int Run() override;
41 
43  bool ShouldSkipLine(const std::string& line, const std::vector<std::string>& SkipVector);
44 
49  bool CompareTwoConfigs(const std::string& File1, const std::string& File2, const std::vector<std::string>& SkipVector);
50 
52  bool checkSoftwareVersions(TFile *file, TFile *prevFile, const std::string& ConfigName, const std::vector<std::string>& SkipVector = {});
53 
55  void CopyDir(TDirectory *source);
56 
59  bool CompareHistograms(const TH1* h1, const TH1* h2, const std::string& histName, const std::string& folderName);
60 
62  bool CheckFolder(TFile* file, TFile* prevFile, const std::string& FolderName, const std::vector<std::string>& SkipVector = {});
63 
66  void FastMergeTTrees(const std::vector<std::string>& files, const std::string& outFile, const std::string& TTreeName);
67 
68  void CombineChain();
69 
70  private:
71  std::string OutFileName = "";
73  std::vector<std::string> inpFileList;
74  bool forceOverwrite = false;
75  bool forceMerge = false;
76 };
77 }
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
Definition: Core.h:126
#define _MaCh3_Safe_Include_End_
Allows you to combine multiple chains or ROOT files into a single output.
void FastMergeTTrees(const std::vector< std::string > &files, const std::string &outFile, const std::string &TTreeName)
custom function for merging TTree, should be similar to what HADD is using
std::vector< std::string > inpFileList
int Run() override
Execute the application.
virtual ~CombineModule()
Destructor.
bool ShouldSkipLine(const std::string &line, const std::vector< std::string > &SkipVector)
KS: This allow us to skip output name etc in config. We expect Output name will be different but this...
bool CompareTwoConfigs(const std::string &File1, const std::string &File2, const std::vector< std::string > &SkipVector)
make sure two configs are identical but skip specified fields. For example when comparing two chains ...
bool CompareHistograms(const TH1 *h1, const TH1 *h2, const std::string &histName, const std::string &folderName)
Compare two histograms if they are identical.
std::string OutFileName
void CopyDir(TDirectory *source)
When we merge two chains they have TDirectory ROOT didn't provide method for this so here we have thi...
MaCh3ArgumentParser * get_parser() override
Get the argument parser for this module.
bool CheckFolder(TFile *file, TFile *prevFile, const std::string &FolderName, const std::vector< std::string > &SkipVector={})
Loop through TH1 and TMacro objects in FolderName in 'file' and compare with those in 'prevFile'.
bool checkSoftwareVersions(TFile *file, TFile *prevFile, const std::string &ConfigName, const std::vector< std::string > &SkipVector={})
EM: Will compare the version header contained in the two provided files and shout if they don't match...
Extended ArgumentParser with MaCh3-specific functionality.
Definition: m3argparse.hpp:17
Base class for core modules in MaCh3.
Definition: plugin.hpp:41
Main namespace for MaCh3 software.
Plugin interface and registration macros for MaCh3.