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 Member Functions | Private Attributes
Generator Class Reference

#include <Generator.h>

Public Member Functions

virtual const double eventWeight () const
 
 Generator (const edm::ParameterSet &p)
 
virtual const HepMC::GenEvent * genEvent () const
 
virtual const
math::XYZTLorentzVector
genVertex () const
 
void HepMC2G4 (const HepMC::GenEvent *g, G4Event *e)
 
void nonBeamEvent2G4 (const HepMC::GenEvent *g, G4Event *e)
 
void setGenEvent (const HepMC::GenEvent *inpevt)
 
virtual ~Generator ()
 

Private Member Functions

void particleAssignDaughters (G4PrimaryParticle *p, HepMC::GenParticle *hp, double length)
 
bool particlePassesPrimaryCuts (const G4ThreeVector &p) const
 
void setGenId (G4PrimaryParticle *p, int id) const
 

Private Attributes

HepMC::GenEvent * evt_
 
bool fEtaCuts
 
bool fPCuts
 
bool fPDGFilter
 
bool fPhiCuts
 
bool fPtransCut
 
std::vector< int > pdgFilter
 
bool pdgFilterSel
 
double theDecLenCut
 
double theDecRCut2
 
double theEtaCutForHector
 
double theMaxEtaCut
 
double theMaxPCut
 
double theMaxPhiCut
 
double theMinEtaCut
 
double theMinPCut
 
double theMinPhiCut
 
double theMinPtCut2
 
int verbose
 
math::XYZTLorentzVectorvtx_
 
double weight_
 
double Z_hector
 
double Z_lmax
 
double Z_lmin
 

Detailed Description

Definition at line 18 of file Generator.h.

Constructor & Destructor Documentation

Generator::Generator ( const edm::ParameterSet p)

Definition at line 21 of file Generator.cc.

References edm::ParameterSet::exists(), create_public_lumi_plots::exp, fEtaCuts, fPCuts, fPDGFilter, fPhiCuts, fPtransCut, edm::ParameterSet::getParameter(), cuy::ii, pdgFilter, pdgFilterSel, theDecLenCut, theDecRCut2, theEtaCutForHector, theMaxEtaCut, theMinEtaCut, theMinPCut, theMinPtCut2, Z_hector, Z_lmax, and Z_lmin.

21  :
22  fPCuts(p.getParameter<bool>("ApplyPCuts")),
23  fPtransCut(p.getParameter<bool>("ApplyPtransCut")),
24  fEtaCuts(p.getParameter<bool>("ApplyEtaCuts")),
25  fPhiCuts(p.getParameter<bool>("ApplyPhiCuts")),
26  theMinPhiCut(p.getParameter<double>("MinPhiCut")), // in radians (CMS standard)
27  theMaxPhiCut(p.getParameter<double>("MaxPhiCut")),
28  theMinEtaCut(p.getParameter<double>("MinEtaCut")),
29  theMaxEtaCut(p.getParameter<double>("MaxEtaCut")),
30  theMinPCut(p.getParameter<double>("MinPCut")), // in GeV (CMS standard)
31  theMaxPCut(p.getParameter<double>("MaxPCut")),
32  theEtaCutForHector(p.getParameter<double>("EtaCutForHector")),
33  verbose(p.getUntrackedParameter<int>("Verbosity",0)),
34  evt_(0),
35  vtx_(0),
36  weight_(0),
37  Z_lmin(0),
38  Z_lmax(0),
39  Z_hector(0),
40  pdgFilterSel(false),
41  fPDGFilter(false)
42 {
43  double theRDecLenCut = p.getParameter<double>("RDecLenCut")*cm;
44  theDecRCut2 = theRDecLenCut*theRDecLenCut;
45 
47 
48  double theDecLenCut = p.getParameter<double>("LDecLenCut")*cm;
49 
50  pdgFilter.resize(0);
51  if ( p.exists("PDGselection") ) {
52  pdgFilterSel = (p.getParameter<edm::ParameterSet>("PDGselection")).
53  getParameter<bool>("PDGfilterSel");
54  pdgFilter = (p.getParameter<edm::ParameterSet>("PDGselection")).
55  getParameter<std::vector< int > >("PDGfilter");
56  if(0 < pdgFilter.size()) {
57  fPDGFilter = true;
58  for ( unsigned int ii = 0; ii < pdgFilter.size(); ++ii) {
59  if (pdgFilterSel) {
60  edm::LogWarning("SimG4CoreGenerator")
61  << " *** Selecting only PDG ID = " << pdgFilter[ii];
62  } else {
63  edm::LogWarning("SimG4CoreGenerator") << " *** Filtering out PDG ID = "
64  << pdgFilter[ii];
65  }
66  }
67  }
68  }
69 
70  if(fEtaCuts){
71  Z_lmax = theRDecLenCut*((1 - exp(-2*theMaxEtaCut) )/( 2*exp(-theMaxEtaCut)));
72  Z_lmin = theRDecLenCut*((1 - exp(-2*theMinEtaCut) )/( 2*exp(-theMinEtaCut)));
73  }
74 
75  Z_hector = theRDecLenCut*((1 - exp(-2*theEtaCutForHector))
76  / ( 2*exp(-theEtaCutForHector) ) );
77 
78  edm::LogInfo("SimG4CoreGenerator")
79  << " Rdecaycut= " << theRDecLenCut/cm
80  << " cm; Zdecaycut= " << theDecLenCut/cm
81  << "Z_min= " << Z_lmin/cm << " cm; Z_max= " << Z_lmax
82  << " cm; Z_hector = " << Z_hector << " cm\n"
83  << "ApplyPCuts: " << fPCuts << " ApplyPtransCut: " << fPtransCut
84  << " ApplyEtaCuts: " << fEtaCuts
85  << " ApplyPhiCuts: " << fPhiCuts;
86 }
double theDecRCut2
Definition: Generator.h:52
bool fPhiCuts
Definition: Generator.h:44
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
double theMinPtCut2
Definition: Generator.h:50
double theEtaCutForHector
Definition: Generator.h:53
double Z_lmax
Definition: Generator.h:59
double theMaxPhiCut
Definition: Generator.h:46
bool fPtransCut
Definition: Generator.h:42
bool exists(std::string const &parameterName) const
checks if a parameter exists
double theDecLenCut
Definition: Generator.h:54
double theMinEtaCut
Definition: Generator.h:47
bool pdgFilterSel
Definition: Generator.h:61
int ii
Definition: cuy.py:588
double theMinPCut
Definition: Generator.h:49
bool fPDGFilter
Definition: Generator.h:62
double theMinPhiCut
Definition: Generator.h:45
double weight_
Definition: Generator.h:58
double theMaxEtaCut
Definition: Generator.h:48
double theMaxPCut
Definition: Generator.h:51
math::XYZTLorentzVector * vtx_
Definition: Generator.h:57
HepMC::GenEvent * evt_
Definition: Generator.h:56
double Z_lmin
Definition: Generator.h:59
int verbose
Definition: Generator.h:55
std::vector< int > pdgFilter
Definition: Generator.h:60
bool fEtaCuts
Definition: Generator.h:43
double Z_hector
Definition: Generator.h:59
bool fPCuts
Definition: Generator.h:41
Generator::~Generator ( )
virtual

Definition at line 88 of file Generator.cc.

89 {}

Member Function Documentation

virtual const double Generator::eventWeight ( ) const
inlinevirtual

Definition at line 30 of file Generator.h.

References weight_.

Referenced by RunManager::produce(), and RunManagerMT::produce().

30 { return weight_; }
double weight_
Definition: Generator.h:58
virtual const HepMC::GenEvent* Generator::genEvent ( ) const
inlinevirtual

Definition at line 28 of file Generator.h.

References evt_.

Referenced by RunManager::produce(), and RunManagerMT::produce().

28 { return evt_; }
HepMC::GenEvent * evt_
Definition: Generator.h:56
virtual const math::XYZTLorentzVector* Generator::genVertex ( ) const
inlinevirtual

Definition at line 29 of file Generator.h.

References vtx_.

Referenced by RunManager::produce(), and RunManagerMT::produce().

29 { return vtx_; }
math::XYZTLorentzVector * vtx_
Definition: Generator.h:57
void Generator::HepMC2G4 ( const HepMC::GenEvent *  g,
G4Event *  e 
)

Definition at line 91 of file Generator.cc.

