CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
lhef::LH5Reader Class Reference

#include <LH5Reader.h>

Classes

class  FileSource
 
class  Source
 
class  StringSource
 

Public Member Functions

 LH5Reader (const edm::ParameterSet &params)
 
 LH5Reader (const std::string &inputs, unsigned int skip=0, int maxEvents=-1)
 
 LH5Reader (const std::vector< std::string > &fileNames, unsigned int skip=0, int maxEvents=-1)
 
std::shared_ptr< LHEEventnext (bool *newFileOpened=nullptr)
 
 ~LH5Reader ()
 

Private Attributes

bool curDoc
 
unsigned int curIndex
 
std::shared_ptr< LHERunInfocurRunInfo
 
std::unique_ptr< SourcecurSource
 
const std::vector< std::string > fileURLs
 
unsigned int firstEvent
 
int maxEvents
 
const std::string strName
 
std::vector< std::string > weightsinconfig
 

Detailed Description

Definition at line 40 of file LH5Reader.h.

Constructor & Destructor Documentation

◆ LH5Reader() [1/3]

lhef::LH5Reader::LH5Reader ( const edm::ParameterSet params)

Definition at line 165 of file LH5Reader.cc.

166  : fileURLs(params.getUntrackedParameter<std::vector<std::string> >("fileNames")),
167  strName(""),
168  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
169  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)) {}

◆ LH5Reader() [2/3]

lhef::LH5Reader::LH5Reader ( const std::vector< std::string > &  fileNames,
unsigned int  skip = 0,
int  maxEvents = -1 
)

Definition at line 171 of file LH5Reader.cc.

◆ LH5Reader() [3/3]

lhef::LH5Reader::LH5Reader ( const std::string &  inputs,
unsigned int  skip = 0,
int  maxEvents = -1 
)

Definition at line 174 of file LH5Reader.cc.

◆ ~LH5Reader()

lhef::LH5Reader::~LH5Reader ( )

Definition at line 177 of file LH5Reader.cc.

177 { curSource.release(); }

References curSource.

Member Function Documentation

◆ next()

std::shared_ptr< LHEEvent > lhef::LH5Reader::next ( bool *  newFileOpened = nullptr)

Definition at line 179 of file LH5Reader.cc.

