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

virtual bool atEnd () const
 
std::vector< edm::BranchDescription > const & getBranchDescriptions () const
 
virtual std::string const getBranchNameFor (std::type_info const &, char const *, char const *, char const *) const
 
virtual bool getByLabel (std::type_info const &, char const *, char const *, char const *, void *) const
 
edm::WrapperBase const * getByProductID (edm::ProductID const &) const
 
bool isValid () const
 
 operator bool () const
 
const Runoperator++ ()
 
 Run (TFile *iFile)
 
 Run (std::shared_ptr< BranchMapReader > branchMap)
 
virtual edm::RunAuxiliary const & runAuxiliary () const
 
Long64_t size () const
 
bool to (edm::RunNumber_t run)
 Go to event by Run & Run number. More...
 
const RuntoBegin ()
 
virtual ~Run ()
 
- Public Member Functions inherited from fwlite::RunBase
virtual Long64_t fileIndex () const
 
 RunBase ()
 
virtual Long64_t secondaryFileIndex () const
 
virtual ~RunBase ()
 
- 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 &)
 
 Run (const Run &)
 
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 53 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().

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

Definition at line 90 of file Run.cc.

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

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

Definition at line 135 of file Run.cc.

References diffTwoXMLs::label, labels_, and pOldAux_.

136 {
137  for(auto const& label : labels_) {
138  delete [] label;
139  }
140  delete pOldAux_;
141 }
edm::RunAux const * pOldAux_
Definition: Run.h:124
std::vector< char const * > labels_
Definition: Run.h:118
fwlite::Run::Run ( const Run )
private

Member Function Documentation

bool Run::atEnd ( ) const
virtual

Implements fwlite::RunBase.

Definition at line 200 of file Run.cc.

References branchMap_, or, size(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getByLabel(), and main().

201 {
202  Long_t runIndex = branchMap_->getRunEntry();
203  return runIndex==-1 or runIndex == size();
204 }
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
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
Long64_t size() const
Definition: Run.cc:181
std::vector<edm::BranchDescription> const& fwlite::Run::getBranchDescriptions ( ) const
inline

Definition at line 90 of file Run.h.

References edm::throwProductNotFoundException().

90  {
91  return branchMap_->getBranchDescriptions();
92  }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
std::string const Run::getBranchNameFor ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessLabel 
) const
virtual

Definition at line 208 of file Run.cc.

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

212 {
213  return dataHelper_.getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
214 }
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:128
bool Run::getByLabel ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessLabel,
void *  oData 
) const
virtual

Implements fwlite::RunBase.

Definition at line 217 of file Run.cc.

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

Referenced by FWMagField::checkFieldInfo().

223 {
224  if(atEnd()) {
225  throw cms::Exception("OffEnd")<<"You have requested data past the last run";
226  }
227  Long_t runIndex = branchMap_->getRunEntry();
228  return dataHelper_.getByLabel(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel, oData, runIndex);
229 }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:128
virtual bool atEnd() const
Definition: Run.cc:200
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 315 of file Run.cc.

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

316 {
317  Long_t runIndex = branchMap_->getRunEntry();
318  return dataHelper_.getByProductID(iID, runIndex);
319 }
edm::WrapperBase const * getByProductID(edm::ProductID const &pid, Long_t eventEntry) const
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:128
const edm::ProcessHistory & Run::history ( ) const
private

Definition at line 252 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().

253 {
254  edm::ProcessHistoryID processHistoryID;
255 
256  bool newFormat = false;//(fileVersion_ >= 5);
257 
258  Long_t runIndex = branchMap_->getRunEntry();
259  updateAux(runIndex);
260  if (!newFormat) {
261  processHistoryID = aux_.processHistoryID();
262  }
263 
264  if(historyMap_.empty() || newFormat) {
265  procHistoryNames_.clear();
266  TTree *meta = dynamic_cast<TTree*>(branchMap_->getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
267  if(nullptr == meta) {
268  throw cms::Exception("NoMetaTree")<<"The TFile does not appear to contain a TTree named "
270  }
271  if (historyMap_.empty()) {
272  if (fileVersion_ < 11) {
274  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryMapBranchName().c_str());
275  b->SetAddress(&pPhm);
276  b->GetEntry(0);
277  } else {
278  edm::ProcessHistoryVector historyVector;
279  edm::ProcessHistoryVector* pPhv=&historyVector;
280  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryBranchName().c_str());
281  b->SetAddress(&pPhv);
282  b->GetEntry(0);
283  for (auto& history : historyVector) {
284  historyMap_.insert(std::make_pair(history.setProcessHistoryID(), history));
285  }
286  }
287  }
288 // if (newFormat) {
289 // if (fileVersion_ >= 7) {
290 // edm::History history;
291 // edm::History* pHistory = &history;
292 // TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
293 // if (!eventHistoryBranch)
294 // throw edm::Exception(edm::errors::FatalRootError)
295 // << "Failed to find history branch in event history tree";
296 // eventHistoryBranch->SetAddress(&pHistory);
297 // eventHistoryTree_->GetEntry(runIndex);
298 // processHistoryID = history.processHistoryID();
299 // } else {
300 // std::vector<edm::EventProcessHistoryID> *pEventProcessHistoryIDs = &eventProcessHistoryIDs_;
301 // TBranch* b = meta->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
302 // b->SetAddress(&pEventProcessHistoryIDs);
303 // b->GetEntry(0);
304 // edm::EventProcessHistoryID target(aux_.id(), edm::ProcessHistoryID());
305 // processHistoryID = std::lower_bound(eventProcessHistoryIDs_.begin(), eventProcessHistoryIDs_.end(), target)->processHistoryID_;
306 // }
307 // }
308 
309  }
310  return historyMap_[processHistoryID];
311 }
std::vector< ProcessHistory > ProcessHistoryVector
void updateAux(Long_t runIndex) const
Definition: Run.cc:240
int fileVersion_
Definition: Run.h:126
ProcessHistoryID setProcessHistoryID()
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:193
std::vector< std::string > procHistoryNames_
Definition: Run.h:120
const edm::ProcessHistory & history() const
Definition: Run.cc:252
std::string const & metaDataTreeName()
Definition: BranchType.cc:168
std::string const & processHistoryBranchName()
Definition: BranchType.cc:198
edm::RunAuxiliary aux_
Definition: Run.h:121
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
double b
Definition: hdecay.h:120
ProcessHistoryID const & processHistoryID() const
Definition: RunAuxiliary.h:35
edm::ProcessHistoryMap historyMap_
Definition: Run.h:119
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
bool Run::isValid ( void  ) const

