CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
gen::TauolaInterface Class Reference

#include <TauolaInterface.h>

Inheritance diagram for gen::TauolaInterface:
gen::TauolaInterfaceBase

Public Member Functions

HepMC::GenEvent * decay (HepMC::GenEvent *)
 
void disablePolarization ()
 
void enablePolarization ()
 
void init (const edm::EventSetup &)
 
const std::vector< int > & operatesOnParticles ()
 
void SetDecayRandomEngine (CLHEP::HepRandomEngine *decayRandomEngine)
 
void statistics ()
 
 TauolaInterface (const edm::ParameterSet &)
 
 ~TauolaInterface ()
 
- Public Member Functions inherited from gen::TauolaInterfaceBase
 TauolaInterfaceBase ()
 
 TauolaInterfaceBase (const edm::ParameterSet &)
 
virtual ~TauolaInterfaceBase ()
 

Private Attributes

bool fIsInitialized
 
edm::ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 
int fPolarization
 
Pythia6ServicefPy6Service
 

Additional Inherited Members

- Protected Attributes inherited from gen::TauolaInterfaceBase
std::vector< int > fPDGs
 

Detailed Description

Definition at line 29 of file TauolaInterface.h.

Constructor & Destructor Documentation

TauolaInterface::TauolaInterface ( const edm::ParameterSet pset)

Definition at line 67 of file TauolaInterface.cc.

References fPolarization, fPy6Service, edm::ParameterSet::getParameter(), and ki_taumod_.

68  : fIsInitialized(false)
69 {
71 
72  fPolarization = pset.getParameter<bool>("UseTauolaPolarization") ? 1 : 0 ;
73 
74  // set Tauola defaults
75  //
76  ki_taumod_.pjak1 = -1;
77  ki_taumod_.pjak2 = -1;
78  ki_taumod_.mdtau = -1;
79 
80  // read tau decay mode switches
81  //
82  ParameterSet cards = pset.getParameter< ParameterSet >("InputCards");
83  ki_taumod_.pjak1 = cards.getParameter< int >( "pjak1" );
84  ki_taumod_.pjak2 = cards.getParameter< int >( "pjak2" );
85  ki_taumod_.mdtau = cards.getParameter< int >( "mdtau" );
86 }
T getParameter(std::string const &) const
struct @338 ki_taumod_
Pythia6Service * fPy6Service
TauolaInterface::~TauolaInterface ( )

Definition at line 88 of file TauolaInterface.cc.

References fPy6Service.

89 {
90  delete fPy6Service;
91 }
Pythia6Service * fPy6Service

Member Function Documentation

HepMC::GenEvent * TauolaInterface::decay ( HepMC::GenEvent *  evt)
virtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 146 of file TauolaInterface.cc.

