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";
202 node->GetAttributes()) {
204 TIterator *i=node->GetAttributes()->MakeIterator();
238 const char *binNames=0;
255 child=child->GetNextNode()) {
261 if(child->GetAttributes()) {
262 i=child->GetAttributes()->MakeIterator();
274 binName=binName->GetNextNode()) {
277 i=binName->GetAttributes()->MakeIterator();
278 const char *binLabelName=0;
289 if((index>=0)&&(binLabelName)) {
299 if(theBinNames.
At(ii)) {
300 for(
Int_t k=0;k<emptyName;k++) binNameList+=
";";
307 if(binNameList.
Length()>0) {
308 binNames=binNameList;
320 child=child->GetNextNode()) {
325 i=child->GetAttributes()->MakeIterator();
333 if(length==
r->GetDistributionNumberOfBins()) {
335 const char *
text=child->GetText();
337 stringstream readFactors(
text);
338 for(;nread<length;nread++) {
339 readFactors>> (*perBinFactors)(nread);
340 if(readFactors.fail())
break;
345 child->Error(
"ImportXMLNode",
"while reading per-bin factors"
346 " node=%s length=%d (expected %d)",
r->
GetName(),
347 length,
r->GetDistributionNumberOfBins());
348 }
else if(nread!=length) {
349 child->Error(
"ImportXMLNode",
"while reading per-bin factors"
350 " TUnfoldBinning=%s expected %d found %d",
352 delete perBinFactors;
359 r->SetBinFactor(factor,perBinFactors);
366 child->GetAttributes()) {
368 r->AddBinning(childBinning);
385 child=child->GetNextNode()) {
387 TString nodeName(child->GetNodeName());
388 if(!nodeName.
CompareTo(
"Axis")) axis=child;
392 const char *axisName=0;
408 child=child->GetNextNode()) {
410 TString nodeName(child->GetNodeName());
415 i=child->GetAttributes()->MakeIterator();
420 isUnderflow= !attText.
CompareTo(
"underflow");
421 isOverflow= !attText.
CompareTo(
"overflow");
424 repeat=attText.
Atof();
429 "attribute repeat=%d changed to repeat=1",
433 if((isUnderflow || isOverflow)&&(repeat!=1)) {
434 node->
Error(
"AddAxisXML",
435 "underflow/overflow can not have repeat!=1 attribute");
437 if(isUnderflow || isOverflow) {
438 underflow |= isUnderflow;
439 overflow |= isOverflow;
442 Int_t iBin1=iBin0+repeat;
445 i=child->GetAttributes()->MakeIterator();
453 node->
Error(
"AddAxisXML",
454 "bin width can not be smaller than zero");
456 for(
int iBin=iBin0;iBin<iBin1;iBin++) {
457 binEdges[iBin]=binEdges[iBin0-1]+(iBin-iBin0+1)*binWidth;
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";
518 out<<trailer<<
" </Bins>\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++) {
535 double xEnd=(j-i+1)*
width+(*edges)[i];
536 double xCent=center+(j-i)*
width;
546 out<<axisTrailer<<
" <Bin width=\""
547 <<
width<<
"\" center=\""<<center<<
"\" />\n";
549 out<<axisTrailer<<
" <Bin repeat=\""<<repeat
550 <<
"\" width=\""<<
width<<
"\" center=\""<<center<<
"\" />\n";
555 out<<axisTrailer<<
" <Bin location=\"overflow\" width=\""
562 out<<axisTrailer<<
"</Axis>\n";
566 child=child->GetNextNode()) {
569 out<<trailer<<
"</BinningNode>\n";
571 out<<
"</TUnfoldBinning>\n";
573 return out.fail() ? 0 : 1;
587 ofstream outFile(fileName);
void writeHeader(THtml &html, ostream &out, const char *title, const char *relPath="../")
static void indent(ostringstream &buf, int indent_level)
include TDocParser_001 C image html pict1_TDocParser_001 png width
TVectorT< Double_t > TVectorD
Array of doubles (64 bits per element).
void Set(Int_t n)
Set size of this array to n doubles.
const Double_t * GetArray() const
Iterator abstract base class.
virtual TObject * Next()=0
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntriesFast() const
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
TObject * At(Int_t idx) const
Collectable string class.
virtual const char * GetName() const
Returns name of object.
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.
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.
const char * GetValue() const
const char * GetName() const
Returns name of object.
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 * GetNextNode()
Returns the next sibling XMLNode in the DOM tree, if any return 0 if no next node.
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.