Definition at line 187 of file Run.cc.

References branchMap_, and size().

Referenced by ntuple._Object::_checkIsValid(), operator bool(), and core.AutoHandle.AutoHandle::ReallyLoad().

188 {
189  Long_t runIndex = branchMap_->getRunEntry();
190  return runIndex!=-1 and runIndex < size();
191 }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
Long64_t size() const
Definition: Run.cc:181
Run::operator bool ( ) const

Definition at line 194 of file Run.cc.

References isValid().

195 {
196  return isValid();
197 }
bool isValid() const
Definition: Run.cc:187
const Run & Run::operator++ ( )
virtual

Implements fwlite::RunBase.

Definition at line 148 of file Run.cc.

References branchMap_, and size().

149 {
150  Long_t runIndex = branchMap_->getRunEntry();
151  if(runIndex < size())
152  {
153  branchMap_->updateRun(++runIndex);
154  }
155  return *this;
156 }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
Long64_t size() const
Definition: Run.cc:181
const Run& fwlite::Run::operator= ( const Run )
private
edm::RunAuxiliary const & Run::runAuxiliary ( ) const
virtual

Implements edm::RunBase.

Definition at line 232 of file Run.cc.

References aux_, branchMap_, and updateAux().

233 {
234  Long_t runIndex = branchMap_->getRunEntry();
235  updateAux(runIndex);
236  return aux_;
237 }
void updateAux(Long_t runIndex) const
Definition: Run.cc:240
edm::RunAuxiliary aux_
Definition: Run.h:121
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
Long64_t Run::size ( void  ) const

Definition at line 181 of file Run.cc.

References branchMap_.

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

182 {
183  return branchMap_->getRunTree()->GetEntries();
184 }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
void Run::throwProductNotFoundException ( std::type_info const &  iType,
char const *  iModule,
char const *  iProduct,
char const *  iProcess 
)
static

Definition at line 326 of file Run.cc.

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

327 {
328  edm::TypeID type(iType);
329  throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n type ='"<<type.className()<<"'\n module='"<<iModule
330  <<"'\n productInstance='"<<((nullptr != iProduct)?iProduct:"")<<"'\n process='"<<((nullptr != iProcess)?iProcess:"")<<"'\n"
331  "but no data is available for this Run";
332 }
type
Definition: HCALResponse.h:21
bool Run::to ( edm::RunNumber_t  run)

Go to event by Run & Run number.

Definition at line 160 of file Run.cc.

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

161 {
164  if (entry == EntryFinder::invalidEntry) {
165  return false;
166  }
167  return branchMap_->updateRun(entry);
168 }
RunNumber_t run() const
Definition: RunBase.h:40
EntryFinder entryFinder_
Definition: Run.h:122
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:108
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:39
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
const Run & Run::toBegin ( )
virtual

Implements fwlite::RunBase.

Definition at line 171 of file Run.cc.

References branchMap_.

Referenced by main().

172 {
173  branchMap_->updateRun(0);
174  return *this;
175 }
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:115
void Run::updateAux ( Long_t  runIndex) const
private

Definition at line 240 of file Run.cc.

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

Referenced by history(), and runAuxiliary().

241 {
242  if(auxBranch_->GetEntryNumber() != runIndex) {
243  auxBranch_->GetEntry(runIndex);
244  //handling dealing with old version
245  if(nullptr != pOldAux_) {
247  }
248  }
249 }
TBranch * auxBranch_
Definition: Run.h:125
edm::RunAux const * pOldAux_
Definition: Run.h:124
edm::RunAuxiliary aux_
Definition: Run.h:121
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9

Friends And Related Function Documentation

friend class internal::ProductGetter
friend

Definition at line 104 of file Run.h.

friend class RunHistoryGetter
friend

Definition at line 105 of file Run.h.

Member Data Documentation

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

Definition at line 121 of file Run.h.

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

TBranch* fwlite::Run::auxBranch_
private

Definition at line 125 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 128 of file Run.h.

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

EntryFinder fwlite::Run::entryFinder_
mutableprivate

Definition at line 122 of file Run.h.

Referenced by to().

int fwlite::Run::fileVersion_
private

Definition at line 126 of file Run.h.

Referenced by history(), and Run().

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

Definition at line 119 of file Run.h.

Referenced by history().

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

Definition at line 118 of file Run.h.

Referenced by ~Run().

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

Definition at line 123 of file Run.h.

Referenced by Run().

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

Definition at line 124 of file Run.h.

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

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

Definition at line 120 of file Run.h.

Referenced by history().