179  {
180  while (curDoc || curIndex < fileURLs.size() || (fileURLs.empty() && !strName.empty())) {
181  if (!curDoc) {
182  if (!fileURLs.empty()) {
183  logFileAction(" Initiating request to open LHE file ", fileURLs[curIndex]);
184  curSource = std::make_unique<FileSource>(fileURLs[curIndex]);
185  logFileAction(" Successfully opened LHE file ", fileURLs[curIndex]);
186  if (newFileOpened != nullptr)
187  *newFileOpened = true;
188  ++curIndex;
189  } else if (!strName.empty()) {
190  curSource = std::make_unique<StringSource>(strName);
191  }
192  // New "doc" has been opened. This is the same as a new source.
193  curDoc = true;
194  // Set maxEvents and firstEvent
195  curSource->handler->counter(firstEvent, maxEvents);
196  curSource->handler->readBlock();
197 
198  curRunInfo.reset();
199  HEPRUP tmprup;
200  int beamA, beamB;
201  curSource->handler->_init.getDataSet("beamA").read(beamA);
202  curSource->handler->_init.getDataSet("beamB").read(beamB);
203  tmprup.IDBMUP = std::make_pair(beamA, beamB);
204  double energyA, energyB;
205  curSource->handler->_init.getDataSet("energyA").read(energyA);
206  curSource->handler->_init.getDataSet("energyB").read(energyB);
207  tmprup.EBMUP = std::make_pair(energyA, energyB);
208  int PDFsetA, PDFsetB;
209  curSource->handler->_init.getDataSet("PDFsetA").read(PDFsetA);
210  curSource->handler->_init.getDataSet("PDFsetB").read(PDFsetB);
211  tmprup.PDFSUP = std::make_pair(PDFsetA, PDFsetB);
212  int PDFgroupA, PDFgroupB;
213  curSource->handler->_init.getDataSet("PDFgroupA").read(PDFgroupA);
214  curSource->handler->_init.getDataSet("PDFgroupB").read(PDFgroupB);
215  tmprup.PDFGUP = std::make_pair(PDFgroupA, PDFgroupB);
216  std::vector<int> procId; // NOTE: C++17 allows int[numProcesses]
217  std::vector<double> xSection; // NOTE: C++17 allows double[numProcesses]
218  std::vector<double> error; // NOTE: C++17 allows double[numProcesses]
219  std::vector<double> unitWeight; // NOTE: C++17 allows double[numProcesses]
220 
221  curSource->handler->_procInfo.getDataSet("procId").read(procId);
222  curSource->handler->_procInfo.getDataSet("xSection").read(xSection);
223  curSource->handler->_procInfo.getDataSet("error").read(error);
224  curSource->handler->_procInfo.getDataSet("unitWeight").read(unitWeight);
225 
226  tmprup.LPRUP = procId;
227  tmprup.XSECUP = xSection;
228  tmprup.XERRUP = error;
229  tmprup.XMAXUP = unitWeight;
230  tmprup.IDWTUP = 3;
231  size_t numProcesses = procId.size();
232  tmprup.NPRUP = numProcesses;
233  // Use temporary process info block to define const HEPRUP
234  const HEPRUP heprup(tmprup);
235 
236  curRunInfo.reset(new LHERunInfo(heprup));
237  // Run info has now been set when a new file is encountered
238  }
239  // Handler should be modified to have these capabilities
240  // Maybe this is set event by event??
241  int npLO = curSource->handler->npLO;
242  int npNLO = curSource->handler->npNLO;
243 
244  // Event-loop here
245  std::pair<EventHeader, std::vector<Particle> > evp = curSource->handler->getEventProperties();
246  EventHeader hd = evp.first;
247  if (hd.nparticles < 0) {
248  curDoc = false;
249  logFileAction(" Closed LHE file ", fileURLs[curIndex - 1]);
250  return std::shared_ptr<LHEEvent>();
251  }
252  HEPEUP tmp;
253  tmp.resize(hd.nparticles);
254  //Particle loop
255  unsigned int ip = 0;
256  // for (auto part: curSource->handler->_events1.mkEvent(i)) {
257  for (auto part : evp.second) {
258  tmp.IDUP[ip] = part.id;
259  tmp.ISTUP[ip] = part.status;
260  tmp.MOTHUP[ip] = std::make_pair(part.mother1, part.mother2);
261  tmp.ICOLUP[ip] = std::make_pair(part.color1, part.color2);
262  tmp.VTIMUP[ip] = part.lifetime;
263  tmp.SPINUP[ip] = part.spin;
264  tmp.PUP[ip][0] = part.px;
265  tmp.PUP[ip][1] = part.py;
266  tmp.PUP[ip][2] = part.pz;
267  tmp.PUP[ip][3] = part.e;
268  tmp.PUP[ip][4] = part.m;
269  ip++;
270  }
271  tmp.IDPRUP = hd.pid;
272  tmp.XWGTUP = hd.weight;
273  tmp.SCALUP = hd.scale;
274  tmp.AQEDUP = hd.aqed;
275  tmp.AQCDUP = hd.aqcd;
276  std::shared_ptr<LHEEvent> lheevent;
277  // Use temporary event to construct const HEPEUP;
278  const HEPEUP hepeup(tmp);
279 
280  lheevent.reset(new LHEEvent(curRunInfo, hepeup));
281  // Might have to add this capability later
282  /* const XMLHandler::wgt_info &info = handler->weightsinevent;
283  for (size_t i = 0; i < info.size(); ++i) {
284  double num = -1.0;
285  sscanf(info[i].second.c_str(), "%le", &num);
286  lheevent->addWeight(gen::WeightsInfo(info[i].first, num));
287  }*/
288  // Currently these are set just at the beginning?
289  // might be an event property
290  lheevent->setNpLO(npLO);
291  lheevent->setNpNLO(npNLO);
292  //fill scales
293  /* if (!handler->scales.empty()) {
294  lheevent->setScales(handler->scales);
295  }*/
296  return lheevent;
297  }
298  return std::shared_ptr<LHEEvent>();
299  }

