CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TauTagValidation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TauTagValidation
4 // Class: TauTagValidation
5 //
15 //
16 // Original Author: Ricardo Vasquez Sierra
17 // Created: October 8, 2008
18 // $Id: TauTagValidation.cc,v 1.38 2012/04/02 10:23:15 perchall Exp $
19 //
20 //
21 // user include files
22 
28 
31 
33 
34 using namespace edm;
35 using namespace std;
36 using namespace reco;
37 
39  moduleLabel_(iConfig.getParameter<std::string>("@module_label")),
40  // What do we want to use as source Leptons or Jets (the only difference is the matching criteria)
41  dataType_( iConfig.getParameter<string>("DataType") ),
42  // We need different matching criteria if we talk about leptons or jets
43  matchDeltaR_Leptons_( iConfig.getParameter<double>("MatchDeltaR_Leptons")),
44  matchDeltaR_Jets_( iConfig.getParameter<double>("MatchDeltaR_Jets")),
45  TauPtCut_( iConfig.getParameter<double>("TauPtCut")),
46  //flexible cut interface to filter reco and gen collection. use an empty string to select all.
47  recoCuts_( iConfig.getParameter<std::string>( "recoCuts" )),
48  genCuts_( iConfig.getParameter<std::string>( "genCuts" )),
49  // The output histograms can be stored or not
50  saveoutputhistograms_( iConfig.getParameter<bool>("SaveOutputHistograms")),
51  // Here it can be pretty much anything either a lepton or a jet
52  refCollectionInputTag_( iConfig.getParameter<InputTag>("RefCollection")),
53  // The extension name has information about the Reference collection used
54  extensionName_( iConfig.getParameter<string>("ExtensionName")),
55  // Here is the reconstructed product of interest.
56  TauProducerInputTag_( iConfig.getParameter<InputTag>("TauProducer")),
57  // Get the discriminators and their cuts
58  discriminators_( iConfig.getParameter< std::vector<edm::ParameterSet> >( "discriminators" ))
59 {
60  //LogDebug("StormStorageMaker") << moduleLabel_<<"::TauTagValidation" << endl;
61  turnOnTrigger_ = iConfig.exists("turnOnTrigger") && iConfig.getParameter<bool>("turnOnTrigger");
62  genericTriggerEventFlag_ = (iConfig.exists("GenericTriggerSelection") && turnOnTrigger_) ? new GenericTriggerEventFlag(iConfig.getParameter<edm::ParameterSet>("GenericTriggerSelection")) : NULL;
63  if(genericTriggerEventFlag_ != NULL) LogDebug(moduleLabel_) <<"--> GenericTriggerSelection parameters found in "<<moduleLabel_<<"."<<std::endl;//move to LogDebug
64  else LogDebug(moduleLabel_) <<"--> GenericTriggerSelection not found in "<<moduleLabel_<<"."<<std::endl;//move to LogDebug to keep track of modules that fail and pass
65 
66 
67  //InputTag to strings
70 
71  histoSettings_= (iConfig.exists("histoSettings")) ? iConfig.getParameter<edm::ParameterSet>("histoSettings") : edm::ParameterSet();
72  PrimaryVertexCollection_ = (iConfig.exists("PrimaryVertexCollection")) ? iConfig.getParameter<InputTag>("PrimaryVertexCollection") : edm::InputTag("offlinePrimaryVertices");
73  // The vector of Tau Discriminators to be monitored
74  // TauProducerDiscriminators_ = iConfig.getUntrackedParameter<std::vector<string> >("TauProducerDiscriminators");
75 
76  // The cut on the Discriminators
77  // TauDiscriminatorCuts_ = iConfig.getUntrackedParameter<std::vector<double> > ("TauDiscriminatorCuts");
78 
79  // cout << " RefCollection: " << refCollection_.label() << " "<< refCollection_ << endl;
80 
82  // cout<<endl<<"-----------------------*******************************Version: " << tversion<<endl;
83 
84  if (!saveoutputhistograms_) {
85  LogInfo("OutputInfo") << " TauVisible histograms will NOT be saved";
86  } else {
88  outPutFile_.append("_");
89  tversion.erase(0,1);
90  tversion.erase(tversion.size()-1,1);
91  outPutFile_.append(tversion);
92  outPutFile_.append("_"+ refCollection_);
93  if ( ! extensionName_.empty()){
94  outPutFile_.append("_"+ extensionName_);
95  }
96  outPutFile_.append(".root");
97 
98  // cout<<endl<< outPutFile_<<endl;
99  LogInfo("OutputInfo") << " TauVisiblehistograms will be saved to file:" << outPutFile_;
100  }
101 
102  //---- book-keeping information ---
103  numEvents_ = 0 ;
104 
105  // Check if we want to "chain" the discriminator requirements (i.e. all
106  // prveious discriminators must pass)
107  chainCuts_ = iConfig.exists("chainCuts") ?
108  iConfig.getParameter<bool>("chainCuts") : true;
109 
110 }
113 }
114 
116  //cout << moduleLabel_<<"::analyze" << endl;
118  if (!genericTriggerEventFlag_->on()) std::cout<<"TauTagValidation::analyze: No working genericTriggerEventFlag. Did you specify a valid globaltag?"<<std::endl;//move to LogDebug?
119  if ( genericTriggerEventFlag_->on() && !genericTriggerEventFlag_->accept(iEvent, iSetup) ) {
120 // std::cout<<"genericTriggerEventFlag rejected this event in "<<moduleLabel_<<std::endl;
121  return;
122  } else {
123 // std::cout<<"--> genericTriggerEventFlag accepted this event in "<<moduleLabel_<<std::endl;//REMOVE ME
124  }
125  }
126 
127  numEvents_++;
128  double matching_criteria = -1.0;
129 
130  typedef edm::View<reco::Candidate> genCandidateCollection;
131  // typedef edm::Vector<reco::PFTau> pfCandidateCollection;
132  // typedef edm::Vector<reco::CaloTau> caloCandidateCollection;
133 
134  // std::cout << "--------------------------------------------------------------"<<endl;
135  //std::cout << " RunNumber: " << iEvent.id().run() << ", EventNumber: " << iEvent.id().event() << std:: endl;
136  //std::cout << "Event number: " << ++numEvents_ << endl;
137  //std::cout << "--------------------------------------------------------------"<<endl;
138 
139  // ----------------------- Reference product -----------------------------------------------------------------------
140 
141  Handle<genCandidateCollection> ReferenceCollection;
142  bool isGen = iEvent.getByLabel(refCollectionInputTag_, ReferenceCollection); // get the product from the event
143 
144  Handle<VertexCollection> pvHandle;
145  iEvent.getByLabel(PrimaryVertexCollection_,pvHandle);
146 
147  if (!isGen) {
148  std::cerr << " Reference collection: " << refCollection_ << " not found while running TauTagValidation.cc " << std::endl;
149  return;
150  }
151 
152  if(dataType_ == "Leptons"){
153  matching_criteria = matchDeltaR_Leptons_;
154  }
155  else
156  {
157  matching_criteria = matchDeltaR_Jets_;
158  }
159 
160  // ------------------------------ PFTauCollection Matched and other discriminators ---------------------------------------------------------
161 
162  if ( TauProducer_.find("PFTau") != string::npos || TauProducer_.find("hpsTancTaus") != string::npos )
163  {
164  Handle<PFTauCollection> thePFTauHandle;
165  iEvent.getByLabel(TauProducerInputTag_,thePFTauHandle);
166 
167  const PFTauCollection *pfTauProduct;
168  pfTauProduct = thePFTauHandle.product();
169 
170  PFTauCollection::size_type thePFTauClosest;
171 
172  std::map<std::string, MonitorElement *>::const_iterator element = plotMap_.end();
173 
174  for (genCandidateCollection::const_iterator RefJet= ReferenceCollection->begin() ; RefJet != ReferenceCollection->end(); RefJet++ ){
175 
176  ptTauVisibleMap.find(refCollection_)->second->Fill(RefJet->pt());
177  etaTauVisibleMap.find(refCollection_)->second->Fill(RefJet->eta());
178  phiTauVisibleMap.find(refCollection_)->second->Fill(RefJet->phi()*180.0/TMath::Pi());
179  pileupTauVisibleMap.find(refCollection_)->second->Fill(pvHandle->size());
180 
181  const reco::Candidate *gen_particle = &(*RefJet);
182 
183  double delta=TMath::Pi();
184 
185  thePFTauClosest = pfTauProduct->size();
186 
187  for (PFTauCollection::size_type iPFTau=0 ; iPFTau < pfTauProduct->size() ; iPFTau++)
188  {
189  if (algo_->deltaR(gen_particle, & pfTauProduct->at(iPFTau)) < delta){
190  delta = algo_->deltaR(gen_particle, & pfTauProduct->at(iPFTau));
191  thePFTauClosest = iPFTau;
192  }
193  }
194 
195  // Skip if there is no reconstructed Tau matching the Reference
196  if (thePFTauClosest == pfTauProduct->size()) continue;
197 
198  double deltaR = algo_->deltaR(gen_particle, & pfTauProduct->at(thePFTauClosest));
199 
200  // Skip if the delta R difference is larger than the required criteria
201  if (deltaR > matching_criteria && matching_criteria != -1.0) continue;
202 
203  ptTauVisibleMap.find( TauProducer_+"Matched")->second->Fill(RefJet->pt());
204  etaTauVisibleMap.find( TauProducer_+"Matched" )->second->Fill(RefJet->eta());
205  phiTauVisibleMap.find( TauProducer_+"Matched" )->second->Fill(RefJet->phi()*180.0/TMath::Pi());
206  pileupTauVisibleMap.find( TauProducer_+"Matched")->second->Fill(pvHandle->size());
207 
208  PFTauRef thePFTau(thePFTauHandle, thePFTauClosest);
209 
210  Handle<PFTauDiscriminator> currentDiscriminator;
211 
212 
213  //filter the candidates
214  if(thePFTau->pt() < TauPtCut_ ) continue;//almost deprecated, since recoCuts_ provides more flexibility
215  //reco
217  bool pass = selectReco( thePFTau );
218  if( !pass ) continue;
219  //gen
221  pass = selectGen( *gen_particle );
222  if( !pass ) continue;
223  //printf("TauTagValidation::analyze:selectGen: values: %f, %f\n", gen_particle->pt(), gen_particle->eta());
224 
225 
226  for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++)
227  {
228  string currentDiscriminatorLabel = it->getParameter<string>("discriminator");
229  iEvent.getByLabel(currentDiscriminatorLabel, currentDiscriminator);
230 
231  if ((*currentDiscriminator)[thePFTau] >= it->getParameter<double>("selectionCut")){
232  ptTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(RefJet->pt());
233  etaTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(RefJet->eta());
234  phiTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(RefJet->phi()*180.0/TMath::Pi());
235  pileupTauVisibleMap.find( currentDiscriminatorLabel )->second->Fill(pvHandle->size());
236 
237  //fill the DeltaR plots
238  /*if(thePFTau->jetRef().isAvailable() && thePFTau->jetRef().isNonnull())
239  plotMap_.find( currentDiscriminatorLabel + "_dRTauRefJet")->second->Fill( algo_->deltaR(thePFTau.get(), thePFTau->jetRef().get() ) );*/
240 
241  //fill the momentum resolution plots
242  double tauPtRes = thePFTau->pt()/gen_particle->pt();//WARNING: use only the visible parts!
243  plotMap_.find( currentDiscriminatorLabel + "_pTRatio_allHadronic" )->second->Fill(tauPtRes);
244 
245  //is there a better way than casting the candidate?
246  const reco::GenJet *tauGenJet = dynamic_cast<const reco::GenJet*>(gen_particle);
247  if(tauGenJet!=0){
248  std::string genTauDecayMode = JetMCTagUtils::genTauDecayMode(*tauGenJet); // gen_particle is the tauGenJet matched to the reconstructed tau
249  element = plotMap_.find( currentDiscriminatorLabel + "_pTRatio_" + genTauDecayMode );
250  if( element != plotMap_.end() ) element->second->Fill(tauPtRes);
251  // else LogInfo("TauTagValidation") << "No plot required for decay mode "<<genTauDecayMode.c_str()<<".";
252  // else printf("No plot for decay mode %s required.\n", genTauDecayMode.c_str());
253  }else{
254  LogInfo("TauTagValidation") << " Failed to cast the MC candidate.";
255  }
256 
257  //fill: size and sumPt within tau isolation
258  std::string plotType = "_Size_";
259  element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFCands" );
260  if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFCands().size() );
261  element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFChargedHadrCands" );
262  if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFChargedHadrCands().size() );
263  element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFNeutrHadrCands" );
264  if( element != plotMap_.end() ) element->second->Fill( thePFTau->signalPFNeutrHadrCands().size() );
265  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFCands" );
266  if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFCands().size() );
267  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFChargedHadrCands" );
268  if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFChargedHadrCands().size() );
269  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFNeutrHadrCands" );
270  if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFNeutrHadrCands().size() );
271  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFGammaCands" );
272  if( element != plotMap_.end() ) element->second->Fill( thePFTau->isolationPFGammaCands().size() );
273 
274  plotType = "_SumPt_";
275  element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFCands" );
276  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFCands() ) );
277  element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFChargedHadrCands" );
278  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFChargedHadrCands() ) );
279  element = plotMap_.find( currentDiscriminatorLabel + plotType + "signalPFNeutrHadrCands" );
280  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->signalPFNeutrHadrCands() ) );
281  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFCands" );
282  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFCands() ) );
283  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFChargedHadrCands" );
284  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFChargedHadrCands() ) );
285  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFNeutrHadrCands" );
286  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFNeutrHadrCands() ) );
287  element = plotMap_.find( currentDiscriminatorLabel + plotType + "isolationPFGammaCands" );
288  if( element != plotMap_.end() ) element->second->Fill( getSumPt( thePFTau->isolationPFGammaCands() ) );
289 
290 
291  //deprecated
292 
293  if( TauProducer_.find("PFTau") != string::npos ){
294  if ( currentDiscriminatorLabel.find("LeadingTrackPtCut") != string::npos){
295  nPFJet_LeadingChargedHadron_ChargedHadronsSignal_->Fill((*thePFTau).signalPFChargedHadrCands().size());
296  nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFChargedHadrCands().size());
297  nPFJet_LeadingChargedHadron_GammasSignal_->Fill((*thePFTau).signalPFGammaCands().size());
298  nPFJet_LeadingChargedHadron_GammasIsolAnnulus_->Fill((*thePFTau).isolationPFGammaCands().size());
299  nPFJet_LeadingChargedHadron_NeutralHadronsSignal_->Fill((*thePFTau).signalPFNeutrHadrCands().size());
300  nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFNeutrHadrCands().size());
301  }
302  else if ( currentDiscriminatorLabel.find("ByIsolation") != string::npos ){
303  nIsolated_NoChargedNoGammas_ChargedHadronsSignal_->Fill((*thePFTau).signalPFChargedHadrCands().size());
304  nIsolated_NoChargedNoGammas_GammasSignal_->Fill((*thePFTau).signalPFGammaCands().size());
305  nIsolated_NoChargedNoGammas_NeutralHadronsSignal_->Fill((*thePFTau).signalPFNeutrHadrCands().size());
306  nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_->Fill((*thePFTau).isolationPFNeutrHadrCands().size());
307  }
308  }
309  }
310  else {
311  if (chainCuts_)
312  break;
313  }
314  }
315  }
316  }
317 }
319  //cout << moduleLabel_<<"::beginJob" << endl;
321 
322  if(dbeTau_) {
323 
324  MonitorElement * ptTemp,* etaTemp,* phiTemp, *pileupTemp, *tmpME;
325 
326  dbeTau_->setCurrentFolder("RecoTauV/" + TauProducer_ + extensionName_ + "_ReferenceCollection" );
327 
328  //Histograms settings
329  hinfo ptHinfo = (histoSettings_.exists("pt")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("pt")) : hinfo(75, 0., 150.);
330  hinfo etaHinfo = (histoSettings_.exists("eta")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("eta")) : hinfo(60, -3.0, 3.0);
331  hinfo phiHinfo = (histoSettings_.exists("phi")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("phi")) : hinfo(36, -180., 180.);
332  hinfo pileupHinfo = (histoSettings_.exists("pileup")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("pileup")) : hinfo(25, 0., 25.0);
333  //hinfo dRHinfo = (histoSettings_.exists("deltaR")) ? hinfo(histoSettings_.getParameter<edm::ParameterSet>("deltaR")) : hinfo(10, 0., 0.5);
334 
335  // What kind of Taus do we originally have!
336 
337  ptTemp = dbeTau_->book1D("nRef_Taus_vs_ptTauVisible", "nRef_Taus_vs_ptTauVisible", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
338  etaTemp = dbeTau_->book1D("nRef_Taus_vs_etaTauVisible", "nRef_Taus_vs_etaTauVisible", etaHinfo.nbins, etaHinfo.min, etaHinfo.max );
339  phiTemp = dbeTau_->book1D("nRef_Taus_vs_phiTauVisible", "nRef_Taus_vs_phiTauVisible", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
340  pileupTemp = dbeTau_->book1D("nRef_Taus_vs_pileupTauVisible", "nRef_Taus_vs_pileupTauVisible", pileupHinfo.nbins, pileupHinfo.min, pileupHinfo.max);
341 
342  ptTauVisibleMap.insert( std::make_pair( refCollection_,ptTemp));
343  etaTauVisibleMap.insert( std::make_pair(refCollection_,etaTemp));
344  phiTauVisibleMap.insert( std::make_pair(refCollection_,phiTemp));
345  pileupTauVisibleMap.insert( std::make_pair(refCollection_,pileupTemp));
346 
347 
348  // Number of Tau Candidates matched to MC Taus
349 
350  dbeTau_->setCurrentFolder("RecoTauV/"+ TauProducer_ + extensionName_ + "_Matched");
351 
352  ptTemp = dbeTau_->book1D(TauProducer_ +"Matched_vs_ptTauVisible", TauProducer_ +"Matched_vs_ptTauVisible", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
353  etaTemp = dbeTau_->book1D(TauProducer_ +"Matched_vs_etaTauVisible", TauProducer_ +"Matched_vs_etaTauVisible", etaHinfo.nbins, etaHinfo.min, etaHinfo.max );
354  phiTemp = dbeTau_->book1D(TauProducer_ +"Matched_vs_phiTauVisible", TauProducer_ +"Matched_vs_phiTauVisible", phiHinfo.nbins, phiHinfo.min, phiHinfo.max );
355  pileupTemp = dbeTau_->book1D(TauProducer_ +"Matched_vs_pileupTauVisible", TauProducer_ +"Matched_vs_pileupTauVisible", pileupHinfo.nbins, pileupHinfo.min, pileupHinfo.max);
356 
357  ptTauVisibleMap.insert( std::make_pair( TauProducer_+"Matched" ,ptTemp));
358  etaTauVisibleMap.insert( std::make_pair(TauProducer_+"Matched" ,etaTemp));
359  phiTauVisibleMap.insert( std::make_pair(TauProducer_+"Matched" ,phiTemp));
360  pileupTauVisibleMap.insert( std::make_pair(TauProducer_+"Matched" ,pileupTemp));
361 
362 
363  for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++)
364  {
365  string DiscriminatorLabel = it->getParameter<string>("discriminator");
366  std::string histogramName;
367  stripDiscriminatorLabel(DiscriminatorLabel, histogramName);
368 
369  dbeTau_->setCurrentFolder("RecoTauV/" + TauProducer_ + extensionName_ + "_" + DiscriminatorLabel );
370 
371  ptTemp = dbeTau_->book1D(DiscriminatorLabel + "_vs_ptTauVisible", histogramName +"_vs_ptTauVisible", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
372  etaTemp = dbeTau_->book1D(DiscriminatorLabel + "_vs_etaTauVisible", histogramName + "_vs_etaTauVisible", etaHinfo.nbins, etaHinfo.min, etaHinfo.max );
373  phiTemp = dbeTau_->book1D(DiscriminatorLabel + "_vs_phiTauVisible", histogramName + "_vs_phiTauVisible", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
374  pileupTemp = dbeTau_->book1D(DiscriminatorLabel + "_vs_pileupTauVisible", histogramName + "_vs_pileupTauVisible", pileupHinfo.nbins, pileupHinfo.min, pileupHinfo.max);
375 
376  ptTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,ptTemp));
377  etaTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,etaTemp));
378  phiTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,phiTemp));
379  pileupTauVisibleMap.insert( std::make_pair(DiscriminatorLabel,pileupTemp));
380 
381 
382  /*/DR between tau and refJet
383  tmpME = dbeTau_->book1D(DiscriminatorLabel + "_dRTauRefJet", histogramName +"_dRTauRefJet;#DeltaR(#tau,refJet);Frequency", dRHinfo.nbins, dRHinfo.min, dRHinfo.max);
384  plotMap_.insert( std::make_pair(DiscriminatorLabel + "_dRTauRefJet",tmpME));*/
385 
386 
387  // momentum resolution for several decay modes
388 
389  std::string plotType = "_pTRatio_";//use underscores (this allows to parse plot type in later stages)
390  std::string xaxisLabel = ";p_{T}^{reco}/p_{T}^{gen}";
391  std::string yaxislabel = ";Frequency";
392  std::string plotName = plotType + "allHadronic";
393  int bins = 40;
394  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.);
395  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
396  plotName = plotType + "oneProng0Pi0";
397  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.);
398  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
399  plotName = plotType + "oneProng1Pi0";
400  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.);
401  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
402  plotName = plotType + "oneProng2Pi0";
403  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.);
404  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
405  plotName = plotType + "threeProng0Pi0";
406  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.);
407  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
408  plotName = plotType + "threeProng1Pi0";
409  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 2.);
410  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
411 
412 
413  //size and sumPt within tau isolation
414 
415  plotType = "_Size_";
416  xaxisLabel = ";size";
417  yaxislabel = ";Frequency";
418  bins = 20;
419  plotName = plotType + "signalPFCands";
420  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
421  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
422  plotName = plotType + "signalPFChargedHadrCands";
423  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
424  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
425  plotName = plotType + "signalPFNeutrHadrCands";
426  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
427  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
428 
429  plotName = plotType + "isolationPFCands";
430  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
431  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
432  plotName = plotType + "isolationPFChargedHadrCands";
433  bins = 10;
434  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
435  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
436  plotName = plotType + "isolationPFNeutrHadrCands";
437  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
438  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
439  plotName = plotType + "isolationPFGammaCands";
440  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, -0.5, bins-0.5);
441  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
442 
443  plotType = "_SumPt_";
444  xaxisLabel = ";p_{T}^{sum}/ GeV";
445  yaxislabel = ";Frequency";
446  bins = 20;
447  plotName = plotType + "signalPFCands";
448  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.);
449  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
450  plotName = plotType + "signalPFChargedHadrCands";
451  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.);
452  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
453  plotName = plotType + "signalPFNeutrHadrCands";
454  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.);
455  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
456  plotName = plotType + "isolationPFCands";
457  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 50.);
458  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
459  plotName = plotType + "isolationPFChargedHadrCands";
460  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 10.);
461  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
462  plotName = plotType + "isolationPFNeutrHadrCands";
463  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 30.);
464  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
465  plotName = plotType + "isolationPFGammaCands";
466  tmpME = dbeTau_->book1D(DiscriminatorLabel + plotName, histogramName + plotName + xaxisLabel + yaxislabel, bins, 0., 20.);
467  plotMap_.insert( std::make_pair( DiscriminatorLabel + plotName, tmpME ) );
468 
469 
470  //deprecated!
471 
472  // if ( TauProducer_.find("PFTau") != string::npos)
473  // {
474 
475  if ( DiscriminatorLabel.find("LeadingTrackPtCut") != string::npos){
476  if ( TauProducer_.find("PFTau") != string::npos)
477  {
478  nPFJet_LeadingChargedHadron_ChargedHadronsSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_ChargedHadronsSignal",DiscriminatorLabel + "_ChargedHadronsSignal", 21, -0.5, 20.5);
479  nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_ =dbeTau_->book1D(DiscriminatorLabel + "_ChargedHadronsIsolAnnulus",DiscriminatorLabel + "_ChargedHadronsIsolAnnulus", 21, -0.5, 20.5);
480  nPFJet_LeadingChargedHadron_GammasSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_GammasSignal",DiscriminatorLabel + "_GammasSignal",21, -0.5, 20.5);
481  nPFJet_LeadingChargedHadron_GammasIsolAnnulus_ =dbeTau_->book1D(DiscriminatorLabel + "_GammasIsolAnnulus",DiscriminatorLabel + "_GammasIsolAnnulus",21, -0.5, 20.5);
482  nPFJet_LeadingChargedHadron_NeutralHadronsSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_NeutralHadronsSignal",DiscriminatorLabel + "_NeutralHadronsSignal",21, -0.5, 20.5);
483  nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_ =dbeTau_->book1D(DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",21, -0.5, 20.5);
484  }
485  }
486 
487  if ( DiscriminatorLabel.find("ByIsolationLater") != string::npos ){
488  if ( TauProducer_.find("PFTau") != string::npos)
489  {
490  nIsolated_NoChargedHadrons_ChargedHadronsSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_ChargedHadronsSignal",DiscriminatorLabel + "_ChargedHadronsSignal", 21, -0.5, 20.5);
491  nIsolated_NoChargedHadrons_GammasSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_GammasSignal",DiscriminatorLabel + "_GammasSignal",21, -0.5, 20.5);
492  nIsolated_NoChargedHadrons_GammasIsolAnnulus_ =dbeTau_->book1D(DiscriminatorLabel + "_GammasIsolAnnulus",DiscriminatorLabel + "_GammasIsolAnnulus",21, -0.5, 20.5);
493  nIsolated_NoChargedHadrons_NeutralHadronsSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_NeutralHadronsSignal",DiscriminatorLabel + "_NeutralHadronsSignal",21, -0.5, 20.5);
494  nIsolated_NoChargedHadrons_NeutralHadronsIsolAnnulus_ =dbeTau_->book1D(DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",21, -0.5, 20.5);
495  }
496  }
497 
498  if ( DiscriminatorLabel.find("ByIsolation") != string::npos ){
499  if ( TauProducer_.find("PFTau") != string::npos)
500  {
501  nIsolated_NoChargedNoGammas_ChargedHadronsSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_ChargedHadronsSignal",DiscriminatorLabel + "_ChargedHadronsSignal", 21, -0.5, 20.5);
502  nIsolated_NoChargedNoGammas_GammasSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_GammasSignal",DiscriminatorLabel + "_GammasSignal",21, -0.5, 20.5);
503  nIsolated_NoChargedNoGammas_NeutralHadronsSignal_ =dbeTau_->book1D(DiscriminatorLabel + "_NeutralHadronsSignal",DiscriminatorLabel + "_NeutralHadronsSignal",21, -0.5, 20.5);
504  nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_ =dbeTau_->book1D(DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",DiscriminatorLabel + "_NeutralHadronsIsolAnnulus",21, -0.5, 20.5);
505 
506  }
507  }
508 
509  }
510  }
511 
512  // for ( std::vector< edm::ParameterSet >::iterator it = discriminators_.begin(); it!= discriminators_.end(); it++)
513  // {
514  // cerr<< " "<< it->getParameter<string>("discriminator") << " "<< it->getParameter<double>("selectionCut") << endl;
515 
516  // }
517 }
519  //store the output
521 }
522 void TauTagValidation::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
523  //cout << moduleLabel_<<"::beginRun" << endl;
526  //cout << "initializing trigger" << endl;
527  genericTriggerEventFlag_->initRun(iRun, iSetup);
528  }
529  }
530 }
531 void TauTagValidation::endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
532 }
534 }
536 }
537 
539  double sumPt = 0.;
540  for (reco::PFCandidateRefVector::const_iterator candidate = candidates.begin(); candidate!=candidates.end(); ++candidate) {
541  sumPt += (*candidate)->pt();
542  }
543 
544  return sumPt;
545 }
546 bool TauTagValidation::stripDiscriminatorLabel(const std::string& discriminatorLabel, std::string & newLabel) {
547  std::string separatorString = "DiscriminationBy";
548  std::string::size_type separator = discriminatorLabel.find(separatorString);
549  if(separator==std::string::npos){
550  separatorString = "Discrimination";//DiscriminationAgainst, keep the 'against' here
551  separator = discriminatorLabel.find(separatorString);
552  if(separator==std::string::npos){
553  //std::cout<<"TauTagValidation::splitDiscriminatorLabel: failed to split "<<discriminatorLabel<<std::endl;
554  return false;
555  }
556  }
557 
558  std::string prefix = discriminatorLabel.substr(0,separator);
559  std::string postfix = discriminatorLabel.substr(separator+separatorString.size());
560 
561  //std::cout<<"TauTagValidation::splitDiscriminatorLabel: split "<<discriminatorLabel<<" into "<<prefix<<" and "<<postfix<<std::endl;
562 
563  newLabel = prefix+postfix;
564 
565  return true;
566 }
#define LogDebug(id)
std::map< std::string, MonitorElement * > ptTauVisibleMap
dbl * delta
Definition: mlp_gen.cc:36
const double Pi
T getParameter(std::string const &) const
std::string genTauDecayMode(const reco::CompositePtrCandidate &c)
Definition: JetMCTag.cc:81
MonitorElement * nPFJet_LeadingChargedHadron_ChargedHadronsIsolAnnulus_
std::map< std::string, MonitorElement * > plotMap_
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
double getSumPt(const reco::PFCandidateRefVector &candidates)
sum the transversal momentum of all candidates
double max
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * nPFJet_LeadingChargedHadron_NeutralHadronsIsolAnnulus_
virtual double pt() const =0
transverse momentum
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define NULL
Definition: scimark2.h:8
edm::InputTag TauProducerInputTag_
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
virtual void endJob()
std::string refCollection_
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
uint16_t size_type
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
void Fill(long long x)
std::string outPutFile_
MonitorElement * nPFJet_LeadingChargedHadron_GammasSignal_
std::vector< edm::ParameterSet > discriminators_
MonitorElement * nPFJet_LeadingChargedHadron_ChargedHadronsSignal_
int iEvent
Definition: GenABIO.cc:243
std::string tversion
GenericTriggerEventFlag * genericTriggerEventFlag_
generic access to dynamic trigger table
MonitorElement * nIsolated_NoChargedNoGammas_ChargedHadronsSignal_
std::string dataType_
What&#39;s the reference for the Validation Leptons or Jets.
std::string TauProducer_
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
static double deltaR(const T *, const U *)
Jets made from MC generator particles.
Definition: GenJet.h:25
MonitorElement * nIsolated_NoChargedHadrons_GammasSignal_
MonitorElement * nIsolated_NoChargedHadrons_GammasIsolAnnulus_
std::string genCuts_
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
std::map< std::string, MonitorElement * > etaTauVisibleMap
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::string getReleaseVersion()
MonitorElement * nIsolated_NoChargedNoGammas_NeutralHadronsSignal_
double min
MonitorElement * nIsolated_NoChargedNoGammas_NeutralHadronsIsolAnnulus_
MonitorElement * nIsolated_NoChargedHadrons_NeutralHadronsSignal_
std::string extensionName_
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:25
MonitorElement * nIsolated_NoChargedHadrons_NeutralHadronsIsolAnnulus_
std::string moduleLabel_
label of the current module
edm::InputTag refCollectionInputTag_
virtual void endRun(edm::Run const &, edm::EventSetup const &)
bool stripDiscriminatorLabel(const std::string &discriminatorLabel, std::string &newLabel)
get rid of redundant parts to shorten the label
edm::InputTag PrimaryVertexCollection_
tuple cout
Definition: gather_cfg.py:121
MonitorElement * nIsolated_NoChargedHadrons_ChargedHadronsSignal_
std::map< std::string, MonitorElement * > phiTauVisibleMap
MonitorElement * nPFJet_LeadingChargedHadron_NeutralHadronsSignal_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
TauTagValidation(const edm::ParameterSet &)
edm::ParameterSet histoSettings_
MonitorElement * nPFJet_LeadingChargedHadron_GammasIsolAnnulus_
std::string recoCuts_
std::map< std::string, MonitorElement * > pileupTauVisibleMap
MonitorElement * nIsolated_NoChargedNoGammas_GammasSignal_
PFBenchmarkAlgo * algo_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
virtual void beginJob()
Definition: Run.h:33