CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
fwlite::Record Class Reference

#include <Record.h>

Classes

class  TypeID
 

Public Member Functions

const IOVSyncValueendSyncValue () const
 
template<typename HANDLE >
bool get (HANDLE &, const char *iLabel="") const
 
const std::string & name () const
 
 Record (const char *iName, TTree *)
 
const IOVSyncValuestartSyncValue () const
 
void syncTo (const edm::EventID &, const edm::Timestamp &)
 
std::vector< std::pair
< std::string, std::string > > 
typeAndLabelOfAvailableData () const
 
virtual ~Record ()
 

Private Member Functions

cms::Exceptionget (const TypeID &, const char *iLabel, const void *&) const
 
const Recordoperator= (const Record &)
 
 Record (const Record &)
 
void resetCaches ()
 

Private Attributes

std::map< std::pair< TypeID,
std::string >, std::pair
< TBranch *, void * > > 
m_branches
 
IOVSyncValue m_end
 
long m_entry
 
std::string m_name
 
IOVSyncValue m_start
 
std::map< IOVSyncValue,
unsigned int > 
m_startIOVtoEntry
 
TTree * m_tree
 

Detailed Description

Definition at line 47 of file Record.h.

Constructor & Destructor Documentation

Record::Record ( const char *  iName,
TTree *  iTree 
)

Definition at line 36 of file Record.cc.

References printConversionInfo::aux, edm::ESRecordAuxiliary::eventID(), getHLTprescales::index, edm::Timestamp::invalidTimestamp(), m_startIOVtoEntry, m_tree, edm::EventID::run(), groupFilesInBlocks::temp, and edm::ESRecordAuxiliary::timestamp().

36  :
37 m_name(iName), m_tree(iTree), m_entry(-1),
40 {
41  //read the start iovs and get them in order
44  TBranch* auxBranch = m_tree->FindBranch("ESRecordAuxiliary");
45  auxBranch->SetAddress(&pAux);
47  for(unsigned int index=0; index < m_tree->GetEntries();++index){
48  auxBranch->GetEntry(index);
50  if(aux.eventID().run() != 0) {
51  temp = IOVSyncValue(aux.eventID(),aux.timestamp());
52  } else {
53  temp = IOVSyncValue(aux.timestamp());
54  }
55  } else {
56  temp=IOVSyncValue(aux.eventID());
57  assert(aux.eventID().run()!=0);
58  }
59 
61  }
62 }
RunNumber_t run() const
Definition: EventID.h:42
const edm::EventID & eventID() const
IOVSyncValue m_start
Definition: Record.h:86
long m_entry
Definition: Record.h:85
TTree * m_tree
Definition: Record.h:83
static Timestamp const & invalidTimestamp()
Definition: Timestamp.cc:83
std::string m_name
Definition: Record.h:82
std::map< IOVSyncValue, unsigned int > m_startIOVtoEntry
Definition: Record.h:84
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:87
IOVSyncValue m_end
Definition: Record.h:87
const edm::Timestamp & timestamp() const
Record::~Record ( )
virtual

Definition at line 69 of file Record.cc.

References resetCaches().

70 {
71  resetCaches();
72 }
void resetCaches()
Definition: Record.cc:139
fwlite::Record::Record ( const Record )
private

Member Function Documentation

const IOVSyncValue & Record::endSyncValue ( ) const

Definition at line 170 of file Record.cc.

References m_end.

Referenced by FWLiteESSource::setIntervalFor().

171 {
172  return m_end;
173 }
IOVSyncValue m_end
Definition: Record.h:87
template<typename HANDLE >
bool Record::get ( HANDLE &  iHandle,
const char *  iLabel = "" 
) const

Definition at line 94 of file Record.h.

References alignCSCRings::e, and relativeConstraints::value.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), betterConfigParser.BetterConfigParser::getResultingSection(), and main().

95  {
96  const void* value = 0;
97  cms::Exception* e = get(TypeID(iHandle.typeInfo()),iLabel,value);
98  if(0==e){
99  iHandle = HANDLE(value);
100  } else {
101  iHandle = HANDLE(e);
102  }
103  return 0==e;
104  }
cms::Exception * Record::get ( const TypeID iType,
const char *  iLabel,
const void *&  iData 
) const
private

Definition at line 177 of file Record.cc.

References dt, edm::hlt::Exception, fwlite::format_type_to_mangled(), m_branches, m_entry, m_tree, name(), lumiQTWidget::t, and edm::TypeIDBase::typeInfo().

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

