1 |
#include "TrkUpgradeAnalysis/VHbb/interface/NTupleCandidateProxy.h"
|
2 |
|
3 |
#include <stdexcept>
|
4 |
#include <cmath>
|
5 |
#include <iostream>
|
6 |
|
7 |
#include <TTree.h>
|
8 |
|
9 |
// Use the unnamed namespace for things I only want in this file
|
10 |
namespace
|
11 |
{
|
12 |
// These are copied from VHbbAnalysis/VHbbDataFormats/bin/Ntupler.cc,
|
13 |
// I tried including the file to get them but it causes linker errors.
|
14 |
#define MAXJ 30
|
15 |
#define MAXL 10
|
16 |
#define MAXB 10
|
17 |
struct HiggsInfo
|
18 |
{
|
19 |
float mass;
|
20 |
float pt;
|
21 |
float eta;
|
22 |
float phi;
|
23 |
float dR;
|
24 |
float dPhi;
|
25 |
float dEta;
|
26 |
~HiggsInfo() {}
|
27 |
};
|
28 |
|
29 |
struct TrackInfo
|
30 |
{
|
31 |
float mass; //MT in case of W
|
32 |
float pt;
|
33 |
float eta;
|
34 |
float phi;
|
35 |
~TrackInfo() {}
|
36 |
};
|
37 |
|
38 |
/** @brief My wrapper around the ntuple jet info
|
39 |
*
|
40 |
* @author Mark Grimes (mark.grimes@bristol.ac.uk)
|
41 |
* @date 05/Mar/12
|
42 |
*/
|
43 |
struct JetInfo
|
44 |
{
|
45 |
bool id[MAXJ];
|
46 |
float eta[MAXJ];
|
47 |
float pt[MAXJ];
|
48 |
float csv[MAXJ];
|
49 |
|
50 |
void setBranchAddress( TTree* pTree, const std::string& namePrefix )
|
51 |
{
|
52 |
pTree->SetBranchAddress( (namePrefix+"id").c_str(), &id );
|
53 |
pTree->SetBranchAddress( (namePrefix+"eta").c_str(), &eta );
|
54 |
pTree->SetBranchAddress( (namePrefix+"pt").c_str(), &pt );
|
55 |
pTree->SetBranchAddress( (namePrefix+"csv").c_str(), &csv );
|
56 |
}
|
57 |
~JetInfo() {}
|
58 |
};
|
59 |
}
|
60 |
|
61 |
namespace trkupgradeanalysis
|
62 |
{
|
63 |
|
64 |
/** @brief The pimple definition for the NTupleCandidateProxy class
|
65 |
*
|
66 |
* Google "pimple idiom" if you don't know what this is about.
|
67 |
*
|
68 |
* @author Mark Grimes (mark.grimes@bristol.ac.uk)
|
69 |
* @date 05/Mar/12
|
70 |
*/
|
71 |
struct NTupleCandidateProxy_pImple
|
72 |
{
|
73 |
~NTupleCandidateProxy_pImple() {}
|
74 |
|
75 |
int Vtype; ///< @brief The CandidateType.
|
76 |
|
77 |
HiggsInfo H;
|
78 |
TrackInfo V;
|
79 |
|
80 |
::JetInfo hJet;
|
81 |
::JetInfo aJet;
|
82 |
int nhJets; ///< @brief The number of additional jets before any cleaning.
|
83 |
// bool hJet_id[MAXJ]; // MAXJ is defined in Ntupler.cc
|
84 |
// float hJet_eta[MAXJ];
|
85 |
// float hJet_pt[MAXJ];
|
86 |
|
87 |
int naJets; ///< @brief The number of additional jets before any cleaning.
|
88 |
// bool aJet_id[MAXJ]; // MAXJ is defined in Ntupler.cc
|
89 |
// float aJet_eta[MAXJ];
|
90 |
// float aJet_pt[MAXJ];
|
91 |
|
92 |
};
|
93 |
}
|
94 |
|
95 |
trkupgradeanalysis::NTupleCandidateProxy::NTupleCandidateProxy( TTree* pTree )
|
96 |
: pTree_(pTree), pImple_( new NTupleCandidateProxy_pImple )
|
97 |
{
|
98 |
pTree_->SetBranchAddress("Vtype",&pImple_->Vtype);
|
99 |
|
100 |
pTree_->SetBranchAddress("H",&pImple_->H);
|
101 |
pTree_->SetBranchAddress("V",&pImple_->V);
|
102 |
|
103 |
pTree_->SetBranchAddress("nhJets",&pImple_->nhJets);
|
104 |
pImple_->hJet.setBranchAddress( pTree_, "hJet_" );
|
105 |
|
106 |
pTree_->SetBranchAddress("naJets",&pImple_->naJets);
|
107 |
pImple_->aJet.setBranchAddress( pTree_, "aJet_" );
|
108 |
|
109 |
maxCandidateNumber_=pTree_->GetEntries();
|
110 |
candidateNumber_=-1; // Set to minus one, so that the first call to nextCandidate() sets it to the first (0) entry
|
111 |
pTree_->GetEntry(0); // Load in the first candidate so that the memory contents isn't random. Note the first call to nextCandidate() will keep it on the 0th entry.
|
112 |
}
|
113 |
|
114 |
trkupgradeanalysis::NTupleCandidateProxy::~NTupleCandidateProxy()
|
115 |
{
|
116 |
// No operation
|
117 |
}
|
118 |
|
119 |
bool trkupgradeanalysis::NTupleCandidateProxy::nextCandidate()
|
120 |
{
|
121 |
++candidateNumber_;
|
122 |
if( candidateNumber_>=maxCandidateNumber_ ) return false;
|
123 |
|
124 |
pTree_->GetEntry(candidateNumber_);
|
125 |
return true;
|
126 |
}
|
127 |
|
128 |
int trkupgradeanalysis::NTupleCandidateProxy::numberOfRawAdditionalJets()
|
129 |
{
|
130 |
return pImple_->naJets;
|
131 |
}
|
132 |
|
133 |
int trkupgradeanalysis::NTupleCandidateProxy::numberOfAdditionalJets()
|
134 |
{
|
135 |
int numberOfAdditionalJets=0;
|
136 |
for( int b=0; b<pImple_->naJets; ++b )
|
137 |
{
|
138 |
// if( b==MAXJ ) throw std::runtime_error("VHbbEvent::numberOfAdditionalJets() - Too many additional jets.");
|
139 |
if( pImple_->aJet.id[b] == 1 && std::fabs(pImple_->aJet.eta[b]) < 2.5 && pImple_->aJet.pt[b] > 20) ++numberOfAdditionalJets;
|
140 |
// std::cout << "pImple_->aJet.id[b]=" << pImple_->aJet.id[b] << " std::fabs(pImple_->aJet.eta[b])=" << std::fabs(pImple_->aJet.eta[b]) << " pImple_->aJet.pt[b]=" << pImple_->aJet.pt[b] << std::endl;
|
141 |
}
|
142 |
return numberOfAdditionalJets;
|
143 |
}
|
144 |
|
145 |
|
146 |
int trkupgradeanalysis::NTupleCandidateProxy::candidateType()
|
147 |
{
|
148 |
return pImple_->Vtype;
|
149 |
}
|
150 |
|
151 |
int trkupgradeanalysis::NTupleCandidateProxy::numberOfHiggsCandidateJets()
|
152 |
{
|
153 |
return pImple_->nhJets;
|
154 |
}
|
155 |
|
156 |
float trkupgradeanalysis::NTupleCandidateProxy::csvOfHiggsCandidateJet( int jetNumber )
|
157 |
{
|
158 |
if( jetNumber>=pImple_->nhJets || jetNumber>=MAXJ || jetNumber<0 ) throw std::runtime_error("NTupleCandidateProxy::csvOfHiggsCandidateJet() - Invalid jet number.");
|
159 |
|
160 |
return pImple_->hJet.csv[jetNumber];
|
161 |
}
|
162 |
|
163 |
float trkupgradeanalysis::NTupleCandidateProxy::zMass()
|
164 |
{
|
165 |
return pImple_->V.mass;
|
166 |
}
|
167 |
|