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

bool doUpdate (FWJobMetadataUpdateRequest *request) override
 
 FWLiteJobMetadataManager (void)
 
bool hasModuleLabel (std::string &moduleLabel) override
 
- 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 12 of file FWLiteJobMetadataManager.h.

Constructor & Destructor Documentation

◆ FWLiteJobMetadataManager()

FWLiteJobMetadataManager::FWLiteJobMetadataManager ( void  )

Definition at line 12 of file FWLiteJobMetadataManager.cc.

12 : FWJobMetadataManager(), m_event(nullptr) {}

Member Function Documentation

◆ doUpdate()

bool FWLiteJobMetadataManager::doUpdate ( FWJobMetadataUpdateRequest request)
overridevirtual

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 30 of file FWLiteJobMetadataManager.cc.

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

References cms::cuda::assert(), cms::cuda::be, MicroEventContent_cff::branch, FWItemAccessorFactory::classAccessedAsCollection(), filterCSVwithJSON::copy, gather_cfg::cout, ztail::d, debug, submitPVResolutionJobs::desc, FWLiteJobMetadataUpdateRequest::event_, geometryDiff::file, FWLiteJobMetadataUpdateRequest::file_, fwLog, fwlite::Event::getBranchDescriptions(), fwlite::Event::getProcessHistory(), cuy::ii, submitPVValidationJobs::infos, fwlog::kDebug, m_event, FWJobMetadataManager::m_typeAndReps, FWJobMetadataManager::processNamesInJob(), hgcalPlots::purpose, FWTypeToRepresentations::representationsForType(), AlCaHLTBitMon_QueryRunRegistry::string, and FWJobMetadataManager::usableData().

◆ hasModuleLabel()

bool FWLiteJobMetadataManager::hasModuleLabel ( std::string &  moduleLabel)
overridevirtual

Implements FWJobMetadataManager.

Definition at line 14 of file FWLiteJobMetadataManager.cc.

14  {
15  if (m_event) {
16  for (auto bit = m_event->getBranchDescriptions().begin(); bit != m_event->getBranchDescriptions().end(); ++bit) {
17  if (bit->moduleLabel() == moduleLabel) {
18  return true;
19  }
20  }
21  }
22  return false;
23 }

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

Member Data Documentation

◆ m_event

const fwlite::Event* FWLiteJobMetadataManager::m_event
private

Definition at line 20 of file FWLiteJobMetadataManager.h.

Referenced by doUpdate(), and hasModuleLabel().

hgcalPlots.purpose
purpose
Definition: hgcalPlots.py:2679
FWJobMetadataManager::processNamesInJob
std::vector< std::string > & processNamesInJob()
Definition: FWJobMetadataManager.h:32
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:174
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::cuda::assert
assert(be >=bs)
FWLiteJobMetadataUpdateRequest
Definition: FWLiteJobMetadataUpdateRequest.h:12
FWItemAccessorFactory::classAccessedAsCollection
static bool classAccessedAsCollection(const TClass *)
Definition: FWItemAccessorFactory.cc:202
debug
#define debug
Definition: HDRShower.cc:19
fwlite::Event::getBranchDescriptions
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: Event.h:157
geometryDiff.file
file
Definition: geometryDiff.py:13
FWTypeToRepresentations::representationsForType
const std::vector< FWRepresentationInfo > & representationsForType(const std::string &iTypeName) const
Definition: FWTypeToRepresentations.cc:81
FWLiteJobMetadataManager::m_event
const fwlite::Event * m_event
Definition: FWLiteJobMetadataManager.h:20
fwlite::Event::getProcessHistory
std::vector< std::string > const & getProcessHistory() const
Definition: Event.cc:272
FWLiteJobMetadataUpdateRequest::file_
const TFile * file_
Definition: FWLiteJobMetadataUpdateRequest.h:17
FWJobMetadataManager::m_typeAndReps
FWTypeToRepresentations * m_typeAndReps
Definition: FWJobMetadataManager.h:65
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
fwlog::kDebug
Definition: fwLog.h:35
FWJobMetadataManager::usableData
std::vector< Data > & usableData()
Definition: FWJobMetadataManager.h:31
edm::BranchDescription
Definition: BranchDescription.h:32
ztail.d
d
Definition: ztail.py:151
cms::cuda::be
int be
Definition: HistoContainer.h:75
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
cuy.ii
ii
Definition: cuy.py:589
submitPVValidationJobs.infos
dictionary infos
Definition: submitPVValidationJobs.py:221
FWLiteJobMetadataUpdateRequest::event_
const fwlite::Event * event_
Definition: FWLiteJobMetadataUpdateRequest.h:16
FWJobMetadataManager::FWJobMetadataManager
FWJobMetadataManager()
Definition: FWJobMetadataManager.cc:5