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
 
virtual bool getByLabel (std::type_info const &, char const *, char const *, char const *, edm::WrapperHolder &) const
 
edm::WrapperHolder getByProductID (edm::ProductID const &) const
 
bool isValid () const
 
 operator bool () const
 
const Runoperator++ ()
 
 Run (TFile *iFile)
 
 Run (boost::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_
 
boost::shared_ptr
< BranchMapReader
branchMap_
 
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 55 of file Run.h.

Constructor & Destructor Documentation

Run::Run ( TFile *  iFile)

Definition at line 44 of file Run.cc.

References auxBranch_, branchMap_, edm::BranchTypeToAuxiliaryBranchName(), edm::hlt::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  boost::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_ = boost::shared_ptr<edm::EDProductGetter>(new ProductGetter(this));
88 }
TBranch * auxBranch_
Definition: Run.h:128
edm::RunAuxiliary * pAux_
Definition: Run.h:126
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
int fileVersion_
Definition: Run.h:129
edm::RunAux * pOldAux_
Definition: Run.h:127
std::string const & runTreeName()
Definition: BranchType.cc:268
edm::RunAuxiliary aux_
Definition: Run.h:124
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:131
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
friend class RunHistoryGetter
Definition: Run.h:108
Run::Run ( boost::shared_ptr< BranchMapReader branchMap)

Definition at line 90 of file Run.cc.

References auxBranch_, branchMap_, edm::BranchTypeToAuxiliaryBranchName(), edm::hlt::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  boost::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_ = boost::shared_ptr<edm::EDProductGetter>(new ProductGetter(this));
133 }
TBranch * auxBranch_
Definition: Run.h:128
edm::RunAuxiliary * pAux_
Definition: Run.h:126
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
int fileVersion_
Definition: Run.h:129
edm::RunAux * pOldAux_
Definition: Run.h:127
std::string const & runTreeName()
Definition: BranchType.cc:268
edm::RunAuxiliary aux_
Definition: Run.h:124
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:131
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
friend class RunHistoryGetter
Definition: Run.h:108
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:127
std::vector< char const * > labels_
Definition: Run.h:121
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
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
Long64_t size() const
Definition: Run.cc:183
std::vector<edm::BranchDescription> const& fwlite::Run::getBranchDescriptions ( ) const
inline

Definition at line 93 of file Run.h.

References branchMap_.

93  {
94  return branchMap_->getBranchDescriptions();
95  }
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
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:131
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_, edm::hlt::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 }
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:131
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
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
bool Run::getByLabel ( std::type_info const &  iInfo,
char const *  iModuleLabel,
char const *  iProductInstanceLabel,
char const *  iProcessLabel,
edm::WrapperHolder holder 
) const
virtual

Implements fwlite::RunBase.

Definition at line 234 of file Run.cc.

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

238  {
239  if(atEnd()) {
240  throw cms::Exception("OffEnd") << "You have requested data past the last run";
241  }
242  Long_t runIndex = branchMap_->getRunEntry();
243  return dataHelper_.getByLabel(iInfo, iModuleLabel, iProductInstanceLabel, iProcessLabel, holder, runIndex);
244 }
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:131
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
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
edm::WrapperHolder Run::getByProductID ( edm::ProductID const &  iID) const

Definition at line 330 of file Run.cc.

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

331 {
332  Long_t runIndex = branchMap_->getRunEntry();
333  return dataHelper_.getByProductID(iID, runIndex);
334 }
fwlite::DataGetterHelper dataHelper_
Definition: Run.h:131
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
edm::WrapperHolder getByProductID(edm::ProductID const &, Long_t) const
const edm::ProcessHistory & Run::history ( ) const
private

Definition at line 267 of file Run.cc.

References aux_, b, branchMap_, edm::hlt::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().

