CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 }
virtual void analyze(const edm::Event &, const edm::EventSetup &)
tuple cfg
Definition: looper.py:293
const std::string hypoClassKey_
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
Class derived from the TtEvent for the semileptonic decay channel.
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
const edm::EDGetTokenT< TtSemiLeptonicEvent > semiLepEvtToken_
HypothesisAnalyzer(const edm::ParameterSet &)
virtual double eta() const =0
momentum pseudorapidity