References lheh5::EventHeader::aqcd, lheh5::EventHeader::aqed, curDoc, curIndex, curRunInfo, curSource, lhef::HEPRUP::EBMUP, relativeConstraints::error, fileURLs, firstEvent, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, particlelevel_cff::LHERunInfo, lhef::logFileAction(), lhef::HEPRUP::LPRUP, maxEvents, lheh5::EventHeader::nparticles, lhef::HEPRUP::NPRUP, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, lheh5::EventHeader::pid, lheh5::EventHeader::scale, strName, createJobs::tmp, lheh5::EventHeader::weight, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, and lhef::HEPRUP::XSECUP.

Member Data Documentation

◆ curDoc

bool lhef::LH5Reader::curDoc
private

Definition at line 62 of file LH5Reader.h.

Referenced by next().

◆ curIndex

unsigned int lhef::LH5Reader::curIndex
private

Definition at line 58 of file LH5Reader.h.

Referenced by next().

◆ curRunInfo

std::shared_ptr<LHERunInfo> lhef::LH5Reader::curRunInfo
private

Definition at line 63 of file LH5Reader.h.

Referenced by next().

◆ curSource

std::unique_ptr<Source> lhef::LH5Reader::curSource
private

Definition at line 61 of file LH5Reader.h.

Referenced by next(), and ~LH5Reader().

◆ fileURLs

const std::vector<std::string> lhef::LH5Reader::fileURLs
private

Definition at line 52 of file LH5Reader.h.

Referenced by next().

◆ firstEvent

unsigned int lhef::LH5Reader::firstEvent
private

Definition at line 56 of file LH5Reader.h.

Referenced by looper.Looper::loop(), next(), and Printer.Printer::process().

◆ maxEvents

int lhef::LH5Reader::maxEvents
private

Definition at line 57 of file LH5Reader.h.

Referenced by next().

◆ strName

const std::string lhef::LH5Reader::strName
private

Definition at line 55 of file LH5Reader.h.

Referenced by next().

◆ weightsinconfig

std::vector<std::string> lhef::LH5Reader::weightsinconfig
private

Definition at line 59 of file LH5Reader.h.

lhef::LH5Reader::maxEvents
int maxEvents
Definition: LH5Reader.h:57
lhef::LH5Reader::curIndex
unsigned int curIndex
Definition: LH5Reader.h:58
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
particlelevel_cff.LHERunInfo
LHERunInfo
Definition: particlelevel_cff.py:57
lheh5::EventHeader::weight
double weight
Definition: lheh5.h:32
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
relativeConstraints.error
error
Definition: relativeConstraints.py:53
lhef::LH5Reader::curSource
std::unique_ptr< Source > curSource
Definition: LH5Reader.h:61
lhef::LH5Reader::curRunInfo
std::shared_ptr< LHERunInfo > curRunInfo
Definition: LH5Reader.h:63
part
part
Definition: HCALResponse.h:20
lheh5::EventHeader
Definition: lheh5.h:28
LaserDQM_cfg.fileNames
fileNames
Definition: LaserDQM_cfg.py:34
lhef::logFileAction
static void logFileAction(char const *msg, std::string const &fileName)
Definition: LH5Reader.cc:31
lhef::LH5Reader::curDoc
bool curDoc
Definition: LH5Reader.h:62
lhef::LH5Reader::fileURLs
const std::vector< std::string > fileURLs
Definition: LH5Reader.h:52
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
lheh5::EventHeader::pid
int pid
Definition: lheh5.h:31
lheh5::EventHeader::nparticles
int nparticles
Definition: lheh5.h:30
lheh5::EventHeader::aqed
double aqed
Definition: lheh5.h:37
lhef::LH5Reader::firstEvent
unsigned int firstEvent
Definition: LH5Reader.h:56
lheh5::EventHeader::scale
double scale
Definition: lheh5.h:34
lhef::LH5Reader::strName
const std::string strName
Definition: LH5Reader.h:55
lheh5::EventHeader::aqcd
double aqcd
Definition: lheh5.h:38