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
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 22 of file BeamHaloProducer.h.

Constructor & Destructor Documentation

◆ BeamHaloProducer()

BeamHaloProducer::BeamHaloProducer ( const ParameterSet pset)

Constructor.

Definition at line 55 of file BeamHaloProducer.cc.

References call_bh_set_parameters(), gather_cfg::cout, dqmMemoryStats::float, muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

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

◆ ~BeamHaloProducer()

BeamHaloProducer::~BeamHaloProducer ( )
override

Destructor.

Definition at line 50 of file BeamHaloProducer.cc.

50  {
51  int iret = 0;
52  call_ki_bhg_stat(iret);
53 }
bool call_ki_bhg_stat(int &iret)

Member Function Documentation

◆ beginLuminosityBlock()

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

Definition at line 91 of file BeamHaloProducer.cc.

References call_ki_bhg_init(), isInitialized_, and fileCollector::seed.

91  {
92  if (!isInitialized_) {
93  isInitialized_ = true;
94  RandomEngineSentry<BeamHaloProducer> randomEngineSentry(this, lumi.index());
95 
96  // -- initialisation
97  long seed = 1; // This seed is not actually used
99  }
100 }
bool call_ki_bhg_init(long &seed)

◆ call_bh_set_parameters()

bool BeamHaloProducer::call_bh_set_parameters ( int *  ival,
float *  fval,
const std::string  cval_string 
)
private

Definition at line 159 of file BeamHaloProducer.cc.

References BHSETPARAM.

Referenced by BeamHaloProducer().

159  {
160  BHSETPARAM(ival, fval, cval_string.c_str(), cval_string.length());
161  return true;
162 }
#define BHSETPARAM

◆ call_ki_bhg_fill()

bool BeamHaloProducer::call_ki_bhg_fill ( int &  iret,
float &  weight 
)
private

Definition at line 169 of file BeamHaloProducer.cc.

References KI_BHG_FILL.

Referenced by produce().

169  {
170  KI_BHG_FILL(iret, weight);
171  return true;
172 }
Definition: weight.py:1
#define KI_BHG_FILL

◆ call_ki_bhg_init()

bool BeamHaloProducer::call_ki_bhg_init ( long &  seed)
private

Definition at line 164 of file BeamHaloProducer.cc.

References KI_BHG_INIT, and fileCollector::seed.

Referenced by beginLuminosityBlock().

164  {
165  KI_BHG_INIT(seed);
166  return true;
167 }
#define KI_BHG_INIT

◆ call_ki_bhg_stat()

bool BeamHaloProducer::call_ki_bhg_stat ( int &  iret)
private

Definition at line 174 of file BeamHaloProducer.cc.

References KI_BHG_STAT.

174  {
175  KI_BHG_STAT(iret);
176  return true;
177 }
#define KI_BHG_STAT

◆ clear()

void BeamHaloProducer::clear ( void  )
private

Definition at line 87 of file BeamHaloProducer.cc.

87 {}

◆ endLuminosityBlock()

void edm::BeamHaloProducer::endLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &   
)
inlineoverrideprivate

Definition at line 41 of file BeamHaloProducer.h.

41 {}

◆ endRunProduce()

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

Definition at line 151 of file BeamHaloProducer.cc.

References eostools::move(), and writedatasetfile::run.

151  {
152  // just create an empty product
153  // to keep the EventContent definitions happy
154  // later on we might put the info into the run info that this is a PGun
155  unique_ptr<GenRunInfoProduct> genRunInfo(new GenRunInfoProduct());
156  run.put(std::move(genRunInfo));
157 }
def move(src, dest)
Definition: eostools.py:511

◆ produce()

void BeamHaloProducer::produce ( Event e,
const EventSetup es 
)
overrideprivatevirtual

Implements edm::one::EDProducerBase.

Definition at line 102 of file BeamHaloProducer.cc.

References call_ki_bhg_fill(), MillePedeFileConverter_cfg::e, edm::errors::EventCorruption, evt, Exception, genParticles2HepMC_cfi::genEventInfo, GenParticle::GenParticle, ZgammaFilter_cfi::HepMCProduct, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, hltDeepSecondaryVertexTagInfosPFPuppi_cfi::weights, and wrapper.

