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->count(MM, "total events", 1.0);
79  eventMonitor->count(EE, "total events", 1.0);
80  eventMonitor->count(EM, "total events", 1.0);
81  eventMonitor->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 }//end analyze
163 
164 
166 
167  eventMonitor.reset(new EventMonitor(ibooker));
168 }
169 
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:65
GSFTrackMaker gsfTrackMaker
Definition: HWWAnalyzer.h:71
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 *)
virtual ~HWWAnalyzer()
Definition: HWWAnalyzer.cc:67
EGammaMvaEleEstimator * egammaMvaEleEstimator
Definition: HWWAnalyzer.h:58
VertexMaker vertexMaker
Definition: HWWAnalyzer.h:61
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
EventMaker eventMaker
Definition: HWWAnalyzer.h:62
Definition: ME.h:11
HypDilepMaker hypDilepMaker
Definition: HWWAnalyzer.h:67
int iEvent
Definition: GenABIO.cc:230
MVAJetIdMaker mvaJetIdMaker
Definition: HWWAnalyzer.h:76
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: HWWAnalyzer.cc:165
PFElectronMaker pfElectronMaker
Definition: HWWAnalyzer.h:69
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:66
void initialize(std::string methodName, std::string weightsfile, EGammaMvaEleEstimator::MVAType type)
ElectronMaker electronMaker
Definition: HWWAnalyzer.h:64
int bestHypothesis(HWW &hww, const std::vector< int > &)
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
MuonMVAEstimator * muonMVAEstimator
Definition: HWWAnalyzer.h:59
Definition: HWW.h:12
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
RhoMaker rhoMaker
Definition: HWWAnalyzer.h:73
void doCutFlow(HWW &, int, EventMonitor &, EGammaMvaEleEstimator *, MuonMVAEstimator *)
TrackMaker trackMaker
Definition: HWWAnalyzer.h:63
void initialize(std::string methodName, std::string weightsfile, MuonMVAEstimator::MVAType type)
bool passFirstCuts(HWW &, int)
HWWAnalyzer(const edm::ParameterSet &)
Definition: HWWAnalyzer.cc:6
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
PFMETMaker pfMETMaker
Definition: HWWAnalyzer.h:74
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
std::unique_ptr< EventMonitor > eventMonitor
Definition: HWWAnalyzer.h:78
PFElToElAssMaker pfElToElAssMaker
Definition: HWWAnalyzer.h:70
TrkMETMaker trkMETMaker
Definition: HWWAnalyzer.h:75
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: RhoMaker.cc:12
PFCandidateMaker pfCandidateMaker
Definition: HWWAnalyzer.h:68
void SetVars(HWW &, const edm::Event &, const edm::EventSetup &)
Definition: TrackMaker.cc:23
RecoConversionMaker recoConversionMaker
Definition: HWWAnalyzer.h:72
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