CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
fwlite::Run Class Reference

#include <Run.h>

Inheritance diagram for fwlite::Run:
fwlite::RunBase edm::RunBase

Public Member Functions

bool atEnd () const override
 
std::vector< edm::BranchDescription > const & getBranchDescriptions () const
 
virtual const std::string getBranchNameFor (std::type_info const &, char const *, char const *, char const *) const
 
bool getByLabel (std::type_info const &, char const *, char const *, char const *, void *) const override
 
edm::WrapperBase const * getByProductID (edm::ProductID const &) const
 
bool isValid () const
 
 operator bool () const
 
const Runoperator++ () override
 
 Run (std::shared_ptr< BranchMapReader > branchMap)
 
 Run (TFile *iFile)
 
edm::RunAuxiliary const & runAuxiliary () const override
 
Long64_t size () const
 
bool to (edm::RunNumber_t run)
 Go to event by Run & Run number. More...
 
const RuntoBegin () override
 
 ~Run () override
 
- Public Member Functions inherited from fwlite::RunBase
virtual Long64_t fileIndex () const
 
 RunBase ()
 
virtual Long64_t secondaryFileIndex () const
 
 ~RunBase () override
 
- Public Member Functions inherited from edm::RunBase
Timestamp const & beginTime () const
 
Timestamp const & endTime () const
 
template<typename PROD >
bool getByLabel (InputTag const &tag, Handle< PROD > &result) const
 same as above, but using the InputTag class More...
 
template<typename T >
bool getByLabel (InputTag const &tag, Handle< T > &result) const
 
RunID const & id () const
 
RunNumber_t run () const
 
 RunBase ()
 

Static Public Member Functions

static void throwProductNotFoundException (std::type_info const &, char const *, char const *, char const *)
 

Private Member Functions

const edm::ProcessHistoryhistory () const
 
const Runoperator= (const Run &)=delete
 
 Run (const Run &)=delete
 
void updateAux (Long_t runIndex) const
 

Private Attributes

edm::RunAuxiliary aux_
 
TBranch * auxBranch_
 
std::shared_ptr< BranchMapReaderbranchMap_
 
fwlite::DataGetterHelper dataHelper_
 
EntryFinder entryFinder_
 
int fileVersion_
 
edm::ProcessHistoryMap historyMap_
 
std::vector< char const * > labels_
 
edm::RunAuxiliary const * pAux_
 
edm::RunAux const * pOldAux_
 
std::vector< std::string > procHistoryNames_
 

Friends

class internal::ProductGetter
 
class RunHistoryGetter
 

Detailed Description

Definition at line 54 of file Run.h.

Constructor & Destructor Documentation

◆ Run() [1/3]

Run::Run ( TFile *  iFile)

Definition at line 44 of file Run.cc.

45  : branchMap_(new BranchMapReader(iFile)),
46  pAux_(&aux_),
47  pOldAux_(nullptr),
48  fileVersion_(-1),
49  dataHelper_(branchMap_->getRunTree(), std::make_shared<RunHistoryGetter>(this), branchMap_) {
50  if (nullptr == iFile) {
51  throw cms::Exception("NoFile") << "The TFile pointer passed to the constructor was null";
52  }
53 
54  if (nullptr == branchMap_->getRunTree()) {
55  throw cms::Exception("NoRunTree") << "The TFile contains no TTree named " << edm::poolNames::runTreeName();
56  }
57  //need to know file version in order to determine how to read the basic product info
58  fileVersion_ = branchMap_->getFileVersion(iFile);
59 
60  //got this logic from IOPool/Input/src/RootFile.cc
61 
62  TTree* runTree = branchMap_->getRunTree();
63  if (fileVersion_ >= 3) {
64  auxBranch_ = runTree->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InRun).c_str());
65  if (nullptr == auxBranch_) {
66  throw cms::Exception("NoRunAuxilliary")
67  << "The TTree " << edm::poolNames::runTreeName() << " does not contain a branch named 'RunAuxiliary'";
68  }
69  auxBranch_->SetAddress(&pAux_);
70  } else {
71  throw cms::Exception("OldFileVersion") << "The FWLite Run code des not support old file versions";
72  // This code commented from fwlite::Event. May be portable if needed.
73  // pOldAux_ = new edm::EventAux();
74  // auxBranch_ = runTree->GetBranch(edm::BranchTypeToAuxBranchName(edm::InRun).c_str());
75  // if(nullptr == auxBranch_) {
76  // throw cms::Exception("NoRunAux")<<"The TTree "
77  // <<edm::poolNames::runTreeName()
78  // <<" does not contain a branch named 'RunAux'";
79  // }
80  // auxBranch_->SetAddress(&pOldAux_);
81  }
82  branchMap_->updateRun(0);
83  // getter_ = std::make_shared<ProductGetter>(this);
84  }

References auxBranch_, branchMap_, edm::BranchTypeToAuxiliaryBranchName(), Exception, fileVersion_, edm::InRun, pAux_, and edm::poolNames::runTreeName().

◆ Run() [2/3]

Run::Run ( std::shared_ptr< BranchMapReader branchMap)

Definition at line 86 of file Run.cc.

87  : branchMap_(branchMap),
88  pAux_(&aux_),
89  pOldAux_(nullptr),
90  fileVersion_(-1),
91  dataHelper_(branchMap_->getRunTree(), std::make_shared<RunHistoryGetter>(this), branchMap_) {
92  if (nullptr == branchMap_->getRunTree()) {
93  throw cms::Exception("NoRunTree") << "The TFile contains no TTree named " << edm::poolNames::runTreeName();
94  }
95  //need to know file version in order to determine how to read the basic event info
96  fileVersion_ = branchMap_->getFileVersion();
97  //got this logic from IOPool/Input/src/RootFile.cc
98 
99  TTree* runTree = branchMap_->getRunTree();
100  if (fileVersion_ >= 3) {
101  auxBranch_ = runTree->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InRun).c_str());
102  if (nullptr == auxBranch_) {
103  throw cms::Exception("NoRunAuxilliary")
104  << "The TTree " << edm::poolNames::runTreeName() << " does not contain a branch named 'RunAuxiliary'";
105  }
106  auxBranch_->SetAddress(&pAux_);
107  } else {
108  throw cms::Exception("OldFileVersion") << "The FWLite Run code des not support old file versions";
109  /* pOldAux_ = new edm::EventAux();
110  auxBranch_ = runTree->GetBranch(edm::BranchTypeToAuxBranchName(edm::InRun).c_str());
111  if(nullptr == auxBranch_) {
112  throw cms::Exception("NoRunAux")<<"The TTree "
113  <<edm::poolNames::runTreeName()
114  <<" does not contain a branch named 'RunAux'";
115  }
116  auxBranch_->SetAddress(&pOldAux_);*/
117  }
118  branchMap_->updateRun(0);
119 
120  // if(fileVersion_ >= 7) {
121  // eventHistoryTree_ = dynamic_cast<TTree*>(iFile->Get(edm::poolNames::eventHistoryTreeName().c_str()));
122  // }
123 
124  // getter_ = std::make_shared<ProductGetter>(this);
125  }

References auxBranch_, branchMap_, edm::BranchTypeToAuxiliaryBranchName(), Exception, fileVersion_, edm::InRun, pAux_, and edm::poolNames::runTreeName().

◆ ~Run()

Run::~Run ( )
override

Definition at line 127 of file Run.cc.

127  {
128  for (auto const& label : labels_) {
129  delete[] label;
130  }
131  delete pOldAux_;
132  }

References label, labels_, and pOldAux_.

◆ Run() [3/3]

fwlite::Run::Run ( const Run )
privatedelete

Member Function Documentation

◆ atEnd()

bool Run::atEnd ( ) const
overridevirtual

Implements fwlite::RunBase.

Definition at line 172 of file Run.cc.

172  {
173  Long_t runIndex = branchMap_->getRunEntry();
174  return runIndex == -1 or runIndex == size();
175  }

References branchMap_, or, csv2json::runIndex, and size().

Referenced by getByLabel().

◆ getBranchDescriptions()

std::vector<edm::BranchDescription> const& fwlite::Run::getBranchDescriptions ( ) const
inline

Definition at line 86 of file Run.h.

86  {
87  return branchMap_->getBranchDescriptions();
88  }

References branchMap_.

◆ getBranchNameFor()

const std::string Run::getBranchNameFor ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessLabel 
) const
virtual

Definition at line 177 of file Run.cc.

180  {
181  return dataHelper_.getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
182  }

References dataHelper_, and fwlite::DataGetterHelper::getBranchNameFor().

◆ getByLabel()

bool Run::getByLabel ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessLabel,
void *  oData 
) const
overridevirtual

Implements fwlite::RunBase.

Definition at line 184 of file Run.cc.

