CMS 3D CMS Logo

HypothesisAnalyzer.cc
Go to the documentation of this file.
6 
8 
10  semiLepEvtToken_ (consumes<TtSemiLeptonicEvent>(cfg.getParameter<edm::InputTag>("semiLepEvent"))),
11  hypoClassKey_(cfg.getParameter<std::string>("hypoClassKey"))
12 {
13 }
14 
15 void
17 {
19  // get a handle for the TtSemiLeptonicEvent and a key to the hypothesis
21 
23  event.getByToken(semiLepEvtToken_, semiLepEvt);
24 
26  // check if hypothesis is available and valid in this event
28 
29  if( !semiLepEvt->isHypoValid(hypoClassKey_) ){
30  edm::LogInfo("HypothesisAnalyzer") << "Hypothesis " << hypoClassKey_ << " not valid for this event";
31  return;
32  }
33 
35  // get reconstructed top quarks, W bosons, the top pair and the neutrino from the hypothesis
37 
38  const reco::Candidate* topPair = semiLepEvt->topPair(hypoClassKey_);
39  const reco::Candidate* lepTop = semiLepEvt->leptonicDecayTop(hypoClassKey_);
40  const reco::Candidate* lepW = semiLepEvt->leptonicDecayW(hypoClassKey_);
41  const reco::Candidate* hadTop = semiLepEvt->hadronicDecayTop(hypoClassKey_);
42  const reco::Candidate* hadW = semiLepEvt->hadronicDecayW(hypoClassKey_);
43  const reco::Candidate* neutrino = semiLepEvt->singleNeutrino(hypoClassKey_);
44 
46  // fill simple histograms with kinematic variables of the reconstructed particles
48 
49  if(topPair)
50  topPairMass_->Fill( topPair->mass() );
51  if(hadW) {
52  hadWPt_ ->Fill( hadW->pt() );
53  hadWEta_ ->Fill( hadW->eta() );
54  hadWMass_->Fill( hadW->mass() );
55  }
56  if(hadTop) {
57  hadTopPt_ ->Fill( hadTop->pt() );
58  hadTopEta_ ->Fill( hadTop->eta() );
59  hadTopMass_->Fill( hadTop->mass() );
60  }
61  if(lepW) {
62  lepWPt_ ->Fill( lepW->pt() );
63  lepWEta_ ->Fill( lepW->eta() );
64  lepWMass_->Fill( lepW->mass() );
65  }
66  if(lepTop) {
67  lepTopPt_ ->Fill( lepTop->pt() );
68  lepTopEta_ ->Fill( lepTop->eta() );
69  lepTopMass_->Fill( lepTop->mass() );
70  }
71  if(neutrino)
72  neutrinoEta_->Fill( neutrino->eta() );
73 
75  // get corresponding genParticles
77 
78  const math::XYZTLorentzVector* genTopPair = semiLepEvt->topPair();
79  const reco::Candidate* genHadTop = semiLepEvt->hadronicDecayTop();
80  const reco::Candidate* genHadW = semiLepEvt->hadronicDecayW();
81  const reco::Candidate* genLepTop = semiLepEvt->leptonicDecayTop();
82  const reco::Candidate* genLepW = semiLepEvt->leptonicDecayW();
83  const reco::Candidate* genNeutrino = semiLepEvt->singleNeutrino();
84 
86  // fill pull histograms of kinematic variables with respect to the generated particles
88 
89  if(topPair && genTopPair)
90  topPairPullMass_->Fill( (topPair->mass()-genTopPair->mass())/ genTopPair->mass() );
91  if(hadW && genHadW) {
92  hadWPullPt_ ->Fill( (hadW->pt() - genHadW->pt()) / genHadW->pt() );
93  hadWPullEta_ ->Fill( (hadW->eta() - genHadW->eta()) / genHadW->eta() );
94  hadWPullMass_->Fill( (hadW->mass() - genHadW->mass()) / genHadW->mass() );
95  }
96 
97  if(hadTop && genHadTop) {
98  hadTopPullPt_ ->Fill( (hadTop->pt() - genHadTop->pt()) / genHadTop->pt() );
99  hadTopPullEta_ ->Fill( (hadTop->eta() - genHadTop->eta()) / genHadTop->eta() );
100  hadTopPullMass_->Fill( (hadTop->mass() - genHadTop->mass()) / genHadTop->mass() );
101  }
102  if(lepW && genLepW) {
103  lepWPullPt_ ->Fill( (lepW->pt() - genLepW->pt()) / genLepW->pt() );
104  lepWPullEta_ ->Fill( (lepW->eta() - genLepW->eta()) / genLepW->eta() );
105  lepWPullMass_->Fill( (lepW->mass() - genLepW->mass()) / genLepW->mass() );
106  }
107 
108  if(lepTop && genLepTop) {
109  lepTopPullPt_ ->Fill( (lepTop->pt() - genLepTop->pt()) / genLepTop->pt() );
110  lepTopPullEta_ ->Fill( (lepTop->eta() - genLepTop->eta()) / genLepTop->eta() );
111  lepTopPullMass_->Fill( (lepTop->mass() - genLepTop->mass()) / genLepTop->mass() );
112  }
113  if(neutrino && genNeutrino)
114  neutrinoPullEta_->Fill( (neutrino->eta()-genNeutrino->eta()) / genNeutrino->eta() );
115 
117  // fill histograms with variables describing the quality of the hypotheses
119 
120  genMatchDr_->Fill(semiLepEvt->genMatchSumDR());
121  kinFitProb_->Fill(semiLepEvt->fitProb());
122 
123  if(hadTop && genHadTop) {
124  genMatchDrVsHadTopPullMass_->Fill((hadTop->mass() - genHadTop->mass()) / genHadTop->mass(), semiLepEvt->genMatchSumDR());
125  kinFitProbVsHadTopPullMass_->Fill((hadTop->mass() - genHadTop->mass()) / genHadTop->mass(), semiLepEvt->fitProb());
126  }
127 
128 }
129 
130 void
132 {
134  if( !fs ) throw edm::Exception( edm::errors::Configuration, "TFile Service is not registered in cfg file" );
135 
137  // book histograms
139 
140  neutrinoEta_ = fs->make<TH1F>("neutrinoEta", "#eta (neutrino)", 21, -4., 4.);
141  neutrinoPullEta_ = fs->make<TH1F>("neutrinoPullEta", "(#eta_{rec}-#eta_{gen})/#eta_{gen} (neutrino)", 40, -1., 1.);
142 
143  hadWPt_ = fs->make<TH1F>("hadWPt" , "p_{T} (W_{had}) [GeV]", 25, 0., 500.);
144  hadWEta_ = fs->make<TH1F>("hadWEta" , "#eta (W_{had})" , 21, -4., 4.);
145  hadWMass_ = fs->make<TH1F>("hadWMass", "M (W_{had}) [GeV]" , 25, 0., 200.);
146 
147  hadTopPt_ = fs->make<TH1F>("hadTopPt" , "p_{T} (t_{had}) [GeV]", 25, 0. , 500.);
148  hadTopEta_ = fs->make<TH1F>("hadTopEta" , "#eta (t_{had})" , 21, -4., 4.);
149  hadTopMass_ = fs->make<TH1F>("hadTopMass", "M (t_{had}) [GeV]" , 40, 0. , 400.);
150 
151  lepWPt_ = fs->make<TH1F>("lepWPt" , "p_{t} (W_{lep}) [GeV]", 25, 0., 500.);
152  lepWEta_ = fs->make<TH1F>("lepWEta" , "#eta (W_{lep})" , 21, -4., 4.);
153  lepWMass_ = fs->make<TH1F>("lepWMass", "M (W_{lep}) [GeV]" , 25, 0., 200.);
154 
155  lepTopPt_ = fs->make<TH1F>("lepTopPt" , "p_{T} (t_{lep}) [GeV]", 25, 0. , 500.);
156  lepTopEta_ = fs->make<TH1F>("lepTopEta" , "#eta (t_{lep})" , 21, -4., 4.);
157  lepTopMass_ = fs->make<TH1F>("lepTopMass", "M (t_{lep}) [GeV]" , 40, 0. , 400.);
158 
159  hadWPullPt_ = fs->make<TH1F>("hadWPullPt" , "(p_{T,rec}-p_{T,gen})/p_{T,gen} (W_{had})" , 40, -1., 1.);
160  hadWPullEta_ = fs->make<TH1F>("hadWPullEta" , "(#eta_{rec}-#eta_{gen})/#eta_{gen} (W_{had})", 40, -1., 1.);
161  hadWPullMass_ = fs->make<TH1F>("hadWPullMass", "(M_{rec}-M_{gen})/M_{gen} (W_{had})" , 40, -1., 1.);
162 
163  hadTopPullPt_ = fs->make<TH1F>("hadTopPullPt" , "(p_{T,rec}-p_{T,gen})/p_{T,gen} (t_{had})" , 40, -1., 1.);
164  hadTopPullEta_ = fs->make<TH1F>("hadTopPullEta" , "(#eta_{rec}-#eta_{gen})/#eta_{gen} (t_{had})", 40, -1., 1.);
165  hadTopPullMass_ = fs->make<TH1F>("hadTopPullMass", "(M_{rec}-M_{gen})/M_{gen} (t_{had})" , 40, -1., 1.);
166 
167  lepWPullPt_ = fs->make<TH1F>("lepWPullPt" , "(p_{T,rec}-p_{T,gen})/p_{T,gen} (W_{lep})" , 40, -1., 1.);
168  lepWPullEta_ = fs->make<TH1F>("lepWPullEta" , "(#eta_{rec}-#eta_{gen})/#eta_{gen} (W_{lep})", 40, -1., 1.);
169  lepWPullMass_ = fs->make<TH1F>("lepWPullMass", "(M_{rec}-M_{gen})/M_{gen} (W_{lep})" , 40, -1., 1.);
170 
171  lepTopPullPt_ = fs->make<TH1F>("lepTopPullPt" , "(p_{T,rec}-p_{T,gen})/p_{T,gen} (t_{lep})" , 40, -1., 1.);
172  lepTopPullEta_ = fs->make<TH1F>("lepTopPullEta" , "(#eta_{rec}-#eta_{gen})/#eta_{gen} (t_{lep})", 40, -1., 1.);
173  lepTopPullMass_ = fs->make<TH1F>("lepTopPullMass", "(M_{rec}-M_{gen})/M_{gen} (t_{lep})" , 40, -1., 1.);
174 
175  topPairMass_ = fs->make<TH1F>("topPairMass", "M (t#bar{t})", 36, 340., 940.);
176  topPairPullMass_ = fs->make<TH1F>("topPairPullMass", "(M_{rec}-M_{gen})/M_{gen} (t#bar{t})", 40, -1., 1.);
177 
178  genMatchDr_ = fs->make<TH1F>("genMatchDr", "GenMatch #Sigma#DeltaR", 40, 0., 4.);
179  kinFitProb_ = fs->make<TH1F>("kinFitProb", "KinFit probability" , 50, 0., 1.);
180 
181  genMatchDrVsHadTopPullMass_ = fs->make<TH2F>("genMatchDrVsHadTopPullMass",
182  "GenMatch #Sigma #Delta R vs. (M_{rec}-M_{gen})/M_{gen} (t_{had}))",
183  40, -1., 1., 40, 0., 4.);
184  kinFitProbVsHadTopPullMass_ = fs->make<TH2F>("kinFitProbVsHadTopPullMass",
185  "KinFit probability vs. (M_{rec}-M_{gen})/M_{gen} (t_{had}))",
186  40, -1., 1., 20, 0., 1.);
187 }
188 
189 void
191 {
192 }
const reco::Candidate * leptonicDecayW(const std::string &key, const unsigned &cmb=0) const
get leptonic W of the given hypothesis
const std::string hypoClassKey_
const reco::Candidate * hadronicDecayW(const std::string &key, const unsigned &cmb=0) const
get hadronic W of the given hypothesis
const reco::Candidate * hadronicDecayTop(const std::string &key, const unsigned &cmb=0) const
get hadronic top of the given hypothesis
Class derived from the TtEvent for the semileptonic decay channel.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double genMatchSumDR(const unsigned &cmb=0) const
return the sum dr of the generator match if available; -1 else
Definition: TtEvent.h:84
void analyze(const edm::Event &, const edm::EventSetup &) override
const edm::EDGetTokenT< TtSemiLeptonicEvent > semiLepEvtToken_
const reco::Candidate * leptonicDecayTop(const std::string &key, const unsigned &cmb=0) const
get leptonic top of the given hypothesis
void beginJob() override
HypothesisAnalyzer(const edm::ParameterSet &)
virtual double eta() const =0
momentum pseudorapidity
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
double fitProb(const unsigned &cmb=0) const
return the fit probability of hypothesis &#39;cmb&#39; if available; -1 else
Definition: TtEvent.h:94
bool isHypoValid(const std::string &key, const unsigned &cmb=0) const
check if hypothesis &#39;cmb&#39; within the hypothesis class was valid; if not it lead to an empty Composite...
Definition: TtEvent.h:64
HLT enums.
void endJob() override
const reco::Candidate * topPair(const std::string &key, const unsigned &cmb=0) const
get combined 4-vector of top and topBar of the given hypothesis
Definition: TtEvent.h:107
Definition: event.py:1
const reco::Candidate * singleNeutrino(const std::string &key, const unsigned &cmb=0) const
get leptonic light quark of the given hypothesis