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