CMS 3D CMS Logo

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