CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauDQML1Plotter.cc
Go to the documentation of this file.
2 
3 HLTTauDQML1Plotter::HLTTauDQML1Plotter( const edm::ParameterSet& ps, int etbins, int etabins, int phibins, double maxpt, bool ref, double dr, std::string dqmBaseFolder ) {
4  //Initialize Plotter
5  name_ = "HLTTauDQML1Plotter";
6 
7  //Process PSet
8  try {
9  triggerTag_ = ps.getUntrackedParameter<std::string>("DQMFolder");
10  triggerTagAlias_ = ps.getUntrackedParameter<std::string>("Alias","");
11  l1ExtraTaus_ = ps.getParameter<edm::InputTag>("L1Taus");
12  l1ExtraJets_ = ps.getParameter<edm::InputTag>("L1Jets");
13  l1ExtraElectrons_ = ps.getParameter<edm::InputTag>("L1Electrons");
14  l1ExtraMuons_ = ps.getParameter<edm::InputTag>("L1Muons");
15  doRefAnalysis_ = ref;
16  dqmBaseFolder_ = dqmBaseFolder;
17  matchDeltaR_ = dr;
18  maxEt_ = maxpt;
19  binsEt_ = etbins;
20  binsEta_ = etabins;
21  binsPhi_ = phibins;
22  validity_ = true;
23  } catch ( cms::Exception &e ) {
24  edm::LogInfo("HLTTauDQML1Plotter::HLTTauDQML1Plotter") << e.what() << std::endl;
25  validity_ = false;
26  return;
27  }
28 
29  if (store_) {
30  //Create the histograms
33 
34  l1tauEt_ = store_->book1D("L1TauEt","L1 #tau E_{T};L1 #tau E_{T};entries",binsEt_,0,maxEt_);
35  l1tauEta_ = store_->book1D("L1TauEta","L1 #tau #eta;L1 #tau #eta;entries",binsEta_,-2.5,2.5);
36  l1tauPhi_ = store_->book1D("L1TauPhi","L1 #tau #phi;L1 #tau #phi;entries",binsPhi_,-3.2,3.2);
37 
38  l1jetEt_ = store_->book1D("L1JetEt","L1 jet E_{T};L1 Central Jet E_{T};entries",binsEt_,0,maxEt_);
39  l1jetEta_ = store_->book1D("L1JetEta","L1 jet #eta;L1 Central Jet #eta;entries",binsEta_,-2.5,2.5);
40  l1jetPhi_ = store_->book1D("L1JetPhi","L1 jet #phi;L1 Central Jet #phi;entries",binsPhi_,-3.2,3.2);
41 
42  inputEvents_ = store_->book1D("InputEvents","Events Read;;entries",2,0,2);
43 
44  l1electronEt_ = store_->book1D("L1ElectronEt","L1 electron E_{T};L1 e/#gamma E_{T};entries",binsEt_,0,maxEt_);
45  l1electronEta_ = store_->book1D("L1ElectronEta","L1 electron #eta;L1 e/#gamma #eta;entries",binsEta_,-2.5,2.5);
46  l1electronPhi_ = store_->book1D("L1ElectronPhi","L1 electron #phi;L1 e/#gamma #phi;entries",binsPhi_,-3.2,3.2);
47 
48  l1muonEt_ = store_->book1D("L1MuonEt","L1 muon p_{T};L1 #mu p_{T};entries",binsEt_,0,maxEt_);
49  l1muonEta_ = store_->book1D("L1MuonEta","L1 muon #eta;L1 #mu #eta;entries",binsEta_,-2.5,2.5);
50  l1muonPhi_ = store_->book1D("L1MuonPhi","L1 muon #phi;L1 #mu #phi;entries",binsPhi_,-3.2,3.2);
51 
52  l1doubleTauPath_ = store_->book2D("L1DoubleTau","L1 Double Tau Path E_{T};first L1 #tau p_{T};second L1 #tau p_{T}",binsEt_,0,maxEt_,binsEt_,0,maxEt_);
53  l1muonTauPath_ = store_->book2D("L1MuonTau","L1 Muon Tau Path E_{T};first L1 #tau p_{T};first L1 #gamma p_{T}",binsEt_,0,maxEt_,binsEt_,0,maxEt_);
54  l1electronTauPath_ = store_->book2D("L1ElectronTau","L1 Electron Tau Path E_{T};first L1 #mu p_{T};second L1 #mu p_{T}",binsEt_,0,maxEt_,binsEt_,0,maxEt_);
55 
56  firstTauEt_ = store_->book1D("L1LeadTauEt","L1 lead #tau E_{T}",binsEt_,0,maxEt_);
57  firstTauEt_->getTH1F()->Sumw2();
58 
59  secondTauEt_ = store_->book1D("L1SecondTauEt","L1 second #tau E_{T}",binsEt_,0,maxEt_);
60  secondTauEt_->getTH1F()->Sumw2();
61 
62  if (doRefAnalysis_) {
63  l1tauEtRes_ = store_->book1D("L1TauEtResol","L1 #tau E_{T} resolution;[L1 #tau E_{T}-Ref #tau E_{T}]/Ref #tau E_{T};entries",40,-2,2);
64 
65  store_->setCurrentFolder(triggerTag()+"/EfficiencyHelpers");
67 
68  l1tauEtEffNum_ = store_->book1D("L1TauEtEffNum","L1 #tau E_{T} Efficiency Numerator",binsEt_,0,maxEt_);
69  l1tauEtEffNum_->getTH1F()->Sumw2();
70 
71  l1tauEtEffDenom_ = store_->book1D("L1TauEtEffDenom","L1 #tau E_{T} Denominator",binsEt_,0,maxEt_);
72  l1tauEtEffDenom_->getTH1F()->Sumw2();
73 
74  l1tauEtaEffNum_ = store_->book1D("L1TauEtaEffNum","L1 #tau #eta Efficiency",binsEta_,-2.5,2.5);
75  l1tauEtaEffNum_->getTH1F()->Sumw2();
76 
77  l1tauEtaEffDenom_ = store_->book1D("L1TauEtaEffDenom","L1 #tau #eta Denominator",binsEta_,-2.5,2.5);
78  l1tauEtaEffDenom_->getTH1F()->Sumw2();
79 
80  l1tauPhiEffNum_ = store_->book1D("L1TauPhiEffNum","L1 #tau #phi Efficiency",binsPhi_,-3.2,3.2);
81  l1tauPhiEffNum_->getTH1F()->Sumw2();
82 
83  l1tauPhiEffDenom_ = store_->book1D("L1TauPhiEffDenom","L1 #tau #phi Denominator",binsPhi_,-3.2,3.2);
84  l1tauPhiEffDenom_->getTH1F()->Sumw2();
85 
86  l1jetEtEffNum_ = store_->book1D("L1JetEtEffNum","L1 jet E_{T} Efficiency",binsEt_,0,maxEt_);
87  l1jetEtEffNum_->getTH1F()->Sumw2();
88 
89  l1jetEtEffDenom_ = store_->book1D("L1JetEtEffDenom","L1 jet E_{T} Denominator",binsEt_,0,maxEt_);
90  l1jetEtEffDenom_->getTH1F()->Sumw2();
91 
92  l1jetEtaEffNum_ = store_->book1D("L1JetEtaEffNum","L1 jet #eta Efficiency",binsEta_,-2.5,2.5);
93  l1jetEtaEffNum_->getTH1F()->Sumw2();
94 
95  l1jetEtaEffDenom_ = store_->book1D("L1JetEtaEffDenom","L1 jet #eta Denominator",binsEta_,-2.5,2.5);
96  l1jetEtaEffDenom_->getTH1F()->Sumw2();
97 
98  l1jetPhiEffNum_ = store_->book1D("L1JetPhiEffNum","L1 jet #phi Efficiency",binsPhi_,-3.2,3.2);
99  l1jetPhiEffNum_->getTH1F()->Sumw2();
100 
101  l1jetPhiEffDenom_ = store_->book1D("L1JetPhiEffDenom","L1 jet #phi Denominator",binsPhi_,-3.2,3.2);
102  l1jetPhiEffDenom_->getTH1F()->Sumw2();
103  }
104  }
105 }
106 
108 }
109 
110 //
111 // member functions
112 //
113 
114 void HLTTauDQML1Plotter::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::map<int,LVColl>& refC ) {
115  LVColl refTaus, refElectrons, refMuons;
116 
117  if ( doRefAnalysis_ ) {
118  std::map<int,LVColl>::const_iterator iref;
119 
120  //Tau reference
121  iref = refC.find(15);
122  if ( iref != refC.end() ) refTaus = iref->second;
123 
124  //Electron reference
125  iref = refC.find(11);
126  if ( iref != refC.end() ) refElectrons = iref->second;
127 
128  //Muon reference
129  iref = refC.find(13);
130  if ( iref != refC.end() ) refMuons = iref->second;
131 
132  for ( LVColl::const_iterator iter = refTaus.begin(); iter != refTaus.end(); ++iter ) {
133  l1tauEtEffDenom_->Fill(iter->pt());
134  l1jetEtEffDenom_->Fill(iter->pt());
135 
136  l1tauEtaEffDenom_->Fill(iter->eta());
137  l1jetEtaEffDenom_->Fill(iter->eta());
138 
139  l1tauPhiEffDenom_->Fill(iter->phi());
140  l1jetPhiEffDenom_->Fill(iter->phi());
141  }
142  }
143 
144  //Analyze L1 Objects (Tau+Jets)
149 
150  LVColl pathTaus;
151  LVColl pathMuons;
152  LVColl pathElectrons;
153 
154  //Set Variables for the threshold plot
155  LVColl l1taus;
156  LVColl l1electrons;
157  LVColl l1muons;
158  LVColl l1jets;
159 
160  bool gotL1Taus = iEvent.getByLabel(l1ExtraTaus_,taus) && taus.isValid();
161  bool gotL1Jets = iEvent.getByLabel(l1ExtraJets_,jets) && jets.isValid();
162  bool gotL1Electrons = iEvent.getByLabel(l1ExtraElectrons_,electrons) && electrons.isValid();
163  bool gotL1Muons = iEvent.getByLabel(l1ExtraMuons_,muons) && muons.isValid();
164 
165  if ( gotL1Taus ) {
166  if ( taus->size() > 0 ) {
167  if ( !doRefAnalysis_ ) {
168  firstTauEt_->Fill((*taus)[0].pt());
169  if ( taus->size() > 1 ) secondTauEt_->Fill((*taus)[0].pt());
170  }
171  for ( l1extra::L1JetParticleCollection::const_iterator i = taus->begin(); i != taus->end(); ++i ) {
172  l1taus.push_back(i->p4());
173  if ( !doRefAnalysis_ ) {
174  l1tauEt_->Fill(i->et());
175  l1tauEta_->Fill(i->eta());
176  l1tauPhi_->Fill(i->phi());
177  pathTaus.push_back(i->p4());
178  }
179  }
180  }
181  }
182  if ( gotL1Jets ) {
183  if ( jets->size() > 0 ) {
184  for( l1extra::L1JetParticleCollection::const_iterator i = jets->begin(); i != jets->end(); ++i ) {
185  l1jets.push_back(i->p4());
186  if ( !doRefAnalysis_ ) {
187  l1jetEt_->Fill(i->et());
188  l1jetEta_->Fill(i->eta());
189  l1jetPhi_->Fill(i->phi());
190  pathTaus.push_back(i->p4());
191  }
192  }
193  }
194  }
195  if ( gotL1Electrons ) {
196  if( electrons->size() > 0 ) {
197  for ( l1extra::L1EmParticleCollection::const_iterator i = electrons->begin(); i != electrons->end(); ++i ) {
198  l1electrons.push_back(i->p4());
199  l1electronEt_->Fill(i->et());
200  l1electronEta_->Fill(i->eta());
201  l1electronPhi_->Fill(i->phi());
202  pathElectrons.push_back(i->p4());
203  }
204  }
205  }
206  if ( gotL1Muons ) {
207  if ( muons->size() > 0 ) {
208  for ( l1extra::L1MuonParticleCollection::const_iterator i = muons->begin(); i != muons->end(); ++i ) {
209  l1muons.push_back(i->p4());
210  l1muonEt_->Fill(i->et());
211  l1muonEta_->Fill(i->eta());
212  l1muonPhi_->Fill(i->phi());
213  pathMuons.push_back(i->p4());
214  }
215  }
216  }
217 
218  //Now do the efficiency matching
219  if ( doRefAnalysis_ ) {
220  for ( LVColl::const_iterator i = refTaus.begin(); i != refTaus.end(); ++i ) {
221  std::pair<bool,LV> m = match(*i,l1taus,matchDeltaR_);
222  if ( m.first ) {
223  l1tauEt_->Fill(m.second.pt());
224  l1tauEta_->Fill(m.second.eta());
225  l1tauPhi_->Fill(m.second.phi());
226  l1tauEtEffNum_->Fill(i->pt());
227  l1tauEtaEffNum_->Fill(i->eta());
228  l1tauPhiEffNum_->Fill(i->phi());
229  l1tauEtRes_->Fill((m.second.pt()-i->pt())/i->pt());
230  pathTaus.push_back(m.second);
231  }
232  }
233 
234  for ( LVColl::const_iterator i = refTaus.begin(); i != refTaus.end(); ++i ) {
235  std::pair<bool,LV> m = match(*i,l1jets,matchDeltaR_);
236  if ( m.first ) {
237  l1jetEt_->Fill(m.second.pt());
238  l1jetEta_->Fill(m.second.eta());
239  l1jetPhi_->Fill(m.second.phi());
240  l1jetEtEffNum_->Fill(i->pt());
241  l1jetEtaEffNum_->Fill(i->eta());
242  l1jetPhiEffNum_->Fill(i->phi());
243  }
244  }
245 
246  for ( LVColl::const_iterator i = refElectrons.begin(); i != refElectrons.end(); ++i ) {
247  std::pair<bool,LV> m = match(*i,l1electrons,matchDeltaR_);
248  if( m.first ) {
249  l1electronEt_->Fill(m.second.pt());
250  l1electronEta_->Fill(m.second.eta());
251  l1electronPhi_->Fill(m.second.phi());
252  pathElectrons.push_back(m.second);
253  }
254  }
255 
256  for ( LVColl::const_iterator i = refMuons.begin(); i != refMuons.end(); ++i ) {
257  std::pair<bool,LV> m = match(*i,l1muons,matchDeltaR_);
258  if ( m.first ) {
259  l1muonEt_->Fill(m.second.pt());
260  l1muonEta_->Fill(m.second.eta());
261  l1muonPhi_->Fill(m.second.phi());
262  pathMuons.push_back(m.second);
263  }
264  }
265  }
266 
267 
268  //Fill the Threshold Monitoring
269  if(pathTaus.size() > 1) std::sort(pathTaus.begin(),pathTaus.end(),ptSort);
270  if(pathElectrons.size() > 1) std::sort(pathElectrons.begin(),pathElectrons.end(),ptSort);
271  if(pathMuons.size() > 1) std::sort(pathMuons.begin(),pathMuons.end(),ptSort);
272 
273  if ( pathTaus.size() > 0 ) {
274  firstTauEt_->Fill(pathTaus[0].pt());
275  inputEvents_->Fill(0.5);
276  }
277  if ( pathTaus.size() > 1 ) {
278  secondTauEt_->Fill(pathTaus[1].pt());
279  inputEvents_->Fill(1.5);
280  }
281  if ( pathTaus.size() >= 2 ) {
282  l1doubleTauPath_->Fill(pathTaus[0].pt(),pathTaus[1].pt());
283  }
284  if ( pathTaus.size() >= 1 && pathElectrons.size() >= 1 ) {
285  l1electronTauPath_->Fill(pathTaus[0].pt(),pathElectrons[0].pt());
286  }
287  if ( pathTaus.size() >= 1 && pathMuons.size() >= 1 ) {
288  l1muonTauPath_->Fill(pathTaus[0].pt(),pathMuons[0].pt());
289  }
290 }
virtual char const * what() const
Definition: Exception.cc:141
T getParameter(std::string const &) const
MonitorElement * l1doubleTauPath_
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * l1muonTauPath_
MonitorElement * l1jetEta_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
HLTTauDQML1Plotter(const edm::ParameterSet &, int, int, int, double, bool, double, std::string)
MonitorElement * l1jetEtEffNum_
edm::InputTag l1ExtraMuons_
MonitorElement * l1jetPhiEffDenom_
MonitorElement * l1jetEtaEffNum_
MonitorElement * l1muonEta_
MonitorElement * l1tauEt_
MonitorElement * secondTauEt_
MonitorElement * l1tauEtEffDenom_
void Fill(long long x)
MonitorElement * l1jetPhiEffNum_
MonitorElement * l1electronTauPath_
MonitorElement * l1muonPhi_
int iEvent
Definition: GenABIO.cc:243
MonitorElement * l1tauEtaEffNum_
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2564
MonitorElement * firstTauEt_
void analyze(const edm::Event &, const edm::EventSetup &, const std::map< int, LVColl > &)
std::vector< LV > LVColl
MonitorElement * l1electronPhi_
vector< PseudoJet > jets
MonitorElement * l1jetEtEffDenom_
MonitorElement * l1tauEtEffNum_
std::string triggerTagAlias_
MonitorElement * l1tauPhi_
edm::InputTag l1ExtraTaus_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
MonitorElement * l1tauEta_
MonitorElement * l1muonEt_
std::string triggerTag()
MonitorElement * l1tauPhiEffDenom_
TH1F * getTH1F(void) const
edm::InputTag l1ExtraJets_
MonitorElement * l1electronEt_
MonitorElement * l1tauEtaEffDenom_
MonitorElement * l1tauEtRes_
tuple muons
Definition: patZpeak.py:38
MonitorElement * l1jetPhi_
MonitorElement * l1jetEt_
MonitorElement * l1electronEta_
MonitorElement * l1jetEtaEffDenom_
std::pair< bool, LV > match(const LV &, const LVColl &, double)
edm::InputTag l1ExtraElectrons_
std::string triggerTag_
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * l1tauPhiEffNum_
std::string dqmBaseFolder_
MonitorElement * inputEvents_