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 163 of file LH5Reader.cc.

164  : fileURLs(params.getUntrackedParameter<std::vector<std::string> >("fileNames")),
165  strName(""),
166  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
167  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 169 of file LH5Reader.cc.

◆ LH5Reader() [3/3]

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

Definition at line 172 of file LH5Reader.cc.

◆ ~LH5Reader()

lhef::LH5Reader::~LH5Reader ( )

Definition at line 175 of file LH5Reader.cc.

175 { curSource.release(); }

References curSource.

Member Function Documentation

◆ next()

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

Definition at line 177 of file LH5Reader.cc.

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

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:56
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
lhef::logFileAction
static void logFileAction(char const *msg, std::string const &fileName)
Definition: LH5Reader.cc:29
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
LaserTracksInput_cfi.fileNames
fileNames
Definition: LaserTracksInput_cfi.py:8
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