Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tauola 114 7 1 x #4708

Merged
merged 2 commits into from Jul 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions GeneratorInterface/ExternalDecays/src/ExternalDecayDriver.cc
Expand Up @@ -32,14 +32,8 @@ ExternalDecayDriver::ExternalDecayDriver( const ParameterSet& pset )
exSharedResources.emplace_back(edm::SharedResourceNames::kPythia6);
exSharedResources.emplace_back(gen::FortranInstance::kFortranInstance);
}
else if ( curSet == "Tauola" || curSet == "Tauolapp113a" ){
// this is for old tauola27 (+pretauola)
//
// --> fTauolaInterface = new gen::TauolaInterface(pset.getUntrackedParameter< ParameterSet >(curSet));
//
// for tauola++, here it should be something like:
//
fTauolaInterface = (TauolaInterfaceBase*)(TauolaFactory::get()->create("Tauolapp113a", pset.getUntrackedParameter< ParameterSet >(curSet)));
else if ( curSet == "Tauola" || curSet == "Tauolapp114" ){
fTauolaInterface = (TauolaInterfaceBase*)(TauolaFactory::get()->create("Tauolapp114", pset.getUntrackedParameter< ParameterSet >(curSet)));
fPhotosInterface = (PhotosInterfaceBase*)(PhotosFactory::get()->create("Photos2155", pset.getUntrackedParameter< ParameterSet >(curSet)));
fPhotosInterface->configureOnlyFor( 15 );
fPhotosInterface->avoidTauLeptonicDecays();
Expand Down
38 changes: 19 additions & 19 deletions GeneratorInterface/TauolaInterface/interface/TauSpinnerCMS.h
@@ -1,14 +1,14 @@
// -*- C++ -*-
//
// Package: TauSpinnerInterface
// Class: TauSpinnerCMS
//
/**\class TauSpinnerCMS TauSpinnerCMS.cc
// Package: TauSpinnerInterface
// Class: TauSpinnerCMS
//
/**\class TauSpinnerCMS TauSpinnerCMS.cc

*/
*/
//
// Original Author: Ian Nugent
// Created: Fri Feb 15 2013
// Original Author: Ian Nugent
// Created: Fri Feb 15 2013

#ifndef TauSpinnerCMS_h
#define TauSpinnerCMS_h
Expand All @@ -23,7 +23,7 @@
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "TH1.h"

Expand All @@ -47,24 +47,24 @@
#include "FWCore/Utilities/interface/RandomNumberGenerator.h"

class TauSpinnerCMS : public edm::one::EDProducer<edm::EndRunProducer,edm::one::SharedResources>{
public:
public:
explicit TauSpinnerCMS( const edm::ParameterSet& ) ;
virtual ~TauSpinnerCMS(){} // no need to delete ROOT stuff
virtual ~TauSpinnerCMS(){}; // no need to delete ROOT stuff

virtual void beginRun(edm::Run const&, edm::EventSetup const&){}
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {}
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {}
virtual void endRunProduce(edm::Run&, edm::EventSetup const&){}
virtual void beginRun(edm::Run const&, edm::EventSetup const&){}
virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {};
virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) {};
virtual void endRunProduce(edm::Run&, edm::EventSetup const&){};
virtual void produce( edm::Event&, const edm::EventSetup&) override final;
virtual void beginJob() override final;
virtual void endRun( const edm::Run&, const edm::EventSetup& );
virtual void endRun( const edm::Run&, const edm::EventSetup& ){};
virtual void endJob() override final;
virtual void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup);
static double flat();
virtual void endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup){};
static double flat();
void setRandomEngine(CLHEP::HepRandomEngine* v) { fRandomEngine = v; }
virtual void initialize();

private:
private:
bool isReco_;
bool isTauolaConfigured_;
bool isLHPDFConfigured_;
Expand Down Expand Up @@ -92,5 +92,5 @@ class TauSpinnerCMS : public edm::one::EDProducer<edm::EndRunProducer,edm::one::
edm::EDGetTokenT<edm::HepMCProduct> hepmcCollectionToken_;
edm::EDGetTokenT<reco::GenParticleCollection> GenParticleCollectionToken_;
static bool fInitialized;
};
};
#endif
6 changes: 3 additions & 3 deletions GeneratorInterface/TauolaInterface/plugins/BuildFile.xml
Expand Up @@ -13,16 +13,16 @@
</library>


<library file="TauSpinner/*.cc" name="TauSpinnerInterface">
<library file="TauSpinner/*.cc" name="TauSpinnerInterface">
<use name="FWCore/Concurrency"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="FWCore/ServiceRegistry"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="tauolapp"/>
<use name="lhapdf"/>
<use name="root"/>
<use name="rootmath"/>
<use name="clhep"/>
<flags EDM_PLUGIN="1"/>
<flags EDM_PLUGIN="1"/>
</library>
Expand Up @@ -17,8 +17,7 @@ using namespace edm;
using namespace TauSpinner;

CLHEP::HepRandomEngine* TauSpinnerCMS::fRandomEngine= nullptr;
bool TauSpinnerCMS::isTauSpinnerConfigure=false;

