CMS 3D CMS Logo

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

#include <Calibration/IsolatedParticles/plugins/IsolatedParticlesGeneratedJets.cc>

Inheritance diagram for IsolatedParticlesGeneratedJets:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 IsolatedParticlesGeneratedJets (const edm::ParameterSet &)
 
 ~IsolatedParticlesGeneratedJets () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void BookHistograms ()
 
void clearTreeVectors ()
 
void endJob () override
 

Private Attributes

bool debug
 
edm::Service< TFileServicefs
 
std::vector< double > * t_gjetE
 
std::vector< double > * t_gjetEta
 
std::vector< int > * t_gjetN
 
std::vector< double > * t_gjetPhi
 
std::vector< double > * t_gjetPt
 
std::vector< std::vector< double > > * t_jetTrkCharge
 
std::vector< std::vector< double > > * t_jetTrkEta
 
std::vector< std::vector< double > > * t_jetTrkP
 
std::vector< std::vector< double > > * t_jetTrkPdg
 
std::vector< std::vector< double > > * t_jetTrkPhi
 
std::vector< std::vector< double > > * t_jetTrkPt
 
edm::EDGetTokenT< reco::GenJetCollectiontok_jets_
 
edm::EDGetTokenT< reco::GenParticleCollectiontok_parts_
 
TTree * tree
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 35 of file IsolatedParticlesGeneratedJets.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file IsolatedParticlesGeneratedJets.cc.

References debug, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), tok_jets_, and tok_parts_.

22  {
23 
24  debug = iConfig.getUntrackedParameter<bool> ("Debug", false);
25  tok_jets_ = consumes<reco::GenJetCollection>(iConfig.getParameter<edm::InputTag>("JetSource"));
26  tok_parts_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("ParticleSource"));
27 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::GenParticleCollection > tok_parts_
edm::EDGetTokenT< reco::GenJetCollection > tok_jets_
IsolatedParticlesGeneratedJets::~IsolatedParticlesGeneratedJets ( )
override

Definition at line 30 of file IsolatedParticlesGeneratedJets.cc.

30  {
31 
32 }

Member Function Documentation

void IsolatedParticlesGeneratedJets::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 34 of file IsolatedParticlesGeneratedJets.cc.

References funct::abs(), ALCARECOTkAlJpsiMuMu_cff::charge, clearTreeVectors(), edm::EDConsumerBase::consumesCollector(), gather_cfg::cout, debug, reco::LeafCandidate::energy(), PVValHelper::eta, reco::LeafCandidate::eta(), ttbarCategorization_cff::genJets, GenHFHadronMatcher_cfi::genParticles, edm::Event::getByToken(), JetMatchingTools::getGenParticles(), AlCaHLTBitMon_ParallelJobs::p, common_cff::pdgId, phi, reco::LeafCandidate::phi(), EnergyCorrector::pt, reco::LeafCandidate::pt(), t_gjetE, t_gjetEta, t_gjetN, t_gjetPhi, t_gjetPt, t_jetTrkCharge, t_jetTrkEta, t_jetTrkP, t_jetTrkPdg, t_jetTrkPhi, t_jetTrkPt, tok_jets_, and tok_parts_.

