CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
FWLiteJobMetadataManager Class Reference

#include <FWLiteJobMetadataManager.h>

Inheritance diagram for FWLiteJobMetadataManager:
FWJobMetadataManager

Public Member Functions

virtual bool doUpdate (FWJobMetadataUpdateRequest *request)
 
 FWLiteJobMetadataManager (void)
 
virtual bool hasModuleLabel (std::string &moduleLabel)
 
- Public Member Functions inherited from FWJobMetadataManager
 FWJobMetadataManager ()
 
void initReps (const FWTypeToRepresentations &iTypeAndReps)
 
std::vector< std::string > & processNamesInJob ()
 
void update (FWJobMetadataUpdateRequest *request)
 
std::vector< Data > & usableData ()
 
virtual ~FWJobMetadataManager ()
 

Private Attributes

const fwlite::Eventm_event
 

Additional Inherited Members

- Public Attributes inherited from FWJobMetadataManager
sigc::signal< void > metadataChanged_
 
- Protected Attributes inherited from FWJobMetadataManager
std::vector< Datam_metadata
 
std::vector< std::string > m_processNamesInJob
 
FWTypeToRepresentationsm_typeAndReps
 

Detailed Description

Definition at line 13 of file FWLiteJobMetadataManager.h.

Constructor & Destructor Documentation

FWLiteJobMetadataManager::FWLiteJobMetadataManager ( void  )

Definition at line 12 of file FWLiteJobMetadataManager.cc.

14  m_event(0)
15 {}

Member Function Documentation

bool FWLiteJobMetadataManager::doUpdate ( FWJobMetadataUpdateRequest request)
virtual

This method inspects the currently opened TFile and for each branch containing products for which we can either build a TCollectionProxy or for which we have a specialized accessor, it registers it as a viewable item.

Implements FWJobMetadataManager.

Definition at line 38 of file FWLiteJobMetadataManager.cc.

References edm::BranchDescription::branchName(), FWItemAccessorFactory::classAccessedAsCollection(), popcon2dropbox::copy(), gather_cfg::cout, edmIntegrityCheck::d, debug, FWLiteJobMetadataUpdateRequest::event_, FrontierConditions_GlobalTag_cff::file, FWLiteJobMetadataUpdateRequest::file_, edm::BranchDescription::fullClassName(), fwLog, fwlite::Event::getBranchDescriptions(), fwlite::Event::getProcessHistory(), cuy::ii, benchmark_cfg::infos, fwlog::kDebug, m_event, FWJobMetadataManager::m_typeAndReps, edm::BranchDescription::moduleLabel(), FWJobMetadataManager::Data::moduleLabel_, edm::BranchDescription::present(), edm::BranchDescription::processName(), FWJobMetadataManager::Data::processName_, FWJobMetadataManager::processNamesInJob(), FWJobMetadataManager::Data::productInstanceLabel_, edm::BranchDescription::productInstanceName(), trackingPlots::purpose, FWJobMetadataManager::Data::purpose_, FWTypeToRepresentations::representationsForType(), AlCaHLTBitMon_QueryRunRegistry::string, FWJobMetadataManager::Data::type_, and FWJobMetadataManager::usableData().

