CMS 3D CMS Logo

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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 24 of file EnergyRingsTableProducer.cc.

24  :
25  name_(iConfig.getParameter<std::string>("name")),
26  srcJet_(consumes<edm::View<pat::Jet>>(iConfig.getParameter<edm::InputTag>("src")))
27  {
28  produces<nanoaod::FlatTable>();
29  }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
EnergyRingsTableProducer::~EnergyRingsTableProducer ( )
inlineoverride

Definition at line 31 of file EnergyRingsTableProducer.cc.

31 {};

Member Function Documentation

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

Definition at line 33 of file EnergyRingsTableProducer.cc.

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

33  {
35  desc.add<edm::InputTag>("src")->setComment("input Jet collection");
36  desc.add<std::string>("name")->setComment("name of the Jet FlatTable we are extending with energy rings");
37  descriptions.add("EnergyRingsTable", desc);
38  }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void EnergyRingsTableProducer::produce ( edm::Event ,
edm::EventSetup const &   
)
overrideprivate

Definition at line 50 of file EnergyRingsTableProducer.cc.

References funct::abs(), edmIntegrityCheck::d, DEFINE_FWK_MODULE, deltaR(), nanoaod::FlatTable::FloatColumn, edm::Event::getByToken(), nanoaod::FlatTable::IntColumn, metsig::jet, eostools::move(), name_, BPhysicsValidation_cfi::pdgid, edm::Event::put(), electrons_cff::srcJet, and srcJet_.

Referenced by fillDescriptions().

