Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
23#include "HFMsgService.h"
24#include "hist2workspaceCommandLineOptionsHelp.h"
25
26namespace RooStats {
27 namespace HistFactory {
28 void fastDriver(std::string const& input, HistoToWorkspaceFactoryFast::Configuration const& cfg) {
29
30 // Create the initial list of measurements and channels
31 std::vector< HistFactory::Measurement > measurement_list;
32 // std::vector< HistFactory::Channel > channel_list;
33
34 // Fill them using the XML parser
36 measurement_list = xmlParser.GetMeasurementsFromXML( input );
37
38 // At this point, we have all the information we need
39 // from the xml files.
40
41 // We will make the measurements 1-by-1
42 for(unsigned int i = 0; i < measurement_list.size(); ++i) {
43 HistFactory::Measurement measurement = measurement_list.at(i);
44 measurement.CollectHistograms();
45 MakeModelAndMeasurementFast(measurement, cfg);
46 }
47
48 return;
49
50 }
51 } // namespace RooStats
52} // namespace HistFactory
53
54/**
55 * \ingroup HistFactory
56 * main function of the hist2workspace executable.
57 * It creates RooFit models from an xml config and files with histograms.
58 * See MakeModelAndMeasurementFast(), for further instructions.
59 * \param[in] argc number of CLI arguments
60 * \param[in] argv pointer to arguments
61 *
62 * -h Help
63 * -v Switch HistFactory message stream to INFO level.
64 * -vv Switch HistFactory message stream to DEBUG level.
65 * -disable_binned_fit_optimization Disable the binned fit optimization used in HistFactory since ROOT 6.28.
66 */
67int main(int argc, char** argv) {
68
69 if( !(argc > 1) ) {
70 std::cerr << "need input file" << std::endl;
71 exit(1);
72 }
73
74 //Switch off ROOT histogram memory management
75 gROOT->SetMustClean(false);
77 cxcoutIHF << "hist2workspace is less verbose now. Use -v and -vv for more details." << std::endl;
81
82 std::string driverArg;
84
85 for (int i=1; i < argc; ++i) {
86 std::string input = argv[i];
87
88 if (input == "-h" || input == "--help"){
89 fprintf(stderr, kCommandLineOptionsHelp);
90 return 0;
91 }
92
93 if (input == "-v") {
96 continue;
97 }
98
99 if (input == "-vv") {
102 continue;
103 }
104
105 if(input == "-disable_binned_fit_optimization") {
106 cfg.binnedFitOptimization = false;
107 continue;
108 }
109
110 driverArg = argv[i];
111 }
112
113 RooStats::HistFactory::fastDriver(driverArg, cfg);
114
115 return 0;
116}
int main()
Definition Prototype.cxx:12
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
#define gROOT
Definition TROOT.h:406
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
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:31
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.
void fastDriver(std::string const &input, HistoToWorkspaceFactoryFast::Configuration const &cfg)
RooFit::OwningPtr< RooWorkspace > MakeModelAndMeasurementFast(RooStats::HistFactory::Measurement &measurement, HistoToWorkspaceFactoryFast::Configuration const &cfg={})
Namespace for the RooStats classes.
Definition Asimov.h:19
void addTopic(RooFit::MsgTopic newTopic)