268 {
269  edm::ProcessHistoryID processHistoryID;
270 
271  bool newFormat = false;//(fileVersion_ >= 5);
272 
273  Long_t runIndex = branchMap_->getRunEntry();
274  updateAux(runIndex);
275  if (!newFormat) {
276  processHistoryID = aux_.processHistoryID();
277  }
278 
279  if(historyMap_.empty() || newFormat) {
280  procHistoryNames_.clear();
281  TTree *meta = dynamic_cast<TTree*>(branchMap_->getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
282  if(0==meta) {
283  throw cms::Exception("NoMetaTree")<<"The TFile does not appear to contain a TTree named "
285  }
286  if (historyMap_.empty()) {
287  if (fileVersion_ < 11) {
289  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryMapBranchName().c_str());
290  b->SetAddress(&pPhm);
291  b->GetEntry(0);
292  } else {
293  edm::ProcessHistoryVector historyVector;
294  edm::ProcessHistoryVector* pPhv=&historyVector;
295  TBranch* b = meta->GetBranch(edm::poolNames::processHistoryBranchName().c_str());
296  b->SetAddress(&pPhv);
297  b->GetEntry(0);
298  for (auto& history : historyVector) {
299  historyMap_.insert(std::make_pair(history.setProcessHistoryID(), history));
300  }
301  }
302  }
303 // if (newFormat) {
304 // if (fileVersion_ >= 7) {
305 // edm::History history;
306 // edm::History* pHistory = &history;
307 // TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
308 // if (!eventHistoryBranch)
309 // throw edm::Exception(edm::errors::FatalRootError)
310 // << "Failed to find history branch in event history tree";
311 // eventHistoryBranch->SetAddress(&pHistory);
312 // eventHistoryTree_->GetEntry(runIndex);
313 // processHistoryID = history.processHistoryID();
314 // } else {
315 // std::vector<edm::EventProcessHistoryID> *pEventProcessHistoryIDs = &eventProcessHistoryIDs_;
316 // TBranch* b = meta->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
317 // b->SetAddress(&pEventProcessHistoryIDs);
318 // b->GetEntry(0);
319 // edm::EventProcessHistoryID target(aux_.id(), edm::ProcessHistoryID());
320 // processHistoryID = std::lower_bound(eventProcessHistoryIDs_.begin(), eventProcessHistoryIDs_.end(), target)->processHistoryID_;
321 // }
322 // }
323 
324  }
325  return historyMap_[processHistoryID];
326 }
std::vector< ProcessHistory > ProcessHistoryVector
void updateAux(Long_t runIndex) const
Definition: Run.cc:255
int fileVersion_
Definition: Run.h:129
ProcessHistoryID setProcessHistoryID()
std::string const & processHistoryMapBranchName()
Definition: BranchType.cc:192
std::vector< std::string > procHistoryNames_
Definition: Run.h:123
const edm::ProcessHistory & history() const
Definition: Run.cc:267
std::string const & metaDataTreeName()
Definition: BranchType.cc:167
std::string const & processHistoryBranchName()
Definition: BranchType.cc:197
edm::RunAuxiliary aux_
Definition: Run.h:124
double b
Definition: hdecay.h:120
ProcessHistoryID const & processHistoryID() const
Definition: RunAuxiliary.h:35
edm::ProcessHistoryMap historyMap_
Definition: Run.h:122
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
std::map< ProcessHistoryID, ProcessHistory > ProcessHistoryMap
bool Run::isValid ( void  ) const

Definition at line 189 of file Run.cc.

References branchMap_, and size().

190 {
191  Long_t runIndex = branchMap_->getRunEntry();
192  return runIndex!=-1 and runIndex < size();
193 }
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
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 }
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
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 247 of file Run.cc.

References aux_, branchMap_, and updateAux().

248 {
249  Long_t runIndex = branchMap_->getRunEntry();
250  updateAux(runIndex);
251  return aux_;
252 }
void updateAux(Long_t runIndex) const
Definition: Run.cc:255
edm::RunAuxiliary aux_
Definition: Run.h:124
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
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 }
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
void Run::throwProductNotFoundException ( std::type_info const &  iType,
char const *  iModule,
char const *  iProduct,
char const *  iProcess 
)
static

Definition at line 341 of file Run.cc.

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

342 {
343  edm::TypeID type(iType);
344  throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n type ='"<<type.className()<<"'\n module='"<<iModule
345  <<"'\n productInstance='"<<((0!=iProduct)?iProduct:"")<<"'\n process='"<<((0!=iProcess)?iProcess:"")<<"'\n"
346  "but no data is available for this Run";
347 }
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:125
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
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
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 }
boost::shared_ptr< BranchMapReader > branchMap_
Definition: Run.h:118
void Run::updateAux ( Long_t  runIndex) const
private

Definition at line 255 of file Run.cc.

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

Referenced by history(), and runAuxiliary().

256 {
257  if(auxBranch_->GetEntryNumber() != runIndex) {
258  auxBranch_->GetEntry(runIndex);
259  //handling dealing with old version
260  if(0 != pOldAux_) {
262  }
263  }
264 }
TBranch * auxBranch_
Definition: Run.h:128
edm::RunAux * pOldAux_
Definition: Run.h:127
edm::RunAuxiliary aux_
Definition: Run.h:124
void conversion(EventAux const &from, EventAuxiliary &to)
Definition: EventAux.cc:9

Friends And Related Function Documentation

friend class internal::ProductGetter
friend

Definition at line 107 of file Run.h.

friend class RunHistoryGetter
friend

Definition at line 108 of file Run.h.

Member Data Documentation

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

Definition at line 124 of file Run.h.

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

TBranch* fwlite::Run::auxBranch_
private

Definition at line 128 of file Run.h.

Referenced by Run(), and updateAux().

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

Definition at line 131 of file Run.h.

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

EntryFinder fwlite::Run::entryFinder_
mutableprivate

Definition at line 125 of file Run.h.

Referenced by to().

int fwlite::Run::fileVersion_
private

Definition at line 129 of file Run.h.

Referenced by history(), and Run().

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

Definition at line 122 of file Run.h.

Referenced by history().

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

Definition at line 121 of file Run.h.

Referenced by ~Run().

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

Definition at line 126 of file Run.h.

Referenced by Run().

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

Definition at line 127 of file Run.h.

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

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

Definition at line 123 of file Run.h.

Referenced by history().