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 
12  semiLepEvt_ (cfg.getParameter<edm::InputTag>("semiLepEvent")),
13  hypoClassKey_(cfg.getParameter<edm::InputTag>("hypoClassKey"))
14 {
15 }
16 
17 void
19 {
21  // get a handle for the TtSemiLeptonicEvent and a key to the hypothesis
23 
25  event.getByLabel(semiLepEvt_, semiLepEvt);
26 
27  edm::Handle<int> hypoClassKeyHandle;
28  event.getByLabel(hypoClassKey_, hypoClassKeyHandle);
29  TtSemiLeptonicEvent::HypoClassKey& hypoClassKey = (TtSemiLeptonicEvent::HypoClassKey&) *hypoClassKeyHandle;
30 
32  // check if hypothesis is available and valid in this event
34 
35  if( !semiLepEvt->isHypoValid(hypoClassKey) ){
36  edm::LogInfo("HypothesisAnalyzer") << "Hypothesis not valid for this event";
37  return;
38  }
39 
41  // get reconstructed top quarks and W bosons from the hypothesis
43 
44  const reco::Candidate* hadTop = semiLepEvt->hadronicDecayTop(hypoClassKey);
45  const reco::Candidate* hadW = semiLepEvt->hadronicDecayW (hypoClassKey);
46 
48  // fill simple histograms with pt, eta and the masses of the reconstructed particles
50 
51  if(hadW) {
52  hadWPt_ ->Fill( hadW->pt() );
53  hadWEta_ ->Fill( hadW->eta() );
54  hadWMass_->Fill( hadW->mass() );
55  }
56 
57  if(hadTop) {
58  hadTopPt_ ->Fill( hadTop->pt() );
59  hadTopEta_ ->Fill( hadTop->eta() );
60  hadTopMass_->Fill( hadTop->mass() );
61  }
62 
64  // get genParticles
66 
67  const reco::Candidate* genHadTop = semiLepEvt->hadronicDecayTop();
68  const reco::Candidate* genHadW = semiLepEvt->hadronicDecayW();
69 
71  // fill pull histograms for pt, eta and the masses of the reconstructed with respect to the generated particles
73 
74  if(hadW && genHadW) {
75  hadWPullPt_ ->Fill( (hadW->pt() - genHadW->pt()) / genHadW->pt() );
76  hadWPullEta_ ->Fill( (hadW->eta() - genHadW->eta()) / genHadW->eta() );
77  hadWPullMass_->Fill( (hadW->mass() - genHadW->mass()) / genHadW->mass() );
78  }
79 
80  if(hadTop && genHadTop) {
81  hadTopPullPt_ ->Fill( (hadTop->pt() - genHadTop->pt()) / genHadTop->pt() );
82  hadTopPullEta_ ->Fill( (hadTop->eta() - genHadTop->eta()) / genHadTop->eta() );
83  hadTopPullMass_->Fill( (hadTop->mass() - genHadTop->mass()) / genHadTop->mass() );
84  }
85 
87  // fill histograms with variables describing the quality of the hypotheses
89 
90  genMatchDr_->Fill(semiLepEvt->genMatchSumDR());
91  mvaDisc_ ->Fill(semiLepEvt->mvaDisc());
92 
93  if(hadTop && genHadTop) {
94 
95  genMatchDrVsHadTopPullMass_->Fill((hadTop->mass() - genHadTop->mass()) / genHadTop->mass(), semiLepEvt->genMatchSumDR());
96  mvaDiscVsHadTopPullMass_ ->Fill((hadTop->mass() - genHadTop->mass()) / genHadTop->mass(), semiLepEvt->mvaDisc());
97 
98  }
99 
100 }
101 
102 void
104 {
106  if( !fs ) throw edm::Exception( edm::errors::Configuration, "TFile Service is not registered in cfg file" );
107 
109  // book histograms
111 
112  hadWPt_ = fs->make<TH1F>("hadWPt" , "p_{t} (W_{had}) [GeV]", 25, 0., 500.);
113  hadWEta_ = fs->make<TH1F>("hadWEta" , "#eta (W_{had})" , 20, -4., 4.);
114  hadWMass_ = fs->make<TH1F>("hadWMass", "M (W_{had}) [GeV]" , 25, 0., 200.);
115 
116  hadTopPt_ = fs->make<TH1F>("hadTopPt" , "p_{t} (t_{had}) [GeV]", 25, 0. , 500.);
117  hadTopEta_ = fs->make<TH1F>("hadTopEta" , "#eta (t_{had})" , 20, -4., 4.);
118  hadTopMass_ = fs->make<TH1F>("hadTopMass", "M (t_{had}) [GeV]" , 40, 0. , 400.);
119 
120  hadWPullPt_ = fs->make<TH1F>("hadWPullPt" , "(p_{t,rec}-p_{t,gen})/p_{t,gen} (W_{had})" , 40, -1., 1.);
121  hadWPullEta_ = fs->make<TH1F>("hadWPullEta" , "(#eta_{rec}-#eta_{gen})/#eta_{gen} (W_{had})", 40, -1., 1.);
122  hadWPullMass_ = fs->make<TH1F>("hadWPullMass", "(M_{rec}-M_{gen})/M_{gen} (W_{had})" , 40, -1., 1.);
123 
124  hadTopPullPt_ = fs->make<TH1F>("hadTopPullPt" , "(p_{t,rec}-p_{t,gen})/p_{t,gen} (t_{had})" , 40, -1., 1.);
125  hadTopPullEta_ = fs->make<TH1F>("hadTopPullEta" , "(#eta_{rec}-#eta_{gen})/#eta_{gen} (t_{had})", 40, -1., 1.);
126  hadTopPullMass_ = fs->make<TH1F>("hadTopPullMass", "(M_{rec}-M_{gen})/M_{gen} (t_{had})" , 40, -1., 1.);
127 
128  genMatchDr_ = fs->make<TH1F>("genMatchDr", "GenMatch #Sigma #Delta R", 40, 0., 4.);
129  mvaDisc_ = fs->make<TH1F>("mvaDisc" , "MVA discriminator" , 20, 0., 1.);
130 
131  genMatchDrVsHadTopPullMass_ = fs->make<TH2F>("genMatchDrVsHadTopPullMass",
132  "GenMatch #Sigma #Delta R vs. (M_{rec}-M_{gen})/M_{gen} (t_{had}))",
133  40, -1., 1., 40, 0., 4.);
134  mvaDiscVsHadTopPullMass_ = fs->make<TH2F>("mvaDiscVsHadTopPullMass",
135  "MVA discriminator vs. (M_{rec}-M_{gen})/M_{gen} (t_{had}))",
136  40, -1., 1., 20, 0., 1.);
137 }
138 
139 void
141 {
142 }
HypoClassKey
supported classes of event hypotheses
Definition: TtEvent.h:31
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual double pt() const =0
transverse momentum
virtual double mass() const =0
mass
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
HypothesisAnalyzer(const edm::ParameterSet &)
edm::InputTag semiLepEvt_
T * make() const
make new ROOT object
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual double eta() const =0
momentum pseudorapidity
edm::InputTag hypoClassKey_