CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsolatedParticlesGeneratedJets.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: IsolatedParticlesGeneratedJets
4 // Class: IsolatedParticlesGeneratedJets
5 //
13 //
14 // Original Author: Seema Sharma
15 // Created: Thu Mar 4 18:52:02 CST 2010
16 //
17 //
18 
22 
24 
25  debug = iConfig.getUntrackedParameter<bool> ("Debug", false);
26  jetSrc = iConfig.getParameter<edm::InputTag>("JetSource");
27  partSrc = iConfig.getParameter<edm::InputTag>("ParticleSource");
28 }
29 
30 
32 
33 }
34 
36 
37  //using namespace edm;
39 
40  //=== genJet information
42  iEvent.getByLabel(jetSrc, genJets);
43 
44  //=== genJet information
46  iEvent.getByLabel(partSrc, genParticles);
47 
48  JetMatchingTools jetMatching (iEvent);
49  std::vector <std::vector <const reco::GenParticle*> > genJetConstituents (genJets->size());
50 
51  int njets = 0;
52  for (unsigned iGenJet = 0; iGenJet < genJets->size(); ++iGenJet) {
53  const reco::GenJet& genJet = (*genJets) [iGenJet];
54 
55  double genJetE = genJet.energy();
56  double genJetPt = genJet.pt();
57  double genJetEta = genJet.eta();
58  double genJetPhi = genJet.phi();
59 
60  if( genJetPt> 30.0 && std::abs(genJetEta)<3.0 ) {
61 
62  njets++;
63 
64  std::vector <const reco::GenParticle*> genJetConstituents = jetMatching.getGenParticles ((*genJets) [iGenJet]);
65 
66  std::vector<double> v_trkP, v_trkPt, v_trkEta, v_trkPhi, v_trkPdg, v_trkCharge;
67 
68  if(debug) std::cout<<"Jet(pt,Eta,Phi) "<<genJetPt<<" "<<genJetEta<<" "<<genJetPhi <<std::endl;
69  for(unsigned int ic=0; ic<genJetConstituents.size(); ic++) {
70 
71  if(debug) {
72  std::cout << "p,pt,eta,phi "<<genJetConstituents[ic]->p()<<" "<<genJetConstituents[ic]->pt()
73  <<" "<<genJetConstituents[ic]->eta()<<" "<<genJetConstituents[ic]->phi()
74  <<std::endl;
75  }
76 
77  v_trkP.push_back(genJetConstituents[ic]->p());
78  v_trkPt.push_back(genJetConstituents[ic]->pt());
79  v_trkEta.push_back(genJetConstituents[ic]->eta());
80  v_trkPhi.push_back(genJetConstituents[ic]->phi());
81  v_trkPdg.push_back(genJetConstituents[ic]->pdgId());
82  v_trkCharge.push_back(genJetConstituents[ic]->charge());
83 
84  } //loop over genjet constituents
85 
86  t_gjetE ->push_back(genJetE );
87  t_gjetPt ->push_back(genJetPt );
88  t_gjetEta ->push_back(genJetEta);
89  t_gjetPhi ->push_back(genJetPhi);
90 
91  t_jetTrkP ->push_back(v_trkP );
92  t_jetTrkPt ->push_back(v_trkPt );
93  t_jetTrkEta ->push_back(v_trkEta);
94  t_jetTrkPhi ->push_back(v_trkPhi);
95  t_jetTrkPdg ->push_back(v_trkPdg);
96  t_jetTrkCharge ->push_back(v_trkCharge);
97 
98  } // if jetPt>30
99 
100  } //loop over genjets
101 
102  t_gjetN->push_back(njets);
103 
104  unsigned int indx = 0;
105  for(reco::GenParticleCollection::const_iterator ig = genParticles->begin(); ig!= genParticles->end(); ++ig,++indx) {
106 
107  if (debug)
108  std::cout << "Track " << indx << " Status " << ig->status() << " charge "
109  << ig->charge() << " pdgId " << ig->pdgId() << " mass "
110  << ig->mass() << " P " << ig->momentum() << " E "
111  << ig->energy() << " Origin " << ig->vertex() << std::endl;
112  }
113 
114 
115  tree->Fill();
116 }
117 
119 
120  BookHistograms();
121 
122 }
123 
125  t_gjetN ->clear();
126  t_gjetE ->clear();
127  t_gjetPt ->clear();
128  t_gjetEta ->clear();
129  t_gjetPhi ->clear();
130 
131  t_jetTrkP ->clear();
132  t_jetTrkPt ->clear();
133  t_jetTrkEta ->clear();
134  t_jetTrkPhi ->clear();
135  t_jetTrkPdg ->clear();
136  t_jetTrkCharge ->clear();
137 }
138 
140 
141  tree = fs->make<TTree>("tree", "tree");
142 
143  t_gjetN = new std::vector<int> ();
144  t_gjetE = new std::vector<double>();
145  t_gjetPt = new std::vector<double>();
146  t_gjetEta = new std::vector<double>();
147  t_gjetPhi = new std::vector<double>();
148 
149  t_jetTrkP = new std::vector<std::vector<double> >();
150  t_jetTrkPt = new std::vector<std::vector<double> >();
151  t_jetTrkEta = new std::vector<std::vector<double> >();
152  t_jetTrkPhi = new std::vector<std::vector<double> >();
153  t_jetTrkPdg = new std::vector<std::vector<double> >();
154  t_jetTrkCharge = new std::vector<std::vector<double> >();
155 
156  tree->Branch("t_gjetN", "vector<int>", &t_gjetN);
157  tree->Branch("t_gjetE", "vector<double>", &t_gjetE);
158  tree->Branch("t_gjetPt", "vector<double>", &t_gjetPt);
159  tree->Branch("t_gjetEta", "vector<double>", &t_gjetEta);
160  tree->Branch("t_gjetPhi", "vector<double>", &t_gjetPhi);
161 
162  tree->Branch("t_jetTrkP", "vector<vector<double> >", &t_jetTrkP);
163  tree->Branch("t_jetTrkPt", "vector<vector<double> >", &t_jetTrkPt);
164  tree->Branch("t_jetTrkEta", "vector<vector<double> >", &t_jetTrkEta);
165  tree->Branch("t_jetTrkPhi", "vector<vector<double> >", &t_jetTrkPhi);
166  tree->Branch("t_jetTrkPdg", "vector<vector<double> >", &t_jetTrkPdg);
167  tree->Branch("t_jetTrkCharge", "vector<vector<double> >", &t_jetTrkCharge);
168 
169 }
170 
172 }
173 
174 //define this as a plug-in
virtual double energy() const GCC11_FINAL
energy
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::vector< double > > * t_jetTrkEta
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
#define abs(x)
Definition: mlp_lapack.h:159
T eta() const
std::vector< std::vector< double > > * t_jetTrkPdg
double charge(const std::vector< uint8_t > &Ampls)
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
int iEvent
Definition: GenABIO.cc:243
std::vector< std::vector< double > > * t_jetTrkPhi
Jets made from MC generator particles.
Definition: GenJet.h:25
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
std::vector< std::vector< double > > * t_jetTrkPt
std::vector< std::vector< double > > * t_jetTrkCharge
std::vector< const reco::GenParticle * > getGenParticles(const reco::CaloJet &fJet, bool fVerbose=true)
GenParticles for CaloJet.
T * make() const
make new ROOT object
tuple cout
Definition: gather_cfg.py:121
std::vector< std::vector< double > > * t_jetTrkP
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual float pt() const GCC11_FINAL
transverse momentum
IsolatedParticlesGeneratedJets(const edm::ParameterSet &)
Definition: DDAxes.h:10