Filler for TTrees.
More...
#include <HistogramFillerTree.h>
|
| template<class H, typename W, typename C, typename ... Ms> |
| unsigned | fill (W weight, C cut, const Ms &... m) const |
| | Fill histogram from IMonitoredVariable.
|
| template<class H> |
| H * | histogram () const |
Filler for TTrees.
Definition at line 22 of file HistogramFillerTree.h.
◆ HistogramFillerTree()
Definition at line 24 of file HistogramFillerTree.h.
27 }
HistogramFiller(const HistogramDef &histDef, std::shared_ptr< IHistogramProvider > histogramProvider)
Default constructor.
◆ branchHelper()
template<typename T>
| void Monitored::HistogramFillerTree::branchHelper |
( |
TTree * | tree, |
|
|
const std::pair< std::string, std::string > & | brdef ) const |
|
inlineprivate |
◆ createBranches()
| void Monitored::HistogramFillerTree::createBranches |
( |
TTree * | tree | ) |
const |
|
inlineprivate |
Definition at line 141 of file HistogramFillerTree.h.
141 {
152 else if (brdef.second == "string") {
153 std::string
dummy;
tree->Branch(brdef.first.c_str(), &dummy);
154 } else if (brdef.second != "IGNORE") {
155 tree->Branch(brdef.first.c_str(), (
void*)
nullptr, (brdef.first+
"/"+brdef.second).c_str());
156 }
157 }
158 }
std::vector< std::pair< std::string, std::string > > m_branchDefs
void branchHelper(TTree *tree, const std::pair< std::string, std::string > &brdef) const
◆ fill() [1/2]
template<class
H, typename W, typename
C, typename ... Ms>
| unsigned Monitored::HistogramFiller::fill |
( |
W | weight, |
|
|
C | cut, |
|
|
const Ms &... | m ) const |
|
inlineprotectedinherited |
Fill histogram from IMonitoredVariable.
Supports arbitrary dimensions and double/string representation.
- Template Parameters
-
| H | histogram type (TH1, TH2, ...) |
- Parameters
-
Definition at line 168 of file HistogramFiller.h.
168 {
170
172 for (;
i < std::max({
m.size()...}); ++
i ) {
175 }
176 }
178 }
cut
This script demonstrates how to call a C++ class from Python Also how to use PyROOT is shown.
void doFill(H *hist, W weight, size_t i, const M &m1, const Ms &... m)
Perform (arbitrary dimension) histogram fill with weight.
◆ fill() [2/2]
Method that actually fills the ROOT object.
- Returns
- number of fills performed
Implements Monitored::HistogramFiller.
Definition at line 29 of file HistogramFillerTree.h.
29 {
30
31 if (vars.cut) {
32 const size_t maskSize = vars.cut->size();
33
34 if (maskSize == 0 || (maskSize == 1 && !vars.cut->get(0))) { return 0; }
35
38 log << MSG::WARNING <<
"HistogramFillerTree (" <<
m_histDef->alias
39 << ") does not support more than a single entry being filled at a time\n"
40 <<
"so a cut mask with > 1 entry doesn't make sense. Using first entry only." <<
endmsg;
41 if (!vars.cut->get(0)) { return 0; }
42 }
43 }
44
47 log << MSG::ERROR <<
"Mismatch of passed variables and expected variables for " <<
m_histDef->alias
49 return 0;
50 }
51
53 if (
tree->GetListOfBranches()->GetEntries() == 0) {
55 }
56 auto branchList =
tree->GetListOfBranches();
57
58 size_t idx = 0, idxgood = 0;
62 }
63 TBranch* branch = static_cast<TBranch*>(branchList->At(idxgood));
66 }
67 for (Int_t i = 0;
i < branchList->GetEntries(); ++
i) {
68
69
70 }
71 tree->SetEntries(
tree->GetEntries() + 1);
72 return 1;
73 }
std::vector< std::function< void(TBranch *, const IMonitoredVariable &)> > m_fillerFunctions
void createBranches(TTree *tree) const
std::shared_ptr< HistogramDef > m_histDef
IMessageSvc * getMessageSvc(bool quiet=false)
◆ getLock()
| const std::unique_lock< std::mutex > Monitored::HistogramFiller::getLock |
( |
| ) |
const |
|
inlineinherited |
◆ histogram()
| H * Monitored::HistogramFiller::histogram |
( |
| ) |
const |
|
inlineprotectedinherited |
Definition at line 153 of file HistogramFiller.h.
153 {
155 }
std::shared_ptr< IHistogramProvider > m_histogramProvider
◆ histogramCutMaskName()
| const std::string & Monitored::HistogramFiller::histogramCutMaskName |
( |
| ) |
const |
|
inlineinherited |
◆ histogramVariablesNames()
| const std::vector< std::string > & Monitored::HistogramFiller::histogramVariablesNames |
( |
| ) |
const |
|
inlineinherited |
◆ histogramWeightName()
| const std::string & Monitored::HistogramFiller::histogramWeightName |
( |
| ) |
const |
|
inlineinherited |
◆ parseDefinition()
| void Monitored::HistogramFillerTree::parseDefinition |
( |
| ) |
|
|
inlineprivate |
Definition at line 79 of file HistogramFillerTree.h.
79 {
80 std::vector<std::string> tokenized;
81 boost::split(tokenized,
m_histDef->treeDef, [](
char c){ return c ==
':'; });
82 for (const auto& token : tokenized) {
83 auto ipart = token.find('/');
84 if (ipart == std::string::npos) {
86 log << MSG::ERROR <<
"Tree " <<
m_histDef->alias <<
": Badly formed variable definition " << token
88 continue;
89 }
90 auto branch = token.substr(0, ipart);
91 auto type = token.substr(ipart+1);
92 std::function<void(TBranch*, const IMonitoredVariable&)> fillerFunc;
93
117 else if (type == "C") {
119 log << MSG::ERROR <<
"Tree " <<
m_histDef->alias <<
": Branch type \"C\" not supported for branch" << branch
120 <<
"; please use \"string\"" <<
endmsg;
122 } else {
124 log << MSG::ERROR <<
"Tree " <<
m_histDef->alias <<
": Unrecognized branch type " <<
type <<
" for branch " << branch
125 <<
"; ignoring branch " <<
endmsg;
127 }
130 }
131 }
void vectorFillerFunc< std::string >(TBranch *branch, const IMonitoredVariable &var)
void scalarFillerFunc< std::string >(TBranch *branch, const IMonitoredVariable &var)
void vectorFillerFunc(TBranch *branch, const IMonitoredVariable &var)
void scalarFillerFunc(TBranch *branch, const IMonitoredVariable &var)
◆ touch()
| void Monitored::HistogramFiller::touch |
( |
| ) |
const |
|
inlineinherited |
◆ m_branchDefs
| std::vector<std::pair<std::string, std::string> > Monitored::HistogramFillerTree::m_branchDefs |
|
private |
◆ m_fillerFunctions
| std::vector<std::function<void(TBranch*, const IMonitoredVariable&)> > Monitored::HistogramFillerTree::m_fillerFunctions |
|
private |
◆ m_histDef
| std::shared_ptr<HistogramDef> Monitored::HistogramFiller::m_histDef |
|
protectedinherited |
◆ m_histogramProvider
◆ m_lock
| std::mutex Monitored::HistogramFiller::m_lock |
|
mutableprotectedinherited |
The documentation for this class was generated from the following file: