CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (boost::shared_ptr< EventSetupRecordProvider >)
 
 DependentRecordIntervalFinder (const EventSetupRecordKey &)
 
bool haveProviders () const
 
void setAlternateFinder (boost::shared_ptr< EventSetupRecordIntervalFinder >)
 
virtual ~DependentRecordIntervalFinder ()
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
const
eventsetup::ComponentDescription
descriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
std::set
< eventsetup::EventSetupRecordKey
findingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder ()
 

Protected Member Functions

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

Private Types

typedef std::vector
< boost::shared_ptr
< EventSetupRecordProvider > > 
Providers
 

Private Member Functions

 DependentRecordIntervalFinder (const DependentRecordIntervalFinder &)
 
const
DependentRecordIntervalFinder
operator= (const DependentRecordIntervalFinder &)
 

Private Attributes

boost::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 65 of file DependentRecordIntervalFinder.h.

Constructor & Destructor Documentation

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

Definition at line 43 of file DependentRecordIntervalFinder.cc.

44 {
45 }
edm::eventsetup::DependentRecordIntervalFinder::DependentRecordIntervalFinder ( const DependentRecordIntervalFinder )
private

Member Function Documentation

void DependentRecordIntervalFinder::addProviderWeAreDependentOn ( boost::shared_ptr< EventSetupRecordProvider iProvider)
bool edm::eventsetup::DependentRecordIntervalFinder::haveProviders ( ) const
inline

Definition at line 44 of file DependentRecordIntervalFinder.h.

References providers_.

44  {
45  return !providers_.empty();
46  }
const DependentRecordIntervalFinder& edm::eventsetup::DependentRecordIntervalFinder::operator= ( const DependentRecordIntervalFinder )
private
void DependentRecordIntervalFinder::setAlternateFinder ( boost::shared_ptr< EventSetupRecordIntervalFinder iOther)

Definition at line 69 of file DependentRecordIntervalFinder.cc.

References alternate_.

70 {
71  alternate_ = iOther;
72 }
boost::shared_ptr< EventSetupRecordIntervalFinder > alternate_
void DependentRecordIntervalFinder::setIntervalFor ( const EventSetupRecordKey iKey,
const IOVSyncValue iTime,
ValidityInterval oInterval 
)
protectedvirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 75 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(), run_regression::test, edm::IOVSyncValue::time(), tmp, edm::Timestamp::unixTime(), and edm::Timestamp::value().

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

Member Data Documentation

boost::shared_ptr<EventSetupRecordIntervalFinder> edm::eventsetup::DependentRecordIntervalFinder::alternate_
private

Definition at line 68 of file DependentRecordIntervalFinder.h.

Referenced by setAlternateFinder(), and setIntervalFor().

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

Definition at line 69 of file DependentRecordIntervalFinder.h.

Referenced by setIntervalFor().

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