CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
RecoTauDifferenceAnalyzer Class Reference
Inheritance diagram for RecoTauDifferenceAnalyzer:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void endJob () override
 
bool filter (edm::Event &evt, const edm::EventSetup &es) override
 
 RecoTauDifferenceAnalyzer (const edm::ParameterSet &pset)
 
 ~RecoTauDifferenceAnalyzer () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

size_t allPassed1_
 
size_t allPassed2_
 
size_t differences_
 
edm::InputTag disc1_
 
edm::InputTag disc2_
 
size_t eventsExamined_
 
bool filter_
 
double maxDeltaR_
 
size_t passed1_
 
size_t passed2_
 
edm::InputTag src1_
 
edm::InputTag src2_
 
size_t tausExamined_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 10 of file RecoTauDifferenceAnalyzer.cc.

Constructor & Destructor Documentation

RecoTauDifferenceAnalyzer::RecoTauDifferenceAnalyzer ( const edm::ParameterSet pset)
explicit

Definition at line 32 of file RecoTauDifferenceAnalyzer.cc.

References allPassed1_, allPassed2_, differences_, disc1_, disc2_, eventsExamined_, Exception, edm::ParameterSet::exists(), filter_, edm::ParameterSet::getParameter(), edm::Ref< C, T, F >::isNonnull(), reco::PFTau::jetRef(), passed1_, passed2_, reco::PFTau::pfTauTagInfoRef(), src1_, src2_, metsig::tau, and tausExamined_.

