Logo ROOT   6.18/05
Reference Guide
ConfigParser.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id: cranmer $
2// Author: Kyle Cranmer, Akira Shibata
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11////////////////////////////////////////////////////////////////////////////////
12/** \class RooStats::HistFactory::ConfigParser
13 * \ingroup HistFactory
14 * TODO Add documentation.
15*/
16
17#include "TDOMParser.h"
18
22
23#include "Helper.h"
24
25
26using namespace RooStats;
27using namespace HistFactory;
28
29using namespace std;
30
31std::vector< RooStats::HistFactory::Measurement > ConfigParser::GetMeasurementsFromXML( string input ) {
32
33 // Open an input "Driver" XML file (input),
34 // Parse that file and its channel files
35 // and return a vector filled with
36 // the listed measurements
37
38
39 // Create the list of measurements
40 // (This is what will be returned)
41 std::vector< HistFactory::Measurement > measurement_list;
42
43 try {
44
45 // Open the Driver XML File
46 TDOMParser xmlparser;
47 Int_t parseError = xmlparser.ParseFile( input.c_str() );
48 if( parseError ) {
49 std::cerr << "Loading of xml document \"" << input
50 << "\" failed" << std::endl;
51 throw hf_exc();
52 }
53
54
55 // Read the Driver XML File
56 cout << "reading input : " << input << endl;
57 TXMLDocument* xmldoc = xmlparser.GetXMLDocument();
58 TXMLNode* rootNode = xmldoc->GetRootNode();
59
60
61 // Check that it is the proper DOCTYPE
62 if( rootNode->GetNodeName() != TString( "Combination" ) ){
63 std::cout << "Error: Driver DOCTYPE not equal to 'Combination'" << std::endl;
64 throw hf_exc();
65 }
66
67 // Loop over the Combination's attributes
68 std::string OutputFilePrefix;
69
70 TListIter attribIt = rootNode->GetAttributes();
71 TXMLAttr* curAttr = 0;
72 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
73
74 // Get the Name, Val of this node
75 TString attrName = curAttr->GetName();
76 std::string attrVal = curAttr->GetValue();
77
78 if( attrName == TString( "" ) ) {
79 std::cout << " Error: Attribute for 'Combination' with no name found" << std::endl;
80 throw hf_exc();
81 }
82
83 else if( attrName == TString( "OutputFilePrefix" ) ) {
84 OutputFilePrefix = string(curAttr->GetValue());
85 std::cout << "output file prefix is : " << OutputFilePrefix << endl;
86 }
87
88 /*
89 else if( attrName == TString( "InputFile" ) ) {
90 channel.InputFile = attrVal ;
91 }
92 */
93
94 else {
95 std::cout << " Error: Unknown attribute for 'Combination' encountered: "
96 << attrName << std::endl;
97 throw hf_exc();
98 }
99
100 // node = node->GetNextNode();
101
102 }
103
104 TXMLNode* node = NULL;
105
106 // Get the list of channel XML files to combine
107 // Do this first so we can quickly exit
108 // if no channels are found
109 std::vector< std::string > xml_channel_files;
110 node = rootNode->GetChildren();
111 while( node != 0 ) {
112 if( node->GetNodeName() == TString( "Input" ) ) {
113 if( node->GetText() == NULL ) {
114 std::cout << "Error: node: " << node->GetName()
115 << " has no text." << std::endl;
116 throw hf_exc();
117 }
118 xml_channel_files.push_back(node->GetText());
119 }
120 node = node->GetNextNode();
121 }
122
123 // If no channel xml files are found, exit
124 if(xml_channel_files.empty()){
125 cerr << "no input channels found" << endl;
126 throw hf_exc();
127 //return measurement_list;
128 }
129 else {
130 std::cout << "Found Channels: ";
131 for( unsigned int i=0; i < xml_channel_files.size(); ++i ) std::cout << " " << xml_channel_files.at(i);
132 std::cout << std::endl;
133 }
134
135 // Get the list of functions
136 // These apply to all measurements, so we
137 // first create the list of preprocess functions
138 // (before we create the list of measurements)
139 // and then we add them to all measurements
140
141 // For now, we create this list twice
142 // simply for compatability
143 // std::vector< std::string > preprocessFunctions;
144 std::vector< RooStats::HistFactory::PreprocessFunction > functionObjects;
145
146 node = rootNode->GetChildren();
147 while( node != 0 ) {
148 if( node->GetNodeName() == TString( "Function" ) ) {
149
150 // For now, add both the objects itself and
151 // it's command string (for easy compatability)
153 // preprocessFunctions.push_back( Func.GetCommand() );
154 functionObjects.push_back( Func );
155 }
156 node = node->GetNextNode();
157 }
158
159 std::cout << std::endl;
160
161
162 // Fill the list of measurements
163 node = rootNode->GetChildren();
164 while( node != 0 ) {
165
166 if( node->GetNodeName() == TString( "" ) ) {
167 std::cout << "Error: Node found in Measurement Driver XML with no name" << std::endl;
168 throw hf_exc();
169 }
170
171 else if( node->GetNodeName() == TString( "Measurement" ) ) {
173 // Set the prefix (obtained above)
174 measurement.SetOutputFilePrefix( OutputFilePrefix );
175 measurement_list.push_back( measurement );
176 }
177
178 else if( node->GetNodeName() == TString( "Function" ) ) {
179 // Already processed these (directly above)
180 ;
181 }
182
183 else if( node->GetNodeName() == TString( "Input" ) ) {
184 // Already processed these (directly above)
185 ;
186 }
187
188 else if( IsAcceptableNode( node ) ) { ; }
189
190 else {
191 std::cout << "Error: Unknown node found in Measurement Driver XML: "
192 << node->GetNodeName() << std::endl;
193 throw hf_exc();
194 }
195
196 node = node->GetNextNode();
197 }
198
199 std::cout << "Done Processing Measurements" << std::endl;
200
201 if( measurement_list.size() == 0 ) {
202 std::cout << "Error: No Measurements found in XML Driver File" << std::endl;
203 throw hf_exc();
204 }
205 else {
206 std::cout << "Found Measurements: ";
207 for( unsigned int i=0; i < measurement_list.size(); ++i ) std::cout << " " << measurement_list.at(i).GetName();
208 std::cout << std::endl;
209 }
210
211 // Add the preprocessed functions to each measurement
212 // for( unsigned int i = 0; i < measurement_list.size(); ++i) {
213 // measurement_list.at(i).SetPreprocessFunctions( preprocessFunctions );
214 // }
215 // Add the preprocessed functions to each measurement
216 for( unsigned int i = 0; i < measurement_list.size(); ++i) {
217 measurement_list.at(i).SetFunctionObjects( functionObjects );
218 }
219
220 // Create an instance of the class
221 // that collects histograms
222 //HistCollector collector;
223
224 // Create the list of channels
225 // (Each of these will be added
226 // to every measurement)
227 std::vector< HistFactory::Channel > channel_list;
228
229 // Fill the list of channels
230 for( unsigned int i = 0; i < xml_channel_files.size(); ++i ) {
231 std::string channel_xml = xml_channel_files.at(i);
232 std::cout << "Parsing Channel: " << channel_xml << std::endl;
233 HistFactory::Channel channel = ParseChannelXMLFile( channel_xml );
234
235 // Get the histograms for the channel
236 //collector.CollectHistograms( channel );
237 //channel.CollectHistograms();
238 channel_list.push_back( channel );
239 }
240
241 // Finally, add the channels to the measurements:
242 for( unsigned int i = 0; i < measurement_list.size(); ++i) {
243
244 HistFactory::Measurement& measurement = measurement_list.at(i);
245
246 for( unsigned int j = 0; j < channel_list.size(); ++j ) {
247 measurement.GetChannels().push_back( channel_list.at(j) );
248 }
249 }
250 }
251 catch(std::exception& e)
252 {
253 std::cout << e.what() << std::endl;
254 throw hf_exc();
255 }
256
257 return measurement_list;
258
259}
260
261
263
264
265 HistFactory::Measurement measurement;
266
267 // Set the default values:
268 measurement.SetLumi( 1.0 );
269 measurement.SetLumiRelErr( .10 );
270 measurement.SetBinLow( 0 );
271 measurement.SetBinHigh( 1 );
272 measurement.SetExportOnly( false );
273
274 std::cout << "Creating new measurement: " << std::endl;
275
276 // First, get the attributes of the node
277 TListIter attribIt = node->GetAttributes();
278 TXMLAttr* curAttr = 0;
279 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
280
281 if( curAttr->GetName() == TString( "" ) ) {
282 std::cout << "Found XML attribute in Measurement with no name" << std::endl;
283 // ADD Output Here
284 throw hf_exc();
285 }
286 else if( curAttr->GetName() == TString( "Name" ) ) {
287 //rowTitle=curAttr->GetValue();
288 measurement.SetName( curAttr->GetValue() );
289 //measurement.OutputFileName = outputFileNamePrefix+"_"+rowTitle+".root";
290 }
291 else if( curAttr->GetName() == TString( "Lumi" ) ) {
292 measurement.SetLumi( atof(curAttr->GetValue()) );
293 }
294 else if( curAttr->GetName() == TString( "LumiRelErr" ) ) {
295 measurement.SetLumiRelErr( atof(curAttr->GetValue()) );
296 }
297 else if( curAttr->GetName() == TString( "BinLow" ) ) {
298 measurement.SetBinLow( atoi(curAttr->GetValue()) );
299 }
300 else if( curAttr->GetName() == TString( "BinHigh" ) ) {
301 measurement.SetBinHigh( atoi(curAttr->GetValue()) );
302 }
303 else if( curAttr->GetName() == TString( "Mode" ) ) {
304 cout <<"\n INFO: Mode attribute is deprecated, will ignore\n"<<endl;
305 }
306 else if( curAttr->GetName() == TString( "ExportOnly" ) ) {
307 measurement.SetExportOnly( CheckTrueFalse(curAttr->GetValue(),"Measurement") );
308 }
309
310 else {
311 std::cout << "Found unknown XML attribute in Measurement: " << curAttr->GetName()
312 << std::endl;
313 throw hf_exc();
314 }
315
316 } // End Loop over attributes
317
318
319 // Then, get the properties of the children nodes
320 TXMLNode* child = node->GetChildren();
321 while( child != 0 ) {
322
323 if( child->GetNodeName() == TString( "" ) ) {
324 std::cout << "Found XML child node of Measurement with no name" << std::endl;
325 throw hf_exc();
326 }
327
328 else if( child->GetNodeName() == TString( "POI" ) ) {
329 if( child->GetText() == NULL ) {
330 std::cout << "Error: node: " << child->GetName()
331 << " has no text." << std::endl;
332 throw hf_exc();
333 }
334 //poi// measurement.SetPOI( child->GetText() );
335 AddSubStrings( measurement.GetPOIList(), child->GetText() );
336 }
337
338 else if( child->GetNodeName() == TString( "ParamSetting" ) ) {
339 TListIter paramIt = child->GetAttributes();
340 TXMLAttr* curParam = 0;
341 while( ( curParam = dynamic_cast< TXMLAttr* >( paramIt() ) ) != 0 ) {
342
343 if( curParam->GetName() == TString( "" ) ) {
344 std::cout << "Error: Found tag attribute with no name in ParamSetting" << std::endl;
345 throw hf_exc();
346 }
347 else if( curParam->GetName() == TString( "Const" ) ) {
348 if(curParam->GetValue()==TString("True")){
349 // Fix here...?
350 if( child->GetText() == NULL ) {
351 std::cout << "Error: node: " << child->GetName()
352 << " has no text." << std::endl;
353 throw hf_exc();
354 }
355 AddSubStrings( measurement.GetConstantParams(), child->GetText() );
356 }
357 }
358 else if( curParam->GetName() == TString( "Val" ) ) {
359 double val = atof(curParam->GetValue());
360 if( child->GetText() == NULL ) {
361 std::cout << "Error: node: " << child->GetName()
362 << " has no text." << std::endl;
363 throw hf_exc();
364 }
365 std::vector<std::string> child_nodes = GetChildrenFromString(child->GetText());
366 for(unsigned int i = 0; i < child_nodes.size(); ++i) {
367 measurement.SetParamValue( child_nodes.at(i), val);
368 }
369 // AddStringValPairToMap( measurement.GetParamValues(), val, child->GetText() );
370 }
371 else {
372 std::cout << "Found tag attribute with unknown name in ParamSetting: "
373 << curAttr->GetName() << std::endl;
374 throw hf_exc();
375 }
376 }
377 }
378
379 else if( child->GetNodeName() == TString( "Asimov" ) ) {
380
381 //std::string name;
382 //std::map<string, double> fixedParams;
383
384 // Now, create and configure an asimov object
385 // and add it to the measurement
387 std::string ParamFixString;
388
389 // Loop over attributes
390 attribIt = child->GetAttributes();
391 curAttr = 0;
392 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
393
394 if( curAttr->GetName() == TString( "" ) ) {
395 std::cout << "Error: Found tag attribute with no name in ConstraintTerm" << std::endl;
396 throw hf_exc();
397 }
398
399 else if( curAttr->GetName() == TString( "Name" ) ) {
400 std::string name = curAttr->GetValue();
401 asimov.SetName( name );
402 }
403
404 else if( curAttr->GetName() == TString( "FixParams" ) ) {
405 ParamFixString = curAttr->GetValue();
406 //std::map<std::string, double> fixedParams = ExtractParamMapFromString(FixParamList);
407 //asimov.GetFixedParams() = fixedParams;
408 }
409
410 else {
411 std::cout << "Found tag attribute with unknown name in ConstraintTerm: "
412 << curAttr->GetName() << std::endl;
413 throw hf_exc();
414 }
415
416 }
417
418 // Add any parameters to the asimov dataset
419 // to be fixed during the fitting and dataset generation
420 if( ParamFixString=="" ) {
421 std::cout << "Warning: Asimov Dataset with name: " << asimov.GetName()
422 << " added, but no parameters are set to be fixed" << std::endl;
423 }
424 else {
425 AddParamsToAsimov( asimov, ParamFixString );
426 }
427
428 measurement.AddAsimovDataset( asimov );
429
430 }
431
432 else if( child->GetNodeName() == TString( "ConstraintTerm" ) ) {
433 vector<string> syst;
434 string type = "";
435 double rel = 0;
436
437 map<string,double> gammaSyst;
438 map<string,double> uniformSyst;
439 map<string,double> logNormSyst;
440
441 // Get the list of parameters in this tag:
442 if( child->GetText() == NULL ) {
443 std::cout << "Error: node: " << child->GetName()
444 << " has no text." << std::endl;
445 throw hf_exc();
446 }
447 AddSubStrings(syst, child->GetText());
448
449 // Now, loop over this tag's attributes
450 attribIt = child->GetAttributes();
451 curAttr = 0;
452 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
453
454 if( curAttr->GetName() == TString( "" ) ) {
455 std::cout << "Error: Found tag attribute with no name in ConstraintTerm" << std::endl;
456 throw hf_exc();
457 }
458
459 else if( curAttr->GetName() == TString( "Type" ) ) {
460 type = curAttr->GetValue();
461 }
462
463 else if( curAttr->GetName() == TString( "RelativeUncertainty" ) ) {
464 rel = atof(curAttr->GetValue());
465 }
466
467 else {
468 std::cout << "Found tag attribute with unknown name in ConstraintTerm: "
469 << curAttr->GetName() << std::endl;
470 throw hf_exc();
471 }
472
473 } // End Loop over tag attributes
474
475
476 // Now, fill the maps, depending on the type:
477
478 // Check that the type is in the correct form:
479 if( ! (type=="Gamma" || type=="Uniform" ||
480 type=="LogNormal" || type=="NoConstraint") ) {
481 std::cout << "Error: Encountered unknown type for ConstraintTerm: " << type << std::endl;
482 throw hf_exc();
483 }
484
485 if (type=="Gamma" && rel!=0) {
486 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); ++it) {
487 // Fix Here...?
488 measurement.GetGammaSyst()[(*it).c_str()] = rel;
489 }
490 }
491
492 if (type=="Uniform" && rel!=0) {
493 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); ++it) {
494 // Fix Here...?
495 measurement.GetUniformSyst()[(*it).c_str()] = rel;
496 }
497 }
498
499 if (type=="LogNormal" && rel!=0) {
500 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); ++it) {
501 // Fix Here...?
502 measurement.GetLogNormSyst()[(*it).c_str()] = rel;
503 }
504 }
505
506 if (type=="NoConstraint") {
507 for (vector<string>::const_iterator it=syst.begin(); it!=syst.end(); ++it) {
508 // Fix Here...?
509 measurement.GetNoSyst()[(*it).c_str()] = 1.0; // MB : dummy value
510 }
511 }
512 } // End adding of Constraint terms
513
514
515 else if( IsAcceptableNode( child ) ) { ; }
516
517 else {
518 std::cout << "Found XML child of Measurement with unknown name: " << child->GetNodeName()
519 << std::endl;
520 throw hf_exc();
521 }
522
523 child = child->GetNextNode();
524 }
525
526 measurement.PrintTree();
527 std::cout << std::endl;
528
529 return measurement;
530
531}
532
533
534
536
537 /*
538 TString lumiStr;
539 lumiStr+=lumi;
540 lumiStr.ReplaceAll(' ', TString());
541 */
542
543 std::cout << "Parsing file: " << filen ;
544
545 TDOMParser xmlparser;
546
547 // reading in the file and parse by DOM
548 Int_t parseError = xmlparser.ParseFile( filen.c_str() );
549 if( parseError ) {
550 std::cout << "Loading of xml document \"" << filen
551 << "\" failed" << std::endl;
552 throw hf_exc();
553 }
554
555 TXMLDocument* xmldoc = xmlparser.GetXMLDocument();
556 TXMLNode* rootNode = xmldoc->GetRootNode();
557
558 // Check that is is a CHANNEL based on the DOCTYPE
559
560 if( rootNode->GetNodeName() != TString( "Channel" ) ){
561 std::cout << "Error: In parsing a Channel XML, "
562 << "Encounterd XML with DOCTYPE: " << rootNode->GetNodeName()
563 << std::endl;
564 std::cout << " DOCTYPE for channels must be 'Channel' "
565 << " Check that your XML is properly written" << std::endl;
566 throw hf_exc();
567 }
568
569 // Now, create the channel,
570 // configure it based on the XML
571 // and return it
572
573 HistFactory::Channel channel;
574
575 // Set the default values:
576 channel.SetInputFile( "" );
577 channel.SetHistoPath( "" );
578
579 // Walk through the root node and
580 // get its attributes
581 TListIter attribIt = rootNode->GetAttributes();
582 TXMLAttr* curAttr = 0;
583 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
584
585 // Get the Name, Val of this node
586 TString attrName = curAttr->GetName();
587 std::string attrVal = curAttr->GetValue();
588
589 if( attrName == TString( "" ) ) {
590 std::cout << " Error: Attribute for 'Channel' with no name found" << std::endl;
591 throw hf_exc();
592 }
593
594 else if( attrName == TString( "Name" ) ) {
595 channel.SetName( attrVal );
596 std::cout << " : creating a channel named " << channel.GetName() << std::endl;
597 }
598
599 else if( attrName == TString( "InputFile" ) ) {
600 std::cout << "Setting InputFile for this channel: " << attrVal << std::endl;
601 channel.SetInputFile( attrVal );
602 // Set the current (cached) value
603 m_currentInputFile = attrVal;
604 }
605
606 else if( curAttr->GetName() == TString( "HistoPath" ) ) {
607 std::cout << "Setting HistoPath for this channel: " << attrVal << std::endl;
608 // Set the current (cached) value
609 channel.SetHistoPath( attrVal );
610 m_currentHistoPath = attrVal;
611 }
612
613 else if( curAttr->GetName() == TString( "HistoName" ) ) {
614 // Changed This:
615 std::cout << "Use of HistoName in Channel is deprecated" << std::endl;
616 std::cout << "This will be ignored" << std::endl;
617 }
618
619 else {
620 std::cout << " Error: Unknown attribute for 'Channel' encountered: "
621 << attrName << std::endl;
622 throw hf_exc();
623 }
624
625 } // End loop over the channel tag's attributes
626
627 // Check that the channel was properly initiated:
628
629 if( channel.GetName() == "" ) {
630 std::cout << "Error: Channel created with no name" << std::endl;
631 throw hf_exc();
632 }
633
634 m_currentChannel = channel.GetName();
635
636 // Loop over the children nodes in the XML file
637 // and configure the channel based on them
638
639 TXMLNode* node = rootNode->GetChildren();
640
641 bool firstData=true;
642
643 while( node != 0 ) {
644
645 // Restore the Channel-Wide Defaults
648
649 if( node->GetNodeName() == TString( "" ) ) {
650 std::cout << "Error: Encountered node in Channel with no name" << std::endl;
651 throw hf_exc();
652 }
653
654 else if( node->GetNodeName() == TString( "Data" ) ) {
655 if( firstData ) {
657 if( data.GetName() != "" ) {
658 std::cout << "Error: You can only rename the datasets of additional data sets. "
659 << " Remove the 'Name=" << data.GetName() << "' tag"
660 << " from channel: " << channel.GetName() << std::endl;
661 throw hf_exc();
662 }
663 channel.SetData( data );
664 firstData=false;
665 }
666 else {
667 channel.AddAdditionalData( CreateDataElement(node) );
668 }
669 }
670
671 else if( node->GetNodeName() == TString( "StatErrorConfig" ) ) {
673 }
674
675 else if( node->GetNodeName() == TString( "Sample" ) ) {
676 channel.GetSamples().push_back( CreateSampleElement(node) );
677 }
678
679 else if( IsAcceptableNode( node ) ) { ; }
680
681 else {
682 std::cout << "Error: Encountered node in Channel with unknown name: " << node->GetNodeName() << std::endl;
683 throw hf_exc();
684 }
685
686 node = node->GetNextNode();
687
688 } // End loop over tags in this channel
689
690 std::cout << "Created Channel: " << std::endl;
691 channel.Print();
692
693 return channel;
694
695}
696
697
698
700
701 std::cout << "Creating Data Element" << std::endl;
702
704
705 // Set the default values
708 //data.HistoName = m_currentHistoName;
709
710 // Now, set the attributes
711 TListIter attribIt = node->GetAttributes();
712 TXMLAttr* curAttr = 0;
713 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
714
715 // Get the Name, Val of this node
716 TString attrName = curAttr->GetName();
717 std::string attrVal = curAttr->GetValue();
718
719 if( attrName == TString( "" ) ) {
720 std::cout << " Error: Attribute for 'Data' with no name found" << std::endl;
721 throw hf_exc();
722 }
723
724 else if( attrName == TString( "Name" ) ) {
725 data.SetName( attrVal );
726 }
727
728 else if( attrName == TString( "InputFile" ) ) {
729 data.SetInputFile( attrVal );
730 }
731
732 else if( attrName == TString( "HistoName" ) ) {
733 data.SetHistoName( attrVal );
734 }
735
736 else if( attrName == TString( "HistoPath" ) ) {
737 data.SetHistoPath( attrVal );
738 }
739
740 else if( IsAcceptableNode( node ) ) { ; }
741
742 else {
743 std::cout << " Error: Unknown attribute for 'Data' encountered: " << attrName << std::endl;
744 throw hf_exc();
745 }
746
747 }
748
749 // Check the properties of the data node:
750 if( data.GetInputFile() == "" ) {
751 std::cout << "Error: Data Node has no InputFile" << std::endl;
752 throw hf_exc();
753 }
754 if( data.GetHistoName() == "" ) {
755 std::cout << "Error: Data Node has no HistoName" << std::endl;
756 throw hf_exc();
757 }
758
759 std::cout << "Created Data Node with"
760 << " InputFile: " << data.GetInputFile()
761 << " HistoName: " << data.GetHistoName()
762 << " HistoPath: " << data.GetHistoPath();
763 if( data.GetName() != "") std::cout << " Name: " << data.GetName();
764 std::cout << std::endl;
765
766 // data.hist = GetHisto(data.FileName, data.HistoPath, data.HistoName);
767
768 return data;
769}
770
771
772
774
775 std::cout << "Creating StatErrorConfig Element" << std::endl;
776
778
779 // Setup default values:
781 config.SetRelErrorThreshold( 0.05 ); // 5%
782
783 // Loop over the node's attributes
784 TListIter attribIt = node->GetAttributes();
785 TXMLAttr* curAttr = 0;
786 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
787
788 // Get the Name, Val of this node
789 TString attrName = curAttr->GetName();
790 std::string attrVal = curAttr->GetValue();
791
792 if( attrName == TString( "RelErrorThreshold" ) ) {
793 config.SetRelErrorThreshold( atof(attrVal.c_str()) );
794 }
795
796 if( attrName == TString( "ConstraintType" ) ) {
797 // Allowable Values: Gaussian
798
799 if( attrVal == "" ) {
800 std::cout << "Error: Bad Value for StatErrorConfig Constraint Type Found" << std::endl;
801 throw hf_exc();
802 }
803
804 else if( attrVal=="Gaussian" || attrVal=="Gauss" ) {
806 }
807
808 else if( attrVal=="Poisson" || attrVal=="Pois" ) {
810 }
811
812 else if( IsAcceptableNode( node ) ) { ; }
813
814 else {
815 cout << "Invalid Stat Constraint Type: " << curAttr->GetValue() << endl;
816 throw hf_exc();
817 }
818 }
819 } // End: Loop Over Attributes
820
821 std::cout << "Created StatErrorConfig Element with"
822 << " Constraint type: " << config.GetConstraintType()
823 << " RelError Threshold: " << config.GetRelErrorThreshold()
824 << std::endl;
825
826 return config;
827
828}
829
830
832
833 std::cout << "Creating Sample Element" << std::endl;
834
835 HistFactory::Sample sample;
836
837 // Set the default values
841 sample.SetNormalizeByTheory( true );
842 //sample.HistoName = m_currentHistoName;
843
844 // Now, set the attributes
845
846 TListIter attribIt = node->GetAttributes();
847 TXMLAttr* curAttr = 0;
848 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
849
850 // Get the Name, Val of this node
851 TString attrName = curAttr->GetName();
852 std::string attrVal = curAttr->GetValue();
853
854 if( attrName == TString( "" ) ) {
855 std::cout << " Error: Attribute for 'Sample' with no name found" << std::endl;
856 throw hf_exc();
857 }
858
859 else if( attrName == TString( "Name" ) ) {
860 sample.SetName( attrVal );
861 }
862
863 else if( attrName == TString( "InputFile" ) ) {
864 sample.SetInputFile( attrVal );
865 m_currentInputFile = attrVal;
866 }
867
868 else if( attrName == TString( "HistoName" ) ) {
869 sample.SetHistoName( attrVal );
870 }
871
872 else if( attrName == TString( "HistoPath" ) ) {
873 sample.SetHistoPath( attrVal );
874 m_currentHistoPath = attrVal;
875 }
876
877 else if( attrName == TString( "NormalizeByTheory" ) ) {
878 sample.SetNormalizeByTheory( CheckTrueFalse(attrVal,"Sample") );
879 /*
880 if( attrVal == "" ) {
881 std::cout << "Error: Attribute 'NormalizeByTheory' in Sample has no value" << std::endl;
882 throw hf_exc();
883 }
884 else if ( attrVal == "True" || attrVal == "true" ) sample.NormalizeByTheory = true;
885 else if ( attrVal == "False" || attrVal == "false" ) sample.NormalizeByTheory = false;
886 else {
887 std::cout << "Error: Attribute 'NormalizeByTheory' in Sample has unknown value: " << attrVal << std::endl;
888 std::cout << "Value must be 'True' or 'False' " << std::endl;
889 throw hf_exc();
890 }
891 */
892 }
893
894 else {
895 std::cout << " Error: Unknown attribute for 'Sample' encountered: " << attrName << std::endl;
896 throw hf_exc();
897 }
898 }
899
900 // Quickly check the properties of the Sample Node
901 if( sample.GetName() == "" ) {
902 std::cout << "Error: Sample Node has no Name" << std::endl;
903 throw hf_exc();
904 }
905 if( sample.GetInputFile() == "" ) {
906 std::cout << "Error: Sample Node has no InputFile" << std::endl;
907 throw hf_exc();
908 }
909 if( sample.GetHistoName() == "" ) {
910 std::cout << "Error: Sample Node has no HistoName" << std::endl;
911 throw hf_exc();
912 }
913
914
915 // Now, loop over the children and add the systematics
916
917 TXMLNode* child = node->GetChildren();
918
919 while( child != 0 ) {
920
921 if( child->GetNodeName() == TString( "" ) ) {
922 std::cout << "Error: Encountered node in Sample with no name" << std::endl;
923 throw hf_exc();
924 }
925
926 else if( child->GetNodeName() == TString( "NormFactor" ) ) {
927 sample.GetNormFactorList().push_back( MakeNormFactor( child ) );
928 }
929
930 else if( child->GetNodeName() == TString( "OverallSys" ) ) {
931 sample.GetOverallSysList().push_back( MakeOverallSys( child ) );
932 }
933
934 else if( child->GetNodeName() == TString( "HistoSys" ) ) {
935 sample.GetHistoSysList().push_back( MakeHistoSys( child ) );
936 }
937
938 else if( child->GetNodeName() == TString( "HistoFactor" ) ) {
939 std::cout << "WARNING: HistoFactor not yet supported" << std::endl;
940 //sample.GetHistoFactorList().push_back( MakeHistoFactor( child ) );
941 }
942
943 else if( child->GetNodeName() == TString( "ShapeSys" ) ) {
944 sample.GetShapeSysList().push_back( MakeShapeSys( child ) );
945 }
946
947 else if( child->GetNodeName() == TString( "ShapeFactor" ) ) {
948 sample.GetShapeFactorList().push_back( MakeShapeFactor( child ) );
949 }
950
951 else if( child->GetNodeName() == TString( "StatError" ) ) {
952 sample.SetStatError( ActivateStatError(child) );
953 }
954
955 else if( IsAcceptableNode( child ) ) { ; }
956
957 else {
958 std::cout << "Error: Encountered node in Sample with unknown name: " << child->GetNodeName() << std::endl;
959 throw hf_exc();
960 }
961
962 child=child->GetNextNode();
963 }
964
965 std::cout << "Created Sample Node with"
966 << " Name: " << sample.GetName()
967 << " InputFile: " << sample.GetInputFile()
968 << " HistoName: " << sample.GetHistoName()
969 << " HistoPath: " << sample.GetHistoPath()
970 << std::endl;
971
972 // sample.hist = GetHisto(sample.FileName, sample.HistoPath, sample.HistoName);
973
974 return sample;
975}
976
977
979
980 std::cout << "Making NormFactor:" << std::endl;
981
983
984 TListIter attribIt = node->GetAttributes();
985 TXMLAttr* curAttr = 0;
986 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
987
988 // Get the Name, Val of this node
989 TString attrName = curAttr->GetName();
990 std::string attrVal = curAttr->GetValue();
991
992 if( attrName == TString( "" ) ){
993 std::cout << "Error: Encountered Element in NormFactor with no name" << std::endl;
994 throw hf_exc();
995 }
996
997 else if( curAttr->GetName() == TString( "Name" ) ) {
998 norm.SetName( attrVal );
999 }
1000 else if( curAttr->GetName() == TString( "Val" ) ) {
1001 norm.SetVal( atof(attrVal.c_str()) );
1002 }
1003 else if( curAttr->GetName() == TString( "Low" ) ) {
1004 norm.SetLow( atof(attrVal.c_str()) );
1005 }
1006 else if( curAttr->GetName() == TString( "High" ) ) {
1007 norm.SetHigh( atof(attrVal.c_str()) );
1008 }
1009 else if( curAttr->GetName() == TString( "Const" ) ) {
1010 norm.SetConst( CheckTrueFalse(attrVal,"NormFactor") );
1011 }
1012
1013 else {
1014 std::cout << "Error: Encountered Element in NormFactor with unknown name: "
1015 << attrName << std::endl;
1016 throw hf_exc();
1017 }
1018
1019 } // End loop over properties
1020
1021 if( norm.GetName() == "" ) {
1022 std::cout << "Error: NormFactor Node has no Name" << std::endl;
1023 throw hf_exc();
1024 }
1025
1026 if( norm.GetLow() >= norm.GetHigh() ) {
1027 std::cout << "Error: NormFactor: " << norm.GetName()
1028 << " has lower limit >= its upper limit: "
1029 << " Lower: " << norm.GetLow()
1030 << " Upper: " << norm.GetHigh()
1031 << ". Please Fix" << std::endl;
1032 throw hf_exc();
1033 }
1034 if( norm.GetVal() > norm.GetHigh() || norm.GetVal() < norm.GetLow() ) {
1035 std::cout << "Error: NormFactor: " << norm.GetName()
1036 << " has initial value not within its range: "
1037 << " Val: " << norm.GetVal()
1038 << " Lower: " << norm.GetLow()
1039 << " Upper: " << norm.GetHigh()
1040 << ". Please Fix" << std::endl;
1041 throw hf_exc();
1042 }
1043
1044 norm.Print();
1045
1046 return norm;
1047
1048}
1049
1051
1052 std::cout << "Making HistoFactor" << std::endl;
1053
1055
1056 dummy.SetInputFileLow( m_currentInputFile );
1057 dummy.SetHistoPathLow( m_currentHistoPath );
1058
1059 dummy.SetInputFileHigh( m_currentInputFile );
1060 dummy.SetHistoPathHigh( m_currentHistoPath );
1061
1062 std::cout << "Made HistoFactor" << std::endl;
1063
1064 return dummy;
1065
1066}
1067
1068
1070
1071 std::cout << "Making HistoSys:" << std::endl;
1072
1073 HistFactory::HistoSys histoSys;
1074
1075 // Set Default values
1078
1081
1082 TListIter attribIt = node->GetAttributes();
1083 TXMLAttr* curAttr = 0;
1084 /*
1085 string Name, histoPathHigh, histoPathLow,
1086 histoNameLow, histoNameHigh, inputFileHigh, inputFileLow;
1087 inputFileLow=inputFileName; inputFileHigh=inputFileName;
1088 histoPathLow=histoPathName; histoPathHigh=histoPathName;
1089 histoNameLow=histoName; histoNameHigh=histoName;
1090 */
1091
1092 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
1093
1094 // Get the Name, Val of this node
1095 TString attrName = curAttr->GetName();
1096 std::string attrVal = curAttr->GetValue();
1097
1098 if( attrName == TString( "" ) ){
1099 std::cout << "Error: Encountered Element in HistoSys with no name" << std::endl;
1100 throw hf_exc();
1101 }
1102
1103 else if( curAttr->GetName() == TString( "Name" ) ) {
1104 histoSys.SetName( attrVal );
1105 }
1106
1107 else if( curAttr->GetName() == TString( "HistoFileHigh" ) ) {
1108 histoSys.SetInputFileHigh( attrVal );
1109 }
1110 else if( curAttr->GetName() == TString( "HistoPathHigh" ) ) {
1111 histoSys.SetHistoPathHigh( attrVal );
1112 }
1113 else if( curAttr->GetName() == TString( "HistoNameHigh" ) ) {
1114 histoSys.SetHistoNameHigh( attrVal );
1115 }
1116
1117 else if( curAttr->GetName() == TString( "HistoFileLow" ) ) {
1118 histoSys.SetInputFileLow( attrVal );
1119 }
1120 else if( curAttr->GetName() == TString( "HistoPathLow" ) ) {
1121 histoSys.SetHistoPathLow( attrVal );
1122 }
1123 else if( curAttr->GetName() == TString( "HistoNameLow" ) ) {
1124 histoSys.SetHistoNameLow( attrVal );
1125 }
1126
1127 else {
1128 std::cout << "Error: Encountered Element in HistoSys with unknown name: "
1129 << attrName << std::endl;
1130 throw hf_exc();
1131 }
1132
1133 } // End loop over properties
1134
1135
1136 if( histoSys.GetName() == "" ) {
1137 std::cout << "Error: HistoSys Node has no Name" << std::endl;
1138 throw hf_exc();
1139 }
1140 if( histoSys.GetInputFileHigh() == "" ) {
1141 std::cout << "Error: HistoSysSample Node has no InputFileHigh" << std::endl;
1142 throw hf_exc();
1143 }
1144 if( histoSys.GetInputFileLow() == "" ) {
1145 std::cout << "Error: HistoSysSample Node has no InputFileLow" << std::endl;
1146 throw hf_exc();
1147 }
1148 if( histoSys.GetHistoNameHigh() == "" ) {
1149 std::cout << "Error: HistoSysSample Node has no HistoNameHigh" << std::endl;
1150 throw hf_exc();
1151 }
1152 if( histoSys.GetHistoNameLow() == "" ) {
1153 std::cout << "Error: HistoSysSample Node has no HistoNameLow" << std::endl;
1154 throw hf_exc();
1155 }
1156
1157
1158 histoSys.Print();
1159
1160 return histoSys;
1161
1162}
1163
1164
1166
1167 std::cout << "Making OverallSys:" << std::endl;
1168
1169 HistFactory::OverallSys overallSys;
1170
1171 TListIter attribIt = node->GetAttributes();
1172 TXMLAttr* curAttr = 0;
1173 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
1174
1175 // Get the Name, Val of this node
1176 TString attrName = curAttr->GetName();
1177 std::string attrVal = curAttr->GetValue();
1178
1179 if( attrName == TString( "" ) ){
1180 std::cout << "Error: Encountered Element in OverallSys with no name" << std::endl;
1181 throw hf_exc();
1182 }
1183
1184 else if( attrName == TString( "Name" ) ) {
1185 overallSys.SetName( attrVal );
1186 }
1187 else if( attrName == TString( "High" ) ) {
1188 overallSys.SetHigh( atof(attrVal.c_str()) );
1189 }
1190 else if( attrName == TString( "Low" ) ) {
1191 overallSys.SetLow( atof(attrVal.c_str()) );
1192 }
1193
1194 else {
1195 std::cout << "Error: Encountered Element in OverallSys with unknown name: "
1196 << attrName << std::endl;
1197 throw hf_exc();
1198 }
1199
1200 }
1201
1202 if( overallSys.GetName() == "" ) {
1203 std::cout << "Error: Encountered OverallSys with no name" << std::endl;
1204 throw hf_exc();
1205 }
1206
1207
1208 overallSys.Print();
1209
1210 return overallSys;
1211
1212}
1213
1214
1216
1217 std::cout << "Making ShapeFactor" << std::endl;
1218
1219 HistFactory::ShapeFactor shapeFactor;
1220
1221 TListIter attribIt = node->GetAttributes();
1222 TXMLAttr* curAttr = 0;
1223
1224 // A Shape Factor may or may not include an initial shape
1225 // This will be set by strings pointing to a histogram
1226 // If we don't see a 'HistoName' attribute, we assume
1227 // that an initial shape is not being set
1228 std::string ShapeInputFile = m_currentInputFile;
1229 std::string ShapeInputPath = m_currentHistoPath;
1230
1231 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
1232
1233 // Get the Name, Val of this node
1234 TString attrName = curAttr->GetName();
1235 std::string attrVal = curAttr->GetValue();
1236
1237 if( attrName == TString( "" ) ){
1238 std::cout << "Error: Encountered Element in ShapeFactor with no name" << std::endl;
1239 throw hf_exc();
1240 }
1241
1242 else if( attrName == TString( "Name" ) ) {
1243 shapeFactor.SetName( attrVal );
1244 }
1245 else if( attrName == TString( "Const" ) ) {
1246 shapeFactor.SetConstant( CheckTrueFalse(attrVal, "ShapeFactor" ) );
1247 }
1248
1249 else if( attrName == TString( "HistoName" ) ) {
1250 shapeFactor.SetHistoName( attrVal );
1251 }
1252
1253 else if( attrName == TString( "InputFile" ) ) {
1254 ShapeInputFile = attrVal;
1255 }
1256
1257 else if( attrName == TString( "HistoPath" ) ) {
1258 ShapeInputPath = attrVal;
1259 }
1260
1261 else {
1262 std::cout << "Error: Encountered Element in ShapeFactor with unknown name: "
1263 << attrName << std::endl;
1264 throw hf_exc();
1265 }
1266
1267 }
1268
1269 if( shapeFactor.GetName() == "" ) {
1270 std::cout << "Error: Encountered ShapeFactor with no name" << std::endl;
1271 throw hf_exc();
1272 }
1273
1274 // Set the Histogram name, path, and file
1275 // if an InitialHist is set
1276 if( shapeFactor.HasInitialShape() ) {
1277 if( shapeFactor.GetHistoName() == "" ) {
1278 std::cout << "Error: ShapeFactor: " << shapeFactor.GetName()
1279 << " is configured to have an initial shape, but "
1280 << "its histogram doesn't have a name"
1281 << std::endl;
1282 throw hf_exc();
1283 }
1284 shapeFactor.SetHistoPath( ShapeInputPath );
1285 shapeFactor.SetInputFile( ShapeInputFile );
1286 }
1287
1288 shapeFactor.Print();
1289
1290 return shapeFactor;
1291
1292}
1293
1294
1296
1297 std::cout << "Making ShapeSys" << std::endl;
1298
1299 HistFactory::ShapeSys shapeSys;
1300
1301 // Set the default values
1303 shapeSys.SetInputFile( m_currentInputFile );
1304 shapeSys.SetHistoPath( m_currentHistoPath );
1305
1306
1307 TListIter attribIt = node->GetAttributes();
1308 TXMLAttr* curAttr = 0;
1309 //EstimateSummary::ConstraintType ConstraintType = EstimateSummary::Gaussian; //"Gaussian";
1310
1311 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
1312
1313
1314 // Get the Name, Val of this node
1315 TString attrName = curAttr->GetName();
1316 std::string attrVal = curAttr->GetValue();
1317
1318 if( attrName == TString( "" ) ){
1319 std::cout << "Error: Encountered Element in ShapeSys with no name" << std::endl;
1320 throw hf_exc();
1321 }
1322
1323 else if( attrName == TString( "Name" ) ) {
1324 shapeSys.SetName( attrVal );
1325 }
1326
1327 else if( attrName == TString( "HistoName" ) ) {
1328 shapeSys.SetHistoName( attrVal );
1329 }
1330
1331 else if( attrName == TString( "HistoPath" ) ) {
1332 shapeSys.SetHistoPath( attrVal );
1333 }
1334
1335 else if( attrName == TString( "InputFile" ) ) {
1336 shapeSys.SetInputFile( attrVal );
1337 }
1338
1339 else if( attrName == TString( "ConstraintType" ) ) {
1340 if( attrVal=="" ) {
1341 std::cout << "Error: ShapeSys Constraint type is empty" << std::endl;
1342 throw hf_exc();
1343 }
1344 else if( attrVal=="Gaussian" || attrVal=="Gauss" ) {
1346 }
1347 else if( attrVal=="Poisson" || attrVal=="Pois" ) {
1349 }
1350 else {
1351 cout << "Error: Encountered unknown ShapeSys Constraint type: " << attrVal << endl;
1352 throw hf_exc();
1353 }
1354 }
1355
1356 else {
1357 std::cout << "Error: Encountered Element in ShapeSys with unknown name: "
1358 << attrName << std::endl;
1359 throw hf_exc();
1360 }
1361
1362 } // End loop over attributes
1363
1364
1365 if( shapeSys.GetName() == "" ) {
1366 std::cout << "Error: Encountered ShapeSys with no Name" << std::endl;
1367 throw hf_exc();
1368 }
1369 if( shapeSys.GetInputFile() == "" ) {
1370 std::cout << "Error: Encountered ShapeSys with no InputFile" << std::endl;
1371 throw hf_exc();
1372 }
1373 if( shapeSys.GetHistoName() == "" ) {
1374 std::cout << "Error: Encountered ShapeSys with no HistoName" << std::endl;
1375 throw hf_exc();
1376 }
1377
1378 shapeSys.Print();
1379
1380 return shapeSys;
1381
1382}
1383
1384
1386
1387 std::cout << "Activating StatError" << std::endl;
1388
1389 // Set default values
1390 HistFactory::StatError statError;
1391 statError.Activate( false );
1392 statError.SetUseHisto( false );
1393 statError.SetHistoName( "" );
1394
1395 // Loop over the node's attributes
1396 TListIter attribIt = node->GetAttributes();
1397 TXMLAttr* curAttr = 0;
1398 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
1399
1400 // Get the Name, Val of this node
1401 TString attrName = curAttr->GetName();
1402 std::string attrVal = curAttr->GetValue();
1403
1404 if( attrName == TString( "" ) ){
1405 std::cout << "Error: Encountered Element in ActivateStatError with no name" << std::endl;
1406 throw hf_exc();
1407 }
1408
1409 else if( attrName == TString( "Activate" ) ) {
1410 statError.Activate( CheckTrueFalse(attrVal,"ActivateStatError") );
1411 }
1412
1413 else if( attrName == TString( "HistoName" ) ) {
1414 statError.SetHistoName( attrVal );
1415 }
1416
1417 else if( attrName == TString( "HistoPath" ) ) {
1418 statError.SetHistoPath( attrVal );
1419 }
1420
1421 else if( attrName == TString( "InputFile" ) ) {
1422 statError.SetInputFile( attrVal );
1423 }
1424
1425 else {
1426 std::cout << "Error: Encountered Element in ActivateStatError with unknown name: "
1427 << attrName << std::endl;
1428 throw hf_exc();
1429 }
1430
1431 } // End: Loop Over Attributes
1432
1433 // Based on the input, determine
1434 // if we should use a histogram or not:
1435 // Logic: One turns on using a histogram
1436 // by setting the attribute "HistoName"
1437 // If this is set AND the InputFile or
1438 // HistoPath aren't set, we set those
1439 // to the current default values
1440 if( statError.GetHistoName() != "" ) {
1441 statError.SetUseHisto( true );
1442
1443 // Check that a file has been set
1444 // (Possibly using the default)
1445 if( statError.GetInputFile() == "" ) {
1446 statError.SetInputFile( m_currentInputFile );
1447 }
1448 if( statError.GetHistoPath() == "" ) {
1449 statError.SetHistoPath( m_currentHistoPath );
1450 }
1451
1452 }
1453
1454 /*
1455 if( statError.Activate ) {
1456 if( statError.UseHisto ) {
1457 }
1458 else {
1459 statError.InputFile = "";
1460 statError.HistoName = "";
1461 statError.HistoPath = "";
1462 }
1463 }
1464 */
1465
1466 statError.Print();
1467
1468 return statError;
1469
1470}
1471
1472
1474
1475 std::cout << "Parsing FunctionConfig" << std::endl;
1476
1477 //std::string name, expression, dependents;
1478 TListIter attribIt = functionNode->GetAttributes();
1479 TXMLAttr* curAttr = 0;
1480
1481 std::string Name = "";
1482 std::string Expression = "";
1483 std::string Dependents = "";
1484
1485 // Add protection to ensure that all parts are there
1486 while( ( curAttr = dynamic_cast< TXMLAttr* >( attribIt() ) ) != 0 ) {
1487 if( curAttr->GetName() == TString( "Name" ) ) {
1488 Name = curAttr->GetValue();
1489 //func.SetName( curAttr->GetValue() );
1490 //name = curAttr->GetValue() ;
1491 }
1492 if( curAttr->GetName() == TString( "Expression" ) ) {
1493 Expression = curAttr->GetValue();
1494 //func.SetExpression( curAttr->GetValue() );
1495 }
1496 if( curAttr->GetName() == TString( "Dependents" ) ) {
1497 Dependents = curAttr->GetValue();
1498 //func.SetDependents( curAttr->GetValue() );
1499 }
1500 }
1501
1502 if( Name=="" ){
1503 std::cout << "Error processing PreprocessFunction: Name attribute is empty" << std::endl;
1504 throw hf_exc();
1505 }
1506 if( Expression=="" ){
1507 std::cout << "Error processing PreprocessFunction: Expression attribute is empty" << std::endl;
1508 throw hf_exc();
1509 }
1510 if( Dependents=="" ){
1511 std::cout << "Error processing PreprocessFunction: Dependents attribute is empty" << std::endl;
1512 throw hf_exc();
1513 }
1514
1515 RooStats::HistFactory::PreprocessFunction func(Name, Expression, Dependents);
1516
1517 std::cout << "Created Preprocess Function: " << func.GetCommand() << std::endl;
1518
1519 //std::string command = "expr::"+func.GetName()+"('"+func.GetExpression()+"',{"+func.GetDependents()+"})";
1520 //func.SetCommand( command );
1521 // // cout << "will pre-process this line " << ret <<endl;
1522 return func;
1523
1524}
1525
1526
1528
1529 if( node->GetNodeName() == TString( "text" ) ) {
1530 return true;
1531 }
1532
1533 if( node->GetNodeName() == TString( "comment" ) ) {
1534 return true;
1535 }
1536
1537 return false;
1538
1539}
1540
1541
1542bool ConfigParser::CheckTrueFalse( std::string attrVal, std::string NodeTitle ) {
1543
1544 if( attrVal == "" ) {
1545 std::cout << "Error: In " << NodeTitle
1546 << " Expected either 'True' or 'False' but found empty" << std::endl;
1547 throw hf_exc();
1548 }
1549 else if ( attrVal == "True" || attrVal == "true" ) return true;
1550 else if ( attrVal == "False" || attrVal == "false" ) return false;
1551 else {
1552 std::cout << "Error: In " << NodeTitle
1553 << " Expected either 'True' or 'False' but found: " << attrVal << std::endl;
1554 throw hf_exc();
1555 }
1556
1557 return false;
1558
1559}
1560
1561//ConfigParser
#define e(i)
Definition: RSha256.hxx:103
static RooMathCoreReg dummy
int Int_t
Definition: RtypesCore.h:41
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
TODO Here, we are missing some documentation.
Definition: Asimov.h:23
std::string GetName()
Definition: Asimov.h:32
void SetName(const std::string &name)
Definition: Asimov.h:33
This class encapsulates all information for the statistical interpretation of one experiment.
Definition: Channel.h:26
std::string GetInputFile()
get name of input file
Definition: Channel.h:43
void SetName(const std::string &Name)
set name of channel
Definition: Channel.h:37
std::string GetHistoPath()
get path to histograms in input file
Definition: Channel.h:47
void Print(std::ostream &=std::cout)
Definition: Channel.cxx:73
void AddAdditionalData(const RooStats::HistFactory::Data &data)
add additional data object
Definition: Channel.h:58
void SetData(const RooStats::HistFactory::Data &data)
set data object
Definition: Channel.h:50
void SetInputFile(const std::string &file)
set name of input file containing histograms
Definition: Channel.h:41
std::string GetName()
get name of channel
Definition: Channel.h:39
void SetStatErrorConfig(double RelErrorThreshold, Constraint::Type ConstraintType)
Definition: Channel.cxx:201
std::vector< RooStats::HistFactory::Sample > & GetSamples()
get vector of samples for this channel
Definition: Channel.h:71
void SetHistoPath(const std::string &file)
set path for histograms in input file
Definition: Channel.h:45
bool IsAcceptableNode(TXMLNode *functionNode)
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.
Definition: ConfigParser.h:64
HistFactory::ShapeFactor MakeShapeFactor(TXMLNode *node)
bool CheckTrueFalse(std::string val, std::string Name)
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)
RooStats::HistFactory::Channel ParseChannelXMLFile(std::string filen)
HistFactory::ShapeSys MakeShapeSys(TXMLNode *node)
HistFactory::NormFactor MakeNormFactor(TXMLNode *node)
Helpers used when processing a Sample.
std::string GetName()
Definition: Data.h:33
void SetInputFile(const std::string &InputFile)
Definition: Data.h:36
std::string GetInputFile()
Definition: Data.h:37
void SetHistoPath(const std::string &HistoPath)
Definition: Data.h:42
void SetName(const std::string &name)
Definition: Data.h:34
std::string GetHistoName()
Definition: Data.h:40
void SetHistoName(const std::string &HistoName)
Definition: Data.h:39
std::string GetHistoPath()
Definition: Data.h:43
Configuration for an *un*constrained, coherent shape variation of affected samples.
Definition: Systematics.h:215
Configuration for a constrained, coherent shape variation of affected samples.
Definition: Systematics.h:205
void SetInputFileHigh(const std::string &InputFileHigh)
Definition: Systematics.h:166
void SetName(const std::string &Name)
Definition: Systematics.h:162
void SetHistoPathHigh(const std::string &HistoPathHigh)
Definition: Systematics.h:178
void SetInputFileLow(const std::string &InputFileLow)
Definition: Systematics.h:165
const std::string & GetHistoNameHigh() const
Definition: Systematics.h:175
const std::string & GetHistoNameLow() const
Definition: Systematics.h:174
void SetHistoNameHigh(const std::string &HistoNameHigh)
Definition: Systematics.h:172
void SetHistoNameLow(const std::string &HistoNameLow)
Definition: Systematics.h:171
virtual void Print(std::ostream &=std::cout) const
Definition: Systematics.cxx:95
const std::string & GetInputFileHigh() const
Definition: Systematics.h:169
const std::string & GetInputFileLow() const
Definition: Systematics.h:168
void SetHistoPathLow(const std::string &HistoPathLow)
Definition: Systematics.h:177
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
Definition: Measurement.h:30
std::map< std::string, double > & GetGammaSyst()
Definition: Measurement.h:121
std::map< std::string, double > & GetLogNormSyst()
Definition: Measurement.h:123
std::map< std::string, double > & GetNoSyst()
Definition: Measurement.h:124
void SetExportOnly(bool ExportOnly)
do not produce any plots or tables, just save the model
Definition: Measurement.h:98
std::vector< std::string > & GetPOIList()
get vector of PoI names
Definition: Measurement.h:51
void SetLumi(double Lumi)
set integrated luminosity used to normalise histograms (if NormalizeByTheory is true for this sample)
Definition: Measurement.h:84
void SetParamValue(const std::string &param, double value)
Set a parameter to a specific value (And optionally fix it)
Definition: Measurement.cxx:86
std::map< std::string, double > & GetUniformSyst()
Definition: Measurement.h:122
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
Definition: Measurement.h:60
void SetOutputFilePrefix(const std::string &prefix)
set output prefix
Definition: Measurement.h:40
void PrintTree(std::ostream &=std::cout)
Print information about measurement object in tree-like structure to given stream.
std::vector< RooStats::HistFactory::Channel > & GetChannels()
Definition: Measurement.h:105
void SetLumiRelErr(double RelErr)
set relative uncertainty on luminosity
Definition: Measurement.h:86
void AddAsimovDataset(RooStats::HistFactory::Asimov dataset)
add an Asimov Dataset
Definition: Measurement.h:81
Configuration for an un- constrained overall systematic to scale sample normalisations.
Definition: Systematics.h:77
std::string GetName() const
Definition: Systematics.h:84
void Print(std::ostream &=std::cout) const
Definition: Systematics.cxx:61
void SetConst(bool Const=true)
Definition: Systematics.h:89
void SetName(const std::string &Name)
Definition: Systematics.h:83
Configuration for a constrained overall systematic to scale sample normalisations.
Definition: Systematics.h:49
std::string GetName() const
Definition: Systematics.h:56
void SetName(const std::string &Name)
Definition: Systematics.h:55
void Print(std::ostream &=std::cout) const
Definition: Systematics.cxx:80
std::string GetCommand(std::string Name, std::string Expression, std::string Dependents)
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
Definition: Sample.h:109
std::string GetHistoName() const
get histogram name
Definition: Sample.h:93
void SetStatError(RooStats::HistFactory::StatError Error)
Definition: Sample.h:119
std::string GetName() const
get name of sample
Definition: Sample.h:83
void SetInputFile(const std::string &InputFile)
set input ROOT file
Definition: Sample.h:90
void SetChannelName(const std::string &ChannelName)
set name of associated channel
Definition: Sample.h:105
void SetHistoName(const std::string &HistoName)
set histogram name
Definition: Sample.h:95
std::string GetHistoPath() const
get histogram path
Definition: Sample.h:98
void SetNormalizeByTheory(bool norm)
defines whether the normalization scale with luminosity
Definition: Sample.h:77
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
Definition: Sample.h:116
void SetName(const std::string &Name)
set name of sample
Definition: Sample.h:85
void SetHistoPath(const std::string &HistoPath)
set histogram path
Definition: Sample.h:100
std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList()
Definition: Sample.h:110
std::string GetInputFile() const
get input ROOT file
Definition: Sample.h:88
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
Definition: Sample.h:112
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
Definition: Sample.h:115
*Un*constrained bin-by-bin variation of affected histogram.
Definition: Systematics.h:267
void SetInputFile(const std::string &InputFile)
Definition: Systematics.h:290
void SetHistoName(const std::string &HistoName)
Definition: Systematics.h:296
void Print(std::ostream &=std::cout) const override
void SetConstant(bool constant)
Definition: Systematics.h:285
void SetHistoPath(const std::string &HistoPath)
Definition: Systematics.h:302
const std::string & GetHistoName() const
Definition: Systematics.h:300
Constrained bin-by-bin variation of affected histogram.
Definition: Systematics.h:225
std::string GetHistoName() const
Definition: Systematics.h:240
void SetInputFile(const std::string &InputFile)
Definition: Systematics.h:236
void Print(std::ostream &=std::cout) const override
void SetHistoName(const std::string &HistoName)
Definition: Systematics.h:239
void SetConstraintType(Constraint::Type ConstrType)
Definition: Systematics.h:256
std::string GetInputFile() const
Definition: Systematics.h:237
void SetHistoPath(const std::string &HistoPath)
Definition: Systematics.h:242
Configuration to automatically assign nuisance parameters for the statistical error of the Monte Carl...
Definition: Systematics.h:367
void SetConstraintType(Constraint::Type ConstrType)
Definition: Systematics.h:378
void SetRelErrorThreshold(double Threshold)
Definition: Systematics.h:375
Constraint::Type GetConstraintType() const
Definition: Systematics.h:379
Statistical error of Monte Carlo predictions.
Definition: Systematics.h:321
const std::string & GetHistoPath() const
Definition: Systematics.h:346
void Activate(bool IsActive=true)
Definition: Systematics.h:333
void SetHistoPath(const std::string &HistoPath)
Definition: Systematics.h:345
void SetInputFile(const std::string &InputFile)
Definition: Systematics.h:339
const std::string & GetInputFile() const
Definition: Systematics.h:340
void SetHistoName(const std::string &HistoName)
Definition: Systematics.h:342
const std::string & GetHistoName() const
Definition: Systematics.h:343
void SetUseHisto(bool UseHisto=true)
Definition: Systematics.h:336
void Print(std::ostream &=std::cout) const override
virtual TXMLDocument * GetXMLDocument() const
Returns the TXMLDocument.
Definition: TDOMParser.cxx:144
virtual Int_t ParseFile(const char *filename)
Parse the XML file where filename is the XML file name.
Definition: TDOMParser.cxx:70
Iterator of linked list.
Definition: TList.h:200
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
Basic string class.
Definition: TString.h:131
TXMLAttribute is the attribute of an Element.
Definition: TXMLAttr.h:18
const char * GetValue() const
Definition: TXMLAttr.h:33
const char * GetName() const
Returns name of object.
Definition: TXMLAttr.h:31
TXMLDocument contains a pointer to an xmlDoc structure, after the parser returns a tree built during ...
Definition: TXMLDocument.h:24
TXMLNode * GetRootNode() const
Returns the root element node.
TXMLNode contains a pointer to xmlNode, which is a node under the DOM tree.
Definition: TXMLNode.h:22
TList * GetAttributes()
Returns a list of node's attribute if any, returns 0 if no attribute.
Definition: TXMLNode.cxx:108
const char * GetText() const
Returns the content of a Text node if node is a TextNode, 0 otherwise.
Definition: TXMLNode.cxx:154
TXMLNode * GetNextNode()
Returns the next sibling XMLNode in the DOM tree, if any return 0 if no next node.
Definition: TXMLNode.cxx:130
TXMLNode * GetChildren()
Returns the node's child if any, returns 0 if no child.
Definition: TXMLNode.cxx:74
const char * GetNodeName() const
Returns the node's name.
Definition: TXMLNode.cxx:66
void AddSubStrings(vector< std::string > &vs, std::string s)
Definition: Helper.cxx:165
std::vector< std::string > GetChildrenFromString(std::string str)
Definition: Helper.cxx:179
void AddParamsToAsimov(RooStats::HistFactory::Asimov &asimov, std::string str)
Definition: Helper.cxx:199
Namespace for the RooStats classes.
Definition: Asimov.h:20
const char * Name
Definition: TXMLSetup.cxx:66