CMS 3D CMS Logo

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

#include <MultiParticleInConeGunSource.h>

Inheritance diagram for edm::MultiParticleInConeGunSource:
edm::BaseFlatGunSource edm::GeneratedInputSource edm::ConfigurableInputSource edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 MultiParticleInConeGunSource (const ParameterSet &, const InputSourceDescription &)
 
virtual ~MultiParticleInConeGunSource ()
 
- Public Member Functions inherited from edm::BaseFlatGunSource
 BaseFlatGunSource (const ParameterSet &, const InputSourceDescription &)
 
void beginRun (edm::Run &r, const edm::EventSetup &)
 
virtual ~BaseFlatGunSource ()
 
- Public Member Functions inherited from edm::GeneratedInputSource
 GeneratedInputSource (ParameterSet const &pset, InputSourceDescription const &desc)
 
virtual ~GeneratedInputSource ()
 
- Public Member Functions inherited from edm::ConfigurableInputSource
 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
LuminosityBlockNumber_t luminosityBlock () const
 
unsigned int numberEventsInLumi () const
 
unsigned int numberEventsInRun () const
 
unsigned int numberEventsInThisLumi () const
 
unsigned int numberEventsInThisRun () const
 
TimeValue_t presentTime () const
 
RunNumber_t run () const
 
unsigned int timeBetweenEvents () const
 
virtual ~ConfigurableInputSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool const primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryID const & processHistoryID () const
 Accessor for the input process history ID of the current run. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi ()
 Read next luminosity block. More...
 
void readAndCacheRun ()
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
void wakeUp ()
 Wake up the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 

Protected Attributes

std::vector< int > fInConeIds
 
double fInConeMaxEta
 
double fInConeMaxPhi
 
unsigned int fInConeMaxTry
 
double fInConeMinEta
 
double fInConeMinPhi
 
double fMaxDeltaR
 
double fMaxMomRatio
 
double fMaxPt
 
double fMinDeltaR
 
double fMinMomRatio
 
double fMinPt
 
- Protected Attributes inherited from edm::BaseFlatGunSource
bool fAddAntiParticle
 
HepMC::GenEvent * fEvt
 
double fMaxEta
 
double fMaxPhi
 
double fMinEta
 
double fMinPhi
 
std::vector< int > fPartIDs
 
ESHandle
< HepPDT::ParticleDataTable
fPDGTable
 
CLHEP::HepRandomEngine & fRandomEngine
 
CLHEP::RandFlat * fRandomGenerator
 
int fVerbosity
 

Private Member Functions

virtual bool produce (Event &e)
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ConfigurableInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ConfigurableInputSource
void reallyReadEvent ()
 
void setEventNumber (EventNumber_t e)
 
void setTime (TimeValue_t t)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipal *const eventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setLumiPrematurelyRead ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setRunPrematurelyRead ()
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Detailed Description

Definition at line 15 of file MultiParticleInConeGunSource.h.

Constructor & Destructor Documentation

MultiParticleInConeGunSource::MultiParticleInConeGunSource ( const ParameterSet pset,
const InputSourceDescription desc 
)

Definition at line 23 of file MultiParticleInConeGunSource.cc.

References fInConeIds, fInConeMaxEta, fInConeMaxPhi, fInConeMaxTry, fInConeMinEta, fInConeMinPhi, fMaxDeltaR, fMaxMomRatio, fMaxPt, fMinDeltaR, fMinMomRatio, fMinPt, and edm::ParameterSet::getUntrackedParameter().

24  :
25  BaseFlatGunSource(pset, desc)
26 {
27 
28 
29  ParameterSet defpset ;
30  ParameterSet pgun_params =
31  pset.getUntrackedParameter<ParameterSet>("PGunParameters",defpset) ;
32 
33  fMinPt = pgun_params.getUntrackedParameter<double>("MinPt",0.99);
34  fMaxPt = pgun_params.getUntrackedParameter<double>("MaxPt",1.01);
35 
36  fInConeIds = pgun_params.getUntrackedParameter< vector<int> >("InConeID",vector<int>());
37  fMinDeltaR = pgun_params.getUntrackedParameter<double>("MinDeltaR",0.0);
38  fMaxDeltaR = pgun_params.getUntrackedParameter<double>("MaxDeltaR",0.1);
39  fMinMomRatio = pgun_params.getUntrackedParameter<double>("MinMomRatio",0.99);
40  fMaxMomRatio = pgun_params.getUntrackedParameter<double>("MaxMomRatio",1.01);
41 
42  fInConeMinEta = pgun_params.getUntrackedParameter<double>("InConeMinEta",-5.5);
43  fInConeMaxEta = pgun_params.getUntrackedParameter<double>("InConeMaxEta",5.5);
44  fInConeMinPhi = pgun_params.getUntrackedParameter<double>("InConeMinPhi",-3.14159265358979323846);
45  fInConeMaxPhi = pgun_params.getUntrackedParameter<double>("InConeMaxPhi",3.14159265358979323846);
46  fInConeMaxTry = pgun_params.getUntrackedParameter<unsigned int>("InConeMaxTry",100);
47 
48  produces<HepMCProduct>();
49 }
T getUntrackedParameter(std::string const &, T const &) const
BaseFlatGunSource(const ParameterSet &, const InputSourceDescription &)
MultiParticleInConeGunSource::~MultiParticleInConeGunSource ( )
virtual

