#include <MultiParticleInConeGunProducer.h>
Public Member Functions | |
MultiParticleInConeGunProducer (const ParameterSet &) | |
virtual | ~MultiParticleInConeGunProducer () |
Protected Attributes | |
std::vector< int > | fInConeIds |
double | fInConeMaxEta |
double | fInConeMaxPhi |
unsigned int | fInConeMaxTry |
double | fInConeMinEta |
double | fInConeMinPhi |
double | fMaxDeltaR |
double | fMaxMomRatio |
double | fMaxPt |
double | fMinDeltaR |
double | fMinMomRatio |
double | fMinPt |
Private Member Functions | |
virtual void | produce (Event &e, const EventSetup &es) |
Definition at line 15 of file MultiParticleInConeGunProducer.h.
MultiParticleInConeGunProducer::MultiParticleInConeGunProducer | ( | const ParameterSet & | pset | ) |
Definition at line 24 of file MultiParticleInConeGunProducer.cc.
References fInConeIds, fInConeMaxEta, fInConeMaxPhi, fInConeMaxTry, fInConeMinEta, fInConeMinPhi, fMaxDeltaR, fMaxMomRatio, fMaxPt, fMinDeltaR, fMinMomRatio, fMinPt, and edm::ParameterSet::getParameter().
: BaseFlatGunProducer(pset) { ParameterSet defpset ; ParameterSet pgun_params = pset.getParameter<ParameterSet>("PGunParameters") ; fMinPt = pgun_params.getParameter<double>("MinPt"); fMaxPt = pgun_params.getParameter<double>("MaxPt"); fInConeIds = pgun_params.getParameter< vector<int> >("InConeID"); fMinDeltaR = pgun_params.getParameter<double>("MinDeltaR"); fMaxDeltaR = pgun_params.getParameter<double>("MaxDeltaR"); fMinMomRatio = pgun_params.getParameter<double>("MinMomRatio"); fMaxMomRatio = pgun_params.getParameter<double>("MaxMomRatio"); fInConeMinEta = pgun_params.getParameter<double>("InConeMinEta"); fInConeMaxEta = pgun_params.getParameter<double>("InConeMaxEta"); fInConeMinPhi = pgun_params.getParameter<double>("InConeMinPhi"); fInConeMaxPhi = pgun_params.getParameter<double>("InConeMaxPhi"); fInConeMaxTry = pgun_params.getParameter<unsigned int>("InConeMaxTry"); produces<HepMCProduct>(); produces<GenEventInfoProduct>(); }
MultiParticleInConeGunProducer::~MultiParticleInConeGunProducer | ( | ) | [virtual] |
Definition at line 52 of file MultiParticleInConeGunProducer.cc.
{
// no need to cleanup GenEvent memory - done in HepMCProduct
}
void MultiParticleInConeGunProducer::produce | ( | Event & | e, |
const EventSetup & | es | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 57 of file MultiParticleInConeGunProducer.cc.
References abs, alpha, funct::cos(), gather_cfg::cout, dPhi(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, relval_parameters_module::energy, eta, edm::EventID::event(), funct::exp(), edm::BaseFlatGunProducer::fAddAntiParticle, edm::BaseFlatGunProducer::fEvt, fInConeIds, fInConeMaxEta, fInConeMaxPhi, fInConeMaxTry, fMaxDeltaR, edm::BaseFlatGunProducer::fMaxEta, fMaxMomRatio, edm::BaseFlatGunProducer::fMaxPhi, fMaxPt, fMinDeltaR, edm::BaseFlatGunProducer::fMinEta, fMinMomRatio, edm::BaseFlatGunProducer::fMinPhi, fMinPt, edm::BaseFlatGunProducer::fPartIDs, edm::BaseFlatGunProducer::fPDGTable, edm::BaseFlatGunProducer::fRandomGenerator, edm::BaseFlatGunProducer::fVerbosity, configurableAnalysis::GenParticle, edm::EventBase::id(), AlCaHLTBitMon_ParallelJobs::p, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, phi, edm::Event::put(), funct::sin(), mathSSE::sqrt(), and theta().
{ if ( fVerbosity > 0 ) { cout << " MultiParticleInConeGunProducer : Begin New Event Generation" << endl ; } // event loop (well, another step in it...) // no need to clean up GenEvent memory - done in HepMCProduct // // here re-create fEvt (memory) // fEvt = new HepMC::GenEvent() ; // now actualy, cook up the event from PDGTable and gun parameters // // 1st, primary vertex // //HepMC::GenVertex* Vtx = new HepMC::GenVertex(CLHEP::HepLorentzVector(0.,0.,0.)); HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.)); // loop over particles // int barcode = 1 ; for (unsigned int ip=0; ip<fPartIDs.size(); ++ip) { double pt = fRandomGenerator->fire(fMinPt, fMaxPt) ; double eta = fRandomGenerator->fire(fMinEta, fMaxEta) ; double phi = fRandomGenerator->fire(fMinPhi, fMaxPhi) ; int PartID = fPartIDs[ip] ; const HepPDT::ParticleData* PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ; double mass = PData->mass().value() ; double theta = 2.*atan(exp(-eta)) ; double mom = pt/sin(theta) ; double px = pt*cos(phi) ; double py = pt*sin(phi) ; double pz = mom*cos(theta) ; double energy2= mom*mom + mass*mass ; double energy = sqrt(energy2) ; HepMC::FourVector p(px,py,pz,energy) ; HepMC::GenParticle* Part = new HepMC::GenParticle(p,PartID,1); Part->suggest_barcode( barcode ) ; barcode++ ; Vtx->add_particle_out(Part); if ( fAddAntiParticle ){} // now add the particles in the cone for (unsigned iPic=0; iPic!=fInConeIds.size();iPic++){ unsigned int nTry=0; while(true){ //shoot flat Deltar double dR = fRandomGenerator->fire(fMinDeltaR, fMaxDeltaR); //shoot flat eta/phi mixing double alpha = fRandomGenerator->fire(-3.14159265358979323846, 3.14159265358979323846); double dEta = dR*cos(alpha); double dPhi = dR*sin(alpha); /* //shoot Energy of associated particle double energyIc = fRandomGenerator->fire(fMinEInCone, fMaxEInCone); if (mom2Ic>0){ momIC = sqrt(mom2Ic);} */ // get kinematics double etaIc = eta+dEta; double phiIc = phi+dPhi; //put it back in -Pi:Pi if necessary. multiple time might be necessary if dR > 3 const unsigned int maxL=100; unsigned int iL=0; while(iL++<maxL){ if (phiIc > 3.14159265358979323846) phiIc-=2*3.14159265358979323846; else if(phiIc <-3.14159265358979323846) phiIc+=2*3.14159265358979323846; if (abs(phiIc)<3.14159265358979323846) break; } //allow to skip it if you did not run out of possible drawing if (nTry++<=fInConeMaxTry){ //draw another one if this one is not in acceptance if (etaIc<fInConeMinEta || etaIc > fInConeMaxEta) continue; if (phiIc<fInConeMinPhi || phiIc > fInConeMaxPhi) continue; } else{ if ( fVerbosity > 0 ) { cout << " MultiParticleInConeGunProducer : could not produce a particle " << fInConeIds[iPic]<<" in cone " << fMinDeltaR<<" to "<<fMaxDeltaR<<" within the "<<fInConeMaxTry<<" allowed tries."<<endl; } /* edm::LogError("MultiParticleInConeGunProducer")<< " MultiParticleInConeGunProducer : could not produce a particle "<< fInConeIds[iPic]<<" in cone "<< fMinDeltaR<<" to "<<fMaxDeltaR<<" within the "<<fInConeMaxTry<<" allowed tries.";*/ } int PartIDIc=fInConeIds[iPic]; const HepPDT::ParticleData* PDataIc = fPDGTable->particle(HepPDT::ParticleID(abs(PartIDIc))); //shoot momentum ratio double momR = fRandomGenerator->fire(fMinMomRatio, fMaxMomRatio); double massIc= PDataIc->mass().value() ; double momIc = momR * mom; double energyIc = sqrt(momIc*momIc + massIc*massIc); double thetaIc = 2.*atan(exp(-etaIc)) ; double pxIc = momIc*sin(thetaIc)*cos(phiIc); double pyIc = momIc*sin(thetaIc)*sin(phiIc); double pzIc = momIc*cos(thetaIc); HepMC::FourVector pIc(pxIc,pyIc,pzIc,energyIc) ; HepMC::GenParticle* PartIc = new HepMC::GenParticle(pIc, PartIDIc, 1); PartIc->suggest_barcode( barcode ) ; barcode++ ; Vtx->add_particle_out(PartIc); break; }//try many times while not in acceptance }//loop over the particle Ids in the cone } fEvt->add_vertex(Vtx) ; fEvt->set_event_number(e.id().event()) ; fEvt->set_signal_process_id(20) ; if ( fVerbosity > 0 ) { fEvt->print() ; } auto_ptr<HepMCProduct> BProduct(new HepMCProduct()) ; BProduct->addHepMCData( fEvt ); e.put(BProduct); auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(fEvt)); e.put(genEventInfo); if ( fVerbosity > 0 ) { cout << " MultiParticleInConeGunProducer : Event Generation Done " << endl; } }
std::vector<int> edm::MultiParticleInConeGunProducer::fInConeIds [protected] |
Definition at line 32 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fInConeMaxEta [protected] |
Definition at line 39 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fInConeMaxPhi [protected] |
Definition at line 41 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
unsigned int edm::MultiParticleInConeGunProducer::fInConeMaxTry [protected] |
Definition at line 42 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fInConeMinEta [protected] |
Definition at line 38 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer().
double edm::MultiParticleInConeGunProducer::fInConeMinPhi [protected] |
Definition at line 40 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer().
double edm::MultiParticleInConeGunProducer::fMaxDeltaR [protected] |
Definition at line 34 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fMaxMomRatio [protected] |
Definition at line 36 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fMaxPt [protected] |
Definition at line 30 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fMinDeltaR [protected] |
Definition at line 33 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fMinMomRatio [protected] |
Definition at line 35 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().
double edm::MultiParticleInConeGunProducer::fMinPt [protected] |
Definition at line 29 of file MultiParticleInConeGunProducer.h.
Referenced by MultiParticleInConeGunProducer(), and produce().