ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/EffMod.cc
Revision: 1.3
Committed: Fri Jul 10 14:04:43 2009 UTC (15 years, 9 months ago) by loizides
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, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010, HEAD
Changes since 1.2: +5 -5 lines
Log Message:
Cleanup

File Contents

# User Rev Content
1 loizides 1.3 // $Id: EffMod.cc,v 1.2 2009/06/29 08:41:50 loizides Exp $
2 loizides 1.1
3     #include "MitPhysics/Mods/interface/EffMod.h"
4     #include "MitAna/DataCont/interface/BaseCollection.h"
5     #include "MitPhysics/Init/interface/ModNames.h"
6     #include "MitCommon/MathTools/interface/MathUtils.h"
7     #include <TH1D.h>
8    
9     using namespace mithep;
10    
11     ClassImp(mithep::EffMod)
12    
13     //--------------------------------------------------------------------------------------------------
14     EffMod::EffMod(const char *name, const char *title) :
15     BaseMod(name,title),
16     fCol1Name(ModNames::gkMCLeptonsName),
17     fCol2Name(ModNames::gkMergedLeptonsName),
18     fMinPt(10),
19     fMaxEta(2.4),
20     fRadius(0.1),
21     fPartType(MCParticle::kUnknown)
22     {
23     // Constructor.
24     }
25    
26    
27     //--------------------------------------------------------------------------------------------------
28     void EffMod::Process()
29     {
30     // Process entries of the tree.
31    
32     const BaseCollection *col1 = GetObjThisEvt<BaseCollection>(fCol1Name);
33     const BaseCollection *col2 = GetObjThisEvt<BaseCollection>(fCol2Name);
34    
35     UInt_t ents1 = 0;
36     if (col1)
37     ents1 = col1->GetEntries();
38    
39     UInt_t ents2 = 0;
40     if (col2)
41     ents2 = col2->GetEntries();
42    
43     Bool_t *found = new Bool_t[ents2];
44     for (UInt_t i=0; i<ents2; ++i)
45     found[i] = kFALSE;
46    
47     // find matches
48     for (UInt_t j=0; j<ents1; ++j) {
49     const Particle *p1 = dynamic_cast<const Particle*>(col1->ObjAt(j));
50     if (!p1)
51     continue;
52    
53     if (fPartType != MCParticle::kUnknown) {
54     const MCParticle *mc = dynamic_cast<const MCParticle*>(p1);
55     if (!mc || !mc->Is(fPartType))
56     continue;
57     }
58    
59     Double_t pt = p1->Pt();
60     if (pt < fMinPt)
61     continue;
62     if (p1->AbsEta() > fMaxEta)
63     continue;
64    
65     Double_t phi = p1->Phi();
66     Double_t eta = p1->Eta();
67    
68     fCol1Pt->Fill(TMath::Min(pt, 299.999));
69     fCol1Eta->Fill(eta);
70    
71     UInt_t foundInd = ents2;
72     Double_t foundD = 1e12;
73    
74     for (UInt_t i=0; i<ents2; ++i) {
75     if (found[i]) continue;
76     const Particle *p2 = dynamic_cast<const Particle*>(col2->ObjAt(i));
77     if (!p2)
78     continue;
79    
80     if(MathUtils::DeltaR(phi, eta, p2->Phi(), p2->Eta()) < fRadius) {
81     Double_t newDiff = TMath::Abs(pt - p2->Pt());
82     if (newDiff < foundD) {
83     foundInd = i;
84     foundD = newDiff;
85     }
86     }
87     }
88     if (foundInd < ents2) {
89     fCol2Pt->Fill(TMath::Min(p1->Pt(),299.999));
90     fCol2Eta->Fill(p1->Eta());
91     found[foundInd] = 1;
92     }
93     }
94    
95     // find fakes
96     for (UInt_t i=0; i<ents2; ++i) {
97     const Particle *p2 = dynamic_cast<const Particle*>(col2->ObjAt(i));
98     if (!p2)
99     continue;
100     if (found[i]) {
101     fGoodPt->Fill(TMath::Min(p2->Pt(),299.999));
102     fGoodEta->Fill(p2->Eta());
103     } else {
104     fFakePt->Fill(TMath::Min(p2->Pt(),299.999));
105     fFakeEta->Fill(p2->Eta());
106     }
107     }
108    
109     }
110    
111     //--------------------------------------------------------------------------------------------------
112     void EffMod::SlaveBegin()
113     {
114     // Create and add histograms to the output list.
115    
116 loizides 1.3 AddTH1(fCol1Pt,"hCol1Pt",";p_{t} [GeV];#",100,0,300);
117 loizides 1.1 AddTH1(fCol1Eta,"hCol1Eta",";#eta;#",50,-5,5);
118 loizides 1.3 AddTH1(fCol2Pt,"hCol2Pt",";p_{t} [GeV];#",100,0,300);
119 loizides 1.1 AddTH1(fCol2Eta,"hCol2Eta",";#eta;#",50,-5,5);
120 loizides 1.3 AddTH1(fGoodPt,"hGoodPt",";p_{t} [GeV];#",100,0,300);
121 loizides 1.1 AddTH1(fGoodEta,"hGoodEta",";#eta;#",50,-5,5);
122 loizides 1.3 AddTH1(fFakePt,"hFakePt",";p_{t} [GeV];#",100,0,300);
123 loizides 1.1 AddTH1(fFakeEta,"hFakeEta",";#eta;#",50,-5,5);
124     }
125    
126     //--------------------------------------------------------------------------------------------------
127     void EffMod::Terminate()
128     {
129     // Create and add ratio histograms to the output list.
130    
131 loizides 1.2 if (gROOT->IsBatch()) {
132     TH1D *pteff = static_cast<TH1D*>(fCol2Pt->Clone("hPtEff"));
133     pteff->Divide(fCol1Pt);
134     AddOutput(pteff);
135    
136     TH1D *etaeff = static_cast<TH1D*>(fCol2Eta->Clone("hEtaEff"));
137     etaeff->Divide(fCol1Eta);
138     AddOutput(etaeff);
139    
140     TH1D *ptfrate = static_cast<TH1D*>(fFakePt->Clone("hPtFakeRate"));
141     ptfrate->Divide(fGoodPt);
142     AddOutput(ptfrate);
143    
144     TH1D *etafrate = static_cast<TH1D*>(fFakeEta->Clone("hEtaFakeRate"));
145     etafrate->Divide(fGoodEta);
146     AddOutput(etafrate);
147     }
148 loizides 1.1 }