diff --git a/PhysicsTools/FWLite/interface/WSelectorFast.h b/PhysicsTools/FWLite/interface/WSelectorFast.h deleted file mode 100644 index 9b9f923e7914f..0000000000000 --- a/PhysicsTools/FWLite/interface/WSelectorFast.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef PhysicsTools_FWLite_WSelectorFast_h -#define PhysicsTools_FWLite_WSelectorFast_h -#include "DataFormats/PatCandidates/interface/MET.h" -#include "DataFormats/PatCandidates/interface/Muon.h" -#include "PhysicsTools/SelectorUtils/interface/EventSelector.h" - -/** - \class WSelector WSelector.h "PhysicsTools/FWLite/interface/WSelector.h" - \brief Example class of an EventSelector to apply a simple W Boson selection - - Example class for of an EventSelector as defined in the SelectorUtils package. - EventSelectors may be used to facilitate cutflows and to implement selections - independent from the event loop in FWLite or full framework. -*/ - -class WSelectorFast : public EventSelector { -public: - /// constructor - WSelectorFast(edm::ParameterSet const& params) - : muonSrc_(params.getParameter("muonSrc")), metSrc_(params.getParameter("metSrc")) { - double muonPtMin = params.getParameter("muonPtMin"); - double metMin = params.getParameter("metMin"); - push_back("Muon Pt", muonPtMin); - push_back("MET", metMin); - set("Muon Pt"); - set("MET"); - wMuon_ = 0; - met_ = 0; - if (params.exists("cutsToIgnore")) { - setIgnoredCuts(params.getParameter >("cutsToIgnore")); - } - retInternal_ = getBitTemplate(); - } - /// destructor - virtual ~WSelectorFast() {} - /// return muon candidate of W boson - pat::Muon const& wMuon() const { return *wMuon_; } - /// return MET of W boson - pat::MET const& met() const { return *met_; } - - /// here is where the selection occurs - virtual bool operator()(edm::EventBase const& event, pat::strbitset& ret) { - ret.set(false); - // Handle to the muon collection - edm::Handle > muons; - // Handle to the MET collection - edm::Handle > met; - // get the objects from the event - bool gotMuons = event.getByLabel(muonSrc_, muons); - bool gotMET = event.getByLabel(metSrc_, met); - // get the MET, require to be > minimum - if (gotMET) { - met_ = &met->at(0); - if (met_->pt() > cut(metIndex_, double()) || ignoreCut(metIndex_)) - passCut(ret, metIndex_); - } - // get the highest pt muon, require to have pt > minimum - if (gotMuons) { - if (!ignoreCut(muonPtIndex_)) { - if (muons->size() > 0) { - wMuon_ = &muons->at(0); - if (wMuon_->pt() > cut(muonPtIndex_, double()) || ignoreCut(muonPtIndex_)) - passCut(ret, muonPtIndex_); - } - } else { - passCut(ret, muonPtIndex_); - } - } - setIgnored(ret); - return (bool)ret; - } - -protected: - /// muon input - edm::InputTag muonSrc_; - /// met input - edm::InputTag metSrc_; - /// muon candidate from W boson - pat::Muon const* wMuon_; - /// MET from W boson - pat::MET const* met_; - /// index for muon Pt cut - index_type muonPtIndex_; - /// index for MET cut - index_type metIndex_; -}; -#endif // PhysicsTools_FWLite_WSelectorFast_h diff --git a/PhysicsTools/MVAComputer/interface/MVAModuleHelper.h b/PhysicsTools/MVAComputer/interface/MVAModuleHelper.h deleted file mode 100644 index d0cc993c87ac9..0000000000000 --- a/PhysicsTools/MVAComputer/interface/MVAModuleHelper.h +++ /dev/null @@ -1,160 +0,0 @@ -#ifndef PhysicsTools_MVAComputer_MVAModuleHelper_h -#define PhysicsTools_MVAComputer_MVAModuleHelper_h -// -*- C++ -*- -// -// Package: MVAComputer -// Class : MVAModuleHelper -// - -// -// Author: Christophe Saout -// Created: Sat Apr 24 15:18 CEST 2007 -// - -#include -#include -#include -#include -#include -#include -#include - -#include "FWCore/Framework/interface/EventSetup.h" - -#include "PhysicsTools/MVAComputer/interface/AtomicId.h" -#include "PhysicsTools/MVAComputer/interface/Calibration.h" -#include "PhysicsTools/MVAComputer/interface/MVAComputerCache.h" -#include "CondFormats/PhysicsToolsObjects/interface/MVAComputer.h" - -namespace PhysicsTools { - - /** \class MVAModuleHelperDefaultFiller - * - * \short Default template for MVAModuleHelper "Filler" template argument - * - * Simply calls a "double compute(const AtomicID &name) const" method - * on the object for each variable requested. - * - ************************************************************/ - template - struct MVAModuleHelperDefaultFiller { - MVAModuleHelperDefaultFiller(const PhysicsTools::AtomicId &name) {} - - double operator()(const Object &object, const PhysicsTools::AtomicId &name) { return object.compute(name); } - }; - - /** \class MVAModuleHelper - * - * \short Template for automated variable collection and MVA computation in EDM modules - * - * The class MVAModuleHelper can be embedded in EDM modules. It automatically - * collects the variables listed in the MVA training description using type - * traits and passes them on to the computer. The calibration and or trainer - * is automatically collected from the EventSetup. - * - ************************************************************/ - template > - class MVAModuleHelper { - public: - MVAModuleHelper(const std::string &label) : label(label) {} - MVAModuleHelper(const MVAModuleHelper &orig) : label(orig.label) {} - ~MVAModuleHelper() {} - - void setEventSetup(const edm::EventSetup &setup); - void setEventSetup(const edm::EventSetup &setup, const char *esLabel); - - double operator()(const Object &object) const; - - void train(const Object &object, bool target, double weight = 1.0) const; - - private: - void init(const PhysicsTools::Calibration::MVAComputerContainer *container); - - const std::string label; - PhysicsTools::MVAComputerCache cache; - - class Value { - public: - Value(const std::string &name) : name(name), filler(name) {} - Value(const std::string &name, double value) : name(name), filler(name), value(value) {} - - inline bool update(const Object &object) const { - value = filler(object, name); - return !std::isfinite(value); - } - - PhysicsTools::AtomicId getName() const { return name; } - double getValue() const { return value; } - - private: - PhysicsTools::AtomicId name; - Filler filler; - - mutable double value; - }; - - std::vector values; - }; - - template - void MVAModuleHelper::setEventSetup(const edm::EventSetup &setup) { - edm::ESHandle handle; - setup.get().get(handle); - const PhysicsTools::Calibration::MVAComputerContainer *container = handle.product(); - if (cache.update(container, label.c_str()) && cache) - init(container); - } - - template - void MVAModuleHelper::setEventSetup(const edm::EventSetup &setup, const char *esLabel) { - edm::ESHandle handle; - setup.get().get(esLabel, handle); - const PhysicsTools::Calibration::MVAComputerContainer *container = handle.product(); - if (cache.update(container, label.c_str()) && cache) - init(container); - } - - template - void MVAModuleHelper::init(const PhysicsTools::Calibration::MVAComputerContainer *container) { - const std::vector &vars = container->find(label).inputSet; - values.clear(); - for (std::vector::const_iterator iter = vars.begin(); iter != vars.end(); - ++iter) - if (std::strncmp(iter->name.c_str(), "__", 2) != 0) - values.push_back(Value(iter->name)); - } - - template - double MVAModuleHelper::operator()(const Object &object) const { - std::for_each(values.begin(), values.end(), std::bind(&Value::update, std::placeholders::_1, object)); - return cache->eval(values); - } - - template - void MVAModuleHelper::train(const Object &object, bool target, double weight) const { - static const PhysicsTools::AtomicId kTargetId("__TARGET__"); - static const PhysicsTools::AtomicId kWeightId("__WEIGHT__"); - - if (!cache) - return; - - if (std::accumulate( - values.begin(), - values.end(), - 0, - std::bind( - std::plus(), std::placeholders::_1, std::bind(&Value::update, std::placeholders::_2, object)))) - return; - - PhysicsTools::Variable::ValueList list; - list.add(kTargetId, target); - list.add(kWeightId, weight); - for (typename std::vector::const_iterator iter = values.begin(); iter != values.end(); ++iter) - list.add(iter->getName(), iter->getValue()); - - cache->eval(list); - } - -} // namespace PhysicsTools - -#endif // PhysicsTools_MVAComputer_MVAModuleHelper_h diff --git a/PhysicsTools/PatExamples/interface/WPlusJetsEventSelector.h b/PhysicsTools/PatExamples/interface/WPlusJetsEventSelector.h deleted file mode 100644 index 0de02de5f5412..0000000000000 --- a/PhysicsTools/PatExamples/interface/WPlusJetsEventSelector.h +++ /dev/null @@ -1,2 +0,0 @@ -#warning "This has moved to PhysicsTools/SelectorUtils" -#include "PhysicsTools/SelectorUtils/interface/WPlusJetsEventSelector.h" diff --git a/PhysicsTools/PatUtils/interface/JetSelector.h b/PhysicsTools/PatUtils/interface/JetSelector.h deleted file mode 100644 index a3c17dd98a88a..0000000000000 --- a/PhysicsTools/PatUtils/interface/JetSelector.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef PhysicsTools_PatUtils_JetSelector_h -#define PhysicsTools_PatUtils_JetSelector_h - -/** - \class pat::JetSelector JetSelector.h "PhysicsTools/PatUtils/JetSelector.h" - \brief Selects good Jets - - The Jet selector returns a flag (see pat::ParticleStatus) based on one of the possible - selections: either cut-based or custom (user-defined set of cuts). - This is driven by the configuration parameters (see the PATJetCleaner - documentation for configuration details). - - The parameters are passed to the selector through a JetSelection struct. - (An adapter exists for use in CMSSW: - reco::modules::ParameterAdapter>.) - - \author C. Autermann (Uni Hamburg) - \version $Id: JetSelector.h,v 1.4 2008/03/05 14:51:02 fronga Exp $ -**/ - -#include -#include "DataFormats/JetReco/interface/Jet.h" -#include "DataFormats/JetReco/interface/CaloJet.h" -#include "DataFormats/JetReco/interface/PFJet.h" -#include "PhysicsTools/PatUtils/interface/JetSelection.h" -#include "PhysicsTools/PatUtils/interface/CaloJetSelector.h" -#include "DataFormats/Common/interface/ValueMap.h" - -#include "PhysicsTools/PatUtils/interface/ParticleCode.h" - - -namespace pat { - - typedef edm::ValueMap JetValueMap; - - template - class JetSelector { - - - public: - JetSelector( const JetSelection& config ); - ~JetSelector() {} - - /// Returns 0 if Jet matches criteria, a flag otherwise. - /// Criteria depend on the selector's configuration. - /// Jet IDs only need to be provided if selection is based - /// on it (cut, neural net or likelihood). Cluster shapes are for - /// custom selection only. - const ParticleStatus - filter( const unsigned int& index, - const edm::View& Jets, - const JetValueMap* JetMap - ) const; - - - private: - - JetSelection config_; - - std::unique_ptr CaloJetSelector_;///Selects CaloJets - //std::unique_ptr PFSelector_;///Selects PFJets - - }; // class - -} // namespace - -#endif diff --git a/PhysicsTools/PatUtils/interface/JetSelector.icc b/PhysicsTools/PatUtils/interface/JetSelector.icc deleted file mode 100644 index a462b047b54b4..0000000000000 --- a/PhysicsTools/PatUtils/interface/JetSelector.icc +++ /dev/null @@ -1,63 +0,0 @@ - -#include "PhysicsTools/PatUtils/interface/JetSelector.h" -#include "DataFormats/Common/interface/RefToBase.h" - - -//______________________________________________________________________________ -template -pat::JetSelector::JetSelector( const pat::JetSelection& config ) : - config_( config ) -{ - - if (config_.selectionType=="custom") { - CaloJetSelector_ = std::make_unique(config); - //PFJetSelector_ = std::make_unique(config); - } - -} - - -//______________________________________________________________________________ -template -const pat::ParticleStatus -pat::JetSelector::filter( const unsigned int& index, - const edm::View& Jets, - const JetValueMap * JetMap - ) const -{ - - ParticleStatus result = BAD; - - if (config_.selectionType=="none") { - - result = GOOD; - } - else if (config_.selectionType=="JetID" && JetMap!=0) { - const double jetIDresult = (*JetMap)[ Jets.refAt(index) ]; - if ( jetIDresult > config_.value ) result = GOOD; - else result = BAD; - } - else if ( config_.selectionType == "custom" ) { - - const JetType& Jet = Jets[index]; - const reco::CaloJet * caloJet = 0; - const reco::PFJet * pfJet = 0; - caloJet = dynamic_cast(&Jet); - ///specific selection for CaloJets - if (caloJet) result = CaloJetSelector_->filter( *caloJet ); - else { - ///specific selection for PFJets - pfJet = dynamic_cast( &Jet); - //FIXME: not implemented yet! - //if (pfJet) result = PFJetSelector_->filter( *pfJet); - } - - } else - // Throw! unknown configuration - throw edm::Exception(edm::errors::Configuration) - << "Unknown Jet ID selection " << config_.selectionType; - - - return result; -} - diff --git a/PhysicsTools/PatUtils/interface/PatSelectorByFlags.h b/PhysicsTools/PatUtils/interface/PatSelectorByFlags.h deleted file mode 100644 index fcd5d01e519f7..0000000000000 --- a/PhysicsTools/PatUtils/interface/PatSelectorByFlags.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef PhysicsTools_PatUtils_interface_PatSelectorByFlags_h -#define PhysicsTools_PatUtils_interface_PatSelectorByFlags_h - -#include "DataFormats/PatCandidates/interface/Flags.h" - -namespace pat { - class SelectorByFlags { - public: - SelectorByFlags() : mask_(0) { } - SelectorByFlags(uint32_t maskToTest) : mask_(~maskToTest) {} - SelectorByFlags(const std::string &bitToTest) ; - SelectorByFlags(const std::vector bitsToTest) ; - bool operator()(const reco::Candidate &c) const { return pat::Flags::test(c, mask_); } - bool operator()(const reco::Candidate *c) const { return (c == 0 ? false : pat::Flags::test(*c, mask_)); } - private: - uint32_t mask_; - }; -} -#endif diff --git a/PhysicsTools/PatUtils/interface/RefHelper.h b/PhysicsTools/PatUtils/interface/RefHelper.h deleted file mode 100644 index 4756266e9ba40..0000000000000 --- a/PhysicsTools/PatUtils/interface/RefHelper.h +++ /dev/null @@ -1,130 +0,0 @@ -#ifndef PhysicsTools_PatUtils_RefHelper_h -#define PhysicsTools_PatUtils_RefHelper_h - -#include "DataFormats/Common/interface/Ptr.h" -#include "DataFormats/Common/interface/ValueMap.h" -namespace pat { namespace helper { -/*** \brief A class to help manage references and associative containers in some tricky cases (e.g. selection by copy) -*/ -template -class RefHelper { - public: - typedef typename edm::Ptr Ref; - - /// Constructor taking a ValueMap of back-references daughter => mother. - RefHelper(const edm::ValueMap< Ref > &backRefMap) : backRefMap_(backRefMap) { } - - /// Returns a Ref to the direct parent of "ref", or a null Ref if "ref" is already root - Ref parentOrNull(const Ref &ref) const ; - - /// Returns a Ref to the direct parent of "ref", or "ref" itself if it's already root - Ref parentOrSelf(const Ref &ref) const ; - - /// Climbs back the Ref chain and returns the root of the branch starting from "ref" - Ref ancestorOrSelf(const Ref &ref) const ; - - bool isRoot(const Ref &ref) const ; - - /// true if old is some ancestor of young (it does not have to be the root) - bool isAncestorOf(const Ref &old, const Ref &young) const ; - - /// true if the two share the same root - bool sharedAncestor(const Ref &ref1, const Ref &ref2) const ; - - /// Recursively looks up map to find something associated to ref, or one of its parents. - /// Throws edm::Exception(edm::errors::InvalidReference) if there's no match - template - V recursiveLookup(const SomeRef &ref, const edm::ValueMap &map) const ; - - /// Looks up map to find something associated to the root ancestor of "ref" - /// Throws edm::Exception(edm::errors::InvalidReference) if there's no match - template - V ancestorLookup(const SomeRef &ref, const edm::ValueMap &map) const ; - - private: - const edm::ValueMap< Ref > & backRefMap_; -}; - -template -typename RefHelper::Ref RefHelper::parentOrNull(const RefHelper::Ref &ref) const { - if (backRefMap_.contains(ref.id())) { - try { - return backRefMap_[ref]; - } catch (edm::Exception &e) { - if (e.categoryCode() == edm::errors::InvalidReference) { - return Ref(); - } else { - throw; - } - } - } else { - return Ref(); - } -} - -template -typename RefHelper::Ref RefHelper::parentOrSelf(const RefHelper::Ref &ref) const { - Ref ret = parentOrNull(ref); - return ret.isNonnull() ? ret : ref; -} - -template -typename RefHelper::Ref RefHelper::ancestorOrSelf(const RefHelper::Ref &ref) const { - Ref ret = ref; - do { - Ref test = parentOrNull(ret); - if (test.isNull()) return ret; - ret = test; - } while (true); -} - - -template -bool RefHelper::isRoot(const RefHelper::Ref &ref) const { - return parentOrNull(ref).isNull(); -} - -template -bool RefHelper::isAncestorOf(const RefHelper::Ref &old, const RefHelper::Ref &young) const { - Ref test = young; - do { - if (test == old) return true; - test = parentOrNull(test); - } while (test.isNonnull()); - return false; -} - -template -bool RefHelper::sharedAncestor(const RefHelper::Ref &ref1, const RefHelper::Ref &ref2) const { - return ( ancestorOrSelf(ref1) == ancestorOrSelf(ref2) ); -} - -template -template -V RefHelper::recursiveLookup(const SomeRef &ref, const edm::ValueMap &map) const { - Ref test(ref); - do { - if (map.contains(test.id())) { - try { - return map[test]; - } catch (edm::Exception &e) { - if (e.categoryCode() != edm::errors::InvalidReference) { - throw; - } - } - } - test = parentOrNull(test); - } while (test.isNonnull()); - throw edm::Exception(edm::errors::InvalidReference) << - "RefHelper: recursive Lookup failed: neither the specified ref nor any of its parents are in the map.\n"; -} - -template -template -V RefHelper::ancestorLookup(const SomeRef &ref, const edm::ValueMap &map) const { - Ref tref(ref); - return map[ancestorOrSelf(tref)]; -} - -} } // namespace -#endif diff --git a/PhysicsTools/SelectorUtils/interface/Variables.h b/PhysicsTools/SelectorUtils/interface/Variables.h deleted file mode 100644 index b911a79e316b0..0000000000000 --- a/PhysicsTools/SelectorUtils/interface/Variables.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef SelectorUtils_Variables_h -#define SelectorUtils_Variables_h - -// short cut classes for reco::Candidate methods -// Benedikt Hegner, DESY - -#include "DataFormats/Candidate/interface/Candidate.h" - -class vEnergy { -public: - typedef reco::Candidate ValType; - vEnergy() {} - double operator()( const ValType& x ) const { return x.energy(); } -}; - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/DummyMatchSelector.h b/PhysicsTools/UtilAlgos/interface/DummyMatchSelector.h deleted file mode 100644 index 8d0d99aab14d8..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/DummyMatchSelector.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef DummyMatchSelector_h -#define DummyMatchSelector_h - -/** - Dummy class for preselection of object matches. -*/ - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -namespace reco { - - template - class DummyMatchSelector { - - public: - - DummyMatchSelector(const edm::ParameterSet& cfg) { } - - bool operator()( const T1 & c, const T2 & hlt ) const { return true; } - - }; - -} - - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/EventSelector.h b/PhysicsTools/UtilAlgos/interface/EventSelector.h deleted file mode 100644 index 60176c8025f34..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/EventSelector.h +++ /dev/null @@ -1 +0,0 @@ -#include "CommonTools/UtilAlgos/interface/EventSelector.h" diff --git a/PhysicsTools/UtilAlgos/interface/MCMatchSelector.h b/PhysicsTools/UtilAlgos/interface/MCMatchSelector.h deleted file mode 100644 index a54aecc246ba8..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/MCMatchSelector.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef MCMatchSelector_h -#define MCMatchSelector_h -/* \class MCMatchSelector - * - * Extended version of MCTruthPairSelector. Preselects matches - * based on charge, pdgId and status. - */ - -#include -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -namespace reco { - template - class MCMatchSelector { - public: - MCMatchSelector(const edm::ParameterSet& cfg) : - checkCharge_(cfg.getParameter("checkCharge")) { - std::vector ids = - cfg.getParameter< std::vector >("mcPdgId"); - for ( std::vector::const_iterator i=ids.begin(); - i!=ids.end(); ++i ) ids_.insert(*i); - std::vector status = - cfg.getParameter< std::vector >("mcStatus"); - for ( std::vector::const_iterator i=status.begin(); - i!=status.end(); ++i ) status_.insert(*i); - } - /// true if match is possible - bool operator()( const T1 & c, const T2 & mc ) const { - if ( checkCharge_ && c.charge() != mc.charge() ) return false; - if ( !ids_.empty() ) { - if ( ids_.find(abs(mc.pdgId()))==ids_.end() ) return false; - } - if ( status_.empty() ) return true; - return status_.find(mc.status())!=status_.end(); - } - private: - bool checkCharge_; - std::set ids_; - std::set status_; - }; -} - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/NtpProducer.h b/PhysicsTools/UtilAlgos/interface/NtpProducer.h deleted file mode 100755 index 5f0fab84a092f..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/NtpProducer.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef UtilAlgos_NtpProducer_h -#define UtilAlgos_NtpProducer_h -/** \class NtpProducer - * - * Creates histograms defined in config file - * - * \author: Luca Lista, INFN - * - * Template parameters: - * - C : Concrete candidate collection type - * - */ -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Utilities/interface/InputTag.h" -#include "CommonTools/Utils/interface/StringObjectFunction.h" - -template -class NtpProducer : public edm::EDProducer { -public: - /// constructor from parameter set - NtpProducer( const edm::ParameterSet& ); - /// destructor - ~NtpProducer(); - -protected: - /// process an event - virtual void produce( edm::Event&, const edm::EventSetup& ); - -private: - /// label of the collection to be read in - edm::EDGetTokenT srcToken_; - /// variable tags - std::vector > > tags_; -}; - -template -NtpProducer::NtpProducer( const edm::ParameterSet& par ) : - srcToken_( consumes(par.template getParameter( "src" ) ) ) { - std::vector variables = - par.template getParameter >("variables"); - std::vector::const_iterator - q = variables.begin(), end = variables.end(); - for (; q!=end; ++q) { - std::string tag = q->getUntrackedParameter("tag"); - StringObjectFunction quantity(q->getUntrackedParameter("quantity")); - tags_.push_back(std::make_pair(tag, quantity)); - produces >(tag).setBranchAlias(tag); - } -} - -template -NtpProducer::~NtpProducer() { -} - -template -void NtpProducer::produce( edm::Event& iEvent, const edm::EventSetup& ) { - edm::Handle coll; - iEvent.getByToken(srcToken_, coll); - - typename std::vector > >::const_iterator - q = tags_.begin(), end = tags_.end(); - for(;q!=end; ++q) { - auto x = std::make_unique>(); - x->reserve(coll->size()); - for (typename C::const_iterator elem=coll->begin(); elem!=coll->end(); ++elem ) { - x->push_back(q->second(*elem)); - } - iEvent.put(std::move(x), q->first); - } -} - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/SelectedOutputCollectionTrait.h b/PhysicsTools/UtilAlgos/interface/SelectedOutputCollectionTrait.h deleted file mode 100755 index 229e4b88144d1..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/SelectedOutputCollectionTrait.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef UtilAlgos_SelectedOutputCollectionTrait_h -#define UtilAlgos_SelectedOutputCollectionTrait_h -/* \class helper SelectedOutputCollection - * - * \author Luca Lista, INFN - * - */ -#include "DataFormats/Common/interface/AssociationVector.h" -#include "DataFormats/Common/interface/RefToBase.h" -#include "DataFormats/Common/interface/RefToBaseVector.h" -#include "DataFormats/Common/interface/RefToBaseProd.h" -#include "DataFormats/Common/interface/RefVector.h" -#include "DataFormats/Common/interface/View.h" - -namespace helper { - - template - struct SelectedOutputCollectionTrait { - typedef InputCollection type; - }; - - template - struct SelectedOutputCollectionTrait, C> > { - typedef typename edm::RefProd::product_type type; - }; - - template - struct SelectedOutputCollectionTrait, C> > { - typedef typename edm::RefToBaseVector type; - }; - - template - struct SelectedOutputCollectionTrait > { - typedef typename edm::RefToBaseVector type; - }; - - template - struct SelectedOutputCollectionTrait > { - typedef typename edm::RefToBaseVector type; - }; - - template - struct SelectedOutputCollectionTrait > { - typedef typename edm::RefVector type; - }; - -} - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/SelectionAdderTrait.h b/PhysicsTools/UtilAlgos/interface/SelectionAdderTrait.h deleted file mode 100755 index d830b07f6bc8c..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/SelectionAdderTrait.h +++ /dev/null @@ -1,147 +0,0 @@ -#ifndef UtilAlgos_SelectionAdderTrait_h -#define UtilAlgos_SelectionAdderTrait_h -/* \class SelectionAdderTrait - * - * \author Luca Lista, INFN - */ -#include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/Common/interface/RefVector.h" -#include "DataFormats/Common/interface/PtrVector.h" -#include "DataFormats/Common/interface/RefToBaseVector.h" -#include "DataFormats/Common/interface/RefToBaseProd.h" -#include "DataFormats/Common/interface/RefProd.h" -#include "DataFormats/Common/interface/AssociationVector.h" - -namespace helper { - - template - struct SelectionCopyAdder { - template - void operator()( StoreContainer & selected, const edm::Handle & c, size_t idx ) { - selected.push_back( ( * c )[ idx ] ); - } - }; - - template - struct SelectionPointerAdder { - template - void operator()( StoreContainer & selected, const edm::Handle & c, size_t idx ) { - selected.push_back( & ( * c )[ idx ] ); - } - }; - - template - struct SelectionPointerDerefAdder { - template - void operator()( StoreContainer & selected, const edm::Handle & c, size_t idx ) { - selected.push_back( & * ( * c )[ idx ] ); - } - }; - - template - struct SelectionFirstPointerAdder { - template - void operator()( StoreContainer & selected, const edm::Handle & c, size_t idx ) { - selected.push_back( & * ( ( * c )[ idx ].first ) ); - } - }; - - template - struct SelectionFirstRefAdder { - template - void operator()( StoreContainer & selected, const edm::Handle & c, size_t idx ) { - selected.push_back( ( * c )[ idx ].first ); - } - }; - - template - struct SelectionRefAdder { - template - void operator()( StoreContainer & selected, const edm::Handle & c, size_t idx ) { - selected.push_back( edm::Ref( c, idx ) ); - } - }; - - template - struct SelectionRefViewAdder { - void operator()( edm::RefToBaseVector & selected, const edm::Handle > & c, size_t idx ) { - selected.push_back( c->refAt( idx ) ); - } - }; - - template - struct SelectionPtrViewAdder { - void operator()( edm::PtrVector & selected, const edm::Handle > & c, size_t idx ) { - selected.push_back( c->ptrAt( idx ) ); - } - }; - - template - struct SelectionAdderTrait { - static_assert(sizeof(InputCollection) == 0); - }; - - template - struct SelectionAdderTrait > { - typedef SelectionPointerAdder > type; - }; - - template - struct SelectionAdderTrait > { - typedef SelectionRefAdder > type; - }; - - template - struct SelectionAdderTrait, edm::RefVector > { - typedef SelectionCopyAdder > type; - }; - - template - struct SelectionAdderTrait, std::vector > { - typedef SelectionPointerDerefAdder > type; - }; - - template - struct SelectionAdderTrait, edm::RefToBaseVector > { - typedef SelectionCopyAdder > type; - }; - - template - struct SelectionAdderTrait, std::vector > { - typedef SelectionPointerDerefAdder > type; - }; - - template - struct SelectionAdderTrait, C>, std::vector > { - typedef SelectionFirstPointerAdder > type; - }; - - template - struct SelectionAdderTrait, C>, std::vector > { - typedef SelectionFirstPointerAdder > type; - }; - - template - struct SelectionAdderTrait, C>, edm::RefVector > { - typedef SelectionFirstRefAdder > type; - }; - - template - struct SelectionAdderTrait, C>, - edm::RefToBaseVector > { - typedef SelectionFirstRefAdder > type; - }; - - template - struct SelectionAdderTrait, edm::RefToBaseVector > { - typedef SelectionRefViewAdder type; - }; - - template - struct SelectionAdderTrait, edm::PtrVector > { - typedef SelectionPtrViewAdder type; - }; - -} - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/StoreContainerTrait.h b/PhysicsTools/UtilAlgos/interface/StoreContainerTrait.h deleted file mode 100755 index f563c548df5e4..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/StoreContainerTrait.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef UtilAlgos_StoreContainerTrait_h -#define UtilAlgos_StoreContainerTrait_h -/* \class helper::StoreContainerTrait - * - * \author Luca Lista, INFN - */ -#include "DataFormats/Common/interface/RefVector.h" -#include "DataFormats/Common/interface/RefToBaseVector.h" -#include "DataFormats/Common/interface/PtrVector.h" -#include "DataFormats/Common/interface/AssociationVector.h" - -namespace helper { - template - struct StoreContainerTrait { - typedef std::vector type; - }; - - template - struct StoreContainerTrait > { - typedef edm::RefVector type; - }; - - template - struct StoreContainerTrait > { - typedef edm::RefToBaseVector type; - }; - - template - struct StoreContainerTrait > { - typedef edm::PtrVector type; - }; - - template - struct StoreContainerTrait > { - typedef typename StoreContainerTrait::type type; - }; -} - -#endif diff --git a/PhysicsTools/UtilAlgos/interface/TwoObjectCalculator.h b/PhysicsTools/UtilAlgos/interface/TwoObjectCalculator.h deleted file mode 100644 index cc3bc3b8b048e..0000000000000 --- a/PhysicsTools/UtilAlgos/interface/TwoObjectCalculator.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef CommonTools_UtilAlgos_TwoObjectCalculator_H -#define CommonTools_UtilAlgos_TwoObjectCalculator_H - -#include -#include - -struct CosDphiCalculator { - template double operator()( const LHS & lhs, const RHS & rhs){ - double cdphi = cos(lhs.phi()-rhs.phi()); - return cdphi; - } - static std::string calculationType(){ return "CosDphiCalculator";} - static std::string description() { return " calculate cos(Delta Phi(Obj1, Obj2))";} -}; - -#endif diff --git a/PhysicsTools/Utilities/interface/GammaPropagator.h b/PhysicsTools/Utilities/interface/GammaPropagator.h deleted file mode 100644 index d9c31e730722c..0000000000000 --- a/PhysicsTools/Utilities/interface/GammaPropagator.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef PhysicsTools_Utilities_GammaPropagator_h -#define PhysicsTools_Utilities_GammaPropagator_h - -namespace funct { - - struct GammaPropagator { - GammaPropagator() {} - double operator()(double mass) const { - if(mass <= 0) return 0; - return 1./(mass*mass); - } - }; - -} - -#endif diff --git a/PhysicsTools/Utilities/interface/GammaZInterference.h b/PhysicsTools/Utilities/interface/GammaZInterference.h deleted file mode 100644 index e6a09214baac3..0000000000000 --- a/PhysicsTools/Utilities/interface/GammaZInterference.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef PhysicsTools_Utilities_GammaZInterference_h -#define PhysicsTools_Utilities_GammaZInterference_h -#include "PhysicsTools/Utilities/interface/Parameter.h" - -#include - -namespace funct { - - struct GammaZInterference { - GammaZInterference(const Parameter& m, const Parameter& g) : mass(m.ptr()), width(g.ptr()) {} - GammaZInterference(std::shared_ptr m, std::shared_ptr g) : mass(m), width(g) {} - double operator()(double x) const { - double m2 = *mass * (*mass); - double g2 = *width * (*width); - double g2OverM2 = g2 / m2; - double s = x * x; - double deltaS = s - m2; - double interference = 0; - if (fabs(deltaS / m2) < 16) { - double prop = deltaS * deltaS + s * s * g2OverM2; - interference = 5 * (*mass) * deltaS / prop; - } - return interference; - } - std::shared_ptr mass, width; - }; - -} // namespace funct - -#endif diff --git a/PhysicsTools/Utilities/interface/Number.h b/PhysicsTools/Utilities/interface/Number.h deleted file mode 100644 index 017216302d631..0000000000000 --- a/PhysicsTools/Utilities/interface/Number.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef PhysicsTools_Utilities_Number_h -#define PhysicsTools_Utilities_Number_h - -namespace funct { - - struct Number { - Number(double value) : value_(value) { } - double operator()(double x) const { return value_; } - private: - double value_; - }; - -} - -#endif diff --git a/PhysicsTools/Utilities/interface/ZLineShape.h b/PhysicsTools/Utilities/interface/ZLineShape.h deleted file mode 100644 index faa936648c335..0000000000000 --- a/PhysicsTools/Utilities/interface/ZLineShape.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PhysicsTools_Utilities_ZLineShape_h -#define PhysicsTools_Utilities_ZLineShape_h -#include "PhysicsTools/Utilities/interface/BreitWigner.h" -#include "PhysicsTools/Utilities/interface/GammaPropagator.h" -#include "PhysicsTools/Utilities/interface/GammaZInterference.h" -#include "PhysicsTools/Utilities/interface/Parameter.h" - -namespace funct { - class ZLineShape { - public: - ZLineShape(const Parameter& m, const Parameter& g, const Parameter& Ng, const Parameter& Ni) - : Ngamma(Ng.ptr()), Nint(Ni.ptr()), bw_(m, g), gp_(), gzi_(m, g) {} - ZLineShape(std::shared_ptr m, - std::shared_ptr g, - std::shared_ptr Ng, - std::shared_ptr Ni) - : Ngamma(Ng), Nint(Ni), bw_(m, g), gp_(), gzi_(m, g) {} - double operator()(double x) const { return (1.0 - *Nint - *Ngamma) * bw_(x) + *Ngamma * gp_(x) + *Nint * gzi_(x); } - std::shared_ptr Ngamma, Nint; - - private: - BreitWigner bw_; - GammaPropagator gp_; - GammaZInterference gzi_; - }; - -} // namespace funct - -#endif diff --git a/TopQuarkAnalysis/TopTools/interface/TopologyWorker.h b/TopQuarkAnalysis/TopTools/interface/TopologyWorker.h deleted file mode 100644 index 101c5bbd43b46..0000000000000 --- a/TopQuarkAnalysis/TopTools/interface/TopologyWorker.h +++ /dev/null @@ -1,1718 +0,0 @@ -// -*- C++ -*- -// -// Package: TopTools -// Class: TopologyWorker -// -/**\class TopologyWorker TopologyWorker.cc TopQuarkAnalysis/TopTools/interface/TopologyWorker.h - - Description: - - Implementation: - - This class contains the topological methods as used in D0 (all hadronic) analyses. -*/ -#ifndef __TOPTOOLSTOPOLOGYWORKER__ -#define __TOPTOOLSTOPOLOGYWORKER__ - -#warning The TopologyWorker class is currently not supported anymore! There might be issues in its implementation. -#warning If you are still using it or planned to do so, please contact the admins of the corresponding CMSSW package. -#warning You can find their e-mail adresses in: cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/TopQuarkAnalysis/TopTools/.admin/ - -#include "TF1.h" -#include "TMath.h" -#include "TClass.h" -#include "TString.h" -#include "TRandom.h" -#include "TMatrixD.h" -#include "TLorentzVector.h" - -#include -#include - -class TopologyWorker -{ -public: - TopologyWorker(){;} - TopologyWorker(bool boost); - virtual ~TopologyWorker(){;} - - void clear(void){m_np=0;m_np2=0;return;} - - void setPartList(TObjArray* e1, TObjArray* e2); - void setVerbose(bool loud){m_verbose=loud; return;} - - void setThMomPower(double tp); - double getThMomPower(); - void setFast(int nf); - int getFast(); - - TVector3 thrustAxis(); - TVector3 majorAxis(); - TVector3 minorAxis(); - - TVector3 thrust(); - // thrust :: Corresponding thrust, major, and minor value. - - double oblateness(); - double get_sphericity(); - double get_aplanarity(); - double get_h10(); - double get_h20(); - double get_h30(); - double get_h40(); - double get_h50(); - double get_h60(); - - - void planes_sphe(double& pnorm,double& p2, double& p3); - void planes_sphe_wei(double& pnorm,double& p2, double& p3); - void planes_thrust(double& pnorm,double& p2, double& p3); - void sumangles(float& sdeta, float& sdr); - - double get_ht() {return m_ht;} - double get_ht3() {return m_ht3;} - double get_et0() {return m_et0;} - double get_sqrts() {return m_sqrts;} - double get_njetW() {return m_njetsweighed;} - double get_et56() {return m_et56;} - double get_centrality() { return m_centrality;} - -private: - bool m_verbose; - void getetaphi(double px, double py, double pz, double& eta, double& phi); - double ulAngle(double x, double y); - double sign(double a, double b); - void ludbrb(TMatrix *mom, - double the, - double phi, - double bx, - double by, - double bz); - - int iPow(int man, int exp); - - double m_dSphMomPower; - // PARU(41): Power of momentum dependence in sphericity finder. - - double m_dDeltaThPower; - // PARU(42): Power of momentum dependence in thrust finder. - - int m_iFast; - // MSTU(44): # of initial fastest particles choosen to start search. - - double m_dConv; - // PARU(48): Convergence criteria for axis maximization. - - int m_iGood; - // MSTU(45): # different starting configurations that must - // converge before axis is accepted as correct. - - TMatrix m_dAxes; - // data: results - // m_dAxes[1] is the Thrust axis. - // m_dAxes[2] is the Major axis. - // m_dAxes[3] is the Minor axis. - - TVector3 m_ThrustAxis; - TVector3 m_MajorAxis; - TVector3 m_MinorAxis; - TVector3 m_Thrust; - - TRandom m_random; - - TMatrix m_mom; - TMatrix m_mom2; - - double m_dThrust[4]; - double m_dOblateness; - int m_np; - int m_np2; - bool m_sanda_called; - bool m_fowo_called; - bool m_boost; - bool m_sumangles_called; - double m_sph; - double m_apl; - double m_h10; - double m_h20; - double m_h30; - double m_h40; - double m_h50; - double m_h60; - double m_ht; - double m_ht3; - double m_et0; - double m_sqrts; - double m_njetsweighed; - double m_et56; - double m_centrality; - - void sanda(); - void fowo(); - static int m_maxpart; - - void CalcWmul(); - void CalcSqrts(); - void CalcHTstuff(); - double CalcPt(int i) { return sqrt(pow(m_mom(i,1),2)+pow(m_mom(i,2),2));} - double CalcPt2(int i) { return sqrt(pow(m_mom2(i,1),2)+pow(m_mom2(i,2),2));} - double CalcEta(int i) {double eta, phi;getetaphi(m_mom(i,1),m_mom(i,2),m_mom(i,3),eta,phi); return eta;} - double CalcEta2(int i) {double eta, phi; getetaphi(m_mom2(i,1),m_mom2(i,2),m_mom2(i,3),eta,phi); return eta;} - -}; - -class LessThan { - public : - // retrieve tru info MC stuff - bool operator () (const TLorentzVector & tl1, const TLorentzVector & - tl2) - const { - return tl2.Pt() < tl1.Pt(); - } -}; - -Int_t TopologyWorker::m_maxpart = 1000; - -TopologyWorker::TopologyWorker(bool boost): - m_dSphMomPower(2.0),m_dDeltaThPower(0), - m_iFast(4),m_dConv(0.0001),m_iGood(2) -{ - m_dAxes.ResizeTo(4,4); - m_mom.ResizeTo(m_maxpart,6); - m_mom2.ResizeTo(m_maxpart,6); - m_np=-1; - m_np2=-1; - m_sanda_called=false; - m_fowo_called=false; - m_sumangles_called=false; - m_verbose=false; - m_boost=boost; - m_sph=-1; - m_apl=-1; - m_h10=-1; - m_h20=-1; - m_h30=-1; - m_h40=-1; - m_sqrts=0; - m_ht=0; - m_ht3=0; - m_et56=0; - m_njetsweighed=0; - m_et0=0; -} -//______________________________________________________________ - - -// Input the particle 3(4)-vector list -// e: 3-vector TVector3 ..(px,py,pz) or -// 4-vector TLorentzVector ..(px,py,pz,E) -// Even input the TLorentzVector, we don't use Energy -// -void TopologyWorker::setPartList(TObjArray* e1, TObjArray* e2) -{ - //To make this look like normal physics notation the - //zeroth element of each array, mom[i][0], will be ignored - //and operations will be on elements 1,2,3... - TMatrix mom(m_maxpart,6); - TMatrix mom2(m_maxpart,6); - double tmax = 0; - double phi = 0.; - double the = 0.; - double sgn; - TMatrix fast(m_iFast + 1,6); - TMatrix work(11,6); - double tdi[4] = {0.,0.,0.,0.}; - double tds; - double tpr[4] = {0.,0.,0.,0.}; - double thp; - double thps; - double pxtot=0; - double pytot=0; - double pztot=0; - double etot=0; - - TMatrix temp(3,5); - Int_t np = 0; - Int_t numElements = e1->GetEntries(); - Int_t numElements2 = e2->GetEntries(); - - // trying to sort... - - - - m_np=0; - for(Int_t elem=0;elemAt(elem); - if(m_verbose){ - std::cerr << "TopologyWorker:SetPartList(): adding jet " << elem << "." << std::endl; - } - if (np >= m_maxpart) { - printf("Too many particles input to TopologyWorker"); - return; - } - if(m_verbose){ - std::cout << "getting name of object..." << std::endl; - } - TString nam(o->IsA()->GetName()); - if(m_verbose){ - std::cout << "TopologyWorker::setPartList(): object is of type " << nam << std::endl; - } - if (nam.Contains("TVector3")) { - TVector3 v(((TVector3 *) o)->X(), - ((TVector3 *) o)->Y(), - ((TVector3 *) o)->Z()); - mom(np,1) = v.X(); - mom(np,2) = v.Y(); - mom(np,3) = v.Z(); - mom(np,4) = v.Mag(); - } - else if (nam.Contains("TLorentzVector")) { - TVector3 v(((TLorentzVector *) o)->X(), - ((TLorentzVector *) o)->Y(), - ((TLorentzVector *) o)->Z()); - mom(np,1) = v.X(); - mom(np,2) = v.Y(); - mom(np,3) = v.Z(); - mom(np,4) = ((TLorentzVector *) o)->T(); - } - else { - printf("TopologyWorker::setEvent input is not a TVector3 or a TLorentzVector\n"); - continue; - } - - - if ( TMath::Abs( m_dDeltaThPower ) <= 0.001 ) { - mom(np,5) = 1.0; - } - else { - mom(np,5) = TMath::Power(mom(np,4),m_dDeltaThPower); - } - tmax = tmax + mom(np,4)*mom(np,5); - pxtot+=mom(np,1); - pytot+=mom(np,2); - pztot+=mom(np,3); - etot+=mom(np,4); - np++; - m_np=np; - } - Int_t np2=0; - // second jet array.... only use some values here. - for(Int_t elem=0;elemAt(elem); - if (np2 >= m_maxpart) { - printf("Too many particles input to TopologyWorker"); - return; - } - - TString nam(o->IsA()->GetName()); - if (nam.Contains("TVector3")) { - TVector3 v(((TVector3 *) o)->X(), - ((TVector3 *) o)->Y(), - ((TVector3 *) o)->Z()); - mom2(np2,1) = v.X(); - mom2(np2,2) = v.Y(); - mom2(np2,3) = v.Z(); - mom2(np2,4) = v.Mag(); - } - else if (nam.Contains("TLorentzVector")) { - TVector3 v(((TLorentzVector *) o)->X(), - ((TLorentzVector *) o)->Y(), - ((TLorentzVector *) o)->Z()); - mom2(np2,1) = v.X(); - mom2(np2,2) = v.Y(); - mom2(np2,3) = v.Z(); - mom2(np2,4) = ((TLorentzVector *) o)->T(); - // cout << "mom2: " << mom2(np2,1) << ", " << mom2(np2,2)<<", " << mom2(np2,3)<<", " << mom2(np2,4)<< endl; - } - else { - printf("TopologyWorker::setEvent Second vector input is not a TVector3 or a TLorentzVector\n"); - continue; - } - np2++; - m_np2=np2; - } - m_mom2=mom2; - - if (m_boost && m_np>1) { - printf("TopologyWorker::setEvent Only boosting first vector so watch out when you do this!!!"); - TVector3 booze(-pxtot/etot,-pytot/etot,-pztot/etot); - TLorentzVector l1; - for (int k=0; k -1; ifas-- ) { - if ( mom(i,4) > fast(ifas,4) ) { - for ( Int_t j = 1; j < 6; j++ ) { - fast(ifas+1,j) = fast(ifas,j); - if ( ifas == 0 ) fast(ifas,j) = mom(i,j); - } - } - else { - for ( Int_t j = 1; j < 6; j++ ) { - fast(ifas+1,j) = mom(i,j); - } - break; - } - } - } - // Find axis with highest thrust (case 1)/ highest major (case 2). - for ( Int_t ie = 0; ie < work.GetNrows(); ie++ ) { - work(ie,4) = 0.; - } - Int_t p = TMath::Min( m_iFast, np ) - 1; - // Don't trust Math.pow to give right answer always. - // Want nc = 2**p. - Int_t nc = iPow(2,p); - for ( Int_t n = 0; n < nc; n++ ) { - for ( Int_t j = 1; j < 4; j++ ) { - tdi[j] = 0.; - } - for ( Int_t i = 0; i < TMath::Min(m_iFast,n); i++ ) { - sgn = fast(i,5); - if (iPow(2,(i+1))*((n+iPow(2,i))/iPow(2,(i+1))) >= i+1){ - sgn = -sgn; - } - for ( Int_t j = 1; j < 5-pass; j++ ) { - tdi[j] = tdi[j] + sgn*fast(i,j); - } - } - tds = tdi[1]*tdi[1] + tdi[2]*tdi[2] + tdi[3]*tdi[3]; - for ( Int_t iw = TMath::Min(n,9); iw > -1; iw--) { - if( tds > work(iw,4) ) { - for ( Int_t j = 1; j < 5; j++ ) { - work(iw+1,j) = work(iw,j); - if ( iw == 0 ) { - if ( j < 4 ) { - work(iw,j) = tdi[j]; - } - else { - work(iw,j) = tds; - } - } - } - } - else { - for ( Int_t j = 1; j < 4; j++ ) { - work(iw+1,j) = tdi[j]; - } - work(iw+1,4) = tds; - } - } - } - // Iterate direction of axis until stable maximum. - m_dThrust[pass] = 0; - thp = -99999.; - Int_t nagree = 0; - for ( Int_t iw = 0; - iw < TMath::Min(nc,10) && nagree < m_iGood; iw++ ){ - thp = 0.; - thps = -99999.; - while ( thp > thps + m_dConv ) { - thps = thp; - for ( Int_t j = 1; j < 4; j++ ) { - if ( thp <= 1E-10 ) { - tdi[j] = work(iw,j); - } - else { - tdi[j] = tpr[j]; - tpr[j] = 0; - } - } - for ( Int_t i = 0; i < np; i++ ) { - sgn = sign(mom(i,5), - tdi[1]*mom(i,1) + - tdi[2]*mom(i,2) + - tdi[3]*mom(i,3)); - for ( Int_t j = 1; j < 5 - pass; j++ ){ - tpr[j] = tpr[j] + sgn*mom(i,j); - } - } - thp = TMath::Sqrt(tpr[1]*tpr[1] - + tpr[2]*tpr[2] - + tpr[3]*tpr[3])/tmax; - } - // Save good axis. Try new initial axis until enough - // tries agree. - if ( thp < m_dThrust[pass] - m_dConv ) { - break; - } - if ( thp > m_dThrust[pass] + m_dConv ) { - nagree = 0; - sgn = iPow( -1, (Int_t)TMath::Nint(m_random.Rndm()) ); - for ( Int_t j = 1; j < 4; j++ ) { - m_dAxes(pass,j) = sgn*tpr[j]/(tmax*thp); - } - m_dThrust[pass] = thp; - } - nagree = nagree + 1; - } - } - // Find minor axis and value by orthogonality. - sgn = iPow( -1, (Int_t)TMath::Nint(m_random.Rndm())); - m_dAxes(3,1) = -sgn*m_dAxes(2,2); - m_dAxes(3,2) = sgn*m_dAxes(2,1); - m_dAxes(3,3) = 0.; - thp = 0.; - for ( Int_t i = 0; i < np; i++ ) { - thp += mom(i,5)*TMath::Abs(m_dAxes(3,1)*mom(i,1) + - m_dAxes(3,2)*mom(i,2)); - } - m_dThrust[3] = thp/tmax; - // Rotate back to original coordinate system. - for ( Int_t i6 = 0; i6 < 3; i6++ ) { - for ( Int_t j = 1; j < 4; j++ ) { - temp(i6,j) = m_dAxes(i6+1,j); - } - temp(i6,4) = 0; - } - ludbrb(&temp,the,phi,0.,0.,0.); - for ( Int_t i7 = 0; i7 < 3; i7++ ) { - for ( Int_t j = 1; j < 4; j++ ) { - m_dAxes(i7+1,j) = temp(i7,j); - } - } - m_dOblateness = m_dThrust[2] - m_dThrust[3]; - - // more stuff: - - // calculate weighed jet multiplicity(); - CalcWmul(); - CalcHTstuff(); - CalcSqrts(); - -} -//______________________________________________________________ - -// Setting and getting parameters. - -void TopologyWorker::setThMomPower(double tp) -{ - // Error if sp not positive. - if ( tp > 0. ) m_dDeltaThPower = tp - 1.0; - return; -} -//______________________________________________________________ - -double TopologyWorker::getThMomPower() -{ - return 1.0 + m_dDeltaThPower; -} -//______________________________________________________________ - -void TopologyWorker::setFast(Int_t nf) -{ - // Error if sp not positive. - if ( nf > 3 ) m_iFast = nf; - return; -} -//______________________________________________________________ - -Int_t TopologyWorker::getFast() -{ - return m_iFast; -} -//______________________________________________________________ - -// Returning results - -TVector3 TopologyWorker::thrustAxis() { - TVector3 m_ThrustAxis(m_dAxes(1,1),m_dAxes(1,2),m_dAxes(1,3)); - return m_ThrustAxis; -} -//______________________________________________________________ - -TVector3 TopologyWorker::majorAxis() { - TVector3 m_MajorAxis(m_dAxes(2,1),m_dAxes(2,2),m_dAxes(2,3)); - return m_MajorAxis; -} -//______________________________________________________________ - -TVector3 TopologyWorker::minorAxis() { - TVector3 m_MinorAxis(m_dAxes(3,1),m_dAxes(3,2),m_dAxes(3,3)); - return m_MinorAxis; -} -//______________________________________________________________ - -TVector3 TopologyWorker::thrust() { - TVector3 m_Thrust(m_dThrust[1],m_dThrust[2],m_dThrust[3]); - return m_Thrust; -} -//______________________________________________________________ - -double TopologyWorker::oblateness() { - return m_dOblateness; -} -//______________________________________________________________ - -// utilities(from Jetset): -double TopologyWorker::ulAngle(double x, double y) -{ - double ulangl = 0; - double r = TMath::Sqrt(x*x + y*y); - if ( r < 1.0E-20 ) { - return ulangl; - } - if ( TMath::Abs(x)/r < 0.8 ) { - ulangl = sign(TMath::ACos(x/r),y); - } - else { - ulangl = TMath::ASin(y/r); - if ( x < 0. && ulangl >= 0. ) { - ulangl = TMath::Pi() - ulangl; - } - else if ( x < 0. ) { - ulangl = -TMath::Pi() - ulangl; - } - } - return ulangl; -} -//______________________________________________________________ - -double TopologyWorker::sign(double a, double b) { - if ( b < 0 ) { - return -TMath::Abs(a); - } - else { - return TMath::Abs(a); - } -} -//______________________________________________________________ - -void TopologyWorker::ludbrb(TMatrix* mom, - double the, - double phi, - double bx, - double by, - double bz) -{ - // Ignore "zeroth" elements in rot,pr,dp. - // Trying to use physics-like notation. - TMatrix rot(4,4); - double pr[4]; - double dp[5]; - Int_t np = mom->GetNrows(); - if ( the*the + phi*phi > 1.0E-20 ) - { - rot(1,1) = TMath::Cos(the)*TMath::Cos(phi); - rot(1,2) = -TMath::Sin(phi); - rot(1,3) = TMath::Sin(the)*TMath::Cos(phi); - rot(2,1) = TMath::Cos(the)*TMath::Sin(phi); - rot(2,2) = TMath::Cos(phi); - rot(2,3) = TMath::Sin(the)*TMath::Sin(phi); - rot(3,1) = -TMath::Sin(the); - rot(3,2) = 0.0; - rot(3,3) = TMath::Cos(the); - for ( Int_t i = 0; i < np; i++ ) - { - for ( Int_t j = 1; j < 4; j++ ) - { - pr[j] = (*mom)(i,j); - (*mom)(i,j) = 0; - } - for ( Int_t jb = 1; jb < 4; jb++) - { - for ( Int_t k = 1; k < 4; k++) - { - (*mom)(i,jb) = (*mom)(i,jb) + rot(jb,k)*pr[k]; - } - } - } - double beta = TMath::Sqrt( bx*bx + by*by + bz*bz ); - if ( beta*beta > 1.0E-20 ) - { - if ( beta > 0.99999999 ) - { - //send message: boost too large, resetting to <~1.0. - bx = bx*(0.99999999/beta); - by = by*(0.99999999/beta); - bz = bz*(0.99999999/beta); - beta = 0.99999999; - } - double gamma = 1.0/TMath::Sqrt(1.0 - beta*beta); - for ( Int_t i = 0; i < np; i++ ) - { - for ( Int_t j = 1; j < 5; j++ ) - { - dp[j] = (*mom)(i,j); - } - double bp = bx*dp[1] + by*dp[2] + bz*dp[3]; - double gbp = gamma*(gamma*bp/(1.0 + gamma) + dp[4]); - (*mom)(i,1) = dp[1] + gbp*bx; - (*mom)(i,2) = dp[2] + gbp*by; - (*mom)(i,3) = dp[3] + gbp*bz; - (*mom)(i,4) = gamma*(dp[4] + bp); - } - } - } - return; -} - - - -// APLANARITY and SPHERICITY - -void TopologyWorker::sanda() { - float SPH=-1; - float APL=-1; - m_sanda_called=true; - //======================================================================= - // By M.Vreeswijk, (core was fortran, stolen from somewhere) - // Purpose: to perform sphericity tensor analysis to give sphericity - // and aplanarity. - // - // Needs: Array (standard from root-tuples): GTRACK_px, py, pz - // The number of tracks in these arrays: GTRACK_ijet - // In addition: Array GTRACK_ijet contains a jet number 'ijet' - // (if you wish to change this, simply change code) - // - // Uses: TVector3 and TLorentzVector classes - // - // Output: Sphericity SPH and Aplanarity APL - //======================================================================= -// C...Calculate matrix to be diagonalized. - float P[1000][6]; - double SM[4][4],SV[4][4]; - double PA,PWT,PS,SQ,SR,SP,SMAX,SGN; - int NP; - int J, J1, J2, I, N, JA, JB, J3, JC, JB1, JB2; - JA=JB=JC=0; - double RL; - float rlu,rlu1; - // - // --- get the input form GTRACK arrays - // - N=m_np; - NP=0; - for (I=1;I 1E-5) { - -// C...Find first and last eigenvector by solving equation system. - for (I=1;I<4;I=I+2) { // 240 - for (J1=1;J1<4;J1++) { // 180 - SV[J1][J1]=SM[J1][J1]-P[N+I][4]; - for (J2=J1+1;J2<4;J2++) { // 170 - SV[J1][J2]=SM[J1][J2]; - SV[J2][J1]=SM[J1][J2]; - } - } // 180 - SMAX=0.; - for (J1=1;J1<4;J1++) { // 200 - for (J2=1;J2<4;J2++) { // 190 - if(std::fabs(SV[J1][J2])>SMAX) { // 190 - JA=J1; - JB=J2; - SMAX=std::fabs(SV[J1][J2]); - } - } // 190 - } // 200 - SMAX=0.; - for (J3=JA+1;J3SMAX) { // GOTO 210 - JC=J1; - SMAX=std::fabs(SV[J1][J2]); - } - } // 210 - } // 220 - JB1=JB+1-3*(JB/3); - JB2=JB+2-3*((JB+1)/3); - P[N+I][JB1]=-SV[JC][JB2]; - P[N+I][JB2]=SV[JC][JB1]; - P[N+I][JB]=-(SV[JA][JB1]*P[N+I][JB1]+SV[JA][JB2]*P[N+I][JB2])/ - SV[JA][JB]; - PA=TMath::Sqrt(pow(P[N+I][1],2)+pow(P[N+I][2],2)+pow(P[N+I][3],2)); -// make a random number - float pa=P[N-1][I]; - rlu=std::fabs(pa)-std::fabs(int(pa)*1.); - rlu1=std::fabs(pa*pa)-std::fabs(int(pa*pa)*1.); - SGN=pow((-1.),1.*int(rlu+0.5)); - for (J=1;J<4;J++) { // 230 - P[N+I][J]=SGN*P[N+I][J]/PA; - } // 230 - } // 240 - -// C...Middle axis orthogonal to other two. Fill other codes. - SGN=pow((-1.),1.*int(rlu1+0.5)); - P[N+2][1]=SGN*(P[N+1][2]*P[N+3][3]-P[N+1][3]*P[N+3][2]); - P[N+2][2]=SGN*(P[N+1][3]*P[N+3][1]-P[N+1][1]*P[N+3][3]); - P[N+2][3]=SGN*(P[N+1][1]*P[N+3][2]-P[N+1][2]*P[N+3][1]); - -// C...Calculate sphericity and aplanarity. Select storing option. - SPH=1.5*(P[N+2][4]+P[N+3][4]); - APL=1.5*P[N+3][4]; - - } // check 1 - - m_sph=SPH; - m_apl=APL; - return; -} // end sanda - - - - -void TopologyWorker::planes_sphe(double& pnorm, double& p2, double& p3) { - //float SPH=-1; //FIXME: commented out since gcc461 complained that this variable is set but unused - //float APL=-1; //FIXME: commented out since gcc461 complained that this variable is set but unused -// C...Calculate matrix to be diagonalized. - float P[1000][6]; - double SM[4][4],SV[4][4]; - double PA,PWT,PS,SQ,SR,SP,SMAX,SGN; - int NP; - int J, J1, J2, I, N, JA, JB, J3, JC, JB1, JB2; - JA=JB=JC=0; - double RL; - float rlu,rlu1; - // - // --- get the input form GTRACK arrays - // - N=m_np; - NP=0; - for (I=1;I 1E-5) { - -// C...Find first and last eigenvector by solving equation system. - for (I=1;I<4;I=I+2) { // 240 - for (J1=1;J1<4;J1++) { // 180 - SV[J1][J1]=SM[J1][J1]-P[N+I][4]; - for (J2=J1+1;J2<4;J2++) { // 170 - SV[J1][J2]=SM[J1][J2]; - SV[J2][J1]=SM[J1][J2]; - } - } // 180 - SMAX=0.; - for (J1=1;J1<4;J1++) { // 200 - for (J2=1;J2<4;J2++) { // 190 - if(std::fabs(SV[J1][J2])>SMAX) { // 190 - JA=J1; - JB=J2; - SMAX=std::fabs(SV[J1][J2]); - } - } // 190 - } // 200 - SMAX=0.; - for (J3=JA+1;J3SMAX) { // GOTO 210 - JC=J1; - SMAX=std::fabs(SV[J1][J2]); - } - } // 210 - } // 220 - JB1=JB+1-3*(JB/3); - JB2=JB+2-3*((JB+1)/3); - P[N+I][JB1]=-SV[JC][JB2]; - P[N+I][JB2]=SV[JC][JB1]; - P[N+I][JB]=-(SV[JA][JB1]*P[N+I][JB1]+SV[JA][JB2]*P[N+I][JB2])/ - SV[JA][JB]; - PA=TMath::Sqrt(pow(P[N+I][1],2)+pow(P[N+I][2],2)+pow(P[N+I][3],2)); -// make a random number - float pa=P[N-1][I]; - rlu=std::fabs(pa)-std::fabs(int(pa)*1.); - rlu1=std::fabs(pa*pa)-std::fabs(int(pa*pa)*1.); - SGN=pow((-1.),1.*int(rlu+0.5)); - for (J=1;J<4;J++) { // 230 - P[N+I][J]=SGN*P[N+I][J]/PA; - } // 230 - } // 240 - -// C...Middle axis orthogonal to other two. Fill other codes. - SGN=pow((-1.),1.*int(rlu1+0.5)); - P[N+2][1]=SGN*(P[N+1][2]*P[N+3][3]-P[N+1][3]*P[N+3][2]); - P[N+2][2]=SGN*(P[N+1][3]*P[N+3][1]-P[N+1][1]*P[N+3][3]); - P[N+2][3]=SGN*(P[N+1][1]*P[N+3][2]-P[N+1][2]*P[N+3][1]); - -// C...Calculate sphericity and aplanarity. Select storing option. - //SPH=1.5*(P[N+2][4]+P[N+3][4]); //FIXME: commented out since gcc461 complained that this variable is set but unused - //APL=1.5*P[N+3][4]; //FIXME: commented out since gcc461 complained that this variable is set but unused - - } // check 1 - - // so assume now we have Sphericity axis, which one give the minimal Pts - double etstot[4]; - double eltot[4]; - double sum23=0; - double sum22=0; - double sum33=0; - double pina[4]; - double ax[4], ay[4], az[4]; - for (int ia=1;ia<4;ia++) { - etstot[ia]=0; - eltot[ia]=0; - pina[ia]=0; - ax[ia]=P[N+ia][1]; - ay[ia]=P[N+ia][2]; - az[ia]=P[N+ia][3]; - ax[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - ay[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - az[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - } - - - for (int k =0 ; k=0) { - double x1=(sqrt(disc)-b)/2/a; - double x2=(-sqrt(disc)-b)/2/a; - phi=atan(x1); - phip=atan(x2); - if (phi<0) phi=2.*pi+phi; - if (phip<0) phip=2.*pi+phip; - } - double p21=sum22*cos(phi)*cos(phi)+sum33*sin(phi)*sin(phi)+2*sum23*cos(phi)*sin(phi); - double p31=sum22*sin(phi)*sin(phi)+sum33*cos(phi)*cos(phi)-2*sum23*cos(phi)*sin(phi); - - double p22=sum22*cos(phip)*cos(phip)+sum33*sin(phip)*sin(phip)+2*sum23*cos(phip)*sin(phip); - double p32=sum22*sin(phip)*sin(phip)+sum33*cos(phip)*cos(phip)-2*sum23*cos(phip)*sin(phip); - - - double d1=std::fabs(p31*p31 - p21*p21); - double d2=std::fabs(p32*p32 - p22*p22); - //cout << " eltot " << eltot[2] << " " << eltot[3] << endl; - //cout << " phi " << phi << " " << phip << endl; - //cout << " d " << d1 << " " << d2 << endl; - p2=p21; - p3=p31; - if (d2>d1) { - p2=p22; - p3=p32; - } - pnorm=sqrt(eltot[1]); - if (p2>p3) { - p3=sqrt(p3); - p2=sqrt(p2); - }else { - double p4=p3; - p3=sqrt(p2); - p2=sqrt(p4); - } - //cout << " sum2 sum3 " << sqrt(sum22) << " " << sqrt(sum33) << endl; - //cout << " p2 p3 " << p2 << " " << p3 << endl; - //double els=sqrt(eltot[2]*eltot[2]+eltot[3]*eltot[3]); - // cout << " ets els " << (ettot[1]) << " " << els << endl; - - //m_sph=SPH; //FIXME: shouldn't the local variables be used to reset the class member variables accordingly? - //m_apl=APL; //FIXME: shouldn't the local variables be used to reset the class member variables accordingly? - return; -} // end planes_sphe - - -void TopologyWorker::planes_sphe_wei(double& pnorm, double& p2, double& p3) { - //float SPH=-1; //FIXME: commented out since gcc461 complained that this variable is set but unused - //float APL=-1; //FIXME: commented out since gcc461 complained that this variable is set but unused -// C...Calculate matrix to be diagonalized. - float P[1000][6]; - double SM[4][4],SV[4][4]; - double PA,PWT,PS,SQ,SR,SP,SMAX,SGN; - int NP; - int J, J1, J2, I, N, JA, JB, J3, JC, JB1, JB2; - JA=JB=JC=0; - double RL; - float rlu,rlu1; - // - // --- get the input form GTRACK arrays - // - N=m_np; - NP=0; - for (I=1;I 1E-5) { - -// C...Find first and last eigenvector by solving equation system. - for (I=1;I<4;I=I+2) { // 240 - for (J1=1;J1<4;J1++) { // 180 - SV[J1][J1]=SM[J1][J1]-P[N+I][4]; - for (J2=J1+1;J2<4;J2++) { // 170 - SV[J1][J2]=SM[J1][J2]; - SV[J2][J1]=SM[J1][J2]; - } - } // 180 - SMAX=0.; - for (J1=1;J1<4;J1++) { // 200 - for (J2=1;J2<4;J2++) { // 190 - if(std::fabs(SV[J1][J2])>SMAX) { // 190 - JA=J1; - JB=J2; - SMAX=std::fabs(SV[J1][J2]); - } - } // 190 - } // 200 - SMAX=0.; - for (J3=JA+1;J3SMAX) { // GOTO 210 - JC=J1; - SMAX=std::fabs(SV[J1][J2]); - } - } // 210 - } // 220 - JB1=JB+1-3*(JB/3); - JB2=JB+2-3*((JB+1)/3); - P[N+I][JB1]=-SV[JC][JB2]; - P[N+I][JB2]=SV[JC][JB1]; - P[N+I][JB]=-(SV[JA][JB1]*P[N+I][JB1]+SV[JA][JB2]*P[N+I][JB2])/ - SV[JA][JB]; - PA=TMath::Sqrt(pow(P[N+I][1],2)+pow(P[N+I][2],2)+pow(P[N+I][3],2)); -// make a random number - float pa=P[N-1][I]; - rlu=std::fabs(pa)-std::fabs(int(pa)*1.); - rlu1=std::fabs(pa*pa)-std::fabs(int(pa*pa)*1.); - SGN=pow((-1.),1.*int(rlu+0.5)); - for (J=1;J<4;J++) { // 230 - P[N+I][J]=SGN*P[N+I][J]/PA; - } // 230 - } // 240 - -// C...Middle axis orthogonal to other two. Fill other codes. - SGN=pow((-1.),1.*int(rlu1+0.5)); - P[N+2][1]=SGN*(P[N+1][2]*P[N+3][3]-P[N+1][3]*P[N+3][2]); - P[N+2][2]=SGN*(P[N+1][3]*P[N+3][1]-P[N+1][1]*P[N+3][3]); - P[N+2][3]=SGN*(P[N+1][1]*P[N+3][2]-P[N+1][2]*P[N+3][1]); - -// C...Calculate sphericity and aplanarity. Select storing option. - //SPH=1.5*(P[N+2][4]+P[N+3][4]); //FIXME: commented out since gcc461 complained that this variable is set but unused - //APL=1.5*P[N+3][4]; //FIXME: commented out since gcc461 complained that this variable is set but unused - - } // check 1 - - // so assume now we have Sphericity axis, which one give the minimal Pts - double etstot[4]; - double eltot[4]; - double sum23=0; - double sum22=0; - double sum33=0; - double pina[4]; - double ax[4], ay[4], az[4]; - for (int ia=1;ia<4;ia++) { - etstot[ia]=0; - eltot[ia]=0; - pina[ia]=0; - ax[ia]=P[N+ia][1]; - ay[ia]=P[N+ia][2]; - az[ia]=P[N+ia][3]; - ax[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - ay[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - az[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - } - - for (int k =0 ; k=0) { - double x1=(sqrt(disc)-b)/2/a; - double x2=(-sqrt(disc)-b)/2/a; - phi=atan(x1); - phip=atan(x2); - if (phi<0) phi=2.*pi+phi; - if (phip<0) phip=2.*pi+phip; - } - double p21=sum22*cos(phi)*cos(phi)+sum33*sin(phi)*sin(phi)+2*sum23*cos(phi)*sin(phi); - double p31=sum22*sin(phi)*sin(phi)+sum33*cos(phi)*cos(phi)-2*sum23*cos(phi)*sin(phi); - - double p22=sum22*cos(phip)*cos(phip)+sum33*sin(phip)*sin(phip)+2*sum23*cos(phip)*sin(phip); - double p32=sum22*sin(phip)*sin(phip)+sum33*cos(phip)*cos(phip)-2*sum23*cos(phip)*sin(phip); - - - double d1=std::fabs(p31*p31 - p21*p21); - double d2=std::fabs(p32*p32 - p22*p22); - //cout << " eltot " << eltot[2] << " " << eltot[3] << endl; - //cout << " phi " << phi << " " << phip << endl; - //cout << " d " << d1 << " " << d2 << endl; - p2=p21; - p3=p31; - if (d2>d1) { - p2=p22; - p3=p32; - } - pnorm=sqrt(eltot[1]); - if (p2>p3) { - p3=sqrt(p3); - p2=sqrt(p2); - }else { - double p4=p3; - p3=sqrt(p2); - p2=sqrt(p4); - } - //cout << " sum2 sum3 " << sqrt(sum22) << " " << sqrt(sum33) << endl; - //cout << " p2 p3 " << p2 << " " << p3 << endl; - //double els=sqrt(eltot[2]*eltot[2]+eltot[3]*eltot[3]); - // cout << " ets els " << (ettot[1]) << " " << els << endl; - - //m_sph=SPH; //FIXME: shouldn't the local variables be used to reset the class member variables accordingly? - //m_apl=APL; //FIXME: shouldn't the local variables be used to reset the class member variables accordingly? - return; -} // end planes_sphe - - - -void TopologyWorker::planes_thrust(double& pnorm, double& p2, double& p3) { - TVector3 thrustaxis=thrustAxis(); - TVector3 majoraxis=majorAxis(); - TVector3 minoraxis=minorAxis(); - // so assume now we have Sphericity axis, which one give the minimal Pts - double etstot[4]; - double eltot[4]; - double sum23=0; - double sum22=0; - double sum33=0; - double pina[4]; - double ax[4], ay[4], az[4]; - ax[1]=thrustaxis(0); ay[1]=thrustaxis(1); az[1]=thrustaxis(2); - ax[2]=minoraxis(0); ay[2]=minoraxis(1); az[2]=minoraxis(2); - ax[3]=majoraxis(0); ay[3]=majoraxis(1); az[3]=majoraxis(2); - for (int ia=1;ia<4;ia++) { - etstot[ia]=0; - eltot[ia]=0; - pina[ia]=0; - ax[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - ay[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - az[ia]/=sqrt(ax[ia]*ax[ia]+ay[ia]*ay[ia]+az[ia]*az[ia]); - } - - for (int k =0 ; k=0) { - double x1=(sqrt(disc)-b)/2/a; - double x2=(-sqrt(disc)-b)/2/a; - phi=atan(x1); - phip=atan(x2); - if (phi<0) phi=2.*pi+phi; - if (phip<0) phip=2.*pi+phip; - } - double p21=sum22*cos(phi)*cos(phi)+sum33*sin(phi)*sin(phi)+2*sum23*cos(phi)*sin(phi); - double p31=sum22*sin(phi)*sin(phi)+sum33*cos(phi)*cos(phi)-2*sum23*cos(phi)*sin(phi); - - double p22=sum22*cos(phip)*cos(phip)+sum33*sin(phip)*sin(phip)+2*sum23*cos(phip)*sin(phip); - double p32=sum22*sin(phip)*sin(phip)+sum33*cos(phip)*cos(phip)-2*sum23*cos(phip)*sin(phip); - - - double d1=std::fabs(p31*p31 - p21*p21); - double d2=std::fabs(p32*p32 - p22*p22); - //cout << " eltot " << eltot[2] << " " << eltot[3] << endl; - //cout << " phi " << phi << " " << phip << endl; - //cout << " d " << d1 << " " << d2 << endl; - p2=p21; - p3=p31; - if (d2>d1) { - p2=p22; - p3=p32; - } - pnorm=sqrt(etstot[1]); - if (p2>p3) { - p3=sqrt(p3); - p2=sqrt(p2); - }else { - double p4=p3; - p3=sqrt(p2); - p2=sqrt(p4); - } - //cout << " sum2 sum3 " << sqrt(sum22) << " " << sqrt(sum33) << endl; - //cout << " p2 p3 " << p2 << " " << p3 << endl; - //double els=sqrt(eltot[2]*eltot[2]+eltot[3]*eltot[3]); - // cout << " ets els " << (ettot[1]) << " " << els << endl; - return; -} // end planes_thru - - -void TopologyWorker::fowo() { -// 20020830 changed: from p/E to Et/Ettot and include H50 and H60 - m_fowo_called=true; - // include fox wolframs - float H10=-1; - float H20=-1; - float H30=-1; - float H40=-1; - float H50=-1; - float H60=-1; - if (1==1) { - float P[1000][6],H0,HD,CTHE; - int N,NP,I,J,I1,I2; - H0=HD=0.; - N=m_np; - NP=0; - for (I=1;I0.000001) { - eta = -log( tan( thg/2.0 ) ); - } - phi = atan2(py,px); - if(phi<=0) phi += 2.0*pi; - return; -} - - - -void TopologyWorker::sumangles(float& sdeta, float& sdr) { - double eta1,eta2,phi1,phi2,deta,dphi,dr; - m_sumangles_called=true; - sdeta=0; - sdr=0; - for (int k=0;k3.1415) dphi=2*3.1415-dphi; - deta=std::fabs(eta1-eta2); - dr=sqrt(dphi*dphi+deta*deta); - sdeta+=deta; - sdr+=dr; - } - } - return; -} - -//______________________________________________________________ - -Int_t TopologyWorker::iPow(Int_t man, Int_t exp) -{ - Int_t ans = 1; - for( Int_t k = 0; k < exp; k++) - { - ans = ans*man; - } - return ans; -} - -// added by Freya: - -void TopologyWorker::CalcWmul(){ - - Int_t njets = m_np; - double result=0; - for(Int_t ijet=0; ijetelo){ - elo=CalcPt(njets-1); - } - - result+=0.5 * (elo*elo-(15*15))*(njets); - result/=((55*55)-100)/2.0; - m_njetsweighed=result; -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void TopologyWorker::CalcSqrts(){ - TLorentzVector event(0,0,0,0); - TLorentzVector worker(0,0,0,0); - - for(int i=0; i< m_np; i++){ - double energy=m_mom(i,4); - if(m_mom(i,4)<0.00001) - energy=sqrt(pow(m_mom(i,1),2)+pow(m_mom(i,2),2)+pow(m_mom(i,3),2)); - // assume massless particle if only TVector3s are provided... - worker.SetXYZT(m_mom(i,1),m_mom(i,2),m_mom(i,3),energy); - event+=worker; - } - m_sqrts=event.M(); -} - -//++++++++++++++++++++++++++++++++++++++ -void TopologyWorker::CalcHTstuff(){ - m_ht=0; - m_ht3=0; - m_et56=0; - m_et0=0; - double ptlead=0; - double h=0; - for(int i=0; i< m_np; i++){ - //cout << i << "/" << m_np << ":" << CalcPt(i) << endl; - m_ht+=CalcPt(i); - h+=m_mom(i,4); - if(i>1) - m_ht3+=CalcPt(i); - if(i==5) - m_et56=sqrt(CalcPt(i)*CalcPt(i-1)); - } - - for(int j=0; j< m_np2; j++){ - //cout << j << "/" << m_np2 << ":" << CalcPt2(j) << endl; - if(ptlead0.0001){ - m_et0=ptlead/m_ht; - //cout << "calculating ETO" << m_et0 << "=" << ptlead << endl; - } - if(h>0.00001) - m_centrality=m_ht/h; -} - -#endif - - - - diff --git a/TrackingTools/AnalyticalJacobians/interface/CurvilinearJacobian.h b/TrackingTools/AnalyticalJacobians/interface/CurvilinearJacobian.h deleted file mode 100644 index 85ae38f062ac1..0000000000000 --- a/TrackingTools/AnalyticalJacobians/interface/CurvilinearJacobian.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CurvilinearJacobian_H -#define CurvilinearJacobian_H - -#include "DataFormats/Math/interface/AlgebraicROOTObjects.h" - -/** Base class for calculations of Jacobians of transformations within the curvilinear frame. - */ - -class CurvilinearJacobian { -public: - - CurvilinearJacobian() : theJacobian(AlgebraicMatrixID()){} - - virtual ~CurvilinearJacobian() {} - - const AlgebraicMatrix55& jacobian() const {return theJacobian;} - -protected: - - AlgebraicMatrix55 theJacobian; - - -}; - -#endif diff --git a/TrackingTools/GsfTools/interface/GaussianSumUtilities.h b/TrackingTools/GsfTools/interface/GaussianSumUtilities.h deleted file mode 100644 index 77ca08116638f..0000000000000 --- a/TrackingTools/GsfTools/interface/GaussianSumUtilities.h +++ /dev/null @@ -1,154 +0,0 @@ -#ifndef GaussianSumUtilities_h_ -#define GaussianSumUtilities_h_ - -#include "TrackingTools/GsfTools/interface/MultiGaussianState1D.h" -#include "TrackingTools/GsfTools/interface/SingleGaussianState.h" -#include "TrackingTools/GsfTools/interface/MultiGaussianState.h" -#include - -/** Utility class for the analysis of multi-dimensional Gaussian - * mixtures. The input state is assumed to exist for - * the lifetime of this object. - */ - -template -class GaussianSumUtilities { -public: - typedef SingleGaussianState SingleState; - typedef MultiGaussianState MultiState; -// typedef ROOT::Math::SVector Vector; - typedef ROOT::Math::SMatrix > GenMatrix; - - typedef typename SingleState::Vector Vector; - typedef typename SingleState::Matrix Matrix; - typedef typename MultiState::SingleStatePtr SingleStatePtr; - typedef typename MultiState::SingleStateContainer SingleStateContainer; - -private: - enum ModeStatus { Valid, NotValid, NotComputed }; - -public: - GaussianSumUtilities (const MultiState& state) : - theState(state), - theModeStatus(NotComputed) { - } - ~GaussianSumUtilities () { - } - - /// number of components - inline unsigned int size () const { - return components().size(); - } - /// components - const SingleStateContainer& components () const { - return theState.components(); - } - /// multi-state - const MultiState& state () const { - return theState; - } - /// weight of a component - inline double weight (unsigned int i) const { - return components()[i]->weight(); - } - /// mean value of a component - inline const Vector& mean (unsigned int i) const { - return components()[i]->mean(); - } - /// covariance matrix of a component - inline const Matrix& covariance (unsigned int i) const { - return components()[i]->covariance(); - } - /// mode status - bool modeIsValid () const; - /** Mode "state": mean = mode, covariance = local covariance at mode, - * weight chosen to have pdf(mode) equal to the one of the mixture */ - const SingleGaussianState& mode () const; - /// value of the p.d.f. - double pdf (const Vector&) const; - /// gradient - Vector d1Pdf (const Vector&) const; - /// Hessian - Matrix d2Pdf (const Vector&) const; - /// value of ln(pdf) - double lnPdf (const Vector&) const; - /// gradient of ln(pdf) - Vector d1LnPdf (const Vector&) const; - /// Hessian of ln(pdf) - Matrix d2LnPdf (const Vector&) const; - - /// combined weight - double weight () const { - return theState.weight(); - } - /// combined mean - const Vector& mean () const { - return theState.mean(); - } - /// combined covariance - const Matrix& covariance () const { - return theState.covariance(); - } - - -protected: - /// calculation of mode - Vector computeModeWithoutTransform () const; - -private: - /// Symmetric Tensor Product (not recognized by standard ROOT Math) - Matrix tensorProduct (const Vector&) const; - /// value of gaussian distribution - double gauss (const double&, const double&, const double&) const; - /// value of multidimensional gaussian distribution - double gauss (const Vector&, - const Vector&, - const Matrix&) const; - /// mode from starting value in ln(pdf); returns true on success - bool findMode (Vector& mode, double& pdfAtMode, - const Vector& xStart) const; - /// calculation of mode with transformation of pdf - void computeMode () const; - /// state constrained to a line x = s*d+x0 - MultiGaussianState1D constrainedState (const Vector& d, - const Vector& x0) const; -// /// replacement of CLHEP determinant (which rounds off small values) -// double determinant (const Matrix& matrix) const; - /** Local variance from Hessian matrix. - * Only valid if x corresponds to a (local) maximum! */ - Matrix localCovariance (const Vector& x) const; - /// set mode "state" from solution of mode finding - void setMode (const Vector& mode) const; - /// set mode "state" in case of failure - void setInvalidMode () const; - - /// pdf components - std::vector pdfComponents (const Vector&) const; - /// value of the p.d.f. using the pdf components at the evaluation point - double pdf (const Vector&, const std::vector&) const; - /// gradient using the pdf components at the evaluation point - Vector d1Pdf (const Vector&, const std::vector&) const; - /// Hessian using the pdf components at the evaluation point - Matrix d2Pdf (const Vector&, const std::vector&) const; - /// value of ln(pdf) using the pdf components at the evaluation point - double lnPdf (const Vector&, const std::vector&) const; - /// gradient of ln(pdf) using the pdf components at the evaluation point - Vector d1LnPdf (const Vector&, const std::vector&) const; - /// Hessian of ln(pdf) using the pdf components at the evaluation point - Matrix d2LnPdf (const Vector&, const std::vector&) const; - - - -private: - const MultiState& theState; -// int theDimension; - - mutable ModeStatus theModeStatus; -// mutable Vector theMode; - mutable SingleGaussianState theMode; - -}; - -#include "TrackingTools/GsfTools/interface/GaussianSumUtilities.icc" - -#endif diff --git a/TrackingTools/GsfTools/interface/GaussianSumUtilities.icc b/TrackingTools/GsfTools/interface/GaussianSumUtilities.icc deleted file mode 100644 index 926f60dd7f6af..0000000000000 --- a/TrackingTools/GsfTools/interface/GaussianSumUtilities.icc +++ /dev/null @@ -1,573 +0,0 @@ -#include "TrackingTools/GsfTools/interface/GaussianSumUtilities.h" - -#include "TrackingTools/GsfTools/interface/SingleGaussianState1D.h" -#include "TrackingTools/GsfTools/interface/MultiGaussianState1D.h" -#include "TrackingTools/GsfTools/interface/GaussianSumUtilities1D.h" -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -// #include "Utilities/Timing/interface/TimingReport.h" -// #include "Utilities/Timing/interface/TimerStack.h" - -#include "TROOT.h" -#include "TMath.h" -#include "TVectorD.h" -#include "TMatrixDSym.h" -#include "TMatrixDSymEigen.h" - -#include -#include - -#include -#include - - -template -bool -GaussianSumUtilities::modeIsValid () const -{ - if ( theModeStatus==NotComputed ) computeMode(); - return theModeStatus==Valid; -} - -template -const SingleGaussianState& -GaussianSumUtilities::mode () const -{ - if ( theModeStatus==NotComputed ) computeMode(); - return theMode; -} - -template -void -GaussianSumUtilities::computeMode () const -{ -// TimerStack tstack; -// tstack.benchmark("GSUND::benchmark",1000000); -// FastTimerStackPush(tstack,"GaussianSumUtilities::computeMode"); - // - // initialize status - // - theModeStatus = NotValid; - // - // diagonalize / normalize (better convergence) - // based on component with highest pdf at mean - // - unsigned int icMax(0); - double yMax(-1.); - for ( unsigned int ic=0; icyMax ) { - icMax = ic; - yMax = y; - } - } - // need to copy the matrix since diagonalization is not - // available for SMatrix but there must be a better way - // to copy the matrix ... - TMatrixDSym diag(N); - for ( unsigned int i=0; i(newMean,newCov,(**i).weight()); - newStates.push_back(sgs); - } - MultiState newState(newStates); - GaussianSumUtilities newGSU(newState); - // - // get mode in transformed system - // - Vector newMode = newGSU.computeModeWithoutTransform(); - // - // transform back - // - if ( newGSU.modeIsValid() ) { -// Vector mode((ROOT::Math::Transpose(rotT)*newMode)+trans); - Vector mode(rot*newMode+trans); - setMode(mode); - } - else { - edm::LogWarning("GaussianSumUtilities") << "multi-dimensional mode calculation failed"; - setInvalidMode(); - } - -} - -template -typename GaussianSumUtilities::Vector -GaussianSumUtilities::computeModeWithoutTransform () const -{ - // - // initialize status - // - theModeStatus = NotValid; - // - // Use means of individual components as start values. - // Sort by value of pdf. - // - typedef std::multimap > StartMap; - StartMap xStart; - for ( UInt_t i=0; i result(-1.,mean((*xStart.begin()).second)); - Vector xRes; - double yRes(0.); - for ( StartMap::const_iterator i=xStart.begin(); - i!=xStart.end(); i++ ) { - // - // If a solution exists: drop as soon as the pdf at - // start value drops to < 75% of maximum (try to avoid - // unnecessary searches for the mode) - // - if ( theModeStatus==Valid && - (*i).first/(*xStart.begin()).first<0.75 ) break; - // - // try to find mode from this start value - // - bool valid = findMode(xRes,yRes,mean((*i).second)); - - // - // store result if findMode was successful and if - // the new value is significantly higher - // - if ( valid && (result.first<0. || - (yRes-result.first)/(yRes+result.first)>1.e-5) ) { - theModeStatus = Valid; - result = std::make_pair(yRes,xRes); - } - } - // - // check (existance of) solution - // - if ( theModeStatus==Valid ) { - setMode(result.second); - } - else - setInvalidMode(); - - - return theMode.mean(); -} - -template -bool -GaussianSumUtilities::findMode (Vector& xMode, double& yMode, - const Vector& xStart) const -{ - static const int signHesse = (N%2) ? -1 : 1; - // - // use Newton or follow gradient - // - bool result(false); - Vector x1; - double y1(0.); - Vector x2(xStart); - std::vector pdfs; - pdfs.reserve(size()); - double y2(0.); - Vector yd2; - Vector ydh2; - double detHesse2(0.); - bool usedHesse(false); - // - // iterate until convergence - // - int nLoop(0); - while ( nLoop++<50 ) { - pdfs = pdfComponents(x2); - y2 = pdf(x2,pdfs); - ydh2 = yd2 = d1LnPdf(x2,pdfs); - // cuts tuned on N=5, might need revision for other dimension - // even if distribution is approx. normalized - if ( nLoop>1 && usedHesse && detHesse2>0. && - fabs(y2-y1)/(y2+y1)<1.e-10 || ROOT::Math::Mag2(yd2)<1.e-20 ) { - result = true; - break; - } - // - // Hessian (Sign(Det(hesse)) should be (-1)**N around maximum) - // -// Matrix hesse2 = d2LnPdf(x2,pdfs); -// usedHesse = false; -// hesse2.Det2(detHesse2); -// detHesse2 *= signHesse; -// int ifail; -// // GenMatrix invHesse2(hesse2.inverse(ifail)); -// Matrix invHesse2 = hesse2.Inverse(ifail); - Matrix hesse2(d2LnPdf(x2,pdfs)); - usedHesse = false; - hesse2.Det2(detHesse2); - detHesse2 *= signHesse; - bool success = hesse2.Invert(); - if ( success ) { - ydh2 = -hesse2*yd2; - usedHesse = true; - } - double s = ROOT::Math::Mag(ydh2); - if ( fabs(s)>FLT_MIN ) ydh2 *= 1./s; - // - // restrict to direction of gradient - // - if ( !usedHesse || detHesse2<0. ) { - MultiGaussianState1D oneDimState(constrainedState(ydh2,x2)); - GaussianSumUtilities1D gsUtils(oneDimState); - if ( !usedHesse || gsUtils.d2Pdf(0.)>=0. ) { - s = gsUtils.mode().mean(); - if ( !gsUtils.modeIsValid() ) s = 0.1; - } - } - // - // protect against too large steps (to be revised??) - // - if ( s<-3. ) s = -3.; - else if ( s>3. ) s = 3.; - // - // save old values - // - x1 = x2; - y1 = y2; - // - // set new values - // - x2 += s*ydh2; - } - xMode = x2; - yMode = y2; - return result; -} - -template -MultiGaussianState1D -GaussianSumUtilities::constrainedState (const Vector& d, - const Vector& x0) const -{ - static const double fNorm(1./pow(2*TMath::Pi(),N-1)); - std::vector states; - states.reserve(size()); - for ( typename SingleStateContainer::const_iterator i=components().begin(); - i!=components().end(); i++ ) { - double det; - (**i).weightMatrix().Det2(det); - if ( det<0 ) continue; - - Vector dx((**i).mean()-x0); -// double dGd = (**i).weightMatrix().similarity(d); - double dGd = ROOT::Math::Similarity(d,(**i).weightMatrix()); - if ( dGd<-FLT_MIN ) continue; - Vector gDx = (**i).weightMatrix()*dx; -// double dxGdx = dot(dx,gDx); -// double dGdx = dot(d,gDx); - double dxGdx = ROOT::Math::Dot(dx,gDx); - double dGdx = ROOT::Math::Dot(d,gDx); - double weight((**i).weight()); -// weight *= sqrt(determinant((**i).weightMatrix())* -// pow(fNorm,N-1)/dGd); -// weight *= sqrt(det*pow(fNorm,N-1)/dGd); - weight *= sqrt(det*fNorm/dGd); - double exponent = dxGdx - dGdx*dGdx/dGd; - if ( exponent>-400. ) weight *= exp(-0.5*exponent); - else weight = 0.; - states.push_back(SingleGaussianState1D(dGdx/dGd,1./dGd,weight)); - } - return MultiGaussianState1D(states); -} - -template -double -GaussianSumUtilities::pdf(const Vector& x) const -{ -return pdf(x,pdfComponents(x)); -} - -template -typename GaussianSumUtilities::Vector -GaussianSumUtilities::d1Pdf(const Vector& x) const -{ -return d1Pdf(x,pdfComponents(x)); -} - -template -typename GaussianSumUtilities::Matrix -GaussianSumUtilities::d2Pdf(const Vector& x) const -{ -return d2Pdf(x,pdfComponents(x)); -} - -template -double -GaussianSumUtilities::lnPdf(const Vector& x) const -{ -return lnPdf(x,pdfComponents(x)); -} - -template -typename GaussianSumUtilities::Vector -GaussianSumUtilities::d1LnPdf(const Vector& x) const -{ -return d1LnPdf(x,pdfComponents(x)); -} - -template -typename GaussianSumUtilities::Matrix -GaussianSumUtilities::d2LnPdf (const Vector& x) const -{ -return d2LnPdf(x,pdfComponents(x)); -} - -template -std::vector -GaussianSumUtilities::pdfComponents (const Vector& x) const -{ - std::vector result; - result.reserve(size()); - for ( typename SingleStateContainer::const_iterator i=components().begin(); - i!=components().end(); i++ ) { - result.push_back((**i).weight()*gauss(x,(**i).mean(),(**i).weightMatrix())); - } - return result; -} - -template -double -GaussianSumUtilities::pdf (const Vector& x, const std::vector& pdfs) const -{ - double result(0.); - for ( std::vector::const_iterator i=pdfs.begin(); - i!=pdfs.end(); ++i ) result += *i; - return result; -} - -template -typename GaussianSumUtilities::Vector -GaussianSumUtilities::d1Pdf (const Vector& x, const std::vector& pdfs) const -{ - Vector result; // rely on root doc that vector is initialised to 0 - typename SingleStateContainer::const_iterator ic = components().begin(); - std::vector::const_iterator ip = pdfs.begin(); - for ( ; ic!=components().end(); ++ic,++ip ) { - Vector gx((**ic).weightMatrix()*(x-(**ic).mean())); - gx *= -(*ip); - result += gx; - } - return result; -} - -template -typename GaussianSumUtilities::Matrix -GaussianSumUtilities::d2Pdf (const Vector& x, const std::vector& pdfs) const -{ - Matrix result; // (N,0); - typename SingleStateContainer::const_iterator ic = components().begin(); - std::vector::const_iterator ip = pdfs.begin(); - for ( ; ic!=components().end(); ++ic,++ip ) { - Vector gx((**ic).weightMatrix()*(x-(**ic).mean())); -// Matrix c(vT_times_v(gx)); - Matrix c(tensorProduct(gx)); - c -= (**ic).weightMatrix(); - c *= (*ip); - result += c; - } - return result; -} - -template -double -GaussianSumUtilities::lnPdf (const Vector& x, const std::vector& pdfs) const -{ - double result = pdf(x,pdfs); - if ( result>DBL_MIN ) result = log(result); - else result = -FLT_MAX; - return result; -} - -template -typename GaussianSumUtilities::Vector -GaussianSumUtilities::d1LnPdf (const Vector& x, const std::vector& pdfs) const -{ - double f = pdf(x,pdfs); - Vector result(d1Pdf(x,pdfs)); - if ( f>DBL_MIN ) result /= f; - else result *= 0.; - return result; -} - -template -typename GaussianSumUtilities::Matrix -GaussianSumUtilities::d2LnPdf (const Vector& x, const std::vector& pdfs) const -{ - double f(pdf(x,pdfs)); - Vector df(d1LnPdf(x,pdfs)); -// Matrix result(-vT_times_v(df)); - Matrix result(-tensorProduct(df)); - if ( f>DBL_MIN ) result += d2Pdf(x,pdfs)/f; - return result; -} - -template -double -GaussianSumUtilities::gauss (const double& x, const double& mean, - const double& sigma) const -{ - const double fNorm(1./sqrt(2*TMath::Pi())); - double result(0.); - - double d((x-mean)/sigma); - if ( fabs(d)<20. ) result = exp(-d*d/2.); - result *= fNorm/sigma; - return result; -} - -template -double -GaussianSumUtilities::gauss (const Vector& x, - const Vector& means, - const Matrix& weightMatrix) const -{ - static const double fNorm(1./pow(2*TMath::Pi(),N)); - double result(0.); - - double det; - weightMatrix.Det2(det); - if ( det<0. ) return 0.; - - Vector dx(x-means); -// double d = weightMatrix.similarity(dx); - double d = ROOT::Math::Similarity(dx,weightMatrix); - // protection against numerical problems - if ( d<-FLT_MIN ) return 0.; - if ( d<400. ) result = exp(-d/2.); -// result *= sqrt(pow(fNorm,N)*determinant(weightMatrix)); -// result *= sqrt(pow(fNorm,N)*det); - result *= sqrt(fNorm*det); - return result; -} - -template -typename GaussianSumUtilities::Matrix -GaussianSumUtilities::localCovariance (const Vector& x) const -{ - Matrix result(d2Pdf(x)); - result *= -1./pdf(x); - - double det; - result.Det2(det); -// int ifail; -// // Matrix covariance(weightMatrix.inverse(ifail)); -// Matrix covariance = weightMatrix.Inverse(ifail); -// if ( ifail!=0 || det<=DBL_MIN ) { - bool success = result.Invert(); - if ( !success || det<=DBL_MIN ) { - edm::LogWarning("GaussianSumUtilities") - << "localCovariance: weight matrix is not pos. def."; - } -// return covariance; - return result; -} - -template -void -GaussianSumUtilities::setMode (const Vector& mode) const -{ - // - // Valid mode: construct single Gaussian state with - // mean = mode - // covariance = local covariance at mode - // weight such that the pdf's of the mixture and the - // single state are equal at the mode - // - theModeStatus = Valid; - Matrix covMode(localCovariance(mode)); - static const double fNorm(pow(2*TMath::Pi(),N)); - double det; - covMode.Det2(det); - double wgtMode = pdf(mode)*sqrt(fNorm*det); - theMode = SingleGaussianState(mode,covMode,wgtMode); -} - -template -void -GaussianSumUtilities::setInvalidMode () const -{ - // - // Mode finding failed: set solution to highest component - // (alternative would be global mean / covariance ..?) - // -// theMode = SingleGaussianState(mean(),covariance(),weight()); - // - // look for component with highest value at mean - // - unsigned int icMax(0); - double ySqMax(0.); - for ( unsigned int ic=0; ic(*components()[icMax]); -} - -template -typename GaussianSumUtilities::Matrix -GaussianSumUtilities::tensorProduct (const Vector& v) const -{ - Matrix result; - for ( unsigned int i=0; i