CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 std::string const 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
 
const Runoperator= (const Run &)=delete
 
 Run (TFile *iFile)
 
 Run (std::shared_ptr< BranchMapReader > branchMap)
 
 Run (const Run &)=delete
 
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
 
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::Run ( TFile *  iFile)

Definition at line 44 of file Run.cc.

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

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  }
edm::RunAuxiliary const * pAux_
Definition: Run.h:119
TBranch * auxBranch_
Definition: Run.h:121
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
int fileVersion_
Definition: Run.h:122
std::string const & runTreeName()
Definition: BranchType.cc:226
edm::RunAux const * pOldAux_
Definition: Run.h:120
edm::RunAuxiliary aux_
Definition: Run.h:117
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:124
Run::Run ( std::shared_ptr< BranchMapReader branchMap)

Definition at line 86 of file Run.cc.

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

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  }
edm::RunAuxiliary const * pAux_
Definition: Run.h:119
TBranch * auxBranch_
Definition: Run.h:121
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
int fileVersion_
Definition: Run.h:122
std::string const & runTreeName()
Definition: BranchType.cc:226
edm::RunAux const * pOldAux_
Definition: Run.h:120
edm::RunAuxiliary aux_
Definition: Run.h:117
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:124
fwlite::Run::Run ( const Run )
delete
Run::~Run ( )
override

Definition at line 127 of file Run.cc.

References label, labels_, and pOldAux_.

127  {
128  for (auto const& label : labels_) {
129  delete[] label;
130  }
131  delete pOldAux_;
132  }
char const * label
edm::RunAux const * pOldAux_
Definition: Run.h:120
std::vector< char const * > labels_
Definition: Run.h:114

Member Function Documentation

bool Run::atEnd ( ) const
overridevirtual

Implements fwlite::RunBase.

Definition at line 172 of file Run.cc.

References branchMap_, or, and size().

Referenced by getByLabel(), and main().

172  {
173  Long_t runIndex = branchMap_->getRunEntry();
174  return runIndex == -1 or runIndex == size();
175  }
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
Long64_t size() const
Definition: Run.cc:163
std::vector<edm::BranchDescription> const& fwlite::Run::getBranchDescriptions ( ) const
inline

Definition at line 89 of file Run.h.

References branchMap_.

89  {
90  return branchMap_->getBranchDescriptions();
91  }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
std::string const 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.

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

180  {
181  return dataHelper_.getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
182  }
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:124
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.

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

Referenced by FWMagField::checkFieldInfo().

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  }
bool atEnd() const override
Definition: Run.cc:172
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:124
virtual bool getByLabel(std::type_info const &, char const *, char const *, char const *, void *, Long_t) const
edm::WrapperBase const * Run::getByProductID ( edm::ProductID const &  iID) const

Definition at line 271 of file Run.cc.

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

271  {
272  Long_t runIndex = branchMap_->getRunEntry();
273  return dataHelper_.getByProductID(iID, runIndex);
274  }
edm::WrapperBase const * getByProductID(edm::ProductID const &pid, Long_t eventEntry) const
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:124
const edm::ProcessHistory & Run::history ( ) const
private

Definition at line 212 of file Run.cc.

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

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

212  {
213  edm::ProcessHistoryID processHistoryID;
214 
215  bool newFormat = false; //(fileVersion_ >= 5);
216 
217  Long_t runIndex = branchMap_->getRunEntry();
218  updateAux(runIndex);
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  }
std::vector< ProcessHistory > ProcessHistoryVector
void updateAux(Long_t runIndex) const
Definition: Run.cc:202
int fileVersion_
Definition: Run.h:122
ProcessHistoryID setProcessHistoryID()
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:174
std::vector< std::string > procHistoryNames_
Definition: Run.h:116
const edm::ProcessHistory & history() const
Definition: Run.cc:212
std::string const & metaDataTreeName()
Definition: BranchType.cc:159
std::string const & processHistoryBranchName()
Definition: BranchType.cc:177
edm::RunAuxiliary aux_
Definition: Run.h:117
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
double b
Definition: hdecay.h:118
ProcessHistoryID const & processHistoryID() const
Definition: RunAuxiliary.h:25
edm::ProcessHistoryMap historyMap_
Definition: Run.h:115
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
bool Run::isValid ( void  ) const

Definition at line 165 of file Run.cc.

References branchMap_, and size().

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

