CMS 3D CMS Logo

EnergyRingsTableProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
7 
9 
13 
16 
18 
21 
23 public:
25  : name_(iConfig.getParameter<std::string>("name")),
26  srcJet_(consumes<edm::View<pat::Jet>>(iConfig.getParameter<edm::InputTag>("src"))) {
27  produces<nanoaod::FlatTable>();
28  }
29 
31 
32  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
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  }
38 
39 private:
40  void produce(edm::Event&, edm::EventSetup const&) override;
41 
44 };
45 
46 // ------------ method called to produce the data ------------
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>("numDaughtersPt03", numdaughterspt03, "number of jet daughters with pT>0.3 GeV");
93 
94  tab->addColumn<float>("EmFractionEnergyRing0", EmFractionEnergyRings[0], "Em energy fraction in ring in dR 0-0.05");
95  tab->addColumn<float>("EmFractionEnergyRing1", EmFractionEnergyRings[1], "Em energy fraction in ring in dR 0.05-0.1");
96  tab->addColumn<float>("EmFractionEnergyRing2", EmFractionEnergyRings[2], "Em energy fraction in ring in dR 0.1-0.2");
97  tab->addColumn<float>("EmFractionEnergyRing3", EmFractionEnergyRings[3], "Em energy fraction in ring in dR 0.2-0.3");
98  tab->addColumn<float>("EmFractionEnergyRing4", EmFractionEnergyRings[4], "Em energy fraction in ring in dR 0.3-0.4");
99  tab->addColumn<float>(
100  "EmFractionEnergyRing5", EmFractionEnergyRings[5], "Em energy fraction in ring in dR 0.4 overflow");
101 
102  tab->addColumn<float>("ChFractionEnergyRing0", ChFractionEnergyRings[0], "Ch energy fraction in ring in dR 0-0.05");
103  tab->addColumn<float>("ChFractionEnergyRing1", ChFractionEnergyRings[1], "Ch energy fraction in ring in dR 0.05-0.1");
104  tab->addColumn<float>("ChFractionEnergyRing2", ChFractionEnergyRings[2], "Ch energy fraction in ring in dR 0.1-0.2");
105  tab->addColumn<float>("ChFractionEnergyRing3", ChFractionEnergyRings[3], "Ch energy fraction in ring in dR 0.2-0.3");
106  tab->addColumn<float>("ChFractionEnergyRing4", ChFractionEnergyRings[4], "Ch energy fraction in ring in dR 0.3-0.4");
107  tab->addColumn<float>(
108  "ChFractionEnergyRing5", ChFractionEnergyRings[5], "Ch energy fraction in ring in dR 0.4 overflow");
109 
110  tab->addColumn<float>("MuFractionEnergyRing0", MuFractionEnergyRings[0], "Mu energy fraction in ring in dR 0-0.05");
111  tab->addColumn<float>("MuFractionEnergyRing1", MuFractionEnergyRings[1], "Mu energy fraction in ring in dR 0.05-0.1");
112  tab->addColumn<float>("MuFractionEnergyRing2", MuFractionEnergyRings[2], "Mu energy fraction in ring in dR 0.1-0.2");
113  tab->addColumn<float>("MuFractionEnergyRing3", MuFractionEnergyRings[3], "Mu energy fraction in ring in dR 0.2-0.3");
114  tab->addColumn<float>("MuFractionEnergyRing4", MuFractionEnergyRings[4], "Mu energy fraction in ring in dR 0.3-0.4");
115  tab->addColumn<float>(
116  "MuFractionEnergyRing5", MuFractionEnergyRings[5], "Mu energy fraction in ring in dR 0.4 overflow");
117 
118  tab->addColumn<float>("NeFractionEnergyRing0", NeFractionEnergyRings[0], "Ne energy fraction in ring in dR 0-0.05");
119  tab->addColumn<float>("NeFractionEnergyRing1", NeFractionEnergyRings[1], "Ne energy fraction in ring in dR 0.05-0.1");
120  tab->addColumn<float>("NeFractionEnergyRing2", NeFractionEnergyRings[2], "Ne energy fraction in ring in dR 0.1-0.2");
121  tab->addColumn<float>("NeFractionEnergyRing3", NeFractionEnergyRings[3], "Ne energy fraction in ring in dR 0.2-0.3");
122  tab->addColumn<float>("NeFractionEnergyRing4", NeFractionEnergyRings[4], "Ne energy fraction in ring in dR 0.3-0.4");
123  tab->addColumn<float>(
124  "NeFractionEnergyRing5", NeFractionEnergyRings[5], "Ne energy fraction in ring in dR 0.4 overflow");
125 
126  iEvent.put(std::move(tab));
127 }
128 
130 //define this as a plug-in
ConfigurationDescriptions.h
sistrip::View
View
Definition: ConstantsForView.h:26
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EnergyRingsTableProducer::name_
std::string name_
Definition: EnergyRingsTableProducer.cc:42
EnergyRingsTableProducer
Definition: EnergyRingsTableProducer.cc:22
EDProducer.h
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Jet
Definition: Jet.py:1
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
ParameterSetDescription.h
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EnergyRingsTableProducer::produce
void produce(edm::Event &, edm::EventSetup const &) override
Definition: EnergyRingsTableProducer.cc:47
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
iEvent
int iEvent
Definition: GenABIO.cc:224
EnergyRingsTableProducer::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: EnergyRingsTableProducer.cc:32
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
Jet.h
FlatTable.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
StringCutObjectSelector.h
EnergyRingsTableProducer::EnergyRingsTableProducer
EnergyRingsTableProducer(const edm::ParameterSet &iConfig)
Definition: EnergyRingsTableProducer.cc:24
Frameworkfwd.h
metsig::jet
Definition: SignAlgoResolutions.h:47
electrons_cff.srcJet
srcJet
Definition: electrons_cff.py:158
EnergyRingsTableProducer::srcJet_
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
Definition: EnergyRingsTableProducer.cc:43
EnergyRingsTableProducer::~EnergyRingsTableProducer
~EnergyRingsTableProducer() override
Definition: EnergyRingsTableProducer.cc:30
ztail.d
d
Definition: ztail.py:151
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
edm::Event
Definition: Event.h:73
EgammaValidation_cff.pdgid
pdgid
Definition: EgammaValidation_cff.py:30
StringObjectFunction.h
edm::InputTag
Definition: InputTag.h:15