CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes

fwlite::RecordWriter Class Reference

#include <RecordWriter.h>

List of all members.

Classes

struct  DataBuffer

Public Member Functions

void fill (const edm::ESRecordAuxiliary &)
 RecordWriter (const char *iName, TFile *iFile)
void update (const void *iData, const std::type_info &iType, const char *iLabel)
void write ()
virtual ~RecordWriter ()

Private Member Functions

const RecordWriteroperator= (const RecordWriter &)
 RecordWriter (const RecordWriter &)

Private Attributes

edm::ESRecordAuxiliary aux_
TBranch * auxBranch_
std::map< std::pair
< edm::TypeIDBase, std::string >
, DataBuffer
idToBuffer_
edm::ESRecordAuxiliarypAux_
TTree * tree_

Detailed Description

Definition at line 34 of file RecordWriter.h.


Constructor & Destructor Documentation

RecordWriter::RecordWriter ( const char *  iName,
TFile *  iFile 
)

Definition at line 39 of file RecordWriter.cc.

References auxBranch_, fwlite::format_type_to_mangled(), pAux_, and tree_.

                                                         :
pAux_(&aux_)
{
   tree_ = new TTree(fwlite::format_type_to_mangled(iName).c_str(),"Holds data for an EventSetup Record");
   tree_->SetDirectory(iFile);
   
   auxBranch_ = tree_->Branch("ESRecordAuxiliary","edm::ESRecordAuxiliary",&pAux_);
}
RecordWriter::~RecordWriter ( ) [virtual]

Definition at line 53 of file RecordWriter.cc.

{
}
fwlite::RecordWriter::RecordWriter ( const RecordWriter ) [private]

Member Function Documentation

void RecordWriter::fill ( const edm::ESRecordAuxiliary iValue)

Definition at line 113 of file RecordWriter.cc.

References aux_, Exception, idToBuffer_, python::multivaluedict::map(), and tree_.

{
   for(std::map<std::pair<edm::TypeIDBase,std::string>, DataBuffer>::iterator it=idToBuffer_.begin(),itEnd=idToBuffer_.end();
       it!=itEnd;++it) {
      if(0==it->second.pBuffer_) {
         throw cms::Exception("MissingESData")<<"The EventSetup data "<<it->first.first.name()<<" '"<<it->first.second<<"' was not supplied";
      }
   }
   
   aux_ = iValue;
   tree_->Fill();
   for(std::map<std::pair<edm::TypeIDBase,std::string>, DataBuffer>::iterator it=idToBuffer_.begin(),itEnd=idToBuffer_.end();
       it!=itEnd;++it) {
          it->second.pBuffer_=0;
   }
}
const RecordWriter& fwlite::RecordWriter::operator= ( const RecordWriter ) [private]
void RecordWriter::update ( const void *  iData,
const std::type_info &  iType,
const char *  iLabel 
)

Definition at line 73 of file RecordWriter.cc.

References fwlite::RecordWriter::DataBuffer::branch_, className(), fwlite::format_type_to_mangled(), idToBuffer_, label, connectstrParser::o, fwlite::RecordWriter::DataBuffer::pBuffer_, matplotRender::t, tree_, and fwlite::RecordWriter::DataBuffer::trueType_.

{
   const char* label = iLabel;
   if(0==iLabel) {
      label = "";
   }
   std::map<std::pair<edm::TypeIDBase,std::string>, DataBuffer>::iterator itFound = idToBuffer_.find(std::make_pair(edm::TypeIDBase(iType),
      std::string(iLabel)));
   if(itFound == idToBuffer_.end()) {
      //first request
      DataBuffer buffer;
      buffer.pBuffer_=iData;
      ROOT::Reflex::Type t = ROOT::Reflex::Type::ByTypeInfo(iType);
      assert(t != ROOT::Reflex::Type());
      
      std::string className = t.Name(ROOT::Reflex::SCOPED|ROOT::Reflex::FINAL);
      
      //now find actual type
      ROOT::Reflex::Object o(t,const_cast<void*>(iData));
      ROOT::Reflex::Type trueType = o.DynamicType();
      buffer.trueType_ = edm::TypeIDBase(trueType.TypeInfo());
      std::string trueClassName = trueType.Name(ROOT::Reflex::SCOPED|ROOT::Reflex::FINAL);
      
      buffer.branch_ = tree_->Branch((fwlite::format_type_to_mangled(className)+"__"+label).c_str(),
                                     trueClassName.c_str(),
                                     &buffer.pBuffer_);
      idToBuffer_.insert(std::make_pair(std::make_pair(edm::TypeIDBase(iType),std::string(iLabel)),buffer));
      itFound = idToBuffer_.find(std::make_pair(edm::TypeIDBase(iType),
         std::string(iLabel)));
   }
   ROOT::Reflex::Type t = ROOT::Reflex::Type::ByTypeInfo(iType);
   ROOT::Reflex::Object o(t,const_cast<void*>(iData));
   ROOT::Reflex::Type trueType = o.DynamicType();
   assert(edm::TypeIDBase(trueType.TypeInfo())==itFound->second.trueType_);
   itFound->second.branch_->SetAddress(&(itFound->second.pBuffer_));
   itFound->second.pBuffer_ = iData;
}
void RecordWriter::write ( void  )

Definition at line 131 of file RecordWriter.cc.

References tree_.

{
   tree_->Write();
}

Member Data Documentation

Definition at line 65 of file RecordWriter.h.

Referenced by fill().

Definition at line 67 of file RecordWriter.h.

Referenced by RecordWriter().

std::map<std::pair<edm::TypeIDBase,std::string>, DataBuffer> fwlite::RecordWriter::idToBuffer_ [private]

Definition at line 68 of file RecordWriter.h.

Referenced by fill(), and update().

Definition at line 66 of file RecordWriter.h.

Referenced by RecordWriter().

TTree* fwlite::RecordWriter::tree_ [private]

Definition at line 64 of file RecordWriter.h.

Referenced by fill(), RecordWriter(), update(), and write().