CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
MCatNLOSource Class Reference

#include <MCatNLOSource.h>

Inheritance diagram for MCatNLOSource:
edm::ExternalInputSource gen::Herwig6Instance edm::ConfigurableInputSource gen::FortranInstance edm::InputSource edm::ProductRegistryHelper

Public Member Functions

 MCatNLOSource (const edm::ParameterSet &params, const edm::InputSourceDescription &desc)
 
virtual ~MCatNLOSource ()
 
- Public Member Functions inherited from edm::ExternalInputSource
InputFileCatalogcatalog ()
 
 ExternalInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
std::vector< std::string > const & fileNames () const
 
std::vector< std::string > const & logicalFileNames () const
 
virtual ~ExternalInputSource ()
 
- Public Member Functions inherited from edm::ConfigurableInputSource
 ConfigurableInputSource (ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
 
EventNumber_t event () const
 
unsigned int eventCreationDelay () const
 
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
 
virtual ~ConfigurableInputSource ()
 
- Public Member Functions inherited from edm::InputSource
boost::shared_ptr
< ActivityRegistry
actReg () const
 Accessor for Activity Registry. More...
 
void closeFile (boost::shared_ptr< FileBlock >, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
void doBeginLumi (LuminosityBlockPrincipal &lbp)
 Called by framework at beginning of lumi block. More...
 
void doBeginRun (RunPrincipal &rp)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void doEndLumi (LuminosityBlockPrincipal &lbp, bool cleaningUpAfterException)
 Called by framework at end of lumi block. More...
 
void doEndRun (RunPrincipal &rp, bool cleaningUpAfterException)
 Called by framework at end of run. More...
 
void doPostForkReacquireResources (boost::shared_ptr< multicore::MessageReceiverForSource >)
 
void doPreForkReleaseResources ()
 Called by the framework before forking the process. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
luminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int markLumi ()
 Mark lumi as read. More...
 
int markRun ()
 Mark run as read. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 
bool primary () const
 Accessor for primary input source flag. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 Accessor for product registry. More...
 
bool randomAccess () const
 
void readAndCacheLumi (bool merge, HistoryAppender &historyAppender)
 Read next luminosity block. More...
 
void readAndCacheRun (bool merge, HistoryAppender &historyAppender)
 Read next run. More...
 
EventPrincipalreadEvent (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
EventPrincipalreadEvent (EventID const &)
 Read a specific event. More...
 
boost::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
boost::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)
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource ()
 Destructor. More...
 
- Public Member Functions inherited from gen::Herwig6Instance
bool callWithTimeout (unsigned int secs, void(*fn)())
 
bool give (const std::string &line)
 
 Herwig6Instance (CLHEP::HepRandomEngine *randomEngine=0)
 
 Herwig6Instance (int dummy)
 
void openParticleSpecFile (const std::string fileName)
 
virtual ~Herwig6Instance ()
 
- Public Member Functions inherited from gen::FortranInstance
void call (void(&fn)())
 
template<typename T >
T call (T(&fn)())
 
template<typename A >
void call (void(&fn)(A), A a)
 
template<typename T , typename A >
T call (T(&fn)(A), A a)
 
template<typename A1 , typename A2 >
void call (void(&fn)(A1, A2), A1 a1, A2 a2)
 
template<typename T , typename A1 , typename A2 >
T call (T(&fn)(A1, A2), A1 a1, A2 a2)
 
virtual void enter ()
 
 FortranInstance ()
 
virtual void leave ()
 
virtual void upEvnt ()
 
virtual void upInit ()
 
virtual bool upVeto ()
 
virtual ~FortranInstance ()
 

Protected Member Functions

virtual void beginRun (edm::Run &run)
 
virtual void endJob ()
 
virtual bool hwwarn (const std::string &fn, int code)
 
void nextEvent ()
 
virtual bool produce (edm::Event &event)
 
- Protected Member Functions inherited from edm::ExternalInputSource
void incrementFileIndex ()
 
- Protected Member Functions inherited from edm::ConfigurableInputSource
void reallyReadEvent ()
 
void setEventNumber (EventNumber_t e)
 
void setTime (TimeValue_t t)
 
- Protected Member Functions inherited from edm::InputSource
void decreaseRemainingEventsBy (int iSkipped)
 
EventPrincipaleventPrincipalCache ()
 
boost::shared_ptr
< LuminosityBlockPrincipal >
const 
luminosityBlockPrincipal () const
 
PrincipalCache const & principalCache () const
 
PrincipalCacheprincipalCache ()
 
ProductRegistryproductRegistryUpdate () const
 
void reset () const
 
void resetLuminosityBlockAuxiliary () const
 
void resetRunAuxiliary () const
 
boost::shared_ptr
< RunPrincipal > const 
runPrincipal () const
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
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 Attributes

boost::shared_ptr< lhef::LHEEventevent
 
std::string fileName
 Name of the input file. More...
 
std::auto_ptr< std::ifstream > inputFile
 Pointer to the input file. More...
 
unsigned int nEvents
 Number of events. More...
 
int processCode
 
std::auto_ptr< std::ifstream > reader
 
boost::shared_ptr
< lhef::LHERunInfo
runInfo
 
unsigned int skipEvents
 Number of events to skip. More...
 

Additional Inherited Members

- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::ExternalInputSource
static void fillDescription (ParameterSetDescription &desc)
 
- Static Public Member Functions inherited from edm::ConfigurableInputSource
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 &)
 
- Static Public Member Functions inherited from gen::FortranInstance
template<typename T >
static TgetInstance ()
 

Detailed Description

Definition at line 43 of file MCatNLOSource.h.

Constructor & Destructor Documentation

MCatNLOSource::MCatNLOSource ( const edm::ParameterSet params,
const edm::InputSourceDescription desc 
)
explicit

Definition at line 41 of file MCatNLOSource.cc.

References fileName, edm::ExternalInputSource::fileNames(), and reader.

42  :
43  ExternalInputSource(params, desc, false),
45  skipEvents(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
46  nEvents(0),
47  processCode(params.getParameter<int>("processCode"))
48 {
49  std::vector<std::string> allFileNames = fileNames();
50 
51  // Only one filename
52  if (allFileNames.size() != 1)
53  throw cms::Exception("Generator|MCatNLOInterface")
54  << "MCatNLOSource needs exactly one file specified. " <<std::endl;
55 
56  fileName = allFileNames[0];
57 
58  // Strip the "file:" prefix
59  if (fileName.find("file:") != 0)
60  throw cms::Exception("Generator|MCatNLOInterface") << "MCatNLOSource only supports the file: scheme. "<<std::endl;
61  fileName.erase(0, 5);
62 
63  // open input file
64  reader.reset(new std::ifstream(fileName.c_str()));
65 
66  produces<LHEEventProduct>();
67  produces<LHERunInfoProduct, edm::InRun>();
68 }
T getParameter(std::string const &) const
unsigned int nEvents
Number of events.
Definition: MCatNLOSource.h:69
T getUntrackedParameter(std::string const &, T const &) const
std::auto_ptr< std::ifstream > reader
Definition: MCatNLOSource.h:73
std::string fileName
Name of the input file.
Definition: MCatNLOSource.h:60
unsigned int skipEvents
Number of events to skip.
Definition: MCatNLOSource.h:66
ExternalInputSource(ParameterSet const &pset, InputSourceDescription const &desc, bool realData=true)
std::vector< std::string > const & fileNames() const
MCatNLOSource::~MCatNLOSource ( )
virtual

Definition at line 70 of file MCatNLOSource.cc.

71 {
72 }

Member Function Documentation

void MCatNLOSource::beginRun ( edm::Run run)
protectedvirtual

Reimplemented from edm::ConfigurableInputSource.

Definition at line 100 of file MCatNLOSource.cc.

References abs, LHERunInfoProduct::Header::addLine(), MCPARS_::emmax, MCPARS_::emmaxs, MCPARS_::emmin, MCPARS_::emmins, fileName, MCPARS_::gammax, MCPARS_::gammaxs, MCPARS_::gamw, MCPARS_::gamws, MCPARS_::gamz, MCPARS_::gamzs, i, makeConfigLine(), mcatnloupinit_(), mcpars_, processCode, edm::Run::put(), lhef::CommonBlocks::readHEPRUP(), MCPARS_::rmass, MCPARS_::rmasss, runInfo, and wrapper.

101 {
102  InstanceWrapper wrapper(this);
103 
104  // call UPINIT privided by MC@NLO (v3.4)
105  mcatnloupinit_(&processCode, fileName.c_str(), fileName.length());
106 
107  // fill HEPRUP common block and store in edm::Run
108  lhef::HEPRUP heprup;
110 
111  // make sure we write a valid LHE header, Herwig6Hadronizer
112  // will interpret it correctly and set up LHAPDF
113  heprup.PDFGUP.first = 0;
114  heprup.PDFGUP.second = 0;
115 
116  std::auto_ptr<LHERunInfoProduct> runInfo(new LHERunInfoProduct(heprup));
117 
118  LHERunInfoProduct::Header hw6header("herwig6header");
119  hw6header.addLine("\n");
120  hw6header.addLine("# Herwig6 parameters\n");
121  hw6header.addLine(makeConfigLine("IPROC", processCode));
122  // add lines for parameter that have been touched by UPINIT
123  if(mcpars_.emmins)
124  hw6header.addLine(makeConfigLine("EMMIN", mcpars_.emmin));
125  if(mcpars_.emmaxs)
126  hw6header.addLine(makeConfigLine("EMMAX", mcpars_.emmax));
127  if(mcpars_.gammaxs)
128  hw6header.addLine(makeConfigLine("GAMMAX",mcpars_.gammax));
129  if(mcpars_.gamzs)
130  hw6header.addLine(makeConfigLine("GAMZ",mcpars_.gamz));
131  if(mcpars_.gamws)
132  hw6header.addLine(makeConfigLine("GAMW",mcpars_.gamw));
133  for(unsigned int i=0; i<1000; ++i) {
134  if(mcpars_.rmasss[i])
135  hw6header.addLine(makeConfigLine("RMASS",i+1,mcpars_.rmass[i]));
136  }
137 
138  // other needed MC@NLO defaults (from mcatnlo_hwdriver.f v3.4)
139  hw6header.addLine(makeConfigLine("SOFTME", false));
140  hw6header.addLine(makeConfigLine("NOWGT", false));
141  hw6header.addLine(makeConfigLine("NEGWTS", true));
142  if(abs(processCode)==1705 || abs(processCode)==11705)
143  hw6header.addLine(makeConfigLine("PSPLT",2,0.5));
144  double wgtmax_=1.000001;
145  hw6header.addLine(makeConfigLine("WGTMAX", wgtmax_));
146  hw6header.addLine(makeConfigLine("AVABW", wgtmax_));
147  hw6header.addLine(makeConfigLine("RLTIM",6, 1.0E-23));
148  hw6header.addLine(makeConfigLine("RLTIM",12, 1.0E-23));
149 
150 
151  runInfo->addHeader(hw6header);
152 
153  run.put(runInfo);
154 
155  return;
156 }
int i
Definition: DBlmapReader.cc:9
static std::string makeConfigLine(const char *var, T value)
struct MCPARS_ mcpars_
int emmaxs
Definition: MCatNLOSource.h:30
double rmass[1000]
Definition: MCatNLOSource.h:26
#define abs(x)
Definition: mlp_lapack.h:159
void mcatnloupinit_(int *, const char *, int)
int emmins
Definition: MCatNLOSource.h:29
double gammax
Definition: MCatNLOSource.h:25
double emmin
Definition: MCatNLOSource.h:23
static void readHEPRUP(HEPRUP *heprup)
int rmasss[1000]
Definition: MCatNLOSource.h:32
int gammaxs
Definition: MCatNLOSource.h:31
double gamz
Definition: MCatNLOSource.h:28
double emmax
Definition: MCatNLOSource.h:24
double gamw
Definition: MCatNLOSource.h:27
std::string fileName
Name of the input file.
Definition: MCatNLOSource.h:60
boost::shared_ptr< lhef::LHERunInfo > runInfo
Definition: MCatNLOSource.h:75
void put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Run.h:81
static HepMC::HEPEVT_Wrapper wrapper
void MCatNLOSource::endJob ( void  )
protectedvirtual

Reimplemented from edm::InputSource.

Definition at line 74 of file MCatNLOSource.cc.

References reader.

75 {
76  reader.reset();
77 }
std::auto_ptr< std::ifstream > reader
Definition: MCatNLOSource.h:73
bool MCatNLOSource::hwwarn ( const std::string &  fn,
int  code 
)
protectedvirtual

Reimplemented from gen::Herwig6Instance.

Definition at line 190 of file MCatNLOSource.cc.

191 {
192  // dummy ignoring useless HERWIG warnings
193  return true;
194 }
void MCatNLOSource::nextEvent ( )
protectedvirtual

Reimplemented from edm::ConfigurableInputSource.

Definition at line 79 of file MCatNLOSource.cc.

80 {
81  return;
82 }
bool MCatNLOSource::produce ( edm::Event event)
protectedvirtual

Implements edm::ConfigurableInputSource.

Definition at line 158 of file MCatNLOSource.cc.

References lhef::HEPEUP::IDPRUP, lhef::HEPRUP::LPRUP, makeConfigLine(), mcatnloupevnt_(), processCode, lhef::CommonBlocks::readHEPEUP(), lhef::CommonBlocks::readHEPRUP(), skipEvents, wrapper, and lhef::HEPEUP::XWGTUP.

159 {
160  InstanceWrapper wrapper(this);
161 
162  int lastEventDone=0;
163  int ihpro=0;
164  // skip events if asked to...
165 
166  while(skipEvents>0) {
167  skipEvents--;
168  mcatnloupevnt_(&processCode,&lastEventDone,&ihpro);
169  if(lastEventDone) return false;
170  }
171 
172  // call UPINIT privided by MC@NLO (v3.4)
173  mcatnloupevnt_(&processCode,&lastEventDone,&ihpro);
174 
175  if(lastEventDone) return false;
176 
177  // fill HEPRUP common block and store in edm::Run
178  lhef::HEPRUP heprup;
179  lhef::HEPEUP hepeup;
182  hepeup.IDPRUP = heprup.LPRUP[0];
183  std::auto_ptr<LHEEventProduct> lhEvent(new LHEEventProduct(hepeup,hepeup.XWGTUP));
184  lhEvent->addComment(makeConfigLine("#IHPRO", ihpro));
185  event.put(lhEvent);
186 
187  return true;
188 }
static std::string makeConfigLine(const char *var, T value)
static void readHEPRUP(HEPRUP *heprup)
unsigned int skipEvents
Number of events to skip.
Definition: MCatNLOSource.h:66
void mcatnloupevnt_(int *, int *, int *)
static void readHEPEUP(HEPEUP *hepeup)
double XWGTUP
Definition: LesHouches.h:196
static HepMC::HEPEVT_Wrapper wrapper
std::vector< int > LPRUP
Definition: LesHouches.h:124

Member Data Documentation

boost::shared_ptr<lhef::LHEEvent> MCatNLOSource::event
protected

Definition at line 76 of file MCatNLOSource.h.

std::string MCatNLOSource::fileName
protected

Name of the input file.

Definition at line 60 of file MCatNLOSource.h.

Referenced by beginRun(), and MCatNLOSource().

std::auto_ptr<std::ifstream> MCatNLOSource::inputFile
protected

Pointer to the input file.

Definition at line 63 of file MCatNLOSource.h.

unsigned int MCatNLOSource::nEvents
protected

Number of events.

Definition at line 69 of file MCatNLOSource.h.

int MCatNLOSource::processCode
protected

Definition at line 71 of file MCatNLOSource.h.

Referenced by beginRun(), and produce().

std::auto_ptr<std::ifstream> MCatNLOSource::reader
protected

Definition at line 73 of file MCatNLOSource.h.

Referenced by endJob(), and MCatNLOSource().

boost::shared_ptr<lhef::LHERunInfo> MCatNLOSource::runInfo
protected

Definition at line 75 of file MCatNLOSource.h.

Referenced by beginRun().

unsigned int MCatNLOSource::skipEvents
protected

Number of events to skip.

Definition at line 66 of file MCatNLOSource.h.

Referenced by produce().