Definition at line 51 of file MultiParticleInConeGunSource.cc.

52 {
53  // no need to cleanup GenEvent memory - done in HepMCProduct
54 }

Member Function Documentation

bool MultiParticleInConeGunSource::produce ( Event e)
privatevirtual

Implements edm::ConfigurableInputSource.

Definition at line 56 of file MultiParticleInConeGunSource.cc.

References abs, alpha, funct::cos(), gather_cfg::cout, dPhi(), relval_parameters_module::energy, eta(), edm::ConfigurableInputSource::event(), funct::exp(), edm::BaseFlatGunSource::fAddAntiParticle, edm::BaseFlatGunSource::fEvt, fInConeIds, fInConeMaxEta, fInConeMaxPhi, fInConeMaxTry, fMaxDeltaR, edm::BaseFlatGunSource::fMaxEta, fMaxMomRatio, edm::BaseFlatGunSource::fMaxPhi, fMaxPt, fMinDeltaR, edm::BaseFlatGunSource::fMinEta, fMinMomRatio, edm::BaseFlatGunSource::fMinPhi, fMinPt, edm::BaseFlatGunSource::fPartIDs, edm::BaseFlatGunSource::fPDGTable, edm::BaseFlatGunSource::fRandomGenerator, edm::BaseFlatGunSource::fVerbosity, configurableAnalysis::GenParticle, L1TEmulatorMonitor_cff::p, RecoTau_DiTaus_pt_20-420_cfg::ParticleID, phi, ExpressReco_HICollisions_FallBack::pt, edm::Event::put(), funct::sin(), mathSSE::sqrt(), and theta().