33  {
34  src1_ = pset.getParameter<edm::InputTag>("src1");
35  src2_ = pset.getParameter<edm::InputTag>("src2");
36  disc1_ = pset.getParameter<edm::InputTag>("disc1");
37  disc2_ = pset.getParameter<edm::InputTag>("disc2");
38  eventsExamined_ = 0;
39  tausExamined_ = 0;
40  differences_ = 0;
41  passed1_ = 0;
42  passed2_ = 0;
43  allPassed2_ = 0;
44  allPassed1_ = 0;
45  filter_ = pset.exists("filter") ? pset.getParameter<bool>("filter") : false;
46 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
RecoTauDifferenceAnalyzer::~RecoTauDifferenceAnalyzer ( )
inlineoverride

Definition at line 13 of file RecoTauDifferenceAnalyzer.cc.

References endJob(), and filter().

13 {}

Member Function Documentation

void RecoTauDifferenceAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 120 of file RecoTauDifferenceAnalyzer.cc.

References allPassed1_, allPassed2_, gather_cfg::cout, DEFINE_FWK_MODULE, differences_, disc1_, disc2_, eventsExamined_, passed1_, passed2_, src1_, src2_, and tausExamined_.

Referenced by ~RecoTauDifferenceAnalyzer().

120  {
121  std::cout << " RECO TAU DIFFERENCE SUMMARY: " << std::endl;
122  std::cout << " Examined " << tausExamined_ << " taus in "
123  << eventsExamined_ << " events." << std::endl;
124  std::cout << " There were " << differences_ << " differences." << std::endl;
125  std::cout << src1_ << "," << disc1_ << " had "
126  << allPassed1_ << " total passes and "
127  << passed1_ << " exclusive passes." << std::endl;
128  std::cout << src2_ << "," << disc2_ << " had "
129  << allPassed2_ << " total passes and "
130  << passed2_ << " exclusive passes." << std::endl;
131 }
bool RecoTauDifferenceAnalyzer::filter ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 58 of file RecoTauDifferenceAnalyzer.cc.

References allPassed1_, allPassed2_, deltar::bestMatch(), gather_cfg::cout, deltaR(), differences_, disc1_, disc2_, eventsExamined_, filter_, edm::Event::getByLabel(), edm::Ref< C, T, F >::isNull(), passed1_, passed2_, src1_, src2_, jets_cff::tau1, jets_cff::tau2, and tausExamined_.

Referenced by ~RecoTauDifferenceAnalyzer().

59  {
61  // Get taus
63  evt.getByLabel(src1_, taus1);
65  evt.getByLabel(src2_, taus2);
66 
67  // Get discriminators
69  evt.getByLabel(disc1_, disc1);
71  evt.getByLabel(disc2_, disc2);
72 
73  bool differenceFound = false;
74  // Loop over first collection
75  for (size_t iTau1 = 0; iTau1 < taus1->size(); ++iTau1) {
76  tausExamined_++;
77  reco::PFTauRef tau1(taus1, iTau1);
78  // Find the best match in the other collection
80  double bestDeltaR = -1;
81  for (size_t iTau2 = 0; iTau2 < taus2->size(); ++iTau2) {
82  reco::PFTauRef tau2(taus2, iTau2);
83  reco::PFJetRef jet1 = getJetRef(*tau1);
84  reco::PFJetRef jet2 = getJetRef(*tau2);
85  double deltaRVal = deltaR(jet2->p4(), jet1->p4());
86  if (bestMatch.isNull() || deltaRVal < bestDeltaR) {
87  bestMatch = tau2;
88  bestDeltaR = deltaRVal;
89  }
90  }
91  // See what's up with the discriminators
92  bool result1 = ((*disc1)[tau1] > 0.5);
93  bool result2 = ((*disc2)[bestMatch] > 0.5);
94  allPassed1_ += result1;
95  allPassed2_ += result2;
96  if (result1 ^ result2) {
97  differenceFound = true;
98  passed1_ += result1;
99  passed2_ += result2;
100  differences_++;
101  std::cout << "********* RecoTau difference detected! *************"
102  << std::endl;
103  std::cout << " Tau1 InputTag: " << src1_ << " result: " << result1
104  << std::endl;
105  std::cout << " Tau2 InputTag: " << src2_ << " result: " << result2
106  << std::endl;
107  std::cout << "--------- Tau 1 -------------"
108  << std::endl;
109  std::cout << *tau1 << std::endl;
110  tau1->dump(std::cout);
111  std::cout << "--------- Tau 2 -------------"
112  << std::endl;
113  std::cout << *bestMatch << std::endl;
114  bestMatch->dump(std::cout);
115  }
116  }
117  return (filter_ ? differenceFound : true);
118 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:475
bool isNull() const
Checks for null.
Definition: Ref.h:250
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
def bestMatch(object, matchCollection)
Definition: deltar.py:139

Member Data Documentation

size_t RecoTauDifferenceAnalyzer::allPassed1_
private

Definition at line 27 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

size_t RecoTauDifferenceAnalyzer::allPassed2_
private

Definition at line 28 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

size_t RecoTauDifferenceAnalyzer::differences_
private

Definition at line 24 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

edm::InputTag RecoTauDifferenceAnalyzer::disc1_
private

Definition at line 19 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

edm::InputTag RecoTauDifferenceAnalyzer::disc2_
private

Definition at line 20 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

size_t RecoTauDifferenceAnalyzer::eventsExamined_
private

Definition at line 22 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

bool RecoTauDifferenceAnalyzer::filter_
private

Definition at line 29 of file RecoTauDifferenceAnalyzer.cc.

Referenced by filter(), and RecoTauDifferenceAnalyzer().

double RecoTauDifferenceAnalyzer::maxDeltaR_
private

Definition at line 21 of file RecoTauDifferenceAnalyzer.cc.

size_t RecoTauDifferenceAnalyzer::passed1_
private

Definition at line 25 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

size_t RecoTauDifferenceAnalyzer::passed2_
private

Definition at line 26 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

edm::InputTag RecoTauDifferenceAnalyzer::src1_
private

Definition at line 17 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

edm::InputTag RecoTauDifferenceAnalyzer::src2_
private

Definition at line 18 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().

size_t RecoTauDifferenceAnalyzer::tausExamined_
private

Definition at line 23 of file RecoTauDifferenceAnalyzer.cc.

Referenced by endJob(), filter(), and RecoTauDifferenceAnalyzer().