File indexing completed on 2024-04-06 12:24:22
0001
0002
0003
0004
0005 #include <TF1.h>
0006 #include <TFile.h>
0007 #include <TH1F.h>
0008 #include <TCanvas.h>
0009
0010
0011 void Reweight_Gen() {
0012
0013 TH1F* PU_intended = new TH1F("PU_intended","Intended pileup distribution (i.e. Data)",25,-0.5,24.5);
0014 TH1F* PU_generated = new TH1F("PU_generated","Generated pileup distribution (i.e., MC)",25,-0.5,24.5);
0015
0016
0017 double x;
0018
0019
0020
0021 Double_t probdistFlat10[25] = {
0022 0.0698146584,
0023 0.0698146584,
0024 0.0698146584,
0025 0.0698146584,
0026 0.0698146584,
0027 0.0698146584,
0028 0.0698146584,
0029 0.0698146584,
0030 0.0698146584,
0031 0.0698146584,
0032 0.0698146584,
0033 0.0630151648,
0034 0.0526654164,
0035 0.0402754482,
0036 0.0292988928,
0037 0.0194384503,
0038 0.0122016783,
0039 0.007207042,
0040 0.004003637,
0041 0.0020278322,
0042 0.0010739954,
0043 0.0004595759,
0044 0.0002229748,
0045 0.0001028162,
0046 4.58337152809607E-05
0047 };
0048
0049
0050
0051 Double_t probdist_Lumpy[25] = {
0052 0.073050961,
0053 0.073282135,
0054 0.06588457,
0055 0.07120157,
0056 0.064497526,
0057 0.073513309,
0058 0.078136788,
0059 0.073050961,
0060 0.066809265,
0061 0.073050961,
0062 0.06588457,
0063 0.060105221,
0064 0.049702395,
0065 0.03352022,
0066 0.029821437,
0067 0.018725088,
0068 0.012483392,
0069 0.008322261,
0070 0.002774087,
0071 0.002774087,
0072 0.001849391,
0073 0.000870009,
0074 0.000372861,
0075 0.000211288,
0076 0.000105644,
0077 }
0078
0079
0080
0081 Double_t probdist_Lumpy2[25] = {
0082 0.0662635239567,
0083 0.0749768160742,
0084 0.0644551777434,
0085 0.0768663060278,
0086 0.0675077279753,
0087 0.0712751159196,
0088 0.0687384080371,
0089 0.0680486862442,
0090 0.064364374034,
0091 0.0756530139104,
0092 0.0686843122102,
0093 0.0662480680062,
0094 0.0544165378671,
0095 0.0318933539413,
0096 0.0268682380216,
0097 0.0193836939722,
0098 0.0162635239567,
0099 0.0112364760433,
0100 0.00311244204019,
0101 0.00312017001546,
0102 0.000624034003091,
0103 0.0004,
0104 0.0002,
0105 0.0001,
0106 0.00004
0107 };
0108
0109
0110
0111
0112 Double_t PoissonIntDist[25] = {
0113 0.104109,
0114 0.0703573,
0115 0.0698445,
0116 0.0698254,
0117 0.0697054,
0118 0.0697907,
0119 0.0696751,
0120 0.0694486,
0121 0.0680332,
0122 0.0651044,
0123 0.0598036,
0124 0.0527395,
0125 0.0439513,
0126 0.0352202,
0127 0.0266714,
0128 0.019411,
0129 0.0133974,
0130 0.00898536,
0131 0.0057516,
0132 0.00351493,
0133 0.00212087,
0134 0.00122891,
0135 0.00070592,
0136 0.000384744,
0137 0.000219377
0138 };
0139
0140
0141
0142 Double_t PoissonOneXDist[25] = {
0143 0.14551,
0144 0.0644453,
0145 0.0696412,
0146 0.0700311,
0147 0.0694257,
0148 0.0685655,
0149 0.0670929,
0150 0.0646049,
0151 0.0609383,
0152 0.0564597,
0153 0.0508014,
0154 0.0445226,
0155 0.0378796,
0156 0.0314746,
0157 0.0254139,
0158 0.0200091,
0159 0.0154191,
0160 0.0116242,
0161 0.00846857,
0162 0.00614328,
0163 0.00426355,
0164 0.00300632,
0165 0.00203485,
0166 0.00133045,
0167 0.000893794
0168 };
0169
0170
0171
0172 Double_t TrueDist2011[25] = {
0173 0.019091,
0174 0.0293974,
0175 0.0667931,
0176 0.108859,
0177 0.139533,
0178 0.149342,
0179 0.138629,
0180 0.114582,
0181 0.0859364,
0182 0.059324,
0183 0.0381123,
0184 0.0229881,
0185 0.0131129,
0186 0.00711764,
0187 0.00369635,
0188 0.00184543,
0189 0.000889604,
0190 0.000415683,
0191 0.000188921,
0192 0.000146288,
0193 0.0,
0194 0.0,
0195 0.0,
0196 0.0,
0197 0.0
0198 };
0199
0200
0201
0202 for (int i=1;i<26;i++) {
0203 PU_generated->SetBinContent(i,probdistFlat10[i-1]);
0204 PU_intended->SetBinContent(i,TrueDist2011[i-1]);
0205 }
0206
0207 TCanvas *can1 = new TCanvas("can1,","can1",1200,800);
0208 can1->Divide(2,2);
0209
0210 can1->cd(1);
0211 PU_generated->SetLineColor(kRed);
0212 PU_intended->SetLineColor(kBlue);
0213
0214 PU_intended->Draw();
0215 PU_generated->Draw("Same");
0216
0217
0218 can1->cd(2);
0219 PU_generated->Draw();
0220
0221
0222 can1->cd(3);
0223 PU_intended->DrawNormalized();
0224
0225 TCanvas *can2 = new TCanvas("can2,","can2",1200,800);
0226
0227 TH1F* PUnorm = dynamic_cast<TH1F*>(PU_intended->DrawNormalized());
0228
0229 TH1F* Quotient = PUnorm;
0230
0231 Quotient->Divide(PUnorm,PU_generated,1.0,1.0);
0232
0233 std::cout << "Bin Contents" << std::endl;
0234
0235 for(int ibin=1; ibin<26; ibin++){
0236
0237 x = Quotient->GetBinContent(ibin);
0238
0239 std::cout << ibin-1 << " " << x << std::endl;
0240
0241
0242 }
0243
0244 Quotient->SetNameTitle("Computed Weights","Computed Weights");
0245 Quotient->Draw();
0246
0247 }
0248