References DeDxDiscriminatorTools::charge(), fEtaCuts, spr::find(), fPCuts, fPDGFilter, fPhiCuts, fPtransCut, configurableAnalysis::GenParticle, LogDebug, AlCaHLTBitMon_ParallelJobs::p, particleAssignDaughters(), pdgFilter, pdgFilterSel, phi, setGenId(), mathSSE::sqrt(), ntuplemaker::status, theDecRCut2, theMaxPCut, theMaxPhiCut, theMinPtCut2, vtx_, weight_, Z_hector, Z_lmax, and Z_lmin.

Referenced by RunManager::generateEvent(), and RunManagerMT::generateEvent().

92 {
93 
94  if ( *(evt_orig->vertices_begin()) == 0 ) {
95  throw SimG4Exception("SimG4CoreGenerator: Corrupted Event - GenEvent with no vertex");
96  }
97 
98  HepMC::GenEvent* evt = new HepMC::GenEvent(*evt_orig);
99 
100  if (evt->weights().size() > 0) {
101 
102  weight_ = evt->weights()[0] ;
103  for (unsigned int iw=1; iw<evt->weights().size(); ++iw) {
104 
105  // terminate if the versot of weights contains a zero-weight
106  if ( evt->weights()[iw] <= 0 ) break;
107  weight_ *= evt->weights()[iw] ;
108  }
109  }
110 
111  if (vtx_ != 0) delete vtx_;
112  vtx_ = new math::XYZTLorentzVector((*(evt->vertices_begin()))->position().x(),
113  (*(evt->vertices_begin()))->position().y(),
114  (*(evt->vertices_begin()))->position().z(),
115  (*(evt->vertices_begin()))->position().t());
116 
117  if(verbose > 0) {
118  evt->print();
119  LogDebug("SimG4CoreGenerator") << "Primary Vertex = ("
120  << vtx_->x() << ","
121  << vtx_->y() << ","
122  << vtx_->z() << ")";
123  }
124 
125  unsigned int ng4vtx = 0;
126 
127  for(HepMC::GenEvent::vertex_const_iterator vitr= evt->vertices_begin();
128  vitr != evt->vertices_end(); ++vitr ) {
129 
130  // loop for vertex, is it a real vertex?
131  G4bool qvtx=false;
132  HepMC::GenVertex::particle_iterator pitr;
133  for (pitr= (*vitr)->particles_begin(HepMC::children);
134  pitr != (*vitr)->particles_end(HepMC::children); ++pitr) {
135 
136  // Particles which are not decayed by generator
137  if (1 == (*pitr)->status()) {
138  qvtx = true;
139  if (verbose > 2) LogDebug("SimG4CoreGenerator")
140  << "GenVertex barcode = " << (*vitr)->barcode()
141  << " selected for GenParticle barcode = " << (*pitr)->barcode();
142  break;
143  }
144  // The selection is made considering if the partcile with status = 2
145  // have the end_vertex with a radius greater than the radius of beampipe
146  // cilinder (no requirement on the Z of the vertex is applyed).
147  else if (2 == (*pitr)->status()) {
148 
149  if ( (*pitr)->end_vertex() != 0 ) {
150  double xx = (*pitr)->end_vertex()->position().x();
151  double yy = (*pitr)->end_vertex()->position().y();
152  double r_dd = xx*xx+yy*yy;
153  if (r_dd > theDecRCut2) {
154  qvtx = true;
155  if (verbose > 2) LogDebug("SimG4CoreGenerator")
156  << "GenVertex barcode = " << (*vitr)->barcode()
157  << " selected for GenParticle barcode = "
158  << (*pitr)->barcode() << " radius = " << std::sqrt(r_dd);
159  break;
160  }
161  } else {
162  // particles with status 2 without end_vertex are
163  // equivalent to stable
164  qvtx = true;
165  }
166  }
167  }
168 
169  // if this vertex is inside fiductial volume inside the beam pipe
170  // and has no long-lived secondary the vertex is not saved
171  if (!qvtx) {
172  continue;
173  }
174 
175  double x1 = (*vitr)->position().x()*mm;
176  double y1 = (*vitr)->position().y()*mm;
177  double z1 = (*vitr)->position().z()*mm;
178  double t1 = (*vitr)->position().t()*mm/c_light;
179 
180  G4PrimaryVertex* g4vtx = new G4PrimaryVertex(x1, y1, z1, t1);
181 
182  for (pitr= (*vitr)->particles_begin(HepMC::children);
183  pitr != (*vitr)->particles_end(HepMC::children); ++pitr){
184 
185  // Filter on allowed particle species if required
186  if (fPDGFilter) {
187  std::vector<int>::iterator it = find(pdgFilter.begin(),pdgFilter.end(),
188  (*pitr)->pdg_id());
189  if ( (it != pdgFilter.end() && !pdgFilterSel)
190  || ( it == pdgFilter.end() && pdgFilterSel ) ) {
191  if (verbose > 2) LogDebug("SimG4CoreGenerator")
192  << "Skip GenParticle barcode = " << (*pitr)->barcode()
193  << " PDG Id = " << (*pitr)->pdg_id();
194  continue;
195  }
196  }
197 
198  double x2 = 0.0;
199  double y2 = 0.0;
200  double z2 = 0.0;
201  double decay_length = 0.0;
202  int status = (*pitr)->status();
203 
204  // check the status, 2 has end point with decay defined by generator
205  if (1 == status || 2 == status) {
206 
207  // this particle has decayed but have no vertex
208  // it is an exotic case
209  if ( !(*pitr)->end_vertex() ) {
210  status = 1;
211  } else {
212  x2 = (*pitr)->end_vertex()->position().x();
213  y2 = (*pitr)->end_vertex()->position().y();
214  z2 = (*pitr)->end_vertex()->position().z();
215  decay_length =
216  std::sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
217  }
218  }
219 
220  bool toBeAdded = false;
221  double px = (*pitr)->momentum().px();
222  double py = (*pitr)->momentum().py();
223  double pz = (*pitr)->momentum().pz();
224  double ptot = std::sqrt(px*px + py*py + pz*pz);
225  math::XYZTLorentzVector p(px, py, pz, (*pitr)->momentum().e());
226 
227  double ximpact = x1;
228  double yimpact = y1;
229  double zimpact = z1;
230 
231  // protection against numerical problems for extremely low momenta
232  // compute impact point at transition to Hector
233  const double minTan = 1.e-20;
234  if(fabs(z1) < Z_hector && fabs(pz) >= minTan*ptot) {
235  if(pz > 0.0) { zimpact = Z_hector; }
236  else { zimpact = -Z_hector; }
237  double del = (zimpact - z1)/pz;
238  ximpact += del*px;
239  yimpact += del*py;
240  }
241  double rimpact2 = ximpact*ximpact + yimpact*yimpact;
242 
243  if (verbose > 2) LogDebug("SimG4CoreGenerator")
244  << "Processing GenParticle barcode= " << (*pitr)->barcode()
245  << " pdg= " << (*pitr)-> pdg_id()
246  << " status= " << (*pitr)->status()
247  << " st= " << status
248  << " rimpact(cm)= " << std::sqrt(rimpact2)/cm
249  << " zimpact(cm)= " << zimpact/cm
250  << " ptot(GeV)= " << ptot
251  << " pz(GeV)= " << pz;
252 
253  // Particles of status 1 trasnported along the beam pipe for forward
254  // detectors (HECTOR) always pass to Geant4 without cuts
255  if( 1 == status &&
256  fabs(zimpact) >= Z_hector && rimpact2 <= theDecRCut2) {
257  toBeAdded = true;
258  if ( verbose > 2 ) LogDebug("SimG4CoreGenerator")
259  << "GenParticle barcode = " << (*pitr)->barcode()
260  << " passed case 3";
261  } else {
262 
263  // Standard case: particles not decayed by the generator
264  if(1 == status &&
265  (fabs(zimpact) < Z_hector || rimpact2 > theDecRCut2)) {
266 
267  // Ptot cut for all particles
268  if (fPCuts && (ptot < theMinPCut || ptot > theMaxPCut)) {
269  continue;
270  }
271  // phi cut is applied mainly for particle gun
272  if (fPhiCuts) {
273  double phi = p.phi();
274  if(phi < theMinPhiCut || phi > theMaxPhiCut) {
275  continue;
276  }
277  }
278  // eta cut is applied if position of the decay
279  // is within vacuum chamber and limited in Z
280  if(fEtaCuts) {
281 
282  // eta cut
283  double xi = x1;
284  double yi = y1;
285  double zi = z1;
286 
287  // can be propagated along Z
288  if(fabs(pz) >= minTan*ptot) {
289  if((zi >= Z_lmax) & (pz < 0.0)) {
290  zi = Z_lmax;
291  } else if((zi <= Z_lmin) & (pz > 0.0)) {
292  zi = Z_lmin;
293  } else {
294  if(pz > 0) { zi = Z_lmax; }
295  else { zi = Z_lmin; }
296  }
297  double del = (zi - z1)/pz;
298  xi += del*px;
299  yi += del*py;
300  }
301  // check eta cut
302  if((zi >= Z_lmin) & (zi <= Z_lmax)
303  & (xi*xi + yi*yi < theDecRCut2)) {
304  continue;
305  }
306  }
307  toBeAdded = true;
308  if ( verbose > 2 ) LogDebug("SimG4CoreGenerator")
309  << "GenParticle barcode = " << (*pitr)->barcode()
310  << " passed case 1";
311 
312  // Decay chain outside the fiducial cylinder defined by theRDecLenCut
313  // are used for Geant4 tracking with predefined decay channel
314  // In the case of decay in vacuum particle is not tracked by Geant4
315  } else if(2 == status &&
316  x2*x2 + y2*y2 >= theDecRCut2 && fabs(z2) < Z_hector) {
317 
318  toBeAdded = true;
319  if ( verbose > 2 ) LogDebug("SimG4CoreGenerator")
320  << "GenParticle barcode = " << (*pitr)->barcode()
321  << " passed case 2"
322  << " decay_length(cm)= " << decay_length/cm;
323  }
324  }
325  if(toBeAdded){
326 
327  G4int pdgcode= (*pitr)-> pdg_id();
328  G4PrimaryParticle* g4prim=
329  new G4PrimaryParticle(pdgcode, px*GeV, py*GeV, pz*GeV);
330 
331  if ( g4prim->GetG4code() != 0 ){
332  g4prim->SetMass( g4prim->GetG4code()->GetPDGMass() );
333  double charge = g4prim->GetG4code()->GetPDGCharge();
334 
335  // apply Pt cut
336  if (fPtransCut &&
337  0.0 != charge && px*px + py*py < theMinPtCut2) {
338  delete g4prim;
339  continue;
340  }
341  g4prim->SetCharge(charge);
342  }
343 
344  // V.I. do not use SetWeight but the same code
345  // value of the code compute inside TrackWithHistory
346  //g4prim->SetWeight( 10000*(*vpitr)->barcode() ) ;
347  setGenId( g4prim, (*pitr)->barcode() );
348 
349  if (2 == status) {
351  (HepMC::GenParticle *) *pitr, decay_length);
352  }
353  if ( verbose > 1 ) g4prim->Print();
354  g4vtx->SetPrimary(g4prim);
355 
356  // impose also proper time for status=1 and available end_vertex
357  // VI: this is impossible, so commented out
358  /*
359  if ( 1 == status && decay_length > 0.0) {
360  double proper_time = decay_length/(p.Beta()*p.Gamma()*c_light);
361  if ( verbose > 1 ) LogDebug("SimG4CoreGenerator")
362  <<"Setting proper time for beta="<<p.Beta()<<" gamma="
363  <<p.Gamma()<<" Proper time=" <<proper_time/ns<<" ns" ;
364  g4prim->SetProperTime(proper_time);
365  }
366  */
367  }
368  }
369 
370  if ( verbose > 1 ) g4vtx->Print();
371  g4evt->AddPrimaryVertex(g4vtx);
372  ++ng4vtx;
373  }
374 
375  // Add a protection for completely empty events (produced by LHCTransport):
376  // add a dummy vertex with no particle attached to it
377  if ( ng4vtx == 0 ) {
378  G4PrimaryVertex* g4vtx = new G4PrimaryVertex(0.0, 0.0, 0.0, 0.0);
379  if ( verbose > 1 ) g4vtx->Print();
380  g4evt->AddPrimaryVertex(g4vtx);
381  }
382 
383  delete evt;
384 }
#define LogDebug(id)
double theDecRCut2
Definition: Generator.h:52
bool fPhiCuts
Definition: Generator.h:44
void setGenId(G4PrimaryParticle *p, int id) const
Definition: Generator.h:37
double theMinPtCut2
Definition: Generator.h:50
double Z_lmax
Definition: Generator.h:59
double theMaxPhiCut
Definition: Generator.h:46
bool fPtransCut
Definition: Generator.h:42
bool pdgFilterSel
Definition: Generator.h:61
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double charge(const std::vector< uint8_t > &Ampls)
void particleAssignDaughters(G4PrimaryParticle *p, HepMC::GenParticle *hp, double length)
Definition: Generator.cc:386
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T sqrt(T t)
Definition: SSEVec.h:48
bool fPDGFilter
Definition: Generator.h:62
double weight_
Definition: Generator.h:58
double theMaxPCut
Definition: Generator.h:51
math::XYZTLorentzVector * vtx_
Definition: Generator.h:57
double Z_lmin
Definition: Generator.h:59
std::vector< int > pdgFilter
Definition: Generator.h:60
tuple status
Definition: ntuplemaker.py:245
bool fEtaCuts
Definition: Generator.h:43
double Z_hector
Definition: Generator.h:59
Definition: DDAxes.h:10
bool fPCuts
Definition: Generator.h:41
void Generator::nonBeamEvent2G4 ( const HepMC::GenEvent *  g,
G4Event *  e 
)

