Logo ROOT   6.16/01
Reference Guide
hist2workspace.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Kyle Cranmer, George Lewis
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
13
14
15#include <string>
16#include <exception>
17#include <vector>
18
19//void topDriver(string input); // in MakeModelAndMeasurements
20//void fastDriver(string input); // in MakeModelAndMeasurementsFast
21
22//#include "RooStats/HistFactory/MakeModelAndMeasurements.h"
25
26//_____________________________batch only_____________________
27#ifndef __CINT__
28
29namespace RooStats {
30 namespace HistFactory {
31 void fastDriver(std::string input) {
32
33 // Create the initial list of measurements and channels
34 std::vector< HistFactory::Measurement > measurement_list;
35 // std::vector< HistFactory::Channel > channel_list;
36
37 // Fill them using the XML parser
39 measurement_list = xmlParser.GetMeasurementsFromXML( input );
40
41 // At this point, we have all the information we need
42 // from the xml files.
43
44 // We will make the measurements 1-by-1
45 for(unsigned int i = 0; i < measurement_list.size(); ++i) {
46 HistFactory::Measurement measurement = measurement_list.at(i);
47 measurement.CollectHistograms();
48 MakeModelAndMeasurementFast( measurement );
49 }
50
51 return;
52
53 }
54 } // namespace RooStats
55} // namespace HistFactory
56
57/**
58 * \ingroup HistFactory
59 * hist2workspace executable main function to create RooFit models from an xml config and files with histograms.
60 */
61int main(int argc, char** argv) {
62
63 if( !(argc > 1) ) {
64 std::cerr << "need input file" << std::endl;
65 exit(1);
66 }
67
68 if(argc==2){
69 std::string input(argv[1]);
70 try {
72 }
73 catch(const std::string &str) {
74 std::cerr << "hist2workspace - Caught exception: " << str << std::endl ;
75 exit(1);
76 }
77 catch( const std::exception& e ) {
78 std::cerr << "hist2workspace - Caught Exception: " << e.what() << std::endl;
79 exit(1);
80 }
81 catch(...) {
82 exit(1);
83 }
84 }
85
86 if(argc==3){
87 std::string flag(argv[1]);
88 std::string input(argv[2]);
89
90 if(flag=="-standard_form") {
91 try {
93 }
94 catch(const std::string &str) {
95 std::cerr << "hist2workspace - Caught exception: " << str << std::endl ;
96 exit(1);
97 }
98 catch( const std::exception& e ) {
99 std::cerr << "hist2workspace - Caught Exception: " << e.what() << std::endl;
100 exit(1);
101 }
102 catch(...) {
103 std::cerr << "hist2workspace - Caught Exception" << std::endl;
104 exit(1);
105 }
106 }
107
108 else if(flag=="-number_counting_form") {
109 std::cout << "ERROR: 'number_counting_form' is now deprecated." << std::endl;
110 /*
111 try {
112 //topDriver(input);
113 }
114 catch (std::string str) {
115 std::cerr << "caught exception: " << str << std::endl ;
116 }
117 catch( const std::exception& e ) {
118 std::cerr << "Caught Exception: " << e.what() << std::endl;
119 }
120 */
121 return 255;
122 }
123
124 else {
125 std::cerr << "Unrecognized flag. " << std::endl;
126 return 255;
127 }
128 }
129
130 return 0;
131
132}
133
134#endif
#define e(i)
Definition: RSha256.hxx:103
TODO Add documentation.
Definition: ConfigParser.h:32
std::vector< RooStats::HistFactory::Measurement > GetMeasurementsFromXML(std::string input)
The "main" method.
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
Definition: Measurement.h:30
int main(int argc, char **argv)
hist2workspace executable main function to create RooFit models from an xml config and files with his...
void fastDriver(std::string input)
RooWorkspace * MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement &measurement)
Make a model from histograms.
@(#)root/roostats:$Id$ Author: George Lewis, Kyle Cranmer
Definition: Asimov.h:20