CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
EnergyRingsTableProducer Class Reference
Inheritance diagram for EnergyRingsTableProducer:
edm::stream::EDProducer<>

Public Member Functions

 EnergyRingsTableProducer (const edm::ParameterSet &iConfig)
 
 ~EnergyRingsTableProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, edm::EventSetup const &) override
 

Private Attributes

std::string name_
 
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 22 of file EnergyRingsTableProducer.cc.

Constructor & Destructor Documentation

◆ EnergyRingsTableProducer()

EnergyRingsTableProducer::EnergyRingsTableProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 24 of file EnergyRingsTableProducer.cc.

25  : name_(iConfig.getParameter<std::string>("name")),
26  srcJet_(consumes<edm::View<pat::Jet>>(iConfig.getParameter<edm::InputTag>("src"))) {
27  produces<nanoaod::FlatTable>();
28  }

◆ ~EnergyRingsTableProducer()

EnergyRingsTableProducer::~EnergyRingsTableProducer ( )
inlineoverride

Definition at line 30 of file EnergyRingsTableProducer.cc.

30 {};

Member Function Documentation

◆ fillDescriptions()

static void EnergyRingsTableProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
inlinestatic

Definition at line 32 of file EnergyRingsTableProducer.cc.

32  {
34  desc.add<edm::InputTag>("src")->setComment("input Jet collection");
35  desc.add<std::string>("name")->setComment("name of the Jet FlatTable we are extending with energy rings");
36  descriptions.add("EnergyRingsTable", desc);
37  }

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ produce()

void EnergyRingsTableProducer::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivate

Definition at line 47 of file EnergyRingsTableProducer.cc.

