CMS 3D CMS Logo

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

#include <LH5Reader.h>

Public Member Functions

void counter (int, int)
 
std::vector< lheh5::ParticlegetEvent ()
 
std::pair< lheh5::EventHeader, std::vector< lheh5::Particle > > getEventProperties ()
 
lheh5::EventHeader getHeader ()
 
 H5Handler (const std::string &fileNameIn)
 
void readBlock ()
 
virtual ~H5Handler ()
 

Public Attributes

HighFive::Group _event
 
lheh5::Events _events1
 
lheh5::Events2 _events2
 
unsigned int long _eventsRead
 
HighFive::Group _index
 
HighFive::Group _init
 
HighFive::Group _particle
 
HighFive::Group _procInfo
 
std::unique_ptr< HighFive::File > h5file
 
bool indexStatus
 
int npLO
 
int npNLO
 

Private Attributes

int _blocksRead
 
int _eventsInBlock
 
unsigned int long _eventsTotal
 
int _formatType
 

Detailed Description

Definition at line 16 of file LH5Reader.h.

Constructor & Destructor Documentation

◆ H5Handler()

lhef::H5Handler::H5Handler ( const std::string &  fileNameIn)

Definition at line 68 of file LH5Reader.cc.

69  : h5file(new HighFive::File(fileNameIn)),
70  indexStatus(h5file->exist("/index")),
71  _index(h5file->getGroup(indexStatus ? "index" : "event")),
72  _particle(h5file->getGroup("particle")),
73  _event(h5file->getGroup("event")),
74  _init(h5file->getGroup("init")),
75  _procInfo(h5file->getGroup("procInfo")) {
76  hid_t dspace;
77  _formatType = 1;
78 
79  if (indexStatus) {
80  dspace = H5Dget_space(h5file->getDataSet("index/start").getId());
81  _formatType = 2;
82  } else {
83  _index = h5file->getGroup("event");
84  dspace = H5Dget_space(h5file->getDataSet("event/start").getId());
85  _formatType = 1;
86  }
87 
88  _eventsTotal = H5Sget_simple_extent_npoints(dspace);
89  _eventsRead = 0;
90  _eventsInBlock = 6400 / 4; // configurable parameter??
91  if (_eventsTotal % _eventsInBlock != 0)
92  throw cms::Exception("ReadError") << "block size does not match HDF5 file" << std::endl;
93  _blocksRead = 0;
94 
95  // Check if the file contains the npLO, npNLO information
96  bool status = h5file->exist("/procInfo/npLO");
97  if (status) {
98  HighFive::DataSet _npLO = _procInfo.getDataSet("npLO");
99  _npLO.read(npLO);
100  HighFive::DataSet _npNLO = _procInfo.getDataSet("npNLO");
101  _npNLO.read(npNLO);
102  } else {
103  npLO = 1;
104  npNLO = 0;
105  }
106  };

References _blocksRead, _eventsInBlock, _eventsRead, _eventsTotal, _formatType, _index, _procInfo, Exception, h5file, indexStatus, npLO, npNLO, and mps_update::status.

◆ ~H5Handler()

virtual lhef::H5Handler::~H5Handler ( )
inlinevirtual

Definition at line 19 of file LH5Reader.h.

19 {}

Member Function Documentation

◆ counter()

void lhef::H5Handler::counter ( int  firstEventIn,
int  maxEventsIn 
)

Definition at line 108 of file LH5Reader.cc.

108  {
109  if (maxEventsIn > 0 && firstEventIn > maxEventsIn)
110  throw cms::Exception("ConfigurationError") << "\" firstEvent > maxEvents \"" << std::endl;
111  // Reset maximum number of events to read
112  if (_blocksRead == 0 && maxEventsIn >= 0 && (unsigned long int)maxEventsIn < _eventsTotal)
113  _eventsTotal = (unsigned long int)maxEventsIn;
114  // If there are multiple files, assume you only want to jump through the first file
115  if (firstEventIn > 0 && _blocksRead > 0)
116  _eventsRead = firstEventIn - 1;
117  // Set blocks read to be in the correct place
119  }

References _blocksRead, _eventsInBlock, _eventsRead, _eventsTotal, Exception, and createfilelist::int.

Referenced by counter.Counters::__getitem__().

◆ getEvent()

std::vector< lheh5::Particle > lhef::H5Handler::getEvent ( )

Definition at line 131 of file LH5Reader.cc.

131  {
132  std::vector<lheh5::Particle> _vE;
133  if (_eventsRead > _eventsTotal - 1)
134  return std::vector<lheh5::Particle>();
135  int checkEvents = (_blocksRead)*_eventsInBlock - 1;
137  _eventsRead++;
138  if (checkEvents >= 0 && _eventsRead > (unsigned long int)checkEvents)
139  readBlock();
140  return _vE;
141  }

References _blocksRead, _events1, _eventsInBlock, _eventsRead, _eventsTotal, lheh5::Events::mkEvent(), and readBlock().

