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 //------------------------------------------------------------------------------
15 // A simple constructor which takes as inoput only the name of the PF jet collection
18  m_eleCollectionTag(conf.getUntrackedParameter<edm::InputTag>("eleCollectionName",edm::InputTag("hltPixelMatchElectronsActivity"))),
19  m_jetCollectionTag(conf.getUntrackedParameter<edm::InputTag>("jetCollectionName",edm::InputTag("hltCaloJetIDPassed"))),
20  m_muCollectionTag(conf.getUntrackedParameter<edm::InputTag>("muCollectionName",edm::InputTag("hltL3MuonCandidates"))),
21  m_razorVarCollectionTag(conf.getUntrackedParameter<edm::InputTag>("razorVarCollectionName")){
22 
23  //set Token(-s)
24  m_jetCollectionTagToken_ = consumes<reco::CaloJetCollection>(conf.getUntrackedParameter<edm::InputTag>("jetCollectionName",edm::InputTag("hltCaloJetIDPassed")));
25  m_muCollectionTagToken_ = consumes<std::vector<reco::RecoChargedCandidate> >(conf.getUntrackedParameter<edm::InputTag>("muCollectionName",edm::InputTag("hltL3MuonCandidates")));
26  m_eleCollectionTagToken_ = consumes<reco::ElectronCollection>(conf.getUntrackedParameter<edm::InputTag>("eleCollectionName",edm::InputTag("hltPixelMatchElectronsActivity")));
27  m_razorVarCollectionTagToken_ = consumes<std::vector<double> >(conf.getUntrackedParameter<edm::InputTag>("razorVarCollectionName"));
28 }
29 
30 //------------------------------------------------------------------------------
31 // Nothing to destroy: the DQM service thinks about everything
33 
34 //------------------------------------------------------------------------------
35 // Usual analyze method
37 
38  //count the number of jets with a minimal selection
40  iEvent.getByToken(m_jetCollectionTagToken_, calojets_handle);
41 
42 
43  unsigned int njets = 0;
44  for(reco::CaloJetCollection::const_iterator it = calojets_handle->begin(); it != calojets_handle->end(); ++it){
45  if(it->pt() >= 30. && fabs(it->eta()) <= 3.0){
46  njets++;
47  }
48  }
49 
50  //count the number of muons
52  iEvent.getByToken(m_muCollectionTagToken_, muon_handle);
53 
54  unsigned int nmu_loose = 0;
55  unsigned int nmu_tight = 0;
56  if(muon_handle.isValid()){
57  for(std::vector<reco::RecoChargedCandidate>::const_iterator it = muon_handle->begin(); it != muon_handle->end(); ++it){
58  if(it->pt() >= 15 && fabs(it->eta()) <= 2.1) nmu_tight++;
59  if(it->pt() >= 10 && fabs(it->eta()) <= 2.4) nmu_loose++;
60  }
61  }
62 
63  //count the number of electrons
65  iEvent.getByToken(m_eleCollectionTagToken_, ele_handle);
66 
67  unsigned int nele_loose = 0;
68  unsigned int nele_tight = 0;
69  if(ele_handle.isValid()){
70  for(reco::ElectronCollection::const_iterator it = ele_handle->begin(); it != ele_handle->end(); ++it){
71  if(it->pt() >= 20 && fabs(it->eta()) <= 2.5) nele_tight++;
72  if(it->pt() >= 10 && fabs(it->eta()) <= 2.5) nele_loose++;
73  }
74  }
75 
76  //now get the box number: {'MuEle':0,'MuMu':1,'EleEle':2,'Mu':3,'Ele':4,'Had':5}
77  unsigned int box_num = 5;
78  if(nmu_tight > 0 && nele_tight > 0){
79  box_num = 0;
80  }else if(nmu_tight > 0 && nmu_loose > 1){
81  box_num = 1;
82  }else if(nele_tight > 0 && nele_loose > 1){
83  box_num = 2;
84  }else if(nmu_tight > 0){
85  box_num = 3;
86  }else if(nele_tight > 0){
87  box_num = 4;
88  }
89 
90  edm::Handle<std::vector<double> > razorvar_handle;
91  iEvent.getByToken(m_razorVarCollectionTagToken_, razorvar_handle);
92 
93  if(razorvar_handle->size() > 1){
94  const double MR = razorvar_handle->at(0);
95  const double R = razorvar_handle->at(1);
96  m_rsqMRFullyInc->Fill(MR,R*R);
97  if(njets >= 4) m_rsqMRInc4J->Fill(MR,R*R);
98  if(njets >= 6) m_rsqMRInc6J->Fill(MR,R*R);
99  if(njets >= 8) m_rsqMRInc8J->Fill(MR,R*R);
100  if(njets >= 10) m_rsqMRInc10J->Fill(MR,R*R);
101  if(njets >= 12) m_rsqMRInc12J->Fill(MR,R*R);
102  if(njets >= 14) m_rsqMRInc14J->Fill(MR,R*R);
103 
104  //now fill the boxes
105  if(box_num == 0) m_rsqMREleMu->Fill(MR,R*R);
106  if(box_num == 1) m_rsqMRMuMu->Fill(MR,R*R);
107  if(box_num == 2) m_rsqMREleEle->Fill(MR,R*R);
108  if(box_num == 3) m_rsqMRMu->Fill(MR,R*R);
109  if(box_num == 4) m_rsqMREle->Fill(MR,R*R);
110  if(box_num == 5) m_rsqMRHad->Fill(MR,R*R);
111 
112  //finally the multijet boxes - think ttbar
113  //muon boxes: muons are not in jets
114  if( box_num == 3 && njets >= 4) m_rsqMRMuMJ->Fill(MR,R*R);
115  //ele boxes: electrons are in jets
116  else if( box_num == 4 && njets >= 5) m_rsqMREleMJ->Fill(MR,R*R);
117  //fill the Had box
118  else if( box_num == 5 && njets >= 6) m_rsqMRHadMJ->Fill(MR,R*R);
119  }
120 
121 }
122 
124 }
125 
126 //------------------------------------------------------------------------------
127 // Function to book the Monitoring Elements.
129 
130  //the full inclusive histograms
131  m_rsqMRFullyInc = bookH2withSumw2("rsqMRFullyInc",
132  "M_{R} vs R^{2} (All Events)",
133  400,0.,4000.,
134  50,0.,1.,
135  "M_{R} [GeV]",
136  "R^{2}");
137  m_rsqMRInc4J = bookH2withSumw2("rsqMRInc4J",
138  "M_{R} vs R^{2} (>= 4j)",
139  400,0.,4000.,
140  50,0.,1.,
141  "M_{R} [GeV]",
142  "R^{2}");
143  m_rsqMRInc6J = bookH2withSumw2("rsqMRInc6J",
144  "M_{R} vs R^{2} (>= 6j)",
145  400,0.,4000.,
146  50,0.,1.,
147  "M_{R} [GeV]",
148  "R^{2}");
149  m_rsqMRInc8J = bookH2withSumw2("rsqMRInc8J",
150  "M_{R} vs R^{2} (>= 8j)",
151  400,0.,4000.,
152  50,0.,1.,
153  "M_{R} [GeV]",
154  "R^{2}");
155  m_rsqMRInc10J = bookH2withSumw2("rsqMRInc10J",
156  "M_{R} vs R^{2} (>= 10j)",
157  400,0.,4000.,
158  50,0.,1.,
159  "M_{R} [GeV]",
160  "R^{2}");
161  m_rsqMRInc12J = bookH2withSumw2("rsqMRInc12J",
162  "M_{R} vs R^{2} (>= 12j)",
163  400,0.,4000.,
164  50,0.,1.,
165  "M_{R} [GeV]",
166  "R^{2}");
167  m_rsqMRInc14J = bookH2withSumw2("rsqMRInc14J",
168  "M_{R} vs R^{2} (>= 14j)",
169  400,0.,4000.,
170  50,0.,1.,
171  "M_{R} [GeV]",
172  "R^{2}");
173 
174  //the by box histograms
175  m_rsqMREleMu = bookH2withSumw2("rsqMREleMu",
176  "M_{R} vs R^{2} (EleMu box)",
177  400,0.,4000.,
178  50,0.,1.,
179  "M_{R} [GeV]",
180  "R^{2}");
181  m_rsqMRMuMu = bookH2withSumw2("rsqMRMuMu",
182  "M_{R} vs R^{2} (MuMu box)",
183  400,0.,4000.,
184  50,0.,1.,
185  "M_{R} [GeV]",
186  "R^{2}");
187  m_rsqMREleEle = bookH2withSumw2("rsqMREleEle",
188  "M_{R} vs R^{2} (EleEle box)",
189  400,0.,4000.,
190  50,0.,1.,
191  "M_{R} [GeV]",
192  "R^{2}");
193  m_rsqMRMu = bookH2withSumw2("rsqMRMu",
194  "M_{R} vs R^{2} (Mu box)",
195  400,0.,4000.,
196  50,0.,1.,
197  "M_{R} [GeV]",
198  "R^{2}");
199  m_rsqMREle = bookH2withSumw2("rsqMREle",
200  "M_{R} vs R^{2} (Ele box)",
201  400,0.,4000.,
202  50,0.,1.,
203  "M_{R} [GeV]",
204  "R^{2}");
205  m_rsqMRHad = bookH2withSumw2("rsqMRHad",
206  "M_{R} vs R^{2} (Had box)",
207  400,0.,4000.,
208  50,0.,1.,
209  "M_{R} [GeV]",
210  "R^{2}");
211 
212  //the by box histograms
213  m_rsqMRMuMJ = bookH2withSumw2("rsqMRMuMJ",
214  "M_{R} vs R^{2} (Mu box >= 4j)",
215  400,0.,4000.,
216  50,0.,1.,
217  "M_{R} [GeV]",
218  "R^{2}");
219  m_rsqMREleMJ = bookH2withSumw2("rsqMREleMJ",
220  "M_{R} vs R^{2} (Ele box >= 5j)",
221  400,0.,4000.,
222  50,0.,1.,
223  "M_{R} [GeV]",
224  "R^{2}");
225  m_rsqMRHadMJ = bookH2withSumw2("rsqMRHadMJ",
226  "M_{R} vs R^{2} (Had box >= 6j)",
227  400,0.,4000.,
228  50,0.,1.,
229  "M_{R} [GeV]",
230  "R^{2}");
231 
232 
233 }
234 
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_
MonitorElement * bookH2withSumw2(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_rsqMREle
MonitorElement * m_rsqMRInc6J
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void endRun(edm::Run const &, edm::EventSetup const &)
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:76
tuple conf
Definition: dbtoconf.py:185
MonitorElement * m_rsqMRInc14J
MonitorElement * m_rsqMRInc4J
MonitorElement * m_rsqMREleEle
virtual ~RazorVarAnalyzer()
edm::EDGetTokenT< reco::CaloJetCollection > m_jetCollectionTagToken_
virtual void bookMEs()
MonitorElement * m_rsqMRHad
MonitorElement * m_rsqMRInc10J
MonitorElement * m_rsqMRFullyInc
Definition: Run.h:41