CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Run.h
Go to the documentation of this file.
1 #ifndef Framework_Run_h
2 #define Framework_Run_h
3 
4 // -*- C++ -*-
5 //
6 // Package: Framework
7 // Class : Run
8 //
16 /*----------------------------------------------------------------------
17 
18 ----------------------------------------------------------------------*/
19 
24 
25 #include <memory>
26 #include <set>
27 #include <string>
28 #include <typeinfo>
29 #include <vector>
30 
31 namespace edm {
32 
33  class Run : public RunBase {
34  public:
35  Run(RunPrincipal& rp, ModuleDescription const& md);
36  ~Run();
37 
39  // AUX functions are defined in RunBase
40  RunAuxiliary const& runAuxiliary() const {return aux_;}
41  // AUX functions.
42 // RunID const& id() const {return aux_.id();}
43 // RunNumber_t run() const {return aux_.run();}
44 // Timestamp const& beginTime() const {return aux_.beginTime();}
45 // Timestamp const& endTime() const {return aux_.endTime();}
46 
47  template <typename PROD>
48  bool
49  get(SelectorBase const&, Handle<PROD>& result) const;
50 
51  template <typename PROD>
52  bool
53  getByLabel(std::string const& label, Handle<PROD>& result) const;
54 
55  template <typename PROD>
56  bool
57  getByLabel(std::string const& label,
58  std::string const& productInstanceName,
59  Handle<PROD>& result) const;
60 
62  template <typename PROD>
63  bool
64  getByLabel(InputTag const& tag, Handle<PROD>& result) const;
65 
66  template <typename PROD>
67  void
68  getMany(SelectorBase const&, std::vector<Handle<PROD> >& results) const;
69 
70  template <typename PROD>
71  bool
73 
74  template <typename PROD>
75  void
76  getManyByType(std::vector<Handle<PROD> >& results) const;
77 
79  template <typename PROD>
80  void
81  put(std::auto_ptr<PROD> product) {put<PROD>(product, std::string());}
82 
84  template <typename PROD>
85  void
86  put(std::auto_ptr<PROD> product, std::string const& productInstanceName);
87 
89  getProvenance(BranchID const& theID) const;
90 
91  void
92  getAllProvenance(std::vector<Provenance const*>& provenances) const;
93 
94  // Return true if this Run has been subjected to a process with
95  // the given processName, and false otherwise.
96  // If true is returned, then ps is filled with the ParameterSets
97  // (possibly more than one) used to configure the identified
98  // process(es). Equivalent ParameterSets are compressed out of the
99  // result.
100  // This function is not yet implemented in full.
101  //bool
102  //getProcessParameterSet(std::string const& processName, std::vector<ParameterSet>& ps) const;
103 
104  ProcessHistoryID const& processHistoryID() const;
105 
106  ProcessHistory const&
107  processHistory() const;
108 
109  private:
110  RunPrincipal const&
111  runPrincipal() const;
112 
113  RunPrincipal&
114  runPrincipal();
115 
116  // Override version from RunBase class
117  virtual BasicHandle getByLabelImpl(std::type_info const& iWrapperType, std::type_info const& iProductType, InputTag const& iTag) const;
118 
119  typedef std::vector<std::pair<WrapperOwningHolder, ConstBranchDescription const*> > ProductPtrVec;
121  ProductPtrVec const& putProducts() const {return putProducts_;}
122 
123  // commit_() is called to complete the transaction represented by
124  // this PrincipalGetAdapter. The friendships required seems gross, but any
125  // alternative is not great either. Putting it into the
126  // public interface is asking for trouble
128  friend class DaqSource;
129  friend class InputSource;
130  friend class RawInputSource;
131  friend class EDFilter;
132  friend class EDProducer;
133 
134  void commit_();
135  void addToGotBranchIDs(Provenance const& prov) const;
136 
140  typedef std::set<BranchID> BranchIDSet;
142  };
143 
144  template <typename PROD>
145  void
146  Run::put(std::auto_ptr<PROD> product, std::string const& productInstanceName) {
147  if (product.get() == 0) { // null pointer is illegal
148  TypeID typeID(typeid(PROD));
149  principal_get_adapter_detail::throwOnPutOfNullProduct("Run", typeID, productInstanceName);
150  }
151 
152  // The following will call post_insert if T has such a function,
153  // and do nothing if T has no such function.
156  DoNotPostInsert<PROD> >::type maybe_inserter;
157  maybe_inserter(product.get());
158 
159  ConstBranchDescription const& desc =
160  provRecorder_.getBranchDescription(TypeID(*product), productInstanceName);
161 
163  putProducts().push_back(std::make_pair(edp, &desc));
164 
165  // product.release(); // The object has been copied into the Wrapper.
166  // The old copy must be deleted, so we cannot release ownership.
167  }
168 
169  template <typename PROD>
170  bool
172  return provRecorder_.get(sel, result);
173  }
174 
175  template <typename PROD>
176  bool
177  Run::getByLabel(std::string const& label, Handle<PROD>& result) const {
178  return provRecorder_.getByLabel(label, result);
179  }
180 
181  template <typename PROD>
182  bool
183  Run::getByLabel(std::string const& label,
184  std::string const& productInstanceName,
185  Handle<PROD>& result) const {
186  return provRecorder_.getByLabel(label, productInstanceName, result);
187  }
188 
190  template <typename PROD>
191  bool
193  return provRecorder_.getByLabel(tag, result);
194  }
195 
196  template <typename PROD>
197  void
198  Run::getMany(SelectorBase const& sel, std::vector<Handle<PROD> >& results) const {
199  return provRecorder_.getMany(sel, results);
200  }
201 
202  template <typename PROD>
203  bool
205  return provRecorder_.getByType(result);
206  }
207 
208  template <typename PROD>
209  void
210  Run::getManyByType(std::vector<Handle<PROD> >& results) const {
212  }
213 
214 }
215 #endif
type
Definition: HCALResponse.h:22
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:177
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Provenance getProvenance(BranchID const &theID) const
Definition: Run.cc:30
ProductPtrVec putProducts_
Definition: Run.h:138
ProductPtrVec const & putProducts() const
Definition: Run.h:121
void getMany(SelectorBase const &, std::vector< Handle< PROD > > &results) const
Definition: Run.h:198
RunAuxiliary const & aux_
Definition: Run.h:139
Definition: Hash.h:41
PrincipalGetAdapter Base
Definition: Run.h:38
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Run.cc:35
void getManyByType(std::vector< Handle< PROD > > &results) const
Run(RunPrincipal &rp, ModuleDescription const &md)
Definition: Run.cc:8
std::vector< std::pair< WrapperOwningHolder, ConstBranchDescription const * > > ProductPtrVec
Definition: Run.h:119
tuple result
Definition: query.py:137
void commit_()
Definition: Run.cc:77
ProcessHistory const & processHistory() const
Definition: Run.cc:99
bool get(SelectorBase const &, Handle< PROD > &result) const
Definition: Run.h:171
void getMany(SelectorBase const &, std::vector< Handle< PROD > > &results) const
ProcessHistoryID const & processHistoryID() const
Definition: Run.cc:94
bool getByType(Handle< PROD > &result) const
Definition: Run.h:204
RunPrincipal const & runPrincipal() const
Definition: Run.cc:25
~Run()
Definition: Run.cc:13
bool get(SelectorBase const &, Handle< PROD > &result) const
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Run.h:210
virtual BasicHandle getByLabelImpl(std::type_info const &iWrapperType, std::type_info const &iProductType, InputTag const &iTag) const
Definition: Run.cc:109
ProductPtrVec & putProducts()
Definition: Run.h:120
void addToGotBranchIDs(Provenance const &prov) const
Definition: Run.cc:104
RunAuxiliary const & runAuxiliary() const
Definition: Run.h:40
#define PROD(A, B)
void put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Run.h:81
std::set< BranchID > BranchIDSet
Definition: Run.h:140
void throwOnPutOfNullProduct(char const *principalType, TypeID const &productType, std::string const &productInstanceName)
ConstBranchDescription const & getBranchDescription(TypeID const &type, std::string const &productInstanceName) const
BranchIDSet gotBranchIDs_
Definition: Run.h:141
Definition: Run.h:33
PrincipalGetAdapter provRecorder_
Definition: Run.h:137
bool getByType(Handle< PROD > &result) const