1 |
loizides |
1.1 |
// $Id: PDFProducerMod.cc,v 1.2 2009/08/11 10:50:38 loizides Exp $
|
2 |
|
|
|
3 |
|
|
#include "MitPhysics/Mods/interface/PDFProducerMod.h"
|
4 |
|
|
#include "MitCommon/MathTools/interface/MathUtils.h"
|
5 |
|
|
#include "MitAna/DataTree/interface/MCEventInfo.h"
|
6 |
|
|
#include "MitPhysics/Init/interface/ModNames.h"
|
7 |
|
|
#include <TH1D.h>
|
8 |
|
|
#include <TH2D.h>
|
9 |
|
|
#include <TSystem.h>
|
10 |
|
|
#include "LHAPDF/LHAPDF.h"
|
11 |
|
|
|
12 |
|
|
using namespace mithep;
|
13 |
|
|
|
14 |
|
|
ClassImp(mithep::PDFProducerMod)
|
15 |
|
|
|
16 |
|
|
//--------------------------------------------------------------------------------------------------
|
17 |
|
|
PDFProducerMod::PDFProducerMod(const char *name, const char *title) :
|
18 |
|
|
BaseMod(name,title),
|
19 |
|
|
fPrintDebug(kFALSE),
|
20 |
|
|
fMCEvInfoName(Names::gkMCEvtInfoBrn),
|
21 |
|
|
fPDFName("cteq65.LHgrid"),
|
22 |
|
|
fMCEventInfo(0)
|
23 |
|
|
{
|
24 |
|
|
// Constructor
|
25 |
|
|
}
|
26 |
|
|
|
27 |
|
|
//--------------------------------------------------------------------------------------------------
|
28 |
|
|
void PDFProducerMod::Process()
|
29 |
|
|
{
|
30 |
|
|
// Process entries of the tree.
|
31 |
|
|
|
32 |
|
|
LoadBranch(fMCEvInfoName);
|
33 |
|
|
|
34 |
|
|
Double_t Q = fMCEventInfo->Scale();
|
35 |
|
|
Int_t id1 = fMCEventInfo->Id1();
|
36 |
|
|
Double_t x1 = fMCEventInfo->X1();
|
37 |
|
|
Double_t pdf1 = fMCEventInfo->Pdf1();
|
38 |
|
|
Int_t id2 = fMCEventInfo->Id2();
|
39 |
|
|
Double_t x2 = fMCEventInfo->X2();
|
40 |
|
|
Double_t pdf2 = fMCEventInfo->Pdf2();
|
41 |
|
|
|
42 |
|
|
UInt_t nmembers = LHAPDF::numberPDF() + 1;
|
43 |
|
|
|
44 |
|
|
// Array to be filled
|
45 |
|
|
FArrDouble *PDFArr = new FArrDouble(nmembers);
|
46 |
|
|
|
47 |
|
|
if (fPrintDebug)
|
48 |
|
|
cout << "Start loop over PDF members:" << endl;
|
49 |
|
|
|
50 |
|
|
for (UInt_t i=0; i<nmembers; ++i) {
|
51 |
|
|
LHAPDF::usePDFMember(i);
|
52 |
|
|
Double_t newpdf1 = LHAPDF::xfx(x1, Q, id1)/x1;
|
53 |
|
|
Double_t newpdf2 = LHAPDF::xfx(x2, Q, id2)/x2;
|
54 |
|
|
Double_t TheWeight = newpdf1/pdf1*newpdf2/pdf2;
|
55 |
|
|
|
56 |
|
|
if (fPrintDebug) {
|
57 |
|
|
cout << i << " --> " << pdf1 << " " << pdf2 << " | "
|
58 |
|
|
<< x1 << " " << x2 << " | "
|
59 |
|
|
<< id1 << " " << id2 << " | "
|
60 |
|
|
<< Q << " : " << TheWeight << endl;
|
61 |
|
|
}
|
62 |
|
|
if (GetFillHist()) {
|
63 |
|
|
hDPDFHisto[0]->Fill(TheWeight);
|
64 |
|
|
}
|
65 |
|
|
PDFArr->Add(TheWeight);
|
66 |
|
|
}
|
67 |
|
|
|
68 |
|
|
AddObjThisEvt(PDFArr, "PDFWeights");
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
//--------------------------------------------------------------------------------------------------
|
72 |
|
|
void PDFProducerMod::SlaveBegin()
|
73 |
|
|
{
|
74 |
|
|
// Setup LHAPDF and book branch and histograms if wanted.
|
75 |
|
|
|
76 |
|
|
gSystem->Setenv("LHAPATH","");
|
77 |
|
|
LHAPDF::setVerbosity(LHAPDF::SILENT);
|
78 |
|
|
LHAPDF::initPDFSet(fPDFName.Data());
|
79 |
|
|
LHAPDF::getDescription();
|
80 |
|
|
|
81 |
|
|
ReqBranch(fMCEvInfoName, fMCEventInfo);
|
82 |
|
|
|
83 |
|
|
if (GetFillHist()) {
|
84 |
|
|
char sb[1024];
|
85 |
|
|
sprintf(sb,"hDPDFHisto_%d", 0);
|
86 |
|
|
hDPDFHisto[0] = new TH1D(sb,sb,1,0,1);
|
87 |
|
|
AddOutput(hDPDFHisto[0]);
|
88 |
|
|
}
|
89 |
|
|
}
|