ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/AnalysisFramework/Plotting/Modules/HistoDB.C
Revision: 1.2
Committed: Wed Jul 20 08:54:02 2011 UTC (13 years, 9 months ago) by buchmann
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Error occurred while calculating annotation data.
Log Message:
Removing skeleton of the advanced histo class as it is outdated

File Contents

# Content
1 #include <iostream>
2 #include <sstream>
3 #include <string>
4 #include <vector>
5 #include <TH1.h>
6 #include <TCut.h>
7 #ifndef SampleClassLoaded
8 #include "SampleClass.C"
9 #endif
10 #ifndef GeneralToolBoxLoaded
11 #include "GeneralToolBox.C"
12 #endif
13 #define HistoDBLoaded
14
15 using namespace std;
16
17
18 class HistoDB
19 {
20 public:
21 std::string histoname;
22 int nbins;
23
24 float minx;
25 float maxx;
26 string xlabel;
27 string ylabel;
28 string cut;
29 string variable;
30 bool is_data;
31 float luminosity;
32 TH1F *histo;
33 vector<string> used_samples;
34 vector<TH1F*> comphisto;
35 // void FillInfo(string m_histoname,string var, int nbins, float minx, float maxx, string xlabel, string ylabel, string cut, bool is_data, vector<sample> &samples, float luminosity);
36 HistoDB(string m_histoname,string var, int nbins, float minx, float maxx, string xlabel, string ylabel, TCut Cut, bool is_data, vector<sample> &samples, float luminosity);
37 void fillHisto(vector<sample> &samples);
38 };
39
40 HistoDB::HistoDB(string m_histoname,string m_var, int m_nbins, float m_minx, float m_maxx, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, vector<sample> &samples, float luminosity)
41 {
42 string realcut = (const char*)Cut;
43 cout << "We are constructing an object with histoname " << m_histoname << endl;
44 stringstream h_histoname;
45 h_histoname<<"h_"<<m_histoname;
46 this->histoname=h_histoname.str();
47 this->nbins=m_nbins;
48 this->minx=m_minx;
49 this->maxx=m_maxx;
50 this->xlabel=m_xlabel;
51 this->ylabel=m_ylabel;
52 this->cut=realcut;
53 this->is_data=m_is_data;
54 this->histo = new TH1F(histoname.c_str(),"",m_nbins,minx,maxx);
55 this->variable=m_var;
56 this->fillHisto(samples);
57 cout << "Generated histo " << this->histoname << " for the variable " << this->variable << " with integral " << this->histo->Integral() << endl;
58 (this->histo)->Draw();
59 (this->histo)->GetXaxis()->SetTitle(m_xlabel.c_str());
60 (this->histo)->GetYaxis()->SetTitle(m_ylabel.c_str());
61 (this->histo)->GetXaxis()->CenterTitle();
62 (this->histo)->GetYaxis()->CenterTitle();
63 }
64
65
66 void HistoDB::fillHisto(vector<sample> &samples)
67 {
68
69 cout << "Going to fill the histogram called " << histo->GetName() << " with the variable " << variable << " and cut " << cut << endl;
70
71 stringstream drawthis;
72 drawthis<<this->variable<<">>tempdrawhisto";
73 for (unsigned int isample=0;isample<samples.size();isample++)
74 {
75 TH1F *tempdrawhisto = new TH1F("tempdrawhisto","tempdrawhisto",this->nbins,this->minx,this->maxx);
76 if(samples[isample].is_data==this->is_data) {//fills mc if we want mc, else fills data.
77 cout << "Considering " << samples[isample].filename << " with weight " << samples[isample].weight << endl;
78 /*
79 samples[isample].events->Draw(drawthis.str().c_str(),this->cut.c_str());
80 if(!this->is_data) tempdrawhisto->Scale(1000*samples[isample].weight);
81 (this->histo)->Add(tempdrawhisto);
82 // (this->comphisto).push_back(tempdrawhisto);
83 // (this->used_samples).push_back(samples[isample].filename);
84 */
85 }
86 delete tempdrawhisto;
87 }
88
89 }
90
91