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
 
LumiMonitorFilterfLumiFilter
 
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 19 of file Generator.h.

Constructor & Destructor Documentation

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

Definition at line 22 of file Generator.cc.

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

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

Definition at line 95 of file Generator.cc.

References fLumiFilter.

96 {
97  delete fLumiFilter;
98 }
LumiMonitorFilter * fLumiFilter
Definition: Generator.h:57

Member Function Documentation

virtual const double Generator::eventWeight ( ) const
inlinevirtual

Definition at line 31 of file Generator.h.

References weight_.

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

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

Definition at line 29 of file Generator.h.

References evt_.

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

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

Definition at line 30 of file Generator.h.

References vtx_.

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

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

Definition at line 100 of file Generator.cc.

References fEtaCuts, spr::find(), fLumiFilter, fPCuts, fPDGFilter, fPhiCuts, fPtransCut, GenParticle::GenParticle, GeV, LumiMonitorFilter::isGoodForLumiMonitor(), 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 RunManagerMTWorker::generateEvent(), and RunManager::generateEvent().

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

Definition at line 495 of file Generator.cc.

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

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

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

Definition at line 384 of file Generator.cc.

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

Referenced by HepMC2G4().

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

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

Referenced by nonBeamEvent2G4().

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

Definition at line 25 of file Generator.h.

References evt_, and mathSSE::return().

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

26  { evt_ = (HepMC::GenEvent*)inpevt; return ; }
return((rh^lh)&mask)
HepMC::GenEvent * evt_
Definition: Generator.h:58
void Generator::setGenId ( G4PrimaryParticle *  p,
int  id 
) const
inlineprivate

Definition at line 38 of file Generator.h.

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

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

Member Data Documentation

HepMC::GenEvent* Generator::evt_
private

Definition at line 58 of file Generator.h.

Referenced by genEvent(), and setGenEvent().

bool Generator::fEtaCuts
private

Definition at line 44 of file Generator.h.

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

LumiMonitorFilter* Generator::fLumiFilter
private

Definition at line 57 of file Generator.h.

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

bool Generator::fPCuts
private

Definition at line 42 of file Generator.h.

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

bool Generator::fPDGFilter
private

Definition at line 64 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

bool Generator::fPhiCuts
private

Definition at line 45 of file Generator.h.

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

bool Generator::fPtransCut
private

Definition at line 43 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

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

Definition at line 62 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

bool Generator::pdgFilterSel
private

Definition at line 63 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::theDecLenCut
private

Definition at line 55 of file Generator.h.

Referenced by Generator().

double Generator::theDecRCut2
private

Definition at line 53 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::theEtaCutForHector
private

Definition at line 54 of file Generator.h.

Referenced by Generator().

double Generator::theMaxEtaCut
private

Definition at line 49 of file Generator.h.

Referenced by Generator(), and particlePassesPrimaryCuts().

double Generator::theMaxPCut
private

Definition at line 52 of file Generator.h.

Referenced by HepMC2G4(), and particlePassesPrimaryCuts().

double Generator::theMaxPhiCut
private

Definition at line 47 of file Generator.h.

Referenced by HepMC2G4(), and particlePassesPrimaryCuts().

double Generator::theMinEtaCut
private

Definition at line 48 of file Generator.h.

Referenced by Generator().

double Generator::theMinPCut
private

Definition at line 50 of file Generator.h.

Referenced by Generator().

double Generator::theMinPhiCut
private

Definition at line 46 of file Generator.h.

double Generator::theMinPtCut2
private

Definition at line 51 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

int Generator::verbose
private

Definition at line 56 of file Generator.h.

math::XYZTLorentzVector* Generator::vtx_
private

Definition at line 59 of file Generator.h.

Referenced by genVertex(), and HepMC2G4().

double Generator::weight_
private

Definition at line 60 of file Generator.h.

Referenced by eventWeight(), and HepMC2G4().

double Generator::Z_hector
private

Definition at line 61 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::Z_lmax
private

Definition at line 61 of file Generator.h.

Referenced by Generator(), and HepMC2G4().

double Generator::Z_lmin
private

Definition at line 61 of file Generator.h.

Referenced by Generator(), and HepMC2G4().