57 {
58 
59  if ( fVerbosity > 0 )
60  {
61  cout << " MultiParticleInConeGunSource : Begin New Event Generation" << endl ;
62  }
63  // event loop (well, another step in it...)
64 
65  // no need to clean up GenEvent memory - done in HepMCProduct
66  //
67 
68  // here re-create fEvt (memory)
69  //
70  fEvt = new HepMC::GenEvent() ;
71 
72  // now actualy, cook up the event from PDGTable and gun parameters
73  //
74  // 1st, primary vertex
75  //
76  //HepMC::GenVertex* Vtx = new HepMC::GenVertex(CLHEP::HepLorentzVector(0.,0.,0.));
77  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(0.,0.,0.));
78 
79  // loop over particles
80  //
81  int barcode = 1 ;
82  for (unsigned int ip=0; ip<fPartIDs.size(); ++ip)
83  {
84 
85  double pt = fRandomGenerator->fire(fMinPt, fMaxPt) ;
86  double eta = fRandomGenerator->fire(fMinEta, fMaxEta) ;
87  double phi = fRandomGenerator->fire(fMinPhi, fMaxPhi) ;
88  int PartID = fPartIDs[ip] ;
89  const HepPDT::ParticleData*
90  PData = fPDGTable->particle(HepPDT::ParticleID(abs(PartID))) ;
91  double mass = PData->mass().value() ;
92  double theta = 2.*atan(exp(-eta)) ;
93  double mom = pt/sin(theta) ;
94  double px = pt*cos(phi) ;
95  double py = pt*sin(phi) ;
96  double pz = mom*cos(theta) ;
97  double energy2= mom*mom + mass*mass ;
98  double energy = sqrt(energy2) ;
99 
100  HepMC::FourVector p(px,py,pz,energy) ;
101  HepMC::GenParticle* Part =
102  new HepMC::GenParticle(p,PartID,1);
103  Part->suggest_barcode( barcode ) ;
104  barcode++ ;
105  Vtx->add_particle_out(Part);
106 
107  if ( fAddAntiParticle ){}
108 
109  // now add the particles in the cone
110  for (unsigned iPic=0; iPic!=fInConeIds.size();iPic++){
111  unsigned int nTry=0;
112  while(true){
113  //shoot flat Deltar
114  double dR = fRandomGenerator->fire(fMinDeltaR, fMaxDeltaR);
115  //shoot flat eta/phi mixing
116  double alpha = fRandomGenerator->fire(-3.14159265358979323846, 3.14159265358979323846);
117  double dEta = dR*cos(alpha);
118  double dPhi = dR*sin(alpha);
119 
120  /*
121  //shoot Energy of associated particle
122  double energyIc = fRandomGenerator->fire(fMinEInCone, fMaxEInCone);
123  if (mom2Ic>0){ momIC = sqrt(mom2Ic);}
124  */
125  // get kinematics
126  double etaIc = eta+dEta;
127  double phiIc = phi+dPhi;
128  //put it back in -Pi:Pi if necessary. multiple time might be necessary if dR > 3
129  const unsigned int maxL=100;
130  unsigned int iL=0;
131  while(iL++<maxL){
132  if (phiIc > 3.14159265358979323846) phiIc-=2*3.14159265358979323846;
133  else if(phiIc <-3.14159265358979323846) phiIc+=2*3.14159265358979323846;
134 
135  if (abs(phiIc)<3.14159265358979323846) break;
136  }
137 
138 
139  //allow to skip it if you did not run out of possible drawing
140  if (nTry++<=fInConeMaxTry){
141  //draw another one if this one is not in acceptance
142  if (etaIc<fInConeMinEta || etaIc > fInConeMaxEta) continue;
143  if (phiIc<fInConeMinPhi || phiIc > fInConeMaxPhi) continue;
144  }
145  else{
146  if ( fVerbosity > 0 )
147  {
148  cout << " MultiParticleInConeGunSource : could not produce a particle "
149  << fInConeIds[iPic]<<" in cone "
150  << fMinDeltaR<<" to "<<fMaxDeltaR<<" within the "<<fInConeMaxTry<<" allowed tries."<<endl;
151  }
152  /* edm::LogError("MultiParticleInConeGunSource")<< " MultiParticleInConeGunSource : could not produce a particle "<<
153  fInConeIds[iPic]<<" in cone "<<
154  fMinDeltaR<<" to "<<fMaxDeltaR<<" within the "<<fInConeMaxTry<<" allowed tries.";*/
155  }
156  int PartIDIc=fInConeIds[iPic];
157  const HepPDT::ParticleData*
158  PDataIc = fPDGTable->particle(HepPDT::ParticleID(abs(PartIDIc)));
159 
160  //shoot momentum ratio
161  double momR = fRandomGenerator->fire(fMinMomRatio, fMaxMomRatio);
162  double massIc= PDataIc->mass().value() ;
163  double momIc = momR * mom;
164  double energyIc = sqrt(momIc*momIc + massIc*massIc);
165 
166  double thetaIc = 2.*atan(exp(-etaIc)) ;
167  double pxIc = momIc*sin(thetaIc)*cos(phiIc);
168  double pyIc = momIc*sin(thetaIc)*sin(phiIc);
169  double pzIc = momIc*cos(thetaIc);
170 
171  HepMC::FourVector pIc(pxIc,pyIc,pzIc,energyIc) ;
172  HepMC::GenParticle* PartIc = new HepMC::GenParticle(pIc, PartIDIc, 1);
173  PartIc->suggest_barcode( barcode ) ;
174  barcode++ ;
175  Vtx->add_particle_out(PartIc);
176  break;
177  }//try many times while not in acceptance
178  }//loop over the particle Ids in the cone
179  }
180 
181  fEvt->add_vertex(Vtx) ;
182  fEvt->set_event_number(event()) ;
183  fEvt->set_signal_process_id(20) ;
184 
185  if ( fVerbosity > 0 )
186  {
187  fEvt->print() ;
188  }
189 
190  auto_ptr<HepMCProduct> BProduct(new HepMCProduct()) ;
191  BProduct->addHepMCData( fEvt );
192  e.put(BProduct);
193 
194  if ( fVerbosity > 0 )
195  {
196  cout << " MultiParticleInConeGunSource : Event Generation Done " << endl;
197  }
198 
199  return true;
200 }
std::vector< int > fPartIDs
float alpha
Definition: AMPTWrapper.h:95
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define abs(x)
Definition: mlp_lapack.h:159
CLHEP::RandFlat * fRandomGenerator
Geom::Theta< T > theta() const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T eta() const
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
T sqrt(T t)
Definition: SSEVec.h:28
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
HepPDT::ParticleData ParticleData
ESHandle< HepPDT::ParticleDataTable > fPDGTable
HepMC::GenEvent * fEvt
tuple cout
Definition: gather_cfg.py:41
Definition: DDAxes.h:10

Member Data Documentation

std::vector<int> edm::MultiParticleInConeGunSource::fInConeIds
protected

Definition at line 32 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fInConeMaxEta
protected

Definition at line 39 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fInConeMaxPhi
protected

Definition at line 41 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

unsigned int edm::MultiParticleInConeGunSource::fInConeMaxTry
protected

Definition at line 42 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fInConeMinEta
protected

Definition at line 38 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource().

double edm::MultiParticleInConeGunSource::fInConeMinPhi
protected

Definition at line 40 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource().

double edm::MultiParticleInConeGunSource::fMaxDeltaR
protected

Definition at line 34 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fMaxMomRatio
protected

Definition at line 36 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fMaxPt
protected

Definition at line 30 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fMinDeltaR
protected

Definition at line 33 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fMinMomRatio
protected

Definition at line 35 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().

double edm::MultiParticleInConeGunSource::fMinPt
protected

Definition at line 29 of file MultiParticleInConeGunSource.h.

Referenced by MultiParticleInConeGunSource(), and produce().