51 {
53  iEvent.getByToken(srcJet_, srcJet);
54 
55 
56  float cone_boundaries[] = { 0.05, 0.1, 0.2, 0.3,0.4 };
57  size_t ncone_boundaries = sizeof(cone_boundaries)/sizeof(float);
58  unsigned int nJet = srcJet->size();
59  unsigned int ncand = 0;
60  std::vector<float> numdaughterspt03;
61  std::vector<std::vector<float>> EmFractionEnergyRings(ncone_boundaries+1,std::vector<float>(nJet, 0.));
62  std::vector<std::vector<float>> ChFractionEnergyRings(ncone_boundaries+1,std::vector<float>(nJet, 0.));
63  std::vector<std::vector<float>> NeFractionEnergyRings(ncone_boundaries+1,std::vector<float>(nJet, 0.));
64  std::vector<std::vector<float>> MuFractionEnergyRings(ncone_boundaries+1,std::vector<float>(nJet, 0.));
65 
66  for (unsigned int ij = 0; ij<nJet; ij++){
67  ++ncand;
68  auto jet = srcJet->ptrAt(ij);
69  int numDaughtersPt03=0;
70  for (unsigned int ijcone = 0; ijcone<ncone_boundaries; ijcone++){
71  EmFractionEnergyRings[ijcone][ij] = 0;
72  MuFractionEnergyRings[ijcone][ij] = 0;
73  ChFractionEnergyRings[ijcone][ij] = 0;
74  NeFractionEnergyRings[ijcone][ij] = 0;
75  }
76  for(const auto & d : jet->daughterPtrVector()){
77  float candDr = Geom::deltaR(d->p4(),jet->p4());
78  size_t icone = std::lower_bound(&cone_boundaries[0],&cone_boundaries[ncone_boundaries],candDr) - &cone_boundaries[0];
79  float candEnergy = d->energy();
80  int pdgid = abs(d->pdgId()) ;
81  if( pdgid == 22 || pdgid == 11 ) {
82  EmFractionEnergyRings[icone][ij] += candEnergy;
83  } else if ( pdgid == 13 ) {
84  MuFractionEnergyRings[icone][ij] += candEnergy;
85  } else if ( d->charge() != 0 ) {
86  ChFractionEnergyRings[icone][ij] += candEnergy;
87  } else {
88  NeFractionEnergyRings[icone][ij] += candEnergy;
89  }
90  if(d->pt()>0.3) numDaughtersPt03+=1;
91  } // end of jet daughters loop
92  numdaughterspt03.push_back(numDaughtersPt03);
93  }//end of jet loop
94  auto tab = std::make_unique<nanoaod::FlatTable>(ncand, name_, false, true);//extension to Jet collection set to true
95  tab->addColumn<int>("numDaughtersPt03", numdaughterspt03, "number of jet daughters with pT>0.3 GeV", nanoaod::FlatTable::IntColumn);
96 
97  tab->addColumn<float>("EmFractionEnergyRing0", EmFractionEnergyRings[0], "Em energy fraction in ring in dR 0-0.05", nanoaod::FlatTable::FloatColumn);
98  tab->addColumn<float>("EmFractionEnergyRing1", EmFractionEnergyRings[1], "Em energy fraction in ring in dR 0.05-0.1", nanoaod::FlatTable::FloatColumn);
99  tab->addColumn<float>("EmFractionEnergyRing2", EmFractionEnergyRings[2], "Em energy fraction in ring in dR 0.1-0.2", nanoaod::FlatTable::FloatColumn);
100  tab->addColumn<float>("EmFractionEnergyRing3", EmFractionEnergyRings[3], "Em energy fraction in ring in dR 0.2-0.3", nanoaod::FlatTable::FloatColumn);
101  tab->addColumn<float>("EmFractionEnergyRing4", EmFractionEnergyRings[4], "Em energy fraction in ring in dR 0.3-0.4", nanoaod::FlatTable::FloatColumn);
102  tab->addColumn<float>("EmFractionEnergyRing5", EmFractionEnergyRings[5], "Em energy fraction in ring in dR 0.4 overflow", nanoaod::FlatTable::FloatColumn);
103 
104  tab->addColumn<float>("ChFractionEnergyRing0", ChFractionEnergyRings[0], "Ch energy fraction in ring in dR 0-0.05", nanoaod::FlatTable::FloatColumn);
105  tab->addColumn<float>("ChFractionEnergyRing1", ChFractionEnergyRings[1], "Ch energy fraction in ring in dR 0.05-0.1", nanoaod::FlatTable::FloatColumn);
106  tab->addColumn<float>("ChFractionEnergyRing2", ChFractionEnergyRings[2], "Ch energy fraction in ring in dR 0.1-0.2", nanoaod::FlatTable::FloatColumn);
107  tab->addColumn<float>("ChFractionEnergyRing3", ChFractionEnergyRings[3], "Ch energy fraction in ring in dR 0.2-0.3", nanoaod::FlatTable::FloatColumn);
108  tab->addColumn<float>("ChFractionEnergyRing4", ChFractionEnergyRings[4], "Ch energy fraction in ring in dR 0.3-0.4", nanoaod::FlatTable::FloatColumn);
109  tab->addColumn<float>("ChFractionEnergyRing5", ChFractionEnergyRings[5], "Ch energy fraction in ring in dR 0.4 overflow", nanoaod::FlatTable::FloatColumn);
110 
111  tab->addColumn<float>("MuFractionEnergyRing0", MuFractionEnergyRings[0], "Mu energy fraction in ring in dR 0-0.05", nanoaod::FlatTable::FloatColumn);
112  tab->addColumn<float>("MuFractionEnergyRing1", MuFractionEnergyRings[1], "Mu energy fraction in ring in dR 0.05-0.1", nanoaod::FlatTable::FloatColumn);
113  tab->addColumn<float>("MuFractionEnergyRing2", MuFractionEnergyRings[2], "Mu energy fraction in ring in dR 0.1-0.2", nanoaod::FlatTable::FloatColumn);
114  tab->addColumn<float>("MuFractionEnergyRing3", MuFractionEnergyRings[3], "Mu energy fraction in ring in dR 0.2-0.3", nanoaod::FlatTable::FloatColumn);
115  tab->addColumn<float>("MuFractionEnergyRing4", MuFractionEnergyRings[4], "Mu energy fraction in ring in dR 0.3-0.4", nanoaod::FlatTable::FloatColumn);
116  tab->addColumn<float>("MuFractionEnergyRing5", MuFractionEnergyRings[5], "Mu energy fraction in ring in dR 0.4 overflow", nanoaod::FlatTable::FloatColumn);
117 
118  tab->addColumn<float>("NeFractionEnergyRing0", NeFractionEnergyRings[0], "Ne energy fraction in ring in dR 0-0.05", nanoaod::FlatTable::FloatColumn);
119  tab->addColumn<float>("NeFractionEnergyRing1", NeFractionEnergyRings[1], "Ne energy fraction in ring in dR 0.05-0.1", nanoaod::FlatTable::FloatColumn);
120  tab->addColumn<float>("NeFractionEnergyRing2", NeFractionEnergyRings[2], "Ne energy fraction in ring in dR 0.1-0.2", nanoaod::FlatTable::FloatColumn);
121  tab->addColumn<float>("NeFractionEnergyRing3", NeFractionEnergyRings[3], "Ne energy fraction in ring in dR 0.2-0.3", nanoaod::FlatTable::FloatColumn);
122  tab->addColumn<float>("NeFractionEnergyRing4", NeFractionEnergyRings[4], "Ne energy fraction in ring in dR 0.3-0.4", nanoaod::FlatTable::FloatColumn);
123  tab->addColumn<float>("NeFractionEnergyRing5", NeFractionEnergyRings[5], "Ne energy fraction in ring in dR 0.4 overflow", nanoaod::FlatTable::FloatColumn);
124 
125  iEvent.put(std::move(tab));
126 }
edm::EDGetTokenT< edm::View< pat::Jet > > srcJet_
int iEvent
Definition: GenABIO.cc:230
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::string EnergyRingsTableProducer::name_
private

Definition at line 43 of file EnergyRingsTableProducer.cc.

Referenced by produce().

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

Definition at line 44 of file EnergyRingsTableProducer.cc.

Referenced by produce().