CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
AlphaTVarProducer Class Reference

#include <AlphaTVarProducer.h>

Inheritance diagram for AlphaTVarProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AlphaTVarProducer (const edm::ParameterSet &)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

double CalcAlphaT (const std::vector< TLorentzVector > &) const
 

Static Private Member Functions

static double alphaT (const double, const double, const double)
 
static double CalcHT (const std::vector< TLorentzVector > &)
 
static double CalcMHT (const std::vector< TLorentzVector > &)
 
static double deltaHt (const std::vector< double > &)
 

Private Attributes

edm::InputTag inputJetTag_
 
edm::EDGetTokenT< reco::CaloJetCollectioninputJetTagToken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 16 of file AlphaTVarProducer.h.

Constructor & Destructor Documentation

◆ AlphaTVarProducer()

AlphaTVarProducer::AlphaTVarProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 26 of file AlphaTVarProducer.cc.

References edm::InputTag::encode(), edm::ParameterSet::getParameter(), inputJetTag_, inputJetTagToken_, and LogDebug.

27  : inputJetTag_(iConfig.getParameter<edm::InputTag>("inputJetTag")) {
28  produces<std::vector<double>>();
29 
30  // set Token(-s)
31  inputJetTagToken_ = consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("inputJetTag"));
32 
33  LogDebug("") << "Inputs: " << inputJetTag_.encode() << " ";
34 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string encode() const
Definition: InputTag.cc:159
edm::InputTag inputJetTag_
edm::EDGetTokenT< reco::CaloJetCollection > inputJetTagToken_
#define LogDebug(id)

Member Function Documentation

◆ alphaT()

double AlphaTVarProducer::alphaT ( const double  HT,
const double  DHT,
const double  MHT 
)
staticprivate

Definition at line 102 of file AlphaTVarProducer.cc.

References nanoDQM_cfi::MHT, and mathSSE::sqrt().

Referenced by CalcAlphaT(), and produce().

102  {
103  return 0.5 * (HT - DHT) / sqrt(HT * HT - MHT * MHT);
104 }
T sqrt(T t)
Definition: SSEVec.h:19
Definition: HT.h:21

◆ CalcAlphaT()

double AlphaTVarProducer::CalcAlphaT ( const std::vector< TLorentzVector > &  jets) const
private

Definition at line 66 of file AlphaTVarProducer.cc.

References alphaT(), CalcHT(), CalcMHT(), deltaHt(), mps_fire::i, PDWG_EXODelayedJetMET_cff::jets, and nanoDQM_cfi::MHT.

Referenced by produce().

66  {
67  std::vector<double> ETs;
68  TVector3 MHT{CalcMHT(jets), 0.0, 0.0};
69  float HT = CalcHT(jets);
70  // float HT = 0;
71  for (unsigned int i = 0; i < jets.size(); i++) {
72  if (jets[i].Et() > 50. && fabs(jets[i].Eta()) < 2.5)
73  ETs.push_back(jets[i].Et());
74  // HT += jets[i].Et();
75  }
76  if (ETs.size() < 2.)
77  return 0.0;
78  if (ETs.size() > 16.)
79  return 0.0;
80  float DHT = deltaHt(ETs);
81 
82  float AlphaT = alphaT(HT, DHT, MHT.Mag());
83 
84  return AlphaT;
85 }
static double CalcMHT(const std::vector< TLorentzVector > &)
static double alphaT(const double, const double, const double)
static double deltaHt(const std::vector< double > &)
static double CalcHT(const std::vector< TLorentzVector > &)
Definition: HT.h:21

◆ CalcHT()

double AlphaTVarProducer::CalcHT ( const std::vector< TLorentzVector > &  jets)
staticprivate

Definition at line 106 of file AlphaTVarProducer.cc.

References tmtt::Utility::HT, mps_fire::i, and PDWG_EXODelayedJetMET_cff::jets.

Referenced by CalcAlphaT(), and produce().