188  {
189  if (atEnd()) {
190  throw cms::Exception("OffEnd") << "You have requested data past the last run";
191  }
192  Long_t runIndex = branchMap_->getRunEntry();
193  return dataHelper_.getByLabel(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel, oData, runIndex);
194  }

References atEnd(), branchMap_, dataHelper_, Exception, fwlite::DataGetterHelper::getByLabel(), and csv2json::runIndex.

Referenced by FWMagField::checkFieldInfo().

◆ getByProductID()

edm::WrapperBase const * Run::getByProductID ( edm::ProductID const &  iID) const

Definition at line 271 of file Run.cc.

271  {
272  Long_t runIndex = branchMap_->getRunEntry();
273  return dataHelper_.getByProductID(iID, runIndex);
274  }

References branchMap_, dataHelper_, fwlite::DataGetterHelper::getByProductID(), and csv2json::runIndex.

◆ history()

const edm::ProcessHistory & Run::history ( ) const
private

Definition at line 212 of file Run.cc.

212  {
213  edm::ProcessHistoryID processHistoryID;
214 
215  bool newFormat = false; //(fileVersion_ >= 5);
216 
217  Long_t runIndex = branchMap_->getRunEntry();
219  if (!newFormat) {
220  processHistoryID = aux_.processHistoryID();
221  }
222 
223  if (historyMap_.empty() || newFormat) {
224  procHistoryNames_.clear();
225  TTree* meta = dynamic_cast<TTree*>(branchMap_->getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
226  if (nullptr == meta) {
227  throw cms::Exception("NoMetaTree")
228  << "The TFile does not appear to contain a TTree named " << edm::poolNames::metaDataTreeName();
229  }
230  if (historyMap_.empty()) {
231  if (fileVersion_ < 11) {
233  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryMapBranchName().c_str());
234  b->SetAddress(&pPhm);
235  b->GetEntry(0);
236  } else {
237  edm::ProcessHistoryVector historyVector;
238  edm::ProcessHistoryVector* pPhv = &historyVector;
239  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryBranchName().c_str());
240  b->SetAddress(&pPhv);
241  b->GetEntry(0);
242  for (auto& history : historyVector) {
243  historyMap_.insert(std::make_pair(history.setProcessHistoryID(), history));
244  }
245  }
246  }
247  // if (newFormat) {
248  // if (fileVersion_ >= 7) {
249  // edm::History history;
250  // edm::History* pHistory = &history;
251  // TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
252  // if (!eventHistoryBranch)
253  // throw edm::Exception(edm::errors::FatalRootError)
254  // << "Failed to find history branch in event history tree";
255  // eventHistoryBranch->SetAddress(&pHistory);
256  // eventHistoryTree_->GetEntry(runIndex);
257  // processHistoryID = history.processHistoryID();
258  // } else {
259  // std::vector<edm::EventProcessHistoryID> *pEventProcessHistoryIDs = &eventProcessHistoryIDs_;
260  // TBranch* b = meta->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
261  // b->SetAddress(&pEventProcessHistoryIDs);
262  // b->GetEntry(0);
263  // edm::EventProcessHistoryID target(aux_.id(), edm::ProcessHistoryID());
264  // processHistoryID = std::lower_bound(eventProcessHistoryIDs_.begin(), eventProcessHistoryIDs_.end(), target)->processHistoryID_;
265  // }
266  // }
267  }
268  return historyMap_[processHistoryID];
269  }

References aux_, b, branchMap_, Exception, fileVersion_, historyMap_, edm::poolNames::metaDataTreeName(), edm::poolNames::processHistoryBranchName(), edm::RunAuxiliary::processHistoryID(), edm::poolNames::processHistoryMapBranchName(), procHistoryNames_, csv2json::runIndex, edm::ProcessHistory::setProcessHistoryID(), and updateAux().

Referenced by fwlite::RunHistoryGetter::history().

◆ isValid()

bool Run::isValid ( void  ) const

Definition at line 165 of file Run.cc.

165  {
166  Long_t runIndex = branchMap_->getRunEntry();
167  return runIndex != -1 and runIndex < size();
168  }

References branchMap_, csv2json::runIndex, and size().

Referenced by ntupleDataFormat._Object::_checkIsValid(), and core.AutoHandle.AutoHandle::ReallyLoad().

◆ operator bool()

Run::operator bool ( ) const

Definition at line 170 of file Run.cc.

170 { return isValid(); }

◆ operator++()

const Run & Run::operator++ ( )
overridevirtual

