ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/PDFProducerMod.cc
Revision: 1.2
Committed: Sun Dec 6 14:59:28 2009 UTC (15 years, 5 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_012i, Mit_012g, Mit_012f, Mit_012e
Changes since 1.1: +45 -22 lines
Log Message:
small updates

File Contents

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