ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PDFProducerMod.cc
Revision: 1.3
Committed: Sat Mar 13 20:50:03 2010 UTC (15 years, 1 month ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1
Changes since 1.2: +36 -29 lines
Log Message:
adding run

File Contents

# Content
1 // $Id: PDFProducerMod.cc,v 1.2 2009/12/06 14:59:28 ceballos 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 "MitAna/DataTree/interface/ParticleCol.h"
7 #include "MitPhysics/Init/interface/ModNames.h"
8 #include <TH1D.h>
9 #include <TH2D.h>
10 #include <TSystem.h>
11 #include "LHAPDF/LHAPDF.h"
12
13 using namespace mithep;
14
15 ClassImp(mithep::PDFProducerMod)
16
17 //--------------------------------------------------------------------------------------------------
18 PDFProducerMod::PDFProducerMod(const char *name, const char *title) :
19 BaseMod(name,title),
20 fPrintDebug(kFALSE),
21 fMCEvInfoName(Names::gkMCEvtInfoBrn),
22 fPDFName("cteq65.LHgrid"),
23 fRunPDF(kFALSE),
24 fMCEventInfo(0)
25 {
26 // Constructor
27 }
28
29 //--------------------------------------------------------------------------------------------------
30 void PDFProducerMod::Process()
31 {
32 // Process entries of the tree.
33
34 LoadBranch(fMCEvInfoName);
35
36 Double_t Q = fMCEventInfo->Scale();
37 Int_t id1 = fMCEventInfo->Id1();
38 Double_t x1 = fMCEventInfo->X1();
39 Double_t pdf1 = fMCEventInfo->Pdf1();
40 Int_t id2 = fMCEventInfo->Id2();
41 Double_t x2 = fMCEventInfo->X2();
42 Double_t pdf2 = fMCEventInfo->Pdf2();
43
44 if (GetFillHist()) {
45 hDPDFHisto[0]->Fill(TMath::Min(Q,999.999));
46 hDPDFHisto[1]->Fill(TMath::Min(pdf1,999.999));
47 hDPDFHisto[2]->Fill(TMath::Min(pdf2,999.999));
48 hDPDFHisto[3]->Fill(TMath::Min(x1,0.999));
49 hDPDFHisto[4]->Fill(TMath::Min(x2,0.999));
50 if(x1 + x2 > 0){
51 hDPDFHisto[5]->Fill(TMath::Min(x1/(x1+x2),0.999));
52 }
53 }
54
55 UInt_t nmembers = LHAPDF::numberPDF() + 1;
56
57 // Array to be filled
58 FArrDouble *PDFArr = new FArrDouble(nmembers);
59
60 if(fRunPDF == kTRUE){
61 ParticleOArr *leptons = GetObjThisEvt<ParticleOArr>(ModNames::gkMergedLeptonsName);
62 if(leptons->GetEntries() >= 2){ // Nlep >= 2 to fill it
63 if (fPrintDebug)
64 cout << "Start loop over PDF members:" << endl;
65
66 for (UInt_t i=0; i<nmembers; ++i) {
67 LHAPDF::usePDFMember(i);
68 Double_t newpdf1 = LHAPDF::xfx(x1, Q, id1)/x1;
69 Double_t newpdf2 = LHAPDF::xfx(x2, Q, id2)/x2;
70 Double_t TheWeight = newpdf1/pdf1*newpdf2/pdf2;
71
72 if (fPrintDebug) {
73 cout << i << " --> " << pdf1 << " " << pdf2 << " | "
74 << x1 << " " << x2 << " | "
75 << id1 << " " << id2 << " | "
76 << Q << " : " << TheWeight << endl;
77 }
78 if (GetFillHist()) {
79 hDPDFHisto[6]->Fill(TMath::Min(TheWeight,99.999));
80 hDPDFHisto[7]->Fill(TheWeight);
81 }
82 PDFArr->Add(TheWeight);
83 }
84 } // Nlep >= 2 to fill it
85 else {
86 for (UInt_t i=0; i<nmembers; ++i) PDFArr->Add(1.0);
87 }
88 }
89
90 AddObjThisEvt(PDFArr, "PDFWeights");
91 }
92
93 //--------------------------------------------------------------------------------------------------
94 void PDFProducerMod::SlaveBegin()
95 {
96 // Setup LHAPDF and book branch and histograms if wanted.
97
98 gSystem->Setenv("LHAPATH","");
99 LHAPDF::setVerbosity(LHAPDF::SILENT);
100 LHAPDF::initPDFSet(fPDFName.Data());
101 LHAPDF::getDescription();
102
103 ReqBranch(fMCEvInfoName, fMCEventInfo);
104
105 if (GetFillHist()) {
106 char sb[1024];
107 sprintf(sb,"hDPDFHisto_%d", 0); hDPDFHisto[0] = new TH1D(sb,sb,500,0,1000);
108 sprintf(sb,"hDPDFHisto_%d", 1); hDPDFHisto[1] = new TH1D(sb,sb,500,0,1000);
109 sprintf(sb,"hDPDFHisto_%d", 2); hDPDFHisto[2] = new TH1D(sb,sb,500,0,1000);
110 sprintf(sb,"hDPDFHisto_%d", 3); hDPDFHisto[3] = new TH1D(sb,sb,100,0,1);
111 sprintf(sb,"hDPDFHisto_%d", 4); hDPDFHisto[4] = new TH1D(sb,sb,100,0,1);
112 sprintf(sb,"hDPDFHisto_%d", 5); hDPDFHisto[5] = new TH1D(sb,sb,100,0,1);
113 sprintf(sb,"hDPDFHisto_%d", 6); hDPDFHisto[6] = new TH1D(sb,sb,500,0,100);
114 sprintf(sb,"hDPDFHisto_%d", 7); hDPDFHisto[7] = new TH1D(sb,sb,1,0,1);
115 for(int i=0; i<8; i++){
116 AddOutput(hDPDFHisto[i]);
117 }
118 }
119 }