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
bool noFiles () const override
 
 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 ()(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 ()(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...
 
- Public Member Functions inherited from edm::InputSource
std::shared_ptr< ActivityRegistryactReg () const
 Accessor for Activity Registry. More...
 
std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
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 (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
 InputSource (InputSource const &)=delete
 
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...
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr< ProductRegistry const > productRegistry () const
 Accessors for product registry. More...
 
std::shared_ptr< ProductRegistry > & productRegistry ()
 
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...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific 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 const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
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
 
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
 

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::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
ProducesCollector producesCollector ()
 

Detailed Description

Definition at line 29 of file AlpgenSource.cc.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 92 of file AlpgenSource.cc.

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.

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();
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))
129  lheAlpgenUnwParHeader.addLine(std::string(buffer) + "\n");
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 }
T getUntrackedParameter(std::string const &, T const &) const
bool parse(const std::vector< std::string >::const_iterator &begin, const std::vector< std::string >::const_iterator &end)
Definition: AlpgenHeader.cc:62
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
reader
Definition: DQM.py:105
const_iterator end() const
bool writeAlpgenParFile
Definition: AlpgenSource.cc:88
bool writeExtraHeader
Definition: AlpgenSource.cc:89
unsigned long nEvent_
Number of events.
Definition: AlpgenSource.cc:71
unsigned long skipEvents_
Number of events to skip.
Definition: AlpgenSource.cc:68
std::vector< std::string > const & fileNames() const
Definition: FromFiles.h:22
bool writeAlpgenWgtFile
configuration flags
Definition: AlpgenSource.cc:87
LHERunInfoProduct::Header lheAlpgenUnwParHeader
Alpgen _unw.par file as a LHE header.
Definition: AlpgenSource.cc:74
std::string extraHeaderFileName_
Name of the extra header file.
Definition: AlpgenSource.cc:81
void addLine(const std::string &line)
std::string fileName_
Name of the input file.
Definition: AlpgenSource.cc:62
std::string extraHeaderName_
Name given to the extra header.
Definition: AlpgenSource.cc:84
const_iterator begin() const
AlpgenSource::~AlpgenSource ( )
override

Destructor.

Definition at line 142 of file AlpgenSource.cc.

142 {}

Member Function Documentation

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

Reimplemented from edm::PuttableSourceBase.

Definition at line 151 of file AlpgenSource.cc.

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(), edm::Run::put(), lhef::HEPRUP::resize(), slhaMassLine(), AlCaHLTBitMon_QueryRunRegistry::string, writeAlpgenParFile, writeAlpgenWgtFile, writeExtraHeader, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, AlpgenHeader::xsec, AlpgenHeader::xsecErr, and lhef::HEPRUP::XSECUP.

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 }
void resize(int nrup)
Definition: LesHouches.h:44
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77
std::unique_ptr< std::ifstream > inputFile_
Pointer to the input file.
Definition: AlpgenSource.cc:65
bool writeAlpgenParFile
Definition: AlpgenSource.cc:88
bool writeExtraHeader
Definition: AlpgenSource.cc:89
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
bool writeAlpgenWgtFile
configuration flags
Definition: AlpgenSource.cc:87
LHERunInfoProduct::Header lheAlpgenUnwParHeader
Alpgen _unw.par file as a LHE header.
Definition: AlpgenSource.cc:74
std::string extraHeaderFileName_
Name of the extra header file.
Definition: AlpgenSource.cc:81
void addLine(const std::string &line)
std::vector< double > XERRUP
Definition: LesHouches.h:118
std::string fileName_
Name of the input file.
Definition: AlpgenSource.cc:62
std::vector< double > XMAXUP
Definition: LesHouches.h:123
std::string slhaMassLine(int pdgId, AlpgenHeader::Masses mass, const std::string &comment) const
std::string extraHeaderName_
Name given to the extra header.
Definition: AlpgenSource.cc:84
void put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Run.h:108
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
double xsecErr
Definition: AlpgenHeader.h:68
std::vector< double > XSECUP
Definition: LesHouches.h:112
def move(src, dest)
Definition: eostools.py:511
std::vector< int > LPRUP
Definition: LesHouches.h:128
unsigned int processID() const
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.

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

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 }
std::map< Parameter, double > params
Definition: AlpgenHeader.h:65
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
static std::string parameterName(Parameter index)
long double T
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.

References header, and AlpgenHeader::params.

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 }
std::map< Parameter, double > params
Definition: AlpgenHeader.h:65
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
long double T
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.

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

