136using std::ofstream, std::stringstream;
150 <<
"<!ELEMENT TUnfoldBinning (BinningNode)+ >\n"
151 <<
"<!ELEMENT BinningNode (BinningNode+|(Binfactorlist?,Axis)|Bins) >\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";
199 node=node->GetNextNode()) {
202 node->GetAttributes()) {
204 TIter i = node->GetAttributes()->MakeIterator();
234 const char *
name=
nullptr;
244 if(!
attName.CompareTo(
"name")) {
247 if(!
attName.CompareTo(
"factor")) {
261 if(
child->GetAttributes()) {
265 if(!
attName.CompareTo(
"nbin")) {
282 if(!
attName.CompareTo(
"index")) {
285 if(!
attName.CompareTo(
"name")) {
328 if(!
attName.CompareTo(
"length")) {
333 if(
length==
r->GetDistributionNumberOfBins()) {
345 child->Error(
"ImportXMLNode",
"while reading per-bin factors"
346 " node=%s length=%d (expected %d)",
r->GetName(),
347 length,
r->GetDistributionNumberOfBins());
349 child->Error(
"ImportXMLNode",
"while reading per-bin factors"
350 " TUnfoldBinning=%s expected %d found %d",
366 child->GetAttributes()) {
398 if(!
attName.CompareTo(
"name")) {
401 if(!
attName.CompareTo(
"lowEdge")) {
419 if(!
attName.CompareTo(
"location")) {
423 if(!
attName.CompareTo(
"repeat")) {
429 "attribute repeat=%d changed to repeat=1",
434 node->
Error(
"AddAxisXML",
435 "underflow/overflow can not have repeat!=1 attribute");
448 if(!
attName.CompareTo(
"width")) {
453 node->
Error(
"AddAxisXML",
454 "bin width can not be smaller than zero");
488 out<<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
489 <<
"<!DOCTYPE TUnfoldBinning SYSTEM \"tunfoldbinning.dtd\">\n"
490 <<
"<TUnfoldBinning>\n";
493 out<<
trailer<<
"<BinningNode name=\""<<binning.
GetName()<<
"\" firstbin=\""
499 out<<
trailer<<
" <Binfactorlist length=\""
502 if(!(i % 10)) out<<
trailer<<
" ";
507 out<<
trailer<<
" </Binfactorlist>\n";
515 out<<
trailer<<
" <BinLabel index=\""<<i<<
"\" name=\""
516 <<
name->GetString()<<
"\" />\n";
524 <<
"\" lowEdge=\""<<(*edges)[0]<<
"\">\n";
526 out<<
axisTrailer<<
" <Bin location=\"underflow\" width=\""
534 for(
Int_t j=i+1;
j<edges->GetNrows()-1;
j++) {
547 <<
width<<
"\" center=\""<<center<<
"\" />\n";
550 <<
"\" width=\""<<
width<<
"\" center=\""<<center<<
"\" />\n";
555 out<<
axisTrailer<<
" <Bin location=\"overflow\" width=\""
569 out<<
trailer<<
"</BinningNode>\n";
571 out<<
"</TUnfoldBinning>\n";
573 return out.fail() ? 0 : 1;
void writeHeader(THtml &html, ostream &out, const char *title, const char *relPath="../")
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
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.