-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPUWeight.h
82 lines (59 loc) · 2.26 KB
/
PUWeight.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
///////////////////////////////////////////////////////////////////////
//
// FILE: PUWeight.h
// CLASS: PUWeight
// AUTHORS: I. Gonzalez Caballero
// DATE: 09/03/2011
//
// CONTENT: An utility class to weight the events according to the real
// data pile up with respect to the generated pileup.
//
///////////////////////////////////////////////////////////////////////
#ifndef PUWEIGHT_H
#define PUWEIGHT_H
#include "TH1F.h"
#include "TNamed.h"
#include "TFile.h"
#include <cstdlib>
#include <iostream>
class PUWeight {
public:
PUWeight(float luminosity = -1, const char* year="2011A", const std::string& idealMCPU="Spring11_Flat10");
PUWeight(const char* mcfolder, const char* mcproccess,
float luminosity = -1, const char* year="2011A");
~PUWeight() {delete fWeight; delete fMC; delete fData;}
//// Tells if this object has loaded correctly the histograms
//bool IsValid() const { return fWeight;}
// Returns the weight for a given PU value
float GetWeight(unsigned int pu) const;
// Returns the MC only weight for a given PU value
float GetPUMC(unsigned int pu) const {
return (fMC? fMC->GetBinContent(pu+1):0);
}
// Returns the Data only weight for a given PU value
float GetPUData(unsigned int pu) const {
return (fData? fData->GetBinContent(pu+1):0);
}
// Get the histogram with the weights
TH1F* GetWeightsHisto() const {return (TH1F*)fWeight->Clone();}
// Get the histogram with the profile for Data
TH1F* GetDataHisto() const {return (TH1F*)fData->Clone();}
// Get the histogram with the profile for MC
TH1F* GetMCHisto() const {return (TH1F*)fMC->Clone();}
void SetMCHistogram(const TH1F* mcHisto);
void SetDataHistogram(const TH1F* dataHisto);
protected:
// Build the PU ideal profile for MC
TH1F* IdealMCHistogram( const std::string & puType="Spring11_Flat10");
// Load the PU profile for MC
TH1F* LoadMCHistogram(const char* mcfolder, const char* mcproccess);
// Load the PU profile for Data
TH1F* LoadDataHistogram(float luminosity, const char* year="2011A");
// Divide the Data profile by the MC profile
TH1F* CalculateWeight();
protected:
TH1F* fData; //PU profile for data
TH1F* fMC; //PU profile for MC
TH1F* fWeight; //Histogram with the weight content
};
#endif