CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FileIndex.cc
Go to the documentation of this file.
3 
4 #include <algorithm>
5 #include <ostream>
6 #include <iomanip>
7 
8 namespace edm {
9 
10  FileIndex::FileIndex() : entries_(), transients_() {}
11 
12  // The default value for sortState_ reflects the fact that
13  // the index is always sorted using Run, Lumi, and Event
14  // number by the PoolOutputModule before being written out.
15  // In the other case when we create a new FileIndex, the
16  // vector is empty, which is consistent with it having been
17  // sorted.
18 
19  FileIndex::Transients::Transients() : allInEntryOrder_(false), resultCached_(false), sortState_(kSorted_Run_Lumi_Event) {}
20 
21  void
23  entries_.push_back(FileIndex::Element(run, lumi, event, entry));
24  resultCached() = false;
26  }
27 
30  resultCached() = false;
32  }
33 
36  resultCached() = false;
38  }
39 
41  if(!resultCached()) {
42  resultCached() = true;
44  for(std::vector<FileIndex::Element>::const_iterator it = entries_.begin(), itEnd = entries_.end(); it != itEnd; ++it) {
45  if(it->getEntryType() == kEvent) {
46  if(it->entry_ < maxEntry) {
47  allInEntryOrder() = false;
48  return false;
49  }
50  maxEntry = it->entry_;
51  }
52  }
53  allInEntryOrder() = true;
54  return true;
55  }
56  return allInEntryOrder();
57  }
58 
61  assert(sortState() != kNotSorted);
62 
63  const_iterator itEnd = entries_.end();
64  const_iterator it;
65  Element el(run, lumi, event);
67  it = lower_bound_all(entries_, el);
68  bool lumiMissing = (lumi == 0 && event != 0);
69  if(lumiMissing) {
70  while(it != itEnd && it->run_ < run) {
71  ++it;
72  }
73  while(it != itEnd && (it->run_ == run && it->event_ < event)) {
74  ++it;
75  }
76  }
77  } else {
79  }
80 
81  return it;
82  }
83 
86 
87  const_iterator it = findPosition(run, lumi, event);
88  const_iterator itEnd = entries_.end();
89  while(it != itEnd && it->getEntryType() != FileIndex::kEvent) {
90  ++it;
91  }
92  if(it == itEnd) {
93  return itEnd;
94  }
95  if(lumi == 0) {
96  lumi = it->lumi_;
97  }
98  if(it->run_ != run || it->lumi_ != lumi || it->event_ != event) {
100  return itEnd;
101  }
102  // not sorted by event, so we need to do a linear search
103  while (it != itEnd && it->run_ == run && it->lumi_ == lumi && it->event_ != event) {
104  ++it;
105  }
106  if(it->run_ != run || it->lumi_ != lumi || it->event_ != event) {
107  return itEnd;
108  }
109  }
110  return it;
111  }
112 
115  const_iterator it = findPosition(run, lumi, 0U);
116  const_iterator itEnd = entries_.end();
117  while(it != itEnd && it->getEntryType() != FileIndex::kLumi) {
118  ++it;
119  }
120  if(it == itEnd) {
121  return itEnd;
122  }
123  if(it->run_ != run || it->lumi_ != lumi) {
124  return itEnd;
125  }
126  return it;
127  }
128 
131  const_iterator it = findPosition(run, 0U, 0U);
132  const_iterator itEnd = entries_.end();
133  while(it != itEnd && it->getEntryType() != FileIndex::kRun) {
134  ++it;
135  }
136  if(it == itEnd) {
137  return itEnd;
138  }
139  if(it->run_ != run) {
140  return itEnd;
141  }
142  return it;
143  }
144 
147  const_iterator it = findPosition(run, lumi, 0U);
148  const_iterator itEnd = entries_.end();
149  while(it != itEnd && it->getEntryType() != FileIndex::kLumi && it->getEntryType() != FileIndex::kRun) {
150  ++it;
151  }
152  return it;
153  }
154 
157  assert(sortState() != kNotSorted);
158  const_iterator it;
159  const_iterator itEnd = entries_.end();
161  assert(lumi != 0U);
162  Element el(run, lumi, event, entry);
164  } else {
165  it = findEventPosition(run, lumi, event);
166  while(it != itEnd && it->entry_ != entry && it->event_ == event) {
167  ++it;
168  }
169  }
170  if(it == itEnd) return itEnd;
171  if(lumi == 0) lumi = it->lumi_;
172  if(it->run_ != run || it->lumi_ != lumi || it->event_ != event || it->entry_ != entry) return itEnd;
173  return it;
174  }
175 
177  if(lh.run_ == rh.run_) {
178  if(lh.lumi_ == rh.lumi_) {
179  return lh.event_ < rh.event_;
180  }
181  return lh.lumi_ < rh.lumi_;
182  }
183  return lh.run_ < rh.run_;
184  }
185 
187  if(lh.run_ == rh.run_) {
188  if(lh.lumi_ == rh.lumi_) {
189  if(lh.event_ == 0U && rh.event_ == 0U) {
190  return false;
191  } else if(lh.event_ == 0U) {
192  return true;
193  } else if(rh.event_ == 0U) {
194  return false;
195  } else {
196  return lh.entry_ < rh.entry_;
197  }
198  }
199  return lh.lumi_ < rh.lumi_;
200  }
201  return lh.run_ < rh.run_;
202  }
203 
204  std::ostream&
205  operator<<(std::ostream& os, FileIndex const& fileIndex) {
206 
207  os << "\nPrinting FileIndex contents. This includes a list of all Runs, LuminosityBlocks\n"
208  << "and Events stored in the root file.\n\n";
209  os << std::setw(15) << "Run"
210  << std::setw(15) << "Lumi"
211  << std::setw(15) << "Event"
212  << std::setw(15) << "TTree Entry"
213  << "\n";
214  for(std::vector<FileIndex::Element>::const_iterator it = fileIndex.begin(), itEnd = fileIndex.end(); it != itEnd; ++it) {
215  if(it->getEntryType() == FileIndex::kEvent) {
216  os << std::setw(15) << it->run_
217  << std::setw(15) << it ->lumi_
218  << std::setw(15) << it->event_
219  << std::setw(15) << it->entry_
220  << "\n";
221  }
222  else if(it->getEntryType() == FileIndex::kLumi) {
223  os << std::setw(15) << it->run_
224  << std::setw(15) << it ->lumi_
225  << std::setw(15) << " "
226  << std::setw(15) << it->entry_ << " (LuminosityBlock)"
227  << "\n";
228  }
229  else if(it->getEntryType() == FileIndex::kRun) {
230  os << std::setw(15) << it->run_
231  << std::setw(15) << " "
232  << std::setw(15) << " "
233  << std::setw(15) << it->entry_ << " (Run)"
234  << "\n";
235  }
236  }
237  return os;
238  }
239 }
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:89
const_iterator findEventEntryPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry) const
Definition: FileIndex.cc:156
ForwardSequence::const_iterator lower_bound_all(ForwardSequence const &s, Datum const &d)
wrappers for std::lower_bound
Definition: Algorithms.h:91
bool & allInEntryOrder() const
Definition: FileIndex.h:127
unsigned int EventNumber_t
Definition: EventID.h:30
bool operator()(FileIndex::Element const &lh, FileIndex::Element const &rh)
Definition: FileIndex.cc:186
tuple lumi
Definition: fjr2json.py:41
SortState & sortState() const
Definition: FileIndex.h:129
bool int lh
Definition: SSEVec.h:37
void stable_sort_all(RandomAccessSequence &s)
wrappers for std::stable_sort
Definition: Algorithms.h:135
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
void sortBy_Run_Lumi_EventEntry()
Definition: FileIndex.cc:34
EntryNumber_t entry_
Definition: FileIndex.h:50
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:53
bool allEventsInEntryOrder() const
Definition: FileIndex.cc:40
static EntryNumber_t const invalidEntry
Definition: FileIndex.h:34
long long EntryNumber_t
Definition: FileIndex.h:23
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:85
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:130
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
const_iterator end() const
Definition: FileIndex.h:100
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
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:114
LuminosityBlockNumber_t lumi_
Definition: FileIndex.h:48
const_iterator findLumiOrRunPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:146
std::vector< Element > entries_
Definition: FileIndex.h:131
void sortBy_Run_Lumi_Event()
Definition: FileIndex.cc:28
void addEntry(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
Definition: FileIndex.cc:22
const_iterator findPosition(RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
Definition: FileIndex.cc:60
bool & resultCached() const
Definition: FileIndex.h:128
const_iterator begin() const
Definition: FileIndex.h:98
unsigned int RunNumber_t
Definition: EventRange.h:32
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
EventNumber_t event_
Definition: FileIndex.h:49