Definition at line 500 of file Generator.cc.

References configurableAnalysis::GenParticle, i, particlePassesPrimaryCuts(), setGenId(), and findQualityFiles::v.

Referenced by RunManager::generateEvent(), and RunManagerMT::generateEvent().

501 {
502  int i = 0;
503  for(HepMC::GenEvent::particle_const_iterator it = evt->particles_begin();
504  it != evt->particles_end(); ++it ) {
505  ++i;
506  HepMC::GenParticle * gp = (*it);
507  int g_status = gp->status();
508  // storing only particle with status == 1
509  if (g_status == 1) {
510  int g_id = gp->pdg_id();
511  G4PrimaryParticle * g4p =
512  new G4PrimaryParticle(g_id,gp->momentum().px()*GeV,
513  gp->momentum().py()*GeV,
514  gp->momentum().pz()*GeV);
515  if (g4p->GetG4code() != 0) {
516  g4p->SetMass(g4p->GetG4code()->GetPDGMass());
517  g4p->SetCharge(g4p->GetG4code()->GetPDGCharge());
518  }
519  // V.I. do not use SetWeight but the same code
520  // value of the code compute inside TrackWithHistory
521  //g4p->SetWeight(i*10000);
522  setGenId(g4p,i);
523  if (particlePassesPrimaryCuts(g4p->GetMomentum())) {
524  G4PrimaryVertex * v =
525  new G4PrimaryVertex(gp->production_vertex()->position().x()*mm,
526  gp->production_vertex()->position().y()*mm,
527  gp->production_vertex()->position().z()*mm,
528  gp->production_vertex()->position().t()*mm/c_light);
529  v->SetPrimary(g4p);
530  g4evt->AddPrimaryVertex(v);
531  if(verbose > 0) { v->Print(); }
532 
533  } else {
534  delete g4p;
535  }
536  }
537  } // end loop on HepMC particles
538 }
int i
Definition: DBlmapReader.cc:9
void setGenId(G4PrimaryParticle *p, int id) const
Definition: Generator.h:37
bool particlePassesPrimaryCuts(const G4ThreeVector &p) const
Definition: Generator.cc:467
void Generator::particleAssignDaughters ( G4PrimaryParticle *  p,
HepMC::GenParticle *  hp,
double  length 
)
private

