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
edm::BeamHaloProducer Class Reference

#include <BeamHaloProducer.h>

Inheritance diagram for edm::BeamHaloProducer:
edm::one::EDProducer< EndRunProducer, one::WatchLuminosityBlocks, one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BeamHaloProducer (const ParameterSet &)
 Constructor. More...
 
void setRandomEngine (CLHEP::HepRandomEngine *v)
 
virtual ~BeamHaloProducer ()
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDProducer< EndRunProducer, one::WatchLuminosityBlocks, one::SharedResources >
 EDProducer ()=default
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
bool call_bh_set_parameters (int *ival, float *fval, const std::string cval_string)
 
bool call_ki_bhg_fill (int &iret, float &weight)
 
bool call_ki_bhg_init (long &seed)
 
bool call_ki_bhg_stat (int &iret)
 
void clear ()
 
virtual void endLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
virtual void endRunProduce (Run &r, const EventSetup &es) override
 
virtual void produce (Event &e, const EventSetup &es) override
 

Private Attributes

float EG_MAX_
 
float EG_MIN_
 
HepMC::GenEvent * evt
 
std::string G3FNAME_
 
int GENMOD_
 
bool isInitialized_
 
int IW_HAD_
 
int IW_MUO_
 
int LHC_B1_
 
int LHC_B2_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 23 of file BeamHaloProducer.h.

Constructor & Destructor Documentation

BeamHaloProducer::BeamHaloProducer ( const ParameterSet pset)

Constructor.

Definition at line 59 of file BeamHaloProducer.cc.

References call_bh_set_parameters(), gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

59  :
60  evt(0),
61  isInitialized_(false)
62 {
63 
64  int iparam[8];
65  float fparam[4];
66  std::string cparam;
67  // -- from bhgctrl.inc
68  iparam[0] = pset.getUntrackedParameter<int>("GENMOD");
69  iparam[1] = pset.getUntrackedParameter<int>("LHC_B1");
70  iparam[2] = pset.getUntrackedParameter<int>("LHC_B2");
71  iparam[3] = pset.getUntrackedParameter<int>("IW_MUO");
72  iparam[4] = pset.getUntrackedParameter<int>("IW_HAD");
73  iparam[5] = 9999999;
74  iparam[6] = pset.getUntrackedParameter<int>("OFFSET",0);
75  iparam[7] = pset.getUntrackedParameter<int>("shift_bx");
76 
77  fparam[0] = (float)pset.getUntrackedParameter<double>("EG_MIN");
78  fparam[1] = (float)pset.getUntrackedParameter<double>("EG_MAX");
79 
80  fparam[2] = (float)pset.getUntrackedParameter<double>("BXNS");
81  fparam[3] = (float)pset.getUntrackedParameter<double>("W0",1.0);
82 
83  cparam = pset.getUntrackedParameter<std::string>("G3FNAME","input.txt");
84  call_bh_set_parameters(iparam,fparam,cparam);
85 
86  produces<HepMCProduct>("unsmeared");
87  produces<GenEventInfoProduct>();
88  produces<GenRunInfoProduct, InRun>();
89 
90  usesResource("BeamHaloProducer");
91 
92  cout << "BeamHaloProducer: starting event generation ... " << endl;
93 }
T getUntrackedParameter(std::string const &, T const &) const
HepMC::GenEvent * evt
bool call_bh_set_parameters(int *ival, float *fval, const std::string cval_string)
tuple cout
Definition: gather_cfg.py:145
BeamHaloProducer::~BeamHaloProducer ( )
virtual

Destructor.

Definition at line 53 of file BeamHaloProducer.cc.

53  {
54  int iret=0;
55  call_ki_bhg_stat(iret);
56 }
bool call_ki_bhg_stat(int &iret)

Member Function Documentation

void BeamHaloProducer::beginLuminosityBlock ( LuminosityBlock const &  lumi,
EventSetup const &   
)
overrideprivatevirtual

Definition at line 104 of file BeamHaloProducer.cc.

References call_ki_bhg_init(), edm::LuminosityBlock::index(), isInitialized_, and fileCollector::seed.

105 {
106  if(!isInitialized_) {
107  isInitialized_ = true;
108  RandomEngineSentry<BeamHaloProducer> randomEngineSentry(this, lumi.index());
109 
110  // -- initialisation
111  long seed = 1; // This seed is not actually used
112  call_ki_bhg_init(seed);
113  }
114 }
tuple lumi
Definition: fjr2json.py:35
bool call_ki_bhg_init(long &seed)
bool BeamHaloProducer::call_bh_set_parameters ( int *  ival,
float *  fval,
const std::string  cval_string 
)
private

Definition at line 175 of file BeamHaloProducer.cc.

References BHSETPARAM.

Referenced by BeamHaloProducer().

175  {
176  BHSETPARAM(ival,fval,cval_string.c_str(),cval_string.length());
177  return true;
178 }
#define BHSETPARAM
bool BeamHaloProducer::call_ki_bhg_fill ( int &  iret,
float &  weight 
)
private

Definition at line 185 of file BeamHaloProducer.cc.

References KI_BHG_FILL.

Referenced by produce().

185  {
186  KI_BHG_FILL(iret,weight);
187  return true;
188 }
#define KI_BHG_FILL
bool BeamHaloProducer::call_ki_bhg_init ( long &  seed)
private

Definition at line 180 of file BeamHaloProducer.cc.

References KI_BHG_INIT.

Referenced by beginLuminosityBlock().

180  {
181  KI_BHG_INIT(seed);
182  return true;
183 }
#define KI_BHG_INIT
bool BeamHaloProducer::call_ki_bhg_stat ( int &  iret)
private