Implements fwlite::RunBase.

Definition at line 138 of file Run.cc.

138  {
139  Long_t runIndex = branchMap_->getRunEntry();
140  if (runIndex < size()) {
141  branchMap_->updateRun(++runIndex);
142  }
143  return *this;
144  }

References branchMap_, csv2json::runIndex, and size().

◆ operator=()

const Run& fwlite::Run::operator= ( const Run )
privatedelete

◆ runAuxiliary()

edm::RunAuxiliary const & Run::runAuxiliary ( ) const
overridevirtual

Implements edm::RunBase.

Definition at line 196 of file Run.cc.

196  {
197  Long_t runIndex = branchMap_->getRunEntry();
199  return aux_;
200  }

References aux_, branchMap_, csv2json::runIndex, and updateAux().

◆ size()

Long64_t Run::size ( void  ) const

Definition at line 163 of file Run.cc.

163 { return branchMap_->getRunTree()->GetEntries(); }

References branchMap_.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), atEnd(), isValid(), and operator++().

◆ throwProductNotFoundException()

void Run::throwProductNotFoundException ( std::type_info const &  iType,
char const *  iModule,
char const *  iProduct,
char const *  iProcess 
)
static

Definition at line 279 of file Run.cc.

282  {
283  edm::TypeID type(iType);
285  << "A branch was found for \n type ='" << type.className() << "'\n module='" << iModule
286  << "'\n productInstance='" << ((nullptr != iProduct) ? iProduct : "") << "'\n process='"
287  << ((nullptr != iProcess) ? iProcess : "")
288  << "'\n"
289  "but no data is available for this Run";
290  }

References Exception, and edm::errors::ProductNotFound.

◆ to()

bool Run::to ( edm::RunNumber_t  run)

Go to event by Run & Run number.

Definition at line 146 of file Run.cc.

146  {
150  return false;
151  }
152  return branchMap_->updateRun(entry);
153  }

References branchMap_, mps_splice::entry, entryFinder_, fwlite::EntryFinder::fillIndex(), fwlite::EntryFinder::findRun(), fwlite::EntryFinder::invalidEntry, and edm::RunBase::run().

◆ toBegin()

const Run & Run::toBegin ( )
overridevirtual

Implements fwlite::RunBase.

Definition at line 155 of file Run.cc.

155  {
156  branchMap_->updateRun(0);
157  return *this;
158  }

References branchMap_.

◆ updateAux()

void Run::updateAux ( Long_t  runIndex) const
private

Definition at line 202 of file Run.cc.

202  {
203  if (auxBranch_->GetEntryNumber() != runIndex) {
204  auxBranch_->GetEntry(runIndex);
205  //handling dealing with old version
206  if (nullptr != pOldAux_) {
208  }
209  }
210  }

References aux_, auxBranch_, edm::conversion(), pOldAux_, and csv2json::runIndex.

Referenced by history(), and runAuxiliary().

Friends And Related Function Documentation

◆ internal::ProductGetter

friend class internal::ProductGetter
friend

Definition at line 100 of file Run.h.

◆ RunHistoryGetter

friend class RunHistoryGetter
friend

Definition at line 101 of file Run.h.

Member Data Documentation

◆ aux_

edm::RunAuxiliary fwlite::Run::aux_
mutableprivate

Definition at line 118 of file Run.h.

Referenced by history(), runAuxiliary(), and updateAux().

◆ auxBranch_

TBranch* fwlite::Run::auxBranch_
private

Definition at line 122 of file Run.h.

Referenced by Run(), and updateAux().

◆ branchMap_

std::shared_ptr<BranchMapReader> fwlite::Run::branchMap_
mutableprivate

◆ dataHelper_

fwlite::DataGetterHelper fwlite::Run::dataHelper_
private

Definition at line 125 of file Run.h.

Referenced by getBranchNameFor(), getByLabel(), and getByProductID().

◆ entryFinder_

EntryFinder fwlite::Run::entryFinder_
mutableprivate

Definition at line 119 of file Run.h.

Referenced by to().

◆ fileVersion_

int fwlite::Run::fileVersion_
private

Definition at line 123 of file Run.h.

Referenced by history(), and Run().

◆ historyMap_

edm::ProcessHistoryMap fwlite::Run::historyMap_
mutableprivate

Definition at line 116 of file Run.h.

Referenced by history().

◆ labels_

std::vector<char const*> fwlite::Run::labels_
mutableprivate

Definition at line 115 of file Run.h.

