CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Group.cc
Go to the documentation of this file.
1 /*----------------------------------------------------------------------
2 ----------------------------------------------------------------------*/
8 
9 using Reflex::Type;
10 using Reflex::TypeTemplate;
11 
12 namespace edm {
13 
15 
22 
23  void
25  std::auto_ptr<EDProduct> edp,
26  boost::shared_ptr<ProductProvenance> productProvenance) {
27  if (product()) {
29  << "Attempt to insert more than one product on branch " << groupData().branchDescription()->branchName() << "\n";
30  }
31  assert(branchDescription().produced());
32  assert(edp.get() != 0);
33  assert(!provenance()->productProvenanceResolved());
34  assert(status() != Present);
35  assert(status() != Uninitialized);
36  setProductProvenance(productProvenance);
37  assert(provenance()->productProvenanceResolved());
38  groupData().product_.reset(edp.release()); // Group takes ownership
39  status_() = Present;
40  }
41 
42  void
44  std::auto_ptr<EDProduct> edp,
45  boost::shared_ptr<ProductProvenance> productProvenance) {
46  assert(provenance()->productProvenanceResolved());
47  assert(status() == Present);
48  assert (productProvenancePtr()->productStatus() == productProvenance->productStatus());
49  productProvenancePtr() = productProvenance;
50  mergeTheProduct(edp);
51  }
52 
53  bool
55  return productUnavailable();
56  }
57 
58  void
59  ProducedGroup::mergeProduct_(std::auto_ptr<EDProduct> edp) const {
60  assert(0);
61  }
62 
63  void
64  ProducedGroup::putProduct_(std::auto_ptr<EDProduct> edp) const {
65  assert(0);
66  }
67 
68  void
70  std::auto_ptr<EDProduct> edp,
71  boost::shared_ptr<ProductProvenance> productProvenance) {
72  assert(!product());
73  assert(!provenance()->productProvenanceResolved());
74  setProductProvenance(productProvenance);
75  assert(provenance()->productProvenanceResolved());
76  setProduct(edp);
77  }
78 
79  void
81  std::auto_ptr<EDProduct> edp,
82  boost::shared_ptr<ProductProvenance> productProvenance) {
83  assert(0);
84  }
85 
86  void
87  InputGroup::mergeProduct_(std::auto_ptr<EDProduct> edp) const {
88  mergeTheProduct(edp);
89  }
90 
91  bool
93  return (!product());
94  }
95 
96  void
97  InputGroup::putProduct_(std::auto_ptr<EDProduct> edp) const {
98  assert(!product());
99  setProduct(edp);
100  }
101 
102  void
103  Group::mergeTheProduct(std::auto_ptr<EDProduct> edp) const {
104  if (product()->isMergeable()) {
105  product()->mergeProduct(edp.get());
106  } else if (product()->hasIsProductEqual()) {
107  if (!product()->isProductEqual(edp.get())) {
108  LogError("RunLumiMerging")
109  << "Group::mergeGroup\n"
110  << "Two run/lumi products for the same run/lumi which should be equal are not\n"
111  << "Using the first, ignoring the second\n"
112  << "className = " << branchDescription().className() << "\n"
113  << "moduleLabel = " << moduleLabel() << "\n"
114  << "instance = " << productInstanceName() << "\n"
115  << "process = " << processName() << "\n";
116  }
117  } else {
118  LogWarning("RunLumiMerging")
119  << "Group::mergeGroup\n"
120  << "Run/lumi product has neither a mergeProduct nor isProductEqual function\n"
121  << "Using the first, ignoring the second in merge\n"
122  << "className = " << branchDescription().className() << "\n"
123  << "moduleLabel = " << moduleLabel() << "\n"
124  << "instance = " << productInstanceName() << "\n"
125  << "process = " << processName() << "\n";
126  }
127  }
128 
129  void
131  // Check if the types match.
132  TypeID typeID(prod.dynamicTypeInfo());
133  if (typeID != branchDescription()->typeID()) {
134  // Types do not match.
136  << "Product on branch " << branchDescription()->branchName() << " is of wrong type.\n"
137  << "It is supposed to be of type " << branchDescription()->className() << ".\n"
138  << "It is actually of type " << typeID.className() << ".\n";
139  }
140  }
141 
142  void
143  InputGroup::setProduct(std::auto_ptr<EDProduct> prod) const {
144  assert (!product());
145  if (prod.get() == 0 || !prod->isPresent()) {
147  }
148  groupData().product_.reset(prod.release()); // Group takes ownership
149  }
150 
151  void
152  Group::setProductProvenance(boost::shared_ptr<ProductProvenance> prov) const {
154  }
155 
156  // This routine returns true if it is known that currently there is no real product.
157  // If there is a real product, it returns false.
158  // If it is not known if there is a real product, it returns false.
159  bool
161  if (productIsUnavailable()) {
162  return true;
163  }
164  // If there is a product, we know if it is real or a dummy.
165  if (product()) {
166  bool unavailable = !(product()->isPresent());
167  if (unavailable) {
169  }
170  return unavailable;
171  }
172  return false;
173  }
174 
175  // This routine returns true if it is known that currently there is no real product.
176  // If there is a real product, it returns false.
177  // If it is not known if there is a real product, it returns false.
178  bool
180  // If unscheduled production, the product is potentially available.
181  if (onDemand()) return false;
182  // The product is available if and only if a product has been put.
183  bool unavailable = !(product() && product()->isPresent());
185  assert(unavailable == productstatus::notPresent(status()));
186  return unavailable;
187  }
188 
189  bool
191  // If this product is from a the current process,
192  // the provenance is available if and only if a product has been put.
193  if (branchDescription().produced()) {
194  return product() && product()->isPresent();
195  }
196  // If this product is from a prior process, the provenance is available,
197  // although the per event part may have been dropped.
198  return true;
199  }
200 
201  Type
203  return Type::ByTypeInfo(typeid(*product()));
204  }
205 
206  bool
207  Group::isMatchingSequence(Type const& wantedElementType) const {
209  bool is_sequence = is_sequence_wrapper(productType(), value_type);
210 
211  // If our product is not a sequence, we can't match...
212  if (!is_sequence) return false;
213 
214  Type elementType = value_type; // this is not true for RefVector...
215 
216  TypeTemplate valueTypeTemplate = value_type.TemplateFamily();
217 
218  return (elementType==wantedElementType ||
219  elementType.HasBase(wantedElementType));
220  }
221 
222  void
223  Group::setProvenance(boost::shared_ptr<BranchMapper> mapper, ProductID const& pid) {
224  //assert(!groupData().prov_);
226  groupData().prov_.setStore(mapper);
227  }
228 
229  void
230  Group::setProvenance(boost::shared_ptr<BranchMapper> mapper) {
231  groupData().prov_.setStore(mapper);
232  }
233 
234  Provenance*
236  return &(groupData().prov_);
237  }
238 
239  void
240  Group::write(std::ostream& os) const {
241  // This is grossly inadequate. It is also not critical for the
242  // first pass.
243  os << std::string("Group for product with ID: ")
244  << productID();
245  }
246 }
virtual bool putOrMergeProduct_() const
Definition: Group.cc:92
std::string const & processName() const
Definition: Group.h:102
void setProductUnavailable() const
Definition: Group.h:205
virtual bool putOrMergeProduct_() const
Definition: Group.cc:54
void setProvenance(boost::shared_ptr< BranchMapper > mapper, ProductID const &pid)
Definition: Group.cc:223
virtual GroupData const & groupData() const
Definition: Group.h:222
GroupStatus const & status() const
Definition: Group.h:248
Reflex::Type productType() const
Definition: Group.cc:202
bool is_sequence_wrapper(Reflex::Type const &possible_sequence_wrapper, Reflex::Type &found_sequence_value_type)
virtual ~InputGroup()
Definition: Group.cc:17
bool notPresent(ProductStatus status)
Definition: ProductStatus.h:42
std::type_info const & dynamicTypeInfo() const
Definition: EDProduct.h:35
Provenance prov_
Definition: Group.h:54
void checkType(EDProduct const &prod) const
Definition: Group.cc:130
Container::value_type value_type
Group()
Definition: Group.cc:14
ProductID const & productID() const
Definition: Group.h:129
virtual void mergeProduct_(std::auto_ptr< EDProduct > edp, boost::shared_ptr< ProductProvenance > productProvenance)
Definition: Group.cc:80
virtual ~SourceGroup()
Definition: Group.cc:21
bool isMatchingSequence(Reflex::Type const &wanted) const
Definition: Group.cc:207
bool onDemand() const
Definition: Group.h:78
virtual ~UnscheduledGroup()
Definition: Group.cc:20
virtual bool productUnavailable_() const
Definition: Group.cc:179
boost::shared_ptr< ConstBranchDescription > const & branchDescription() const
Definition: Group.h:36
void setProduct(std::auto_ptr< EDProduct > prod) const
Definition: Group.cc:143
virtual ~Group()
Definition: Group.cc:16
void setStore(boost::shared_ptr< BranchMapper > store) const
Definition: Provenance.h:86
virtual void putProduct_(std::auto_ptr< EDProduct > edp, boost::shared_ptr< ProductProvenance > productProvenance)
Definition: Group.cc:24
std::string const & moduleLabel() const
Definition: Group.h:96
void mergeTheProduct(std::auto_ptr< EDProduct > edp) const
Definition: Group.cc:103
tuple prod
Definition: CrabTask.py:87
boost::shared_ptr< EDProduct > product_
Definition: Group.h:53
virtual ~ProducedGroup()
Definition: Group.cc:18
eventsetup::produce::Produce produced
Definition: ESProducts.cc:21
virtual GroupData const & groupData() const =0
void setProductProvenance(boost::shared_ptr< ProductProvenance > prov) const
Definition: Provenance.h:90
std::string const & className() const
boost::shared_ptr< ProductProvenance > productProvenancePtr() const
Definition: Group.h:84
boost::shared_ptr< EDProduct > product() const
Definition: Group.h:81
void setProductID(ProductID const &pid)
Definition: Provenance.h:94
virtual GroupStatus const & status_() const =0
Provenance * provenance() const
Definition: Group.cc:235
std::string const & productInstanceName() const
Definition: Group.h:99
bool productIsUnavailable() const
Definition: Group.h:204
virtual void putProduct_(std::auto_ptr< EDProduct > edp, boost::shared_ptr< ProductProvenance > productProvenance)
Definition: Group.cc:69
bool provenanceAvailable() const
Definition: Group.cc:190
virtual ~ScheduledGroup()
Definition: Group.cc:19
bool productUnavailable() const
Definition: Group.h:72
void setProductProvenance(boost::shared_ptr< ProductProvenance > prov) const
Definition: Group.cc:152
bool presenceUnknown(ProductStatus status)
Definition: ProductStatus.h:41
ConstBranchDescription const & branchDescription() const
Definition: Group.h:90
virtual void mergeProduct_(std::auto_ptr< EDProduct > edp, boost::shared_ptr< ProductProvenance > productProvenance)
Definition: Group.cc:43
virtual bool productUnavailable_() const
Definition: Group.cc:160
void write(std::ostream &os) const
Definition: Group.cc:240