Definition at line 386 of file Generator.cc.

References createTree::dd, LogDebug, AlCaHLTBitMon_ParallelJobs::p, setGenId(), and mathSSE::sqrt().

Referenced by HepMC2G4().

389 {
390  // V.I.: not needed anymore
391  //if (!(vp->end_vertex())) return;
392 
393  if ( verbose > 1 )
394  LogDebug("SimG4CoreGenerator")
395  << "Special case of long decay length \n"
396  << "Assign daughters with to mother with decaylength="
397  << decaylength/cm << " cm";
398 
399  math::XYZTLorentzVector p(vp->momentum().px(), vp->momentum().py(),
400  vp->momentum().pz(), vp->momentum().e());
401 
402  // defined preassigned decay time
403  double proper_time = decaylength/(p.Beta()*p.Gamma()*c_light);
404  g4p->SetProperTime(proper_time);
405 
406  if( verbose > 2 ) {
407  LogDebug("SimG4CoreGenerator") <<" px= "<< p.px()
408  <<" py= "<< p.py()
409  <<" pz= "<< p.pz()
410  <<" e= " << p.e()
411  <<" beta= "<< p.Beta()
412  <<" gamma= " << p.Gamma()
413  <<" Proper time= " <<proper_time/ns <<" ns";
414  }
415 
416  // the particle will decay after the same length if it
417  // has not interacted before
418  double x1 = vp->end_vertex()->position().x();
419  double y1 = vp->end_vertex()->position().y();
420  double z1 = vp->end_vertex()->position().z();
421 
422  for (HepMC::GenVertex::particle_iterator
423  vpdec= vp->end_vertex()->particles_begin(HepMC::children);
424  vpdec != vp->end_vertex()->particles_end(HepMC::children); ++vpdec) {
425 
426  //transform decay products such that in the rest frame of mother
427  math::XYZTLorentzVector pdec((*vpdec)->momentum().px(),
428  (*vpdec)->momentum().py(),
429  (*vpdec)->momentum().pz(),
430  (*vpdec)->momentum().e());
431 
432  // children should only be taken into account once
433  G4PrimaryParticle * g4daught=
434  new G4PrimaryParticle((*vpdec)->pdg_id(), pdec.x()*GeV,
435  pdec.y()*GeV, pdec.z()*GeV);
436 
437  if ( g4daught->GetG4code() != 0 )
438  {
439  g4daught->SetMass( g4daught->GetG4code()->GetPDGMass() ) ;
440  g4daught->SetCharge( g4daught->GetG4code()->GetPDGCharge() ) ;
441  }
442 
443  // V.I. do not use SetWeight but the same code
444  // value of the code compute inside TrackWithHistory
445  //g4daught->SetWeight( 10000*(*vpdec)->barcode() ) ;
446  setGenId( g4daught, (*vpdec)->barcode() );
447 
448  if ( verbose > 2 ) LogDebug("SimG4CoreGenerator")
449  <<"Assigning a "<< (*vpdec)->pdg_id()
450  <<" as daughter of a " << vp->pdg_id();
451  if ( (*vpdec)->status() == 2 && (*vpdec)->end_vertex() != 0 )
452  {
453  double x2 = (*vpdec)->end_vertex()->position().x();
454  double y2 = (*vpdec)->end_vertex()->position().y();
455  double z2 = (*vpdec)->end_vertex()->position().z();
456  double dd = std::sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
457  particleAssignDaughters(g4daught,*vpdec,dd);
458  }
459 
460  (*vpdec)->set_status(1000+(*vpdec)->status());
461  g4p->SetDaughter(g4daught);
462  if ( verbose > 1 ) g4daught->Print();
463  }
464 }
#define LogDebug(id)
void setGenId(G4PrimaryParticle *p, int id) const
Definition: Generator.h:37
void particleAssignDaughters(G4PrimaryParticle *p, HepMC::GenParticle *hp, double length)
Definition: Generator.cc:386
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
T sqrt(T t)
Definition: SSEVec.h:48
bool Generator::particlePassesPrimaryCuts ( const G4ThreeVector &  p) const
private

