CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HWWAnalyzer.cc
Go to the documentation of this file.
4 
5 
7  :vertexMaker (iConfig, consumesCollector()),
8  trackMaker (iConfig, consumesCollector()),
9  electronMaker (iConfig, consumesCollector()),
10  muonMaker (iConfig, consumesCollector()),
11  pfJetMaker (iConfig, consumesCollector()),
12  pfCandidateMaker (iConfig, consumesCollector()),
13  pfElectronMaker (iConfig, consumesCollector()),
14  gsfTrackMaker (iConfig, consumesCollector()),
15  recoConversionMaker(iConfig, consumesCollector()),
16  rhoMaker (iConfig, consumesCollector()),
17  pfMETMaker (iConfig, consumesCollector()),
18  mvaJetIdMaker (iConfig, consumesCollector())
19 {
20 
21  doTest = iConfig.getParameter<bool>("doTest");
22  if(doTest) edm::LogInfo("OutputInfo") << "running with doTest==True";
23 
25  muonMVAEstimator = 0;
26 
27 
28  // --------------- EGamma Id MVA --------------------------
29  std::string egammaweights1 = iConfig.getParameter<edm::FileInPath> ("InputEGammaWeights1").fullPath();
30  std::string egammaweights2 = iConfig.getParameter<edm::FileInPath> ("InputEGammaWeights2").fullPath();
31  std::string egammaweights3 = iConfig.getParameter<edm::FileInPath> ("InputEGammaWeights3").fullPath();
32  std::string egammaweights4 = iConfig.getParameter<edm::FileInPath> ("InputEGammaWeights4").fullPath();
33  std::string egammaweights5 = iConfig.getParameter<edm::FileInPath> ("InputEGammaWeights5").fullPath();
34  std::string egammaweights6 = iConfig.getParameter<edm::FileInPath> ("InputEGammaWeights6").fullPath();
35  std::vector<std::string> egammaweights = {
36  egammaweights1,
37  egammaweights2,
38  egammaweights3,
39  egammaweights4,
40  egammaweights5,
41  egammaweights6
42  };
44  egammaMvaEleEstimator->initialize("BDT", EGammaMvaEleEstimator::kTrig, true, egammaweights );
45 
46  // --------------- Muon RingIso MVA --------------------------
47  std::string muonisoweights1 = iConfig.getParameter<edm::FileInPath> ("InputMuonIsoWeights1").fullPath();
48  std::string muonisoweights2 = iConfig.getParameter<edm::FileInPath> ("InputMuonIsoWeights2").fullPath();
49  std::string muonisoweights3 = iConfig.getParameter<edm::FileInPath> ("InputMuonIsoWeights3").fullPath();
50  std::string muonisoweights4 = iConfig.getParameter<edm::FileInPath> ("InputMuonIsoWeights4").fullPath();
51  std::string muonisoweights5 = iConfig.getParameter<edm::FileInPath> ("InputMuonIsoWeights5").fullPath();
52  std::string muonisoweights6 = iConfig.getParameter<edm::FileInPath> ("InputMuonIsoWeights6").fullPath();
53  std::vector<std::string> muonisoweights = {
54  muonisoweights1,
55  muonisoweights2,
56  muonisoweights3,
57  muonisoweights4,
58  muonisoweights5,
59  muonisoweights6
60  };
62  muonMVAEstimator->initialize( "MuonIso_BDTG_IsoRings", MuonMVAEstimator::kIsoRings, true, muonisoweights );
63 
64 }
65 
66 
68 }
69 
70 
72 
73  using namespace HWWFunctions;
74 
75  HWW hww;
76 
77  //count total events
78  eventMonitor.monitor.count(MM, "total events", 1.0);
79  eventMonitor.monitor.count(EE, "total events", 1.0);
80  eventMonitor.monitor.count(EM, "total events", 1.0);
81  eventMonitor.monitor.count(ME, "total events", 1.0);
82 
83  //if doTest flag is true, all we do is access all the collections
84  //without having to make it through the cutflow.
85  if(doTest){
86 
87  eventMaker .SetVars(hww, iEvent, iSetup);
88  vertexMaker .SetVars(hww, iEvent, iSetup);
89  trackMaker .SetVars(hww, iEvent, iSetup);
90  electronMaker .SetVars(hww, iEvent, iSetup);
91  muonMaker .SetVars(hww, iEvent, iSetup);
92  pfJetMaker .SetVars(hww, iEvent, iSetup);
93  hypDilepMaker .SetVars(hww, iEvent, iSetup);
94  pfCandidateMaker .SetVars(hww, iEvent, iSetup);
95  pfElectronMaker .SetVars(hww, iEvent, iSetup);
96  pfElToElAssMaker .SetVars(hww, iEvent, iSetup);
97  gsfTrackMaker .SetVars(hww, iEvent, iSetup);
98  recoConversionMaker .SetVars(hww, iEvent, iSetup);
99  rhoMaker .SetVars(hww, iEvent, iSetup);
100  pfMETMaker .SetVars(hww, iEvent, iSetup);
101  trkMETMaker .SetVars(hww, iEvent, iSetup);
102  mvaJetIdMaker .SetVars(hww, iEvent, iSetup);
103 
104  return;
105 
106  }
107 
108  //get variables
109  eventMaker .SetVars(hww, iEvent, iSetup);
110  vertexMaker .SetVars(hww, iEvent, iSetup);
111  trackMaker .SetVars(hww, iEvent, iSetup);
112 
113  if(hww.trks_trk_p4().size() < 2) return;
114 
115  electronMaker .SetVars(hww, iEvent, iSetup);
116  muonMaker .SetVars(hww, iEvent, iSetup);
117  pfJetMaker .SetVars(hww, iEvent, iSetup);
118  hypDilepMaker .SetVars(hww, iEvent, iSetup);
119 
120  //check some basic event requirements
121  std::vector<int> goodHyps;
122  for(unsigned int i=0; i < hww.hyp_p4().size(); i++){
123  if(!passFirstCuts(hww, i)) continue;
124  goodHyps.push_back(i);
125  }
126 
127  //no need to continue if event didn't pass basic requirements
128  if(goodHyps.size() > 0){
129 
130  //get variables
131  pfCandidateMaker .SetVars(hww, iEvent, iSetup);
132  pfElectronMaker .SetVars(hww, iEvent, iSetup);
133  pfElToElAssMaker .SetVars(hww, iEvent, iSetup);
134  gsfTrackMaker .SetVars(hww, iEvent, iSetup);
135  recoConversionMaker .SetVars(hww, iEvent, iSetup);
136  rhoMaker .SetVars(hww, iEvent, iSetup);
137 
138  //to hold indices of candidate lepton pairs
139  std::vector<int> candidates;
140 
141  //get lepton pairs that pass baseline selection
142  for(unsigned int i=0; i < goodHyps.size(); i++){
143  if(!passBaseline(hww, goodHyps.at(i), egammaMvaEleEstimator, muonMVAEstimator)) continue;
144  candidates.push_back(i);
145  }
146 
147  if(candidates.size()>0){
148 
149  //get variables
150  pfMETMaker .SetVars(hww, iEvent, iSetup);
151  trkMETMaker .SetVars(hww, iEvent, iSetup);
152  mvaJetIdMaker .SetVars(hww, iEvent, iSetup);
153 
154  //find best lepton pair
155  int bestHyp = bestHypothesis(hww, candidates);
156 
157  //perform remaining selections
159 
160  }
161  }
162 
163  FillHistograms();
164 
165 }//end analyze
166 
167 
169 
170  ibooker.setCurrentFolder("PhysicsHWW");
171 
172  cutflowHist[0] = ibooker.book1D("cutflow_mm", "HWW cutflow mm", 21, 0, 21);
173  cutflowHist[1] = ibooker.book1D("cutflow_ee", "HWW cutflow ee", 21, 0, 21);
174  cutflowHist[2] = ibooker.book1D("cutflow_em", "HWW cutflow em", 21, 0, 21);
175  cutflowHist[3] = ibooker.book1D("cutflow_me", "HWW cutflow me", 21, 0, 21);
176 
177 }
178 
180 
181  for (unsigned int i=0; i<4; i++){
182  for (unsigned int j=0; j<eventMonitor.monitor.counters.size(); j++){
183  cutflowHist[i]->setBinContent(j+1, eventMonitor.monitor.counters[j].nevt[i] - 1); //the "- 1" accounts for the initial count in the EventMonitor constructor
184  cutflowHist[i]->setBinLabel(j+1, eventMonitor.monitor.counters[j].name.c_str(), 1);
185  }
186  }
187 
188 }
189 
T getParameter(std::string const &) const
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
int i
Definition: DBlmapReader.cc:9
MuonMaker muonMaker
Definition: HWWAnalyzer.h:66
void setBinContent(int binx, double content)
set content of bin (1-D)
GSFTrackMaker gsfTrackMaker
Definition: HWWAnalyzer.h:72
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: PFMETMaker.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool passBaseline(HWW &, int, EGammaMvaEleEstimator *, MuonMVAEstimator *)
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual ~HWWAnalyzer()
Definition: HWWAnalyzer.cc:67
EGammaMvaEleEstimator * egammaMvaEleEstimator
Definition: HWWAnalyzer.h:57
VertexMaker vertexMaker
Definition: HWWAnalyzer.h:62
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
void analyze(const edm::Event &, const edm::EventSetup &)
Definition: HWWAnalyzer.cc:71
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: PFJetMaker.cc:13
void doCutFlow(HWW &, int, EventMonitor::hypo_monitor &, EGammaMvaEleEstimator *, MuonMVAEstimator *)
EventMaker eventMaker
Definition: HWWAnalyzer.h:63
Definition: ME.h:11
HypDilepMaker hypDilepMaker
Definition: HWWAnalyzer.h:68
int iEvent
Definition: GenABIO.cc:230
hypo_monitor monitor
Definition: monitor.h:28
MVAJetIdMaker mvaJetIdMaker
Definition: HWWAnalyzer.h:77
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HWWAnalyzer.cc:168
PFElectronMaker pfElectronMaker
Definition: HWWAnalyzer.h:70
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: VertexMaker.cc:12
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: EventMaker.cc:5
PFJetMaker pfJetMaker
Definition: HWWAnalyzer.h:67
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
ElectronMaker electronMaker
Definition: HWWAnalyzer.h:65
int bestHypothesis(HWW &hww, const std::vector< int > &)
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
MuonMVAEstimator * muonMVAEstimator
Definition: HWWAnalyzer.h:58
Definition: HWW.h:12
void FillHistograms()
Definition: HWWAnalyzer.cc:179
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
RhoMaker rhoMaker
Definition: HWWAnalyzer.h:74
TrackMaker trackMaker
Definition: HWWAnalyzer.h:64
void initialize(std::string methodName, std::string weightsfile, MuonMVAEstimator::MVAType type)
bool passFirstCuts(HWW &, int)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
HWWAnalyzer(const edm::ParameterSet &)
Definition: HWWAnalyzer.cc:6
MonitorElement * cutflowHist[4]
Definition: HWWAnalyzer.h:79
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
PFMETMaker pfMETMaker
Definition: HWWAnalyzer.h:75
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
PFElToElAssMaker pfElToElAssMaker
Definition: HWWAnalyzer.h:71
TrkMETMaker trkMETMaker
Definition: HWWAnalyzer.h:76
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: RhoMaker.cc:12
PFCandidateMaker pfCandidateMaker
Definition: HWWAnalyzer.h:69
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: TrackMaker.cc:23
EventMonitor eventMonitor
Definition: HWWAnalyzer.h:60
RecoConversionMaker recoConversionMaker
Definition: HWWAnalyzer.h:73
std::vector< EventMonitor::Entry > counters
Definition: monitor.h:23
void count(HypothesisType type, const char *name, double weight=1.0)
Definition: monitor.cc:11
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: Run.h:41
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: MuonMaker.cc:23
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: TrkMETMaker.cc:17