106  {
107  double HT = 0;
108  for (unsigned int i = 0; i < jets.size(); i++) {
109  if (jets[i].Et() > 50. && fabs(jets[i].Eta()) < 2.5)
110  HT += jets[i].Et();
111  }
112 
113  return HT;
114 }
Definition: HT.h:21

◆ CalcMHT()

double AlphaTVarProducer::CalcMHT ( const std::vector< TLorentzVector > &  jets)
staticprivate

Definition at line 116 of file AlphaTVarProducer.cc.

References mps_fire::i, PDWG_EXODelayedJetMET_cff::jets, and nanoDQM_cfi::MHT.

Referenced by CalcAlphaT().

116  {
117  TVector3 MHT;
118  for (unsigned int i = 0; i < jets.size(); i++) {
119  if (jets[i].Et() > 50. && fabs(jets[i].Eta()) < 2.5)
120  MHT -= jets[i].Vect();
121  }
122  MHT.SetZ(0.0);
123  return MHT.Mag();
124 }

◆ deltaHt()

double AlphaTVarProducer::deltaHt ( const std::vector< double > &  ETs)
staticprivate

Definition at line 87 of file AlphaTVarProducer.cc.

References change_name::diff, mps_fire::i, dqmiolumiharvest::j, and SiStripPI::min.

Referenced by CalcAlphaT().

87  {
88  if (ETs.size() > 16.)
89  return 9999999;
90  std::vector<double> diff(1 << (ETs.size() - 1), 0.);
91  for (unsigned i = 0; i < diff.size(); i++)
92  for (unsigned j = 0; j < ETs.size(); j++)
93  diff[i] += ETs[j] * (1 - 2 * (int(i >> j) & 1));
94  std::vector<double>::const_iterator it;
95  double min = 9999999;
96  for (it = diff.begin(); it != diff.end(); it++)
97  if (*it < min)
98  min = *it;
99  return min;
100 }

◆ produce()

void AlphaTVarProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overridevirtual

Implements edm::global::EDProducerBase.

Definition at line 37 of file AlphaTVarProducer.cc.

References alphaT(), CalcAlphaT(), CalcHT(), iEvent, inputJetTagToken_, edm::HandleBase::isValid(), dqmiolumiharvest::j, eostools::move(), and mps_fire::result.

37  {
38  using namespace std;
39  using namespace edm;
40  using namespace reco;
41 
42  // get hold of collection of objects
44  iEvent.getByToken(inputJetTagToken_, calojet_handle);
45 
46  std::unique_ptr<std::vector<double>> result(new std::vector<double>);
47  // check the the input collections are available
48  if (calojet_handle.isValid()) {
49  std::vector<TLorentzVector> myJets;
50  reco::CaloJetCollection::const_iterator jetIt;
51  for (jetIt = calojet_handle->begin(); jetIt != calojet_handle->end(); jetIt++) {
52  TLorentzVector j;
53  j.SetPtEtaPhiE(jetIt->pt(), jetIt->eta(), jetIt->phi(), jetIt->energy());
54  myJets.push_back(j);
55  }
56 
57  double alphaT = CalcAlphaT(myJets);
58  double HT = CalcHT(myJets);
59 
60  result->push_back(alphaT);
61  result->push_back(HT);
62  }
63  iEvent.put(std::move(result));
64 }
static double alphaT(const double, const double, const double)
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::CaloJetCollection > inputJetTagToken_
bool isValid() const
Definition: HandleBase.h:70
static double CalcHT(const std::vector< TLorentzVector > &)
fixed size matrix
HLT enums.
double CalcAlphaT(const std::vector< TLorentzVector > &) const
Definition: HT.h:21
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ inputJetTag_

edm::InputTag AlphaTVarProducer::inputJetTag_
private

Definition at line 29 of file AlphaTVarProducer.h.

Referenced by AlphaTVarProducer().

◆ inputJetTagToken_

edm::EDGetTokenT<reco::CaloJetCollection> AlphaTVarProducer::inputJetTagToken_
private

Definition at line 32 of file AlphaTVarProducer.h.

Referenced by AlphaTVarProducer(), and produce().