Definition at line 467 of file Generator.cc.

References alignCSCRings::e, eta(), fEtaCuts, fPCuts, fPhiCuts, LogDebug, phi, theMaxEtaCut, theMaxPCut, and theMaxPhiCut.

Referenced by nonBeamEvent2G4().

468 {
469  bool flag = true;
470  double ptot = p.mag();
471  if (fPCuts && (ptot < theMinPCut*GeV || ptot > theMaxPCut*GeV)) {
472  flag = false;
473  }
474  if (fEtaCuts && flag) {
475  double pz = p.z();
476  if(ptot < pz + 1.e-10) {
477  flag = false;
478 
479  } else {
480  double eta = 0.5*G4Log((ptot + pz)/(ptot - pz));
481  if(eta < theMinEtaCut || eta > theMaxEtaCut) {
482  flag = false;
483  }
484  }
485  }
486  if (fPhiCuts && flag) {
487  double phi = p.phi();
488  if(phi < theMinPhiCut || phi > theMaxPhiCut) {
489  flag = false;
490  }
491  }
492 
493  if ( verbose > 2 ) LogDebug("SimG4CoreGenerator")
494  << "Generator ptot(GeV)= " << ptot/GeV << " eta= " << p.eta()
495  << " phi= " << p.phi() << " Flag= " << flag;
496 
497  return flag;
498 }
#define LogDebug(id)
bool fPhiCuts
Definition: Generator.h:44
double theMaxPhiCut
Definition: Generator.h:46
T eta() const
double theMaxEtaCut
Definition: Generator.h:48
double theMaxPCut
Definition: Generator.h:51
bool fEtaCuts
Definition: Generator.h:43
Definition: DDAxes.h:10
bool fPCuts
Definition: Generator.h:41
void Generator::setGenEvent ( const HepMC::GenEvent *  inpevt)
inline

