CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
edm::eventsetup::DependentRecordIntervalFinder Class Reference

#include <DependentRecordIntervalFinder.h>

Inheritance diagram for edm::eventsetup::DependentRecordIntervalFinder:
edm::EventSetupRecordIntervalFinder

Public Member Functions

void addProviderWeAreDependentOn (std::shared_ptr< EventSetupRecordProvider >)
 
 DependentRecordIntervalFinder (const EventSetupRecordKey &)
 
bool haveProviders () const
 
void setAlternateFinder (std::shared_ptr< EventSetupRecordIntervalFinder >)
 
 ~DependentRecordIntervalFinder () override
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 

Protected Member Functions

void setIntervalFor (const EventSetupRecordKey &, const IOVSyncValue &, ValidityInterval &) override
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 

Private Types

typedef std::vector< edm::propagate_const< std::shared_ptr< EventSetupRecordProvider > > > Providers
 

Private Member Functions

 DependentRecordIntervalFinder (const DependentRecordIntervalFinder &)=delete
 
const DependentRecordIntervalFinderoperator= (const DependentRecordIntervalFinder &)=delete
 

Private Attributes

edm::propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > alternate_
 
std::vector< ValidityIntervalpreviousIOVs_
 
Providers providers_
 

Detailed Description

Definition at line 36 of file DependentRecordIntervalFinder.h.

Member Typedef Documentation

Definition at line 60 of file DependentRecordIntervalFinder.h.

Constructor & Destructor Documentation

DependentRecordIntervalFinder::DependentRecordIntervalFinder ( const EventSetupRecordKey iKey)
DependentRecordIntervalFinder::~DependentRecordIntervalFinder ( )
override

Definition at line 41 of file DependentRecordIntervalFinder.cc.

41 {}
edm::eventsetup::DependentRecordIntervalFinder::DependentRecordIntervalFinder ( const DependentRecordIntervalFinder )
privatedelete

Member Function Documentation

void DependentRecordIntervalFinder::addProviderWeAreDependentOn ( std::shared_ptr< EventSetupRecordProvider iProvider)

Definition at line 58 of file DependentRecordIntervalFinder.cc.

References providers_.

Referenced by haveProviders().

59  {
60  providers_.push_back(iProvider);
61  }
bool edm::eventsetup::DependentRecordIntervalFinder::haveProviders ( ) const
inline
const DependentRecordIntervalFinder& edm::eventsetup::DependentRecordIntervalFinder::operator= ( const DependentRecordIntervalFinder )
privatedelete

Referenced by haveProviders().

void DependentRecordIntervalFinder::setAlternateFinder ( std::shared_ptr< EventSetupRecordIntervalFinder iOther)

Definition at line 63 of file DependentRecordIntervalFinder.cc.

References alternate_.

Referenced by haveProviders().

63  {
64  alternate_ = iOther;
65  }
edm::propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > alternate_
void DependentRecordIntervalFinder::setIntervalFor ( const EventSetupRecordKey iKey,
const IOVSyncValue iTime,
ValidityInterval oInterval 
)
overrideprotectedvirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 67 of file DependentRecordIntervalFinder.cc.

References alternate_, edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::comparable(), edm::IOVSyncValue::endOfTime(), edm::IOVSyncValue::eventID(), edm::ValidityInterval::first(), edm::ValidityInterval::invalidInterval(), edm::IOVSyncValue::invalidIOVSyncValue(), edm::ValidityInterval::last(), edm::EventID::luminosityBlock(), previousIOVs_, providers_, edm::EventID::run(), edm::ValidityInterval::setFirst(), edm::ValidityInterval::setLast(), PFTauMVAInputDiscriminatorTranslator_cfi::test, edm::IOVSyncValue::time(), tmp, edm::Timestamp::unixTime(), and edm::Timestamp::value().

Referenced by haveProviders().

