36using std::string, std::vector;
40 void AddSubStrings( vector<std::string> & vs, std::string s){
41 const std::string delims(
"\\ ");
42 std::string::size_type begIdx;
43 std::string::size_type endIdx;
44 begIdx=s.find_first_not_of(delims);
45 while(begIdx!=string::npos){
46 endIdx=s.find_first_of(delims, begIdx);
47 if(endIdx==string::npos) endIdx=s.length();
48 vs.push_back(s.substr(begIdx,endIdx-begIdx));
49 begIdx=s.find_first_not_of(delims, endIdx);
55 std::vector<std::string> GetChildrenFromString( std::string str ) {
57 std::vector<std::string> child_vec;
59 const std::string delims(
"\\ ");
60 std::string::size_type begIdx;
61 std::string::size_type endIdx;
62 begIdx=str.find_first_not_of(delims);
63 while(begIdx!=string::npos){
64 endIdx=str.find_first_of(delims, begIdx);
65 if(endIdx==string::npos) endIdx=str.length();
66 std::string child_name = str.substr(begIdx,endIdx-begIdx);
67 child_vec.push_back(child_name);
68 begIdx=str.find_first_not_of(delims, endIdx);
80 std::vector<std::string> string_list = GetChildrenFromString( str );
85 for(
unsigned int i=0; i < string_list.size(); ++i) {
87 std::string param = string_list.at(i);
89 size_t eql_location = param.find(
'=');
93 if( eql_location==string::npos ) {
98 std::string param_name = param.substr(0,eql_location);
99 double param_val =
toDouble(param.substr(eql_location + 1, param.size()));
101 std::cout <<
"ASIMOV - Param Name: " << param_name
102 <<
" Param Val: " << param_val << std::endl;
125 std::vector< HistFactory::Measurement > measurement_list;
129 Int_t parseError = xmlparser.ParseFile(
input.c_str() );
131 std::cerr <<
"Loading of xml document \"" <<
input
132 <<
"\" failed" << std::endl;
140 TXMLNode* rootNode = xmldoc->GetRootNode();
145 cxcoutEHF <<
"Error: Driver DOCTYPE not equal to 'Combination'" << std::endl;
150 std::string OutputFilePrefix;
154 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
157 TString attrName = curAttr->GetName();
159 if( attrName ==
TString(
"" ) ) {
160 cxcoutEHF <<
" Error: Attribute for 'Combination' with no name found" << std::endl;
164 else if( attrName ==
TString(
"OutputFilePrefix" ) ) {
165 OutputFilePrefix = string(curAttr->GetValue());
166 cxcoutIHF <<
"output file prefix is : " << OutputFilePrefix << std::endl;
176 cxcoutEHF <<
" Error: Unknown attribute for 'Combination' encountered: "
177 << attrName << std::endl;
190 std::vector< std::string > xml_channel_files;
192 while( node !=
nullptr ) {
194 if( node->
GetText() ==
nullptr ) {
196 <<
" has no text." << std::endl;
199 xml_channel_files.push_back(node->
GetText());
205 if(xml_channel_files.empty()){
206 std::cerr <<
"no input channels found" << std::endl;
211 std::ostringstream msg;
212 msg <<
"Found Channels: ";
213 for(
unsigned int i=0; i < xml_channel_files.size(); ++i ) msg <<
" " << xml_channel_files.at(i);
226 std::vector< RooStats::HistFactory::PreprocessFunction > functionObjects;
229 while( node !=
nullptr ) {
236 functionObjects.push_back( Func );
241 std::cout << std::endl;
246 while( node !=
nullptr ) {
249 cxcoutEHF <<
"Error: Node found in Measurement Driver XML with no name" << std::endl;
256 measurement.SetOutputFilePrefix( OutputFilePrefix );
257 measurement_list.push_back( measurement );
273 cxcoutEHF <<
"Error: Unknown node found in Measurement Driver XML: "
281 cxcoutIHF <<
"Done Processing Measurements" << std::endl;
283 if( measurement_list.empty() ) {
284 cxcoutEHF <<
"Error: No Measurements found in XML Driver File" << std::endl;
288 std::ostringstream msg;
289 msg <<
"Found Measurements: ";
290 for(
unsigned int i=0; i < measurement_list.size(); ++i ) msg <<
" " << measurement_list.at(i).GetName();
300 for(
unsigned int i = 0; i < measurement_list.size(); ++i) {
301 measurement_list.at(i).SetFunctionObjects( functionObjects );
311 std::vector< HistFactory::Channel > channel_list;
314 for(
unsigned int i = 0; i < xml_channel_files.size(); ++i ) {
315 std::string channel_xml = xml_channel_files.at(i);
316 cxcoutIHF <<
"Parsing Channel: " << channel_xml << std::endl;
322 channel_list.push_back( channel );
326 for(
unsigned int i = 0; i < measurement_list.size(); ++i) {
330 for(
unsigned int j = 0; j < channel_list.size(); ++j ) {
331 measurement.
GetChannels().push_back( channel_list.at(j) );
335 return measurement_list;
345 if (node ==
nullptr) {
346 cxcoutWHF <<
"Input driver node is undefined, ignoring\n";
352 measurement.SetLumiRelErr(.10);
353 measurement.SetBinLow(0);
354 measurement.SetBinHigh(1);
356 cxcoutIHF <<
"Creating new measurement:\n";
361 while (( curAttr =
dynamic_cast<TXMLAttr *
>(attribIt()) ) !=
nullptr) {
363 const std::string curAttrName(curAttr->GetName() ? curAttr->GetName() :
"");
364 const std::string curAttrValue(curAttr->GetValue() ? curAttr->GetValue() :
"");
365 if (curAttrName.empty()) {
366 cxcoutEHF <<
"Found XML attribute in Measurement with no name.\n";
369 }
else if (curAttrName ==
"Name") {
370 measurement.SetName(curAttrValue.c_str());
371 }
else if (curAttrName ==
"Lumi") {
372 measurement.SetLumi(
toDouble(curAttrValue));
373 }
else if (curAttrName ==
"LumiRelErr") {
374 measurement.SetLumiRelErr(
toDouble(curAttrValue));
375 }
else if (curAttrName ==
"BinLow") {
376 measurement.SetBinLow(std::stoi(curAttrValue));
377 }
else if (curAttrName ==
"BinHigh") {
378 measurement.SetBinHigh(std::stoi(curAttrValue));
379 }
else if (curAttrName ==
"Mode") {
380 std::cout <<
"\n INFO: Mode attribute is deprecated and no longer supported, will ignore\n";
381 }
else if (curAttrName ==
"ExportOnly") {
383 cxcoutIHF <<
"The \"ExportOnly\" attribute is ignored it is always \"true\" for any Measurement." << std::endl;
385 cxcoutEHF <<
"Found unknown XML attribute in Measurement: " << curAttrName <<
"\n";
392 while (
child !=
nullptr) {
393 const std::string childName(
child->GetName() ?
child->GetName() :
"");
394 const std::string childNodeName(
child->GetNodeName() ?
child->GetNodeName() :
"");
395 const std::string childText(
child->GetText() ?
child->GetText() :
"");
396 if (childNodeName.empty()) {
397 cxcoutEHF <<
"Found XML child node of Measurement with no name\n";
399 }
else if (childNodeName ==
"POI") {
400 if (childText.empty()) {
401 cxcoutEHF <<
"Error: node: " << childName <<
" has no text.\n";
405 AddSubStrings(measurement.GetPOIList(), childText);
406 }
else if (childNodeName ==
"ParamSetting") {
409 while (( curParam =
dynamic_cast<TXMLAttr *
>(paramIt()) ) !=
nullptr) {
411 const std::string curParamName(curParam->GetName() ? curParam->GetName() :
"");
412 if (curParamName.empty()) {
413 cxcoutEHF <<
"Error: Found tag attribute with no name in ParamSetting\n";
415 }
else if (curParamName ==
"Const") {
416 if (curParam->GetValue() ==
TString(
"True")) {
418 if (childText.empty()) {
419 cxcoutEHF <<
"Error: node: " << childName <<
" has no text.\n";
422 AddSubStrings(measurement.GetConstantParams(), childText);
424 }
else if (curParamName ==
"Val") {
425 double val =
toDouble(curParam->GetValue());
426 if (childText.empty()) {
427 cxcoutEHF <<
"Error: node: " << childName <<
" has no text.\n";
430 std::vector<std::string> child_nodes = GetChildrenFromString(childText);
431 for (
size_t i = 0; i < child_nodes.size(); ++i) {
432 measurement.SetParamValue(child_nodes.at(i), val);
435 cxcoutEHF <<
"Found tag attribute with unknown name in ParamSetting: " << curParamName <<
"\n";
439 }
else if (childNodeName ==
"Asimov") {
443 std::string ParamFixString;
446 attribIt =
child->GetAttributes();
448 while (( curAttr =
dynamic_cast<TXMLAttr *
>(attribIt()) ) !=
nullptr) {
449 const std::string curAttrName(curAttr->GetName() ? curAttr->GetName() :
"");
450 const std::string curAttrValue(curAttr->GetValue() ? curAttr->GetValue() :
"");
451 if (curAttrName.empty()) {
452 cxcoutEHF <<
"Error: Found tag attribute with no name in ConstraintTerm\n";
454 }
else if (curAttrName ==
"Name") {
456 }
else if (curAttrName ==
"FixParams") {
457 ParamFixString = curAttrValue;
459 cxcoutEHF <<
"Found tag attribute with unknown name in ConstraintTerm: " << curAttrName <<
"\n";
466 if (ParamFixString.empty()) {
468 <<
" added, but no parameters are set to be fixed\n";
470 AddParamsToAsimov(asimov, ParamFixString);
472 measurement.AddAsimovDataset(asimov);
473 }
else if (childNodeName ==
"ConstraintTerm") {
474 std::vector<string> syst;
479 if (childText.empty()) {
480 cxcoutEHF <<
"Error: node: " << childName <<
" has no text\n";
483 AddSubStrings(syst, childText);
486 attribIt =
child->GetAttributes();
488 while (( curAttr =
dynamic_cast<TXMLAttr *
>(attribIt()) ) !=
nullptr) {
489 const std::string curAttrName(curAttr->GetName() ? curAttr->GetName() :
"");
490 const std::string curAttrValue(curAttr->GetValue() ? curAttr->GetValue() :
"");
491 if (curAttrName.empty()) {
492 cxcoutEHF <<
"Error: Found tag attribute with no name in ConstraintTerm\n";
494 }
else if (curAttrName ==
"Type") {
496 }
else if (curAttrName ==
"RelativeUncertainty") {
499 cxcoutEHF <<
"Found tag attribute with unknown name in ConstraintTerm: " << curAttrName <<
"\n";
506 if (
type ==
"Gamma") {
507 for (
const auto &isyst : syst) {
509 measurement.GetGammaSyst()[isyst] = rel;
511 }
else if (
type ==
"Uniform") {
512 for (
const auto &isyst : syst) {
514 measurement.GetUniformSyst()[isyst] = rel;
516 }
else if (
type ==
"LogNormal") {
517 for (
const auto &isyst : syst) {
519 measurement.GetLogNormSyst()[isyst] = rel;
522 }
else if (
type ==
"NoConstraint") {
523 for (
const auto &isyst : syst) {
525 measurement.GetNoSyst()[isyst] = 1.0;
529 cxcoutEHF <<
"Error: Encountered unknown type for ConstraintTerm: " <<
type <<
"\n";
536 cxcoutEHF <<
"Found XML child of Measurement with unknown name: " << childNodeName <<
"\n";
542 measurement.PrintTree(
oocoutI(
nullptr, HistFactory));
555 cxcoutIHF <<
"Parsing file: " << filen << std::endl;
560 Int_t parseError = xmlparser.ParseFile( filen.c_str() );
562 cxcoutEHF <<
"Loading of xml document \"" << filen
563 <<
"\" failed" << std::endl;
568 TXMLNode* rootNode = xmldoc->GetRootNode();
573 cxcoutEHF <<
"Error: In parsing a Channel XML, "
574 <<
"Encountered XML with DOCTYPE: " << rootNode->
GetNodeName()
576 cxcoutEHF <<
" DOCTYPE for channels must be 'Channel' "
577 <<
" Check that your XML is properly written" << std::endl;
595 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
598 TString attrName = curAttr->GetName();
599 std::string attrVal = curAttr->GetValue();
601 if( attrName ==
TString(
"" ) ) {
602 cxcoutEHF <<
" Error: Attribute for 'Channel' with no name found" << std::endl;
606 else if( attrName ==
TString(
"Name" ) ) {
608 cxcoutIHF <<
" : creating a channel named " << channel.
GetName() << std::endl;
611 else if( attrName ==
TString(
"InputFile" ) ) {
612 cxcoutIHF <<
"Setting InputFile for this channel: " << attrVal << std::endl;
618 else if( curAttr->GetName() ==
TString(
"HistoPath" ) ) {
619 cxcoutIHF <<
"Setting HistoPath for this channel: " << attrVal << std::endl;
625 else if( curAttr->GetName() ==
TString(
"HistoName" ) ) {
627 cxcoutEHF <<
"Use of HistoName in Channel is deprecated" << std::endl;
628 cxcoutEHF <<
"This will be ignored" << std::endl;
632 cxcoutEHF <<
" Error: Unknown attribute for 'Channel' encountered: "
633 << attrName << std::endl;
641 if( channel.
GetName().empty() ) {
642 cxcoutEHF <<
"Error: Channel created with no name" << std::endl;
655 while( node !=
nullptr ) {
662 cxcoutEHF <<
"Error: Encountered node in Channel with no name" << std::endl;
669 if( !
data.GetName().empty() ) {
670 cxcoutEHF <<
"Error: You can only rename the datasets of additional data sets. "
671 <<
" Remove the 'Name=" <<
data.GetName() <<
"' tag"
672 <<
" from channel: " << channel.
GetName() << std::endl;
694 cxcoutEHF <<
"Error: Encountered node in Channel with unknown name: " << node->
GetNodeName() << std::endl;
702 cxcoutIHF <<
"Created Channel: " << std::endl;
713 cxcoutIHF <<
"Creating Data Element" << std::endl;
725 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
728 TString attrName = curAttr->GetName();
729 std::string attrVal = curAttr->GetValue();
731 if( attrName ==
TString(
"" ) ) {
732 cxcoutEHF <<
" Error: Attribute for 'Data' with no name found" << std::endl;
736 else if( attrName ==
TString(
"Name" ) ) {
737 data.SetName( attrVal );
740 else if( attrName ==
TString(
"InputFile" ) ) {
741 data.SetInputFile( attrVal );
744 else if( attrName ==
TString(
"HistoName" ) ) {
745 data.SetHistoName( attrVal );
748 else if( attrName ==
TString(
"HistoPath" ) ) {
749 data.SetHistoPath( attrVal );
755 cxcoutEHF <<
" Error: Unknown attribute for 'Data' encountered: " << attrName << std::endl;
762 if(
data.GetInputFile().empty() ) {
763 cxcoutEHF <<
"Error: Data Node has no InputFile" << std::endl;
766 if(
data.GetHistoName().empty() ) {
767 cxcoutEHF <<
"Error: Data Node has no HistoName" << std::endl;
772 <<
" InputFile: " <<
data.GetInputFile()
773 <<
" HistoName: " <<
data.GetHistoName()
774 <<
" HistoPath: " <<
data.GetHistoPath()
775 << (!
data.GetName().empty() ?
" Name: " :
"") <<
data.GetName() << std::endl;
786 cxcoutIHF <<
"Creating StatErrorConfig Element" << std::endl;
797 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
800 TString attrName = curAttr->GetName();
801 std::string attrVal = curAttr->GetValue();
803 if( attrName ==
TString(
"RelErrorThreshold" ) ) {
807 if( attrName ==
TString(
"ConstraintType" ) ) {
810 if( attrVal.empty() ) {
811 cxcoutEHF <<
"Error: Bad Value for StatErrorConfig Constraint Type Found" << std::endl;
815 else if( attrVal==
"Gaussian" || attrVal==
"Gauss" ) {
819 else if( attrVal==
"Poisson" || attrVal==
"Pois" ) {
826 std::cout <<
"Invalid Stat Constraint Type: " << curAttr->GetValue() << std::endl;
832 cxcoutIHF <<
"Created StatErrorConfig Element with"
844 cxcoutIHF <<
"Creating Sample Element" << std::endl;
852 sample.SetNormalizeByTheory(
true );
859 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
862 TString attrName = curAttr->GetName();
863 std::string attrVal = curAttr->GetValue();
865 if( attrName ==
TString(
"" ) ) {
866 cxcoutEHF <<
" Error: Attribute for 'Sample' with no name found" << std::endl;
870 else if( attrName ==
TString(
"Name" ) ) {
871 sample.SetName( attrVal );
874 else if( attrName ==
TString(
"InputFile" ) ) {
875 sample.SetInputFile( attrVal );
879 else if( attrName ==
TString(
"HistoName" ) ) {
880 sample.SetHistoName( attrVal );
883 else if( attrName ==
TString(
"HistoPath" ) ) {
884 sample.SetHistoPath( attrVal );
888 else if( attrName ==
TString(
"NormalizeByTheory" ) ) {
906 cxcoutEHF <<
" Error: Unknown attribute for 'Sample' encountered: " << attrName << std::endl;
912 if( sample.GetName().empty() ) {
913 cxcoutEHF <<
"Error: Sample Node has no Name" << std::endl;
916 if( sample.GetInputFile().empty() ) {
917 cxcoutEHF <<
"Error: Sample Node has no InputFile" << std::endl;
920 if( sample.GetHistoName().empty() ) {
921 cxcoutEHF <<
"Error: Sample Node has no HistoName" << std::endl;
930 while(
child !=
nullptr ) {
933 cxcoutEHF <<
"Error: Encountered node in Sample with no name" << std::endl;
937 else if(
child->GetNodeName() ==
TString(
"NormFactor" ) ) {
941 else if(
child->GetNodeName() ==
TString(
"OverallSys" ) ) {
945 else if(
child->GetNodeName() ==
TString(
"HistoSys" ) ) {
949 else if(
child->GetNodeName() ==
TString(
"HistoFactor" ) ) {
950 cxcoutEHF <<
"WARNING: HistoFactor not yet supported" << std::endl;
954 else if(
child->GetNodeName() ==
TString(
"ShapeSys" ) ) {
958 else if(
child->GetNodeName() ==
TString(
"ShapeFactor" ) ) {
962 else if(
child->GetNodeName() ==
TString(
"StatError" ) ) {
969 cxcoutEHF <<
"Error: Encountered node in Sample with unknown name: " <<
child->GetNodeName() << std::endl;
977 <<
" Name: " << sample.GetName()
978 <<
" InputFile: " << sample.GetInputFile()
979 <<
" HistoName: " << sample.GetHistoName()
980 <<
" HistoPath: " << sample.GetHistoPath()
991 cxcoutIHF <<
"Making NormFactor:" << std::endl;
997 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1000 TString attrName = curAttr->GetName();
1001 std::string attrVal = curAttr->GetValue();
1003 if( attrName ==
TString(
"" ) ){
1004 cxcoutEHF <<
"Error: Encountered Element in NormFactor with no name" << std::endl;
1008 else if( curAttr->GetName() ==
TString(
"Name" ) ) {
1009 norm.SetName( attrVal );
1011 else if( curAttr->GetName() ==
TString(
"Val" ) ) {
1014 else if( curAttr->GetName() ==
TString(
"Low" ) ) {
1017 else if( curAttr->GetName() ==
TString(
"High" ) ) {
1022 cxcoutEHF <<
"Error: Encountered Element in NormFactor with unknown name: "
1023 << attrName << std::endl;
1029 if( norm.GetName().empty() ) {
1030 cxcoutEHF <<
"Error: NormFactor Node has no Name" << std::endl;
1034 if( norm.GetLow() >= norm.GetHigh() ) {
1035 cxcoutEHF <<
"Error: NormFactor: " << norm.GetName()
1036 <<
" has lower limit >= its upper limit: "
1037 <<
" Lower: " << norm.GetLow()
1038 <<
" Upper: " << norm.GetHigh()
1039 <<
". Please Fix" << std::endl;
1042 if( norm.GetVal() > norm.GetHigh() || norm.GetVal() < norm.GetLow() ) {
1043 cxcoutEHF <<
"Error: NormFactor: " << norm.GetName()
1044 <<
" has initial value not within its range: "
1045 <<
" Val: " << norm.GetVal()
1046 <<
" Lower: " << norm.GetLow()
1047 <<
" Upper: " << norm.GetHigh()
1048 <<
". Please Fix" << std::endl;
1052 norm.Print(
oocoutI(
nullptr, HistFactory));
1060 cxcoutIHF <<
"Making HistoFactor" << std::endl;
1070 cxcoutIHF <<
"Made HistoFactor" << std::endl;
1079 cxcoutIHF <<
"Making HistoSys:" << std::endl;
1100 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1103 TString attrName = curAttr->GetName();
1104 std::string attrVal = curAttr->GetValue();
1106 if( attrName ==
TString(
"" ) ){
1107 cxcoutEHF <<
"Error: Encountered Element in HistoSys with no name" << std::endl;
1111 else if( curAttr->GetName() ==
TString(
"Name" ) ) {
1112 histoSys.SetName( attrVal );
1115 else if( curAttr->GetName() ==
TString(
"HistoFileHigh" ) ) {
1116 histoSys.SetInputFileHigh( attrVal );
1118 else if( curAttr->GetName() ==
TString(
"HistoPathHigh" ) ) {
1119 histoSys.SetHistoPathHigh( attrVal );
1121 else if( curAttr->GetName() ==
TString(
"HistoNameHigh" ) ) {
1122 histoSys.SetHistoNameHigh( attrVal );
1125 else if( curAttr->GetName() ==
TString(
"HistoFileLow" ) ) {
1126 histoSys.SetInputFileLow( attrVal );
1128 else if( curAttr->GetName() ==
TString(
"HistoPathLow" ) ) {
1129 histoSys.SetHistoPathLow( attrVal );
1131 else if( curAttr->GetName() ==
TString(
"HistoNameLow" ) ) {
1132 histoSys.SetHistoNameLow( attrVal );
1136 cxcoutEHF <<
"Error: Encountered Element in HistoSys with unknown name: "
1137 << attrName << std::endl;
1144 if( histoSys.GetName().empty() ) {
1145 cxcoutEHF <<
"Error: HistoSys Node has no Name" << std::endl;
1148 if( histoSys.GetInputFileHigh().empty() ) {
1149 cxcoutEHF <<
"Error: HistoSysSample Node has no InputFileHigh" << std::endl;
1152 if( histoSys.GetInputFileLow().empty() ) {
1153 cxcoutEHF <<
"Error: HistoSysSample Node has no InputFileLow" << std::endl;
1156 if( histoSys.GetHistoNameHigh().empty() ) {
1157 cxcoutEHF <<
"Error: HistoSysSample Node has no HistoNameHigh" << std::endl;
1160 if( histoSys.GetHistoNameLow().empty() ) {
1161 cxcoutEHF <<
"Error: HistoSysSample Node has no HistoNameLow" << std::endl;
1166 histoSys.Print(
oocoutI(
nullptr, HistFactory));
1175 cxcoutIHF <<
"Making OverallSys:" << std::endl;
1181 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1184 TString attrName = curAttr->GetName();
1185 std::string attrVal = curAttr->GetValue();
1187 if( attrName ==
TString(
"" ) ){
1188 cxcoutEHF <<
"Error: Encountered Element in OverallSys with no name" << std::endl;
1192 else if( attrName ==
TString(
"Name" ) ) {
1193 overallSys.SetName( attrVal );
1195 else if( attrName ==
TString(
"High" ) ) {
1196 overallSys.SetHigh(
toDouble(attrVal));
1198 else if( attrName ==
TString(
"Low" ) ) {
1199 overallSys.SetLow(
toDouble(attrVal));
1203 cxcoutEHF <<
"Error: Encountered Element in OverallSys with unknown name: "
1204 << attrName << std::endl;
1210 if( overallSys.GetName().empty() ) {
1211 cxcoutEHF <<
"Error: Encountered OverallSys with no name" << std::endl;
1216 overallSys.Print(
oocoutI(
nullptr, HistFactory));
1225 cxcoutIHF <<
"Making ShapeFactor" << std::endl;
1239 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1242 TString attrName = curAttr->GetName();
1243 std::string attrVal = curAttr->GetValue();
1245 if( attrName ==
TString(
"" ) ){
1246 cxcoutEHF <<
"Error: Encountered Element in ShapeFactor with no name" << std::endl;
1250 else if( attrName ==
TString(
"Name" ) ) {
1251 shapeFactor.SetName( attrVal );
1252 }
else if (attrName ==
TString(
"Val")) {
1253 shapeFactor.SetVal(
toDouble(attrVal));
1254 }
else if (attrName ==
TString(
"Low")) {
1255 shapeFactor.SetLow(
toDouble(attrVal));
1256 }
else if (attrName ==
TString(
"High")) {
1257 shapeFactor.SetHigh(
toDouble(attrVal));
1258 }
else if (attrName ==
TString(
"Const")) {
1262 else if (attrName ==
TString(
"HistoName")) {
1263 shapeFactor.SetHistoName(attrVal);
1266 else if (attrName ==
TString(
"InputFile")) {
1267 ShapeInputFile = attrVal;
1270 else if (attrName ==
TString(
"HistoPath")) {
1271 ShapeInputPath = attrVal;
1275 cxcoutEHF <<
"Error: Encountered Element in ShapeFactor with unknown name: " << attrName << std::endl;
1280 if( shapeFactor.GetName().empty() ) {
1281 cxcoutEHF <<
"Error: Encountered ShapeFactor with no name" << std::endl;
1287 if( shapeFactor.HasInitialShape() ) {
1288 if( shapeFactor.GetHistoName().empty() ) {
1289 cxcoutEHF <<
"Error: ShapeFactor: " << shapeFactor.GetName()
1290 <<
" is configured to have an initial shape, but "
1291 <<
"its histogram doesn't have a name"
1295 shapeFactor.SetHistoPath( ShapeInputPath );
1296 shapeFactor.SetInputFile( ShapeInputFile );
1299 shapeFactor.Print(
oocoutI(
nullptr, HistFactory));
1308 cxcoutIHF <<
"Making ShapeSys" << std::endl;
1322 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1326 TString attrName = curAttr->GetName();
1327 std::string attrVal = curAttr->GetValue();
1329 if( attrName ==
TString(
"" ) ){
1330 cxcoutEHF <<
"Error: Encountered Element in ShapeSys with no name" << std::endl;
1334 else if( attrName ==
TString(
"Name" ) ) {
1335 shapeSys.SetName( attrVal );
1338 else if( attrName ==
TString(
"HistoName" ) ) {
1339 shapeSys.SetHistoName( attrVal );
1342 else if( attrName ==
TString(
"HistoPath" ) ) {
1343 shapeSys.SetHistoPath( attrVal );
1346 else if( attrName ==
TString(
"InputFile" ) ) {
1347 shapeSys.SetInputFile( attrVal );
1350 else if( attrName ==
TString(
"ConstraintType" ) ) {
1351 if( attrVal.empty() ) {
1352 cxcoutEHF <<
"Error: ShapeSys Constraint type is empty" << std::endl;
1355 else if( attrVal==
"Gaussian" || attrVal==
"Gauss" ) {
1358 else if( attrVal==
"Poisson" || attrVal==
"Pois" ) {
1362 std::cout <<
"Error: Encountered unknown ShapeSys Constraint type: " << attrVal << std::endl;
1368 cxcoutEHF <<
"Error: Encountered Element in ShapeSys with unknown name: "
1369 << attrName << std::endl;
1376 if( shapeSys.GetName().empty() ) {
1377 cxcoutEHF <<
"Error: Encountered ShapeSys with no Name" << std::endl;
1380 if( shapeSys.GetInputFile().empty() ) {
1381 cxcoutEHF <<
"Error: Encountered ShapeSys with no InputFile" << std::endl;
1384 if( shapeSys.GetHistoName().empty() ) {
1385 cxcoutEHF <<
"Error: Encountered ShapeSys with no HistoName" << std::endl;
1389 shapeSys.Print(
oocoutI(
nullptr, HistFactory));
1398 cxcoutIHF <<
"Activating StatError" << std::endl;
1409 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1412 TString attrName = curAttr->GetName();
1413 std::string attrVal = curAttr->GetValue();
1415 if( attrName ==
TString(
"" ) ){
1416 cxcoutEHF <<
"Error: Encountered Element in ActivateStatError with no name" << std::endl;
1420 else if( attrName ==
TString(
"Activate" ) ) {
1424 else if( attrName ==
TString(
"HistoName" ) ) {
1428 else if( attrName ==
TString(
"HistoPath" ) ) {
1432 else if( attrName ==
TString(
"InputFile" ) ) {
1437 cxcoutEHF <<
"Error: Encountered Element in ActivateStatError with unknown name: "
1438 << attrName << std::endl;
1486 cxcoutIHF <<
"Parsing FunctionConfig" << std::endl;
1489 TListIter attribIt = functionNode->GetAttributes();
1493 std::string Expression;
1494 std::string Dependents;
1497 while( ( curAttr =
dynamic_cast< TXMLAttr*
>( attribIt() ) ) !=
nullptr ) {
1498 if( curAttr->GetName() ==
TString(
"Name" ) ) {
1499 Name = curAttr->GetValue();
1503 if( curAttr->GetName() ==
TString(
"Expression" ) ) {
1504 Expression = curAttr->GetValue();
1507 if( curAttr->GetName() ==
TString(
"Dependents" ) ) {
1508 Dependents = curAttr->GetValue();
1514 cxcoutEHF <<
"Error processing PreprocessFunction: Name attribute is empty" << std::endl;
1517 if( Expression.empty() ){
1518 cxcoutEHF <<
"Error processing PreprocessFunction: Expression attribute is empty" << std::endl;
1521 if( Dependents.empty() ){
1522 cxcoutEHF <<
"Error processing PreprocessFunction: Dependents attribute is empty" << std::endl;
1555 if( attrVal.empty() ) {
1557 <<
" Expected either 'True' or 'False' but found empty" << std::endl;
1559 }
else if (attrVal ==
"True" || attrVal ==
"true") {
1561 }
else if (attrVal ==
"False" || attrVal ==
"false") {
1564 cxcoutEHF <<
"Error: In " << NodeTitle <<
" Expected either 'True' or 'False' but found: " << attrVal << std::endl;
double toDouble(const char *s)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
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 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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
TODO Here, we are missing some documentation.
void SetName(const std::string &name)
void SetParamValue(const std::string ¶m, double value)
void SetFixedParam(const std::string ¶m, bool constant=true)
This class encapsulates all information for the statistical interpretation of one experiment.
void SetName(const std::string &Name)
set name of channel
void Print(std::ostream &=std::cout)
void AddAdditionalData(const RooStats::HistFactory::Data &data)
add additional data object
std::string GetInputFile() const
get name of input file
std::string GetHistoPath() const
get path to histograms in input file
void SetData(const RooStats::HistFactory::Data &data)
set data object
void SetInputFile(const std::string &file)
set name of input file containing histograms
void SetStatErrorConfig(double RelErrorThreshold, Constraint::Type ConstraintType)
std::vector< RooStats::HistFactory::Sample > & GetSamples()
get vector of samples for this channel
void SetHistoPath(const std::string &file)
set path for histograms in input file
std::string GetName() const
get name of channel
bool CheckTrueFalse(std::string val, std::string NodeTitle)
bool IsAcceptableNode(TXMLNode *functionNode)
std::vector< RooStats::HistFactory::Measurement > GetMeasurementsFromXML(std::string input)
The "main" method.
HistFactory::StatErrorConfig CreateStatErrorConfigElement(TXMLNode *node)
HistFactory::StatError ActivateStatError(TXMLNode *node)
HistFactory::OverallSys MakeOverallSys(TXMLNode *node)
HistFactory::Sample CreateSampleElement(TXMLNode *node)
HistFactory::HistoSys MakeHistoSys(TXMLNode *node)
std::string m_currentInputFile
To facilitate writing xml, when not specified, files and paths default to these cached values.
HistFactory::ShapeFactor MakeShapeFactor(TXMLNode *node)
std::string m_currentChannel
RooStats::HistFactory::Measurement CreateMeasurementFromDriverNode(TXMLNode *node)
HistFactory::PreprocessFunction ParseFunctionConfig(TXMLNode *functionNode)
HistFactory::Data CreateDataElement(TXMLNode *node)
Helpers used to process a channel.
HistFactory::HistoFactor MakeHistoFactor(TXMLNode *node)
std::string m_currentHistoPath
RooStats::HistFactory::Channel ParseChannelXMLFile(std::string filen)
HistFactory::ShapeSys MakeShapeSys(TXMLNode *node)
HistFactory::NormFactor MakeNormFactor(TXMLNode *node)
Helpers used when processing a Sample.
Configuration for an *un*constrained, coherent shape variation of affected samples.
Configuration for a constrained, coherent shape variation of affected samples.
void SetInputFileHigh(const std::string &InputFileHigh)
void SetHistoPathHigh(const std::string &HistoPathHigh)
void SetInputFileLow(const std::string &InputFileLow)
void SetHistoPathLow(const std::string &HistoPathLow)
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
void SetLumi(double Lumi)
set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
std::vector< RooStats::HistFactory::Channel > & GetChannels()
Configuration for an un- constrained overall systematic to scale sample normalisations.
Configuration for a constrained overall systematic to scale sample normalisations.
std::string GetCommand() const
void SetInputFile(const std::string &InputFile)
set input ROOT file
*Un*constrained bin-by-bin variation of affected histogram.
Constrained bin-by-bin variation of affected histogram.
void SetConstraintType(Constraint::Type ConstrType)
Configuration to automatically assign nuisance parameters for the statistical error of the Monte Carl...
void SetConstraintType(Constraint::Type ConstrType)
double GetRelErrorThreshold() const
void SetRelErrorThreshold(double Threshold)
Constraint::Type GetConstraintType() const
Statistical error of Monte Carlo predictions.
const std::string & GetHistoPath() const
void Activate(bool IsActive=true)
void SetHistoPath(const std::string &HistoPath)
void SetInputFile(const std::string &InputFile)
const std::string & GetInputFile() const
void SetHistoName(const std::string &HistoName)
const std::string & GetHistoName() const
void SetUseHisto(bool UseHisto=true)
void Print(std::ostream &=std::cout) const override
virtual const char * GetName() const
Returns name of object.
TXMLAttribute is the attribute of an Element.
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
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.
const char * GetText() const
Returns the content of a Text node if node is a TextNode, 0 otherwise.
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.
Namespace for the RooStats classes.