34  {
35 
36  //using namespace edm;
38 
39  //=== genJet information
41  iEvent.getByToken(tok_jets_, genJets);
42 
43  //=== genJet information
45  iEvent.getByToken(tok_parts_, genParticles);
46 
47  JetMatchingTools jetMatching (iEvent, consumesCollector());
48  std::vector <std::vector <const reco::GenParticle*> > genJetConstituents (genJets->size());
49 
50  int njets = 0;
51  for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {
52  const reco::GenJet& genJet = (*genJets) [iGenJet];
53 
54  double genJetE = genJet.energy();
55  double genJetPt = genJet.pt();
56  double genJetEta = genJet.eta();
57  double genJetPhi = genJet.phi();
58 
59  if( genJetPt> 30.0 && std::abs(genJetEta)<3.0 ) {
60 
61  njets++;
62 
63  std::vector <const reco::GenParticle*> genJetConstituents = jetMatching.getGenParticles ((*genJets) [iGenJet]);
64 
65  std::vector<double> v_trkP, v_trkPt, v_trkEta, v_trkPhi, v_trkPdg, v_trkCharge;
66 
67  if(debug) std::cout<<"Jet(pt,Eta,Phi) "<<genJetPt<<" "<<genJetEta<<" "<<genJetPhi <<std::endl;
68  for(unsigned int ic=0; ic<genJetConstituents.size(); ic++) {
69 
70  if(debug) {
71  std::cout << "p,pt,eta,phi "<<genJetConstituents[ic]->p()<<" "<<genJetConstituents[ic]->pt()
72  <<" "<<genJetConstituents[ic]->eta()<<" "<<genJetConstituents[ic]->phi()
73  <<std::endl;
74  }
75 
76  v_trkP.push_back(genJetConstituents[ic]->p());
77  v_trkPt.push_back(genJetConstituents[ic]->pt());
78  v_trkEta.push_back(genJetConstituents[ic]->eta());
79  v_trkPhi.push_back(genJetConstituents[ic]->phi());
80  v_trkPdg.push_back(genJetConstituents[ic]->pdgId());
81  v_trkCharge.push_back(genJetConstituents[ic]->charge());
82 
83  } //loop over genjet constituents
84 
85  t_gjetE ->push_back(genJetE );
86  t_gjetPt ->push_back(genJetPt );
87  t_gjetEta ->push_back(genJetEta);
88  t_gjetPhi ->push_back(genJetPhi);
89 
90  t_jetTrkP ->push_back(v_trkP );
91  t_jetTrkPt ->push_back(v_trkPt );
92  t_jetTrkEta ->push_back(v_trkEta);
93  t_jetTrkPhi ->push_back(v_trkPhi);
94  t_jetTrkPdg ->push_back(v_trkPdg);
95  t_jetTrkCharge ->push_back(v_trkCharge);
96 
97  } // if jetPt>30
98 
99  } //loop over genjets
100 
101  t_gjetN->push_back(njets);
102 
103  unsigned int indx = 0;
104  for(reco::GenParticleCollection::const_iterator ig = genParticles->begin(); ig!= genParticles->end(); ++ig,++indx) {
105 
106  if (debug)
107  std::cout << "Track " << indx << " Status " << ig->status() << " charge "
108  << ig->charge() << " pdgId " << ig->pdgId() << " mass "
109  << ig->mass() << " P " << ig->momentum() << " E "
110  << ig->energy() << " Origin " << ig->vertex() << std::endl;
111  }
112 
113 
114  tree->Fill();
115 }
std::vector< std::vector< double > > * t_jetTrkEta
double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
double pt() const final
transverse momentum
edm::EDGetTokenT< reco::GenParticleCollection > tok_parts_
std::vector< std::vector< double > > * t_jetTrkPdg
std::vector< std::vector< double > > * t_jetTrkPhi
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
double energy() const final
energy
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Jets made from MC generator particles.
Definition: GenJet.h:24
std::vector< std::vector< double > > * t_jetTrkPt
std::vector< std::vector< double > > * t_jetTrkCharge
edm::EDGetTokenT< reco::GenJetCollection > tok_jets_
std::vector< std::vector< double > > * t_jetTrkP
Definition: tree.py:1
double phi() const final
momentum azimuthal angle
void IsolatedParticlesGeneratedJets::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 117 of file IsolatedParticlesGeneratedJets.cc.

References BookHistograms().

117  {
118 
119  BookHistograms();
120 
121 }
void IsolatedParticlesGeneratedJets::BookHistograms ( )
private

Definition at line 138 of file IsolatedParticlesGeneratedJets.cc.

References fs, TFileService::make(), t_gjetE, t_gjetEta, t_gjetN, t_gjetPhi, t_gjetPt, t_jetTrkCharge, t_jetTrkEta, t_jetTrkP, t_jetTrkPdg, t_jetTrkPhi, and t_jetTrkPt.

Referenced by beginJob().

138  {
139 
140  tree = fs->make<TTree>("tree", "tree");
141 
142  t_gjetN = new std::vector<int> ();
143  t_gjetE = new std::vector<double>();
144  t_gjetPt = new std::vector<double>();
145  t_gjetEta = new std::vector<double>();
146  t_gjetPhi = new std::vector<double>();
147 
148  t_jetTrkP = new std::vector<std::vector<double> >();
149  t_jetTrkPt = new std::vector<std::vector<double> >();
150  t_jetTrkEta = new std::vector<std::vector<double> >();
151  t_jetTrkPhi = new std::vector<std::vector<double> >();
152  t_jetTrkPdg = new std::vector<std::vector<double> >();
153  t_jetTrkCharge = new std::vector<std::vector<double> >();
154 
155  tree->Branch("t_gjetN", "vector<int>", &t_gjetN);
156  tree->Branch("t_gjetE", "vector<double>", &t_gjetE);
157  tree->Branch("t_gjetPt", "vector<double>", &t_gjetPt);
158  tree->Branch("t_gjetEta", "vector<double>", &t_gjetEta);
159  tree->Branch("t_gjetPhi", "vector<double>", &t_gjetPhi);
160 
161  tree->Branch("t_jetTrkP", "vector<vector<double> >", &t_jetTrkP);
162  tree->Branch("t_jetTrkPt", "vector<vector<double> >", &t_jetTrkPt);
163  tree->Branch("t_jetTrkEta", "vector<vector<double> >", &t_jetTrkEta);
164  tree->Branch("t_jetTrkPhi", "vector<vector<double> >", &t_jetTrkPhi);
165  tree->Branch("t_jetTrkPdg", "vector<vector<double> >", &t_jetTrkPdg);
166  tree->Branch("t_jetTrkCharge", "vector<vector<double> >", &t_jetTrkCharge);
167 
168 }
std::vector< std::vector< double > > * t_jetTrkEta
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
std::vector< std::vector< double > > * t_jetTrkPdg
std::vector< std::vector< double > > * t_jetTrkPhi
std::vector< std::vector< double > > * t_jetTrkPt
std::vector< std::vector< double > > * t_jetTrkCharge
std::vector< std::vector< double > > * t_jetTrkP
Definition: tree.py:1
void IsolatedParticlesGeneratedJets::clearTreeVectors ( )
private

