CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RazorVarAnalyzer.cc
Go to the documentation of this file.
2 
5 
8 
11 
12 #include <cmath>
13 
14 // A simple constructor which takes as inoput only the name of the PF jet collection
17  m_eleCollectionTag(conf.getUntrackedParameter<edm::InputTag>("eleCollectionName",edm::InputTag("hltPixelMatchElectronsActivity"))),
18  m_jetCollectionTag(conf.getUntrackedParameter<edm::InputTag>("jetCollectionName",edm::InputTag("hltCaloJetIDPassed"))),
19  m_muCollectionTag(conf.getUntrackedParameter<edm::InputTag>("muCollectionName",edm::InputTag("hltL3MuonCandidates"))),
20  m_razorVarCollectionTag(conf.getUntrackedParameter<edm::InputTag>("razorVarCollectionName")) {
21  //set Token(-s)
22  m_jetCollectionTagToken_ = consumes<reco::CaloJetCollection>(conf.getUntrackedParameter<edm::InputTag>("jetCollectionName",edm::InputTag("hltCaloJetIDPassed")));
23  m_muCollectionTagToken_ = consumes<std::vector<reco::RecoChargedCandidate> >(conf.getUntrackedParameter<edm::InputTag>("muCollectionName",edm::InputTag("hltL3MuonCandidates")));
24  m_eleCollectionTagToken_ = consumes<reco::ElectronCollection>(conf.getUntrackedParameter<edm::InputTag>("eleCollectionName",edm::InputTag("hltPixelMatchElectronsActivity")));
25  m_razorVarCollectionTagToken_ = consumes<std::vector<double> >(conf.getUntrackedParameter<edm::InputTag>("razorVarCollectionName"));
26 }
27 
29 
30 // Function to book the Monitoring Elements.
33  //the full inclusive histograms
35  iBooker,
36  "rsqMRFullyInc",
37  "M_{R} vs R^{2} (All Events)",
38  400,0.,4000.,
39  50,0.,1.,
40  "M_{R} [GeV]",
41  "R^{2}");
43  iBooker,
44  "rsqMRInc4J",
45  "M_{R} vs R^{2} (>= 4j)",
46  400,0.,4000.,
47  50,0.,1.,
48  "M_{R} [GeV]",
49  "R^{2}");
51  iBooker,
52  "rsqMRInc6J",
53  "M_{R} vs R^{2} (>= 6j)",
54  400,0.,4000.,
55  50,0.,1.,
56  "M_{R} [GeV]",
57  "R^{2}");
59  iBooker,
60  "rsqMRInc8J",
61  "M_{R} vs R^{2} (>= 8j)",
62  400,0.,4000.,
63  50,0.,1.,
64  "M_{R} [GeV]",
65  "R^{2}");
67  iBooker,
68  "rsqMRInc10J",
69  "M_{R} vs R^{2} (>= 10j)",
70  400,0.,4000.,
71  50,0.,1.,
72  "M_{R} [GeV]",
73  "R^{2}");
75  iBooker,
76  "rsqMRInc12J",
77  "M_{R} vs R^{2} (>= 12j)",
78  400,0.,4000.,
79  50,0.,1.,
80  "M_{R} [GeV]",
81  "R^{2}");
83  iBooker,
84  "rsqMRInc14J",
85  "M_{R} vs R^{2} (>= 14j)",
86  400,0.,4000.,
87  50,0.,1.,
88  "M_{R} [GeV]",
89  "R^{2}");
90 
91  //the by box histograms
93  iBooker,
94  "rsqMREleMu",
95  "M_{R} vs R^{2} (EleMu box)",
96  400,0.,4000.,
97  50,0.,1.,
98  "M_{R} [GeV]",
99  "R^{2}");
101  iBooker,
102  "rsqMRMuMu",
103  "M_{R} vs R^{2} (MuMu box)",
104  400,0.,4000.,
105  50,0.,1.,
106  "M_{R} [GeV]",
107  "R^{2}");
109  iBooker,
110  "rsqMREleEle",
111  "M_{R} vs R^{2} (EleEle box)",
112  400,0.,4000.,
113  50,0.,1.,
114  "M_{R} [GeV]",
115  "R^{2}");
117  iBooker,
118  "rsqMRMu",
119  "M_{R} vs R^{2} (Mu box)",
120  400,0.,4000.,
121  50,0.,1.,
122  "M_{R} [GeV]",
123  "R^{2}");
125  iBooker,
126  "rsqMREle",
127  "M_{R} vs R^{2} (Ele box)",
128  400,0.,4000.,
129  50,0.,1.,
130  "M_{R} [GeV]",
131  "R^{2}");
133  iBooker,
134  "rsqMRHad",
135  "M_{R} vs R^{2} (Had box)",
136  400,0.,4000.,
137  50,0.,1.,
138  "M_{R} [GeV]",
139  "R^{2}");
140 
141  //the by box histograms
143  iBooker,
144  "rsqMRMuMJ",
145  "M_{R} vs R^{2} (Mu box >= 4j)",
146  400,0.,4000.,
147  50,0.,1.,
148  "M_{R} [GeV]",
149  "R^{2}");
151  iBooker,
152  "rsqMREleMJ",
153  "M_{R} vs R^{2} (Ele box >= 5j)",
154  400,0.,4000.,
155  50,0.,1.,
156  "M_{R} [GeV]",
157  "R^{2}");
159  iBooker,
160  "rsqMRHadMJ",
161  "M_{R} vs R^{2} (Had box >= 6j)",
162  400,0.,4000.,
163  50,0.,1.,
164  "M_{R} [GeV]",
165  "R^{2}");
166 }
167 
168 // Usual analyze method
170  //count the number of jets with a minimal selection
171  edm::Handle<reco::CaloJetCollection> calojets_handle;
172  iEvent.getByToken(m_jetCollectionTagToken_, calojets_handle);
173 
174  unsigned int njets = 0;
175  for(reco::CaloJetCollection::const_iterator it = calojets_handle->begin(); it != calojets_handle->end(); ++it){
176  if(it->pt() >= 30. && fabs(it->eta()) <= 3.0){
177  njets++;
178  }
179  }
180 
181  //count the number of muons
183  iEvent.getByToken(m_muCollectionTagToken_, muon_handle);
184 
185  unsigned int nmu_loose = 0;
186  unsigned int nmu_tight = 0;
187  if(muon_handle.isValid()){
188  for(std::vector<reco::RecoChargedCandidate>::const_iterator it = muon_handle->begin(); it != muon_handle->end(); ++it){
189  if(it->pt() >= 15 && fabs(it->eta()) <= 2.1) nmu_tight++;
190  if(it->pt() >= 10 && fabs(it->eta()) <= 2.4) nmu_loose++;
191  }
192  }
193 
194  //count the number of electrons
196  iEvent.getByToken(m_eleCollectionTagToken_, ele_handle);
197 
198  unsigned int nele_loose = 0;
199  unsigned int nele_tight = 0;
200  if(ele_handle.isValid()){
201  for(reco::ElectronCollection::const_iterator it = ele_handle->begin(); it != ele_handle->end(); ++it){
202  if(it->pt() >= 20 && fabs(it->eta()) <= 2.5) nele_tight++;
203  if(it->pt() >= 10 && fabs(it->eta()) <= 2.5) nele_loose++;
204  }
205  }
206 
207  //now get the box number: {'MuEle':0,'MuMu':1,'EleEle':2,'Mu':3,'Ele':4,'Had':5}
208  unsigned int box_num = 5;
209  if(nmu_tight > 0 && nele_tight > 0){
210  box_num = 0;
211  }else if(nmu_tight > 0 && nmu_loose > 1){
212  box_num = 1;
213  }else if(nele_tight > 0 && nele_loose > 1){
214  box_num = 2;
215  }else if(nmu_tight > 0){
216  box_num = 3;
217  }else if(nele_tight > 0){
218  box_num = 4;
219  }
220 
221  edm::Handle<std::vector<double> > razorvar_handle;
222  iEvent.getByToken(m_razorVarCollectionTagToken_, razorvar_handle);
223  if(razorvar_handle->size() > 1){
224  const double MR = razorvar_handle->at(0);
225  const double R = razorvar_handle->at(1);
226  m_rsqMRFullyInc->Fill(MR,R*R);
227  if(njets >= 4) m_rsqMRInc4J->Fill(MR,R*R);
228  if(njets >= 6) m_rsqMRInc6J->Fill(MR,R*R);
229  if(njets >= 8) m_rsqMRInc8J->Fill(MR,R*R);
230  if(njets >= 10) m_rsqMRInc10J->Fill(MR,R*R);
231  if(njets >= 12) m_rsqMRInc12J->Fill(MR,R*R);
232  if(njets >= 14) m_rsqMRInc14J->Fill(MR,R*R);
233 
234  //now fill the boxes
235  if(box_num == 0) m_rsqMREleMu->Fill(MR,R*R);
236  if(box_num == 1) m_rsqMRMuMu->Fill(MR,R*R);
237  if(box_num == 2) m_rsqMREleEle->Fill(MR,R*R);
238  if(box_num == 3) m_rsqMRMu->Fill(MR,R*R);
239  if(box_num == 4) m_rsqMREle->Fill(MR,R*R);
240  if(box_num == 5) m_rsqMRHad->Fill(MR,R*R);
241 
242  //finally the multijet boxes - think ttbar
243  //muon boxes: muons are not in jets
244  if( box_num == 3 && njets >= 4) m_rsqMRMuMJ->Fill(MR,R*R);
245  //ele boxes: electrons are in jets
246  else if( box_num == 4 && njets >= 5) m_rsqMREleMJ->Fill(MR,R*R);
247  //fill the Had box
248  else if( box_num == 5 && njets >= 6) m_rsqMRHadMJ->Fill(MR,R*R);
249  }
250 }
MonitorElement * m_rsqMRInc12J
MonitorElement * m_rsqMRHadMJ
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< std::vector< double > > m_razorVarCollectionTagToken_
edm::EDGetTokenT< reco::ElectronCollection > m_eleCollectionTagToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * m_rsqMREle
MonitorElement * m_rsqMRInc6J
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
void prepareBooking(DQMStore::IBooker &)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void Fill(long long x)
MonitorElement * m_rsqMREleMJ
MonitorElement * m_rsqMRInc8J
MonitorElement * m_rsqMRMu
int iEvent
Definition: GenABIO.cc:230
MonitorElement * m_rsqMRMuMJ
edm::EDGetTokenT< std::vector< reco::RecoChargedCandidate > > m_muCollectionTagToken_
RazorVarAnalyzer(const edm::ParameterSet &)
MonitorElement * m_rsqMREleMu
MonitorElement * m_rsqMRMuMu
bool isValid() const
Definition: HandleBase.h:75
tuple conf
Definition: dbtoconf.py:185
MonitorElement * m_rsqMRInc14J
MonitorElement * m_rsqMRInc4J
MonitorElement * bookH2withSumw2(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="COLZ")
MonitorElement * m_rsqMREleEle
virtual ~RazorVarAnalyzer()
edm::EDGetTokenT< reco::CaloJetCollection > m_jetCollectionTagToken_
MonitorElement * m_rsqMRHad
MonitorElement * m_rsqMRInc10J
MonitorElement * m_rsqMRFullyInc
Definition: Run.h:43