-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roger Wolf
committed
Nov 10, 2009
1 parent
84ada87
commit ec03717
Showing
16 changed files
with
2,477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* This is en example for an Analyzer of a Herwig HepMCProduct | ||
and looks for muons pairs and fills a histogram | ||
with the invaraint mass of the four. | ||
*/ | ||
|
||
// | ||
// Original Author: Fabian Stoeckli | ||
// Created: Tue Nov 14 13:43:02 CET 2006 | ||
// $Id: BBbarAnalyzer.cc,v 1.3 2009/07/31 23:21:07 kharchil Exp $ | ||
// | ||
// | ||
|
||
|
||
// system include files | ||
#include <memory> | ||
#include <iostream> | ||
|
||
// user include files | ||
#include "Validation/Generator/plugins/BBbarAnalyzer.h" | ||
#include "DataFormats/Math/interface/LorentzVector.h" | ||
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" | ||
|
||
|
||
BBbarAnalyzer::BBbarAnalyzer(const edm::ParameterSet& iConfig) | ||
{ | ||
outputFilename=iConfig.getUntrackedParameter<std::string>("OutputFilename","dummy.root"); | ||
Pt_histo = new TH1F("invmass_histo","invmass_histo",100,0,20); | ||
invmass_histo = new TH1F("mu_invmass_histo","mu_invmass_histo",100,0,20); | ||
} | ||
|
||
BBbarAnalyzer::~BBbarAnalyzer() | ||
{ | ||
|
||
} | ||
|
||
void | ||
BBbarAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
|
||
// get HepMC::GenEvent ... | ||
//Handle<HepMCProduct> evt_h; | ||
//iEvent.getByType(evt_h); | ||
//HepMC::GenEvent * evt = new HepMC::GenEvent(*(evt_h->GetEvent())); | ||
|
||
|
||
// look for stable muons | ||
// std::vector<HepMC::GenParticle*> muons; | ||
//muons.resize(0); | ||
//for(HepMC::GenEvent::particle_iterator it = evt->particles_begin(); it != evt->particles_end(); ++it) { | ||
// if(abs((*it)->pdg_id())==13 && (*it)->status()==1) { | ||
// muons.push_back(*it); | ||
// } | ||
// } | ||
|
||
math::XYZTLorentzVector Lvector1(0,0,0,0); | ||
math::XYZTLorentzVector Lvector2(0,0,0,0); | ||
|
||
Handle<HepMCProduct> mcEventHandle; | ||
try{ | ||
iEvent.getByLabel("source",mcEventHandle); | ||
}catch(...) {;} | ||
|
||
if(mcEventHandle.isValid()){ | ||
const HepMC::GenEvent* mcEvent = mcEventHandle->GetEvent() ; | ||
|
||
// if there are at least four muons | ||
// calculate invarant mass of first two and fill it into histogram | ||
math::XYZTLorentzVector tot_momentum; math::XYZTLorentzVector tot_mumomentum; | ||
float inv_mass = 0.0; | ||
//double mu_invmass = 0.0; | ||
float Pt = 0; | ||
|
||
HepMC::GenEvent::particle_const_iterator i; | ||
HepMC::GenEvent::particle_const_iterator j; | ||
for(i = mcEvent->particles_begin(); i!= mcEvent->particles_end(); i++){ | ||
for(j = mcEvent->particles_begin(); j!= mcEvent->particles_end(); j++){ | ||
HepMC::FourVector p41 = (*i)->momentum(); | ||
HepMC::FourVector p42 = (*i)->momentum(); | ||
Lvector1 = math::XYZTLorentzVector(p41.px(),p41.py(),p41.pz(),p41.e()); | ||
Lvector2 = math::XYZTLorentzVector(p42.px(),p42.py(),p42.pz(),p42.e()); | ||
Pt = sqrt(p41.px()*p41.px()+p41.py()*p41.py()); | ||
Pt_histo->Fill(Pt); | ||
inv_mass = sqrt((p41.e()+p42.e())*(p41.e()+p42.e())-((p41.px()+p42.px())*(p41.px()+p42.px())+(p41.py()+p42.py())*(p41.py()+p42.py())+(p41.pz()+p42.pz())*(p41.pz()+p42.pz()))); | ||
invmass_histo->Fill(inv_mass); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void | ||
BBbarAnalyzer::beginJob(const edm::EventSetup&) | ||
{ | ||
} | ||
|
||
void | ||
BBbarAnalyzer::endJob() { | ||
// save histograms into file | ||
TFile file(outputFilename.c_str(),"RECREATE"); | ||
Pt_histo->Write(); | ||
invmass_histo->Write(); | ||
file.Close(); | ||
|
||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
DEFINE_FWK_MODULE(BBbarAnalyzer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EDAnalyzer.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "HepMC/GenEvent.h" | ||
#include "HepMC/GenParticle.h" | ||
#include "HepMC/WeightContainer.h" | ||
|
||
#include "TH1D.h" | ||
#include "TFile.h" | ||
|
||
|
||
class BBbarAnalyzer : public edm::EDAnalyzer { | ||
public: | ||
explicit BBbarAnalyzer(const edm::ParameterSet&); | ||
~BBbarAnalyzer(); | ||
|
||
private: | ||
virtual void beginJob(const edm::EventSetup&) ; | ||
virtual void analyze(const edm::Event&, const edm::EventSetup&); | ||
virtual void endJob() ; | ||
|
||
private: | ||
std::string outputFilename; | ||
TH1D* weight_histo; | ||
TH1F* invmass_histo; | ||
TH1F* Pt_histo; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* This is en example for an Analyzer of a Herwig HepMCProduct | ||
and looks for muons pairs and fills a histogram | ||
with the invaraint mass of the four. | ||
*/ | ||
|
||
// | ||
// Original Author: Fabian Stoeckli | ||
// Created: Tue Nov 14 13:43:02 CET 2006 | ||
// $Id: H4muAnalyzer.cc,v 1.3 2009/07/31 23:21:08 kharchil Exp $ | ||
// | ||
// | ||
|
||
// system include files | ||
#include <memory> | ||
#include <iostream> | ||
// user include files | ||
#include "Validation/Generator/plugins/H4muAnalyzer.h" | ||
|
||
#include "DataFormats/Math/interface/LorentzVector.h" | ||
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" | ||
|
||
|
||
H4muAnalyzer::H4muAnalyzer(const edm::ParameterSet& iConfig) | ||
{ | ||
outputFilename=iConfig.getUntrackedParameter<std::string>("OutputFilename","dummy.root"); | ||
invmass_histo = new TH1D("invmass_histo","invmass_histo",60,180,200); | ||
Z_invmass_histo = new TH1D("mu_invmass_histo","mu_invmass_histo",60,70,100); | ||
} | ||
|
||
H4muAnalyzer::~H4muAnalyzer() | ||
{ | ||
|
||
} | ||
|
||
void | ||
H4muAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
|
||
// get HepMC::GenEvent ... | ||
Handle<HepMCProduct> evt_h; | ||
iEvent.getByType(evt_h); | ||
HepMC::GenEvent * evt = new HepMC::GenEvent(*(evt_h->GetEvent())); | ||
|
||
|
||
// look for stable muons | ||
std::vector<HepMC::GenParticle*> muons; | ||
muons.resize(0); | ||
for(HepMC::GenEvent::particle_iterator it = evt->particles_begin(); it != evt->particles_end(); ++it) { | ||
if(abs((*it)->pdg_id())==13 && (*it)->status()==1) { | ||
muons.push_back(*it); | ||
} | ||
} | ||
|
||
// if there are at least four muons | ||
// calculate invarant mass of first two and fill it into histogram | ||
math::XYZTLorentzVector tot_momentum; math::XYZTLorentzVector tot_mumomentum; | ||
double inv_mass = 0.0; double mu_invmass = 0.0; | ||
if(muons.size()>1) { | ||
for(unsigned int i=0; i<muons.size() - 1; ++i) { | ||
for(unsigned int j = i+1; j < muons.size(); ++j){ | ||
math::XYZTLorentzVector mumom(muons[i]->momentum()); | ||
math::XYZTLorentzVector mumom1(muons[j]->momentum()); | ||
tot_mumomentum = mumom + mumom1; | ||
mu_invmass = sqrt(tot_mumomentum.mass2()); | ||
Z_invmass_histo->Fill(mu_invmass); | ||
} | ||
} | ||
//invmass_histo->Fill(inv_mass); | ||
|
||
} | ||
|
||
if(muons.size()>3) { | ||
for(unsigned int i=0; i<4; ++i) { | ||
math::XYZTLorentzVector mom(muons[i]->momentum()); | ||
tot_momentum += mom; | ||
} | ||
inv_mass = sqrt(tot_momentum.mass2()); | ||
} | ||
invmass_histo->Fill(inv_mass); | ||
|
||
} | ||
|
||
void | ||
H4muAnalyzer::beginJob(const edm::EventSetup&) | ||
{ | ||
} | ||
|
||
void | ||
H4muAnalyzer::endJob() { | ||
// save histograms into file | ||
TFile file(outputFilename.c_str(),"RECREATE"); | ||
invmass_histo->Write(); | ||
Z_invmass_histo->Write(); | ||
file.Close(); | ||
|
||
} | ||
|
||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
DEFINE_FWK_MODULE(H4muAnalyzer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EDAnalyzer.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
|
||
#include "HepMC/GenEvent.h" | ||
#include "HepMC/GenParticle.h" | ||
#include "HepMC/WeightContainer.h" | ||
|
||
#include "TH1D.h" | ||
#include "TFile.h" | ||
|
||
|
||
class H4muAnalyzer : public edm::EDAnalyzer { | ||
public: | ||
explicit H4muAnalyzer(const edm::ParameterSet&); | ||
~H4muAnalyzer(); | ||
|
||
private: | ||
virtual void beginJob(const edm::EventSetup&) ; | ||
virtual void analyze(const edm::Event&, const edm::EventSetup&); | ||
virtual void endJob() ; | ||
|
||
private: | ||
std::string outputFilename; | ||
TH1D* weight_histo; | ||
TH1D* invmass_histo; | ||
TH1D* Z_invmass_histo; | ||
|
||
}; |
Oops, something went wrong.