Definition at line 24 of file Generator.h.

References evt_, and reco::return().

Referenced by RunManager::generateEvent(), and RunManagerMT::generateEvent().

25  { evt_ = (HepMC::GenEvent*)inpevt; return ; }
HepMC::GenEvent * evt_
Definition: Generator.h:56
return(e1-e2)*(e1-e2)+dp *dp
void Generator::setGenId ( G4PrimaryParticle *  p,
int  id 
) const
inlineprivate

Definition at line 37 of file Generator.h.

Referenced by HepMC2G4(), nonBeamEvent2G4(), and particleAssignDaughters().

38  { p->SetUserInformation(new GenParticleInfo(id));}

Member Data Documentation

HepMC::GenEvent* Generator::evt_
private

Definition at line 56 of file Generator.h.

Referenced by genEvent(), and setGenEvent().

bool Generator::fEtaCuts
private

Definition at line 43 of file Generator.h.

Referenced by Generator(), HepMC2G4(), and particlePassesPrimaryCuts().

bool Generator::fPCuts
private

Definition at line 41 of file Generator.h.

Referenced by Generator(), HepMC2G4(), and particlePassesPrimaryCuts().

bool Generator::fPDGFilter
private

Definition at line 62 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

bool Generator::fPhiCuts
private

Definition at line 44 of file Generator.h.

