CMS 3D CMS Logo

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)
 
 ~BeamHaloProducer () override
 Destructor. More...
 
- Public Member Functions inherited from edm::one::EDProducer< EndRunProducer, one::WatchLuminosityBlocks, one::SharedResources >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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 ()
 
void endLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
void endRunProduce (Run &r, const EventSetup &es) override
 
void produce (Event &e, const EventSetup &es) override
 

Private Attributes

float EG_MAX_
 
float EG_MIN_
 
HepMC::GenEventevt
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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, objects.autophobj::float, edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

59  :
60  evt(nullptr),
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, Transition::EndRun>();
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)
BeamHaloProducer::~BeamHaloProducer ( )
override

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 &   
)
overrideprivate

Definition at line 104 of file BeamHaloProducer.cc.

References call_ki_bhg_init(), edm::LuminosityBlock::index(), isInitialized_, and SurveyInfoScenario_cff::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 }
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 }
Definition: weight.py:1
#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 }
void edm::BeamHaloProducer::endLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &   
)
inlineoverrideprivate

Definition at line 44 of file BeamHaloProducer.h.

References hitfit::clear().

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

Definition at line 166 of file BeamHaloProducer.cc.

References eostools::move(), and 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  unique_ptr<GenRunInfoProduct> genRunInfo( new GenRunInfoProduct() );
172  run.put(std::move(genRunInfo));
173 }
def move(src, dest)
Definition: eostools.py:510
void BeamHaloProducer::produce ( Event e,
const EventSetup es 
)
overrideprivate

Definition at line 116 of file BeamHaloProducer.cc.

References call_ki_bhg_fill(), edm::EventID::event(), edm::errors::EventCorruption, evt, Exception, particlelevel_cff::genEventInfo, GenParticle::GenParticle, edm::EventBase::id(), eostools::move(), AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), edm::Event::streamID(), create_public_lumi_plots::weights, and wrapper.

116  {
117 
118  RandomEngineSentry<BeamHaloProducer> randomEngineSentry(this, e.streamID());
119 
120  // cout << "in produce " << endl;
121 
122  // unique_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::unique_ptr<HepMCProduct> CMProduct(new HepMCProduct());
159  if (evt) CMProduct->addHepMCData(evt);
160  e.put(std::move(CMProduct), "unsmeared");
161 
162  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(evt));
164 }
EventNumber_t event() const
Definition: EventID.h:41
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
Definition: weight.py:1
HepMC::GenEvent * evt
bool call_ki_bhg_fill(int &iret, float &weight)
edm::EventID id() const
Definition: EventBase.h:60
StreamID streamID() const
Definition: Event.h:96
def move(src, dest)
Definition: eostools.py:510
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.