138using std::ofstream, std::stringstream;
151 <<
"<!ELEMENT TUnfoldBinning (BinningNode)+ >\n"
152 <<
"<!ELEMENT BinningNode ((Bins?,BinningNode*)|(Binfactorlist?,Axis,BinningNode*)) >\n"
153 <<
"<!ATTLIST BinningNode name ID #REQUIRED firstbin CDATA \"-1\"\n"
154 <<
" factor CDATA \"1.\">\n"
155 <<
"<!ELEMENT Axis ((Bin+,Axis?)|(Axis)) >\n"
156 <<
"<!ATTLIST Axis name CDATA #REQUIRED lowEdge CDATA #REQUIRED>\n"
157 <<
"<!ELEMENT Binfactorlist (#PCDATA)>\n"
158 <<
"<!ATTLIST Binfactorlist length CDATA #REQUIRED>\n"
159 <<
"<!ELEMENT Bin EMPTY>\n"
160 <<
"<!ATTLIST Bin width CDATA #REQUIRED location CDATA #IMPLIED\n"
161 <<
" center CDATA #IMPLIED repeat CDATA #IMPLIED>\n"
162 <<
"<!ELEMENT Bins (BinLabel)* >\n"
163 <<
"<!ATTLIST Bins nbin CDATA #REQUIRED>\n"
164 <<
"<!ELEMENT BinLabel EMPTY>\n"
165 <<
"<!ATTLIST BinLabel index CDATA #REQUIRED name CDATA #REQUIRED>\n";
197 node=node->GetNextNode()) {
200 node->GetAttributes()) {
202 TIterator *i=node->GetAttributes()->MakeIterator();
231 const char *
name=
nullptr;
241 if(!
attName.CompareTo(
"name")) {
244 if(!
attName.CompareTo(
"factor")) {
258 if(
child->GetAttributes()) {
259 i=
child->GetAttributes()->MakeIterator();
262 if(!
attName.CompareTo(
"nbin")) {
274 i=
binName->GetAttributes()->MakeIterator();
279 if(!
attName.CompareTo(
"index")) {
282 if(!
attName.CompareTo(
"name")) {
322 i=
child->GetAttributes()->MakeIterator();
325 if(!
attName.CompareTo(
"length")) {
330 if(
length==
r->GetDistributionNumberOfBins()) {
342 child->Error(
"ImportXMLNode",
"while reading per-bin factors"
343 " node=%s length=%d (expected %d)",
r->GetName(),
344 length,
r->GetDistributionNumberOfBins());
346 child->Error(
"ImportXMLNode",
"while reading per-bin factors"
347 " TUnfoldBinning=%s expected %d found %d",
363 child->GetAttributes()) {
394 if(!
attName.CompareTo(
"name")) {
397 if(!
attName.CompareTo(
"lowEdge")) {
411 i=
child->GetAttributes()->MakeIterator();
415 if(!
attName.CompareTo(
"location")) {
419 if(!
attName.CompareTo(
"repeat")) {
425 "attribute repeat=%d changed to repeat=1",
430 node->
Error(
"AddAxisXML",
431 "underflow/overflow can not have repeat!=1 attribute");
441 i=
child->GetAttributes()->MakeIterator();
444 if(!
attName.CompareTo(
"width")) {
449 node->
Error(
"AddAxisXML",
450 "bin withd can not be smaller than zero");
484 out<<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
485 <<
"<!DOCTYPE TUnfoldBinning SYSTEM \"tunfoldbinning.dtd\">\n"
486 <<
"<TUnfoldBinning>\n";
489 out<<
trailer<<
"<BinningNode name=\""<<binning.
GetName()<<
"\" firstbin=\""
495 out<<
trailer<<
" <Binfactorlist length=\""
498 if(!(i % 10)) out<<
trailer<<
" ";
503 out<<
trailer<<
" </Binfactorlist>\n";
511 out<<
trailer<<
" <BinLabel index=\""<<i<<
"\" name=\""
512 <<
name->GetString()<<
"\" />\n";
520 <<
"\" lowEdge=\""<<(*edges)[0]<<
"\">\n";
522 out<<
axisTrailer<<
" <Bin location=\"underflow\" width=\""
530 for(
Int_t j=i+1;
j<edges->GetNrows()-1;
j++) {
543 <<
width<<
"\" center=\""<<center<<
"\" />\n";
546 <<
"\" width=\""<<
width<<
"\" center=\""<<center<<
"\" />\n";
551 out<<
axisTrailer<<
" <Bin location=\"overflow\" width=\""
565 out<<
trailer<<
"</BinningNode>\n";
567 out<<
"</TUnfoldBinning>\n";
569 return out.fail() ? 0 : 1;
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 TPoint TPoint const char text
TVectorT< Double_t > TVectorD
Array of doubles (64 bits per element).
void Set(Int_t n) override
Set size of this array to n doubles.
const Double_t * GetArray() const
Iterator abstract base class.
virtual TObject * Next()=0
TIterator * MakeIterator(Bool_t dir=kIterForward) const override
Return a list iterator.
const char * GetName() const override
Returns name of object.
Collectable string class.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Int_t Atoi() const
Return integer value of string.
Double_t Atof() const
Return floating-point value contained in string.
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
TXMLAttribute is the attribute of an Element.
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.
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
const char * GetNodeName() const
Returns the node's name.
EXMLElementType GetNodeType() const
Returns the node's type.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.