References abs, gen::FortranInstance::call(), conv, alignCSCRings::e, fIsInitialized, fPDGTable, fPolarization, fPy6Service, errorMatrix2Lands_multiChannel::id, create_public_lumi_plots::log, m, scaleCards::mass, alignBH_cfg::mode, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, gen::ranmar_(), ntuplemaker::status, lumiQTWidget::t, tauola_srs_(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

147 {
148  // event record convertor
149  //
150  HepMC::IO_HEPEVT conv;
151 
152  if ( !fIsInitialized ) return conv.read_next_event();
153 
154  // We are using random numbers, we are fetched through Pythia6Service
155  // (through ranmar_ below) -> so grab the instance during decay()
156 
157  Pythia6Service::InstanceWrapper pythia6InstanceGuard( fPy6Service );
158 
159  // fill up HEPEVT common block
160  //
161  // IDEALLY, this should be the way to go
162  // BUT !!! this utility fills it up in the "reshuffled" order,
163  // and later on Tauola chocks on it
164  //
165  // Needs to be sorted out, eith in HepMC, or in Tauola, or both !!!
166  //
167  // At present, this thing blindly relies on the assumption that
168  // HEPEVT is always there - which wont be the case with Py8 or Hwg++
169  //
170  //HepMC::IO_HEPEVT conv;
171  //conv.write_event( evt ) ;
172 
173  int numPartBeforeTauola = HepMC::HEPEVT_Wrapper::number_entries();
174  // HepMC::HEPEVT_Wrapper::print_hepevt();
175 
176  int mode = 0;
177  // tauola_( &mode, &fPolarization );
179 
180  int numPartAfterTauola = HepMC::HEPEVT_Wrapper::number_entries();
181  // HepMC::HEPEVT_Wrapper::print_hepevt();
182 
183  // before we do the conversion, we need to deal with decay vertexes
184  // since Tauola knows nothing about lifetimes, all decay vertexes are set to 0.
185  // nees to set them properly, knowing lifetime !
186  // here we do it on HEPEVT record, also for consistency, although it's probably
187  // even easier to deal with HepMC::GenEvent record
188 
189  // find 1st "non-doc" tau
190  //
191  bool foundTau = false;
192  for ( int ip=1; ip<=numPartAfterTauola; ip++ )
193  {
194  if ( std::abs( HepMC::HEPEVT_Wrapper::id( ip ) ) == 15
195  && HepMC::HEPEVT_Wrapper::status( ip ) != 3 )
196  {
197  foundTau = true;
198  break;
199  }
200  }
201 
202  if ( !foundTau )
203  {
204  // no tau found
205  // just give up here
206  //
207  return conv.read_next_event();
208  }
209 
210  std::vector<int> PrntIndx;
211 
212  for ( int ip=numPartAfterTauola; ip>numPartBeforeTauola; ip-- ) // Fortran indexing !
213  {
214 
215  // first of all, find out how many generations in decay chain
216  //
217  PrntIndx.clear();
218  int Prnt = HepMC::HEPEVT_Wrapper::first_parent(ip);
219  ip -= (HepMC::HEPEVT_Wrapper::number_children(Prnt)-1); // such that we don't go the same part again
220  PrntIndx.push_back( Prnt );
221  while ( abs( HepMC::HEPEVT_Wrapper::id(Prnt) ) != 15 ) // shortcut; need to loop over fPDGs...
222  {
223  int Prnt1 = HepMC::HEPEVT_Wrapper::first_parent( Prnt );
224  Prnt = Prnt1;
225  // such that the tau always appear at the start of the list
226  PrntIndx.insert( PrntIndx.begin(), Prnt );
227  ip -= HepMC::HEPEVT_Wrapper::number_children(Prnt); // such that we don't go the same part again
228  }
229  for ( size_t iprt=0; iprt<PrntIndx.size(); iprt++ )
230  {
231  int Indx = PrntIndx[iprt];
232  int PartID = HepMC::HEPEVT_Wrapper::id( Indx );
233  const HepPDT::ParticleData*
234  PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
235  //
236  // prob = exp(-t/lifetime) ==> t = -lifetime * log(prob)
237  //
238  float prob = 0.;
239  int length=1;
240  ranmar_(&prob,&length);
241  double lifetime = PData->lifetime().value();
242  //
243  // in case of Py6, this would be copied into V(5,i)
244  // for HEPEVT, need to check...
245  //
246  double ct = -lifetime * std::log(prob);
247  //
248  double ee = HepMC::HEPEVT_Wrapper::e( Indx );
249  double px = HepMC::HEPEVT_Wrapper::px( Indx );
250  double py = HepMC::HEPEVT_Wrapper::py( Indx );
251  double pz = HepMC::HEPEVT_Wrapper::pz( Indx );
252  // double pp = std::sqrt( px*px + py*py + pz*pz );
253  double mass = HepMC::HEPEVT_Wrapper::m( Indx );
254  //
255  // this is in py6 terms:
256  // VDCY(J)=V(IP,J)+V(IP,5)*P(IP,J)/P(IP,5)
257  //
258  double VxDec = HepMC::HEPEVT_Wrapper::x( Indx );
259  VxDec += ct * (px/mass);
260  double VyDec = HepMC::HEPEVT_Wrapper::y( Indx );
261  VyDec += ct * (py/mass);
262  double VzDec = HepMC::HEPEVT_Wrapper::z( Indx );
263  VzDec += ct * (pz/mass);
264  double VtDec = HepMC::HEPEVT_Wrapper::t( Indx );
265  VtDec += ct * (ee/mass);
266  for ( int idau=HepMC::HEPEVT_Wrapper::first_child( Indx );
267  idau<=HepMC::HEPEVT_Wrapper::last_child( Indx ); idau++ )
268  {
269  HepMC::HEPEVT_Wrapper::set_position( idau, VxDec, VyDec, VzDec, VtDec );
270  }
271  }
272  }
273  return conv.read_next_event();
274 
275 }
void call(void(&fn)())
static HepMC::IO_HEPEVT conv
#define abs(x)
Definition: mlp_lapack.h:159
double double double z
void tauola_srs_(int *, int *)
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
void ranmar_(float *rvec, int *lenv)
HepPDT::ParticleData ParticleData
Pythia6Service * fPy6Service
tuple mass
Definition: scaleCards.py:27
Definition: DDAxes.h:10
tuple status
Definition: ntuplemaker.py:245
void gen::TauolaInterface::disablePolarization ( )
inlinevirtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 39 of file TauolaInterface.h.

References fPolarization.

39 { fPolarization = 0; return; }
void gen::TauolaInterface::enablePolarization ( )
inlinevirtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 38 of file TauolaInterface.h.

References fPolarization.

38 { fPolarization = 1; return; }
void TauolaInterface::init ( const edm::EventSetup es)
virtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 98 of file TauolaInterface.cc.

References gen::FortranInstance::call(), gather_cfg::cout, fIsInitialized, gen::TauolaInterfaceBase::fPDGs, fPDGTable, fPolarization, fPy6Service, edm::EventSetup::getData(), ki_taumod_, alignBH_cfg::mode, hitfit::return, tauola_srs_(), and taurep_().

99 {
100  if ( fIsInitialized ) return; // do init only once
101 
102  if ( ki_taumod_.mdtau <= -1 ) // actually, need to throw exception !
103  return ;
104 
105  fPDGs.push_back( 15 ) ;
106  es.getData( fPDGTable ) ;
107 
108  cout << "----------------------------------------------" << endl;
109  cout << "Initializing Tauola" << endl;
110  if ( fPolarization == 0 )
111  {
112  cout << "Tauola: Polarization disabled" << endl;
113  }
114  else if ( fPolarization == 1 )
115  {
116  cout << "Tauola: Polarization enabled" << endl;
117  }
118 
119 // FIXME !!!
120 // This is a temporary hack - we're re-using master generator's seed to init RANMAR
121 // FIXME !!!
122 // This is now off because ranmar has been overriden (see code above) to use pyr_(...)
123 // - this way we're using guaranteed initialized rndm generator... BUT !!! in the long
124 // run we may want a separate random stream for tauola...
125 
126 // Service<RandomNumberGenerator> rng;
127 // int seed = rng->mySeed() ;
128 // int ntot=0, ntot2=0;
129 // rmarin_( &seed, &ntot, &ntot2 );
130 
131  int mode = -2;
132  taurep_( &mode ) ;
133  mode = -1;
134  // tauola_( &mode, &fPolarization );
135  // tauola_srs_( &mode, &fPolarization );
136  //
137  // We're using the call(...) method here because it'll make sure that Py6
138  // is initialized, and that's done only once, and will grab exatly that instance
139  //
141 
142  fIsInitialized = true;
143  return;
144 }
void call(void(&fn)())
struct @338 ki_taumod_
void getData(T &iHolder) const
Definition: EventSetup.h:67
void tauola_srs_(int *, int *)
void taurep_(int *)
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
Pythia6Service * fPy6Service
tuple cout
Definition: gather_cfg.py:121
const std::vector<int>& gen::TauolaInterface::operatesOnParticles ( )
inlinevirtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 41 of file TauolaInterface.h.

References gen::TauolaInterfaceBase::fPDGs.

41 { return fPDGs; }
void TauolaInterface::SetDecayRandomEngine ( CLHEP::HepRandomEngine *  decayRandomEngine)
virtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 93 of file TauolaInterface.cc.

References TauolaInterfaceVar::decayRandomEngine, and decayRandomEngine.

93  {
95 }
CLHEP::HepRandomEngine * decayRandomEngine
CLHEP::HepRandomEngine * decayRandomEngine
void TauolaInterface::statistics ( )
virtual

Reimplemented from gen::TauolaInterfaceBase.

Definition at line 277 of file TauolaInterface.cc.

References gen::FortranInstance::call(), fPolarization, fPy6Service, alignBH_cfg::mode, and tauola_srs_().

278 {
279  int mode = 1;
280  // tauola_( &mode, &fPolarization ) ;
281  // tauola_srs_( &mode, &fPolarization ) ;
283  return;
284 }
void call(void(&fn)())
void tauola_srs_(int *, int *)
Pythia6Service * fPy6Service

Member Data Documentation

bool gen::TauolaInterface::fIsInitialized
private

Definition at line 50 of file TauolaInterface.h.

Referenced by decay(), and init().

edm::ESHandle<HepPDT::ParticleDataTable> gen::TauolaInterface::fPDGTable
private

Definition at line 48 of file TauolaInterface.h.

Referenced by decay(), and init().

int gen::TauolaInterface::fPolarization
private
Pythia6Service* gen::TauolaInterface::fPy6Service
private

Definition at line 49 of file TauolaInterface.h.

Referenced by decay(), init(), statistics(), TauolaInterface(), and ~TauolaInterface().