165  {
166  Long_t runIndex = branchMap_->getRunEntry();
167  return runIndex != -1 and runIndex < size();
168  }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
Long64_t size() const
Definition: Run.cc:163
Run::operator bool ( ) const

Definition at line 170 of file Run.cc.

References sistrip::SpyUtilities::isValid().

170 { return isValid(); }
bool isValid() const
Definition: Run.cc:165
const Run & Run::operator++ ( )
overridevirtual

Implements fwlite::RunBase.

Definition at line 138 of file Run.cc.

References branchMap_, and size().

138  {
139  Long_t runIndex = branchMap_->getRunEntry();
140  if (runIndex < size()) {
141  branchMap_->updateRun(++runIndex);
142  }
143  return *this;
144  }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
Long64_t size() const
Definition: Run.cc:163
const Run& fwlite::Run::operator= ( const Run )
delete
edm::RunAuxiliary const & Run::runAuxiliary ( ) const
overridevirtual

Implements edm::RunBase.

Definition at line 196 of file Run.cc.

References aux_, branchMap_, and updateAux().

196  {
197  Long_t runIndex = branchMap_->getRunEntry();
198  updateAux(runIndex);
199  return aux_;
200  }
void updateAux(Long_t runIndex) const
Definition: Run.cc:202
edm::RunAuxiliary aux_
Definition: Run.h:117
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
Long64_t Run::size ( void  ) const

Definition at line 163 of file Run.cc.

References branchMap_.

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

163 { return branchMap_->getRunTree()->GetEntries(); }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
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.

References edm::TypeID::className(), Exception, and edm::errors::ProductNotFound.

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  }
bool Run::to ( edm::RunNumber_t  run)

Go to event by Run & Run number.

Definition at line 146 of file Run.cc.

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

146  {
149  if (entry == EntryFinder::invalidEntry) {
150  return false;
151  }
152  return branchMap_->updateRun(entry);
153  }
RunNumber_t run() const
Definition: RunBase.h:40
EntryFinder entryFinder_
Definition: Run.h:118
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
EntryNumber_t findRun(edm::RunNumber_t const &run) const
Definition: EntryFinder.cc:91
void fillIndex(BranchMapReader &branchMap)
Definition: EntryFinder.cc:107
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:41
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
list entry
Definition: mps_splice.py:68
const Run & Run::toBegin ( )
overridevirtual

Implements fwlite::RunBase.

Definition at line 155 of file Run.cc.

References branchMap_.

Referenced by main().

155  {
156  branchMap_->updateRun(0);
157  return *this;
158  }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:111
void Run::updateAux ( Long_t  runIndex) const
private

Definition at line 202 of file Run.cc.

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

Referenced by history(), and runAuxiliary().

202  {
203  if (auxBranch_->GetEntryNumber() != runIndex) {
204  auxBranch_->GetEntry(runIndex);
205  //handling dealing with old version
206  if (nullptr != pOldAux_) {
208  }
209  }
210  }
TBranch * auxBranch_
Definition: Run.h:121
edm::RunAux const * pOldAux_
Definition: Run.h:120
edm::RunAuxiliary aux_
Definition: Run.h:117
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9

Friends And Related Function Documentation

friend class internal::ProductGetter
friend

Definition at line 103 of file Run.h.

friend class RunHistoryGetter
friend

Definition at line 104 of file Run.h.

Member Data Documentation

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

Definition at line 117 of file Run.h.

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

TBranch* fwlite::Run::auxBranch_
private

Definition at line 121 of file Run.h.

Referenced by Run(), and updateAux().

std::shared_ptr<BranchMapReader> fwlite::Run::branchMap_
mutableprivate
fwlite::DataGetterHelper fwlite::Run::dataHelper_
private

Definition at line 124 of file Run.h.

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

EntryFinder fwlite::Run::entryFinder_
mutableprivate

Definition at line 118 of file Run.h.

Referenced by to().

int fwlite::Run::fileVersion_
private

Definition at line 122 of file Run.h.

Referenced by history(), and Run().

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

Definition at line 115 of file Run.h.

Referenced by history().

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

Definition at line 114 of file Run.h.

Referenced by ~Run().

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

Definition at line 119 of file Run.h.

Referenced by Run().

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

Definition at line 120 of file Run.h.

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

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

Definition at line 116 of file Run.h.

Referenced by history().