69  {
70  //NOTE: oInterval is the last value that was used so if nothing changed do not modify oInterval
71 
72  //I am assuming that an invalidTime is always less then the first valid time
74  if (providers_.empty() && alternate_.get() == nullptr) {
76  return;
77  }
78  bool haveAValidDependentRecord = false;
79  bool allRecordsValid = true;
81 
82  if (alternate_.get() != nullptr) {
83  ValidityInterval test = alternate_->findIntervalFor(iKey, iTime);
84  if (test != ValidityInterval::invalidInterval()) {
85  haveAValidDependentRecord = true;
86  newInterval = test;
87  }
88  }
89  bool intervalsWereComparible = true;
90  for (Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
91  itProvider != itProviderEnd;
92  ++itProvider) {
93  if ((*itProvider)->setValidityIntervalFor(iTime)) {
94  haveAValidDependentRecord = true;
95  ValidityInterval providerInterval = (*itProvider)->validityInterval();
96  if ((!newInterval.first().comparable(providerInterval.first())) ||
97  (!newInterval.last().comparable(providerInterval.last()))) {
98  intervalsWereComparible = false;
99  break;
100  }
101  if (newInterval.first() < providerInterval.first()) {
102  newInterval.setFirst(providerInterval.first());
103  }
104  if (newInterval.last() > providerInterval.last()) {
105  newInterval.setLast(providerInterval.last());
106  }
107  } else {
108  allRecordsValid = false;
109  }
110  }
111  if (intervalsWereComparible) {
112  if (!haveAValidDependentRecord) {
113  //If no Finder has no valid time, then this record is also invalid for this time
114  newInterval = ValidityInterval::invalidInterval();
115  }
116  if (!allRecordsValid) {
117  //since some of the dependent providers do not have a valid IOV for this syncvalue
118  // we do not know what the true end IOV is. Therefore we must make it open ended
119  // so that we can check each time to see if those providers become valid.
120  newInterval.setLast(IOVSyncValue::invalidIOVSyncValue());
121  }
122  oInterval = newInterval;
123  return;
124  }
125  //handle the case where some providers use time and others use run/lumi/event
126  // in this case all we can do is find an IOV which changed since last time
127  // and use its start time to do the synching and use an 'invalid' end time
128  // so the system always checks back to see if something has changed
129  if (previousIOVs_.empty()) {
130  std::vector<ValidityInterval> tmp(providers_.size(), ValidityInterval());
131  previousIOVs_.swap(tmp);
132  }
133 
134  //I'm using an heuristic to pick a reasonable starting point for the IOV. The idea is to
135  // assume that lumi sections are 23 seconds long and therefore if we take a difference between
136  // iTime and the beginning of a changed IOV we can pick the changed IOV with the start time
137  // closest to iTime. This doesn't have to be perfect, we just want to reduce the dependency
138  // on provider order to make the jobs more deterministic
139 
140  bool hadChangedIOV = false;
141  //both start at the smallest value
142  EventID closestID;
143  Timestamp closestTimeStamp(0);
144  std::vector<ValidityInterval>::iterator itIOVs = previousIOVs_.begin();
145  for (Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
146  itProvider != itProviderEnd;
147  ++itProvider, ++itIOVs) {
148  if ((*itProvider)->setValidityIntervalFor(iTime)) {
149  ValidityInterval providerInterval = (*itProvider)->validityInterval();
150  if (*itIOVs != providerInterval) {
151  hadChangedIOV = true;
152  if (providerInterval.first().time().value() == 0) {
153  //this is a run/lumi based one
154  if (closestID < providerInterval.first().eventID()) {
155  closestID = providerInterval.first().eventID();
156  }
157  } else {
158  if (closestTimeStamp < providerInterval.first().time()) {
159  closestTimeStamp = providerInterval.first().time();
160  }
161  }
162  *itIOVs = providerInterval;
163  }
164  }
165  }
166  if (hadChangedIOV) {
167  if (closestID.run() != 0) {
168  if (closestTimeStamp.value() == 0) {
169  //no time
171  } else {
172  if (closestID.run() == iTime.eventID().run()) {
173  //can compare time to lumi
174  const unsigned long long kLumiTimeLength = 23;
175 
176  if ((iTime.eventID().luminosityBlock() - closestID.luminosityBlock()) * kLumiTimeLength <
177  iTime.time().unixTime() - closestTimeStamp.unixTime()) {
178  //closestID was closer
180  } else {
181  oInterval = ValidityInterval(IOVSyncValue(closestTimeStamp), IOVSyncValue::invalidIOVSyncValue());
182  }
183  } else {
184  //since we don't know how to change run # into time we can't compare
185  // so if we have a time just use it
186  oInterval = ValidityInterval(IOVSyncValue(closestTimeStamp), IOVSyncValue::invalidIOVSyncValue());
187  }
188  }
189  } else {
190  oInterval = ValidityInterval(IOVSyncValue(closestTimeStamp), IOVSyncValue::invalidIOVSyncValue());
191  }
192  }
193  }
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::propagate_const< std::shared_ptr< EventSetupRecordIntervalFinder > > alternate_
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
static const ValidityInterval & invalidInterval()
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:78

Member Data Documentation

edm::propagate_const<std::shared_ptr<EventSetupRecordIntervalFinder> > edm::eventsetup::DependentRecordIntervalFinder::alternate_
private

Definition at line 63 of file DependentRecordIntervalFinder.h.

Referenced by setAlternateFinder(), and setIntervalFor().

std::vector<ValidityInterval> edm::eventsetup::DependentRecordIntervalFinder::previousIOVs_
private

Definition at line 64 of file DependentRecordIntervalFinder.h.

Referenced by setIntervalFor().

Providers edm::eventsetup::DependentRecordIntervalFinder::providers_
private