Definition at line 123 of file IsolatedParticlesGeneratedJets.cc.

References t_gjetE, t_gjetEta, t_gjetN, t_gjetPhi, t_gjetPt, t_jetTrkCharge, t_jetTrkEta, t_jetTrkP, t_jetTrkPdg, t_jetTrkPhi, and t_jetTrkPt.

Referenced by analyze().

123  {
124  t_gjetN ->clear();
125  t_gjetE ->clear();
126  t_gjetPt ->clear();
127  t_gjetEta ->clear();
128  t_gjetPhi ->clear();
129 
130  t_jetTrkP ->clear();
131  t_jetTrkPt ->clear();
132  t_jetTrkEta ->clear();
133  t_jetTrkPhi ->clear();
134  t_jetTrkPdg ->clear();
135  t_jetTrkCharge ->clear();
136 }
std::vector< std::vector< double > > * t_jetTrkEta
std::vector< std::vector< double > > * t_jetTrkPdg
std::vector< std::vector< double > > * t_jetTrkPhi
std::vector< std::vector< double > > * t_jetTrkPt
std::vector< std::vector< double > > * t_jetTrkCharge
std::vector< std::vector< double > > * t_jetTrkP
void IsolatedParticlesGeneratedJets::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 170 of file IsolatedParticlesGeneratedJets.cc.

References DEFINE_FWK_MODULE.

Referenced by o2olib.O2ORunMgr::executeJob().

170  {
171 }

Member Data Documentation

bool IsolatedParticlesGeneratedJets::debug
private
edm::Service<TFileService> IsolatedParticlesGeneratedJets::fs
private

Definition at line 50 of file IsolatedParticlesGeneratedJets.h.

Referenced by BookHistograms().

std::vector<double>* IsolatedParticlesGeneratedJets::t_gjetE
private

Definition at line 57 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector<double> * IsolatedParticlesGeneratedJets::t_gjetEta
private

Definition at line 57 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector<int>* IsolatedParticlesGeneratedJets::t_gjetN
private

Definition at line 56 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector<double> * IsolatedParticlesGeneratedJets::t_gjetPhi
private

Definition at line 57 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector<double> * IsolatedParticlesGeneratedJets::t_gjetPt
private

Definition at line 57 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector< std::vector<double> >* IsolatedParticlesGeneratedJets::t_jetTrkCharge
private

Definition at line 63 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector< std::vector<double> >* IsolatedParticlesGeneratedJets::t_jetTrkEta
private

Definition at line 60 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector< std::vector<double> >* IsolatedParticlesGeneratedJets::t_jetTrkP
private

Definition at line 58 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector< std::vector<double> >* IsolatedParticlesGeneratedJets::t_jetTrkPdg
private

Definition at line 62 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector< std::vector<double> >* IsolatedParticlesGeneratedJets::t_jetTrkPhi
private

Definition at line 61 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

std::vector< std::vector<double> >* IsolatedParticlesGeneratedJets::t_jetTrkPt
private

Definition at line 59 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), BookHistograms(), and clearTreeVectors().

edm::EDGetTokenT<reco::GenJetCollection> IsolatedParticlesGeneratedJets::tok_jets_
private

Definition at line 53 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), and IsolatedParticlesGeneratedJets().

edm::EDGetTokenT<reco::GenParticleCollection> IsolatedParticlesGeneratedJets::tok_parts_
private

Definition at line 54 of file IsolatedParticlesGeneratedJets.h.

Referenced by analyze(), and IsolatedParticlesGeneratedJets().

TTree* IsolatedParticlesGeneratedJets::tree
private