CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AlpgenSource Class Reference
Inheritance diagram for AlpgenSource:
edm::ProducerSourceFromFiles edm::ProducerSourceBase edm::FromFiles edm::IDGeneratorSourceBase< PuttableSourceBase > edm::PuttableSourceBase edm::InputSource edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 AlpgenSource (const edm::ParameterSet &params, const edm::InputSourceDescription &desc)
 Constructor. More...
 
 ~AlpgenSource () override
 Destructor. More...
 
- Public Member Functions inherited from edm::ProducerSourceFromFiles
InputFileCatalogcatalog ()
 
std::vector< std::string > fileNames (unsigned iCatalog) const
 
std::vector< std::string > const & logicalFileNames () const
 
 ProducerSourceFromFiles (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
 ~ProducerSourceFromFiles () override
 
- Public Member Functions inherited from edm::ProducerSourceBase
 ProducerSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
 ~ProducerSourceBase () noexcept(false) override
 
- Public Member Functions inherited from edm::IDGeneratorSourceBase< PuttableSourceBase >
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
EventID const & eventID () const
 
 IDGeneratorSourceBase (ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
 
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
 
 ~IDGeneratorSourceBase () noexcept(false) override
 
- Public Member Functions inherited from edm::PuttableSourceBase
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
 PuttableSourceBase (ParameterSet const &, InputSourceDescription const &)
 
void registerProducts () final
 Register any produced products. More...
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
- Public Member Functions inherited from edm::InputSource
std::shared_ptr< ActivityRegistryactReg () const
 Accessor for Activity Registry. More...
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (InputSource const &)=delete
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID, StreamID streamID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
std::shared_ptr< LuminosityBlockAuxiliaryluminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 Advances the source to the next item. More...
 
InputSourceoperator= (InputSource const &)=delete
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr< ProductRegistry > & productRegistry ()
 
std::shared_ptr< ProductRegistry const > productRegistry () const
 Accessors for product registry. More...
 
bool randomAccess () const
 
void readAndMergeLumi (LuminosityBlockPrincipal &lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (RunPrincipal &rp)
 Read next run (same as a prior run) More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific event. More...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
std::unique_ptr< FileBlockreadFile ()
 Read next file. More...
 
void readLuminosityBlock (LuminosityBlockPrincipal &lumiPrincipal, HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
void readRun (RunPrincipal &runPrincipal, HistoryAppender &historyAppender)
 Read next run (new run) More...
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > resourceSharedWithDelayedReader ()
 Returns nullptr if no resource shared between the Source and a DelayedReader. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
std::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)
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource () noexcept(false)
 Destructor. More...
 
- 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
 

Private Member Functions

void beginRun (edm::Run &run) override
 
template<typename T >
T getParameter (AlpgenHeader::Parameter index) const
 Function to get parameter by name from AlpgenHeader. More...
 
template<typename T >
T getParameter (AlpgenHeader::Parameter index, const T &defValue) const
 Function to get parameter by name from AlpgenHeader, w/ default. More...
 
unsigned int processID () const
 
void produce (edm::Event &event) override
 
bool readAlpgenEvent (lhef::HEPEUP &hepeup)
 Read an event and put it into the HEPEUP. More...
 
bool setRunAndEventInfo (edm::EventID &, edm::TimeValue_t &, edm::EventAuxiliary::ExperimentType &) override
 
std::string slhaMassLine (int pdgId, AlpgenHeader::Masses mass, const std::string &comment) const
 

Private Attributes

std::string extraHeaderFileName_
 Name of the extra header file. More...
 
std::string extraHeaderName_
 Name given to the extra header. More...
 
std::string fileName_
 Name of the input file. More...
 
AlpgenHeader header
 Alpgen _unw.par file as an AlpgenHeader. More...
 
std::unique_ptr< lhef::HEPEUPhepeup_
 
std::unique_ptr< std::ifstream > inputFile_
 Pointer to the input file. More...
 
LHERunInfoProduct::Header lheAlpgenUnwParHeader
 Alpgen _unw.par file as a LHE header. More...
 
unsigned long nEvent_
 Number of events. More...
 
unsigned long skipEvents_
 Number of events to skip. More...
 
bool writeAlpgenParFile
 
bool writeAlpgenWgtFile
 configuration flags More...
 
bool writeExtraHeader
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat, IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
- 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
 
- Static Public Member Functions inherited from edm::ProducerSourceFromFiles
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::IDGeneratorSourceBase< PuttableSourceBase >
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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Public Attributes inherited from edm::InputSource
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postEventReadFromSourceSignal_
 
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preEventReadFromSourceSignal_
 
- Protected Member Functions inherited from edm::ProducerSourceFromFiles
void incrementFileIndex ()
 
- Protected Member Functions inherited from edm::IDGeneratorSourceBase< PuttableSourceBase >
void doReadEvent (EventPrincipal &eventPrincipal, F &&f)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
bool newLumi () const
 
bool newRun () const
 
ProcessHistoryRegistryprocessHistoryRegistryForUpdate ()
 
ProductRegistryproductRegistryUpdate ()
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 

Detailed Description

Definition at line 29 of file AlpgenSource.cc.

Constructor & Destructor Documentation

◆ AlpgenSource()

AlpgenSource::AlpgenSource ( const edm::ParameterSet params,
const edm::InputSourceDescription desc 
)

Constructor.

Definition at line 92 of file AlpgenSource.cc.

93  : edm::ProducerSourceFromFiles(params, desc, false),
94  skipEvents_(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
95  nEvent_(0),
96  lheAlpgenUnwParHeader("AlpgenUnwParFile"),
97  extraHeaderFileName_(params.getUntrackedParameter<std::string>("extraHeaderFileName", "")),
98  extraHeaderName_(params.getUntrackedParameter<std::string>("extraHeaderName", "")),
99  writeAlpgenWgtFile(params.getUntrackedParameter<bool>("writeAlpgenWgtFile", true)),
100  writeAlpgenParFile(params.getUntrackedParameter<bool>("writeAlpgenParFile", true)),
101  writeExtraHeader(params.getUntrackedParameter<bool>("writeExtraHeader", false)) {
102  std::vector<std::string> allFileNames = fileNames(0);
103 
104  // Only one filename
105  if (allFileNames.size() != 1)
106  throw cms::Exception("Generator|AlpgenInterface") << "AlpgenSource needs exactly one file specified "
107  "for now."
108  << std::endl;
109 
110  fileName_ = allFileNames[0];
111 
112  // Strip the "file:" prefix
113  if (fileName_.find("file:") != 0)
114  throw cms::Exception("Generator|AlpgenInterface") << "AlpgenSource only supports the file: scheme "
115  "for now."
116  << std::endl;
117  fileName_.erase(0, 5);
118 
119  // Open the _unw.par file to store additional
120  // informations in the LHERunInfoProduct
121  std::ifstream reader((fileName_ + "_unw.par").c_str());
122  if (!reader.good())
123  throw cms::Exception("Generator|AlpgenInterface")
124  << "AlpgenSource was unable to open the file \"" << fileName_ << "_unw.par\"." << std::endl;
125 
126  // A full copy of the _unw.par file in the LHE header.
127  char buffer[256];
128  while (reader.getline(buffer, sizeof buffer))
130 
131  // Parse that header to setup an Alpgen header,
132  // which will be used in the production itself.
134  throw cms::Exception("Generator|AlpgenInterface") << "AlpgenSource was unable to parse the Alpgen "
135  << "unweighted parameter file." << std::endl;
136 
137  // Declare the products.
138  produces<LHERunInfoProduct, edm::Transition::BeginRun>();
139  produces<LHEEventProduct>();
140 }

References LHERunInfoProduct::Header::addLine(), LHERunInfoProduct::Header::begin(), edmScanValgrind::buffer, LHERunInfoProduct::Header::end(), Exception, fileName_, edm::FromFiles::fileNames(), header, lheAlpgenUnwParHeader, AlpgenHeader::parse(), DQM::reader, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~AlpgenSource()

AlpgenSource::~AlpgenSource ( )
override

Destructor.

Definition at line 142 of file AlpgenSource.cc.

142 {}

Member Function Documentation

◆ beginRun()

void AlpgenSource::beginRun ( edm::Run run)
overrideprivatevirtual

Reimplemented from edm::PuttableSourceBase.

Definition at line 151 of file AlpgenSource.cc.

151  {
152  // At this point, the lheUnwParHeader has the full contents of the _unw.par
153  // file. So we can get the HEPRUP information from the LHE header itself.
154  lhef::HEPRUP heprup;
155 
156  // Get basic run information.
157  // Beam identity.
158  heprup.IDBMUP.first = 2212;
159  switch (getParameter<int>(AlpgenHeader::ih2)) {
160  case 1:
161  heprup.IDBMUP.second = 2212;
162  break;
163  case -1:
164  heprup.IDBMUP.second = -2212;
165  break;
166  default:
167  throw cms::Exception("Generator|AlpgenInterface") << "AlpgenSource was unable to understand the ih2 "
168  << "parameter." << std::endl;
169  }
170 
171  // Beam energy.
172  heprup.EBMUP.second = heprup.EBMUP.first = getParameter<double>(AlpgenHeader::ebeam);
173 
174  // PDF info. Initially, Alpgen doesn't fill it.
175  heprup.PDFGUP.first = -1;
176  heprup.PDFGUP.second = -1;
177  heprup.PDFSUP.first = -1;
178  heprup.PDFSUP.second = -1;
179 
180  // Unweighted events.
181  heprup.IDWTUP = 3;
182 
183  // Only one process.
184  heprup.resize(1);
185 
186  // Cross section and error.
187  heprup.XSECUP[0] = header.xsec;
188  heprup.XERRUP[0] = header.xsecErr;
189 
190  // Maximum weight.
191  heprup.XMAXUP[0] = header.xsec;
192 
193  // Process code for Pythia.
194  heprup.LPRUP[0] = processID();
195 
196  // Comments on top.
198  comments.addLine("\n");
199  comments.addLine("\tExtracted by AlpgenInterface\n");
200 
201  // Add SLHA header containing particle masses from Alpgen.
202  // Pythia6Hadronisation will feed the masses to Pythia automatically.
203  LHERunInfoProduct::Header slha("slha");
204  slha.addLine("\n# SLHA header containing masses from Alpgen\n");
205  slha.addLine("Block MASS # Mass spectrum (kinematic masses)\n");
206  slha.addLine("# PDG Mass\n");
207  slha.addLine(slhaMassLine(4, AlpgenHeader::mc, "charm pole mass"));
208  slha.addLine(slhaMassLine(5, AlpgenHeader::mb, "bottom pole mass"));
209  slha.addLine(slhaMassLine(6, AlpgenHeader::mt, "top pole mass"));
210  slha.addLine(slhaMassLine(23, AlpgenHeader::mz, "Z mass"));
211  slha.addLine(slhaMassLine(24, AlpgenHeader::mw, "W mass"));
212  slha.addLine(slhaMassLine(25, AlpgenHeader::mh, "H mass"));
213 
214  char buffer[512];
215 
216  // We also add the information on weighted events.
217  LHERunInfoProduct::Header lheAlpgenWgtHeader("AlpgenWgtFile");
218  if (writeAlpgenWgtFile) {
219  std::ifstream wgtascii((fileName_ + ".wgt").c_str());
220  while (wgtascii.getline(buffer, 512)) {
221  lheAlpgenWgtHeader.addLine(std::string(buffer) + "\n");
222  }
223  }
224 
225  LHERunInfoProduct::Header lheAlpgenParHeader("AlpgenParFile");
226  if (writeAlpgenParFile) {
227  std::ifstream parascii((fileName_ + ".par").c_str());
228  while (parascii.getline(buffer, 512)) {
229  lheAlpgenParHeader.addLine(std::string(buffer) + "\n");
230  }
231  }
232 
233  // If requested by the user, we also add any specific header provided.
234  // Nota bene: the header is put in the LHERunInfoProduct AS IT WAS GIVEN.
235  // That means NO CROSS-CHECKS WHATSOEVER. Use with care.
237  if (writeExtraHeader) {
238  std::ifstream extraascii(extraHeaderFileName_.c_str());
239  while (extraascii.getline(buffer, 512)) {
240  extraHeader.addLine(std::string(buffer) + "\n");
241  }
242  }
243 
244  // Build the final Run info object. Backwards-compatible order.
245  std::unique_ptr<LHERunInfoProduct> runInfo(new LHERunInfoProduct(heprup));
246  runInfo->addHeader(comments);
247  runInfo->addHeader(lheAlpgenUnwParHeader);
248  if (writeAlpgenWgtFile)
249  runInfo->addHeader(lheAlpgenWgtHeader);
250  if (writeAlpgenParFile)
251  runInfo->addHeader(lheAlpgenParHeader);
252  runInfo->addHeader(slha);
253  if (writeExtraHeader)
254  runInfo->addHeader(extraHeader);
255  run.put(std::move(runInfo));
256 
257  // Open the .unw file in the heap, and set the global pointer to it.
258  inputFile_.reset(new std::ifstream((fileName_ + ".unw").c_str()));
259  if (!inputFile_->good())
260  throw cms::Exception("Generator|AlpgenInterface")
261  << "AlpgenSource was unable to open the file \"" << fileName_ << ".unw\"." << std::endl;
262 }

References LHERunInfoProduct::Header::addLine(), edmScanValgrind::buffer, indexGen::comments, AlpgenHeader::ebeam, lhef::HEPRUP::EBMUP, Exception, extraHeaderFileName_, extraHeaderName_, fileName_, header, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, AlpgenHeader::ih2, inputFile_, lheAlpgenUnwParHeader, lhe2HepMCConverter_cff::LHERunInfoProduct, lhef::HEPRUP::LPRUP, AlpgenHeader::mb, AlpgenHeader::mc, AlpgenHeader::mh, eostools::move(), AlpgenHeader::mt, AlpgenHeader::mw, AlpgenHeader::mz, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, processID(), lhef::HEPRUP::resize(), edm::IDGeneratorSourceBase< PuttableSourceBase >::run(), slhaMassLine(), AlCaHLTBitMon_QueryRunRegistry::string, writeAlpgenParFile, writeAlpgenWgtFile, writeExtraHeader, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, AlpgenHeader::xsec, AlpgenHeader::xsecErr, and lhef::HEPRUP::XSECUP.

◆ getParameter() [1/2]

template<typename T >
T AlpgenSource::getParameter ( AlpgenHeader::Parameter  index) const
private

Function to get parameter by name from AlpgenHeader.

Definition at line 265 of file AlpgenSource.cc.

265  {
266  std::map<AlpgenHeader::Parameter, double>::const_iterator pos = header.params.find(index);
267  if (pos == header.params.end())
268  throw cms::Exception("Generator|AlpgenInterface")
269  << "Requested Alpgen parameter \"" << AlpgenHeader::parameterName(index)
270  << "\" "
271  "not found in Alpgen parameter file."
272  << std::endl;
273 
274  return T(pos->second);
275 }

References header, AlpgenHeader::parameterName(), and AlpgenHeader::params.

◆ getParameter() [2/2]

template<typename T >
T AlpgenSource::getParameter ( AlpgenHeader::Parameter  index,
const T defValue 
) const
private

Function to get parameter by name from AlpgenHeader, w/ default.

Definition at line 278 of file AlpgenSource.cc.

278  {
279  std::map<AlpgenHeader::Parameter, double>::const_iterator pos = header.params.find(index);
280  if (pos == header.params.end())
281  return defValue;
282  else
283  return T(pos->second);
284 }

References header, and AlpgenHeader::params.

◆ processID()

unsigned int AlpgenSource::processID ( ) const
private

The Alpgen process ID. This is defined as processID() = 100*X + 10*Y + Z, where = ihrd, Y = ihvy, Z = njets

Definition at line 286 of file AlpgenSource.cc.

286  {
287  // return 661; // The original, old thing.
288  // digits #XYZ: X = ihrd, Y = ihvy, Z = njets
289  return header.ihrd * 100 + getParameter<unsigned int>(AlpgenHeader::ihvy, 0) * 10 +
290  getParameter<unsigned int>(AlpgenHeader::njets, 0);
291 }

References header, AlpgenHeader::ihrd, AlpgenHeader::ihvy, and AlpgenHeader::njets.

Referenced by beginRun(), and readAlpgenEvent().

◆ produce()

void AlpgenSource::produce ( edm::Event event)
overrideprivatevirtual

Implements edm::ProducerSourceBase.

Definition at line 420 of file AlpgenSource.cc.

420  {
421  // Here are the Alpgen routines for filling up the rest
422  // of the LHE Event Record. The .unw file has the information
423  // in a compressed way, e.g. it doesn't list the W boson -
424  // one has to reconstruct it from the e nu pair.
425  lhef::HEPEUP &hepeup = *hepeup_;
426 
427  switch (header.ihrd) {
428  case 1:
429  case 2:
430  case 3:
431  case 4:
432  case 10:
433  case 14:
434  case 15:
435  alpgen::fixEventWZ(hepeup);
436  break;
437  case 5:
439  break;
440  case 6:
441  alpgen::fixEventTTbar(hepeup);
442  break;
443  case 8:
445  break;
446  case 13:
448  break;
449  case 7:
450  case 9:
451  case 11:
452  case 12:
453  case 16:
454  // No fixes needed.
455  break;
456 
457  default:
458  throw cms::Exception("Generator|AlpgenInterface") << "Unrecognized IHRD process code" << std::endl;
459  }
460 
461  // Create the LHEEventProduct and put it into the Event.
462  std::unique_ptr<LHEEventProduct> lheEvent(new LHEEventProduct(hepeup));
463  event.put(std::move(lheEvent));
464 
465  hepeup_.reset();
466 }

References Exception, alpgen::fixEventHiggsTTbar(), alpgen::fixEventMultiBoson(), alpgen::fixEventSingleTop(), alpgen::fixEventTTbar(), alpgen::fixEventWZ(), header, hepeup_, AlpgenHeader::ihrd, AlpgenHeader::itopprc, lhe2HepMCConverter_cff::LHEEventProduct, AlpgenHeader::masses, AlpgenHeader::mb, eostools::move(), and AlpgenHeader::params.

◆ readAlpgenEvent()

bool AlpgenSource::readAlpgenEvent ( lhef::HEPEUP hepeup)
private

Read an event and put it into the HEPEUP.

Definition at line 293 of file AlpgenSource.cc.

293  {
294  char buffer[512];
295  double dummy;
296  int nPart;
297  double sWgtRes;
298  double sQ;
299 
300  inputFile_->getline(buffer, sizeof buffer);
301  if (!inputFile_->good())
302  return false;
303 
304  std::istringstream ls(buffer);
305 
306  // Event number and process don't matter (or do they?)
307  ls >> dummy >> dummy;
308 
309  // Number of particles in the record, sample's average weight and Q scale
310  ls >> nPart >> sWgtRes >> sQ;
311 
312  if (ls.bad() || nPart < 1 || nPart > 1000)
313  return false;
314 
315  // Make room for the particles listed in the Alpgen file
316  hepeup.resize(nPart);
317 
318  // Scales, weights and process ID.
319  hepeup.SCALUP = sQ;
320  hepeup.XWGTUP = sWgtRes;
321  hepeup.IDPRUP = processID();
322 
323  // Incoming lines
324  for (int i = 0; i != 2; ++i) {
325  inputFile_->getline(buffer, sizeof buffer);
326  std::istringstream ls(buffer);
327  int flavour;
328  ls >> flavour;
329  int colour1;
330  ls >> colour1;
331  int colour2;
332  ls >> colour2;
333  double zMomentum;
334  ls >> zMomentum;
335 
336  if (inputFile_->bad())
337  return false;
338 
339  // Setting the HEPEUP of the incoming lines.
340  hepeup.IDUP[i] = flavour;
341  hepeup.ISTUP[i] = -1;
342  hepeup.MOTHUP[i].first = 0;
343  hepeup.MOTHUP[i].second = 0;
344  hepeup.PUP[i][0] = 0.;
345  hepeup.PUP[i][1] = 0.;
346  hepeup.PUP[i][2] = zMomentum;
347  hepeup.PUP[i][3] = std::fabs(zMomentum);
348  hepeup.PUP[i][4] = 0.;
349  if (colour1)
350  colour1 += 500;
351  if (colour2)
352  colour2 += 500;
353  hepeup.ICOLUP[i].first = colour1;
354  hepeup.ICOLUP[i].second = colour2;
355  }
356 
357  // Outgoing lines
358  for (int i = 2; i != nPart; ++i) {
359  inputFile_->getline(buffer, sizeof buffer);
360  std::istringstream ls(buffer);
361  int flavour;
362  ls >> flavour;
363  int colour1;
364  ls >> colour1;
365  int colour2;
366  ls >> colour2;
367  double px, py, pz, mass;
368  ls >> px >> py >> pz >> mass;
369  double energy = std::sqrt(px * px + py * py + pz * pz + mass * mass);
370 
371  if (inputFile_->bad())
372  return false;
373 
374  // Setting the HEPEUP of the outgoing lines.
375  hepeup.IDUP[i] = flavour;
376  hepeup.ISTUP[i] = 1;
377  hepeup.MOTHUP[i].first = 1;
378  hepeup.MOTHUP[i].second = 2;
379  hepeup.PUP[i][0] = px;
380  hepeup.PUP[i][1] = py;
381  hepeup.PUP[i][2] = pz;
382  hepeup.PUP[i][3] = energy;
383  hepeup.PUP[i][4] = mass;
384  if (colour1)
385  colour1 += 500;
386  if (colour2)
387  colour2 += 500;
388  hepeup.ICOLUP[i].first = colour1;
389  hepeup.ICOLUP[i].second = colour2;
390  }
391 
392  return true;
393 }

References edmScanValgrind::buffer, HCALHighEnergyHPDFilter_cfi::energy, GenHFHadronMatcher_cff::flavour, mps_fire::i, lhef::HEPEUP::ICOLUP, lhef::HEPEUP::IDPRUP, lhef::HEPEUP::IDUP, inputFile_, lhef::HEPEUP::ISTUP, eostools::ls(), EgHLTOffHistBins_cfi::mass, lhef::HEPEUP::MOTHUP, nPart(), processID(), lhef::HEPEUP::PUP, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, lhef::HEPEUP::resize(), lhef::HEPEUP::SCALUP, mathSSE::sqrt(), and lhef::HEPEUP::XWGTUP.

Referenced by setRunAndEventInfo().

◆ setRunAndEventInfo()

bool AlpgenSource::setRunAndEventInfo ( edm::EventID ,
edm::TimeValue_t ,
edm::EventAuxiliary::ExperimentType  
)
overrideprivatevirtual

Implements edm::IDGeneratorSourceBase< PuttableSourceBase >.

Definition at line 395 of file AlpgenSource.cc.

395  {
396  // The LHE Event Record
397  hepeup_.reset(new lhef::HEPEUP);
398 
399  lhef::HEPEUP &hepeup = *hepeup_;
400 
401  // Read the .unw file until it is over.
402  for (;;) {
403  if (!readAlpgenEvent(hepeup)) {
404  if (inputFile_->eof())
405  return false;
406 
407  throw cms::Exception("Generator|AlpgenInterface")
408  << "AlpgenSource is not able read event no. " << nEvent_ << std::endl;
409  }
410 
411  nEvent_++;
412  if (skipEvents_ > 0)
413  skipEvents_--;
414  else
415  break;
416  }
417  return true;
418 }

References Exception, hepeup_, inputFile_, nEvent_, readAlpgenEvent(), and skipEvents_.

◆ slhaMassLine()

std::string AlpgenSource::slhaMassLine ( int  pdgId,
AlpgenHeader::Masses  mass,
const std::string &  comment 
) const
private

Converts the AlpgenHeader::Masses to a std::string formatted as a slhaMassLine to facilitate passing them to Alpgen.

Definition at line 144 of file AlpgenSource.cc.

144  {
145  std::ostringstream ss;
146  ss << std::setw(9) << pdgId << " " << std::scientific << std::setprecision(9) << header.masses[mass] << " # "
147  << comment << std::endl;
148  return ss.str();
149 }

References comment, header, EgHLTOffHistBins_cfi::mass, AlpgenHeader::masses, EgammaValidation_cff::pdgId, and contentValuesCheck::ss.

Referenced by beginRun().

Member Data Documentation

◆ extraHeaderFileName_

std::string AlpgenSource::extraHeaderFileName_
private

Name of the extra header file.

Definition at line 81 of file AlpgenSource.cc.

Referenced by beginRun().

◆ extraHeaderName_

std::string AlpgenSource::extraHeaderName_
private

Name given to the extra header.

Definition at line 84 of file AlpgenSource.cc.

Referenced by beginRun().

◆ fileName_

std::string AlpgenSource::fileName_
private

Name of the input file.

Definition at line 62 of file AlpgenSource.cc.

Referenced by AlpgenSource(), and beginRun().

◆ header

AlpgenHeader AlpgenSource::header
private

Alpgen _unw.par file as an AlpgenHeader.

Definition at line 76 of file AlpgenSource.cc.

Referenced by AlpgenSource(), beginRun(), getParameter(), processID(), produce(), and slhaMassLine().

◆ hepeup_

std::unique_ptr<lhef::HEPEUP> AlpgenSource::hepeup_
private

Definition at line 78 of file AlpgenSource.cc.

Referenced by produce(), and setRunAndEventInfo().

◆ inputFile_

std::unique_ptr<std::ifstream> AlpgenSource::inputFile_
private

Pointer to the input file.

Definition at line 65 of file AlpgenSource.cc.

Referenced by beginRun(), readAlpgenEvent(), and setRunAndEventInfo().

◆ lheAlpgenUnwParHeader

LHERunInfoProduct::Header AlpgenSource::lheAlpgenUnwParHeader
private

Alpgen _unw.par file as a LHE header.

Definition at line 74 of file AlpgenSource.cc.

Referenced by AlpgenSource(), and beginRun().

◆ nEvent_

unsigned long AlpgenSource::nEvent_
private

Number of events.

Definition at line 71 of file AlpgenSource.cc.

Referenced by setRunAndEventInfo().

◆ skipEvents_

unsigned long AlpgenSource::skipEvents_
private

Number of events to skip.

Definition at line 68 of file AlpgenSource.cc.

Referenced by setRunAndEventInfo().

◆ writeAlpgenParFile

bool AlpgenSource::writeAlpgenParFile
private

Definition at line 88 of file AlpgenSource.cc.

Referenced by beginRun().

◆ writeAlpgenWgtFile

bool AlpgenSource::writeAlpgenWgtFile
private

configuration flags

Definition at line 87 of file AlpgenSource.cc.

Referenced by beginRun().

◆ writeExtraHeader

bool AlpgenSource::writeExtraHeader
private

Definition at line 89 of file AlpgenSource.cc.

Referenced by beginRun().

lhef::HEPRUP::XSECUP
std::vector< double > XSECUP
Definition: LesHouches.h:112
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
GenHFHadronMatcher_cff.flavour
flavour
Definition: GenHFHadronMatcher_cff.py:8
alpgen::fixEventWZ
void fixEventWZ(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 1,2,3,4,10,14,15.
Definition: AlpgenEventRecordFixes.cc:23
AlpgenSource::extraHeaderFileName_
std::string extraHeaderFileName_
Name of the extra header file.
Definition: AlpgenSource.cc:81
mps_fire.i
i
Definition: mps_fire.py:355
AlpgenSource::hepeup_
std::unique_ptr< lhef::HEPEUP > hepeup_
Definition: AlpgenSource.cc:78
alpgen::fixEventHiggsTTbar
void fixEventHiggsTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 8.
Definition: AlpgenEventRecordFixes.cc:210
AlpgenHeader::xsec
double xsec
Definition: AlpgenHeader.h:67
lhef::HEPEUP::MOTHUP
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
LHERunInfoProduct::Header
Definition: LHERunInfoProduct.h:16
AlpgenSource::skipEvents_
unsigned long skipEvents_
Number of events to skip.
Definition: AlpgenSource.cc:68
edm::IDGeneratorSourceBase< PuttableSourceBase >::run
RunNumber_t run() const
Definition: IDGeneratorSourceBase.h:37
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
lhef::HEPEUP::ISTUP
std::vector< int > ISTUP
Definition: LesHouches.h:228
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
AlpgenSource::lheAlpgenUnwParHeader
LHERunInfoProduct::Header lheAlpgenUnwParHeader
Alpgen _unw.par file as a LHE header.
Definition: AlpgenSource.cc:74
pos
Definition: PixelAliasList.h:18
AlpgenHeader::xsecErr
double xsecErr
Definition: AlpgenHeader.h:68
AlpgenSource::processID
unsigned int processID() const
Definition: AlpgenSource.cc:286
AlpgenHeader::mc
Definition: AlpgenHeader.h:58
AlpgenSource::nEvent_
unsigned long nEvent_
Number of events.
Definition: AlpgenSource.cc:71
AlpgenSource::header
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
lhe2HepMCConverter_cff.LHERunInfoProduct
LHERunInfoProduct
Definition: lhe2HepMCConverter_cff.py:5
AlpgenHeader::parameterName
static std::string parameterName(Parameter index)
Definition: AlpgenHeader.cc:143
AlpgenHeader::ebeam
Definition: AlpgenHeader.h:13
AlpgenHeader::params
std::map< Parameter, double > params
Definition: AlpgenHeader.h:65
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
lhef::HEPRUP::EBMUP
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
AlpgenHeader::ihrd
unsigned int ihrd
Definition: AlpgenHeader.h:66
lhe2HepMCConverter_cff.LHEEventProduct
LHEEventProduct
Definition: lhe2HepMCConverter_cff.py:4
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
AlpgenSource::writeAlpgenParFile
bool writeAlpgenParFile
Definition: AlpgenSource.cc:88
LHERunInfoProduct::Header::end
const_iterator end() const
Definition: LHERunInfoProduct.h:32
DQM.reader
reader
Definition: DQM.py:105
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
AlpgenHeader::mz
Definition: AlpgenHeader.h:58
lhef::HEPRUP::LPRUP
std::vector< int > LPRUP
Definition: LesHouches.h:128
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
AlpgenHeader::mb
Definition: AlpgenHeader.h:58
nPart
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AlpgenHeader::njets
Definition: AlpgenHeader.h:19
AlpgenSource::inputFile_
std::unique_ptr< std::ifstream > inputFile_
Pointer to the input file.
Definition: AlpgenSource.cc:65
lhef::HEPEUP::ICOLUP
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:240
indexGen.comments
comments
Definition: indexGen.py:75
lhef::HEPRUP::PDFGUP
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
AlpgenHeader::ihvy
Definition: AlpgenHeader.h:20
lhef::HEPRUP::resize
void resize(int nrup)
Definition: LesHouches.h:44
lhef::HEPRUP
Definition: LesHouches.h:22
lhef::HEPRUP::IDWTUP
int IDWTUP
Definition: LesHouches.h:101
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
alpgen::fixEventSingleTop
void fixEventSingleTop(lhef::HEPEUP &hepeup, double mb, int itopprc)
Fixes Event Record for ihrd = 13.
Definition: AlpgenEventRecordFixes.cc:310
edm::FromFiles::fileNames
std::vector< std::string > fileNames(unsigned iCatalog) const
Definition: FromFiles.h:22
lhef::HEPEUP
Definition: LesHouches.h:138
lhef::HEPEUP::XWGTUP
double XWGTUP
Definition: LesHouches.h:194
LHERunInfoProduct::Header::addLine
void addLine(const std::string &line)
Definition: LHERunInfoProduct.h:25
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
lhef::HEPRUP::XERRUP
std::vector< double > XERRUP
Definition: LesHouches.h:118
alpgen::fixEventTTbar
void fixEventTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 6.
Definition: AlpgenEventRecordFixes.cc:110
comment
#define comment(par)
Definition: vmac.h:163
lhef::HEPRUP::PDFSUP
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
eostools.move
def move(src, dest)
Definition: eostools.py:511
alpgen::fixEventMultiBoson
void fixEventMultiBoson(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 5.
Definition: AlpgenEventRecordFixes.cc:81
LHERunInfoProduct::Header::begin
const_iterator begin() const
Definition: LHERunInfoProduct.h:31
edm::ProducerSourceFromFiles
Definition: ProducerSourceFromFiles.h:17
lhef::HEPEUP::IDUP
std::vector< int > IDUP
Definition: LesHouches.h:223
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:246
AlpgenHeader::mw
Definition: AlpgenHeader.h:58
AlpgenSource::slhaMassLine
std::string slhaMassLine(int pdgId, AlpgenHeader::Masses mass, const std::string &comment) const
Definition: AlpgenSource.cc:144
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
lhef::HEPEUP::IDPRUP
int IDPRUP
Definition: LesHouches.h:189
AlpgenHeader::mt
Definition: AlpgenHeader.h:58
AlpgenSource::writeAlpgenWgtFile
bool writeAlpgenWgtFile
configuration flags
Definition: AlpgenSource.cc:87
AlpgenHeader::itopprc
Definition: AlpgenHeader.h:48
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
AlpgenHeader::ih2
Definition: AlpgenHeader.h:12
lhef::HEPEUP::resize
void resize(int nup)
Definition: LesHouches.h:161
cms::Exception
Definition: Exception.h:70
AlpgenSource::writeExtraHeader
bool writeExtraHeader
Definition: AlpgenSource.cc:89
AlpgenSource::fileName_
std::string fileName_
Name of the input file.
Definition: AlpgenSource.cc:62
lhef::HEPRUP::XMAXUP
std::vector< double > XMAXUP
Definition: LesHouches.h:123
dummy
Definition: DummySelector.h:38
AlpgenSource::readAlpgenEvent
bool readAlpgenEvent(lhef::HEPEUP &hepeup)
Read an event and put it into the HEPEUP.
Definition: AlpgenSource.cc:293
AlpgenHeader::masses
double masses[MASS_MAX]
Definition: AlpgenHeader.h:71
AlpgenSource::extraHeaderName_
std::string extraHeaderName_
Name given to the extra header.
Definition: AlpgenSource.cc:84
lhef::HEPEUP::PUP
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
lhef::HEPEUP::SCALUP
double SCALUP
Definition: LesHouches.h:208
AlpgenHeader::parse
bool parse(const std::vector< std::string >::const_iterator &begin, const std::vector< std::string >::const_iterator &end)
Definition: AlpgenHeader.cc:62
AlpgenHeader::mh
Definition: AlpgenHeader.h:58
lhef::HEPRUP::IDBMUP
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77