Definition at line 190 of file BeamHaloProducer.cc.

References KI_BHG_STAT.

190  {
191  KI_BHG_STAT(iret);
192  return true;
193 }
#define KI_BHG_STAT
void BeamHaloProducer::clear ( void  )
private

Definition at line 96 of file BeamHaloProducer.cc.

97 {
98 }
virtual void edm::BeamHaloProducer::endLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &   
)
inlineoverrideprivatevirtual

Definition at line 44 of file BeamHaloProducer.h.

44 { }
void BeamHaloProducer::endRunProduce ( Run r,
const EventSetup es 
)
overrideprivatevirtual

Definition at line 166 of file BeamHaloProducer.cc.

References edm::Run::put().

167 {
168  // just create an empty product
169  // to keep the EventContent definitions happy
170  // later on we might put the info into the run info that this is a PGun
171  auto_ptr<GenRunInfoProduct> genRunInfo( new GenRunInfoProduct() );
172  run.put( genRunInfo );
173 }
void BeamHaloProducer::produce ( Event e,
const EventSetup es 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 116 of file BeamHaloProducer.cc.

References call_ki_bhg_fill(), edm::EventID::event(), edm::errors::EventCorruption, evt, Exception, GenParticle::GenParticle, edm::EventBase::id(), AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), edm::Event::streamID(), puppiForMET_cff::weight, create_public_pileup_plots::weights, and wrapper.

116  {
117 
118  RandomEngineSentry<BeamHaloProducer> randomEngineSentry(this, e.streamID());
119 
120  // cout << "in produce " << endl;
121 
122  // auto_ptr<HepMCProduct> bare_product(new HepMCProduct());
123 
124  // cout << "apres autoptr " << endl;
125 
126  int iret=0;
127  float weight = 0;
128  call_ki_bhg_fill(iret, weight);
129 
130 // Throw an exception if call_ki_bhg_fill(...) fails. Use the EventCorruption
131 // exception since it maps onto SkipEvent which is what we want to do here.
132 
133  if( iret < 0 )
135  << "BeamHaloProducer: function call_ki_bhg_fill returned " << iret << endl;
136 
137  // cout << "apres fortran " << endl;
138 
139 
140  // HepMC::GenEvent* evt = conv.getGenEventfromHEPEVT();
141  // HepMC::GenEvent* evt = conv.read_next_event(); seems to be broken (?)
142  evt = new HepMC::GenEvent();
143 
144  for (int theindex = 1; theindex<=wrapper.number_entries(); theindex++) {
145  HepMC::GenVertex* Vtx = new HepMC::GenVertex(HepMC::FourVector(wrapper.x(theindex),wrapper.y(theindex),wrapper.z(theindex),wrapper.t(theindex)));
146  HepMC::FourVector p(wrapper.px(theindex),wrapper.py(theindex),wrapper.pz(theindex),wrapper.e(theindex));
147  HepMC::GenParticle* Part =
148  new HepMC::GenParticle(p,wrapper.id(theindex),wrapper.status(theindex));
149  Vtx->add_particle_out(Part);
150  evt->add_vertex(Vtx);
151  }
152 
153  evt->set_event_number(e.id().event());
154 
155  HepMC::WeightContainer& weights = evt -> weights();
156  weights.push_back(weight);
157  // evt->print();
158  std::auto_ptr<HepMCProduct> CMProduct(new HepMCProduct());
159  if (evt) CMProduct->addHepMCData(evt);
160  e.put(CMProduct, "unsmeared");
161 
162  auto_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(evt));
163  e.put(genEventInfo);
164 }
EventNumber_t event() const
Definition: EventID.h:41
HepMC::GenEvent * evt
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
bool call_ki_bhg_fill(int &iret, float &weight)
edm::EventID id() const
Definition: EventBase.h:59
StreamID streamID() const
Definition: Event.h:80
static HepMC::HEPEVT_Wrapper wrapper
void BeamHaloProducer::setRandomEngine ( CLHEP::HepRandomEngine *  v)

Definition at line 100 of file BeamHaloProducer.cc.

References _BeamHalo_randomEngine, and findQualityFiles::v.

100  {
102 }
CLHEP::HepRandomEngine * _BeamHalo_randomEngine
Definition: PYR.cc:3

Member Data Documentation

float edm::BeamHaloProducer::EG_MAX_
private

Definition at line 56 of file BeamHaloProducer.h.

float edm::BeamHaloProducer::EG_MIN_
private

Definition at line 55 of file BeamHaloProducer.h.

HepMC::GenEvent* edm::BeamHaloProducer::evt
private

Definition at line 48 of file BeamHaloProducer.h.

Referenced by produce().

std::string edm::BeamHaloProducer::G3FNAME_
private

Definition at line 57 of file BeamHaloProducer.h.

int edm::BeamHaloProducer::GENMOD_
private

Definition at line 50 of file BeamHaloProducer.h.

bool edm::BeamHaloProducer::isInitialized_
private

Definition at line 59 of file BeamHaloProducer.h.

Referenced by beginLuminosityBlock().

int edm::BeamHaloProducer::IW_HAD_
private

Definition at line 54 of file BeamHaloProducer.h.

int edm::BeamHaloProducer::IW_MUO_
private

Definition at line 53 of file BeamHaloProducer.h.

int edm::BeamHaloProducer::LHC_B1_
private

Definition at line 51 of file BeamHaloProducer.h.

int edm::BeamHaloProducer::LHC_B2_
private

Definition at line 52 of file BeamHaloProducer.h.