ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/src/PUReweighting.cc
Revision: 1.1
Committed: Wed Jun 1 12:36:59 2011 UTC (13 years, 11 months ago) by mzanetti
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_029c, Mit_029b, Mit_029a, Mit_028a, Mit_028, Mit_027, Mit_027a, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, HEAD
Log Message:
typo in the name of the previous file

File Contents

# User Rev Content
1 mzanetti 1.1 // $Id: PUReweighting.cc,v 1.1 2011/05/26 12:00:56 mzanetti Exp $
2    
3    
4     #include "MitPhysics/Utils/interface/PUReweighting.h"
5     #include <TFile.h>
6    
7     ClassImp(mithep::PUReweighting)
8    
9     using namespace mithep;
10    
11    
12     PUReweighting::PUReweighting(const char* fileName, const char*histoName) {
13    
14     TFile *referenceFile = TFile::Open(fileName);
15     if (!referenceFile) {
16     std::cout<<"Error: PU reference file does not exist, reweighting will not be applied"<<std::endl;
17     }
18     else {
19     referenceHisto = (TH1F*) referenceFile->Get(histoName);
20     }
21    
22     }
23    
24     double PUReweighting::reweightOOT(int inTimePUMultiplicity, int outOfTimePUMultiplicity) {
25    
26     if (!referenceHisto) {
27     std::cout<<"Error: PU reference histo does not exist in the file, reweighting will not be applied"<<std::endl;
28     return 1;
29     }
30    
31     // residual correction to match lumi spectrum
32     static double Correct_Weights2011[25] = {
33     5.30031,
34     2.07903,
35     1.40729,
36     1.27687,
37     1.0702,
38     0.902094,
39     0.902345,
40     0.931449,
41     0.78202,
42     0.824686,
43     0.837735,
44     0.910261,
45     1.01394,
46     1.1599,
47     1.12778,
48     1.58423,
49     1.78868,
50     1.58296,
51     2.3291,
52     3.86641,
53     0,
54     0,
55     0,
56     0,
57     0
58     };
59    
60    
61     static double weight_24[25] = {
62     0,
63     0,
64     0,
65     0,
66     2.46277e-06,
67     2.95532e-05,
68     0.000104668,
69     0.000401431,
70     0.00130034,
71     0.00342202,
72     0.00818132,
73     0.0175534,
74     0.035784,
75     0.0650836,
76     0.112232,
77     0.178699,
78     0.268934,
79     0.380868,
80     0.507505,
81     0.640922,
82     0.768551,
83     0.877829,
84     0.958624,
85     0.99939,
86     1
87     };
88    
89     static double weight_23[25] = {
90     0,
91     1.20628e-06,
92     1.20628e-06,
93     2.41255e-06,
94     1.20628e-05,
95     6.39326e-05,
96     0.000252112,
97     0.000862487,
98     0.00244995,
99     0.00616527,
100     0.0140821,
101     0.0293342,
102     0.0564501,
103     0.100602,
104     0.164479,
105     0.252659,
106     0.36268,
107     0.491427,
108     0.627979,
109     0.75918,
110     0.873185,
111     0.957934,
112     0.999381,
113     1,
114     0.957738
115     };
116    
117     static double weight_22[25] = {
118     0,
119     0,
120     0,
121     5.88636e-06,
122     3.0609e-05,
123     0.000143627,
124     0.000561558,
125     0.00173059,
126     0.00460078,
127     0.0110616,
128     0.0238974,
129     0.0475406,
130     0.0875077,
131     0.148682,
132     0.235752,
133     0.343591,
134     0.473146,
135     0.611897,
136     0.748345,
137     0.865978,
138     0.953199,
139     0.997848,
140     1,
141     0.954245,
142     0.873688
143     };
144    
145     static double weight_21[25] = {
146     0,
147     0,
148     1.15381e-06,
149     8.07665e-06,
150     7.1536e-05,
151     0.000280375,
152     0.00107189,
153     0.00327104,
154     0.00809396,
155     0.0190978,
156     0.0401894,
157     0.0761028,
158     0.13472,
159     0.216315,
160     0.324649,
161     0.455125,
162     0.598241,
163     0.739215,
164     0.861866,
165     0.953911,
166     0.998918,
167     1,
168     0.956683,
169     0.872272,
170     0.76399
171     };
172    
173    
174     static double weight_20[25] = {
175     0,
176     0,
177     1.12532e-06,
178     2.58822e-05,
179     0.000145166,
180     0.000633552,
181     0.00215048,
182     0.00592816,
183     0.0145605,
184     0.0328367,
185     0.0652649,
186     0.11893,
187     0.19803,
188     0.305525,
189     0.436588,
190     0.581566,
191     0.727048,
192     0.8534,
193     0.949419,
194     0.999785,
195     1,
196     0.953008,
197     0.865689,
198     0.753288,
199     0.62765
200     };
201     static double weight_19[25] = {
202     0,
203     0,
204     1.20714e-05,
205     5.92596e-05,
206     0.000364337,
207     0.00124994,
208     0.00403953,
209     0.0108149,
210     0.025824,
211     0.0544969,
212     0.103567,
213     0.17936,
214     0.283532,
215     0.416091,
216     0.562078,
217     0.714714,
218     0.846523,
219     0.947875,
220     1,
221     0.999448,
222     0.951404,
223     0.859717,
224     0.742319,
225     0.613601,
226     0.48552
227     };
228    
229     static double weight_18[25] = {
230     0,
231     3.20101e-06,
232     2.88091e-05,
233     0.000164319,
234     0.000719161,
235     0.00250106,
236     0.00773685,
237     0.0197513,
238     0.0443693,
239     0.0885998,
240     0.159891,
241     0.262607,
242     0.392327,
243     0.543125,
244     0.69924,
245     0.837474,
246     0.943486,
247     0.998029,
248     1,
249     0.945937,
250     0.851807,
251     0.729309,
252     0.596332,
253     0.467818,
254     0.350434
255     };
256    
257    
258     static double weight_17[25] = {
259     1.03634e-06,
260     7.25437e-06,
261     4.97443e-05,
262     0.000340956,
263     0.00148715,
264     0.00501485,
265     0.0143067,
266     0.034679,
267     0.0742009,
268     0.140287,
269     0.238288,
270     0.369416,
271     0.521637,
272     0.682368,
273     0.828634,
274     0.939655,
275     1,
276     0.996829,
277     0.94062,
278     0.841575,
279     0.716664,
280     0.582053,
281     0.449595,
282     0.331336,
283     0.234332
284     };
285    
286    
287     static double weight_16[25] = {
288     4.03159e-06,
289     2.41895e-05,
290     0.000141106,
291     0.00081942,
292     0.00314565,
293     0.00990662,
294     0.026293,
295     0.0603881,
296     0.120973,
297     0.214532,
298     0.343708,
299     0.501141,
300     0.665978,
301     0.820107,
302     0.938149,
303     1,
304     0.99941,
305     0.940768,
306     0.837813,
307     0.703086,
308     0.564023,
309     0.42928,
310     0.312515,
311     0.216251,
312     0.14561
313     };
314    
315    
316     static double weight_15[25] = {
317     9.76084e-07,
318     5.07564e-05,
319     0.000303562,
320     0.00174036,
321     0.00617959,
322     0.0188579,
323     0.047465,
324     0.101656,
325     0.189492,
326     0.315673,
327     0.474383,
328     0.646828,
329     0.809462,
330     0.934107,
331     0.998874,
332     1,
333     0.936163,
334     0.827473,
335     0.689675,
336     0.544384,
337     0.40907,
338     0.290648,
339     0.198861,
340     0.12951,
341     0.0808051
342     };
343    
344    
345     static double weight_14[25] = {
346     1.13288e-05,
347     0.000124617,
348     0.000753365,
349     0.00345056,
350     0.0123909,
351     0.0352712,
352     0.0825463,
353     0.16413,
354     0.287213,
355     0.44615,
356     0.625826,
357     0.796365,
358     0.930624,
359     0.999958,
360     1,
361     0.934414,
362     0.816456,
363     0.672939,
364     0.523033,
365     0.386068,
366     0.269824,
367     0.180342,
368     0.114669,
369     0.0698288,
370     0.0406496
371     };
372    
373    
374     static double weight_13[25] = {
375     2.54296e-05,
376     0.000261561,
377     0.00167018,
378     0.00748083,
379     0.0241308,
380     0.0636801,
381     0.138222,
382     0.255814,
383     0.414275,
384     0.600244,
385     0.779958,
386     0.92256,
387     0.999155,
388     1,
389     0.927126,
390     0.804504,
391     0.651803,
392     0.497534,
393     0.35976,
394     0.245834,
395     0.160904,
396     0.0991589,
397     0.0585434,
398     0.0332437,
399     0.0180159
400     };
401    
402     static double weight_12[25] = {
403     5.85742e-05,
404     0.000627706,
405     0.00386677,
406     0.0154068,
407     0.0465892,
408     0.111683,
409     0.222487,
410     0.381677,
411     0.5719,
412     0.765001,
413     0.915916,
414     1,
415     0.999717,
416     0.921443,
417     0.791958,
418     0.632344,
419     0.475195,
420     0.334982,
421     0.223666,
422     0.141781,
423     0.0851538,
424     0.048433,
425     0.0263287,
426     0.0133969,
427     0.00696683
428     };
429    
430    
431     static double weight_11[25] = {
432     0.00015238,
433     0.00156064,
434     0.00846044,
435     0.0310939,
436     0.0856225,
437     0.187589,
438     0.343579,
439     0.541892,
440     0.74224,
441     0.909269,
442     0.998711,
443     1,
444     0.916889,
445     0.77485,
446     0.608819,
447     0.447016,
448     0.307375,
449     0.198444,
450     0.121208,
451     0.070222,
452     0.0386492,
453     0.0201108,
454     0.0100922,
455     0.00484937,
456     0.00222458
457     };
458    
459     static double weight_10[25] = {
460     0.000393044,
461     0.00367001,
462     0.0179474,
463     0.060389,
464     0.151477,
465     0.302077,
466     0.503113,
467     0.720373,
468     0.899568,
469     1,
470     0.997739,
471     0.909409,
472     0.75728,
473     0.582031,
474     0.415322,
475     0.277663,
476     0.174147,
477     0.102154,
478     0.0566719,
479     0.0298642,
480     0.0147751,
481     0.00710995,
482     0.00319628,
483     0.00140601,
484     0.000568796
485     };
486    
487    
488     static double weight_9[25] = {
489     0.00093396,
490     0.00854448,
491     0.0380306,
492     0.113181,
493     0.256614,
494     0.460894,
495     0.690242,
496     0.888781,
497     1,
498     0.998756,
499     0.899872,
500     0.735642,
501     0.552532,
502     0.382726,
503     0.246114,
504     0.147497,
505     0.0825541,
506     0.0441199,
507     0.0218157,
508     0.0103578,
509     0.00462959,
510     0.0019142,
511     0.000771598,
512     0.000295893,
513     0.000111529
514     };
515    
516    
517     static double weight_8[25] = {
518     0.00240233,
519     0.0192688,
520     0.0768653,
521     0.205008,
522     0.410958,
523     0.65758,
524     0.875657,
525     0.999886,
526     1,
527     0.889476,
528     0.711446,
529     0.517781,
530     0.345774,
531     0.212028,
532     0.121208,
533     0.0644629,
534     0.0324928,
535     0.0152492,
536     0.00673527,
537     0.0028547,
538     0.00117213,
539     0.000440177,
540     0.000168471,
541     5.80689e-05,
542     1.93563e-05
543     };
544    
545     static double weight_7[25] = {
546     0.00617233,
547     0.0428714,
548     0.150018,
549     0.350317,
550     0.612535,
551     0.856525,
552     0.999923,
553     1,
554     0.87544,
555     0.679383,
556     0.478345,
557     0.303378,
558     0.176923,
559     0.0950103,
560     0.0476253,
561     0.0222211,
562     0.00972738,
563     0.00392962,
564     0.0015258,
565     0.000559168,
566     0.000183928,
567     6.77983e-05,
568     1.67818e-05,
569     7.38398e-06,
570     6.71271e-07
571     };
572    
573     static double weight_6[25] = {
574     0.0154465,
575     0.0923472,
576     0.277322,
577     0.55552,
578     0.833099,
579     0.999035,
580     1,
581     0.855183,
582     0.641976,
583     0.428277,
584     0.256804,
585     0.139798,
586     0.0700072,
587     0.0321586,
588     0.0137971,
589     0.00544756,
590     0.00202316,
591     0.000766228,
592     0.000259348,
593     8.45836e-05,
594     1.80362e-05,
595     8.70713e-06,
596     3.73163e-06,
597     6.21938e-07,
598     0
599     };
600    
601    
602     static double weight_5[25] = {
603     0.0382845,
604     0.191122,
605     0.478782,
606     0.797314,
607     1,
608     0.997148,
609     0.831144,
610     0.59461,
611     0.371293,
612     0.205903,
613     0.103102,
614     0.0471424,
615     0.0194997,
616     0.00749415,
617     0.00273709,
618     0.000879189,
619     0.000286049,
620     0.000102364,
621     1.70606e-05,
622     3.98081e-06,
623     2.27475e-06,
624     0,
625     0,
626     0,
627     0
628     };
629    
630    
631     static double weight_4[25] = {
632     0.0941305,
633     0.373824,
634     0.750094,
635     1,
636     0.997698,
637     0.800956,
638     0.532306,
639     0.304597,
640     0.152207,
641     0.0676275,
642     0.0270646,
643     0.00975365,
644     0.00326077,
645     0.00101071,
646     0.000301781,
647     7.41664e-05,
648     1.58563e-05,
649     3.58045e-06,
650     1.02299e-06,
651     0,
652     5.11493e-07,
653     0,
654     0,
655     0,
656     0
657     };
658    
659    
660     static double weight_3[25] = {
661     0.222714,
662     0.667015,
663     1,
664     0.999208,
665     0.750609,
666     0.449854,
667     0.224968,
668     0.0965185,
669     0.0361225,
670     0.012084,
671     0.00359618,
672     0.000977166,
673     0.000239269,
674     6.29422e-05,
675     1.16064e-05,
676     1.78559e-06,
677     0,
678     4.46398e-07,
679     0,
680     0,
681     0,
682     0,
683     0,
684     0,
685     0
686     };
687    
688     static double weight_2[25] = {
689     0.499541,
690     0.999607,
691     1,
692     0.666607,
693     0.333301,
694     0.13279,
695     0.0441871,
696     0.0127455,
697     0.00318434,
698     0.00071752,
699     0.000132204,
700     2.69578e-05,
701     5.16999e-06,
702     2.21571e-06,
703     0,
704     0,
705     0,
706     0,
707     0,
708     0,
709     0,
710     0,
711     0,
712     0,
713     0
714     };
715    
716     static double weight_1[25] = {
717     0.999165,
718     1,
719     0.499996,
720     0.166868,
721     0.0414266,
722     0.00831053,
723     0.00137472,
724     0.000198911,
725     2.66302e-05,
726     2.44563e-06,
727     2.71737e-07,
728     2.71737e-07,
729     0,
730     0,
731     0,
732     0,
733     0,
734     0,
735     0,
736     0,
737     0,
738     0,
739     0,
740     0,
741     0
742     };
743    
744     static double weight_0[25] = {
745     1,
746     0,
747     0,
748     0,
749     0,
750     0,
751     0,
752     0,
753     0,
754     0,
755     0,
756     0,
757     0,
758     0,
759     0,
760     0,
761     0,
762     0,
763     0,
764     0,
765     0,
766     0,
767     0,
768     0,
769     0
770     };
771    
772     double WeightOOTPU[25][25];
773    
774     double* WeightPtr = 0;
775    
776     for(int iint = 0; iint<25; ++iint){
777     if(iint ==0) WeightPtr = weight_0;
778     if(iint ==1) WeightPtr = weight_1;
779     if(iint ==2) WeightPtr = weight_2;
780     if(iint ==3) WeightPtr = weight_3;
781     if(iint ==4) WeightPtr = weight_4;
782     if(iint ==5) WeightPtr = weight_5;
783     if(iint ==6) WeightPtr = weight_6;
784     if(iint ==7) WeightPtr = weight_7;
785     if(iint ==8) WeightPtr = weight_8;
786     if(iint ==9) WeightPtr = weight_9;
787     if(iint ==10) WeightPtr = weight_10;
788     if(iint ==11) WeightPtr = weight_11;
789     if(iint ==12) WeightPtr = weight_12;
790     if(iint ==13) WeightPtr = weight_13;
791     if(iint ==14) WeightPtr = weight_14;
792     if(iint ==15) WeightPtr = weight_15;
793     if(iint ==16) WeightPtr = weight_16;
794     if(iint ==17) WeightPtr = weight_17;
795     if(iint ==18) WeightPtr = weight_18;
796     if(iint ==19) WeightPtr = weight_19;
797     if(iint ==20) WeightPtr = weight_20;
798     if(iint ==21) WeightPtr = weight_21;
799     if(iint ==22) WeightPtr = weight_22;
800     if(iint ==23) WeightPtr = weight_23;
801     if(iint ==24) WeightPtr = weight_24;
802    
803     for(int ibin = 0; ibin<25; ++ibin){
804     WeightOOTPU[iint][ibin] = *(WeightPtr+ibin);
805     }
806     }
807    
808    
809     double inTimeWeight = referenceHisto->GetBinContent( inTimePUMultiplicity );
810    
811     return inTimeWeight * WeightOOTPU[inTimePUMultiplicity-1][outOfTimePUMultiplicity-1] * Correct_Weights2011[inTimePUMultiplicity-1];
812    
813     }
814