Logo ROOT  
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 "HFMsgService.h"
28#include "hist2workspaceCommandLineOptionsHelp.h"
29
30//_____________________________batch only_____________________
31#ifndef __CINT__
32
33namespace RooStats {
34 namespace HistFactory {
35 void fastDriver(std::string input) {
36
37 // Create the initial list of measurements and channels
38 std::vector< HistFactory::Measurement > measurement_list;
39 // std::vector< HistFactory::Channel > channel_list;
40
41 // Fill them using the XML parser
43 measurement_list = xmlParser.GetMeasurementsFromXML( input );
44
45 // At this point, we have all the information we need
46 // from the xml files.
47
48 // We will make the measurements 1-by-1
49 for(unsigned int i = 0; i < measurement_list.size(); ++i) {
50 HistFactory::Measurement measurement = measurement_list.at(i);
51 measurement.CollectHistograms();
52 MakeModelAndMeasurementFast( measurement );
53 }
54
55 return;
56
57 }
58 } // namespace RooStats
59} // namespace HistFactory
60
61/**
62 * \ingroup HistFactory
63 * main function of the hist2workspace executable.
64 * It creates RooFit models from an xml config and files with histograms.
65 * See MakeModelAndMeasurementFast(), for further instructions.
66 * \param[in] -h Help
67 * \param[in] -standard_form Standard xml model definitions. See MakeModelAndMeasurementFast()
68 * \param[in] -number_counting_form Deprecated
69 * \param[in] -v Switch HistFactory message stream to INFO level.
70 * \param[in] -vv Switch HistFactory message stream to DEBUG level.
71 */
72int main(int argc, char** argv) {
73
74 if( !(argc > 1) ) {
75 std::cerr << "need input file" << std::endl;
76 exit(1);
77 }
78
79 //Switch off ROOT histogram memory management
80 gROOT->SetMustClean(false);
82 cxcoutIHF << "hist2workspace is less verbose now. Use -v and -vv for more details." << std::endl;
86
87 std::string driverArg;
88
89 for (int i=1; i < argc; ++i) {
90 std::string input = argv[i];
91
92 if (input == "-h" || input == "--help"){
93 fprintf(stderr, kCommandLineOptionsHelp);
94 return 0;
95 }
96
97 if (input == "-v") {
100 continue;
101 }
102
103 if (input == "-vv") {
106 continue;
107 }
108
109 if (input == "-number_counting_form") {
110 std::cout << "ERROR: 'number_counting_form' is now deprecated." << std::endl;
111 return 255;
112 }
113
114 if(input == "-standard_form") {
115 driverArg = argv[++i];
116 continue;
117 }
118
119 driverArg = argv[i];
120 }
121
122 try {
124 }
125 catch(const std::string &str) {
126 std::cerr << "hist2workspace - Caught exception: " << str << std::endl ;
127 return 1;
128 }
129 catch( const std::exception& e ) {
130 std::cerr << "hist2workspace - Caught Exception: " << e.what() << std::endl;
131 return 1;
132 }
133 catch(...) {
134 std::cerr << "hist2workspace - Caught Exception" << std::endl;
135 return 1;
136 }
137
138
139 return 0;
140}
141
142#endif
#define cxcoutIHF
Definition: HFMsgService.h:17
#define e(i)
Definition: RSha256.hxx:103
#define gROOT
Definition: TROOT.h:404
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
TODO Add documentation.
Definition: ConfigParser.h:30
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:172
int main(int argc, char **argv)
main function of the hist2workspace executable.
RooWorkspace * MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement &measurement)
@ HistFactory
Definition: RooGlobalFunc.h:62
void fastDriver(std::string input)
Namespace for the RooStats classes.
Definition: Asimov.h:19
void addTopic(RooFit::MsgTopic newTopic)