CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/FWCore/FWLite/src/BranchMapReader.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     FWLite
00004 // Class  :     BranchMapReader
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Dan Riley
00010 //         Created:  Tue May 20 10:31:32 EDT 2008
00011 //
00012 
00013 // system include files
00014 
00015 // user include files
00016 #include "FWCore/FWLite/interface/BranchMapReader.h"
00017 
00018 #include "DataFormats/Provenance/interface/BranchIDList.h"
00019 #include "DataFormats/Provenance/interface/BranchListIndex.h"
00020 #include "DataFormats/Provenance/interface/BranchType.h"
00021 #include "DataFormats/Provenance/interface/EventEntryInfo.h"
00022 #include "DataFormats/Provenance/interface/EventSelectionID.h"
00023 #include "DataFormats/Provenance/interface/FileFormatVersion.h"
00024 #include "DataFormats/Provenance/interface/History.h"
00025 #include "DataFormats/Provenance/interface/ProductIDToBranchID.h"
00026 #include "DataFormats/Provenance/interface/ProductRegistry.h"
00027 #include "FWCore/Utilities/interface/EDMException.h"
00028 
00029 #include "TBranch.h"
00030 #include "TFile.h"
00031 #include "TTree.h"
00032 
00033 namespace fwlite {
00034   namespace internal {
00035 
00036     static const edm::BranchDescription kDefaultBranchDescription;
00037 
00038     BMRStrategy::BMRStrategy(TFile* file, int fileVersion)
00039       : currentFile_(file), eventTree_(0), luminosityBlockTree_(0), runTree_(0),
00040         eventEntry_(-1), luminosityBlockEntry_(-1), runEntry_(-1), fileVersion_(fileVersion) {
00041       // do in derived obects
00042       // updateFile(file);
00043     }
00044 
00045     BMRStrategy::~BMRStrategy() {
00046     }
00047 
00048     class Strategy : public BMRStrategy {
00049     public:
00050       typedef std::map<edm::BranchID, edm::BranchDescription> bidToDesc;
00051 
00052       Strategy(TFile* file, int fileVersion);
00053       virtual ~Strategy();
00054       virtual bool updateFile(TFile* file);
00055       virtual bool updateEvent(Long_t eventEntry) { eventEntry_ = eventEntry; return true; }
00056       virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry) {
00057         luminosityBlockEntry_ = luminosityBlockEntry;
00058         return true;
00059       }
00060       virtual bool updateRun(Long_t runEntry) {
00061         runEntry_ = runEntry;
00062         return true;
00063       }
00064       virtual bool updateMap() { return true; }
00065       virtual edm::BranchID productToBranchID(edm::ProductID const& pid);
00066       virtual edm::BranchDescription const& productToBranch(edm::ProductID const& pid);
00067       virtual std::vector<edm::BranchDescription> const& getBranchDescriptions();
00068 
00069       TBranch* getBranchRegistry(edm::ProductRegistry** pReg);
00070 
00071       bidToDesc branchDescriptionMap_;
00072       std::vector<edm::BranchDescription> bDesc_;
00073       bool mapperFilled_;
00074     };
00075 
00076     Strategy::Strategy(TFile* file, int fileVersion)
00077       : BMRStrategy(file, fileVersion), mapperFilled_(false) {
00078       // do in derived obects
00079       // updateFile(file);
00080     }
00081 
00082     Strategy::~Strategy() {
00083       // probably need to clean up something here...
00084     }
00085 
00086     bool Strategy::updateFile(TFile* file) {
00087       currentFile_ = file;
00088       eventTree_ = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::eventTreeName().c_str()));
00089       luminosityBlockTree_ = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::luminosityBlockTreeName().c_str()));
00090       runTree_ = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::runTreeName().c_str()));
00091       fileUUID_ = currentFile_->GetUUID();
00092       branchDescriptionMap_.clear();
00093       bDesc_.clear();
00094       return 0 != eventTree_;
00095     }
00096 
00097     TBranch* Strategy::getBranchRegistry(edm::ProductRegistry** ppReg) {
00098       TBranch* bReg(0);
00099 
00100       TTree* metaDataTree = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::metaDataTreeName().c_str()));
00101       if(0 != metaDataTree) {
00102         bReg = metaDataTree->GetBranch(edm::poolNames::productDescriptionBranchName().c_str());
00103         bReg->SetAddress(ppReg);
00104         bReg->GetEntry(0);
00105         (*ppReg)->setFrozen(false);
00106       }
00107       return bReg;
00108     }
00109 
00110     std::vector<edm::BranchDescription> const&
00111     Strategy::getBranchDescriptions() {
00112       if(bDesc_.empty()) {
00113         for(bidToDesc::const_iterator i = branchDescriptionMap_.begin(); i != branchDescriptionMap_.end(); ++i) {
00114           bDesc_.push_back(i->second);
00115         }
00116       }
00117       return bDesc_;
00118     }
00119 
00120     edm::BranchID
00121     Strategy::productToBranchID(edm::ProductID const&) {
00122       throw edm::Exception(edm::errors::UnimplementedFeature) << "Unsupported EDM file version";
00123     }
00124 
00125     edm::BranchDescription const &
00126     Strategy::productToBranch(edm::ProductID const& pid) {
00127       edm::BranchID bid = productToBranchID(pid);
00128       bidToDesc::const_iterator bdi = branchDescriptionMap_.find(bid);
00129       if(branchDescriptionMap_.end() == bdi) {
00130         return kDefaultBranchDescription;
00131       }
00132       return bdi->second;
00133     }
00134 
00135     class BranchMapReaderStrategyV1 : public Strategy {
00136     public:
00137       BranchMapReaderStrategyV1(TFile* file, int fileVersion);
00138       virtual bool updateFile(TFile* file);
00139       virtual bool updateMap();
00140     private:
00141     };
00142 
00143     BranchMapReaderStrategyV1::BranchMapReaderStrategyV1(TFile* file, int fileVersion)
00144       : Strategy(file, fileVersion) {
00145       updateFile(file);
00146     }
00147 
00148     bool BranchMapReaderStrategyV1::updateFile(TFile* file) {
00149       if(Strategy::updateFile(file)) {
00150         mapperFilled_ = false;
00151         return true;
00152       }
00153       return false;
00154     }
00155 
00156     bool BranchMapReaderStrategyV1::updateMap() {
00157       if(mapperFilled_) {
00158         return true;
00159       }
00160 
00161       branchDescriptionMap_.clear();
00162       bDesc_.clear();
00163 
00164       edm::ProductRegistry reg;
00165       edm::ProductRegistry* pReg = &reg;
00166       TBranch* br = getBranchRegistry(&pReg);
00167 
00168       if(0 != br) {
00169         edm::ProductRegistry::ProductList const& prodList = reg.productList();
00170 
00171         for(edm::ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd; ++it) {
00172           if(edm::InEvent == it->second.branchType()) {
00173             // call to regenerate branchName
00174             it->second.init();
00175             branchDescriptionMap_.insert(bidToDesc::value_type(it->second.branchID(), it->second));
00176           }
00177         }
00178         mapperFilled_ = true;
00179       }
00180       return 0 != br;
00181     }
00182 
00183     // v7 has differences in product status that are not implemented in BranchMapReader yet
00184     class BranchMapReaderStrategyV7 : public BranchMapReaderStrategyV1 {
00185     public:
00186       BranchMapReaderStrategyV7(TFile* file, int fileVersion);
00187     };
00188 
00189     BranchMapReaderStrategyV7::BranchMapReaderStrategyV7(TFile* file, int fileVersion)
00190     : BranchMapReaderStrategyV1(file, fileVersion) {
00191       updateFile(file);
00192     }
00193 
00194     class BranchMapReaderStrategyV8 : public Strategy {
00195     public:
00196       BranchMapReaderStrategyV8(TFile* file, int fileVersion);
00197       virtual bool updateFile(TFile* file);
00198       virtual bool updateEvent(Long_t eventEntry);
00199       virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry);
00200       virtual bool updateRun(Long_t runEntry);
00201       virtual bool updateMap();
00202     private:
00203       TBranch* entryInfoBranch_;
00204       edm::EventEntryInfoVector  eventEntryInfoVector_;
00205       edm::EventEntryInfoVector* pEventEntryInfoVector_;
00206     };
00207 
00208     BranchMapReaderStrategyV8::BranchMapReaderStrategyV8(TFile* file, int fileVersion)
00209     : Strategy(file, fileVersion),
00210       eventEntryInfoVector_(), pEventEntryInfoVector_(&eventEntryInfoVector_) {
00211       updateFile(file);
00212     }
00213 
00214     bool BranchMapReaderStrategyV8::updateEvent(Long_t newevent) {
00215       // std::cout << "v8 updateevent " << newevent << std::endl;
00216       if(newevent != eventEntry_) {
00217         eventEntry_ = newevent;
00218         mapperFilled_ = false;
00219       }
00220       return true;
00221     }
00222 
00223     bool BranchMapReaderStrategyV8::updateLuminosityBlock(Long_t newLumi) {
00224       if(newLumi != luminosityBlockEntry_) {
00225         luminosityBlockEntry_ = newLumi;
00226         mapperFilled_ = false;
00227       }
00228       return true;
00229     }
00230 
00231     bool BranchMapReaderStrategyV8::updateRun(Long_t newRun) {
00232       if(newRun != runEntry_) {
00233         runEntry_ = newRun;
00234         mapperFilled_ = false;
00235       }
00236       return true;
00237     }
00238 
00239     bool BranchMapReaderStrategyV8::updateFile(TFile* file) {
00240       Strategy::updateFile(file);
00241       mapperFilled_ = false;
00242       entryInfoBranch_ = 0;
00243       TTree* metaDataTree = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::eventMetaDataTreeName().c_str()));
00244       if(0 != metaDataTree) {
00245         entryInfoBranch_ = metaDataTree->GetBranch(BranchTypeToBranchEntryInfoBranchName(edm::InEvent).c_str());
00246 //         std::cout << "entryInfoBranch for " << BranchTypeToBranchEntryInfoBranchName(edm::InEvent) << " " << entryInfoBranch_ << std::endl;
00247       } else {
00248         return false;
00249       }
00250       pEventEntryInfoVector_ = &eventEntryInfoVector_;
00251       entryInfoBranch_->SetAddress(&pEventEntryInfoVector_);
00252 
00253       branchDescriptionMap_.clear();
00254       bDesc_.clear();
00255 
00256       edm::ProductRegistry reg;
00257       edm::ProductRegistry* pReg = &reg;
00258       TBranch *br = getBranchRegistry(&pReg);
00259 
00260       if(0 != br) {
00261         edm::ProductRegistry::ProductList const& prodList = reg.productList();
00262 
00263         for(edm::ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd; ++it) {
00264           if(edm::InEvent == it->second.branchType()) {
00265             // call to regenerate branchName
00266             it->second.init();
00267             branchDescriptionMap_.insert(bidToDesc::value_type(it->second.branchID(), it->second));
00268           }
00269         }
00270       }
00271       return 0 != br;
00272     }
00273 
00274     bool BranchMapReaderStrategyV8::updateMap() {
00275       if(mapperFilled_) {
00276         return true;
00277       }
00278 
00279       assert(entryInfoBranch_);
00280 
00281       entryInfoBranch_->GetEntry(eventEntry_);
00282 
00283       for(std::vector<edm::EventEntryInfo>::const_iterator it = pEventEntryInfoVector_->begin(),
00284            itEnd = pEventEntryInfoVector_->end();
00285            it != itEnd; ++it) {
00286 //         eventInfoMap_.insert(*it);
00287       }
00288       mapperFilled_ = true;
00289       return true;
00290     }
00291 
00292     class BranchMapReaderStrategyV11 : public Strategy {
00293     public:
00294       BranchMapReaderStrategyV11(TFile* file, int fileVersion);
00295       virtual bool updateFile(TFile* file);
00296       virtual bool updateEvent(Long_t eventEntry);
00297       virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry);
00298       virtual bool updateRun(Long_t runEntry);
00299       virtual bool updateMap();
00300       virtual edm::BranchID productToBranchID(edm::ProductID const& pid);
00301     private:
00302       std::auto_ptr<edm::BranchIDLists> branchIDLists_;
00303       TTree* eventHistoryTree_;
00304       edm::History history_;
00305       edm::History* pHistory_;
00306     };
00307 
00308     BranchMapReaderStrategyV11::BranchMapReaderStrategyV11(TFile* file, int fileVersion)
00309     : Strategy(file, fileVersion), eventHistoryTree_(0), pHistory_(&history_) {
00310       updateFile(file);
00311     }
00312 
00313     bool BranchMapReaderStrategyV11::updateEvent(Long_t newevent) {
00314 //      std::cout << "v11 updateevent " << newevent << std::endl;
00315       if(newevent != eventEntry_) {
00316         eventEntry_ = newevent;
00317         mapperFilled_ = false;
00318       }
00319       return true;
00320     }
00321 
00322     bool BranchMapReaderStrategyV11::updateLuminosityBlock(Long_t newlumi) {
00323       if(newlumi != luminosityBlockEntry_) {
00324         luminosityBlockEntry_ = newlumi;
00325         mapperFilled_ = false;
00326       }
00327       return true;
00328     }
00329 
00330     bool BranchMapReaderStrategyV11::updateRun(Long_t newRun) {
00331       if(newRun != runEntry_) {
00332         runEntry_ = newRun;
00333         mapperFilled_ = false;
00334       }
00335       return true;
00336     }
00337 
00338     bool BranchMapReaderStrategyV11::updateFile(TFile* file) {
00339       Strategy::updateFile(file);
00340       mapperFilled_ = false;
00341       TTree* metaDataTree = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::metaDataTreeName().c_str()));
00342 
00343       if(0 == metaDataTree) {
00344          throw edm::Exception(edm::errors::EventCorruption)
00345            <<"No "<<edm::poolNames::metaDataTreeName()<<" TTree in file";
00346       }
00347       branchIDLists_.reset(new edm::BranchIDLists);
00348       edm::BranchIDLists* branchIDListsPtr = branchIDLists_.get();
00349       if(metaDataTree->FindBranch(edm::poolNames::branchIDListBranchName().c_str()) != 0) {
00350         TBranch* b = metaDataTree->GetBranch(edm::poolNames::branchIDListBranchName().c_str());
00351         b->SetAddress(&branchIDListsPtr);
00352         b->GetEntry(0);
00353 //         std::cout << "--> " << branchIDLists_->size() << std::endl;
00354       } else {
00355         throw edm::Exception(edm::errors::EventCorruption)
00356           << "FindBranch of branchIDList failed";
00357         return false;
00358       }
00359 
00360       eventHistoryTree_ = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::eventHistoryTreeName().c_str()));
00361 
00362       branchDescriptionMap_.clear();
00363       bDesc_.clear();
00364 
00365       edm::ProductRegistry reg;
00366       edm::ProductRegistry* pReg = &reg;
00367       TBranch *br = getBranchRegistry(&pReg);
00368 
00369       if(0 != br) {
00370         edm::ProductRegistry::ProductList const& prodList = reg.productList();
00371 
00372         for(edm::ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd; ++it) {
00373           if(edm::InEvent == it->second.branchType()) {
00374             // call to regenerate branchName
00375             it->second.init();
00376             branchDescriptionMap_.insert(bidToDesc::value_type(it->second.branchID(), it->second));
00377 //             std::cout << "v11 updatefile " << it->second.branchID() << std::endl;
00378                 }
00379               }
00380       }
00381       return 0 != br;
00382     }
00383 
00384     bool BranchMapReaderStrategyV11::updateMap() {
00385       if(!mapperFilled_) {
00386         TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(edm::poolNames::eventHistoryBranchName().c_str());
00387         if(!eventHistoryBranch) {
00388           throw edm::Exception(edm::errors::EventCorruption)
00389             << "Failed to find history branch in event history tree";
00390           return false;
00391         }
00392         // yes, SetAddress really does need to be called every time...
00393         eventHistoryBranch->SetAddress(&pHistory_);
00394         eventHistoryTree_->GetEntry(eventEntry_);
00395         mapperFilled_ = true;
00396       }
00397       return true;
00398     }
00399 
00400     edm::BranchID
00401     BranchMapReaderStrategyV11::productToBranchID(edm::ProductID const& pid) {
00402       updateMap();
00403       return edm::productIDToBranchID(pid, *branchIDLists_, history_.branchListIndexes());
00404     }
00405 
00406     class BranchMapReaderStrategyV17 : public Strategy {
00407     public:
00408       BranchMapReaderStrategyV17(TFile* file, int fileVersion);
00409       virtual bool updateFile(TFile* file);
00410       virtual bool updateEvent(Long_t eventEntry);
00411       virtual bool updateLuminosityBlock(Long_t luminosityBlockEntry);
00412       virtual bool updateRun(Long_t runEntry);
00413       virtual bool updateMap();
00414       virtual edm::BranchID productToBranchID(edm::ProductID const& pid);
00415     private:
00416       std::auto_ptr<edm::BranchIDLists> branchIDLists_;
00417       TTree* eventsTree_;
00418       edm::BranchListIndexes branchListIndexes_;
00419       edm::BranchListIndexes* pBranchListIndexes_;
00420     };
00421 
00422     BranchMapReaderStrategyV17::BranchMapReaderStrategyV17(TFile* file, int fileVersion)
00423     : Strategy(file, fileVersion), eventsTree_(0), pBranchListIndexes_(&branchListIndexes_) {
00424       updateFile(file);
00425     }
00426 
00427     bool BranchMapReaderStrategyV17::updateEvent(Long_t newevent) {
00428 //      std::cout << "v11 updateevent " << newevent << std::endl;
00429       if(newevent != eventEntry_) {
00430         eventEntry_ = newevent;
00431         mapperFilled_ = false;
00432       }
00433       return true;
00434     }
00435 
00436     bool BranchMapReaderStrategyV17::updateLuminosityBlock(Long_t newlumi) {
00437       if(newlumi != luminosityBlockEntry_) {
00438         luminosityBlockEntry_ = newlumi;
00439         mapperFilled_ = false;
00440       }
00441       return true;
00442     }
00443 
00444     bool BranchMapReaderStrategyV17::updateRun(Long_t newRun) {
00445       if(newRun != runEntry_) {
00446         runEntry_ = newRun;
00447         mapperFilled_ = false;
00448       }
00449       return true;
00450     }
00451 
00452     bool BranchMapReaderStrategyV17::updateFile(TFile* file) {
00453       Strategy::updateFile(file);
00454       mapperFilled_ = false;
00455       TTree* metaDataTree = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::metaDataTreeName().c_str()));
00456       if(0==metaDataTree) {
00457          throw edm::Exception(edm::errors::EventCorruption) <<"No "<<edm::poolNames::metaDataTreeName()<<" TTree in file";
00458       }
00459       branchIDLists_.reset(new edm::BranchIDLists);
00460       edm::BranchIDLists* branchIDListsPtr = branchIDLists_.get();
00461       if(metaDataTree->FindBranch(edm::poolNames::branchIDListBranchName().c_str()) != 0) {
00462         TBranch* b = metaDataTree->GetBranch(edm::poolNames::branchIDListBranchName().c_str());
00463         b->SetAddress(&branchIDListsPtr);
00464         b->GetEntry(0);
00465 //         std::cout << "--> " << branchIDLists_->size() << std::endl;
00466       } else {
00467         throw edm::Exception(edm::errors::EventCorruption)
00468           << "FindBranch of branchIDList failed";
00469         return false;
00470       }
00471 
00472       eventsTree_ = dynamic_cast<TTree*>(currentFile_->Get(edm::poolNames::eventTreeName().c_str()));
00473 
00474       branchDescriptionMap_.clear();
00475       bDesc_.clear();
00476 
00477       edm::ProductRegistry reg;
00478       edm::ProductRegistry* pReg = &reg;
00479       TBranch *br = getBranchRegistry(&pReg);
00480 
00481       if(0 != br) {
00482         edm::ProductRegistry::ProductList const& prodList = reg.productList();
00483 
00484         for(edm::ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd; ++it) {
00485           if(edm::InEvent == it->second.branchType()) {
00486             // call to regenerate branchName
00487             it->second.init();
00488             branchDescriptionMap_.insert(bidToDesc::value_type(it->second.branchID(), it->second));
00489 //             std::cout << "v11 updatefile " << it->second.branchID() << std::endl;
00490                 }
00491               }
00492       }
00493       return 0 != br;
00494     }
00495 
00496     bool BranchMapReaderStrategyV17::updateMap() {
00497       if(!mapperFilled_) {
00498         TBranch* branchListIndexesBranch = eventsTree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str());
00499         if(!branchListIndexesBranch) {
00500           throw edm::Exception(edm::errors::EventCorruption)
00501             << "Failed to find branch list indexes branch in event tree";
00502           return false;
00503         }
00504         // yes, SetAddress really does need to be called every time...
00505         branchListIndexesBranch->SetAddress(&pBranchListIndexes_);
00506         branchListIndexesBranch->GetEntry(eventEntry_);
00507         mapperFilled_ = true;
00508       }
00509       return true;
00510     }
00511 
00512     edm::BranchID
00513     BranchMapReaderStrategyV17::productToBranchID(edm::ProductID const& pid) {
00514       updateMap();
00515       return edm::productIDToBranchID(pid, *branchIDLists_, branchListIndexes_);
00516     }
00517   }
00518 
00519 //
00520 // constants, enums and typedefs
00521 //
00522 
00523 //
00524 // static data member definitions
00525 //
00526 
00527 //
00528 // constructors and destructor
00529 //
00530 
00531 BranchMapReader::BranchMapReader(TFile* file) :
00532     fileVersion_(-1) {
00533   if(0==file) {
00534      throw cms::Exception("NoFile")<<"The TFile pointer is null";
00535   }
00536   strategy_ = newStrategy(file, getFileVersion(file));
00537 }
00538 
00539 //
00540 // member functions
00541 //
00542 
00543 int BranchMapReader::getFileVersion(TFile* file) {
00544   TTree* metaDataTree = dynamic_cast<TTree*>(file->Get(edm::poolNames::metaDataTreeName().c_str()));
00545   if(0==metaDataTree) {
00546     return 0;
00547   }
00548 
00549   edm::FileFormatVersion v;
00550   edm::FileFormatVersion* pV=&v;
00551   TBranch* bVer = metaDataTree->GetBranch(edm::poolNames::fileFormatVersionBranchName().c_str());
00552   bVer->SetAddress(&pV);
00553   bVer->GetEntry(0);
00554   fileVersion_ = v.value();
00555   return v.value();
00556 }
00557 
00558 bool BranchMapReader::updateEvent(Long_t newevent) {
00559   return strategy_->updateEvent(newevent);
00560 }
00561 
00562 bool BranchMapReader::updateLuminosityBlock(Long_t newlumi) {
00563   return strategy_->updateLuminosityBlock(newlumi);
00564 }
00565 
00566 bool BranchMapReader::updateRun(Long_t newRun) {
00567   return strategy_->updateRun(newRun);
00568 }
00569 
00570 bool BranchMapReader::updateFile(TFile* file) {
00571   if(0 == strategy_.get()) {
00572     strategy_ = newStrategy(file, getFileVersion(file));
00573     return true;
00574   }
00575 
00576   TFile* currentFile(strategy_->currentFile_);
00577   bool isNew(file != currentFile);
00578 
00579   if(!isNew) {
00580     //could still have a new TFile which just happens to share the same memory address as the previous file
00581     //will assume that if the Event tree's address and UUID are the same as before then we do not have
00582     // to treat this like a new file
00583     TTree* eventTreeTemp = dynamic_cast<TTree*>(currentFile->Get(edm::poolNames::eventTreeName().c_str()));
00584     isNew = eventTreeTemp != strategy_->eventTree_ || strategy_->fileUUID_ != currentFile->GetUUID();
00585   }
00586   if(isNew) {
00587     int fileVersion = getFileVersion(file);
00588     if(fileVersion != strategy_->fileVersion_) {
00589       strategy_ = newStrategy(file, fileVersion);
00590     } else {
00591       strategy_->updateFile(file);
00592     }
00593   }
00594   return isNew;
00595 }
00596 
00597 edm::BranchDescription const &
00598 BranchMapReader::productToBranch(edm::ProductID const& pid) {
00599   return strategy_->productToBranch(pid);
00600 }
00601 
00602 std::vector<edm::BranchDescription> const&
00603 BranchMapReader::getBranchDescriptions() {
00604   return strategy_->getBranchDescriptions();
00605 }
00606 
00607 
00608 std::auto_ptr<internal::BMRStrategy>
00609 BranchMapReader::newStrategy(TFile* file, int fileVersion) {
00610   std::auto_ptr<internal::BMRStrategy> s;
00611 
00612   if(fileVersion >= 17) {
00613     s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV17(file, fileVersion));
00614   } else if(fileVersion >= 11) {
00615     s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV11(file, fileVersion));
00616   } else if(fileVersion >= 8) {
00617     s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV8(file, fileVersion));
00618   } else if(fileVersion >= 7) {
00619     s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV7(file, fileVersion));
00620   } else {
00621     s = std::auto_ptr<internal::BMRStrategy>(new internal::BranchMapReaderStrategyV1(file, fileVersion));
00622   }
00623   return s;
00624 }
00625 }