00001 #ifndef PhysicsTools_Utilities_interface_LumiReWeighting_cc
00002 #define PhysicsTools_Utilities_interface_LumiReWeighting_cc
00003
00004
00021 #include "TH1.h"
00022 #include "TFile.h"
00023 #include <string>
00024 #include <boost/shared_ptr.hpp>
00025 #include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
00026 #include "PhysicsTools/Utilities/interface/LumiReWeighting.h"
00027 #include "DataFormats/Common/interface/Handle.h"
00028 #include "DataFormats/Provenance/interface/ProcessHistory.h"
00029 #include "DataFormats/Provenance/interface/Provenance.h"
00030 #include "FWCore/Common/interface/EventBase.h"
00031
00032 using namespace edm;
00033
00034 LumiReWeighting::LumiReWeighting( std::string generatedFile,
00035 std::string dataFile,
00036 std::string GenHistName = "pileup",
00037 std::string DataHistName = "pileup" ) :
00038 generatedFileName_( generatedFile),
00039 dataFileName_ ( dataFile ),
00040 GenHistName_ ( GenHistName ),
00041 DataHistName_ ( DataHistName )
00042 {
00043 generatedFile_ = boost::shared_ptr<TFile>( new TFile(generatedFileName_.c_str()) );
00044 dataFile_ = boost::shared_ptr<TFile>( new TFile(dataFileName_.c_str()) );
00045
00046 weights_ = boost::shared_ptr<TH1F> ( new TH1F( *(static_cast<TH1F*>(dataFile_->Get( DataHistName_.c_str() )->Clone() ))));
00047
00048
00049
00050
00051
00052 weights_->Scale( 1.0/ weights_->Integral() );
00053 weights_->SetName("lumiWeights");
00054
00055 TH1F* den = dynamic_cast<TH1F*>(generatedFile_->Get( GenHistName_.c_str() ));
00056
00057 den->Scale(1.0/ den->Integral());
00058
00059 weights_->Divide( den );
00060
00061 std::cout << " Lumi/Pileup Reweighting: Computed Weights per In-Time Nint " << std::endl;
00062
00063 int NBins = weights_->GetNbinsX();
00064
00065 for(int ibin = 1; ibin<NBins+1; ++ibin){
00066 std::cout << " " << ibin-1 << " " << weights_->GetBinContent(ibin) << std::endl;
00067 }
00068
00069
00070 weightOOT_init();
00071
00072 FirstWarning_ = true;
00073 OldLumiSection_ = -1;
00074 }
00075
00076 LumiReWeighting::LumiReWeighting( std::vector< float > MC_distr, std::vector< float > Lumi_distr) {
00077
00078
00079
00080
00081
00082
00083 if( MC_distr.size() != Lumi_distr.size() ){
00084
00085 std::cerr <<"ERROR: LumiReWeighting: input vectors have different sizes. Quitting... \n";
00086 return;
00087
00088 }
00089
00090 Int_t NBins = MC_distr.size();
00091
00092 weights_ = boost::shared_ptr<TH1F> ( new TH1F("luminumer","luminumer",NBins,-0.5, float(NBins)-0.5) );
00093 TH1F* den = new TH1F("lumidenom","lumidenom",NBins,-0.5, float(NBins)-0.5) ;
00094
00095 for(int ibin = 1; ibin<NBins+1; ++ibin ) {
00096 weights_->SetBinContent(ibin, Lumi_distr[ibin-1]);
00097 den->SetBinContent(ibin,MC_distr[ibin-1]);
00098 }
00099
00100
00101
00102 float deltaH = weights_->Integral();
00103 if(fabs(1.0 - deltaH) > 0.02 ) {
00104 weights_->Scale( 1.0/ weights_->Integral() );
00105 }
00106 float deltaMC = den->Integral();
00107 if(fabs(1.0 - deltaMC) > 0.02 ) {
00108 den->Scale(1.0/ den->Integral());
00109 }
00110
00111 weights_->Divide( den );
00112
00113 std::cout << " Lumi/Pileup Reweighting: Computed Weights per In-Time Nint " << std::endl;
00114
00115 for(int ibin = 1; ibin<NBins+1; ++ibin){
00116 std::cout << " " << ibin-1 << " " << weights_->GetBinContent(ibin) << std::endl;
00117 }
00118
00119 weightOOT_init();
00120
00121 FirstWarning_ = true;
00122 OldLumiSection_ = -1;
00123 }
00124
00125 double LumiReWeighting::weight( int npv ) {
00126 int bin = weights_->GetXaxis()->FindBin( npv );
00127 return weights_->GetBinContent( bin );
00128 }
00129
00130
00131
00132
00133
00134 double LumiReWeighting::weight( const edm::EventBase &e ) {
00135
00136
00137
00138 if(FirstWarning_) {
00139
00140 edm::ReleaseVersion TargetRelease = edm::ReleaseVersion("\"CMSSW_4_2_2_patch2\"");
00141 edm::ProcessHistory PHist = e.processHistory();
00142 edm::ProcessHistory::const_iterator PHist_iter = PHist.begin();
00143
00144 for(; PHist_iter<PHist.end() ;++PHist_iter) {
00145 edm::ProcessConfiguration PConf = *(PHist_iter);
00146 edm::ReleaseVersion Release = PConf.releaseVersion() ;
00147 const std::string Process = PConf.processName();
00148
00149 if((Process=="HLT") && (Release==TargetRelease)) {
00150 std::cout << " **** Warning! You are using in-time-only pileup reweighting for Release " << Release << " **** " << std::endl;
00151 std::cout << " **** There is a weightOOT() function available if needed **** " << std::endl;
00152 }
00153 }
00154
00155 FirstWarning_ = false;
00156 }
00157
00158
00159
00160 Handle<std::vector< PileupSummaryInfo > > PupInfo;
00161 e.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
00162
00163 std::vector<PileupSummaryInfo>::const_iterator PVI;
00164
00165 int npv = -1;
00166 for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
00167
00168 int BX = PVI->getBunchCrossing();
00169
00170 if(BX == 0) {
00171 npv = PVI->getPU_NumInteractions();
00172 continue;
00173 }
00174
00175 }
00176
00177 if(npv < 0) std::cerr << " no in-time beam crossing found\n! " ;
00178
00179 int bin = weights_->GetXaxis()->FindBin( npv );
00180
00181 return weights_->GetBinContent( bin );
00182
00183 }
00184
00185 void LumiReWeighting::weightOOT_init() {
00186
00187
00188
00189
00190
00191
00192
00193
00194 static double weight_24[25] = {
00195 0,
00196 0,
00197 0,
00198 0,
00199 2.46277e-06,
00200 2.95532e-05,
00201 0.000104668,
00202 0.000401431,
00203 0.00130034,
00204 0.00342202,
00205 0.00818132,
00206 0.0175534,
00207 0.035784,
00208 0.0650836,
00209 0.112232,
00210 0.178699,
00211 0.268934,
00212 0.380868,
00213 0.507505,
00214 0.640922,
00215 0.768551,
00216 0.877829,
00217 0.958624,
00218 0.99939,
00219 1
00220 };
00221
00222 static double weight_23[25] = {
00223 0,
00224 1.20628e-06,
00225 1.20628e-06,
00226 2.41255e-06,
00227 1.20628e-05,
00228 6.39326e-05,
00229 0.000252112,
00230 0.000862487,
00231 0.00244995,
00232 0.00616527,
00233 0.0140821,
00234 0.0293342,
00235 0.0564501,
00236 0.100602,
00237 0.164479,
00238 0.252659,
00239 0.36268,
00240 0.491427,
00241 0.627979,
00242 0.75918,
00243 0.873185,
00244 0.957934,
00245 0.999381,
00246 1,
00247 0.957738
00248 };
00249
00250 static double weight_22[25] = {
00251 0,
00252 0,
00253 0,
00254 5.88636e-06,
00255 3.0609e-05,
00256 0.000143627,
00257 0.000561558,
00258 0.00173059,
00259 0.00460078,
00260 0.0110616,
00261 0.0238974,
00262 0.0475406,
00263 0.0875077,
00264 0.148682,
00265 0.235752,
00266 0.343591,
00267 0.473146,
00268 0.611897,
00269 0.748345,
00270 0.865978,
00271 0.953199,
00272 0.997848,
00273 1,
00274 0.954245,
00275 0.873688
00276 };
00277
00278 static double weight_21[25] = {
00279 0,
00280 0,
00281 1.15381e-06,
00282 8.07665e-06,
00283 7.1536e-05,
00284 0.000280375,
00285 0.00107189,
00286 0.00327104,
00287 0.00809396,
00288 0.0190978,
00289 0.0401894,
00290 0.0761028,
00291 0.13472,
00292 0.216315,
00293 0.324649,
00294 0.455125,
00295 0.598241,
00296 0.739215,
00297 0.861866,
00298 0.953911,
00299 0.998918,
00300 1,
00301 0.956683,
00302 0.872272,
00303 0.76399
00304 };
00305
00306
00307 static double weight_20[25] = {
00308 0,
00309 0,
00310 1.12532e-06,
00311 2.58822e-05,
00312 0.000145166,
00313 0.000633552,
00314 0.00215048,
00315 0.00592816,
00316 0.0145605,
00317 0.0328367,
00318 0.0652649,
00319 0.11893,
00320 0.19803,
00321 0.305525,
00322 0.436588,
00323 0.581566,
00324 0.727048,
00325 0.8534,
00326 0.949419,
00327 0.999785,
00328 1,
00329 0.953008,
00330 0.865689,
00331 0.753288,
00332 0.62765
00333 };
00334 static double weight_19[25] = {
00335 0,
00336 0,
00337 1.20714e-05,
00338 5.92596e-05,
00339 0.000364337,
00340 0.00124994,
00341 0.00403953,
00342 0.0108149,
00343 0.025824,
00344 0.0544969,
00345 0.103567,
00346 0.17936,
00347 0.283532,
00348 0.416091,
00349 0.562078,
00350 0.714714,
00351 0.846523,
00352 0.947875,
00353 1,
00354 0.999448,
00355 0.951404,
00356 0.859717,
00357 0.742319,
00358 0.613601,
00359 0.48552
00360 };
00361
00362 static double weight_18[25] = {
00363 0,
00364 3.20101e-06,
00365 2.88091e-05,
00366 0.000164319,
00367 0.000719161,
00368 0.00250106,
00369 0.00773685,
00370 0.0197513,
00371 0.0443693,
00372 0.0885998,
00373 0.159891,
00374 0.262607,
00375 0.392327,
00376 0.543125,
00377 0.69924,
00378 0.837474,
00379 0.943486,
00380 0.998029,
00381 1,
00382 0.945937,
00383 0.851807,
00384 0.729309,
00385 0.596332,
00386 0.467818,
00387 0.350434
00388 };
00389
00390
00391 static double weight_17[25] = {
00392 1.03634e-06,
00393 7.25437e-06,
00394 4.97443e-05,
00395 0.000340956,
00396 0.00148715,
00397 0.00501485,
00398 0.0143067,
00399 0.034679,
00400 0.0742009,
00401 0.140287,
00402 0.238288,
00403 0.369416,
00404 0.521637,
00405 0.682368,
00406 0.828634,
00407 0.939655,
00408 1,
00409 0.996829,
00410 0.94062,
00411 0.841575,
00412 0.716664,
00413 0.582053,
00414 0.449595,
00415 0.331336,
00416 0.234332
00417 };
00418
00419
00420 static double weight_16[25] = {
00421 4.03159e-06,
00422 2.41895e-05,
00423 0.000141106,
00424 0.00081942,
00425 0.00314565,
00426 0.00990662,
00427 0.026293,
00428 0.0603881,
00429 0.120973,
00430 0.214532,
00431 0.343708,
00432 0.501141,
00433 0.665978,
00434 0.820107,
00435 0.938149,
00436 1,
00437 0.99941,
00438 0.940768,
00439 0.837813,
00440 0.703086,
00441 0.564023,
00442 0.42928,
00443 0.312515,
00444 0.216251,
00445 0.14561
00446 };
00447
00448
00449 static double weight_15[25] = {
00450 9.76084e-07,
00451 5.07564e-05,
00452 0.000303562,
00453 0.00174036,
00454 0.00617959,
00455 0.0188579,
00456 0.047465,
00457 0.101656,
00458 0.189492,
00459 0.315673,
00460 0.474383,
00461 0.646828,
00462 0.809462,
00463 0.934107,
00464 0.998874,
00465 1,
00466 0.936163,
00467 0.827473,
00468 0.689675,
00469 0.544384,
00470 0.40907,
00471 0.290648,
00472 0.198861,
00473 0.12951,
00474 0.0808051
00475 };
00476
00477
00478 static double weight_14[25] = {
00479 1.13288e-05,
00480 0.000124617,
00481 0.000753365,
00482 0.00345056,
00483 0.0123909,
00484 0.0352712,
00485 0.0825463,
00486 0.16413,
00487 0.287213,
00488 0.44615,
00489 0.625826,
00490 0.796365,
00491 0.930624,
00492 0.999958,
00493 1,
00494 0.934414,
00495 0.816456,
00496 0.672939,
00497 0.523033,
00498 0.386068,
00499 0.269824,
00500 0.180342,
00501 0.114669,
00502 0.0698288,
00503 0.0406496
00504 };
00505
00506
00507 static double weight_13[25] = {
00508 2.54296e-05,
00509 0.000261561,
00510 0.00167018,
00511 0.00748083,
00512 0.0241308,
00513 0.0636801,
00514 0.138222,
00515 0.255814,
00516 0.414275,
00517 0.600244,
00518 0.779958,
00519 0.92256,
00520 0.999155,
00521 1,
00522 0.927126,
00523 0.804504,
00524 0.651803,
00525 0.497534,
00526 0.35976,
00527 0.245834,
00528 0.160904,
00529 0.0991589,
00530 0.0585434,
00531 0.0332437,
00532 0.0180159
00533 };
00534
00535 static double weight_12[25] = {
00536 5.85742e-05,
00537 0.000627706,
00538 0.00386677,
00539 0.0154068,
00540 0.0465892,
00541 0.111683,
00542 0.222487,
00543 0.381677,
00544 0.5719,
00545 0.765001,
00546 0.915916,
00547 1,
00548 0.999717,
00549 0.921443,
00550 0.791958,
00551 0.632344,
00552 0.475195,
00553 0.334982,
00554 0.223666,
00555 0.141781,
00556 0.0851538,
00557 0.048433,
00558 0.0263287,
00559 0.0133969,
00560 0.00696683
00561 };
00562
00563
00564 static double weight_11[25] = {
00565 0.00015238,
00566 0.00156064,
00567 0.00846044,
00568 0.0310939,
00569 0.0856225,
00570 0.187589,
00571 0.343579,
00572 0.541892,
00573 0.74224,
00574 0.909269,
00575 0.998711,
00576 1,
00577 0.916889,
00578 0.77485,
00579 0.608819,
00580 0.447016,
00581 0.307375,
00582 0.198444,
00583 0.121208,
00584 0.070222,
00585 0.0386492,
00586 0.0201108,
00587 0.0100922,
00588 0.00484937,
00589 0.00222458
00590 };
00591
00592 static double weight_10[25] = {
00593 0.000393044,
00594 0.00367001,
00595 0.0179474,
00596 0.060389,
00597 0.151477,
00598 0.302077,
00599 0.503113,
00600 0.720373,
00601 0.899568,
00602 1,
00603 0.997739,
00604 0.909409,
00605 0.75728,
00606 0.582031,
00607 0.415322,
00608 0.277663,
00609 0.174147,
00610 0.102154,
00611 0.0566719,
00612 0.0298642,
00613 0.0147751,
00614 0.00710995,
00615 0.00319628,
00616 0.00140601,
00617 0.000568796
00618 };
00619
00620
00621 static double weight_9[25] = {
00622 0.00093396,
00623 0.00854448,
00624 0.0380306,
00625 0.113181,
00626 0.256614,
00627 0.460894,
00628 0.690242,
00629 0.888781,
00630 1,
00631 0.998756,
00632 0.899872,
00633 0.735642,
00634 0.552532,
00635 0.382726,
00636 0.246114,
00637 0.147497,
00638 0.0825541,
00639 0.0441199,
00640 0.0218157,
00641 0.0103578,
00642 0.00462959,
00643 0.0019142,
00644 0.000771598,
00645 0.000295893,
00646 0.000111529
00647 };
00648
00649
00650 static double weight_8[25] = {
00651 0.00240233,
00652 0.0192688,
00653 0.0768653,
00654 0.205008,
00655 0.410958,
00656 0.65758,
00657 0.875657,
00658 0.999886,
00659 1,
00660 0.889476,
00661 0.711446,
00662 0.517781,
00663 0.345774,
00664 0.212028,
00665 0.121208,
00666 0.0644629,
00667 0.0324928,
00668 0.0152492,
00669 0.00673527,
00670 0.0028547,
00671 0.00117213,
00672 0.000440177,
00673 0.000168471,
00674 5.80689e-05,
00675 1.93563e-05
00676 };
00677
00678 static double weight_7[25] = {
00679 0.00617233,
00680 0.0428714,
00681 0.150018,
00682 0.350317,
00683 0.612535,
00684 0.856525,
00685 0.999923,
00686 1,
00687 0.87544,
00688 0.679383,
00689 0.478345,
00690 0.303378,
00691 0.176923,
00692 0.0950103,
00693 0.0476253,
00694 0.0222211,
00695 0.00972738,
00696 0.00392962,
00697 0.0015258,
00698 0.000559168,
00699 0.000183928,
00700 6.77983e-05,
00701 1.67818e-05,
00702 7.38398e-06,
00703 6.71271e-07
00704 };
00705
00706 static double weight_6[25] = {
00707 0.0154465,
00708 0.0923472,
00709 0.277322,
00710 0.55552,
00711 0.833099,
00712 0.999035,
00713 1,
00714 0.855183,
00715 0.641976,
00716 0.428277,
00717 0.256804,
00718 0.139798,
00719 0.0700072,
00720 0.0321586,
00721 0.0137971,
00722 0.00544756,
00723 0.00202316,
00724 0.000766228,
00725 0.000259348,
00726 8.45836e-05,
00727 1.80362e-05,
00728 8.70713e-06,
00729 3.73163e-06,
00730 6.21938e-07,
00731 0
00732 };
00733
00734
00735 static double weight_5[25] = {
00736 0.0382845,
00737 0.191122,
00738 0.478782,
00739 0.797314,
00740 1,
00741 0.997148,
00742 0.831144,
00743 0.59461,
00744 0.371293,
00745 0.205903,
00746 0.103102,
00747 0.0471424,
00748 0.0194997,
00749 0.00749415,
00750 0.00273709,
00751 0.000879189,
00752 0.000286049,
00753 0.000102364,
00754 1.70606e-05,
00755 3.98081e-06,
00756 2.27475e-06,
00757 0,
00758 0,
00759 0,
00760 0
00761 };
00762
00763
00764 static double weight_4[25] = {
00765 0.0941305,
00766 0.373824,
00767 0.750094,
00768 1,
00769 0.997698,
00770 0.800956,
00771 0.532306,
00772 0.304597,
00773 0.152207,
00774 0.0676275,
00775 0.0270646,
00776 0.00975365,
00777 0.00326077,
00778 0.00101071,
00779 0.000301781,
00780 7.41664e-05,
00781 1.58563e-05,
00782 3.58045e-06,
00783 1.02299e-06,
00784 0,
00785 5.11493e-07,
00786 0,
00787 0,
00788 0,
00789 0
00790 };
00791
00792
00793 static double weight_3[25] = {
00794 0.222714,
00795 0.667015,
00796 1,
00797 0.999208,
00798 0.750609,
00799 0.449854,
00800 0.224968,
00801 0.0965185,
00802 0.0361225,
00803 0.012084,
00804 0.00359618,
00805 0.000977166,
00806 0.000239269,
00807 6.29422e-05,
00808 1.16064e-05,
00809 1.78559e-06,
00810 0,
00811 4.46398e-07,
00812 0,
00813 0,
00814 0,
00815 0,
00816 0,
00817 0,
00818 0
00819 };
00820
00821 static double weight_2[25] = {
00822 0.499541,
00823 0.999607,
00824 1,
00825 0.666607,
00826 0.333301,
00827 0.13279,
00828 0.0441871,
00829 0.0127455,
00830 0.00318434,
00831 0.00071752,
00832 0.000132204,
00833 2.69578e-05,
00834 5.16999e-06,
00835 2.21571e-06,
00836 0,
00837 0,
00838 0,
00839 0,
00840 0,
00841 0,
00842 0,
00843 0,
00844 0,
00845 0,
00846 0
00847 };
00848
00849 static double weight_1[25] = {
00850 0.999165,
00851 1,
00852 0.499996,
00853 0.166868,
00854 0.0414266,
00855 0.00831053,
00856 0.00137472,
00857 0.000198911,
00858 2.66302e-05,
00859 2.44563e-06,
00860 2.71737e-07,
00861 2.71737e-07,
00862 0,
00863 0,
00864 0,
00865 0,
00866 0,
00867 0,
00868 0,
00869 0,
00870 0,
00871 0,
00872 0,
00873 0,
00874 0
00875 };
00876
00877 static double weight_0[25] = {
00878 1,
00879 0,
00880 0,
00881 0,
00882 0,
00883 0,
00884 0,
00885 0,
00886 0,
00887 0,
00888 0,
00889 0,
00890 0,
00891 0,
00892 0,
00893 0,
00894 0,
00895 0,
00896 0,
00897 0,
00898 0,
00899 0,
00900 0,
00901 0,
00902 0
00903 };
00904
00905
00906
00907 double* WeightPtr = 0;
00908
00909 for(int iint = 0; iint<25; ++iint){
00910 if(iint ==0) WeightPtr = weight_0;
00911 if(iint ==1) WeightPtr = weight_1;
00912 if(iint ==2) WeightPtr = weight_2;
00913 if(iint ==3) WeightPtr = weight_3;
00914 if(iint ==4) WeightPtr = weight_4;
00915 if(iint ==5) WeightPtr = weight_5;
00916 if(iint ==6) WeightPtr = weight_6;
00917 if(iint ==7) WeightPtr = weight_7;
00918 if(iint ==8) WeightPtr = weight_8;
00919 if(iint ==9) WeightPtr = weight_9;
00920 if(iint ==10) WeightPtr = weight_10;
00921 if(iint ==11) WeightPtr = weight_11;
00922 if(iint ==12) WeightPtr = weight_12;
00923 if(iint ==13) WeightPtr = weight_13;
00924 if(iint ==14) WeightPtr = weight_14;
00925 if(iint ==15) WeightPtr = weight_15;
00926 if(iint ==16) WeightPtr = weight_16;
00927 if(iint ==17) WeightPtr = weight_17;
00928 if(iint ==18) WeightPtr = weight_18;
00929 if(iint ==19) WeightPtr = weight_19;
00930 if(iint ==20) WeightPtr = weight_20;
00931 if(iint ==21) WeightPtr = weight_21;
00932 if(iint ==22) WeightPtr = weight_22;
00933 if(iint ==23) WeightPtr = weight_23;
00934 if(iint ==24) WeightPtr = weight_24;
00935
00936 for(int ibin = 0; ibin<25; ++ibin){
00937 WeightOOTPU_[iint][ibin] = *(WeightPtr+ibin);
00938 }
00939 }
00940
00941 }
00942
00943
00944
00945
00946
00947 double LumiReWeighting::weightOOT( const edm::EventBase &e ) {
00948
00949
00950 static double Correct_Weights2011[25] = {
00951 5.30031,
00952 2.07903,
00953 1.40729,
00954 1.27687,
00955 1.0702,
00956 0.902094,
00957 0.902345,
00958 0.931449,
00959 0.78202,
00960 0.824686,
00961 0.837735,
00962 0.910261,
00963 1.01394,
00964 1.1599,
00965 1.12778,
00966 1.58423,
00967 1.78868,
00968 1.58296,
00969 2.3291,
00970 3.86641,
00971 0,
00972 0,
00973 0,
00974 0,
00975 0
00976 };
00977
00978
00979 int LumiSection = e.luminosityBlock();
00980
00981
00982
00983 if(LumiSection != OldLumiSection_) {
00984
00985 Reweight_4_2_2p2_ = false;
00986
00987 static edm::ReleaseVersion TargetRelease = edm::ReleaseVersion("\"CMSSW_4_2_2_patch2\"");
00988 edm::ProcessHistory PHist = e.processHistory();
00989 edm::ProcessHistory::const_iterator PHist_iter = PHist.begin();
00990
00991
00992
00993 for(; PHist_iter<PHist.end() ;++PHist_iter) {
00994 edm::ProcessConfiguration PConf = *(PHist_iter);
00995 edm::ReleaseVersion Release = PConf.releaseVersion() ;
00996 const std::string Process = PConf.processName();
00997
00998 if((Process=="HLT") && (Release==TargetRelease)) {
00999
01000 Reweight_4_2_2p2_ = true;
01001
01002 if(FirstWarning_) {
01003
01004 std::cout << " **** Warning: Out-of-time pileup reweighting appropriate for Release " << Release << " **** " << std::endl;
01005 std::cout << " **** will be applied **** " << std::endl;
01006
01007 FirstWarning_ = false;
01008 }
01009 }
01010 }
01011 OldLumiSection_ = LumiSection;
01012 }
01013
01014
01015
01016 Handle<std::vector< PileupSummaryInfo > > PupInfo;
01017 e.getByLabel(edm::InputTag("addPileupInfo"), PupInfo);
01018
01019 std::vector<PileupSummaryInfo>::const_iterator PVI;
01020
01021 int npv = -1;
01022 int npv50ns = -1;
01023
01024 for(PVI = PupInfo->begin(); PVI != PupInfo->end(); ++PVI) {
01025
01026 int BX = PVI->getBunchCrossing();
01027
01028 if(BX == 0) {
01029 npv = PVI->getPU_NumInteractions();
01030 }
01031
01032 if(BX == 1) {
01033 npv50ns = PVI->getPU_NumInteractions();
01034 }
01035
01036 }
01037
01038
01039
01040
01041
01042 if(npv < 0) {
01043 std::cerr << " no in-time beam crossing found\n! " ;
01044 std::cerr << " Returning event weight=0\n! ";
01045 return 0.;
01046 }
01047 if(npv50ns < 0) {
01048 std::cerr << " no out-of-time beam crossing found\n! " ;
01049 std::cerr << " Returning event weight=0\n! ";
01050 return 0.;
01051 }
01052
01053 int bin = weights_->GetXaxis()->FindBin( npv );
01054
01055 double inTimeWeight = weights_->GetBinContent( bin );
01056
01057 double TotalWeight = 1.0;
01058
01059 if(Reweight_4_2_2p2_) {
01060 TotalWeight = inTimeWeight * WeightOOTPU_[bin-1][npv50ns] * Correct_Weights2011[bin-1];
01061 }
01062 else {
01063 TotalWeight = inTimeWeight;
01064 }
01065
01066 return TotalWeight;
01067
01068 }
01069
01070 #endif