CMS 3D CMS Logo

FWLiteJobMetadataManager.cc
Go to the documentation of this file.
7 
8 #include "TFile.h"
9 #include "TTree.h"
10 #include <set>
11 
14  m_event(0)
15 {}
16 
17 bool
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 }
30 
31 
37 bool
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();
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 *)
virtual bool hasModuleLabel(std::string &moduleLabel)
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
virtual bool doUpdate(FWJobMetadataUpdateRequest *request)