test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
22 bool
24 {
25  FWLiteJobMetadataUpdateRequest *liteRequest
26  = dynamic_cast<FWLiteJobMetadataUpdateRequest *>(request);
27  // There is no way we are going to get a non-FWLite updated request for
28  // this class.
29  assert(liteRequest);
30  if (m_event == liteRequest->event_)
31  return false;
32 
33  m_event = liteRequest->event_;
34  const TFile *file = liteRequest->file_;
35 
36  assert(file);
37 
38  usableData().clear();
39 
40  if (!m_event)
41  return true;
42 
43  const std::vector<std::string>& history = m_event->getProcessHistory();
44 
45  // Turns out, in the online system we do sometimes gets files without any
46  // history, this really should be investigated
47  if (history.empty())
48  std::cout << "WARNING: the file '"
49  << file->GetName() << "' contains no processing history"
50  " and therefore should have no accessible data.\n";
51 
52  std::copy(history.rbegin(),history.rend(),
53  std::back_inserter(processNamesInJob()));
54 
55  static const std::string s_blank;
56  const std::vector<edm::BranchDescription>& descriptions =
58 
59  Data d;
60 
61  //I'm not going to modify TFile but I need to see what it is holding
62  TTree* eventsTree = dynamic_cast<TTree*>(const_cast<TFile*>(file)->Get("Events"));
63  assert(eventsTree);
64 
65  std::set<std::string> branchNamesInFile;
66  TIter nextBranch(eventsTree->GetListOfBranches());
67  while(TBranch* branch = static_cast<TBranch*>(nextBranch()))
68  branchNamesInFile.insert(branch->GetName());
69 
70  typedef std::set<std::string> Purposes;
71  Purposes purposes;
72  std::string classType;
73 
74  for(size_t bi = 0, be = descriptions.size(); bi != be; ++bi)
75  {
76  const edm::BranchDescription &desc = descriptions[bi];
77 
78  if (!desc.present()
79  || branchNamesInFile.end() == branchNamesInFile.find(desc.branchName()))
80  continue;
81 
82  const std::vector<FWRepresentationInfo>& infos
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(),
114  itEnd = purposes.end();
115  itPurpose != itEnd;
116  ++itPurpose)
117  {
118  // Determine whether or not the class can be iterated
119  // either by using a TVirtualCollectionProxy (of the class
120  // itself or on one of its members), or by using a
121  // FWItemAccessor plugin.
122  TClass* theClass = TClass::GetClass(desc.fullClassName().c_str());
123 
124  if (!theClass)
125  continue;
126 
127  if (!theClass->GetTypeInfo())
128  continue;
129 
130  const static bool debug = false;
131  // This is pretty much the same thing that happens
133  {
134  if (debug) {
135  fwLog(fwlog::kDebug) << theClass->GetName()
136  << " will not be displayed in table." << std::endl;
137  }
138  continue;
139  }
140  d.type_ = desc.fullClassName();
141  d.purpose_ = *itPurpose;
142  d.moduleLabel_ = desc.moduleLabel();
144  d.processName_ = desc.processName();
145  usableData().push_back(d);
146  if (debug)
147  {
148  fwLog(fwlog::kDebug) << "Add collection will display " << d.type_
149  << " " << d.moduleLabel_
150  << " " << d.productInstanceLabel_
151  << " " << d.processName_ << std::endl;
152  }
153  }
154  }
155  return true;
156 }
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
int ii
Definition: cuy.py:588
std::string const & moduleLabel() const
std::string const & productInstanceName() const
std::vector< Data > & usableData()
std::vector< edm::BranchDescription > const & getBranchDescriptions() const
Definition: Event.h:140
std::vector< std::string > const & getProcessHistory() const
Definition: Event.cc:263
std::string const & fullClassName() const
#define debug
Definition: HDRShower.cc:19
#define fwLog(_level_)
Definition: fwLog.h:50
FWTypeToRepresentations * m_typeAndReps
tuple cout
Definition: gather_cfg.py:121
virtual bool doUpdate(FWJobMetadataUpdateRequest *request)