ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/HKFactorProducer.cc
Revision: 1.8
Committed: Mon Sep 27 15:49:24 2010 UTC (14 years, 7 months ago) by ceballos
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_015
Changes since 1.7: +7 -4 lines
Log Message:
small fix

File Contents

# User Rev Content
1 ceballos 1.8 // $Id: HKFactorProducer.cc,v 1.7 2010/03/13 20:50:32 ceballos Exp $
2 ceballos 1.1
3     #include "MitPhysics/Mods/interface/HKFactorProducer.h"
4     #include "MitCommon/MathTools/interface/MathUtils.h"
5 loizides 1.3 #include "MitAna/DataTree/interface/MCParticleCol.h"
6 ceballos 1.1 #include "MitPhysics/Init/interface/ModNames.h"
7     #include <TH1D.h>
8     #include <TH2D.h>
9     #include <TParameter.h>
10    
11     using namespace mithep;
12    
13     ClassImp(mithep::HKFactorProducer)
14    
15     //--------------------------------------------------------------------------------------------------
16     HKFactorProducer::HKFactorProducer(const char *name, const char *title) :
17     BaseMod(name,title),
18     fProcessID(102),
19 loizides 1.2 fInputFileName("setme"),
20 ceballos 1.1 fMCBosonsName(ModNames::gkMCBosonsName),
21 loizides 1.2 fMCEvInfoName(Names::gkMCEvtInfoBrn),
22 ceballos 1.6 fIsData(kFALSE),
23 loizides 1.2 fPt_histo(0),
24 ceballos 1.1 fMCEventInfo(0)
25     {
26 loizides 1.2 // Constructor
27 ceballos 1.1 }
28    
29 loizides 1.2 //--------------------------------------------------------------------------------------------------
30 ceballos 1.1 HKFactorProducer::~HKFactorProducer()
31     {
32 loizides 1.2 // Destructor
33    
34 ceballos 1.1 delete fPt_histo;
35     }
36    
37     //--------------------------------------------------------------------------------------------------
38     void HKFactorProducer::Process()
39     {
40     // Process entries of the tree.
41    
42     Double_t theWeight = 1.0;
43 loizides 1.2
44 ceballos 1.6 if(fIsData == kFALSE){
45     // get the bosons
46     MCParticleCol *GenBosons = GetObjThisEvt<MCParticleCol>(fMCBosonsName);
47    
48     LoadBranch(fMCEvInfoName);
49    
50     // only accept the exact process id
51     if (fProcessID == fMCEventInfo->ProcessId()) {
52    
53     Double_t ptH = -1.0;
54     for (UInt_t i=0; i<GenBosons->GetEntries(); ++i) {
55     if(GenBosons->At(i)->PdgId() == MCParticle::kH) {
56     ptH = GenBosons->At(i)->Pt();
57     break;
58     }
59 ceballos 1.1 }
60 loizides 1.2
61 ceballos 1.6 if(ptH >= 0) {
62     // calculate bin size
63     Double_t binsize = fPt_histo->GetXaxis()->GetXmax()/fPt_histo->GetNbinsX();
64     // get bin
65     Int_t bin = Int_t((ptH/binsize)) + 1;
66     // overflow protection: use last entry
67     if(bin > fPt_histo->GetNbinsX()) bin=fPt_histo->GetNbinsX();
68     theWeight = fPt_histo->GetBinContent(bin);
69    
70     if (0) {
71     cout << "Bin Size: " << binsize << ", Higgs Pt: " << ptH
72     << ", Bin: "<< bin << ", KFactor: "<< fPt_histo->GetBinContent(bin) << endl;
73     }
74    
75     if (GetFillHist()) {
76     hDHKFactor[0]->Fill(0.5);
77     hDHKFactor[1]->Fill(TMath::Min(ptH,499.999));
78     hDHKFactor[2]->Fill(TMath::Min(ptH,499.999),theWeight);
79 ceballos 1.7 hDHKFactor[3]->Fill(TMath::Max(TMath::Min(theWeight,3.999),-3.999));
80 ceballos 1.6 }
81 ceballos 1.1 }
82 ceballos 1.8 } else if (fProcessID == 999){
83 ceballos 1.7 theWeight = fMCEventInfo->Weight();
84 ceballos 1.8 if (GetFillHist()) hDHKFactor[3]->Fill(TMath::Max(TMath::Min(theWeight,3.999),-3.999));
85 ceballos 1.7 theWeight = theWeight/fabs(theWeight);
86 ceballos 1.8 if (GetFillHist()) hDHKFactor[0]->Fill(0.5,theWeight);
87     }
88     else {
89     if (GetFillHist()) hDHKFactor[0]->Fill(0.5,1.0);
90 ceballos 1.1 }
91 ceballos 1.6 // process id distribution
92     if (GetFillHist()) hDHKFactor[4]->Fill(TMath::Min((Double_t)fMCEventInfo->ProcessId(),999.499));
93 ceballos 1.1 }
94    
95     TParameter<Double_t> *NNLOWeight = new TParameter<Double_t>("NNLOWeight", theWeight);
96     AddObjThisEvt(NNLOWeight);
97     }
98    
99     //--------------------------------------------------------------------------------------------------
100     void HKFactorProducer::SlaveBegin()
101     {
102     // Book branch and histograms if wanted.
103    
104 ceballos 1.6 if(fIsData == kFALSE){
105     ReqBranch(fMCEvInfoName, fMCEventInfo);
106     }
107 loizides 1.2
108     if (!fPt_histo) {
109     Info("SlaveBegin", "Using %s as input data file", fInputFileName.Data());
110     fPt_histo = new HWWKfactorList("KFactorList", fInputFileName);
111     }
112 ceballos 1.1
113 loizides 1.2 if (GetFillHist()) {
114 ceballos 1.1 char sb[1024];
115     sprintf(sb,"hDHKFactor_%d", 0); hDHKFactor[0] = new TH1D(sb,sb,1,0,1);
116     sprintf(sb,"hDHKFactor_%d", 1); hDHKFactor[1] = new TH1D(sb,sb,500,0.,500.);
117     sprintf(sb,"hDHKFactor_%d", 2); hDHKFactor[2] = new TH1D(sb,sb,500,0.,500.);
118 ceballos 1.7 sprintf(sb,"hDHKFactor_%d", 3); hDHKFactor[3] = new TH1D(sb,sb,400,-4.0,4.0);
119 ceballos 1.4 sprintf(sb,"hDHKFactor_%d", 4); hDHKFactor[4] = new TH1D(sb,sb,1000,-0.5,999.5);
120     for(Int_t i=0; i<5; i++) AddOutput(hDHKFactor[i]);
121 ceballos 1.1 }
122     }