bool TauSpinnerCMS::isTauSpinnerConfigure=false;
bool TauSpinnerCMS::fInitialized=false;

TauSpinnerCMS::TauSpinnerCMS( const ParameterSet& pset ) :
Expand Down Expand Up @@ -52,18 +51,21 @@ TauSpinnerCMS::TauSpinnerCMS( const ParameterSet& pset ) :
}
}

void TauSpinnerCMS::beginJob(){};
void TauSpinnerCMS::endJob(){};

void TauSpinnerCMS::initialize(){
// Now for Tauola and TauSpinner
Tauolapp::Tauola::setRandomGenerator(TauSpinnerCMS::flat);
if(!isTauolaConfigured_){
Tauolapp::Tauola::setRandomGenerator(TauSpinnerCMS::flat);
Tauolapp::Tauola::initialize();
}
if(!isLHPDFConfigured_){
LHAPDF::initPDFSetByName(LHAPDFname_);
}
if(!isTauSpinnerConfigure){
isTauSpinnerConfigure=true;
bool Ipp = true; // for pp collisions
bool Ipp = true; // for pp collisions
// Initialize TauSpinner
//Ipol - polarization of input sample
//nonSM2 - nonstandard model calculations
Expand All @@ -73,18 +75,13 @@ void TauSpinnerCMS::initialize(){
fInitialized=true;
}

void TauSpinnerCMS::endLuminosityBlockProduce(edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup){}

void TauSpinnerCMS::beginJob(){

}

void TauSpinnerCMS::produce( edm::Event& e, const edm::EventSetup& iSetup){
RandomEngineSentry<TauSpinnerCMS> randomEngineSentry(this, e.streamID());
if(!fInitialized) initialize();

Tauolapp::Tauola::setRandomGenerator(TauSpinnerCMS::flat); // rest tauola++ random number incase other modules use tauola++

Tauolapp::Tauola::setRandomGenerator(TauSpinnerCMS::flat); // rest tauola++ random number incase other modules use tauola++
Tauolapp::jaki_.ktom = 1; // rest for when you run after tauola
double WT=1.0;
double WTFlip=1.0;
double polSM=-999; //range [-1,1]
Expand All @@ -100,11 +97,11 @@ void TauSpinnerCMS::produce( edm::Event& e, const edm::EventSetup& iSetup){
//Get EVENT
HepMC::GenEvent *Evt = new HepMC::GenEvent(*(evt->GetEvent()));
stat=readParticlesFromHepMC(Evt,X,tau,tau2,tau_daughters,tau_daughters2);
}
}
if(MotherPDGID_<0 || abs(X.pdgid())==MotherPDGID_){
if(stat!=1){
// Determine the weight
if( abs(X.pdgid())==24 || abs(X.pdgid())==37 ){
// Determine the weight
if( abs(X.pdgid())==24 || abs(X.pdgid())==37 ){
TLorentzVector tau_1r(0,0,0,0);
TLorentzVector tau_1(tau.px(),tau.py(),tau.pz(),tau.e());
for(unsigned int i=0; i<tau_daughters.size();i++){
Expand Down Expand Up @@ -152,8 +149,8 @@ void TauSpinnerCMS::produce( edm::Event& e, const edm::EventSetup& iSetup){

// regular weight
std::auto_ptr<double> TauSpinnerWeight(new double);
*TauSpinnerWeight =WT;
e.put(TauSpinnerWeight,"TauSpinnerWT");
*TauSpinnerWeight =WT;
e.put(TauSpinnerWeight,"TauSpinnerWT");

// flipped weight (ie Z->H or H->Z)
std::auto_ptr<double> TauSpinnerWeightFlip(new double);
Expand All @@ -162,7 +159,7 @@ void TauSpinnerCMS::produce( edm::Event& e, const edm::EventSetup& iSetup){

// h+ polarization
double WThplus=WT;
if(polSM<0.0 && polSM!=-999 && isValid) WThplus=0;
if(polSM<0.0 && polSM!=-999 && isValid) WThplus=0;
std::auto_ptr<double> TauSpinnerWeighthplus(new double);
*TauSpinnerWeighthplus = WThplus;
e.put(TauSpinnerWeighthplus,"TauSpinnerWThplus");
Expand All @@ -174,13 +171,9 @@ void TauSpinnerCMS::produce( edm::Event& e, const edm::EventSetup& iSetup){
*TauSpinnerWeighthminus = WThminus;
e.put(TauSpinnerWeighthminus,"TauSpinnerWThminus");
return ;
}

void TauSpinnerCMS::endRun( const edm::Run& r, const edm::EventSetup& ){}

void TauSpinnerCMS::endJob(){}
}

int TauSpinnerCMS::readParticlesfromReco(edm::Event& e,SimpleParticle &X,SimpleParticle &tau,SimpleParticle &tau2,
int TauSpinnerCMS::readParticlesfromReco(edm::Event& e,SimpleParticle &X,SimpleParticle &tau,SimpleParticle &tau2,
std::vector<SimpleParticle> &tau_daughters,std::vector<SimpleParticle> &tau2_daughters){
edm::Handle<reco::GenParticleCollection> genParticles;
e.getByToken(GenParticleCollectionToken_, genParticles);
Expand Down Expand Up @@ -240,7 +233,7 @@ void TauSpinnerCMS::GetLastSelf(const reco::GenParticle *Particle){
const reco::GenParticle *dau=static_cast<const reco::GenParticle*>(Particle->daughter(i));
if(Particle->pdgId()==dau->pdgId()){
Particle=dau;
GetLastSelf(Particle);
GetLastSelf(Particle);
}
}
}
Expand Down Expand Up @@ -278,5 +271,4 @@ double TauSpinnerCMS::flat()
return fRandomEngine->flat();
}


DEFINE_FWK_MODULE(TauSpinnerCMS);
Expand Up @@ -106,6 +106,53 @@ void TauolappInterface::init( const edm::EventSetup& es ){

Tauolapp::Tauola::spin_correlation.setAll(fPolarization);// Tauola switches this on during Tauola::initialise(); so we add this here to keep it on/off

if (fPSet->exists("parameterSets")){
std::vector<std::string> par = fPSet->getParameter< std::vector<std::string> >("parameterSets");
for (unsigned int ip=0; ip<par.size(); ++ip ){
std::string curSet = par[ip];

if(curSet=="setNewCurrents") Tauolapp::Tauola::setNewCurrents(fPSet->getParameter<int>(curSet));
if(curSet=="spinCorrelationSetAll") Tauolapp::Tauola::spin_correlation.setAll(fPSet->getParameter<bool>(curSet));
if(curSet=="spinCorrelationGAMMA") Tauolapp::Tauola::spin_correlation.GAMMA=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationZ0") Tauolapp::Tauola::spin_correlation.Z0=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationHIGGS") Tauolapp::Tauola::spin_correlation.HIGGS=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationHIGGSH") Tauolapp::Tauola::spin_correlation.HIGGS_H=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationHIGGSA") Tauolapp::Tauola::spin_correlation.HIGGS_A=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationHIGGSPLUS") Tauolapp::Tauola::spin_correlation.HIGGS_PLUS=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationHIGGSMINUS") Tauolapp::Tauola::spin_correlation.HIGGS_MINUS=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationWPLUS") Tauolapp::Tauola::spin_correlation.W_PLUS=fPSet->getParameter<bool>(curSet);
if(curSet=="spinCorrelationWMINUS") Tauolapp::Tauola::spin_correlation.W_MINUS=fPSet->getParameter<bool>(curSet);

if(curSet=="setHiggsScalarPseudoscalarPDG") Tauolapp::Tauola::setHiggsScalarPseudoscalarPDG(fPSet->getParameter<int>(curSet));
if(curSet=="setHiggsScalarPseudoscalarMixingAngle") Tauolapp::Tauola::setHiggsScalarPseudoscalarMixingAngle(fPSet->getParameter<double>(curSet));

if(curSet=="setRadiation") Tauolapp::Tauola::setRadiation(fPSet->getParameter<bool>(curSet));
if(curSet=="setRadiationCutOff") Tauolapp::Tauola::setRadiationCutOff(fPSet->getParameter<double>(curSet));

if(curSet=="setEtaK0sPi"){
std::vector<int> vpar = fPSet->getParameter<std::vector<int> >(curSet);
if(vpar.size()==3) Tauolapp::Tauola::setEtaK0sPi(vpar[0],vpar[1],vpar[2]);
else {std::cout << "WARNING invalid size for setEtaK0sPi: " << vpar.size() << " Require 3 elements " << std::endl;}
}

if(curSet=="setTaukle"){
std::vector<double> vpar = fPSet->getParameter<std::vector<double> >(curSet);
if(vpar.size()==4) Tauolapp::Tauola::setTaukle(vpar[0], vpar[1], vpar[2], vpar[3]);
else {std::cout << "WARNING invalid size for setTaukle: " << vpar.size() << " Require 4 elements " << std::endl;}
}

if(curSet=="setTauBr"){
edm::ParameterSet cfg = fPSet->getParameter<edm::ParameterSet>(curSet);
std::vector<int> vJAK = cfg.getParameter<std::vector<int> >("JAK");
std::vector<double> vBR = cfg.getParameter<std::vector<double> >("BR");
if(vJAK.size() == vBR.size()){
for(unsigned int i=0;i<vJAK.size();i++) Tauolapp::Tauola::setTauBr(vJAK[i],vBR[i]);
}
else {std::cout << "WARNING invalid size for setTauBr - JAK: " << vJAK.size() << " BR: " << vBR.size() << std::endl;}
}
}
}

// override decay modes if needs be
//
// we have to do it AFTER init because otherwises branching ratios are NOT filled in
Expand Down
Expand Up @@ -3,4 +3,4 @@
#include "GeneratorInterface/TauolaInterface/interface/TauolaFactory.h"
#include "GeneratorInterface/TauolaInterface/interface/TauolappInterface.h"

DEFINE_EDM_PLUGIN(TauolaFactory, gen::TauolappInterface, "Tauolapp113a");
DEFINE_EDM_PLUGIN(TauolaFactory, gen::TauolappInterface, "Tauolapp114");