◆ getEventProperties()

std::pair< lheh5::EventHeader, std::vector< lheh5::Particle > > lhef::H5Handler::getEventProperties ( )

Definition at line 148 of file LH5Reader.cc.

148  {
149  std::vector<lheh5::Particle> _vE;
151  _h.nparticles = -1;
152  if (_eventsRead > _eventsTotal - 1)
153  return std::make_pair(_h, _vE);
154  int checkEvents = (_blocksRead)*_eventsInBlock - 1;
157  _eventsRead++;
158  if (checkEvents >= 0 && _eventsRead > (unsigned long int)checkEvents)
159  readBlock();
160  return std::make_pair(_h, _vE);
161  }

References _blocksRead, _events1, _eventsInBlock, _eventsRead, _eventsTotal, lheh5::Events::mkEvent(), lheh5::Events::mkEventHeader(), lheh5::EventHeader::nparticles, and readBlock().

◆ getHeader()

lheh5::EventHeader lhef::H5Handler::getHeader ( )

Definition at line 143 of file LH5Reader.cc.

143  {
144  // fragile, must be called before getEvent
146  }

References _events1, _eventsRead, and lheh5::Events::mkEventHeader().

◆ readBlock()

void lhef::H5Handler::readBlock ( )

Definition at line 121 of file LH5Reader.cc.

121  {
122  // Start counting at 0
123  size_t iStart = _blocksRead * _eventsInBlock;
124  size_t nEvents = _eventsInBlock;
125  if ((unsigned long int)(iStart + nEvents) > _eventsTotal)
126  return;
128  _blocksRead++;
129  }

References _blocksRead, _event, _events1, _eventsInBlock, _eventsTotal, _index, _particle, nEvents, and lheh5::readEvents().

Referenced by getEvent(), and getEventProperties().

Member Data Documentation

◆ _blocksRead

int lhef::H5Handler::_blocksRead
private

Definition at line 37 of file LH5Reader.h.

Referenced by counter(), getEvent(), getEventProperties(), H5Handler(), and readBlock().

◆ _event

HighFive::Group lhef::H5Handler::_event

Definition at line 24 of file LH5Reader.h.

Referenced by readBlock().

◆ _events1

lheh5::Events lhef::H5Handler::_events1

Definition at line 28 of file LH5Reader.h.

Referenced by getEvent(), getEventProperties(), getHeader(), and readBlock().

◆ _events2

lheh5::Events2 lhef::H5Handler::_events2

Definition at line 27 of file LH5Reader.h.

◆ _eventsInBlock

int lhef::H5Handler::_eventsInBlock
private

Definition at line 35 of file LH5Reader.h.

Referenced by counter(), getEvent(), getEventProperties(), H5Handler(), and readBlock().

◆ _eventsRead

unsigned int long lhef::H5Handler::_eventsRead

Definition at line 26 of file LH5Reader.h.

Referenced by counter(), getEvent(), getEventProperties(), getHeader(), and H5Handler().

◆ _eventsTotal

unsigned int long lhef::H5Handler::_eventsTotal
private

Definition at line 34 of file LH5Reader.h.

Referenced by counter(), getEvent(), getEventProperties(), H5Handler(), and readBlock().

◆ _formatType

int lhef::H5Handler::_formatType
private

Definition at line 36 of file LH5Reader.h.

Referenced by H5Handler().

◆ _index

HighFive::Group lhef::H5Handler::_index

Definition at line 24 of file LH5Reader.h.

Referenced by ntupleDataFormat._Object::__getattr__(), python.cmstools.EventTree::__getitem__(), python.cmstools.EventTree::__iter__(), python.cmstools.EventBranch::__readData(), python.cmstools.EventTree::__setBranchIndicies(), ntupleDataFormat.TrackingParticle::_nMatchedSeeds(), ntupleDataFormat._SimHitMatchAdaptor::_nMatchedSimHits(), ntupleDataFormat._TrackingParticleMatchAdaptor::_nMatchedTrackingParticles(), ntupleDataFormat.TrackingParticle::_nMatchedTracks(), html.HtmlReport::addNote(), ntupleDataFormat.TrackingVertex::daughterTrackingParticles(), ntupleDataFormat.TrackingParticle::decayVertices(), ntupleDataFormat._DetIdStrAdaptor::detIdStr(), H5Handler(), ntupleDataFormat._Object::index(), python.cmstools.EventTree::index(), ntupleDataFormat.Seed::indexWithinAlgo(), ntupleDataFormat._Object::isValid(), ntupleDataFormat._DetIdStrAdaptor::layerStr(), ntupleDataFormat.InvalidHit::layerStr(), ntupleDataFormat.TrackingParticle::matchedSeedInfos(), ntupleDataFormat._SimHitMatchAdaptor::matchedSimHitInfos(), ntupleDataFormat.TrackingParticle::matchedTrackInfos(), ntupleDataFormat._TrackingParticleMatchAdaptor::matchedTrackingParticleInfos(), ntupleDataFormat.GluedHit::monoHit(), ntupleDataFormat.TrackingVertex::nDaughterTrackingParticles(), ntupleDataFormat.SimHit::nRecHits(), ntupleDataFormat._HitObject::nseeds(), ntupleDataFormat.GluedHit::nseeds(), ntupleDataFormat.TrackingVertex::nSourceTrackingParticles(), ntupleDataFormat._HitObject::ntracks(), ntupleDataFormat.Vertex::nTracks(), ntupleDataFormat.TrackingParticle::parentVertex(), readBlock(), ntupleDataFormat.SeedMatchInfo::seed(), ntupleDataFormat.Track::seed(), ntupleDataFormat._HitObject::seeds(), ntupleDataFormat.GluedHit::seeds(), python.cmstools.EventBranch::setIndex(), ntupleDataFormat.SimHitMatchInfo::simHit(), ntupleDataFormat.TrackingVertex::sourceTrackingParticles(), ntupleDataFormat.GluedHit::stereoHit(), ntupleDataFormat.Seed::track(), ntupleDataFormat.SimHit::trackingParticle(), ntupleDataFormat._HitObject::tracks(), ntupleDataFormat.Vertex::tracks(), ntupleDataFormat.Track::vertex(), and html.HtmlReport::write().

