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";
195 if(root && (!TString(root->
GetNodeName()).CompareTo(
"TUnfoldBinning")) &&
201 !TString(node->GetNodeName()).CompareTo(
"BinningNode") &&
202 node->GetAttributes()) {
204 TIterator *i=node->GetAttributes()->MakeIterator();
207 if((!TString(attr->
GetName()).CompareTo(
"name")) &&
208 ((!TString(attr->
GetValue()).CompareTo(name)) ||
218 r=ImportXMLNode(binningNode);
238 const char *binNames=0;
243 TString attName(attr->
GetName());
244 if(!attName.CompareTo(
"name")) {
247 if(!attName.CompareTo(
"factor")) {
248 factor=TString(attr->
GetValue()).Atof();
252 TString binNameList=
"";
258 !TString(child->GetNodeName()).CompareTo(
"Bins")) {
261 if(child->GetAttributes()) {
262 i=child->GetAttributes()->MakeIterator();
264 TString attName(attr->
GetName());
265 if(!attName.CompareTo(
"nbin")) {
267 nBins=TString(attr->
GetValue()).Atoi();
276 !TString(binName->GetNodeName()).CompareTo(
"BinLabel")) {
277 i=binName->GetAttributes()->MakeIterator();
278 const char *binLabelName=0;
281 TString attName(attr->
GetName());
282 if(!attName.CompareTo(
"index")) {
283 index=TString(attr->
GetValue()).Atoi();
285 if(!attName.CompareTo(
"name")) {
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;
323 !TString(child->GetNodeName()).CompareTo(
"Binfactorlist")) {
325 i=child->GetAttributes()->MakeIterator();
327 TString attName(attr->
GetName());
328 if(!attName.CompareTo(
"length")) {
329 length=TString(attr->
GetValue()).Atoi();
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(),
348 }
else if(nread!=length) {
349 child->Error(
"ImportXMLNode",
"while reading per-bin factors" 350 " TUnfoldBinning=%s expected %d found %d",
352 delete perBinFactors;
365 !TString(child->GetNodeName()).CompareTo(
"BinningNode") &&
366 child->GetAttributes()) {
387 TString nodeName(child->GetNodeName());
388 if(!nodeName.CompareTo(
"Axis")) axis=child;
392 const char *axisName=0;
397 TString attName(attr->
GetName());
398 if(!attName.CompareTo(
"name")) {
401 if(!attName.CompareTo(
"lowEdge")) {
402 binEdges[0]=TString(attr->
GetValue()).Atof();
410 TString nodeName(child->GetNodeName());
411 if(!nodeName.CompareTo(
"Axis")) hasMoreAxes=
kTRUE;
412 if(!nodeName.CompareTo(
"Bin")) {
415 i=child->GetAttributes()->MakeIterator();
417 TString attName(attr->
GetName());
419 if(!attName.CompareTo(
"location")) {
420 isUnderflow= !attText.CompareTo(
"underflow");
421 isOverflow= !attText.CompareTo(
"overflow");
423 if(!attName.CompareTo(
"repeat")) {
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();
447 TString attName(attr->
GetName());
448 if(!attName.CompareTo(
"width")) {
449 binWidth=TString(attr->
GetValue()).Atof();
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";
492 TString trailer(
' ',indent);
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=\"" 518 out<<trailer<<
" </Bins>\n";
521 TString axisTrailer(
' ',indent+1+axis);
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=\"" 561 TString axisTrailer(
' ',indent+1+axis);
562 out<<axisTrailer<<
"</Axis>\n";
569 out<<trailer<<
"</BinningNode>\n";
571 out<<
"</TUnfoldBinning>\n";
573 return out.fail() ? 0 : 1;
587 ofstream outFile(fileName);
virtual const char * GetName() const
Returns name of object.
const TObjString * GetUnconnectedBinName(Int_t bin) const
Return the bin names of unconnected bins.
TUnfoldBinning const * GetChildNode(void) const
first daughter node
virtual Double_t GetDistributionBinCenter(Int_t axis, Int_t bin) const
return bin center for a given axis and bin number
Bool_t HasOverflow(int axis) const
check whether the axis has an overflow bin
Collectable string class.
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
const Double_t * GetArray() const
const char * GetValue() const
void AddAxisXML(TXMLNode *node)
Import axis from XML node.
void SetBinFactor(Double_t normalisation, TObject *factors)
Set normalisation factors which are used in calls to GetBinFactor().
XML interfate to binning schemes, for use with the unfolding algorithm TUnfoldDensity.
TObject * At(Int_t idx) const
Iterator abstract base class.
TUnfoldBinning const * GetNextNode(void) const
next sister node
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
static TUnfoldBinningXML * ImportXMLNode(TXMLNode *node)
Recursively import one node from the XML tree.
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.
Double_t GetGlobalFactor(void) const
Return global scaling factor for this node.
Int_t GetStartBin(void) const
first bin of this node
TVectorT< Double_t > TVectorD
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
TVectorD const * GetDistributionBinning(Int_t axis) const
get vector of bin borders for one axis
Int_t GetDistributionDimension(void) const
query dimension of this node's distribution
TXMLNode * GetNextNode()
Returns the next sibling XMLNode in the DOM tree, if any return 0 if no next node.
const TString & GetString() const
void writeHeader(THtml &html, ostream &out, const char *title, const char *relPath="../")
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
virtual Double_t GetDistributionUnderflowBinWidth(Int_t axis) const
Return bin width assigned to the underflow bin.
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
Int_t GetEntriesFast() const
virtual Bool_t IsBinFactorGlobal(void) const
Check whether there is only a global scaling factor for this node.
static TUnfoldBinningXML * ImportXML(const TXMLDocument *document, const char *name)
Import a binning scheme from an XML file.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static const char * GetTUnfoldVersion(void)
Return a string describing the TUnfold version.
TXMLAttribute is the attribute of an Element.
Bool_t HasUnderflow(int axis) const
check whether an axis has an underflow bin
constexpr Double_t E()
Base of natural log: .
const char * GetName() const
Returns name of object.
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
TString GetDistributionAxisLabel(Int_t axis) const
get name of an axis
static void WriteDTD(const char *fileName="tunfoldbinning.dtd")
Write dtd file.
TXMLNode * GetRootNode() const
Returns the root element node.
Int_t GetDistributionNumberOfBins(void) const
number of bins in the distribution possibly including under/overflow
Array of doubles (64 bits per element).
Bool_t HasUnconnectedBins(void) const
Check whether there are bins but no axis.
virtual Double_t GetDistributionOverflowBinWidth(Int_t axis) const
Return bin width assigned to the overflow bin.
virtual TObject * Next()=0
EXMLElementType GetNodeType() const
Returns the node's type.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
TUnfoldBinning * AddBinning(TUnfoldBinning *binning)
Add a TUnfoldBinning as the last child of this node.
void Set(Int_t n)
Set size of this array to n doubles.
const char * GetNodeName() const
Returns the node's name.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Double_t GetBinFactor(Int_t iBin) const
Return scaling factor for the given global bin number.