47  {
49  iEvent.getByToken(srcJet_, srcJet);
50 
51  float cone_boundaries[] = {0.05, 0.1, 0.2, 0.3, 0.4};
52  size_t ncone_boundaries = sizeof(cone_boundaries) / sizeof(float);
53  unsigned int nJet = srcJet->size();
54  unsigned int ncand = 0;
55  std::vector<float> numdaughterspt03;
56  std::vector<std::vector<float>> EmFractionEnergyRings(ncone_boundaries + 1, std::vector<float>(nJet, 0.));
57  std::vector<std::vector<float>> ChFractionEnergyRings(ncone_boundaries + 1, std::vector<float>(nJet, 0.));
58  std::vector<std::vector<float>> NeFractionEnergyRings(ncone_boundaries + 1, std::vector<float>(nJet, 0.));
59  std::vector<std::vector<float>> MuFractionEnergyRings(ncone_boundaries + 1, std::vector<float>(nJet, 0.));
60 
61  for (unsigned int ij = 0; ij < nJet; ij++) {
62  ++ncand;
63  auto jet = srcJet->ptrAt(ij);
64  int numDaughtersPt03 = 0;
65  for (unsigned int ijcone = 0; ijcone < ncone_boundaries; ijcone++) {
66  EmFractionEnergyRings[ijcone][ij] = 0;
67  MuFractionEnergyRings[ijcone][ij] = 0;
68  ChFractionEnergyRings[ijcone][ij] = 0;
69  NeFractionEnergyRings[ijcone][ij] = 0;
70  }
71  for (const auto& d : jet->daughterPtrVector()) {
72  float candDr = Geom::deltaR(d->p4(), jet->p4());
73  size_t icone =
74  std::lower_bound(&cone_boundaries[0], &cone_boundaries[ncone_boundaries], candDr) - &cone_boundaries[0];
75  float candEnergy = d->energy();
76  int pdgid = abs(d->pdgId());
77  if (pdgid == 22 || pdgid == 11) {
78  EmFractionEnergyRings[icone][ij] += candEnergy;
79  } else if (pdgid == 13) {
80  MuFractionEnergyRings[icone][ij] += candEnergy;
81  } else if (d->charge() != 0) {
82  ChFractionEnergyRings[icone][ij] += candEnergy;
83  } else {
84  NeFractionEnergyRings[icone][ij] += candEnergy;
85  }
86  if (d->pt() > 0.3)
87  numDaughtersPt03 += 1;
88  } // end of jet daughters loop
89  numdaughterspt03.push_back(numDaughtersPt03);
90  } //end of jet loop
91  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true); //extension to Jet collection set to true
92  tab->addColumn<int>(
93  "numDaughtersPt03", numdaughterspt03, "number of jet daughters with pT>0.3 GeV", nanoaod::FlatTable::IntColumn);
94 
95  tab->addColumn<float>("EmFractionEnergyRing0",
96  EmFractionEnergyRings[0],
97  "Em energy fraction in ring in dR 0-0.05",
99  tab->addColumn<float>("EmFractionEnergyRing1",
100  EmFractionEnergyRings[1],
101  "Em energy fraction in ring in dR 0.05-0.1",
103  tab->addColumn<float>("EmFractionEnergyRing2",
104  EmFractionEnergyRings[2],
105  "Em energy fraction in ring in dR 0.1-0.2",
107  tab->addColumn<float>("EmFractionEnergyRing3",
108  EmFractionEnergyRings[3],
109  "Em energy fraction in ring in dR 0.2-0.3",
111  tab->addColumn<float>("EmFractionEnergyRing4",
112  EmFractionEnergyRings[4],
113  "Em energy fraction in ring in dR 0.3-0.4",
115  tab->addColumn<float>("EmFractionEnergyRing5",
116  EmFractionEnergyRings[5],
117  "Em energy fraction in ring in dR 0.4 overflow",
119 
120  tab->addColumn<float>("ChFractionEnergyRing0",
121  ChFractionEnergyRings[0],
122  "Ch energy fraction in ring in dR 0-0.05",
124  tab->addColumn<float>("ChFractionEnergyRing1",
125  ChFractionEnergyRings[1],
126  "Ch energy fraction in ring in dR 0.05-0.1",
128  tab->addColumn<float>("ChFractionEnergyRing2",
129  ChFractionEnergyRings[2],
130  "Ch energy fraction in ring in dR 0.1-0.2",
132  tab->addColumn<float>("ChFractionEnergyRing3",
133  ChFractionEnergyRings[3],
134  "Ch energy fraction in ring in dR 0.2-0.3",
136  tab->addColumn<float>("ChFractionEnergyRing4",
137  ChFractionEnergyRings[4],
138  "Ch energy fraction in ring in dR 0.3-0.4",
140  tab->addColumn<float>("ChFractionEnergyRing5",
141  ChFractionEnergyRings[5],
142  "Ch energy fraction in ring in dR 0.4 overflow",
144 
145  tab->addColumn<float>("MuFractionEnergyRing0",
146  MuFractionEnergyRings[0],
147  "Mu energy fraction in ring in dR 0-0.05",
149  tab->addColumn<float>("MuFractionEnergyRing1",
150  MuFractionEnergyRings[1],
151  "Mu energy fraction in ring in dR 0.05-0.1",
153  tab->addColumn<float>("MuFractionEnergyRing2",
154  MuFractionEnergyRings[2],
155  "Mu energy fraction in ring in dR 0.1-0.2",
157  tab->addColumn<float>("MuFractionEnergyRing3",
158  MuFractionEnergyRings[3],
159  "Mu energy fraction in ring in dR 0.2-0.3",
161  tab->addColumn<float>("MuFractionEnergyRing4",
162  MuFractionEnergyRings[4],
163  "Mu energy fraction in ring in dR 0.3-0.4",
165  tab->addColumn<float>("MuFractionEnergyRing5",
166  MuFractionEnergyRings[5],
167  "Mu energy fraction in ring in dR 0.4 overflow",
169 
170  tab->addColumn<float>("NeFractionEnergyRing0",
171  NeFractionEnergyRings[0],
172  "Ne energy fraction in ring in dR 0-0.05",
174  tab->addColumn<float>("NeFractionEnergyRing1",
175  NeFractionEnergyRings[1],
176  "Ne energy fraction in ring in dR 0.05-0.1",
178  tab->addColumn<float>("NeFractionEnergyRing2",
179  NeFractionEnergyRings[2],
180  "Ne energy fraction in ring in dR 0.1-0.2",
182  tab->addColumn<float>("NeFractionEnergyRing3",
183  NeFractionEnergyRings[3],
184  "Ne energy fraction in ring in dR 0.2-0.3",
186  tab->addColumn<float>("NeFractionEnergyRing4",
187  NeFractionEnergyRings[4],
188  "Ne energy fraction in ring in dR 0.3-0.4",
190  tab->addColumn<float>("NeFractionEnergyRing5",
191  NeFractionEnergyRings[5],
192  "Ne energy fraction in ring in dR 0.4 overflow",
194 
195  iEvent.put(std::move(tab));
196 }

References funct::abs(), ztail::d, PbPb_ZMuSkimMuonDPG_cff::deltaR, nanoaod::FlatTable::FloatColumn, iEvent, nanoaod::FlatTable::IntColumn, metsig::jet, cuda_std::lower_bound(), eostools::move(), name_, EgammaValidation_cff::pdgid, electrons_cff::srcJet, and srcJet_.

Member Data Documentation

◆ name_

std::string EnergyRingsTableProducer::name_
private

Definition at line 42 of file EnergyRingsTableProducer.cc.

Referenced by produce().

◆ srcJet_

edm::EDGetTokenT<edm::View<pat::Jet> > EnergyRingsTableProducer::srcJet_
private

Definition at line 43 of file EnergyRingsTableProducer.cc.

Referenced by produce().

nanoaod::FlatTable::FloatColumn
Definition: FlatTable.h:39
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EnergyRingsTableProducer::name_
std::string name_
Definition: EnergyRingsTableProducer.cc:42
edm::Handle
Definition: AssociativeIterator.h:50
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
nanoaod::FlatTable::IntColumn
Definition: FlatTable.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
metsig::jet
Definition: SignAlgoResolutions.h:47
electrons_cff.srcJet
srcJet
Definition: electrons_cff.py:157
EnergyRingsTableProducer::srcJet_
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
Definition: EnergyRingsTableProducer.cc:43
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:30
edm::InputTag
Definition: InputTag.h:15