CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauDQMCaloPlotter.cc
Go to the documentation of this file.
2 
3 HLTTauDQMCaloPlotter::HLTTauDQMCaloPlotter( const edm::ParameterSet& iConfig, int etbins, int etabins, int phibins, double maxpt, bool ref, double dr, std::string dqmBaseFolder ) {
4  //Initialize Plotter
5  name_ = "HLTTauDQMCaloPlotter";
6 
7  //Process PSet
8  try {
9  l2preJets_ = iConfig.getUntrackedParameter<std::vector<edm::InputTag> >("L2RegionalJets");
10  l2TauInfoAssoc_ = iConfig.getUntrackedParameter<edm::InputTag>("L2InfoAssociationInput");
11  triggerTag_ = iConfig.getUntrackedParameter<std::string>("DQMFolder");
12  triggerTagAlias_ = iConfig.getUntrackedParameter<std::string>("Alias","");
13  l2Isolated_ = iConfig.getUntrackedParameter<edm::InputTag>("L2IsolatedJets");
14  matchDeltaRMC_ = dr;
15  EtMax_ = maxpt;
16  NPtBins_ = etbins;
17  NEtaBins_ = etabins;
18  NPhiBins_ = phibins;
19  doRef_ = ref;
20  dqmBaseFolder_ = dqmBaseFolder;
21  validity_ = true;
22  } catch ( cms::Exception &e ) {
23  edm::LogInfo("HLTTauDQMCaloPlotter::HLTTauDQMCaloPlotter") << e.what() << std::endl;
24  validity_ = false;
25  return;
26  }
27 
28  if (store_) {
29  //Create the histograms
32 
33  preJetEt = store_->book1D("L2PreTauEt","L2 regional #tau E_{t};L2 regional Jet E_{T};entries",NPtBins_,0,EtMax_);
34  preJetEta = store_->book1D("L2PreTauEta","L2 regional #tau #eta;L2 regional Jet #eta;entries",NEtaBins_,-2.5,2.5);
35  preJetPhi = store_->book1D("L2PreTauPhi","L2 regional #tau #phi;L2 regional Jet #phi;entries",NPhiBins_,-3.2,3.2);
36 
37  jetEt = store_->book1D("L2TauEt","L2 #tau E_{t};L2 selected Jet E_{T};entries",NPtBins_,0,EtMax_);
38  jetEta = store_->book1D("L2TauEta","L2 #tau #eta;L2 selected Jet #eta;entries",NEtaBins_,-2.5,2.5);
39  jetPhi = store_->book1D("L2TauPhi","L2 #tau #phi;L2 selected Jet #phi;entries",NPhiBins_,-3.2,3.2);
40  jetEtRes = store_->book1D("L2TauEtResol","L2 #tau E_{t} resolution;L2 selected Jet #phi;entries",40,-2,2);
41 
42  isoJetEt = store_->book1D("L2IsoTauEt","L2 isolated #tau E_{t};L2 isolated Jet E_{T};entries",NPtBins_,0,EtMax_);
43  isoJetEta = store_->book1D("L2IsoTauEta","L2 isolated #tau #eta;L2 isolated Jet #eta;entries",NEtaBins_,-2.5,2.5);
44  isoJetPhi = store_->book1D("L2IsoTauPhi","L2 isolated #tau #phi;L2 isolated Jet #phi;entries",NPhiBins_,-3.2,3.2);
45 
46  ecalIsolEt = store_->book1D("L2EcalIsolation","ECAL Isolation;L2 ECAL isolation E_{T};entries",40,0,20);
47  hcalIsolEt = store_->book1D("L2HcalIsolation","HCAL Isolation;L2 HCAL isolation E_{T};entries",40,0,20);
48 
49  seedHcalEt = store_->book1D("L2HighestHCALCluster","Highest HCAL Cluster;HCAL seed E_{T};entries",40,0,80);
50  seedEcalEt = store_->book1D("L2HighestECALCluster","Highest ECAL Cluster;ECAL seed E_{T};entries",25,0,50);
51 
52  nEcalClusters = store_->book1D("L2NEcalClusters","Nucmber of ECAL Clusters;n. of ECAL Clusters;entries",20,0,20);
53  ecalClusterEtaRMS = store_->book1D("L2EcalEtaRMS","ECAL Cluster #eta RMS;ECAL cluster #eta RMS;entries",15,0,0.05);
54  ecalClusterPhiRMS = store_->book1D("L2EcalPhiRMS","ECAL Cluster #phi RMS;ECAL cluster #phi RMS;entries",30,0,0.1);
55  ecalClusterDeltaRRMS = store_->book1D("L2EcalDeltaRRMS","ECAL Cluster #DeltaR RMS;ECAL cluster #DeltaR RMS;entries",30,0,0.1);
56 
57  nHcalClusters = store_->book1D("L2NHcalClusters","Nucmber of HCAL Clusters;n. of ECAL Clusters;entries",20,0,20);
58  hcalClusterEtaRMS = store_->book1D("L2HcalEtaRMS","HCAL Cluster #eta RMS;HCAL cluster #eta RMS;entries",15,0,0.05);
59  hcalClusterPhiRMS = store_->book1D("L2HcalPhiRMS","HCAL Cluster #phi RMS;HCAL cluster #phi RMS;entries",30,0,0.1);
60  hcalClusterDeltaRRMS = store_->book1D("L2HcalDeltaRRMS","HCAL Cluster #DeltaR RMS;HCAL cluster #DeltaR RMS;entries",30,0,0.1);
61 
62 
63  store_->setCurrentFolder(triggerTag()+"/EfficiencyHelpers");
65 
66  recoEtEffNum = store_->book1D("L2RecoTauEtEffNum","Efficiency vs E_{t}(Numerator)",NPtBins_,0,EtMax_);
67  recoEtEffNum->getTH1F()->Sumw2();
68 
69  recoEtEffDenom = store_->book1D("L2RecoTauEtEffDenom","Efficiency vs E_{t}(Denominator)",NPtBins_,0,EtMax_);
70  recoEtEffDenom->getTH1F()->Sumw2();
71 
72  recoEtaEffNum = store_->book1D("L2RecoTauEtaEffNum","Efficiency vs #eta (Numerator)",NEtaBins_,-2.5,2.5);
73  recoEtaEffNum->getTH1F()->Sumw2();
74 
75  recoEtaEffDenom = store_->book1D("L2RecoTauEtaEffDenom","Efficiency vs #eta(Denominator)",NEtaBins_,-2.5,2.5);
76  recoEtaEffDenom->getTH1F()->Sumw2();
77 
78  recoPhiEffNum = store_->book1D("L2RecoTauPhiEffNum","Efficiency vs #phi (Numerator)",NPhiBins_,-3.2,3.2);
79  recoPhiEffNum->getTH1F()->Sumw2();
80 
81  recoPhiEffDenom = store_->book1D("L2RecoTauPhiEffDenom","Efficiency vs #phi(Denominator)",NPhiBins_,-3.2,3.2);
82  recoPhiEffDenom->getTH1F()->Sumw2();
83 
84  isoEtEffNum = store_->book1D("L2IsoTauEtEffNum","Efficiency vs E_{t}(Numerator)",NPtBins_,0,EtMax_);
85  isoEtEffNum->getTH1F()->Sumw2();
86 
87  isoEtEffDenom = store_->book1D("L2IsoTauEtEffDenom","Efficiency vs E_{t}(Denominator)",NPtBins_,0,EtMax_);
88  isoEtEffDenom->getTH1F()->Sumw2();
89 
90  isoEtaEffNum = store_->book1D("L2IsoTauEtaEffNum","Efficiency vs #eta (Numerator)",NEtaBins_,-2.5,2.5);
91  isoEtaEffNum->getTH1F()->Sumw2();
92 
93  isoEtaEffDenom = store_->book1D("L2IsoTauEtaEffDenom","Efficiency vs #eta(Denominator)",NEtaBins_,-2.5,2.5);
94  isoEtaEffDenom->getTH1F()->Sumw2();
95 
96  isoPhiEffNum = store_->book1D("L2IsoTauPhiEffNum","Efficiency vs #phi (Numerator)",NPhiBins_,-3.2,3.2);
97  isoPhiEffNum->getTH1F()->Sumw2();
98 
99  isoPhiEffDenom = store_->book1D("L2IsoTauPhiEffDenom","Efficiency vs #phi(Denominator)",NPhiBins_,-3.2,3.2);
100  isoPhiEffDenom->getTH1F()->Sumw2();
101  }
102 }
103 
105 }
106 
107 void HLTTauDQMCaloPlotter::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup, const std::map<int,LVColl>& McInfo ) {
111  reco::CaloJetCollection l2RegionalJets;
112 
113  //Merge the L2 Regional Collections
114  reco::CaloJetCollection l2MergedJets;
115 
116  for ( unsigned int j = 0; j < l2preJets_.size(); ++j ) {
117  bool gotPreJets = iEvent.getByLabel(l2preJets_[j],l2Regional) && l2Regional.isValid();
118 
119  if (gotPreJets) {
120  if ( !l2Regional.failedToGet() ) {
121  for ( unsigned int i = 0; i < l2Regional->size(); ++i ) {
122  l2MergedJets.push_back(l2Regional->at(i));
123  }
124  }
125  }
126  }
127 
128  //Sort
130  std::sort(l2MergedJets.begin(),l2MergedJets.end(),sorter);
131 
132  //Remove Collinear Jets
133  reco::CaloJetCollection l2CleanJets;
134  while (l2MergedJets.size() > 0 ) {
135  l2CleanJets.push_back(l2MergedJets.at(0));
137 
138  for ( unsigned int i = 1; i < l2MergedJets.size(); ++i ) {
139  double DR = ROOT::Math::VectorUtil::DeltaR( l2MergedJets.at(0).p4(), l2MergedJets.at(i).p4() );
140  if ( DR > 0.1 ) tmp.push_back(l2MergedJets.at(i));
141  }
142 
143  l2MergedJets.swap(tmp);
144  tmp.clear();
145  }
146 
147  //Tau reference
148  std::map<int,LVColl>::const_iterator iref;
149  iref = McInfo.find(15);
150 
151  //Now fill the regional jet plots by ref if you do ref to avoid double counting!
152  if ( doRef_ ) {
153  if ( iref != McInfo.end() ) {
154  for ( LVColl::const_iterator iter = iref->second.begin(); iter != iref->second.end(); ++iter ) {
155  std::pair<bool,reco::CaloJet> m = inverseMatch(*iter,l2CleanJets);
156  if ( m.first ) {
157  preJetEt->Fill(m.second.pt());
158  preJetEta->Fill(m.second.eta());
159  preJetPhi->Fill(m.second.phi());
160  recoEtEffDenom->Fill(iter->pt());
161  recoEtaEffDenom->Fill(iter->eta());
162  recoPhiEffDenom->Fill(iter->phi());
163  l2RegionalJets.push_back(m.second);
164  }
165  }
166  }
167  } else {
168  for ( unsigned int i = 0; i < l2CleanJets.size(); ++i ) {
169  reco::CaloJet jet = l2CleanJets.at(i);
170  preJetEt->Fill(jet.pt());
171  preJetEta->Fill(jet.eta());
172  preJetPhi->Fill(jet.phi());
173  recoEtEffDenom->Fill(jet.pt());
174  recoEtaEffDenom->Fill(jet.eta());
175  recoPhiEffDenom->Fill(jet.phi());
176  l2RegionalJets.push_back(jet);
177  }
178  }
179 
180  bool gotL2 = iEvent.getByLabel(l2TauInfoAssoc_,l2TauInfoAssoc) && l2TauInfoAssoc.isValid();
181 
182  //If the collection exists do work
183  if ( gotL2 && l2TauInfoAssoc->size() > 0 ) {
184  for ( reco::L2TauInfoAssociation::const_iterator p = l2TauInfoAssoc->begin(); p != l2TauInfoAssoc->end(); ++p ) {
185  //Retrieve The L2TauIsolationInfo class from the AssociationMap
186  const reco::L2TauIsolationInfo l2info = p->val;
187 
188  //Retrieve the Jet From the AssociationMap
189  const reco::Jet& jet =*(p->key);
190 
191  std::pair<bool,LV> m(false,LV());
192  if ( iref != McInfo.end() ) m = match(jet.p4(),iref->second,matchDeltaRMC_);
193 
194  if ( (doRef_ && m.first) || (!doRef_) ) {
195  ecalIsolEt->Fill(l2info.ecalIsolEt());
196  hcalIsolEt->Fill(l2info.hcalIsolEt());
197  seedEcalEt->Fill(l2info.seedEcalHitEt());
198  seedHcalEt->Fill(l2info.seedHcalHitEt());
199 
200  nEcalClusters->Fill(l2info.nEcalHits());
201  ecalClusterEtaRMS->Fill(l2info.ecalClusterShape().at(0));
202  ecalClusterPhiRMS->Fill(l2info.ecalClusterShape().at(1));
203  ecalClusterDeltaRRMS->Fill(l2info.ecalClusterShape().at(2));
204 
205  nHcalClusters->Fill(l2info.nHcalHits());
206  hcalClusterEtaRMS->Fill(l2info.hcalClusterShape().at(0));
207  hcalClusterPhiRMS->Fill(l2info.hcalClusterShape().at(1));
208  hcalClusterDeltaRRMS->Fill(l2info.hcalClusterShape().at(2));
209 
210  jetEt->Fill(jet.et());
211  jetEta->Fill(jet.eta());
212  jetPhi->Fill(jet.phi());
213 
214  LV refLV;
215  if ( doRef_ ) {
216  refLV = m.second;
217  } else {
218  refLV = jet.p4();
219  }
220  if ( doRef_ ) {
221  jetEtRes->Fill((jet.pt()-refLV.pt())/refLV.pt());
222  }
223  if ( matchJet(jet,l2RegionalJets) ) {
224  recoEtEffNum->Fill(refLV.pt());
225  recoEtaEffNum->Fill(refLV.eta());
226  recoPhiEffNum->Fill(refLV.phi());
227  }
228 
229  isoEtEffDenom->Fill(refLV.pt());
230  isoEtaEffDenom->Fill(refLV.eta());
231  isoPhiEffDenom->Fill(refLV.phi());
232 
233  bool gotIsoL2 = iEvent.getByLabel(l2Isolated_,l2Isolated) && l2Isolated.isValid();
234 
235  if ( gotIsoL2 ) {
236  if ( matchJet(jet,*l2Isolated) ) {
237  isoJetEt->Fill(jet.et());
238  isoJetEta->Fill(jet.eta());
239  isoJetPhi->Fill(jet.phi());
240 
241  isoEtEffNum->Fill(refLV.pt());
242  isoEtaEffNum->Fill(refLV.eta());
243  isoPhiEffNum->Fill(refLV.phi());
244  }
245  }
246  }
247  }
248  }
249 }
250 
251 std::pair<bool,reco::CaloJet> HLTTauDQMCaloPlotter::inverseMatch( const LV& jet, const reco::CaloJetCollection& jets ) {
252  //Loop on the collection and see if your tau jet is matched to one there
253  //MATCH THE nearest energy jet in the delta R we want
254 
255  bool matched = false;
256  reco::CaloJet mjet;
257  double distance = 100000;
258  for ( reco::CaloJetCollection::const_iterator it = jets.begin(); it != jets.end(); ++it ) {
259  if ( ROOT::Math::VectorUtil::DeltaR(it->p4(),jet) < matchDeltaRMC_ ) {
260  matched = true;
261  double delta = fabs(jet.pt()-it->pt());
262  if (delta < distance) {
263  distance = delta;
264  mjet = *it;
265  }
266  }
267  }
268 
269  std::pair<bool,reco::CaloJet> p = std::make_pair(matched,mjet);
270  return p;
271 }
272 
274  //Loop on the collection and see if your tau jet is matched to one there
275  //Also find the nearest matched MC particle to your jet (to be complete)
276 
277  bool matched = false;
278 
279  for ( reco::CaloJetCollection::const_iterator it = McInfo.begin(); it != McInfo.end(); ++it ) {
280  if ( jet.p4() == it->p4() ) {
281  matched = true;
282  break;
283  }
284  }
285  return matched;
286 }
virtual char const * what() const
Definition: Exception.cc:141
dbl * delta
Definition: mlp_gen.cc:36
MonitorElement * isoEtaEffDenom
MonitorElement * hcalClusterDeltaRRMS
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:30
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
virtual double et() const
transverse energy
MonitorElement * isoEtaEffNum
Base class for all types of Jets.
Definition: Jet.h:21
std::vector< edm::InputTag > l2preJets_
std::vector< double > hcalClusterShape() const
MonitorElement * preJetEta
MonitorElement * nHcalClusters
MonitorElement * isoEtEffDenom
MonitorElement * ecalClusterEtaRMS
MonitorElement * isoEtEffNum
MonitorElement * seedHcalEt
MonitorElement * recoPhiEffDenom
virtual double eta() const
momentum pseudorapidity
MonitorElement * isoPhiEffNum
void Fill(long long x)
MonitorElement * ecalClusterDeltaRRMS
math::XYZTLorentzVectorD LV
MonitorElement * seedEcalEt
int iEvent
Definition: GenABIO.cc:243
HLTTauDQMCaloPlotter(const edm::ParameterSet &, int, int, int, double, bool, double, std::string)
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2564
MonitorElement * isoJetEta
vector< PseudoJet > jets
MonitorElement * isoJetEt
MonitorElement * preJetPhi
MonitorElement * isoJetPhi
std::string triggerTagAlias_
int j
Definition: DBlmapReader.cc:9
MonitorElement * ecalClusterPhiRMS
bool isValid() const
Definition: HandleBase.h:76
MonitorElement * recoEtEffDenom
MonitorElement * recoEtaEffNum
void analyze(const edm::Event &, const edm::EventSetup &, const std::map< int, LVColl > &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
MonitorElement * recoPhiEffNum
bool failedToGet() const
Definition: HandleBase.h:80
MonitorElement * recoEtaEffDenom
MonitorElement * isoPhiEffDenom
std::string triggerTag()
std::pair< bool, reco::CaloJet > inverseMatch(const LV &, const reco::CaloJetCollection &)
virtual double pt() const
transverse momentum
TH1F * getTH1F(void) const
MonitorElement * preJetEt
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
MonitorElement * hcalClusterEtaRMS
MonitorElement * hcalIsolEt
MonitorElement * jetEtRes
std::pair< bool, LV > match(const LV &, const LVColl &, double)
bool matchJet(const reco::Jet &, const reco::CaloJetCollection &)
std::string triggerTag_
std::vector< double > ecalClusterShape() const
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
MonitorElement * recoEtEffNum
MonitorElement * ecalIsolEt
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * hcalClusterPhiRMS
std::string dqmBaseFolder_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
MonitorElement * nEcalClusters