ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/IPHCalignment2/analysis/Layout.h
Revision: 1.6
Committed: Tue Nov 29 11:01:00 2011 UTC (13 years, 5 months ago) by econte
Content type: text/plain
Branch: MAIN
CVS Tags: TBD2011, HEAD
Changes since 1.5: +14 -14 lines
Log Message:
Chris' bug fix

File Contents

# User Rev Content
1 econte 1.1 #ifndef Layout_h
2     #define Layout_h
3    
4     #include <TROOT.h>
5     #include <TH1F.h>
6     #include <TCanvas.h>
7     #include <TLegend.h>
8     #include <THStack.h>
9     #include <TColor.h>
10    
11     #include <vector>
12     #include <string>
13     #include <sstream>
14    
15    
16     #include "histoAlgo.h"
17    
18    
19     class Layout
20     {
21     public:
22     Layout() { counter_=0;}
23     ~Layout() {}
24    
25 econte 1.6 void Draw(const std::string title, const std::vector<HistoBlock>& histos,
26 econte 1.3 const std::string& xlabel, bool fit, float K, float MU, float SIG);
27 econte 1.6 void Draw(const std::string title, const HistoBlock& histo1,
28 econte 1.3 const std::string& xlabel, bool fit=false, float K=0, float MU=0, float SIG=0)
29 econte 1.2 {
30     std::vector<HistoBlock> histos(1);
31     histos[0]=histo1;
32 econte 1.6 Draw(title,histos,xlabel,fit,K,MU,SIG);
33 econte 1.2 }
34    
35 econte 1.6 void Draw(const std::string title, const HistoBlock& histo1, const HistoBlock& histo2,
36 econte 1.3 const std::string& xlabel, bool fit=false, float K=0, float MU=0, float SIG=0)
37 econte 1.2 {
38     std::vector<HistoBlock> histos(2);
39     histos[0]=histo1;
40     histos[1]=histo2;
41 econte 1.6 Draw(title,histos,xlabel,fit,K,MU,SIG);
42 econte 1.2 }
43    
44 econte 1.6 void Draw(const std::string title, const HistoBlock& histo1,const HistoBlock& histo2,const HistoBlock& histo3,
45 econte 1.3 const std::string& xlabel, bool fit=false, float K=0, float MU=0, float SIG=0)
46 econte 1.2 {
47     std::vector<HistoBlock> histos(3);
48     histos[0]=histo1;
49     histos[1]=histo2;
50     histos[2]=histo3;
51 econte 1.6 Draw(title,histos,xlabel,fit,K,MU,SIG);
52 econte 1.2 }
53    
54 econte 1.6 void Draw(const std::string title, const HistoBlock& histo1, const HistoBlock& histo2,
55 econte 1.2 const HistoBlock& histo3, const HistoBlock& histo4,
56 econte 1.3 const std::string& xlabel, bool fit=false, float K=0, float MU=0, float SIG=0)
57 econte 1.2 {
58     std::vector<HistoBlock> histos(4);
59     histos[0]=histo1;
60     histos[1]=histo2;
61     histos[2]=histo3;
62     histos[3]=histo4;
63 econte 1.6 Draw(title,histos,xlabel,fit,K,MU,SIG);
64 econte 1.2 }
65    
66 econte 1.6 void Draw(const std::string title, const HistoBlock& histo1, const HistoBlock& histo2,
67 econte 1.4 const HistoBlock& histo3, const HistoBlock& histo4,
68     const HistoBlock& histo5,
69     const std::string& xlabel, bool fit=false, float K=0, float MU=0, float SIG=0)
70     {
71     std::vector<HistoBlock> histos(5);
72     histos[0]=histo1;
73     histos[1]=histo2;
74     histos[2]=histo3;
75     histos[3]=histo4;
76     histos[4]=histo5;
77 econte 1.6 Draw(title,histos,xlabel,fit,K,MU,SIG);
78 econte 1.4 }
79    
80 econte 1.6 void Draw(const std::string title, const HistoBlock& histo1, const HistoBlock& histo2,
81 econte 1.4 const HistoBlock& histo3, const HistoBlock& histo4,
82     const HistoBlock& histo5, const HistoBlock& histo6,
83     const std::string& xlabel, bool fit=false, float K=0, float MU=0, float SIG=0)
84     {
85 econte 1.6 std::vector<HistoBlock> histos(6);
86 econte 1.4 histos[0]=histo1;
87     histos[1]=histo2;
88     histos[2]=histo3;
89     histos[3]=histo4;
90     histos[4]=histo5;
91     histos[5]=histo6;
92 econte 1.6 Draw(title,histos,xlabel,fit,K,MU,SIG);
93 econte 1.4 }
94    
95 econte 1.1 void DrawInit();
96    
97     private:
98    
99     unsigned int counter_;
100    
101     // Give a unique string (for ROOT name object)
102     std::string dummy()
103     {
104     counter_++;
105     std::stringstream str;
106     str << counter_;
107     return "dummy_"+str.str();
108     }
109    
110     // Some change to be sure that the string could be a filename
111     std::string GetFileName(std::string name)
112     {
113     for (unsigned int i=0;i<name.size();i++)
114     {
115 econte 1.2 if (name[i]=='^') name[i]='_';
116     else if (name[i]=='{') name[i]='_';
117     else if (name[i]=='}') name[i]='_';
118     else if (name[i]=='(') name[i]='_';
119     else if (name[i]==')') name[i]='_';
120     else if (name[i]==' ') name[i]='_';
121     else if (name[i]=='*') name[i]='_';
122     else if (name[i]=='/') name[i]='_';
123     else if (name[i]=='\\') name[i]='_';
124     else if (name[i]=='#') name[i]='_';
125 econte 1.5 else if (name[i]=='+') name[i]='p';
126     else if (name[i]=='-') name[i]='m';
127     }
128 econte 1.1 return name;
129     }
130    
131     };
132    
133     #endif
134