CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/Fireworks/FWInterface/src/FWFFMetadataManager.cc

Go to the documentation of this file.
00001 #include "Fireworks/FWInterface/src/FWFFMetadataManager.h"
00002 #include "Fireworks/FWInterface/src/FWFFMetadataUpdateRequest.h"
00003 #include "Fireworks/Core/interface/fwLog.h"
00004 #include "DataFormats/Provenance/interface/Provenance.h"
00005 #include "DataFormats/Provenance/interface/BranchDescription.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "Fireworks/Core/interface/FWItemAccessorFactory.h"
00008 
00009 #include "TClass.h"
00010 
00011 bool
00012 FWFFMetadataManager::doUpdate(FWJobMetadataUpdateRequest* request)
00013 {
00014    // Clean up previous data.
00015    usableData().clear();
00016 
00017    assert(m_typeAndReps);
00018    FWFFMetadataUpdateRequest *fullRequest = dynamic_cast<FWFFMetadataUpdateRequest*>(request);
00019    if (!fullRequest)
00020       return false;
00021    const edm::Event &event = fullRequest->event();
00022    typedef std::set<std::string> Purposes;
00023    Purposes purposes;
00024    std::vector<edm::Provenance const *> provenances;
00025 
00026    event.getAllProvenance(provenances);
00027 
00028    for (size_t pi = 0, pe = provenances.size(); pi != pe; ++pi)
00029    {
00030       edm::Provenance const *provenance = provenances[pi];
00031       if (!provenance)
00032          continue;
00033       Data d;
00034       const edm::BranchDescription &desc = provenance->branchDescription();
00035 
00036       if (!desc.present())
00037          continue;
00038 
00039       const std::vector<FWRepresentationInfo>& infos
00040          = m_typeAndReps->representationsForType(desc.fullClassName());
00041       
00042       /*
00043       //std::cout <<"try to find match "<<itBranch->fullClassName()<<std::endl;
00044       //For each view we need to find the non-sub-part builder whose proximity is smallest and 
00045       // then register only that purpose
00046       //NOTE: for now, we will ignore the view and only look for the closest proximity
00047       unsigned int minProx = ~(0U);
00048       for (size_t ii = 0, ei = infos.size(); ii != ei; ++ii) {
00049          if (!infos[ii].representsSubPart() && minProx > infos[ii].proximity()) {
00050             minProx = infos[ii].proximity();
00051          }
00052       }
00053        */
00054       
00055       //the infos list can contain multiple items with the same purpose so we will just find
00056       // the unique ones
00057       purposes.clear();
00058       for (size_t ii = 0, ei = infos.size(); ii != ei; ++ii) {
00059         /* if(!infos[ii].representsSubPart() && minProx != infos[ii].proximity()) {
00060             continue;
00061          } */
00062          purposes.insert(infos[ii].purpose());
00063       }
00064       
00065       if (purposes.empty())
00066          purposes.insert("Table");
00067 
00068       for (Purposes::const_iterator itPurpose = purposes.begin(),
00069                                     itEnd = purposes.end();
00070                                     itPurpose != itEnd;
00071                                     ++itPurpose) 
00072       {
00073          // Determine whether or not the class can be iterated
00074          // either by using a TVirtualCollectionProxy (of the class 
00075          // itself or on one of its members), or by using a 
00076          // FWItemAccessor plugin.
00077          TClass* theClass = TClass::GetClass(desc.fullClassName().c_str());
00078          
00079          if (!theClass)
00080             continue;
00081       
00082          if (!theClass->GetTypeInfo())
00083             continue;
00084          
00085          // This is pretty much the same thing that happens 
00086          if (!FWItemAccessorFactory::classAccessedAsCollection(theClass))
00087          {
00088             fwLog(fwlog::kDebug) << theClass->GetName() 
00089                        << " will not be displayed in table." << std::endl;
00090               continue;
00091          }
00092          d.type_ = desc.fullClassName();
00093          d.purpose_ = *itPurpose;
00094          d.moduleLabel_ = desc.moduleLabel();
00095          d.productInstanceLabel_ = desc.productInstanceName();
00096          d.processName_ = desc.processName();
00097          usableData().push_back(d);
00098          fwLog(fwlog::kDebug) << "Add collection will display " << d.type_ 
00099                               << " " << d.moduleLabel_ 
00100                               << " " << d.productInstanceLabel_
00101                               << " " << d.processName_ << std::endl;
00102       }
00103    } 
00104    return true;
00105 }
00106