39 {
40  FWLiteJobMetadataUpdateRequest *liteRequest
41  = dynamic_cast<FWLiteJobMetadataUpdateRequest *>(request);
42  // There is no way we are going to get a non-FWLite updated request for
43  // this class.
44  assert(liteRequest);
45  if (m_event == liteRequest->event_)
46  return false;
47 
48  m_event = liteRequest->event_;
49  const TFile *file = liteRequest->file_;
50 
51  assert(file);
52 
53  usableData().clear();
54 
55  if (!m_event)
56  return true;
57 
58  const std::vector<std::string>& history = m_event->getProcessHistory();
59 
60  // Turns out, in the online system we do sometimes gets files without any
61  // history, this really should be investigated
62  if (history.empty())
63  std::cout << "WARNING: the file '"
64  << file->GetName() << "' contains no processing history"
65  " and therefore should have no accessible data.\n";
66 
67  std::copy(history.rbegin(),history.rend(),
68  std::back_inserter(processNamesInJob()));
69 
70  static const std::string s_blank;
71  const std::vector<edm::BranchDescription>& descriptions =
73 
74  Data d;
75 
76  //I'm not going to modify TFile but I need to see what it is holding
77  TTree* eventsTree = dynamic_cast<TTree*>(const_cast<TFile*>(file)->Get("Events"));
78  assert(eventsTree);
79 
80  std::set<std::string> branchNamesInFile;
81  TIter nextBranch(eventsTree->GetListOfBranches());
82  while(TBranch* branch = static_cast<TBranch*>(nextBranch()))
83  branchNamesInFile.insert(branch->GetName());
84 
85  typedef std::set<std::string> Purposes;
86  Purposes purposes;
87  std::string classType;
88 
89  for(size_t bi = 0, be = descriptions.size(); bi != be; ++bi)
90  {
91  const edm::BranchDescription &desc = descriptions[bi];
92 
93  if (!desc.present()
94  || branchNamesInFile.end() == branchNamesInFile.find(desc.branchName()))
95  continue;
96 
97  const std::vector<FWRepresentationInfo>& infos
99 
100  /*
101  //std::cout <<"try to find match "<<itBranch->fullClassName()<<std::endl;
102  //For each view we need to find the non-sub-part builder whose proximity is smallest and
103  // then register only that purpose
104  //NOTE: for now, we will ignore the view and only look for the closest proximity
105  unsigned int minProx = ~(0U);
106  for (size_t ii = 0, ei = infos.size(); ii != ei; ++ii) {
107  if (!infos[ii].representsSubPart() && minProx > infos[ii].proximity()) {
108  minProx = infos[ii].proximity();
109  }
110  }
111  */
112 
113  //the infos list can contain multiple items with the same purpose so we will just find
114  // the unique ones
115  purposes.clear();
116  for (size_t ii = 0, ei = infos.size(); ii != ei; ++ii) {
117  /* if(!infos[ii].representsSubPart() && minProx != infos[ii].proximity()) {
118  continue;
119  } */
120  if (infos[ii].requiresFF() == false) {
121  purposes.insert(infos[ii].purpose());
122  }
123  }
124 
125  if (purposes.empty())
126  purposes.insert("Table");
127 
128  for (Purposes::const_iterator itPurpose = purposes.begin(),
129  itEnd = purposes.end();
130  itPurpose != itEnd;
131  ++itPurpose)
132  {
133  // Determine whether or not the class can be iterated
134  // either by using a TVirtualCollectionProxy (of the class
135  // itself or on one of its members), or by using a
136  // FWItemAccessor plugin.
137  TClass* theClass = TClass::GetClass(desc.fullClassName().c_str());
138 
139  if (!theClass)
140  continue;
141 
142  if (!theClass->GetTypeInfo())
143  continue;
144 
145  const static bool debug = false;
146  // This is pretty much the same thing that happens
148  {
149  if (debug) {
150  fwLog(fwlog::kDebug) << theClass->GetName()
151  << " will not be displayed in table." << std::endl;
152  }
153  continue;
154  }
155  d.type_ = desc.fullClassName();
156  d.purpose_ = *itPurpose;
157  d.moduleLabel_ = desc.moduleLabel();
158  d.productInstanceLabel_ = desc.productInstanceName();
159  d.processName_ = desc.processName();
160  usableData().push_back(d);
161  if (debug)
162  {
163  fwLog(fwlog::kDebug) << "Add collection will display " << d.type_
164  << " " << d.moduleLabel_
165  << " " << d.productInstanceLabel_
166  << " " << d.processName_ << std::endl;
167  }
168  }
169  }
170  return true;
171 }
std::string const & branchName() const
static bool classAccessedAsCollection(const TClass *)
const std::vector< FWRepresentationInfo > & representationsForType(const std::string &iTypeName) const
std::vector< std::string > & processNamesInJob()
std::string const & processName() const
std::string const & moduleLabel() const
std::string const & productInstanceName() const
std::vector< Data > & usableData()
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: Event.h:137
std::vector< std::string > const & getProcessHistory() const
Definition: Event.cc:290
std::string const & fullClassName() const
ii
Definition: cuy.py:588
#define debug
Definition: HDRShower.cc:19
#define fwLog(_level_)
Definition: fwLog.h:50
FWTypeToRepresentations * m_typeAndReps
bool FWLiteJobMetadataManager::hasModuleLabel ( std::string &  moduleLabel)
virtual

Implements FWJobMetadataManager.

Definition at line 18 of file FWLiteJobMetadataManager.cc.

References fwlite::Event::getBranchDescriptions(), and m_event.

19 {
20  if (m_event) {
21  for ( auto bit = m_event->getBranchDescriptions().begin(); bit != m_event->getBranchDescriptions().end(); ++bit)
22  {
23  if (bit->moduleLabel() == moduleLabel) {
24  return true;
25  }
26  }
27  }
28  return false;
29 }
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: Event.h:137

Member Data Documentation

const fwlite::Event* FWLiteJobMetadataManager::m_event
private

Definition at line 22 of file FWLiteJobMetadataManager.h.

Referenced by doUpdate(), and hasModuleLabel().