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>

Public Member Functions

HepMC::GenEvent * decay (HepMC::GenEvent *)
 
void disablePolarization ()
 
void enablePolarization ()
 
void init (const edm::EventSetup &)
 
const std::vector< int > & operatesOnParticles ()
 
void statistics ()
 
 TauolaInterface (const edm::ParameterSet &)
 
 ~TauolaInterface ()
 

Private Attributes

bool fIsInitialized
 
std::vector< int > fPDGs
 
edm::ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 
int fPolarization
 
Pythia6ServicefPy6Service
 

Detailed Description

Definition at line 21 of file TauolaInterface.h.

Constructor & Destructor Documentation

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

Definition at line 52 of file TauolaInterface.cc.

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

53  : fIsInitialized(false)
54 {
56 
57  fPolarization = pset.getParameter<bool>("UseTauolaPolarization") ? 1 : 0 ;
58 
59  // set Tauola defaults
60  //
61  ki_taumod_.pjak1 = -1;
62  ki_taumod_.pjak2 = -1;
63  ki_taumod_.mdtau = -1;
64 
65  // read tau decay mode switches
66  //
67  ParameterSet cards = pset.getParameter< ParameterSet >("InputCards");
68  ki_taumod_.pjak1 = cards.getParameter< int >( "pjak1" );
69  ki_taumod_.pjak2 = cards.getParameter< int >( "pjak2" );
70  ki_taumod_.mdtau = cards.getParameter< int >( "mdtau" );
71 
72 }
T getParameter(std::string const &) const
struct @246 ki_taumod_
Pythia6Service * fPy6Service
TauolaInterface::~TauolaInterface ( )

Definition at line 74 of file TauolaInterface.cc.

References fPy6Service.

75 {
76  delete fPy6Service;
77 }
Pythia6Service * fPy6Service

Member Function Documentation

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

Definition at line 129 of file TauolaInterface.cc.

References abs, gen::FortranInstance::call(), conv, fIsInitialized, fPDGTable, fPolarization, fPy6Service, funct::log(), m, mode, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, ranmar_(), ntuplemaker::status, matplotRender::t, tauola_srs_(), x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by gen::ExternalDecayDriver::decay().

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

Definition at line 30 of file TauolaInterface.h.

References fPolarization.

30 { fPolarization = 0; return; }
void gen::TauolaInterface::enablePolarization ( )
inline

Definition at line 29 of file TauolaInterface.h.

References fPolarization.

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

Definition at line 79 of file TauolaInterface.cc.

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

Referenced by gen::ExternalDecayDriver::init().

80 {
81 
82  if ( fIsInitialized ) return; // do init only once
83 
84  if ( ki_taumod_.mdtau <= -1 ) // actually, need to throw exception !
85  return ;
86 
87  fPDGs.push_back( 15 ) ;
88  es.getData( fPDGTable ) ;
89 
90  cout << "----------------------------------------------" << endl;
91  cout << "Initializing Tauola" << endl;
92  if ( fPolarization == 0 )
93  {
94  cout << "Tauola: Polarization disabled" << endl;
95  }
96  else if ( fPolarization == 1 )
97  {
98  cout << "Tauola: Polarization enabled" << endl;
99  }
100 
101 // FIXME !!!
102 // This is a temporary hack - we're re-using master generator's seed to init RANMAR
103 // FIXME !!!
104 // This is now off because ranmar has been overriden (see code above) to use pyr_(...)
105 // - this way we're using guaranteed initialized rndm generator... BUT !!! in the long
106 // run we may want a separate random stream for tauola...
107 
108 // Service<RandomNumberGenerator> rng;
109 // int seed = rng->mySeed() ;
110 // int ntot=0, ntot2=0;
111 // rmarin_( &seed, &ntot, &ntot2 );
112 
113  int mode = -2;
114  taurep_( &mode ) ;
115  mode = -1;
116  // tauola_( &mode, &fPolarization );
117  // tauola_srs_( &mode, &fPolarization );
118  //
119  // We're using the call(...) method here because it'll make sure that Py6
120  // is initialized, and that's done only once, and will grab exatly that instance
121  //
123 
124  fIsInitialized = true;
125 
126  return;
127 }
void call(void(&fn)())
void getData(T &iHolder) const
Definition: EventSetup.h:67
return((rh^lh)&mask)
void tauola_srs_(int *, int *)
void taurep_(int *)
edm::ESHandle< HepPDT::ParticleDataTable > fPDGTable
struct @246 ki_taumod_
std::vector< int > fPDGs
int mode
Definition: AMPTWrapper.h:139
Pythia6Service * fPy6Service
tuple cout
Definition: gather_cfg.py:41
const std::vector<int>& gen::TauolaInterface::operatesOnParticles ( )
inline

Definition at line 32 of file TauolaInterface.h.

References fPDGs.

Referenced by gen::ExternalDecayDriver::init().

32 { return fPDGs; }
std::vector< int > fPDGs
void TauolaInterface::statistics ( )

Definition at line 262 of file TauolaInterface.cc.

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

Referenced by gen::ExternalDecayDriver::statistics().

263 {
264  int mode = 1;
265  // tauola_( &mode, &fPolarization ) ;
266  // tauola_srs_( &mode, &fPolarization ) ;
268  return;
269 }
void call(void(&fn)())
void tauola_srs_(int *, int *)
int mode
Definition: AMPTWrapper.h:139
Pythia6Service * fPy6Service

Member Data Documentation

bool gen::TauolaInterface::fIsInitialized
private

Definition at line 44 of file TauolaInterface.h.

Referenced by decay(), and init().

std::vector<int> gen::TauolaInterface::fPDGs
private

Definition at line 39 of file TauolaInterface.h.

Referenced by init(), and operatesOnParticles().

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

Definition at line 42 of file TauolaInterface.h.

Referenced by decay(), and init().

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

Definition at line 43 of file TauolaInterface.h.

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