CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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

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::RunAuxiliarypAux_
 
edm::RunAuxpOldAux_
 
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().

44  :
45  branchMap_(new BranchMapReader(iFile)),
46  pAux_(&aux_),
47  pOldAux_(0),
48  fileVersion_(-1),
49  dataHelper_(branchMap_->getRunTree(),
50  std::shared_ptr<HistoryGetterBase>(new RunHistoryGetter(this)),
51  branchMap_)
52  {
53  if(0==iFile) {
54  throw cms::Exception("NoFile")<<"The TFile pointer passed to the constructor was null";
55  }
56 
57  if(0==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(0==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(0==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::shared_ptr<edm::EDProductGetter>(new ProductGetter(this));
88 }
TBranch * auxBranch_
Definition: Run.h:126
edm::RunAuxiliary * pAux_
Definition: Run.h:124
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:115
int fileVersion_
Definition: Run.h:127
edm::RunAux * pOldAux_
Definition: Run.h:125
std::string const & runTreeName()
Definition: BranchType.cc:274
edm::RunAuxiliary aux_
Definition: Run.h:122
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:116
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:129
friend class RunHistoryGetter
Definition: Run.h:106
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_(0),
94  fileVersion_(-1),
95  dataHelper_(branchMap_->getRunTree(),
96  std::shared_ptr<HistoryGetterBase>(new RunHistoryGetter(this)),
97  branchMap_)
98  {
99  if(0==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(0==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(0==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::shared_ptr<edm::EDProductGetter>(new ProductGetter(this));
133 }
TBranch * auxBranch_
Definition: Run.h:126
edm::RunAuxiliary * pAux_
Definition: Run.h:124
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:115
int fileVersion_
Definition: Run.h:127
edm::RunAux * pOldAux_
Definition: Run.h:125
std::string const & runTreeName()
Definition: BranchType.cc:274
edm::RunAuxiliary aux_
Definition: Run.h:122
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:116
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:129
friend class RunHistoryGetter
Definition: Run.h:106
Run::~Run ( )
virtual

Definition at line 135 of file Run.cc.

References labels_, and pOldAux_.

136 {
137  for(std::vector<char const*>::iterator it = labels_.begin(), itEnd=labels_.end();
138  it != itEnd;
139  ++it) {
140  delete [] *it;
141  }
142  delete pOldAux_;
143 }
edm::RunAux * pOldAux_
Definition: Run.h:125
std::vector< char const * > labels_
Definition: Run.h:119
fwlite::Run::Run ( const Run )
private

Member Function Documentation

bool Run::atEnd ( ) const
virtual

Implements fwlite::RunBase.

Definition at line 202 of file Run.cc.

References branchMap_, or, and size().

Referenced by getByLabel(), and main().

203 {
204  Long_t runIndex = branchMap_->getRunEntry();
205  return runIndex==-1 or runIndex == size();
206 }
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:116
Long64_t size() const
Definition: Run.cc:183
std::vector<edm::BranchDescription> const& fwlite::Run::getBranchDescriptions ( ) const
inline

Definition at line 91 of file Run.h.

References branchMap_.

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

Definition at line 210 of file Run.cc.

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

214 {
215  return dataHelper_.getBranchNameFor(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel);
216 }
virtual std::string const getBranchNameFor(std::type_info const &, char const *, char const *, char const *) const
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:129
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 219 of file Run.cc.

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

Referenced by FWMagField::checkFieldInfo().

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

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

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

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

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

Definition at line 189 of file Run.cc.

References branchMap_, and size().

Referenced by core.AutoHandle.AutoHandle::ReallyLoad().

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

Definition at line 196 of file Run.cc.

197 {
198  return isValid();
199 }
bool isValid() const
Definition: Run.cc:189
const Run & Run::operator++ ( )
virtual

Implements fwlite::RunBase.

Definition at line 150 of file Run.cc.

References branchMap_, and size().

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

Implements edm::RunBase.

Definition at line 234 of file Run.cc.

References aux_, branchMap_, and updateAux().

235 {
236  Long_t runIndex = branchMap_->getRunEntry();
237  updateAux(runIndex);
238  return aux_;
239 }
void updateAux(Long_t runIndex) const
Definition: Run.cc:242
edm::RunAuxiliary aux_
Definition: Run.h:122
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:116
Long64_t Run::size ( void  ) const

Definition at line 183 of file Run.cc.

References branchMap_.

Referenced by atEnd(), isValid(), and operator++().

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

Definition at line 328 of file Run.cc.

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

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

Go to event by Run & Run number.

Definition at line 162 of file Run.cc.

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

163 {
166  if (entry == EntryFinder::invalidEntry) {
167  return false;
168  }
169  return branchMap_->updateRun(entry);
170 }
RunNumber_t run() const
Definition: RunBase.h:42
EntryFinder entryFinder_
Definition: Run.h:123
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:34
void fillIndex(BranchMapReader const &branchMap)
Definition: EntryFinder.cc:108
EntryNumber_t findRun(edm::RunNumber_t const &run) const
Definition: EntryFinder.cc:91
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:40
std::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:116
const Run & Run::toBegin ( )
virtual

Implements fwlite::RunBase.

Definition at line 173 of file Run.cc.

References branchMap_.

Referenced by main().

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

Definition at line 242 of file Run.cc.

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

Referenced by history(), and runAuxiliary().

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

Friends And Related Function Documentation

friend class internal::ProductGetter
friend

Definition at line 105 of file Run.h.

friend class RunHistoryGetter
friend

Definition at line 106 of file Run.h.

Member Data Documentation

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

Definition at line 122 of file Run.h.

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

TBranch* fwlite::Run::auxBranch_
private

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

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

EntryFinder fwlite::Run::entryFinder_
mutableprivate

Definition at line 123 of file Run.h.

Referenced by to().

int fwlite::Run::fileVersion_
private

Definition at line 127 of file Run.h.

Referenced by history(), and Run().

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

Definition at line 120 of file Run.h.

Referenced by history().

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

Definition at line 119 of file Run.h.

Referenced by ~Run().

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

Definition at line 124 of file Run.h.

Referenced by Run().

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

Definition at line 125 of file Run.h.

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

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

Definition at line 121 of file Run.h.

Referenced by history().