Logo ROOT   6.18/05
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#include <TROOT.h>
20
21//void topDriver(string input); // in MakeModelAndMeasurements
22//void fastDriver(string input); // in MakeModelAndMeasurementsFast
23
24//#include "RooStats/HistFactory/MakeModelAndMeasurements.h"
27#include "hist2workspaceCommandLineOptionsHelp.h"
28
29//_____________________________batch only_____________________
30#ifndef __CINT__
31
32namespace RooStats {
33 namespace HistFactory {
34 void fastDriver(std::string input) {
35
36 // Create the initial list of measurements and channels
37 std::vector< HistFactory::Measurement > measurement_list;
38 // std::vector< HistFactory::Channel > channel_list;
39
40 // Fill them using the XML parser
42 measurement_list = xmlParser.GetMeasurementsFromXML( input );
43
44 // At this point, we have all the information we need
45 // from the xml files.
46
47 // We will make the measurements 1-by-1
48 for(unsigned int i = 0; i < measurement_list.size(); ++i) {
49 HistFactory::Measurement measurement = measurement_list.at(i);
50 measurement.CollectHistograms();
51 MakeModelAndMeasurementFast( measurement );
52 }
53
54 return;
55
56 }
57 } // namespace RooStats
58} // namespace HistFactory
59
60/**
61 * \ingroup HistFactory
62 * main function of the hist2workspace executable.
63 * It creates RooFit models from an xml config and files with histograms.
64 * See MakeModelAndMeasurementFast(), for further instructions.
65 * \param[in] -h Help
66 * \param[in] -standard_form Standard xml model definitions. See MakeModelAndMeasurementFast()
67 * \param[in] -number_counting_form Deprecated
68 */
69int main(int argc, char** argv) {
70
71 if( !(argc > 1) ) {
72 std::cerr << "need input file" << std::endl;
73 exit(1);
74 }
75
76 //Switch off ROOT histogram memory management
77 gROOT->SetMustClean(false);
79
80 if(argc==2){
81 std::string input(argv[1]);
82 if ( input == "-h" || input == "--help"){
83 fprintf(stderr, kCommandLineOptionsHelp);
84 return 0;
85 }
86 else{
87 try {
89 }
90 catch(const std::string &str) {
91 std::cerr << "hist2workspace - Caught exception: " << str << std::endl ;
92 exit(1);
93 }
94 catch( const std::exception& e ) {
95 std::cerr << "hist2workspace - Caught Exception: " << e.what() << std::endl;
96 exit(1);
97 }
98 catch(...) {
99 exit(1);
100 }
101 }
102 }
103
104 if(argc==3){
105 std::string flag(argv[1]);
106 std::string input(argv[2]);
107
108 if(flag=="-standard_form") {
109 try {
111 }
112 catch(const std::string &str) {
113 std::cerr << "hist2workspace - Caught exception: " << str << std::endl ;
114 exit(1);
115 }
116 catch( const std::exception& e ) {
117 std::cerr << "hist2workspace - Caught Exception: " << e.what() << std::endl;
118 exit(1);
119 }
120 catch(...) {
121 std::cerr << "hist2workspace - Caught Exception" << std::endl;
122 exit(1);
123 }
124 }
125
126 else if(flag=="-number_counting_form") {
127 std::cout << "ERROR: 'number_counting_form' is now deprecated." << std::endl;
128 /*
129 try {
130 //topDriver(input);
131 }
132 catch (std::string str) {
133 std::cerr << "caught exception: " << str << std::endl ;
134 }
135 catch( const std::exception& e ) {
136 std::cerr << "Caught Exception: " << e.what() << std::endl;
137 }
138 */
139 return 255;
140 }
141
142 else {
143 std::cerr << "Unrecognized flag. " << std::endl;
144 return 255;
145 }
146 }
147
148 return 0;
149
150}
151
152#endif
#define e(i)
Definition: RSha256.hxx:103
#define gROOT
Definition: TROOT.h:414
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
void CollectHistograms()
The most common way to add histograms to channels is to have them stored in ROOT files and to give Hi...
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add objects like histograms, TGraph2D, etc in memory.
Definition: TDirectory.cxx:171
int main(int argc, char **argv)
main function of the hist2workspace executable.
RooWorkspace * MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement &measurement)
void fastDriver(std::string input)
Namespace for the RooStats classes.
Definition: Asimov.h:20