CMS 3D CMS Logo

PatBJetTagAnalyzer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <vector>
4 #include <string>
5 
6 #include <TH1.h>
7 
15 
17 
19 
21  public:
24  ~PatBJetTagAnalyzer() override;
25 
26  // virtual methods called from base class EDAnalyzer
27  void beginJob() override;
28  void analyze(const edm::Event &event, const edm::EventSetup &es) override;
29 
30  private:
31  // configuration parameters
33 
34  double jetPtCut_; // minimum (uncorrected) jet energy
35  double jetEtaCut_; // maximum |eta| for jet
36 
37  // jet flavour constants
38 
39  enum Flavour {
40  ALL_JETS = 0,
46  };
47 
48  TH1 * flavours_;
49 
50  // one group of plots per jet flavour;
51  struct Plots {
54 };
55 
57  jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
58  jetPtCut_(params.getParameter<double>("jetPtCut")),
59  jetEtaCut_(params.getParameter<double>("jetEtaCut"))
60 {
61 }
62 
64 {
65 }
66 
68 {
69  // retrieve handle to auxiliary service
70  // used for storing histograms into ROOT file
72 
73  flavours_ = fs->make<TH1F>("flavours", "jet flavours", 5, 0, 5);
74 
75  // book histograms for all jet flavours
76  for(unsigned int i = 0; i < N_JET_TYPES; i++) {
77  Plots &plots = plots_[i];
78  const char *flavour, *name;
79 
80  switch((Flavour)i) {
81  case ALL_JETS:
82  flavour = "all jets";
83  name = "all";
84  break;
85  case UDSG_JETS:
86  flavour = "light flavour jets";
87  name = "udsg";
88  break;
89  case C_JETS:
90  flavour = "charm jets";
91  name = "c";
92  break;
93  case B_JETS:
94  flavour = "bottom jets";
95  name = "b";
96  break;
97  default:
98  flavour = "unidentified jets";
99  name = "ni";
100  break;
101  }
102 
103  plots.discrTC = fs->make<TH1F>(Form("discrTC_%s", name),
104  Form("track counting (\"high efficiency\") in %s", flavour),
105  100, 0, 20);
106  plots.discrSSV = fs->make<TH1F>(Form("discrSSV_%s", name),
107  Form("simple secondary vertex in %s", flavour),
108  100, 0, 10);
109  plots.discrCSV = fs->make<TH1F>(Form("discrCSV_%s", name),
110  Form("combined secondary vertex in %s", flavour),
111  100, 0, 1);
112  }
113 }
114 
116 {
117  // handle to the jets collection
119  event.getByToken(jetsToken_, jetsHandle);
120 
121  // now go through all jets
122  for(pat::JetCollection::const_iterator jet = jetsHandle->begin();
123  jet != jetsHandle->end(); ++jet) {
124 
125  // only look at jets that pass the pt and eta cut
126  if (jet->pt() < jetPtCut_ ||
127  std::abs(jet->eta()) > jetEtaCut_)
128  continue;
129 
131  // find out the jet flavour (differs between quark and anti-quark)
132  switch(std::abs(jet->partonFlavour())) {
133  case 1:
134  case 2:
135  case 3:
136  case 21:
137  flavour = UDSG_JETS;
138  break;
139  case 4:
140  flavour = C_JETS;
141  break;
142  case 5:
143  flavour = B_JETS;
144  break;
145  default:
146  flavour = NONID_JETS;
147  }
148 
149  // simply count the number of accepted jets
150  flavours_->Fill(ALL_JETS);
151  flavours_->Fill(flavour);
152 
153  double discrTC = jet->bDiscriminator("trackCountingHighEffBJetTags");
154  double discrSSV = jet->bDiscriminator("simpleSecondaryVertexBJetTags");
155  double discrCSV = jet->bDiscriminator("combinedSecondaryVertexBJetTags");
156 
157  plots_[ALL_JETS].discrTC->Fill(discrTC);
158  plots_[flavour].discrTC->Fill(discrTC);
159 
160  plots_[ALL_JETS].discrSSV->Fill(discrSSV);
161  plots_[flavour].discrSSV->Fill(discrSSV);
162 
163  plots_[ALL_JETS].discrCSV->Fill(discrCSV);
164  plots_[flavour].discrCSV->Fill(discrCSV);
165  }
166 }
167 
169 
struct PatBJetTagAnalyzer::Plots plots_[N_JET_TYPES]
PatBJetTagAnalyzer(const edm::ParameterSet &params)
constructor and destructor
std::vector< Jet > JetCollection
Definition: Jet.h:55
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::EDGetTokenT< pat::JetCollection > jetsToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: HeavyIon.h:7
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
~PatBJetTagAnalyzer() override
void beginJob() override
HLT enums.
void analyze(const edm::Event &event, const edm::EventSetup &es) override
Definition: event.py:1