4 #include "Tauola/Tauola.h"
5 #include "TauSpinner/tau_reweight_lib.h"
6 #include "TauSpinner/Tauola_wrapper.h"
8 #include "TLorentzVector.h"
10 #include "CLHEP/Random/RandomEngine.h"
16 using namespace TauSpinner;
21 for(
int i = 0;
i < *lenv;
i++)
34 isReco_(pset.getParameter<bool>(
"isReco"))
35 ,isTauolaConfigured_(pset.getParameter<bool>(
"isTauolaConfigured" ))
36 ,isLHPDFConfigured_(pset.getParameter<bool>(
"isLHPDFConfigured" ))
37 ,LHAPDFname_(pset.getUntrackedParameter(
"LHAPDFname",(
string)(
"MSTW2008nnlo90cl.LHgrid")))
38 ,CMSEnergy_(pset.getParameter<double>(
"CMSEnergy"))
39 ,gensrc_(pset.getParameter<edm::
InputTag>(
"gensrc"))
40 ,MotherPDGID_(pset.getUntrackedParameter(
"MotherPDGID",(int)(-1)))
41 ,Ipol_(pset.getUntrackedParameter(
"Ipol",(int)(0)))
42 ,nonSM2_(pset.getUntrackedParameter(
"nonSM2",(int)(0)))
43 ,nonSMN_(pset.getUntrackedParameter(
"nonSMN",(int)(0)))
44 ,roundOff_(pset.getUntrackedParameter(
"roundOff",(double)(0.01)))
46 produces<bool>(
"TauSpinnerWTisValid").setBranchAlias(
"TauSpinnerWTisValid");
47 produces<double>(
"TauSpinnerWT").setBranchAlias(
"TauSpinnerWT");
48 produces<double>(
"TauSpinnerWTFlip").setBranchAlias(
"TauSpinnerWTFlip");
49 produces<double>(
"TauSpinnerWThplus").setBranchAlias(
"TauSpinnerWThplus");
50 produces<double>(
"TauSpinnerWThminus").setBranchAlias(
"TauSpinnerWThminus");
56 if(!rng.isAvailable()) {
58 <<
"The RandomNumberProducer module requires the RandomNumberGeneratorService\n"
59 "which appears to be absent. Please add that service to your configuration\n"
60 "or remove the modules that require it." << std::endl;
69 Tauolapp::Tauola::initialize();
89 SimpleParticle
X,
tau, tau2;
90 std::vector<SimpleParticle> tau_daughters, tau_daughters2;
98 const HepMC::GenEvent* Evt = EvtHandle->GetEvent() ;
104 if(
abs(X.pdgid())==24 ||
abs(X.pdgid())==37 ){
105 TLorentzVector tau_1r(0,0,0,0);
106 TLorentzVector tau_1(tau.px(),tau.py(),tau.pz(),tau.e());
107 for(
unsigned int i=0;
i<tau_daughters.size();
i++){
108 tau_1r+=TLorentzVector(tau_daughters.at(
i).px(),tau_daughters.at(
i).py(),tau_daughters.at(
i).pz(),tau_daughters.at(
i).e());
110 if(fabs(tau_1r.M()-tau_1.M())<
roundOff_){
111 WT = TauSpinner::calculateWeightFromParticlesWorHpn(X, tau, tau2, tau_daughters);
116 else if( X.pdgid()==25 || X.pdgid()==36 || X.pdgid()==22 || X.pdgid()==23 ){
117 TLorentzVector tau_1r(0,0,0,0), tau_2r(0,0,0,0);
118 TLorentzVector tau_1(tau.px(),tau.py(),tau.pz(),tau.e()), tau_2(tau2.px(),tau2.py(),tau2.pz(),tau2.e());
119 for(
unsigned int i=0;
i<tau_daughters.size();
i++){
120 tau_1r+=TLorentzVector(tau_daughters.at(
i).px(),tau_daughters.at(
i).py(),tau_daughters.at(
i).pz(),tau_daughters.at(
i).e());
122 for(
unsigned int i=0;
i<tau_daughters2.size();
i++){
123 tau_2r+=TLorentzVector(tau_daughters2.at(
i).px(),tau_daughters2.at(
i).py(),tau_daughters2.at(
i).pz(),tau_daughters2.at(
i).e());
127 WT = TauSpinner::calculateWeightFromParticlesH(X, tau, tau2, tau_daughters,tau_daughters2);
130 if(X.pdgid()==25 || X.pdgid()==22 || X.pdgid()==23 ){
131 if(X.pdgid()==25) X.setPdgid(23);
132 if( X.pdgid()==22 || X.pdgid()==23 ) X.setPdgid(25);
134 double WTother=TauSpinner::calculateWeightFromParticlesH(X, tau, tau2, tau_daughters,tau_daughters2);
140 cout<<
"TauSpinner: WARNING: Unexpected PDG for tau mother: "<<X.pdgid()<<endl;
145 if(!(0<=WT && WT<10)){isValid=
false; WT=1.0; WTFlip=1.0;}
146 std::auto_ptr<bool> TauSpinnerWeightisValid(
new bool);
147 *TauSpinnerWeightisValid =isValid;
148 e.
put(TauSpinnerWeightisValid,
"TauSpinnerWTisValid");
151 std::auto_ptr<double> TauSpinnerWeight(
new double);
152 *TauSpinnerWeight =WT;
153 e.
put(TauSpinnerWeight,
"TauSpinnerWT");
156 std::auto_ptr<double> TauSpinnerWeightFlip(
new double);
157 *TauSpinnerWeightFlip =WTFlip;
158 e.
put(TauSpinnerWeightFlip,
"TauSpinnerWTFlip");
162 if(polSM<0.0 && polSM!=-999 && isValid) WThplus=0;
163 std::auto_ptr<double> TauSpinnerWeighthplus(
new double);
164 *TauSpinnerWeighthplus = WThplus;
165 e.
put(TauSpinnerWeighthplus,
"TauSpinnerWThplus");
169 if(polSM>0.0&& polSM!=-999 && isValid) WThminus=0;
170 std::auto_ptr<double> TauSpinnerWeighthminus(
new double);
171 *TauSpinnerWeighthminus = WThminus;
172 e.
put(TauSpinnerWeighthminus,
"TauSpinnerWThminus");
182 std::vector<SimpleParticle> &tau_daughters,std::vector<SimpleParticle> &tau2_daughters){
185 for(reco::GenParticleCollection::const_iterator itr = genParticles->begin(); itr!= genParticles->end(); ++itr){
186 int pdgid=
abs(itr->pdgId());
187 if(pdgid==24 || pdgid==37 || pdgid ==25 || pdgid==36 || pdgid==22 || pdgid==23 ){
193 unsigned int ntau(0),ntauornu(0);
194 for(
unsigned int i=0;
i<itr->numberOfDaughters();
i++){
198 if(ntau==0 &&
abs(dau->
pdgId())==15){
211 if((ntau==2 && ntauornu==2) || (ntau==1 && ntauornu==2)){
212 X.setPx(itr->p4().Px());
213 X.setPy(itr->p4().Py());
214 X.setPz(itr->p4().Pz());
215 X.setE (itr->p4().E());
216 X.setPdgid(itr->pdgId());
217 tau.setPx(recotau1->
p4().Px());
218 tau.setPy(recotau1->
p4().Py());
219 tau.setPz(recotau1->
p4().Pz());
220 tau.setE (recotau1->
p4().E());
221 tau.setPdgid(recotau1->
pdgId());
223 tau2.setPx(recotau2->
p4().Px());
224 tau2.setPy(recotau2->
p4().Py());
225 tau2.setPz(recotau2->
p4().Pz());
226 tau2.setE (recotau2->
p4().E());
227 tau2.setPdgid(recotau2->
pdgId());
258 SimpleParticle tp(Particle->
p4().Px(), Particle->
p4().Py(), Particle->
p4().Pz(), Particle->
p4().E(), Particle->
pdgId());
259 daughters.push_back(tp);
void GetLastSelf(const reco::GenParticle *Particle)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
edm::EDGetTokenT< reco::GenParticleCollection > gensrcToken_
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
virtual int pdgId() const GCC11_FINAL
PDG identifier.
#define DEFINE_FWK_MODULE(type)
bool isFirst(const reco::GenParticle *Particle)
edm::EDGetTokenT< edm::HepMCProduct > EvtHandleToken_
void rmarin_(int *, int *, int *)
void GetRecoDaughters(const reco::GenParticle *Particle, std::vector< TauSpinner::SimpleParticle > &daughters, int parentpdgid)
static bool isTauSpinnerConfigure
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
virtual size_t numberOfMothers() const
number of mothers
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Abs< T >::type abs(const T &t)
int readParticlesfromReco(edm::Event &e, TauSpinner::SimpleParticle &X, TauSpinner::SimpleParticle &tau, TauSpinner::SimpleParticle &tau2, std::vector< TauSpinner::SimpleParticle > &tau_daughters, std::vector< TauSpinner::SimpleParticle > &tau2_daughters)
void ranmar_(float *rvec, int *lenv)
virtual int pdgId() const =0
PDG identifier.
int readParticlesFromHepMC(const HepMC::GenEvent *event, TauSpinner::SimpleParticle &X, TauSpinner::SimpleParticle &tau, TauSpinner::SimpleParticle &tau2, std::vector< TauSpinner::SimpleParticle > &tau_daughters, std::vector< TauSpinner::SimpleParticle > &tau2_daughters)
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
return(e1-e2)*(e1-e2)+dp *dp
TauSpinnerCMS(const edm::ParameterSet &)
CLHEP::HepRandomEngine * decayRandomEngine
virtual const Candidate * mother(size_type=0) const
return mother at a given position, i = 0, ... numberOfMothers() - 1 (read only mode) ...