102  {
103  RandomEngineSentry<BeamHaloProducer> randomEngineSentry(this, e.streamID());
104 
105  // cout << "in produce " << endl;
106 
107  // unique_ptr<HepMCProduct> bare_product(new HepMCProduct());
108 
109  // cout << "apres autoptr " << endl;
110 
111  int iret = 0;
112  float weight = 0;
113  call_ki_bhg_fill(iret, weight);
114 
115  // Throw an exception if call_ki_bhg_fill(...) fails. Use the EventCorruption
116  // exception since it maps onto SkipEvent which is what we want to do here.
117 
118  if (iret < 0)
120  << "BeamHaloProducer: function call_ki_bhg_fill returned " << iret << endl;
121 
122  // cout << "apres fortran " << endl;
123 
124  // HepMC::GenEvent* evt = conv.getGenEventfromHEPEVT();
125  // HepMC::GenEvent* evt = conv.read_next_event(); seems to be broken (?)
126  evt = new HepMC::GenEvent();
127 
128  for (int theindex = 1; theindex <= wrapper.number_entries(); theindex++) {
129  HepMC::GenVertex* Vtx = new HepMC::GenVertex(
130  HepMC::FourVector(wrapper.x(theindex), wrapper.y(theindex), wrapper.z(theindex), wrapper.t(theindex)));
131  HepMC::FourVector p(wrapper.px(theindex), wrapper.py(theindex), wrapper.pz(theindex), wrapper.e(theindex));
132  HepMC::GenParticle* Part = new HepMC::GenParticle(p, wrapper.id(theindex), wrapper.status(theindex));
133  Vtx->add_particle_out(Part);
134  evt->add_vertex(Vtx);
135  }
136 
137  evt->set_event_number(e.id().event());
138 
139  HepMC::WeightContainer& weights = evt->weights();
140  weights.push_back(weight);
141  // evt->print();
142  std::unique_ptr<HepMCProduct> CMProduct(new HepMCProduct());
143  if (evt)
144  CMProduct->addHepMCData(evt);
145  e.put(std::move(CMProduct), "unsmeared");
146 
147  unique_ptr<GenEventInfoProduct> genEventInfo(new GenEventInfoProduct(evt));
148  e.put(std::move(genEventInfo));
149 }
Definition: weight.py:1
HepMC::GenEvent * evt
bool call_ki_bhg_fill(int &iret, float &weight)
def move(src, dest)
Definition: eostools.py:511
static HepMC::HEPEVT_Wrapper wrapper

◆ setRandomEngine()

void BeamHaloProducer::setRandomEngine ( CLHEP::HepRandomEngine *  v)

Definition at line 89 of file BeamHaloProducer.cc.

References _BeamHalo_randomEngine, and findQualityFiles::v.

CLHEP::HepRandomEngine * _BeamHalo_randomEngine
Definition: PYR.cc:3

Member Data Documentation

◆ EG_MAX_

float edm::BeamHaloProducer::EG_MAX_
private

Definition at line 53 of file BeamHaloProducer.h.

◆ EG_MIN_

float edm::BeamHaloProducer::EG_MIN_
private

Definition at line 52 of file BeamHaloProducer.h.

◆ evt

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

Definition at line 45 of file BeamHaloProducer.h.

Referenced by produce().

◆ G3FNAME_

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

Definition at line 54 of file BeamHaloProducer.h.

◆ GENMOD_

int edm::BeamHaloProducer::GENMOD_
private

Definition at line 47 of file BeamHaloProducer.h.

◆ isInitialized_

bool edm::BeamHaloProducer::isInitialized_
private

Definition at line 56 of file BeamHaloProducer.h.

Referenced by beginLuminosityBlock().

◆ IW_HAD_

int edm::BeamHaloProducer::IW_HAD_
private

Definition at line 51 of file BeamHaloProducer.h.

◆ IW_MUO_

int edm::BeamHaloProducer::IW_MUO_
private

Definition at line 50 of file BeamHaloProducer.h.

◆ LHC_B1_

int edm::BeamHaloProducer::LHC_B1_
private

Definition at line 48 of file BeamHaloProducer.h.

◆ LHC_B2_

int edm::BeamHaloProducer::LHC_B2_
private

Definition at line 49 of file BeamHaloProducer.h.