Referenced by ~Run().

◆ pAux_

edm::RunAuxiliary const* fwlite::Run::pAux_
private

Definition at line 120 of file Run.h.

Referenced by Run().

◆ pOldAux_

edm::RunAux const* fwlite::Run::pOldAux_
private

Definition at line 121 of file Run.h.

Referenced by updateAux(), and ~Run().

◆ procHistoryNames_

std::vector<std::string> fwlite::Run::procHistoryNames_
mutableprivate

Definition at line 117 of file Run.h.

Referenced by history().

fwlite::Run::branchMap_
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:112
edm::poolNames::runTreeName
std::string const & runTreeName()
Definition: BranchType.cc:214
fwlite::Run::aux_
edm::RunAuxiliary aux_
Definition: Run.h:118
edm::conversion
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9
fwlite::EntryFinder::invalidEntry
static const EntryNumber_t invalidEntry
Definition: EntryFinder.h:41
mps_splice.entry
entry
Definition: mps_splice.py:68
fwlite::Run::updateAux
void updateAux(Long_t runIndex) const
Definition: Run.cc:202
fwlite::EntryFinder::findRun
EntryNumber_t findRun(edm::RunNumber_t const &run) const
Definition: EntryFinder.cc:91
fwlite::EntryFinder::EntryNumber_t
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
fwlite::Run::labels_
std::vector< char const * > labels_
Definition: Run.h:115
fwlite::Run::entryFinder_
EntryFinder entryFinder_
Definition: Run.h:119
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
edm::InRun
Definition: BranchType.h:11
edm::BranchTypeToAuxiliaryBranchName
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:109
fwlite::EntryFinder::fillIndex
void fillIndex(BranchMapReader &branchMap)
Definition: EntryFinder.cc:107
edm::errors::ProductNotFound
Definition: EDMException.h:33
edm::ProcessHistoryMap
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
Definition: ProcessHistoryRegistry.h:15
fwlite::Run::size
Long64_t size() const
Definition: Run.cc:163
edm::poolNames::processHistoryBranchName
std::string const & processHistoryBranchName()
Definition: BranchType.cc:170
fwlite::DataGetterHelper::getByLabel
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *, Long_t) const
Definition: DataGetterHelper.cc:282
fwlite::Run::history
const edm::ProcessHistory & history() const
Definition: Run.cc:212
fwlite::Run::pOldAux_
edm::RunAux const * pOldAux_
Definition: Run.h:121
edm::Hash< ProcessHistoryType >
b
double b
Definition: hdecay.h:118
csv2json.runIndex
runIndex
Definition: csv2json.py:29
fwlite::Run::dataHelper_
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:125
fwlite::Run::historyMap_
edm::ProcessHistoryMap historyMap_
Definition: Run.h:116
fwlite::Run::atEnd
bool atEnd() const override
Definition: Run.cc:172
fwlite::Run::procHistoryNames_
std::vector< std::string > procHistoryNames_
Definition: Run.h:117
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:39
edm::RunAuxiliary::processHistoryID
ProcessHistoryID const & processHistoryID() const
Definition: RunAuxiliary.h:25
edm::ProcessHistoryVector
std::vector< ProcessHistory > ProcessHistoryVector
Definition: ProcessHistoryRegistry.h:16
edm::poolNames::processHistoryMapBranchName
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:167
edm::ProcessHistory::setProcessHistoryID
ProcessHistoryID setProcessHistoryID()
Definition: ProcessHistory.cc:27
fwlite::Run::isValid
bool isValid() const
Definition: Run.cc:165
BranchMapReader
edm::TypeID
Definition: TypeID.h:22
fwlite::DataGetterHelper::getBranchNameFor
virtual const std::string getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const
Definition: DataGetterHelper.cc:269
edm::poolNames::metaDataTreeName
std::string const & metaDataTreeName()
Definition: BranchType.cc:152
fwlite::Run::pAux_
edm::RunAuxiliary const * pAux_
Definition: Run.h:120
Exception
Definition: hltDiff.cc:246
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
fwlite::DataGetterHelper::getByProductID
edm::WrapperBase const * getByProductID(edm::ProductID const &pid, Long_t eventEntry) const
Definition: DataGetterHelper.cc:344
fwlite::Run::auxBranch_
TBranch * auxBranch_
Definition: Run.h:122
label
const char * label
Definition: PFTauDecayModeTools.cc:11
fwlite::Run::fileVersion_
int fileVersion_
Definition: Run.h:123