CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EntryFinder.cc
Go to the documentation of this file.
1 
2 /*
3 // -*- C++ -*-
4 //
5 // Package: FWLite/DataFormats
6 // Class : Index
7 //
8 
9  Description: <one line class summary>
10 
11  Usage:
12  <usage>
13 
14 */
15 //
16 // Original Author: Bill Tanenbaum
17 //
18 
19 // user include files
24 
25 #include "TBranch.h"
26 #include "TFile.h"
27 #include "TTree.h"
28 
29 // forward declarations
30 
31 namespace fwlite {
32 
33  // This is a helper class for IndexIntoFile.
35  public:
36  explicit FWLiteEventFinder(TBranch* auxBranch) : auxBranch_(auxBranch) {}
37  virtual ~FWLiteEventFinder() {}
38  virtual
40  void* saveAddress = auxBranch_->GetAddress();
41  edm::EventAuxiliary eventAux;
42  edm::EventAuxiliary *pEvAux = &eventAux;
43  auxBranch_->SetAddress(&pEvAux);
44  auxBranch_->GetEntry(entry);
45  auxBranch_->SetAddress(saveAddress);
46  return eventAux.event();
47  }
48 
49  private:
50  TBranch* auxBranch_;
51  };
52 
53  EntryFinder::EntryFinder() : indexIntoFile_(), fileIndex_() {}
55 
59  if (!indexIntoFile_.empty()) {
62  ret = i.entry();
63  }
64  } else {
66  if (fileIndex_.end() != i) {
67  ret = i->entry_;
68  }
69  }
70  return ret;
71  }
72 
76  if (!indexIntoFile_.empty()) {
79  ret = i.entry();
80  }
81  } else {
83  if (fileIndex_.end() != i) {
84  ret = i->entry_;
85  }
86  }
87  return ret;
88  }
89 
93  if (!indexIntoFile_.empty()) {
96  ret = i.entry();
97  }
98  } else {
100  if (fileIndex_.end() != i) {
101  ret = i->entry_;
102  }
103  }
104  return ret;
105  }
106 
107  void
109  if (empty()) {
110  TTree* meta = dynamic_cast<TTree*>(branchMap.getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
111  if (0 == meta) {
112  throw cms::Exception("NoMetaTree") << "The TFile does not contain a TTree named "
114  }
115  if (meta->FindBranch(edm::poolNames::indexIntoFileBranchName().c_str()) != 0) {
116  edm::IndexIntoFile* indexPtr = &indexIntoFile_;
117  TBranch* b = meta->GetBranch(edm::poolNames::indexIntoFileBranchName().c_str());
118  b->SetAddress(&indexPtr);
119  b->GetEntry(0);
120  TTree* eventTree = branchMap.getEventTree();
121  TBranch* auxBranch = eventTree->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
122  if(0 == auxBranch) {
123  throw cms::Exception("NoEventAuxilliary") << "The TTree "
125  << " does not contain a branch named 'EventAuxiliary'";
126  }
127 
128  indexIntoFile_.setNumberOfEvents(auxBranch->GetEntries());
129  indexIntoFile_.setEventFinder(boost::shared_ptr<edm::IndexIntoFile::EventFinder>(new FWLiteEventFinder(auxBranch)));
130 
131  } else if (meta->FindBranch(edm::poolNames::fileIndexBranchName().c_str()) != 0) {
132  edm::FileIndex* findexPtr = &fileIndex_;
133  TBranch* b = meta->GetBranch(edm::poolNames::fileIndexBranchName().c_str());
134  b->SetAddress(&findexPtr);
135  b->GetEntry(0);
136  } else {
137  // TBD: fill the FileIndex for old file formats (prior to CMSSW 2_0_0)
138  throw cms::Exception("NoIndexBranch") << "The TFile does not contain a TBranch named " <<
140  }
141  }
142  assert(!empty());
143  }
144 }
int i
Definition: DBlmapReader.cc:9
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
unsigned int EventNumber_t
Definition: EventID.h:30
FWLiteEventFinder(TBranch *auxBranch)
Definition: EntryFinder.cc:36
tuple lumi
Definition: fjr2json.py:35
bool empty() const
True if no runs, lumis, or events are in the file.
TFile * getFile() const
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:42
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.
EntryNumber_t findEvent(edm::RunNumber_t const &run, edm::LuminosityBlockNumber_t const &lumi, edm::EventNumber_t const &event) const
Definition: EntryFinder.cc:57
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:53
virtual edm::EventNumber_t getEventNumberOfEntry(long long entry) const
Definition: EntryFinder.cc:39
TTree * getEventTree() const
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
std::string const & fileIndexBranchName()
Definition: BranchType.cc:222
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:34
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:136
std::string const & indexIntoFileBranchName()
Definition: BranchType.cc:227
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
const_iterator end() const
Definition: FileIndex.h:100
void fillIndex(BranchMapReader const &branchMap)
Definition: EntryFinder.cc:108
std::string const & metaDataTreeName()
Definition: BranchType.cc:167
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
EntryNumber_t findRun(edm::RunNumber_t const &run) const
Definition: EntryFinder.cc:91
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:40
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:120
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool empty() const
Definition: EntryFinder.h:35
double b
Definition: hdecay.h:120
void setEventFinder(boost::shared_ptr< EventFinder > ptr) const
edm::FileIndex fileIndex_
Definition: EntryFinder.h:43
void setNumberOfEvents(EntryNumber_t nevents) const
std::string const & eventTreeName()
Definition: BranchType.cc:254
unsigned int RunNumber_t
Definition: EventRange.h:32
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
EventNumber_t event() const
EntryNumber_t findLumi(edm::RunNumber_t const &run, edm::LuminosityBlockNumber_t const &lumi) const
Definition: EntryFinder.cc:74