LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ShowerProducedPtrsHolder.hh
Go to the documentation of this file.
1 //###################################################################
2 //### Name: ShowerProducedPtrsHolder ###
3 //### Author: Dominic Barker ###
4 //### Date: 15.07.19 ###
5 //### Description: Class to holder the unique ptrs required to ###
6 //### produce data products. Used in ###
7 //### LArPandoraModularShower and corresponding ###
8 //### tools. ###
9 //###################################################################
10 
11 #ifndef ShowerProducedPtrsHolder_HH
12 #define ShowerProducedPtrsHolder_HH
13 
15 
16 //Framework includes
21 #include "cetlib_except/demangle.h"
22 #include "cetlib_except/exception.h"
24 
25 namespace reco::shower {
26  class ShowerUniqueProduerPtrBase;
27  template <class T>
29  template <class T>
31  class ShowerPtrMakerBase;
32  template <class T>
35 }
36 
37 #include <iomanip>
38 #include <iostream>
39 #include <map>
40 #include <string>
41 #include <utility> // std::move()
42 #include <vector>
43 
44 //Template to check if its an assn
45 template <class N>
46 struct is_assn {
47  static const int value = 0;
48 };
49 
50 template <class L, class R, class D>
51 struct is_assn<art::Assns<L, R, D>> {
52  static const int value = 1;
53 };
54 
55 //Template to carry the type becuase functions can't, annoyingly, be partially specialised
56 template <typename T>
57 struct type {};
58 
59 //Base class for the class that holds the ptr.
61 
62 public:
63  virtual ~ShowerUniqueProduerPtrBase() noexcept = default;
64 
65  virtual void reset() = 0;
66 
67  virtual void AddDataProduct(const reco::shower::ShowerElementHolder& selement_holder,
68  const std::string& Name) = 0;
69 
70  virtual void MoveToEvent(art::Event& evt) = 0;
71 
72  virtual std::string GetType() const = 0;
73  virtual std::string GetInstanceName() const = 0;
74 
75  virtual int GetVectorPtrSize() const { return -1; }
76 };
77 
78 //Class that holds a unique ptr for the product. This is what is stored in the map. The product is put into
79 //the event as a vector so the this holder maintains this unique ptr and the actions to manipulate it.
80 template <class T>
83 
84 public:
85  ShowerUniqueProductPtr<std::vector<T>>(const std::string& Instancename)
86  {
87  ptr = 1;
88  showeruniqueptr = std::make_unique<std::vector<T>>();
89  InstanceName = Instancename;
90  }
91 
92  //Get the unique ptr for the data product.
93  std::unique_ptr<T>& GetPtr()
94  {
95  if (ptr) { return showeruniqueptr; }
96  else {
97  throw cet::exception("ShowerUniqueProduerPtr") << "Element does not exist" << std::endl;
98  }
99  }
100 
101  void reset() override { showeruniqueptr.reset(new std::vector<T>()); }
102 
103  //Add a data product on to the vector that will be added to the event.
105  const std::string& Name) override
106  {
107  T product;
108  if (!selement_holder.CheckElement(Name)) {
109  mf::LogError("ShowerProducedPtrsHolder")
110  << "Trying to add data product: " << Name
111  << ". This element does not exist in the element holder" << std::endl;
112  return;
113  }
114 
115  int err = selement_holder.GetElement(Name, product);
116  if (err) {
117  mf::LogError("ShowerProducedPtrsHolder")
118  << "Trying to add data product: " << Name
119  << ". This element does not exist in the element holder" << std::endl;
120  return;
121  }
122  showeruniqueptr->push_back(product);
123  return;
124  }
125 
126  //Final thing to do move to the event.
127  void MoveToEvent(art::Event& evt) override { evt.put(std::move(showeruniqueptr), InstanceName); }
128 
129  //This returns the type of the undrlying element. It should be of the form std::unique_ptr<std::vector<T> >
130  std::string GetType() const override
131  {
132  return cet::demangle_symbol(typeid(showeruniqueptr.get()).name());
133  }
134 
135  //A user can set the instances name like an other producer module product. Get it using this.
136  std::string GetInstanceName() const override { return InstanceName; }
137 
138  //Get the size of the std::vector. Usful for making assns.
139  int GetVectorPtrSize() const override { return showeruniqueptr->size(); }
140 
141 private:
142  //Element itself that is put into the art event.
143  std::unique_ptr<std::vector<T>> showeruniqueptr;
144 
145  //bool to see if the element is set.
146  bool ptr;
147 
148  //Name when saved into the the event default is ""
149  std::string InstanceName;
150 };
151 
152 //Class that holds a unique ptr for the association. This is what is stored in the map. The association is put into
153 //the event as a vector so the this holder maintains this unique ptr and the actions to manipulate it.
154 //I guess if the product if a product is unique to the event then this holder will deal with it.
155 //I have tried to be smart and I don't think it not being an association is a problem as
156 //long as the user is smart.
157 template <class T>
159 
160 public:
161  ShowerUniqueAssnPtr(const std::string& Instancename)
162  {
163  ptr = 1;
164  showeruniqueptr = std::make_unique<T>();
165  InstanceName = Instancename;
166  }
167 
168  //Get the ptr to the association.
169  std::unique_ptr<T>& GetPtr()
170  {
171  if (ptr) { return showeruniqueptr; }
172  else {
173  throw cet::exception("ShowerUniqueAssnPtr") << "Element does not exist" << std::endl;
174  }
175  }
176 
177  void reset() override { showeruniqueptr.reset(new T()); }
178 
179  //place the association to the event.
180  void MoveToEvent(art::Event& evt) override { evt.put(std::move(showeruniqueptr), InstanceName); }
181 
182  //Not need but the compiler complains if its not here.
184  const std::string& Name) override
185  {
186  throw cet::exception("ShowerUniqueAssnPtr")
187  << "The creator of this code has failed you. Please contact Dominic Bakrer" << std::endl;
188  }
189 
190  //Get the type in form as a string. It should be the form of std::unique_ptr<art::Assn<T A, T1 B> >
191  std::string GetType() const override
192  {
193  return cet::demangle_symbol(typeid(showeruniqueptr.get()).name());
194  }
195 
196  //Get the Instance name that product will be saved as in the art::Event.
197  std::string GetInstanceName() const override { return InstanceName; }
198 
199 private:
200  //Actual Element the assn. This is put into the event.
201  std::unique_ptr<T> showeruniqueptr;
202 
203  //bool to see if the element is filled.
204  bool ptr;
205 
206  //Name when saved into the the event default is ""
207  std::string InstanceName;
208 };
209 
210 //Base class to hold the pointer makers. This interacts the with the module a little differently
211 //as the ptr makers do not work within the tools. The holds and the ptrmaker and provides set and
212 //get functions so that the usr can access art::Ptrs for the products of the module and associate
213 //them to other things.
215 
216 public:
217  virtual ~ShowerPtrMakerBase() noexcept = default;
218 
219  virtual bool CheckPtrMaker() const = 0;
220 
221  virtual void SetPtrMaker(art::Event& evt) = 0;
222 
223  virtual void Reset() = 0;
224 };
225 
226 //Derived class - See above
227 template <class T>
229 
230 public:
231  ShowerPtrMaker(const std::string& Instancename)
232  {
233  ptrmaker = nullptr;
234  ptr = 0;
235  InstanceName = Instancename;
236  }
237 
238  //Check the ptr maker is ready to be used.
239  bool CheckPtrMaker() const override
240  {
241  if (ptr) { return true; }
242  return false;
243  }
244 
245  //Return the ptr maker. Probably never needed.
247  {
248  if (ptr) {
249  if (ptrmaker == nullptr) {
250  throw cet::exception("ShowerPtrMaker") << "Ptr maker ptr is null" << std::endl;
251  }
252  return *ptrmaker;
253  }
254  throw cet::exception("ShowerPtrMaker")
255  << "Trying to get a ptrmaker that does not exists" << std::endl;
256  }
257 
258  //Return the art ptr that the module produces corresponding the index iter
259  art::Ptr<T> GetArtPtr(int iter) const
260  {
261  if (ptr) {
262  if (ptrmaker == nullptr) {
263  throw cet::exception("ShowerPtrMaker") << "Ptr maker ptr is null" << std::endl;
264  }
265  return (*ptrmaker)(iter);
266  }
267  throw cet::exception("ShowerPtrMaker")
268  << "Trying to get a ptrmaker that does not exists" << std::endl;
269  }
270 
271  //Set the ptr maker this is reset at the start of the event.
272  void SetPtrMaker(art::Event& evt) override
273  {
274  ptrmaker.reset(new art::PtrMaker<T>(evt, InstanceName));
275  ptr = 1;
276  }
277 
278  void Reset() override
279  {
280  if (!ptr) {
281  throw cet::exception("ShowerPtrMaker") << "Trying to reset ptr but it has not been set in "
282  "the first place. Please contatc Dom Barker"
283  << std::endl;
284  }
285  ptrmaker.reset(nullptr);
286  ptr = 0;
287  }
288 
289 private:
290  //The ptr maker itself. Used to make art::Ptrs to make assns.
291  std::unique_ptr<art::PtrMaker<T>> ptrmaker;
292 
293  //The name of the data product which will be saved in the event. The ptr maker requires this.
294  std::string InstanceName;
295 
296  //bool to tell if the ptr maker is ready to use or not.
297  int ptr;
298 };
299 
300 //Class that holds all the unique ptrs and the ptr makers. It is what the tools and module use
301 //to access the above class elements. The end user case will see the user not interact with this
302 // directly.
304 
305 public:
306  //Initialise the a unique ptr in the map. This will be added to the event.
307  template <class T>
308  int SetShowerUniqueProduerPtr(type<T>, const std::string& Name, const std::string& Instance = "")
309  {
310 
311  //Add to the assns
312  if (showerassnPtrs.find(Name) != showerassnPtrs.end()) {
313  mf::LogWarning("ShowerProducedPtrsHolder")
314  << "Trying to set Element: " << Name << ". This element has already been set. Please check."
315  << std::endl;
316  return 1;
317  }
318 
319  //Check the same type has not already been set.
320  if (!CheckForMultipleTypes(type<T>(), Name, Instance)) {
321  throw cet::exception("ShowerProducedPtrsHolder")
322  << "Trying to set multiple objects with same type with no instance name or same instance "
323  "name"
324  << std::endl;
325  }
326 
327  showerassnPtrs[Name] = std::make_unique<ShowerUniqueAssnPtr<T>>(Instance);
328  return 0;
329  }
330 
331  //Set the unique ptr. The unique ptr will be filled into the event.
332  template <class T>
333  int SetShowerUniqueProduerPtr(type<std::vector<T>>,
334  const std::string& Name,
335  const std::string& Instance = "")
336  {
337 
338  //Then add the products
339  if (showerproductPtrs.find(Name) != showerproductPtrs.end()) {
340  mf::LogWarning("ShowerProducedPtrsHolder")
341  << "Trying to set Element: " << Name << ". This element has already been set. Please check."
342  << std::endl;
343  return 1;
344  }
345 
346  //Check the same type has not already been set.
347  if (!CheckForMultipleTypes(type<std::vector<T>>(), Name, Instance)) {
348  throw cet::exception("ShowerProducedPtrsHolder")
349  << "Trying to set multiple objects with same type with no instance name or same instance "
350  "name"
351  << std::endl;
352  }
353 
354  if (showerPtrMakers.find(Name) != showerPtrMakers.end()) {
355  throw cet::exception("ShowerProducedPtrsHolder")
356  << "PtrMaker already exist. It should not be set again" << std::endl;
357  }
358  showerPtrMakers[Name] = std::make_unique<ShowerPtrMaker<T>>(Instance);
359  showerproductPtrs[Name] = std::make_unique<ShowerUniqueProductPtr<std::vector<T>>>(Instance);
360  return 0;
361  }
362 
363  //Checks if the ptr exists
364  bool CheckUniqueProduerPtr(const std::string& Name) const
365  {
366  if (showerproductPtrs.find(Name) != showerproductPtrs.end()) { return true; }
367  if (showerassnPtrs.find(Name) != showerassnPtrs.end()) { return true; }
368  return false;
369  }
370 
371  //Reset the ptrs;
372  void reset()
373  {
374  for (auto const& showerptr : showerproductPtrs) {
375  (showerptr.second)->reset();
376  }
377  for (auto const& showerptr : showerassnPtrs) {
378  (showerptr.second)->reset();
379  }
380  }
381 
382  //Add any data products that are produced by the module to the unique ptr it corresponds to
383  //This is done by matching strings in the element holder and the ptr holder. Hence these
384  //must match. This is a global command done in the module.
386  {
387  for (auto const& showerproductPtr : showerproductPtrs) {
388  (showerproductPtr.second)->AddDataProduct(selement_holder, showerproductPtr.first);
389  }
390  }
391 
392  //Global command to move all products into the event. This is done in the module.
394  {
395  for (auto const& showerproductPtr : showerproductPtrs) {
396  (showerproductPtr.second)->MoveToEvent(evt);
397  }
398  for (auto const& showerassnPtr : showerassnPtrs) {
399  (showerassnPtr.second)->MoveToEvent(evt);
400  }
401  }
402 
404  {
405  bool checked = true;
406  for (auto const& showerproductPtr : showerproductPtrs) {
407  if (showerproductPtr.first == "shower") { continue; }
408  checked = checked && selement_holder.CheckElement(showerproductPtr.first);
409  }
410  return checked;
411  }
412 
413  //This returns the unique ptr. This is a legacy code.
414  template <class T>
415  T& GetPtr(const std::string& Name)
416  {
417  auto const showerproductPtrsIt = showerproductPtrs.find(Name);
418  if (showerproductPtrsIt != showerproductPtrs.end()) {
420  dynamic_cast<reco::shower::ShowerUniqueProductPtr<T>*>(showerproductPtrsIt->second.get());
421  return prod->GetPtr();
422  }
423 
424  auto const showerassnPtrsIt = showerassnPtrs.find(Name);
425  if (showerassnPtrsIt != showerassnPtrs.end()) {
427  dynamic_cast<reco::shower::ShowerUniqueAssnPtr<T>*>(showerassnPtrsIt->second.get());
428  return assn->GetPtr();
429  }
430 
431  throw cet::exception("ShowerProducedPtrsHolder")
432  << "Trying to get Ptr for: " << Name << " but Element does not exist" << std::endl;
433  }
434 
435  //Wrapper so that the use the addSingle command for the association. Add A and B to the association just
436  //as if add single add.
437  template <class T, class A, class B>
438  void AddSingle(A& a, B& b, const std::string& Name)
439  {
440  auto const showerassnPtrsIt = showerassnPtrs.find(Name);
441  if (showerassnPtrsIt == showerassnPtrs.end()) {
442  throw cet::exception("ShowerProducedPtrsHolder")
443  << "Trying to get the association: " << Name << "Element does not exist" << std::endl;
444  }
445  if (!is_assn<T>::value) {
446  throw cet::exception("ShowerProducedPtrsHolder")
447  << "Element type is not an assoication please only use this for assocations" << std::endl;
448  }
450  dynamic_cast<reco::shower::ShowerUniqueAssnPtr<T>*>(showerassnPtrsIt->second.get());
451  if (assnptr == nullptr) {
452  throw cet::exception("ShowerProducedPtrsHolder")
453  << "Failed to cast back. Maybe you got the type wrong or you are accidently accessing a "
454  "differently named product"
455  << std::endl;
456  }
457 
458  T* assn = dynamic_cast<T*>(assnptr->GetPtr().get());
459  if (assn == nullptr) {
460  throw cet::exception("ShowerProducedPtrsHolder")
461  << "Something went wrong trying to cast tothe assn. Maybe the name: " << Name
462  << " exists but its not an assn" << std::endl;
463  }
464 
465  assn->addSingle(a, b);
466  return;
467  }
468 
469  //Initialise the ptr makers. This is done at the the start of the module.
471  {
472  for (auto const& showerPtrMaker : showerPtrMakers) {
473  if (showerPtrMakers.find(showerPtrMaker.first) == showerPtrMakers.end()) {
474  throw cet::exception("ShowerProducedPtrsHolder")
475  << "PtrMaker was empty. This is concerning" << std::endl;
476  }
477  showerPtrMakers[showerPtrMaker.first]->SetPtrMaker(evt);
478  }
479  }
480 
481  //Wrapper to access a particle PtrMaker. This is legacy as is not used.
482  template <class T>
483  art::PtrMaker<T>& GetPtrMaker(const std::string& Name)
484  {
485  auto const showerPtrMakersIt = showerPtrMakers.find(Name);
486  if (showerPtrMakersIt == showerPtrMakers.end()) {
487  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker does not exist" << std::endl;
488  }
489  else {
490  if (!showerPtrMakersIt->second->CheckPtrMaker()) {
491  throw cet::exception("ShowerProducedPtrsHolder") << "PtrMaker is not set" << std::endl;
492  }
494  dynamic_cast<reco::shower::ShowerPtrMaker<T>*>(showerassnPtrs[Name].get());
495  return ptrmaker->GetPtrMaker();
496  }
497  }
498 
499  //Wrapper to return to the the user the art ptr corresponding the index iter
500  template <class T>
501  art::Ptr<T> GetArtPtr(const std::string& Name, const int& iter) const
502  {
503  auto const showerPtrMakersIt = showerPtrMakers.find(Name);
504  if (showerPtrMakersIt == showerPtrMakers.end()) {
505  throw cet::exception("ShowerProducedPtrsHolder")
506  << "PtrMaker does not exist for " << Name << " Did you initialise this? " << std::endl;
507  }
508  else {
509  if (!showerPtrMakersIt->second->CheckPtrMaker()) {
510  throw cet::exception("ShowerProducedPtrsHolder")
511  << "PtrMaker is not set. This is an issue for the devlopment team me. Contact Dom Barker"
512  << std::endl;
513  }
515  dynamic_cast<reco::shower::ShowerPtrMaker<T>*>(showerPtrMakersIt->second.get());
516  if (ptrmaker == nullptr) {
517  throw cet::exception("ShowerProducedPtrsHolder")
518  << "Failed to cast back. Maybe you got the type wrong or you are accidently accessing a "
519  "differently named product"
520  << std::endl;
521  }
522  return ptrmaker->GetArtPtr(iter);
523  }
524  }
525 
526  //Legacy not used.
528  {
529  for (auto const& showerPtrMaker : showerPtrMakers) {
530  (showerPtrMaker.second)->Reset();
531  }
532  }
533 
534  //Return the size of the std::vector of the data object with the unique name string.
535  int GetVectorPtrSize(const std::string& Name) const
536  {
537  auto const showerproductPtrsIt = showerproductPtrs.find(Name);
538  if (showerproductPtrsIt != showerproductPtrs.end()) {
539  return showerproductPtrsIt->second->GetVectorPtrSize();
540  }
541  throw cet::exception("ShowerProducedPtrsHolder")
542  << "Product: " << Name << " has not been set in the producers map" << std::endl;
543  }
544 
545  //Print the type, the element name and the instance name
546  void PrintPtr(const std::string& Name) const
547  {
548  auto const showerproductPtrsIt = showerproductPtrs.find(Name);
549  if (showerproductPtrsIt != showerproductPtrs.end()) {
550  const std::string Type = showerproductPtrsIt->second->GetType();
551  const std::string InstanceName = showerproductPtrsIt->second->GetInstanceName();
552  std::cout << "Element Name: " << Name << " Instance Name: " << InstanceName
553  << " Type: " << Type << std::endl;
554  return;
555  }
556  auto const showerassnPtrsIt = showerassnPtrs.find(Name);
557  if (showerassnPtrsIt != showerassnPtrs.end()) {
558  const std::string Type = showerassnPtrsIt->second->GetType();
559  const std::string InstanceName = showerassnPtrsIt->second->GetInstanceName();
560  std::cout << "Element Name: " << Name << " Instance Name: " << InstanceName
561  << " Type: " << Type << std::endl;
562  return;
563  }
564  mf::LogError("ShowerProducedPtrsHolder")
565  << "Trying to print Element: " << Name
566  << ". This element does not exist in the element holder" << std::endl;
567  return;
568  }
569 
570  //This function will print out all the pointers and there types for the user to check.
571  void PrintPtrs() const
572  {
573 
574  unsigned int maxname = 0;
575  for (auto const& showerprodPtr : showerproductPtrs) {
576  if (showerprodPtr.first.size() > maxname) { maxname = showerprodPtr.first.size(); }
577  }
578  for (auto const& showerassnPtr : showerassnPtrs) {
579  if (showerassnPtr.first.size() > maxname) { maxname = showerassnPtr.first.size(); }
580  }
581 
582  std::map<std::string, std::pair<std::string, std::string>> Type_showerprodPtrs;
583  std::map<std::string, std::pair<std::string, std::string>> Type_showerassnPtrs;
584  for (auto const& showerprodPtr : showerproductPtrs) {
585  const std::string Type = (showerprodPtr.second)->GetType();
586  const std::string InstanceName = (showerprodPtr.second)->GetInstanceName();
587  Type_showerprodPtrs[showerprodPtr.first] = std::make_pair(InstanceName, Type);
588  }
589  for (auto const& showerassnPtr : showerassnPtrs) {
590  const std::string Type = (showerassnPtr.second)->GetType();
591  const std::string InstanceName = (showerassnPtr.second)->GetInstanceName();
592  Type_showerassnPtrs[showerassnPtr.first] = std::make_pair(InstanceName, Type);
593  }
594 
595  unsigned int maxtype = 0;
596  unsigned int maxinstname = 0;
597  for (auto const& Type_showerprodPtr : Type_showerprodPtrs) {
598  if (Type_showerprodPtr.second.second.size() > maxtype) {
599  maxtype = Type_showerprodPtr.second.second.size();
600  }
601  if (Type_showerprodPtr.second.first.size() > maxinstname) {
602  maxinstname = Type_showerprodPtr.second.first.size();
603  }
604  }
605  for (auto const& Type_showerassnPtr : Type_showerassnPtrs) {
606  if (Type_showerassnPtr.second.second.size() > maxtype) {
607  maxtype = Type_showerassnPtr.second.second.size();
608  }
609  if (Type_showerassnPtr.second.first.size() > maxinstname) {
610  maxinstname = Type_showerassnPtr.second.first.size();
611  }
612  }
613 
614  unsigned int n = maxname + maxtype + maxinstname + 51;
615  std::cout << std::left << std::setfill('*') << std::setw(n - 1) << "**" << std::endl;
616  std::cout << "Unique Ptrs that are added to the event" << std::endl;
617  std::cout << std::left << std::setfill('*') << std::setw(n - 1) << "**" << std::endl;
618  for (auto const& Type_showerprodPtr : Type_showerprodPtrs) {
619  std::cout << std::left << std::setfill(' ') << std::setw(21)
620  << "* Data Product Name: " << std::setw(maxname) << Type_showerprodPtr.first;
621  std::cout << std::left << std::setfill(' ') << " * Instance Name: " << std::setw(maxinstname)
622  << Type_showerprodPtr.second.first;
623  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype)
624  << Type_showerprodPtr.second.second << " *" << std::endl;
625  }
626  for (auto const& Type_showerassnPtr : Type_showerassnPtrs) {
627  std::cout << std::left << std::setfill(' ') << std::setw(maxname) << std::setw(21)
628  << "* Association Name: " << std::setw(maxname) << Type_showerassnPtr.first;
629  std::cout << std::left << std::setfill(' ') << " * Instance Name: " << std::setw(maxinstname)
630  << Type_showerassnPtr.second.first;
631  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype)
632  << Type_showerassnPtr.second.second << " *" << std::endl;
633  }
634  std::cout << std::left << std::setfill('*') << std::setw(n - 1) << "**" << std::endl;
635  std::cout << std::setfill(' ');
636  std::cout << std::setw(0);
637  return;
638  }
639 
640 private:
641  //Function to check that a data product does not already exist with the same instance name
642  template <class T>
643  bool CheckForMultipleTypes(type<T>, const std::string& Name, const std::string& Instance) const
644  {
645 
646  //Check the a product of the same does not exist without a different instance name
647  for (auto const& assn : showerassnPtrs) {
649  dynamic_cast<reco::shower::ShowerUniqueAssnPtr<T>*>(assn.second.get());
650  if (assnptr != nullptr) {
651  if (assnptr->GetInstanceName() == Instance) { return false; }
652  }
653  }
654  return true;
655  }
656 
657  //Function to check that a data product does not already exist with the same instance name
658  template <class T>
659  bool CheckForMultipleTypes(type<std::vector<T>>,
660  const std::string& Name,
661  const std::string& Instance) const
662  {
663 
664  //Check the a product of the same does not exist without a different instance name
665  for (auto const& product : showerproductPtrs) {
667  dynamic_cast<reco::shower::ShowerUniqueProductPtr<std::vector<T>>*>(product.second.get());
668  if (prod != nullptr) {
669  if (prod->GetInstanceName() == Instance) { return false; }
670  }
671  }
672  return true;
673  }
674 
675  //Holder of the data objects of type std::vector<T> that will be saved in the events.
676  std::map<std::string, std::unique_ptr<reco::shower::ShowerUniqueProduerPtrBase>>
678 
679  //Holder of the data objects of type T that will be saved into the events. I think these will only be assns.
680  std::map<std::string, std::unique_ptr<reco::shower::ShowerUniqueProduerPtrBase>> showerassnPtrs;
681 
682  //Holder of the ptrMakers whcih make the art::Ptrs of the data objects that lie in showerproductPtrs.
683  std::map<std::string, std::unique_ptr<reco::shower::ShowerPtrMakerBase>> showerPtrMakers;
684 };
685 
686 #endif
void AddDataProduct(const reco::shower::ShowerElementHolder &selement_holder, const std::string &Name) override
art::PtrMaker< T > & GetPtrMaker(const std::string &Name)
art::Ptr< T > GetArtPtr(int iter) const
void AddDataProducts(const reco::shower::ShowerElementHolder &selement_holder)
std::unique_ptr< art::PtrMaker< T > > ptrmaker
STL namespace.
void SetPtrMaker(art::Event &evt) override
ShowerPtrMaker(const std::string &Instancename)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void PrintPtr(const std::string &Name) const
bool CheckUniqueProduerPtr(const std::string &Name) const
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerproductPtrs
PutHandle< PROD > put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: Event.h:77
void MoveToEvent(art::Event &evt) override
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
std::string GetInstanceName() const override
void AddSingle(A &a, B &b, const std::string &Name)
ntupleExperimental Reset()
bool CheckElement(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
double value
Definition: spectrum.C:18
int SetShowerUniqueProduerPtr(type< std::vector< T >>, const std::string &Name, const std::string &Instance="")
bool CheckAllProducedElements(reco::shower::ShowerElementHolder &selement_holder) const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition: AssnsIter.h:94
std::map< std::string, std::unique_ptr< reco::shower::ShowerUniqueProduerPtrBase > > showerassnPtrs
void AddDataProduct(const reco::shower::ShowerElementHolder &selement_holder, const std::string &Name) override
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Definition: MVAAlg.h:12
Char_t n[5]
ShowerUniqueAssnPtr(const std::string &Instancename)
art::Ptr< T > GetArtPtr(const std::string &Name, const int &iter) const
TCEvent evt
Definition: DataStructs.cxx:8
bool CheckForMultipleTypes(type< std::vector< T >>, const std::string &Name, const std::string &Instance) const
std::map< std::string, std::unique_ptr< reco::shower::ShowerPtrMakerBase > > showerPtrMakers
int SetShowerUniqueProduerPtr(type< T >, const std::string &Name, const std::string &Instance="")
bool CheckForMultipleTypes(type< T >, const std::string &Name, const std::string &Instance) const
Definition: fwd.h:26
int GetVectorPtrSize(const std::string &Name) const
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33