Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUnfoldBinningXML.cxx
Go to the documentation of this file.
1// Author: Stefan Schmitt
2// DESY, 10/08/11
3
4// Version 17.9, parallel to changes in TUnfold
5//
6// History:
7// Version 17.8, relaxed DTD definition
8// Version 17.7, in parallel to changes in TUnfold
9// Version 17.6, with updated doxygen comments
10// Version 17.5, in parallel to changes in TUnfold
11// Version 17.4, in parallel to changes in TUnfoldBinning
12// Version 17.3, support for the "repeat" attribute for element Bin
13// Version 17.2, initial version, numbered in parallel to TUnfold
14
15/** \class TUnfoldBinningXML
16XML interfate to binning schemes, for use with the unfolding algorithm
17TUnfoldDensity.
18
19Binning schemes are used to map analysis bins on a single histogram
20axis and back. The analysis bins may include unconnected bins (e.g
21nuisances for background normalisation) or various multidimensional
22histograms (signal bins, differential background normalisation bins, etc).
23<br/>
24If you use this software, please consider the following citation
25<br/>
26<b>S.Schmitt, JINST 7 (2012) T10003 [arXiv:1205.6201]</b>
27<br/>
28Detailed documentation and updates are available on
29http://www.desy.de/~sschmitt
30
31Please consult the documentation of the class TUnfoldBinning about how to use
32binning schemes. This class provides methods to read and write binning
33schemes in the XML language. There is also a method which writes out
34a dtd file for validation.
35<h3>Example XML code</h3>
36The example below encodes two binning schemes, <em>detector</em> and
37<em>generator</em>. The detecor scheme consists of a single,
38three-dimensional distribution (pt,eta,discriminator). The generator
39scheme consists of two two-dimensional distributions, signal and background.
40<pre>
41<?xml version="1.0" encoding="UTF-8" standalone="no"?>
42<!DOCTYPE TUnfoldBinning SYSTEM "tunfoldbinning.dtd">
43<TUnfoldBinning>
44<BinningNode name="detector" firstbin="1" factor="1">
45 <BinningNode name="detectordistribution" firstbin="1" factor="1">
46 <Axis name="pt" lowEdge="3.5">
47 <Bin repeat="3" width="0.5" />
48 <Bin repeat="3" width="1" />
49 <Bin width="2" />
50 <Bin width="3" />
51 <Bin location="overflow"/>
52 <Axis name="eta" lowEdge="-3">
53 <Bin repeat="2" width="0.5" />
54 <Bin width="1" />
55 <Bin repeat="4" width="0.5" />
56 <Bin width="1" />
57 <Bin repeat="2" width="0.5" />
58 <Axis name="discriminator" lowEdge="0">
59 <Bin width="0.15" />
60 <Bin repeat="2" width="0.35" />
61 <Bin width="0.15" />
62 </Axis>
63 </Axis>
64 </Axis>
65 </BinningNode>
66</BinningNode>
67<BinningNode name="generator" firstbin="1" factor="1">
68 <BinningNode name="signal" firstbin="1" factor="1">
69 <Axis name="ptgen" lowEdge="4">
70 <Bin location="underflow" />
71 <Bin width="1" />
72 <Bin width="2" />
73 <Bin width="3" />
74 <Bin location="overflow" />
75 <Axis name="etagen" lowEdge="-2">
76 <Bin location="underflow" />
77 <Bin width="1.5" />
78 <Bin width="1" />
79 <Bin width="1.5" />
80 <Bin location="overflow" />
81 </Axis>
82 </Axis>
83 </BinningNode>
84 <BinningNode name="background" firstbin="26" factor="1">
85 <Axis name="ptrec" lowEdge="3.5">
86 <Bin repeat="3" width="0.5" />
87 <Bin repeat="3" width="1" />
88 <Bin width="2" />
89 <Bin width="3" />
90 <Bin location="overflow" />
91 <Axis name="etarec" lowEdge="-3">
92 <Bin repeat="2" width="0.5" />
93 <Bin width="1" />
94 <Bin repeat="4" width="0.5" />
95 <Bin width="1" />
96 <Bin repeat="2" width="0.5" />
97 </Axis>
98 </Axis>
99 </BinningNode>
100</BinningNode>
101</TUnfoldBinning>
102</pre>
103
104*/
105
106/*
107 This file is part of TUnfold.
108
109 TUnfold is free software: you can redistribute it and/or modify
110 it under the terms of the GNU General Public License as published by
111 the Free Software Foundation, either version 3 of the License, or
112 (at your option) any later version.
113
114 TUnfold is distributed in the hope that it will be useful,
115 but WITHOUT ANY WARRANTY; without even the implied warranty of
116 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
117 GNU General Public License for more details.
118
119 You should have received a copy of the GNU General Public License
120 along with TUnfold. If not, see <http://www.gnu.org/licenses/>.
121*/
122
123
124#include "TUnfold.h"
125#include "TUnfoldBinningXML.h"
126
127#include <TXMLDocument.h>
128#include <TXMLNode.h>
129#include <TXMLAttr.h>
130#include <TList.h>
131#include <TVectorD.h>
132
133#include <fstream>
134#include <sstream>
135
136// #define DEBUG
137
138using std::ofstream, std::stringstream;
139
140
141/********************* XML **********************/
142
143////////////////////////////////////////////////////////////////////////
144/// write dtd file
145///
146/// \param[out] out stream for writing the dtd
147void TUnfoldBinningXML::WriteDTD(std::ostream &out) {
148 out
149 <<"<!-- TUnfold Version "<<TUnfold::GetTUnfoldVersion()<<" -->\n"
150 <<"<!ELEMENT TUnfoldBinning (BinningNode)+ >\n"
151 <<"<!ELEMENT BinningNode ((Bins?,BinningNode*)|(Binfactorlist?,Axis,BinningNode*)) >\n"
152 <<"<!ATTLIST BinningNode name ID #REQUIRED firstbin CDATA \"-1\"\n"
153 <<" factor CDATA \"1.\">\n"
154 <<"<!ELEMENT Axis ((Bin+,Axis?)|(Axis)) >\n"
155 <<"<!ATTLIST Axis name CDATA #REQUIRED lowEdge CDATA #REQUIRED>\n"
156 <<"<!ELEMENT Binfactorlist (#PCDATA)>\n"
157 <<"<!ATTLIST Binfactorlist length CDATA #REQUIRED>\n"
158 <<"<!ELEMENT Bin EMPTY>\n"
159 <<"<!ATTLIST Bin width CDATA #REQUIRED location CDATA #IMPLIED\n"
160 <<" center CDATA #IMPLIED repeat CDATA #IMPLIED>\n"
161 <<"<!ELEMENT Bins (BinLabel)* >\n"
162 <<"<!ATTLIST Bins nbin CDATA #REQUIRED>\n"
163 <<"<!ELEMENT BinLabel EMPTY>\n"
164 <<"<!ATTLIST BinLabel index CDATA #REQUIRED name CDATA #REQUIRED>\n";
165}
166
167////////////////////////////////////////////////////////////////////////
168/// write dtd file
169///
170/// \param[in] file regular file for writing the dtd
171void TUnfoldBinningXML::WriteDTD(const char *file) {
172 ofstream out(file);
173 WriteDTD(out);
174}
175
176////////////////////////////////////////////////////////////////////////
177/// import a binning scheme from an XML file
178///
179/// \param[in] document XMP document tree
180/// \param[in] name identifier of the binning scheme
181///
182/// returns a new TUnfoldBinningXML, if <b>name</b> is found in <b>document</b>
184(const TXMLDocument *document,const char *name) {
185 // import binning scheme from a XML document
186 // document: the XML document
187 // name: the name of the binning scheme to import
188 // if name==nullptr, the first binning scheme found in the tree is imported
189 TUnfoldBinningXML *r=nullptr;
190 TXMLNode *root=document->GetRootNode();
191 TXMLNode *binningNode=nullptr;
192 if(root && (!TString(root->GetNodeName()).CompareTo("TUnfoldBinning")) &&
194 // loop over all "BinningNode" entities
195 for(TXMLNode *node=root->GetChildren();node && !binningNode;
196 node=node->GetNextNode()) {
197 if(node->GetNodeType()==TXMLNode::kXMLElementNode &&
198 !TString(node->GetNodeName()).CompareTo("BinningNode") &&
199 node->GetAttributes()) {
200 // localize the BinningNode with the given name
201 TIterator *i=node->GetAttributes()->MakeIterator();
202 TXMLAttr *attr;
203 while((attr=(TXMLAttr *)i->Next())) {
204 if((!TString(attr->GetName()).CompareTo("name")) &&
205 ((!TString(attr->GetValue()).CompareTo(name)) ||
206 !name)) {
207 binningNode=node;
208 }
209 }
210 }
211 }
212 }
213
214 if(binningNode) {
216 }
217 return r;
218}
219
220////////////////////////////////////////////////////////////////////////
221/// recursively import one node from the XML tree
222///
223/// \param[in] node node in the XML document tree
224///
225/// returns a new TUnfoldBinningXML
226
228(TXMLNode *node) {
229 // import data from a given "BinningNode"
230 const char *name=nullptr;
231 Double_t factor=1.0;
232 TUnfoldBinningXML *r=nullptr;
233 Int_t nBins=0;
234 const char *binNames=nullptr;
236 TXMLAttr *attr;
237 // extract name and global factor
238 while((attr=(TXMLAttr *)i->Next())) {
239 TString attName(attr->GetName());
240 if(!attName.CompareTo("name")) {
241 name=attr->GetValue();
242 }
243 if(!attName.CompareTo("factor")) {
244 factor=TString(attr->GetValue()).Atof();
245 }
246 }
247 if(name) {
249 // loop over all children of this BinningNode
250 for(TXMLNode *child=node->GetChildren();child;
251 child=child->GetNextNode()) {
252 // unconnected bins: children are of type "Bins"
253 if(child->GetNodeType()==TXMLNode::kXMLElementNode &&
254 !TString(child->GetNodeName()).CompareTo("Bins")) {
255 // this node has unconnected bins, no axes
256 // extract number of bins
257 if(child->GetAttributes()) {
258 i=child->GetAttributes()->MakeIterator();
259 while((attr=(TXMLAttr *)i->Next())) {
260 TString attName(attr->GetName());
261 if(!attName.CompareTo("nbin")) {
262 // number of unconnected bins
263 nBins=TString(attr->GetValue()).Atoi();
264 }
265 }
266 }
267 // extract names of unconnected bins
269 for(TXMLNode *binName=child->GetChildren();binName;
270 binName=binName->GetNextNode()) {
271 if(binName->GetNodeType()==TXMLNode::kXMLElementNode &&
272 !TString(binName->GetNodeName()).CompareTo("BinLabel")) {
273 i=binName->GetAttributes()->MakeIterator();
274 const char *binLabelName=nullptr;
275 Int_t index=0;
276 while((attr=(TXMLAttr *)i->Next())) {
277 TString attName(attr->GetName());
278 if(!attName.CompareTo("index")) {
279 index=TString(attr->GetValue()).Atoi();
280 }
281 if(!attName.CompareTo("name")) {
282 binLabelName=attr->GetValue();
283 }
284 }
285 if((index>=0)&&(binLabelName)) {
286 if(index>=theBinNames.GetEntriesFast()) {
287 theBinNames.AddAtAndExpand
289 }
290 }
291 }
292 }
294 for(Int_t ii=0;ii<theBinNames.GetEntriesFast()&&(ii<nBins);ii++) {
295 if(theBinNames.At(ii)) {
296 for(Int_t k=0;k<emptyName;k++) binNameList+=";";
297 emptyName=0;
299 ((TObjString *)theBinNames.At(ii))->GetString();
300 }
301 emptyName++;
302 }
303 if(binNameList.Length()>0) {
305 }
306 }
307 }
308 r=new TUnfoldBinningXML(name,nBins,binNames);
309
310 // add add axis information
311 r->AddAxisXML(node);
312
313 // import per-bin normalisation factors if there are any
314 TVectorD *perBinFactors=nullptr;
315 for(TXMLNode *child=node->GetChildren();child;
316 child=child->GetNextNode()) {
317 // unconnected bins: children are of type "Bins"
318 if(child->GetNodeType()==TXMLNode::kXMLElementNode &&
319 !TString(child->GetNodeName()).CompareTo("Binfactorlist")) {
320 int length=0;
321 i=child->GetAttributes()->MakeIterator();
322 while((attr=(TXMLAttr *)i->Next())) {
323 TString attName(attr->GetName());
324 if(!attName.CompareTo("length")) {
325 length=TString(attr->GetValue()).Atoi();
326 }
327 }
328 int nread=0;
329 if(length==r->GetDistributionNumberOfBins()) {
331 const char *text=child->GetText();
332 if(text) {
333 stringstream readFactors(text);
334 for(;nread<length;nread++) {
335 readFactors>> (*perBinFactors)(nread);
336 if(readFactors.fail()) break;
337 }
338 }
339 }
340 if(!perBinFactors) {
341 child->Error("ImportXMLNode","while reading per-bin factors"
342 " node=%s length=%d (expected %d)",r->GetName(),
343 length,r->GetDistributionNumberOfBins());
344 } else if(nread!=length) {
345 child->Error("ImportXMLNode","while reading per-bin factors"
346 " TUnfoldBinning=%s expected %d found %d",
347 r->GetName(),length,nread);
348 delete perBinFactors;
349 perBinFactors=nullptr;
350 }
351 }
352 }
353
354 // set normalisation factors
355 r->SetBinFactor(factor,perBinFactors);
356
357 // now: loop over all child binnings and add them
358 for(TXMLNode *child=node->GetChildren();child;
359 child=child->GetNextNode()) {
360 if(child->GetNodeType()==TXMLNode::kXMLElementNode &&
361 !TString(child->GetNodeName()).CompareTo("BinningNode") &&
362 child->GetAttributes()) {
364 r->AddBinning(childBinning);
365 }
366 }
367 }
368 return r;
369}
370
371////////////////////////////////////////////////////////////////////////
372/// import axis from XML node
373///
374/// \param[in] node node in the XML document tree
375
377 // find axis if there is one
378 TXMLNode *axis=nullptr;
379 for(TXMLNode *child=node->GetChildren();child;
380 child=child->GetNextNode()) {
381 if(child->GetNodeType()==TXMLNode::kXMLElementNode) {
382 TString nodeName(child->GetNodeName());
383 if(!nodeName.CompareTo("Axis")) axis=child;
384 }
385 }
386 if(axis) {
387 const char *axisName=nullptr;
388 TArrayD binEdges(1);
390 TXMLAttr *attr;
391 while((attr=(TXMLAttr *)i->Next())) {
392 TString attName(attr->GetName());
393 if(!attName.CompareTo("name")) {
394 axisName=attr->GetValue();
395 }
396 if(!attName.CompareTo("lowEdge")) {
397 binEdges[0]=TString(attr->GetValue()).Atof();
398 }
399 }
401 Bool_t underflow=kFALSE,overflow=kFALSE;
402 for(TXMLNode *child=axis->GetChildren();child;
403 child=child->GetNextNode()) {
404 if(child->GetNodeType()==TXMLNode::kXMLElementNode) {
405 TString nodeName(child->GetNodeName());
406 if(!nodeName.CompareTo("Axis")) hasMoreAxes=kTRUE;
407 if(!nodeName.CompareTo("Bin")) {
409 Int_t repeat=1;
410 i=child->GetAttributes()->MakeIterator();
411 while((attr=(TXMLAttr *)i->Next())) {
412 TString attName(attr->GetName());
413 TString attText(attr->GetValue());
414 if(!attName.CompareTo("location")) {
415 isUnderflow= !attText.CompareTo("underflow");
416 isOverflow= !attText.CompareTo("overflow");
417 }
418 if(!attName.CompareTo("repeat")) {
419 repeat=attText.Atof();
420 }
421 }
422 if(repeat<1) {
423 node->Warning("AddAxisXML",
424 "attribute repeat=%d changed to repeat=1",
425 repeat);
426 repeat=1;
427 }
428 if((isUnderflow || isOverflow)&&(repeat!=1)) {
429 node->Error("AddAxisXML",
430 "underflow/overflow can not have repeat!=1 attribute");
431 }
432 if(isUnderflow || isOverflow) {
434 overflow |= isOverflow;
435 } else {
436 Int_t iBin0=binEdges.GetSize();
438 Double_t binWidth=0.0;
439 binEdges.Set(iBin1);
440 i=child->GetAttributes()->MakeIterator();
441 while((attr=(TXMLAttr *)i->Next())) {
442 TString attName(attr->GetName());
443 if(!attName.CompareTo("width")) {
444 binWidth=TString(attr->GetValue()).Atof();
445 }
446 }
447 if(binWidth<=0.0) {
448 node->Error("AddAxisXML",
449 "bin withd can not be smaller than zero");
450 }
451 for(int iBin=iBin0;iBin<iBin1;iBin++) {
452 binEdges[iBin]=binEdges[iBin0-1]+(iBin-iBin0+1)*binWidth;
453 }
454 }
455 }
456 }
457 }
458 AddAxis(axisName,binEdges.GetSize()-1,binEdges.GetArray(),
459 underflow,overflow);
460 if(hasMoreAxes) {
461 AddAxisXML(axis);
462 }
463 }
464}
465
466////////////////////////////////////////////////////////////////////////
467/// export a binning scheme to a stream in XML format
468///
469/// \param[in] binning the binning scheme to export
470/// \param[out] stream to write to
471/// \param[in] writeHeader set true when writing the first binning
472/// scheme to this stream
473/// \param[in] writeFooter set true when writing the last binning
474/// scheme to this stream
475/// \param[in] indent indentation of the XML output
476///
477/// returns true if the writing succeeded
479(const TUnfoldBinning &binning,std::ostream &out,Bool_t writeHeader,
481 //
482 if(writeHeader) {
483 out<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
484 <<"<!DOCTYPE TUnfoldBinning SYSTEM \"tunfoldbinning.dtd\">\n"
485 <<"<TUnfoldBinning>\n";
486 }
488 out<<trailer<<"<BinningNode name=\""<<binning.GetName()<<"\" firstbin=\""
489 <<binning.GetStartBin();
490 if(binning.IsBinFactorGlobal()) {
491 out<<"\" factor=\""<<binning.GetGlobalFactor()<<"\">\n";
492 } else {
493 out<<"\">\n";
494 out<<trailer<<" <Binfactorlist length=\""
495 <<binning.GetDistributionNumberOfBins()<<"\">\n";
496 for(int i=0;i<binning.GetDistributionNumberOfBins();i++) {
497 if(!(i % 10)) out<<trailer<<" ";
498 out<<" "<<binning.GetBinFactor(i+binning.GetStartBin());
499 if(((i %10)==9)||(i==binning.GetDistributionNumberOfBins()-1))
500 out<<"\n";
501 }
502 out<<trailer<<" </Binfactorlist>\n";
503 }
504 if(binning.HasUnconnectedBins()) {
505 out<<trailer<<" <Bins nbin=\""<<binning.GetDistributionNumberOfBins()
506 <<"\">\n";
507 for(Int_t i=0;i<binning.GetDistributionNumberOfBins();i++) {
508 const TObjString *name=binning.GetUnconnectedBinName(i);
509 if(!name) break;
510 out<<trailer<<" <BinLabel index=\""<<i<<"\" name=\""
511 <<name->GetString()<<"\" />\n";
512 }
513 out<<trailer<<" </Bins>\n";
514 } else {
515 for(Int_t axis=0;axis<binning.GetDistributionDimension();axis++) {
516 TString axisTrailer(' ',indent+1+axis);
517 TVectorD const *edges=binning.GetDistributionBinning(axis);
518 out<<axisTrailer<<"<Axis name=\""<<binning.GetDistributionAxisLabel(axis)
519 <<"\" lowEdge=\""<<(*edges)[0]<<"\">\n";
520 if(binning.HasUnderflow(axis)) {
521 out<<axisTrailer<<" <Bin location=\"underflow\" width=\""
522 <<binning.GetDistributionUnderflowBinWidth(axis)<<"\" center=\""
523 <<binning.GetDistributionBinCenter(axis,-1)<<"\" />\n";
524 }
525 for(Int_t i=0;i<edges->GetNrows()-1;i++) {
526 Int_t repeat=1;
527 Double_t width=(*edges)[i+1]-(*edges)[i];
528 Double_t center=binning.GetDistributionBinCenter(axis,i);
529 for(Int_t j=i+1;j<edges->GetNrows()-1;j++) {
530 double xEnd=(j-i+1)*width+(*edges)[i];
531 double xCent=center+(j-i)*width;
532 if((TMath::Abs(xEnd-(*edges)[j+1])<width*1.E-7)&&
534 width*1.E-7)) {
535 ++repeat;
536 } else {
537 break;
538 }
539 }
540 if(repeat==1) {
541 out<<axisTrailer<<" <Bin width=\""
542 <<width<<"\" center=\""<<center<<"\" />\n";
543 } else {
544 out<<axisTrailer<<" <Bin repeat=\""<<repeat
545 <<"\" width=\""<<width<<"\" center=\""<<center<<"\" />\n";
546 i += repeat-1;
547 }
548 }
549 if(binning.HasOverflow(axis)) {
550 out<<axisTrailer<<" <Bin location=\"overflow\" width=\""
551 <<binning.GetDistributionOverflowBinWidth(axis)<<"\" center=\""
552 <<binning.GetDistributionBinCenter(axis,edges->GetNrows()-1)<<"\"/>\n";
553 }
554 }
555 for(Int_t axis=binning.GetDistributionDimension()-1;axis>=0;axis--) {
556 TString axisTrailer(' ',indent+1+axis);
557 out<<axisTrailer<<"</Axis>\n";
558 }
559 }
560 for(TUnfoldBinning const *child=binning.GetChildNode();child;
561 child=child->GetNextNode()) {
563 }
564 out<<trailer<<"</BinningNode>\n";
565 if(writeFooter) {
566 out<<"</TUnfoldBinning>\n";
567 }
568 return out.fail() ? 0 : 1;
569}
570
571////////////////////////////////////////////////////////////////////////
572/// export this binning scheme to a file
573///
574/// \param[in] fileName name of the file
575///
576/// returns true if the writing succeeded
577Int_t TUnfoldBinningXML::ExportXML(char const *fileName) const {
578 // export this binning scheme to a file
579 // fileName: name of the xml file
580 ofstream outFile(fileName);
582 outFile.close();
583 return r;
584}
585
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t child
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t width
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
TVectorT< Double_t > TVectorD
Definition TVectorDfwd.h:23
Array of doubles (64 bits per element).
Definition TArrayD.h:27
void Set(Int_t n) override
Set size of this array to n doubles.
Definition TArrayD.cxx:105
const Double_t * GetArray() const
Definition TArrayD.h:43
Int_t GetSize() const
Definition TArray.h:47
Iterator abstract base class.
Definition TIterator.h:30
virtual TObject * Next()=0
TIterator * MakeIterator(Bool_t dir=kIterForward) const override
Return a list iterator.
Definition TList.cxx:719
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Basic string class.
Definition TString.h:138
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:464
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1994
Double_t Atof() const
Return floating-point value contained in string.
Definition TString.cxx:2060
XML interfate to binning schemes, for use with the unfolding algorithm TUnfoldDensity.
static Int_t ExportXML(const TUnfoldBinning &binning, std::ostream &out, Bool_t writeHeader, Bool_t writeFooter, Int_t indent=0)
export a binning scheme to a stream in XML format
void AddAxisXML(TXMLNode *node)
import axis from XML node
static TUnfoldBinningXML * ImportXMLNode(TXMLNode *node)
recursively import one node from the XML tree
static TUnfoldBinningXML * ImportXML(const TXMLDocument *document, const char *name)
import a binning scheme from an XML file
static void WriteDTD(const char *fileName="tunfoldbinning.dtd")
write dtd file
TUnfoldBinningXML(const char *name=nullptr, Int_t nBins=0, const char *binNames=nullptr)
construct a new binning scheme, for use with the root streamer
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
Bool_t HasOverflow(int axis) const
check whether the axis has an overflow bin
virtual Double_t GetDistributionOverflowBinWidth(Int_t axis) const
return bin width assigned to the overflow bin
Int_t GetDistributionDimension(void) const
query dimension of this node's distribution
virtual Double_t GetDistributionUnderflowBinWidth(Int_t axis) const
return bin width assigned to the underflow bin
Int_t GetDistributionNumberOfBins(void) const
number of bins in the distribution possibly including under/overflow
Double_t GetGlobalFactor(void) const
return global scaling factor for this node
Bool_t HasUnconnectedBins(void) const
check whether there are bins but no axis
virtual Double_t GetBinFactor(Int_t iBin) const
return scaling factor for the given global bin number
Bool_t HasUnderflow(int axis) const
check whether an axis has an underflow bin
virtual Double_t GetDistributionBinCenter(Int_t axis, Int_t bin) const
return bin center for a given axis and bin number
virtual Bool_t IsBinFactorGlobal(void) const
check whether there is only a global scaling factor for this node
TString GetDistributionAxisLabel(Int_t axis) const
get name of an axis
const TObjString * GetUnconnectedBinName(Int_t bin) const
return the bin names of unconnected bins
TVectorD const * GetDistributionBinning(Int_t axis) const
get vector of bin borders for one axis
Bool_t AddAxis(const char *name, Int_t nBins, const Double_t *binBorders, Bool_t hasUnderflow, Bool_t hasOverflow)
add an axis with the specified bin borders
Int_t GetStartBin(void) const
first bin of this node
TUnfoldBinning const * GetChildNode(void) const
first daughter node
static const char * GetTUnfoldVersion(void)
return a string describing the TUnfold version
Definition TUnfold.cxx:3717
Int_t GetNrows() const
Definition TVectorT.h:75
TXMLAttribute is the attribute of an Element.
Definition TXMLAttr.h:18
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
TXMLNode * GetRootNode() const
Returns the root element node.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
Definition TXMLNode.h:20
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
Definition TXMLNode.cxx:107
@ kXMLElementNode
Definition TXMLNode.h:37
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
Definition TXMLNode.cxx:73
const char * GetNodeName() const
Returns the node's name.
Definition TXMLNode.cxx:65
EXMLElementType GetNodeType() const
Returns the node's type.
Definition TXMLNode.cxx:57
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:124