ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PDFProducerMod.cc
Revision: 1.4
Committed: Wed May 12 19:06:53 2010 UTC (14 years, 11 months ago) by ceballos
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, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, HEAD
Changes since 1.3: +53 -50 lines
Log Message:
small additions

File Contents

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