Referenced by beginRun(), and readAlpgenEvent().

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 }
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
unsigned int ihrd
Definition: AlpgenHeader.h:66
void AlpgenSource::produce ( edm::Event event)
overrideprivatevirtual

Implements edm::ProducerSourceBase.

Definition at line 420 of file AlpgenSource.cc.

References DEFINE_FWK_INPUT_SOURCE, 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.

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 }
std::map< Parameter, double > params
Definition: AlpgenHeader.h:65
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
std::unique_ptr< lhef::HEPEUP > hepeup_
Definition: AlpgenSource.cc:78
void fixEventWZ(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 1,2,3,4,10,14,15.
void fixEventMultiBoson(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 5.
void fixEventHiggsTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 8.
void fixEventSingleTop(lhef::HEPEUP &hepeup, double mb, int itopprc)
Fixes Event Record for ihrd = 13.
unsigned int ihrd
Definition: AlpgenHeader.h:66
void fixEventTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 6.
double masses[MASS_MAX]
Definition: AlpgenHeader.h:71
def move(src, dest)
Definition: eostools.py:511
bool AlpgenSource::readAlpgenEvent ( lhef::HEPEUP hepeup)
private

Read an event and put it into the HEPEUP.

Definition at line 293 of file AlpgenSource.cc.

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().

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 }
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:240
std::unique_ptr< std::ifstream > inputFile_
Pointer to the input file.
Definition: AlpgenSource.cc:65
void resize(int nup)
Definition: LesHouches.h:161
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
std::vector< int > ISTUP
Definition: LesHouches.h:228
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
std::vector< int > IDUP
Definition: LesHouches.h:223
def ls(path, rec=False)
Definition: eostools.py:349
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
double XWGTUP
Definition: LesHouches.h:194
double SCALUP
Definition: LesHouches.h:208
unsigned int processID() const
bool AlpgenSource::setRunAndEventInfo ( edm::EventID ,
edm::TimeValue_t ,
edm::EventAuxiliary::ExperimentType  
)
overrideprivatevirtual

Implements edm::IDGeneratorSourceBase< PuttableSourceBase >.

Definition at line 395 of file AlpgenSource.cc.

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

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 }
std::unique_ptr< std::ifstream > inputFile_
Pointer to the input file.
Definition: AlpgenSource.cc:65
unsigned long nEvent_
Number of events.
Definition: AlpgenSource.cc:71
unsigned long skipEvents_
Number of events to skip.
Definition: AlpgenSource.cc:68
std::unique_ptr< lhef::HEPEUP > hepeup_
Definition: AlpgenSource.cc:78
bool readAlpgenEvent(lhef::HEPEUP &hepeup)
Read an event and put it into the HEPEUP.
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.

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

Referenced by beginRun().

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 }
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
Definition: AlpgenSource.cc:76
double masses[MASS_MAX]
Definition: AlpgenHeader.h:71
#define comment(par)
Definition: vmac.h:163

Member Data Documentation

std::string AlpgenSource::extraHeaderFileName_
private

Name of the extra header file.

Definition at line 81 of file AlpgenSource.cc.

Referenced by beginRun().

std::string AlpgenSource::extraHeaderName_
private

Name given to the extra header.

Definition at line 84 of file AlpgenSource.cc.

Referenced by beginRun().

std::string AlpgenSource::fileName_
private

Name of the input file.

Definition at line 62 of file AlpgenSource.cc.

Referenced by AlpgenSource(), and beginRun().

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().

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

Definition at line 78 of file AlpgenSource.cc.

Referenced by produce(), and setRunAndEventInfo().

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().

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().

unsigned long AlpgenSource::nEvent_
private

Number of events.

Definition at line 71 of file AlpgenSource.cc.

Referenced by setRunAndEventInfo().

unsigned long AlpgenSource::skipEvents_
private

Number of events to skip.

Definition at line 68 of file AlpgenSource.cc.

Referenced by setRunAndEventInfo().

bool AlpgenSource::writeAlpgenParFile
private

Definition at line 88 of file AlpgenSource.cc.

Referenced by beginRun().

bool AlpgenSource::writeAlpgenWgtFile
private

configuration flags

Definition at line 87 of file AlpgenSource.cc.

Referenced by beginRun().

bool AlpgenSource::writeExtraHeader
private

Definition at line 89 of file AlpgenSource.cc.

Referenced by beginRun().