180 {
181  cms::Exception* returnValue = 0;
182 
183  std::pair<TBranch*,void*>& branch = m_branches[std::make_pair(iType,iLabel)];
184  if(0==branch.first){
185  branch.second=0;
186  using namespace ROOT::Reflex;
187  Type t = Type::ByTypeInfo(iType.typeInfo());
188  if(t == Type()){
189  returnValue = new cms::Exception("UnknownType");
190  (*returnValue)<<"The type "
191  <<iType.typeInfo().name()<<" was requested from Record "<<name()
192  <<" but the type has no known dictionary";
193  return returnValue;
194  }
195  //build branch name
196  std::string branchName = fwlite::format_type_to_mangled(t.Name(ROOT::Reflex::SCOPED|ROOT::Reflex::FINAL))+"__"+iLabel;
197  branch.first = m_tree->FindBranch(branchName.c_str());
198 
199  if(0==branch.first){
200  returnValue = new cms::Exception("NoDataAvailable");
201  (*returnValue)<<"The data of type "
202  <<t.Name(ROOT::Reflex::SCOPED|ROOT::Reflex::FINAL)
203  <<" with label '"<<iLabel<<"' for Record "<<name()<<" is not in this file.";
204  return returnValue;
205  }
206  //We need GetExpectedType to work in order to delete objects
207  TClass* cls;
208  EDataType dt;
209  if(0!=branch.first->GetExpectedType(cls,dt)) {
210  returnValue = new cms::Exception("UnknownType");
211  (*returnValue)<<"The type "
212  <<iType.typeInfo().name()<<" was requested from Record "<<name()
213  <<" but the TBranch does not know what Type it holds.";
214  return returnValue;
215  }
216 
217  branch.first->SetAutoDelete(kFALSE);
218  }
219  if(m_entry<0) {
220  returnValue = new cms::Exception("NoValidIOV");
221  (*returnValue) <<" The Record "
222  <<name()<<" was asked to get data for a 'time' for which it has no data";
223  return returnValue;
224  }
225  if(0!=branch.second) {
226  iData=branch.second;
227  return nullptr;
228  }
229 
230  assert(0==branch.second);
231  branch.first->SetAddress(&branch.second);
232  iData = branch.second;
233  branch.first->GetEntry(m_entry);
234  return returnValue;
235 }
float dt
Definition: AMPTWrapper.h:126
long m_entry
Definition: Record.h:85
TTree * m_tree
Definition: Record.h:83
const std::string & name() const
Definition: Record.cc:160
std::string format_type_to_mangled(const std::string &)
given a C++ class name returned a mangled name
std::map< std::pair< TypeID, std::string >, std::pair< TBranch *, void * > > m_branches
Definition: Record.h:89
const std::string & Record::name ( ) const

Definition at line 160 of file Record.cc.

References m_name.

Referenced by get(), typeAndLabelOfAvailableData(), and Vispa.Views.PropertyView.Property::valueChanged().

161 {
162  return m_name;
163 }
std::string m_name
Definition: Record.h:82
const Record& fwlite::Record::operator= ( const Record )
private
void Record::resetCaches ( )
private

Definition at line 139 of file Record.cc.

References b, dt, m_branches, and or.

Referenced by syncTo(), and ~Record().

140 {
141  for(auto&b : m_branches){
142  TClass* cls=0;
143  EDataType dt;
144  if(0==b.second.first or 0==b.second.second) continue;
145  if(0==b.second.first->GetExpectedType(cls,dt)) {
146  cls->Destructor(b.second.second);
147  b.second.second=0;
148  }
149  }
150  for(auto&b : m_branches){
151  if(0==b.second.first) continue;
152  assert(b.second.second==0);
153  }
154 }
float dt
Definition: AMPTWrapper.h:126
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
double b
Definition: hdecay.h:120
std::map< std::pair< TypeID, std::string >, std::pair< TBranch *, void * > > m_branches
Definition: Record.h:89
const IOVSyncValue & Record::startSyncValue ( ) const

Definition at line 166 of file Record.cc.

References m_start.

Referenced by main(), and FWLiteESSource::setIntervalFor().

166  {
167  return m_start;
168 }
IOVSyncValue m_start
Definition: Record.h:86
void Record::syncTo ( const edm::EventID iEvent,
const edm::Timestamp iTime 
)

Definition at line 90 of file Record.cc.

References fwlite::IOVSyncValue::invalidIOVSyncValue(), edm::Timestamp::invalidTimestamp(), m_end, m_entry, m_start, m_startIOVtoEntry, resetCaches(), edm::EventID::run(), and groupFilesInBlocks::temp.