Referenced by Generator(), HepMC2G4(), and particlePassesPrimaryCuts().

bool Generator::fPtransCut
private

Definition at line 42 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

std::vector<int> Generator::pdgFilter
private

Definition at line 60 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

bool Generator::pdgFilterSel
private

Definition at line 61 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::theDecLenCut
private

Definition at line 54 of file Generator.h.

Referenced by Generator().

double Generator::theDecRCut2
private

Definition at line 52 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::theEtaCutForHector
private

Definition at line 53 of file Generator.h.

Referenced by Generator().

double Generator::theMaxEtaCut
private

Definition at line 48 of file Generator.h.

Referenced by Generator(), and particlePassesPrimaryCuts().

double Generator::theMaxPCut
private

Definition at line 51 of file Generator.h.

Referenced by HepMC2G4(), and particlePassesPrimaryCuts().

double Generator::theMaxPhiCut
private

Definition at line 46 of file Generator.h.

Referenced by HepMC2G4(), and particlePassesPrimaryCuts().

double Generator::theMinEtaCut
private

Definition at line 47 of file Generator.h.

Referenced by Generator().

double Generator::theMinPCut
private

Definition at line 49 of file Generator.h.

Referenced by Generator().

double Generator::theMinPhiCut
private

Definition at line 45 of file Generator.h.

double Generator::theMinPtCut2
private

Definition at line 50 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

int Generator::verbose
private

Definition at line 55 of file Generator.h.

math::XYZTLorentzVector* Generator::vtx_
private

Definition at line 57 of file Generator.h.

Referenced by genVertex(), and HepMC2G4().

double Generator::weight_
private

Definition at line 58 of file Generator.h.

Referenced by eventWeight(), and HepMC2G4().

double Generator::Z_hector
private

Definition at line 59 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::Z_lmax
private

Definition at line 59 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::Z_lmin
private

Definition at line 59 of file Generator.h.

Referenced by Generator(), and HepMC2G4().