30 NJets =
cfg.getParameter<
int>(
"NJets");
31 debug =
cfg.getParameter<
bool>(
"debug");
32 eventsGen =
cfg.getParameter<
int>(
"eventsGen");
34 xsecGen =
cfg.getParameter<vector<double> >(
"xsecGen");
35 ptHatEdges =
cfg.getParameter<vector<double> >(
"ptHatEdges");
41 m_file =
new TFile(HistoFileName.c_str(),
"RECREATE");
43 const int nMassBins = 103;
44 double massBoundaries[nMassBins + 1] = {
45 1, 3, 6, 10, 16, 23, 31, 40, 50, 61, 74, 88, 103, 119, 137,
46 156, 176, 197, 220, 244, 270, 296, 325, 354, 386, 419, 453, 489, 526, 565,
47 606, 649, 693, 740, 788, 838, 890, 944, 1000, 1058, 1118, 1181, 1246, 1313, 1383,
48 1455, 1530, 1607, 1687, 1770, 1856, 1945, 2037, 2132, 2231, 2332, 2438, 2546, 2659, 2775,
49 2895, 3019, 3147, 3279, 3416, 3558, 3704, 3854, 4010, 4171, 4337, 4509, 4686, 4869, 5058,
50 5253, 5455, 5663, 5877, 6099, 6328, 6564, 6808, 7060, 7320, 7589, 7866, 8152, 8447, 8752,
51 9067, 9391, 9726, 10072, 10430, 10798, 11179, 11571, 11977, 12395, 12827, 13272, 13732, 14000};
54 m_HistNames1D[hname] =
new TH1F(hname, hname, 500, 0, 5000);
57 m_HistNames1D[hname] =
new TH1F(hname, hname, 120, -6, 6);
60 m_HistNames1D[hname] =
new TH1F(hname, hname, 100, -
M_PI,
M_PI);
62 hname =
"NumberOfJets";
63 m_HistNames1D[hname] =
new TH1F(hname, hname, 100, 0, 100);
66 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
68 hname =
"DijetMassWt";
69 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
70 m_HistNames1D.find(hname)->second->Sumw2();
72 hname =
"DijetMassIn";
73 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
75 hname =
"DijetMassInWt";
76 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
77 m_HistNames1D.find(hname)->second->Sumw2();
79 hname =
"DijetMassOut";
80 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
82 hname =
"DijetMassOutWt";
83 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
84 m_HistNames1D.find(hname)->second->Sumw2();
86 hname =
"ResonanceMass";
87 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
89 hname =
"DipartonMass";
90 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
92 hname =
"DipartonMassWt";
93 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
94 m_HistNames1D.find(hname)->second->Sumw2();
96 hname =
"DipartonMassIn";
97 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
99 hname =
"DipartonMassInWt";
100 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
101 m_HistNames1D.find(hname)->second->Sumw2();
103 hname =
"DipartonMassOut";
104 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
106 hname =
"DipartonMassOutWt";
107 m_HistNames1D[hname] =
new TH1F(hname, hname, nMassBins, massBoundaries);
108 m_HistNames1D.find(hname)->second->Sumw2();
111 m_HistNames1D[hname] =
new TH1F(hname, hname, 1000, 0, 5000);
114 m_HistNames1D[hname] =
new TH1F(hname, hname, 1000, 0, 5000);
115 m_HistNames1D.find(hname)->second->Sumw2();
118 m_HistNames1D[hname] =
new TH1F(hname, hname, 5000, 0, 5000);
120 hname =
"PtHatFineWt";
121 m_HistNames1D[hname] =
new TH1F(hname, hname, 5000, 0, 5000);
122 m_HistNames1D.find(hname)->second->Sumw2();
124 mcTruthTree_ =
new TTree(
"mcTruthTree",
"mcTruthTree");
125 mcTruthTree_->Branch(
"xsec", &xsec,
"xsec/F");
126 mcTruthTree_->Branch(
"weight", &
weight,
"weight/F");
127 mcTruthTree_->Branch(
"pt_hat", &pt_hat,
"pt_hat/F");
128 mcTruthTree_->Branch(
"nJets", &nJets,
"nJets/I");
129 mcTruthTree_->Branch(
"etaJet1", &etaJet1,
"etaJet1/F");
130 mcTruthTree_->Branch(
"etaJet2", &etaJet2,
"etaJet2/F");
131 mcTruthTree_->Branch(
"ptJet1", &ptJet1,
"ptJet1/F");
132 mcTruthTree_->Branch(
"ptJet2", &ptJet2,
"ptJet2/F");
133 mcTruthTree_->Branch(
"diJetMass", &diJetMass,
"diJetMass/F");
134 mcTruthTree_->Branch(
"etaPart1", &etaPart1,
"etaPart1/F");
135 mcTruthTree_->Branch(
"etaPart2", &etaPart2,
"etaPart2/F");
136 mcTruthTree_->Branch(
"ptPart1", &ptPart1,
"ptPart1/F");
137 mcTruthTree_->Branch(
"ptPart2", &ptPart2,
"ptPart2/F");
138 mcTruthTree_->Branch(
"diPartMass", &diPartMass,
"diPartMass/F");
157 double pthat = myGenEvent->event_scale();
158 pt_hat =
float(pthat);
162 if (anaLevel !=
"generating") {
167 if (ptHatEdges.size() > xsecGen.size()) {
168 for (
unsigned int i_pthat = 0; i_pthat < xsecGen.size(); ++i_pthat) {
169 if (pthat >= ptHatEdges[i_pthat] && pthat < ptHatEdges[i_pthat + 1])
170 xsec =
float(xsecGen[i_pthat]);
173 std::cout <<
"Number of PtHat bin edges too small. Xsec set to zero" << std::endl;
179 std::cout <<
"cross section=" << xsec <<
" pb" << std::endl;
180 weight = xsec / eventsGen;
183 std::cout <<
"pt_hat=" << pt_hat << std::endl;
185 FillHist1D(hname, pt_hat, 1.0);
187 FillHist1D(hname, pt_hat, 1.0);
189 FillHist1D(hname, pt_hat,
weight);
190 hname =
"PtHatFineWt";
191 FillHist1D(hname, pt_hat,
weight);
192 if (anaLevel ==
"PtHatOnly")
201 typename JetCollection::const_iterator i_jet;
205 hname =
"NumberOfJets";
206 nJets =
jets->size();
207 FillHist1D(hname, nJets, 1.0);
210 for (i_jet =
jets->begin(); i_jet !=
jets->end() &&
index < 2; ++i_jet) {
212 FillHist1D(hname, i_jet->pt(), 1.0);
214 FillHist1D(hname, i_jet->eta(), 1.0);
216 FillHist1D(hname, i_jet->phi(), 1.0);
217 p4jet[
index] = i_jet->p4();
218 etajet[
index] = i_jet->eta();
220 std::cout <<
"jet " <<
index + 1 <<
": pt=" << i_jet->pt() <<
", eta=" << etajet[
index] << std::endl;
227 ptJet1 = p4jet[0].pt();
228 ptJet2 = p4jet[1].pt();
229 diJetMass = (p4jet[0] + p4jet[1]).
mass();
232 if (
index == 2 &&
abs(etaJet1) < 1.3 &&
abs(etaJet2) < 1.3) {
234 FillHist1D(hname, diJetMass, 1.0);
235 hname =
"DijetMassWt";
236 FillHist1D(hname, diJetMass,
weight);
240 if (
index == 2 &&
abs(etaJet1) < 0.7 &&
abs(etaJet2) < 0.7) {
241 hname =
"DijetMassIn";
242 FillHist1D(hname, diJetMass, 1.0);
243 hname =
"DijetMassInWt";
244 FillHist1D(hname, diJetMass,
weight);
247 if (
index == 2 && (
abs(etaJet1) > 0.7 &&
abs(etaJet1) < 1.3) && (
abs(etaJet2) > 0.7 &&
abs(etaJet2) < 1.3)) {
248 hname =
"DijetMassOut";
249 FillHist1D(hname, diJetMass, 1.0);
250 hname =
"DijetMassOutWt";
251 FillHist1D(hname, diJetMass,
weight);
253 if (anaLevel ==
"Jets")
258 evt.
getByLabel(
"genParticles", genParticlesHandle_);
260 for (
size_t i = 0;
i < genParticlesHandle_->size(); ++
i) {
265 if (
i >= 2 &&
i <= 8)
266 std::cout <<
"particle " <<
i <<
": id=" <<
id <<
", status=" << st <<
", mass=" << genP4.mass()
267 <<
", pt=" << genP4.pt() <<
", eta=" << genP4.eta() << std::endl;
277 resonance_p =
p.p4();
278 hname =
"ResonanceMass";
279 FillHist1D(hname, resonance_p.mass(), 1.0);
285 std::cout <<
"Resonance mass=" << resonance_p.mass() <<
", parton 1 pt=" << parton1_p.pt()
286 <<
", parton 2 pt=" << parton2_p.pt() <<
", diparton mass=" << (parton1_p + parton2_p).
mass()
294 std::cout <<
"parton 1 pt=" << parton1_p.pt() <<
", parton 2 pt=" << parton2_p.pt()
295 <<
", diparton mass=" << (parton1_p + parton2_p).
mass() << std::endl;
298 etaPart1 = parton1_p.eta();
299 etaPart2 = parton2_p.eta();
300 ptPart1 = parton1_p.pt();
301 ptPart2 = parton2_p.pt();
302 diPartMass = (parton1_p + parton2_p).
mass();
304 if (
abs(etaPart1) < 1.3 &&
abs(etaPart2) < 1.3) {
305 hname =
"DipartonMass";
306 FillHist1D(hname, diPartMass, 1.0);
307 hname =
"DipartonMassWt";
308 FillHist1D(hname, diPartMass,
weight);
311 if (
abs(etaPart1) < 0.7 &&
abs(etaPart2) < 0.7) {
312 hname =
"DipartonMassIn";
313 FillHist1D(hname, diPartMass, 1.0);
314 hname =
"DipartonMassInWt";
315 FillHist1D(hname, diPartMass,
weight);
318 if ((
abs(etaPart1) > 0.7 &&
abs(etaPart1) < 1.3) && (
abs(etaPart2) > 0.7 &&
abs(etaPart2) < 1.3)) {
319 hname =
"DipartonMassOut";
320 FillHist1D(hname, diPartMass, 1.0);
321 hname =
"DipartonMassOutWt";
322 FillHist1D(hname, diPartMass,
weight);
326 mcTruthTree_->Fill();
335 if (m_file !=
nullptr) {
337 mcTruthTree_->Write();
338 for (std::map<TString, TH1*>::iterator hid = m_HistNames1D.begin(); hid != m_HistNames1D.end(); hid++)
339 hid->second->Write();
347 std::map<TString, TH1*>::iterator hid = m_HistNames1D.find(histName);
348 if (hid == m_HistNames1D.end())
349 std::cout <<
"%fillHist -- Could not find histogram with name: " << histName << std::endl;
351 hid->second->Fill(
value, wt);
JetAnaPythia(edm::ParameterSet const &cfg)
JetAnaPythia< CaloJet > CaloJetAnaPythia
void FillHist1D(const TString &histName, const Double_t &x, const Double_t &wt)
#define DEFINE_FWK_MODULE(type)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void analyze(edm::Event const &e, edm::EventSetup const &iSetup) override
Abs< T >::type abs(const T &t)
const HepMC::GenEvent * GetEvent() const
JetAnaPythia< GenJet > GenJetAnaPythia
JetAnaPythia< PFJet > PFJetAnaPythia
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const