Referenced by fwlite::EventSetup::syncTo().

91 {
92 
94  if(iTime != edm::Timestamp::invalidTimestamp()){
95  if(iEvent.run() != 0) {
96  temp = IOVSyncValue(iEvent,iTime);
97  } else {
98  temp = IOVSyncValue(iTime);
99  }
100  } else {
101  temp=IOVSyncValue(iEvent);
102  assert(iEvent.run()!=0);
103  }
104 
105  //already synched
107  (m_start <=temp ) &&
109  (temp <m_end))) {
110  return;
111  }
112  std::pair<StartIOVtoEntryMap::iterator, StartIOVtoEntryMap::iterator> range =
113  m_startIOVtoEntry.equal_range(temp);
114  if(range.first!=range.second){
115  //happens to be the start of the IOV
116  m_start = range.first->first;
117  m_entry = range.first->second;
118  } else {
119  if(range.first!=m_startIOVtoEntry.begin()){
120  //we have overshot
121  --range.first;
122  m_start = range.first->first;
123  m_entry = range.first->second;
124  } else {
125  //off the beginning
127  m_entry = -1;
128  }
129  }
130  if(range.second==m_startIOVtoEntry.end()){
132  } else {
133  m_end = range.second->first;
134  }
135  resetCaches();
136 }
RunNumber_t run() const
Definition: EventID.h:42
IOVSyncValue m_start
Definition: Record.h:86
long m_entry
Definition: Record.h:85
static Timestamp const & invalidTimestamp()
Definition: Timestamp.cc:83
std::map< IOVSyncValue, unsigned int > m_startIOVtoEntry
Definition: Record.h:84
static const IOVSyncValue & invalidIOVSyncValue()
Definition: IOVSyncValue.cc:87
void resetCaches()
Definition: Record.cc:139
IOVSyncValue m_end
Definition: Record.h:87
std::vector< std::pair< std::string, std::string > > Record::typeAndLabelOfAvailableData ( ) const

Definition at line 238 of file Record.cc.

References diffTwoXMLs::label, m_tree, name(), GetRecoTauVFromDQM_MC_cff::next, getGTfromDQMFile::obj, and fwlite::unformat_mangled_to_type().

Referenced by FWLiteESSource::registerProxies().

239 {
240  std::vector<std::pair<std::string,std::string> > returnValue;
241 
242  TObjArray* branches = m_tree->GetListOfBranches();
243  TIter next( branches );
244  while (TObject* obj = next()) {
245  TBranch* branch = static_cast<TBranch*> (obj);
246  const char* name = branch->GetName();
247  if (0!=strcmp(name, "ESRecordAuxiliary") ) {
248  //The type and label are separated by a double underscore so we need to find that
249  size_t len = strlen(name);
250  const char* cIndex = name+len;
251  std::string label;
252  while (name != --cIndex) {
253  if(*cIndex == '_') {
254  if( *(cIndex-1)=='_') {
255  label = std::string(cIndex+1);
256  break;
257  }
258  }
259  }
260  std::string type(name, cIndex-name-1);
262  returnValue.push_back(std::make_pair(type,label));
263  }
264  }
265  return returnValue;
266 }
type
Definition: HCALResponse.h:22
TTree * m_tree
Definition: Record.h:83
std::string unformat_mangled_to_type(const std::string &)
given a mangled name return the C++ class name
const std::string & name() const
Definition: Record.cc:160

Member Data Documentation

std::map<std::pair<TypeID,std::string>, std::pair<TBranch*,void*> > fwlite::Record::m_branches
mutableprivate

Definition at line 89 of file Record.h.

Referenced by get(), and resetCaches().

IOVSyncValue fwlite::Record::m_end
private

Definition at line 87 of file Record.h.

Referenced by endSyncValue(), and syncTo().

long fwlite::Record::m_entry
private

Definition at line 85 of file Record.h.

Referenced by get(), and syncTo().

std::string fwlite::Record::m_name
private

Definition at line 82 of file Record.h.

Referenced by name().

IOVSyncValue fwlite::Record::m_start
private

Definition at line 86 of file Record.h.

Referenced by startSyncValue(), and syncTo().

std::map<IOVSyncValue,unsigned int> fwlite::Record::m_startIOVtoEntry
private

Definition at line 84 of file Record.h.

Referenced by Record(), and syncTo().

TTree* fwlite::Record::m_tree
private

Definition at line 83 of file Record.h.

Referenced by get(), Record(), and typeAndLabelOfAvailableData().