◆ _init

HighFive::Group lhef::H5Handler::_init

◆ _particle

HighFive::Group lhef::H5Handler::_particle

Definition at line 24 of file LH5Reader.h.

Referenced by readBlock().

◆ _procInfo

HighFive::Group lhef::H5Handler::_procInfo

Definition at line 24 of file LH5Reader.h.

Referenced by H5Handler().

◆ h5file

std::unique_ptr<HighFive::File> lhef::H5Handler::h5file

Definition at line 22 of file LH5Reader.h.

Referenced by H5Handler().

◆ indexStatus

bool lhef::H5Handler::indexStatus

Definition at line 23 of file LH5Reader.h.

Referenced by H5Handler().

◆ npLO

int lhef::H5Handler::npLO

Definition at line 25 of file LH5Reader.h.

Referenced by H5Handler().

◆ npNLO

int lhef::H5Handler::npNLO

Definition at line 25 of file LH5Reader.h.

Referenced by H5Handler().

lhef::H5Handler::_formatType
int _formatType
Definition: LH5Reader.h:36
lheh5::Events::mkEventHeader
EventHeader mkEventHeader(int ievent) const
Definition: lheh5.cc:51
mps_update.status
status
Definition: mps_update.py:69
lhef::H5Handler::readBlock
void readBlock()
Definition: LH5Reader.cc:121
lhef::H5Handler::_particle
HighFive::Group _particle
Definition: LH5Reader.h:24
lhef::H5Handler::_index
HighFive::Group _index
Definition: LH5Reader.h:24
lheh5::Events::mkEvent
std::vector< Particle > mkEvent(size_t ievent) const
Definition: lheh5.cc:35
lhef::H5Handler::indexStatus
bool indexStatus
Definition: LH5Reader.h:23
lhef::H5Handler::npLO
int npLO
Definition: LH5Reader.h:25
lheh5::EventHeader
Definition: lheh5.h:28
lhef::H5Handler::h5file
std::unique_ptr< HighFive::File > h5file
Definition: LH5Reader.h:22
lhef::H5Handler::_eventsInBlock
int _eventsInBlock
Definition: LH5Reader.h:35
lhef::H5Handler::_procInfo
HighFive::Group _procInfo
Definition: LH5Reader.h:24
lhef::H5Handler::_events1
lheh5::Events _events1
Definition: LH5Reader.h:28
createfilelist.int
int
Definition: createfilelist.py:10
lhef::H5Handler::_event
HighFive::Group _event
Definition: LH5Reader.h:24
lhef::H5Handler::_blocksRead
int _blocksRead
Definition: LH5Reader.h:37
lheh5::readEvents
Events readEvents(HighFive::Group &g_index, HighFive::Group &g_particle, HighFive::Group &g_event, size_t first_event, size_t n_events)
Definition: lheh5.cc:68
lhef::H5Handler::_eventsRead
unsigned int long _eventsRead
Definition: LH5Reader.h:26
VtxSmearedBeamProfile_cfi.File
File
Definition: VtxSmearedBeamProfile_cfi.py:30
lheh5::EventHeader::nparticles
int nparticles
Definition: lheh5.h:30
Exception
Definition: hltDiff.cc:245
lhef::H5Handler::_init
HighFive::Group _init
Definition: LH5Reader.h:24
lhef::H5Handler::npNLO
int npNLO
Definition: LH5Reader.h:25
lhef::H5Handler::_eventsTotal
unsigned int long _eventsTotal
Definition: LH5Reader.h:34
nEvents
UInt_t nEvents
Definition: hcalCalib.cc:40