All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowerElementHolder.hh
Go to the documentation of this file.
1 //###################################################################
2 //### Name: ShowerElementHolder ###
3 //### Author: Dominic Barker, Ed Tyley ###
4 //### Date: 15.07.19 ###
5 //### Description: Class to holder the standard shower property ###
6 //### information. Used in LArPandoraModularShower ###
7 //### and corresponding tools ###
8 //###################################################################
9 
10 #ifndef ShowerElementHolder_HH
11 #define ShowerElementHolder_HH
12 
13 //Framework includes
14 #include "art/Framework/Principal/Handle.h"
15 #include "canvas/Persistency/Common/FindOneP.h"
16 #include "canvas/Persistency/Common/FindManyP.h"
17 #include "messagefacility/MessageLogger/MessageLogger.h"
18 #include "cetlib_except/demangle.h"
19 #include "cetlib_except/exception.h"
20 
21 //C++ Inlcudes
22 #include <iostream>
23 #include <map>
24 #include <string>
25 #include <memory>
26 #include <iomanip>
27 
28 namespace reco::shower {
29  class ShowerElementBase;
30  template <class T> class ShowerElementAccessor;
31  template <class T> class ShowerDataProduct;
32  template <class T> class EventDataProduct;
33  template <class T, class T2> class ShowerProperty;
34  class ShowerElementHolder;
35 }
36 
38 
39  public:
40 
41  virtual ~ShowerElementBase() noexcept = default;
42 
43  virtual bool CheckTag() const {
44  throw cet::exception("ShowerElementHolder") << "Trying to check an element that is not a product" << std::endl;
45  }
46  virtual void SetCheckTag(bool& check){
47  throw cet::exception("ShowerElementHolder") << "Trying to set an element that is not a product" << std::endl;
48  }
49 
50  virtual std::string GetType() const = 0;
51 
52  //Check if the element has been set.
53  bool CheckShowerElement() const {
54  if(elementPtr) return true;
55  else return false;
56  }
57 
58  void Clear(){
59  elementPtr = 0;
60  }
61 
62 
63  protected:
64 
65  bool elementPtr;
66 
67 };
68 
69 //This is a template class which holds a shower property. This holds any object e.g. std::vector<double>, double, TVector3
70 //and holds various information which helps the showerproperty holder access the elements. A user should not require any part
71 //of this class.
72 template <class T>
74 
75  public:
76 
77  ShowerElementAccessor(T& Element):
78  element(Element){
79  this->elementPtr = 1;
80  // this->element = Element;
81  }
82 
83  //Set the element in the holder
84  void SetShowerElement(T& Element){
85  element = Element;
86  this->elementPtr = 1;
87  }
88 
89  //Fill Element with the element that the holder holds.
90  int GetShowerElement(T& Element) const {
91  if(this->elementPtr){
92  Element = element;
93  return 0;
94  }
95  else{
96  return 1;
97  }
98  }
99 
100  //Return a copy of the shower element.
102  if(!this->elementPtr){
103  throw cet::exception("ShowerElementHolder") << "The element that is being accessed is not set" << std::endl;
104  }
105  return element;
106  }
107 
108  T GetShowerElement() const {
109  if(!this->elementPtr){
110  throw cet::exception("ShowerElementHolder") << "The element that is being accessed is not set" << std::endl;
111  }
112  return element;
113  }
114 
115  //Return the type as a string.
116  std::string GetType() const override {
117  return cet::demangle_symbol(typeid(element).name());
118  }
119 
120  protected:
122 };
123 
124 //This class holds shower data products which have the potential to be saved in the art::Event e.g. recob::Track. Note the product itself must be store in the element holder as the object will be destoryed in the CalculateProperty Section otherwise. Associtations can be made during Calculate property tool stage.
125 template <class T>
127 
128  public:
129 
130  ShowerDataProduct(T& Element, bool Checktag):
131  reco::shower::ShowerElementAccessor<T>{Element} {
132  checktag = Checktag;
133  }
134 
135 
136  void Clear(){
137  this->element = T();
138  this->elementPtr = 0;
139  }
140 
141  //Check if we should check the dataproduct in the end.
142  bool CheckTag() const {
143  return checktag;
144  }
145 
146  //Set if we should check the data product in the end.
147  void SetCheckTag(bool& Checktag){
148  checktag = Checktag;
149  }
150 
151  private:
152  bool checktag;
153 };
154 
155 
156 
157 // This class holds the things we want per event rather than per shower, e.g. FindManyP
158 template <class T>
160 
161  public:
162 
163  EventDataProduct(T& Element):
164  reco::shower::ShowerElementAccessor<T>{Element} {
165  }
166 
167  void Clear(){
168  // this->element = T();
169  this->elementPtr = 0;
170  }
171 };
172 
173 //This class holds shower properties e.g. ShowerDirection. The user must define the associated error
174 template <class T, class T2>
176 
177  public:
178 
179  ShowerProperty(T& Element, T2& ElementErr):
180  reco::shower::ShowerElementAccessor<T>{Element} {
181  propertyErr = ElementErr;
182  }
183 
184  //Fill the property error as long as it has been set.
185  int GetShowerPropertyError(T2& ElementErr) const {
186  if(this->elementPtr){
187  ElementErr = propertyErr;
188  return 0;
189  }
190  else{
191  return 1;
192  }
193  }
194 
195  //Set the properties. Note you cannot set an property without an error.
196  void SetShowerProperty(T& Element, T2& ElementErr) {
197  this->element = Element;
198  this->elementPtr = 1;
199  propertyErr = ElementErr;
200  }
201 
202  void Clear(){
203  this->element = T();
204  this->elementPtr = 0;
205  }
206 
207  private:
209 
210 };
211 
212 
213 //Class to holder all the reco::shower::ShowerElement objects. This is essentially a map from a string the object so people can
214 //add an object in a tool and get it back later.
216 
217  public:
218 
219  //Getter function for accessing the shower property e..g the direction ShowerElementHolder.GetElement("MyShowerValue"); The name is used access the value and precise names are required for a complete shower in LArPandoraModularShowerCreation: ShowerStartPosition, ShowerDirection, ShowerEnergy ,ShowerdEdx.
220  template <class T >
221  int GetElement(const std::string& Name, T& Element) const {
222  auto const showerPropertiesIt = showerproperties.find(Name);
223  if(showerPropertiesIt != showerproperties.end()){
224  if(showerPropertiesIt->second->CheckShowerElement()){
225  reco::shower::ShowerElementAccessor<T> *showerprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(showerPropertiesIt->second.get());
226  if(showerprop == nullptr){
227  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
228  }
229  showerprop->GetShowerElement(Element);
230  return 0;
231  }
232  else{
233  mf::LogWarning("ShowerElementHolder") << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
234  return 1;
235  }
236  }
237 
238  auto const showerDataProductsIt = showerdataproducts.find(Name);
239  if(showerDataProductsIt != showerdataproducts.end()){
240  if(showerDataProductsIt->second->CheckShowerElement()){
241  reco::shower::ShowerElementAccessor<T> *showerprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(showerDataProductsIt->second.get());
242  if(showerprop == nullptr){
243  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
244  }
245  showerprop->GetShowerElement(Element);
246  return 0;
247  }
248  else{
249  mf::LogWarning("ShowerElementHolder") << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
250  return 1;
251  }
252  }
253 
254  auto const eventDataProductsIt = eventdataproducts.find(Name);
255  if (eventDataProductsIt != eventdataproducts.end()){
256  if(eventDataProductsIt->second->CheckShowerElement()){
257  reco::shower::ShowerElementAccessor<T> *eventprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(eventDataProductsIt->second.get());
258  if(eventprop == nullptr){
259  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
260  }
261  eventprop->GetShowerElement(Element);
262  return 0;
263  }else{
264  mf::LogWarning("ShowerElementHolder") << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
265  return 1;
266  }
267  }
268  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element does not exist in the element holder" << std::endl;
269  }
270 
271  template <class T >
272  int GetEventElement(const std::string& Name, T& Element) const {
273  auto const eventDataProductsIt = eventdataproducts.find(Name);
274  if (eventDataProductsIt != eventdataproducts.end()){
275  if(eventDataProductsIt->second->CheckShowerElement()){
276  reco::shower::ShowerElementAccessor<T> *eventprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(eventDataProductsIt->second.get());
277  if(eventprop == nullptr){
278  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
279  }
280  eventprop->GetShowerElement(Element);
281  return 0;
282  }else{
283  mf::LogWarning("ShowerElementHolder") << "Trying to get Element " << Name << ". This elment has not been filled" << std::endl;
284  return 1;
285  }
286  }
287  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element does not exist in the element holder" << std::endl;
288  }
289 
290  //Alternative get function that returns the object. Not recommended.
291  template <class T >
292  const T& GetEventElement(std::string const& Name) {
293  auto const eventDataProductsIt = eventdataproducts.find(Name);
294  if (eventDataProductsIt != eventdataproducts.end()){
295  if(eventDataProductsIt->second->CheckShowerElement()){
296  reco::shower::ShowerElementAccessor<T> *eventprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(eventDataProductsIt->second.get());
297  if(eventprop == nullptr){
298  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
299  }
300  return eventprop->GetShowerElementRef();
301  }
302  }
303  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element does not exist in the element holder" << std::endl;
304  }
305 
306  //Alternative get function that returns the object. Not recommended.
307  template <class T >
308  T GetElement(const std::string& Name) const {
309  auto const showerPropertiesIt = showerproperties.find(Name);
310  if(showerPropertiesIt != showerproperties.end()){
311  if(showerPropertiesIt->second->CheckShowerElement()){
312  reco::shower::ShowerElementAccessor<T> *showerprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(showerPropertiesIt->second.get());
313  if(showerprop == nullptr){
314  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
315  }
316  return showerprop->GetShowerElement();
317  }
318  }
319 
320  auto const showerDataProductsIt = showerdataproducts.find(Name);
321  if(showerDataProductsIt != showerdataproducts.end()){
322  if(showerDataProductsIt->second->CheckShowerElement()){
323  reco::shower::ShowerElementAccessor<T> *showerprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(showerDataProductsIt->second.get());
324  if(showerprop == nullptr){
325  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
326  }
327  return showerprop->GetShowerElement();
328  }
329  }
330 
331  auto const eventDataProductsIt = eventdataproducts.find(Name);
332  if (eventDataProductsIt != eventdataproducts.end()){
333  if(eventDataProductsIt->second->CheckShowerElement()){
334  reco::shower::ShowerElementAccessor<T> *eventprop = dynamic_cast<reco::shower::ShowerElementAccessor<T> *>(eventDataProductsIt->second.get());
335  if(eventprop == nullptr){
336  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element you are filling is not the correct type" << std::endl;
337  }
338  return eventprop->GetShowerElement();
339  }
340  }
341  throw cet::exception("ShowerElementHolder") << "Trying to get Element: " << Name << ". This element does not exist in the element holder" << std::endl;
342  }
343 
344  //Getter function for accessing the shower property error e.g the direction ShowerElementHolder.GetElement("MyShowerValue");
345  template <class T, class T2>
346  int GetElementAndError(const std::string& Name, T& Element, T2& ElementErr) const {
347  auto const showerPropertiesIt = showerproperties.find(Name);
348  if(showerPropertiesIt == showerproperties.end()){
349  mf::LogError("ShowerElementHolder") << "Trying to get Element Error: " << Name << ". This elment does not exist in the element holder" << std::endl;
350  return 1;
351  }
352  reco::shower::ShowerProperty<T,T2> *showerprop = dynamic_cast<reco::shower::ShowerProperty<T,T2> *>(showerPropertiesIt->second.get());
353  showerprop->GetShowerElement(Element);
354  showerprop->GetShowerPropertyError(ElementErr);
355  return 0;
356  }
357 
358 
359  //This sets the value of the data product. Just give a name and a object
360  //e.g. TVector3 ShowerElementHolder.SetElement((TVector3) StartPosition, "StartPosition");
361  template <class T>
362  void SetElement(T& dataproduct, const std::string& Name, bool checktag=false){
363 
364  auto const showerDataProductsIt = showerdataproducts.find(Name);
365  if(showerDataProductsIt != showerdataproducts.end()){
366  reco::shower::ShowerDataProduct<T>* showerdataprod = dynamic_cast<reco::shower::ShowerDataProduct<T> *>(showerDataProductsIt->second.get());
367  showerdataprod->SetShowerElement(dataproduct);
368  showerdataprod->SetCheckTag(checktag);
369  return;
370  }
371  else{
372  showerdataproducts[Name] = std::make_unique<ShowerDataProduct<T> >(dataproduct,checktag);
373  return;
374  }
375  }
376 
377  //This sets the value of the property. Just give a name and a object
378  //e.g. TVector3 ShowerElementHolder.SetElement((art::Ptr<recob::Track>) track, "StartPosition", save);
379  template <class T, class T2>
380  void SetElement(T& propertyval, T2& propertyvalerror, const std::string& Name){
381 
382  auto const showerPropertiesIt = showerproperties.find(Name);
383  if(showerPropertiesIt != showerproperties.end()){
384  reco::shower::ShowerProperty<T,T2>* showerprop = dynamic_cast<reco::shower::ShowerProperty<T,T2> *>(showerPropertiesIt->second.get());
385  showerprop->SetShowerProperty(propertyval,propertyvalerror);
386  return;
387  }
388  else{
389  showerproperties[Name] = std::make_unique<ShowerProperty<T,T2> >(propertyval,propertyvalerror);
390  return;
391  }
392  }
393 
394  //This sets the value of the event data product. Just give a name and a object
395  //e.g. TVector3 ShowerElementHolder.SetEventElement((TVector3) StartPosition, "StartPosition");
396  template <class T>
397  void SetEventElement(T& dataproduct, const std::string& Name){
398 
399  auto const eventDataProductsIt = eventdataproducts.find(Name);
400  if (eventDataProductsIt != eventdataproducts.end()){
401  reco::shower::EventDataProduct<T>* eventdataprod = dynamic_cast<reco::shower::EventDataProduct<T> *>(eventDataProductsIt->second.get());
402  eventdataprod->SetShowerElement(dataproduct);
403  return;
404  }
405  else{
406  eventdataproducts[Name] = std::make_unique<EventDataProduct<T> >(dataproduct);
407  return;
408  }
409  }
410 
411  bool CheckEventElement(const std::string& Name) const {
412  auto const eventDataProductsIt = eventdataproducts.find(Name);
413  return eventDataProductsIt == eventdataproducts.end() ? false : eventDataProductsIt->second->CheckShowerElement();
414  }
415 
416  //Check that a property is filled
417  bool CheckElement(const std::string& Name) const {
418  auto const showerPropertiesIt = showerproperties.find(Name);
419  if(showerPropertiesIt != showerproperties.end()){
420  return showerPropertiesIt->second->CheckShowerElement();
421  }
422  auto const showerDataProductsIt = showerdataproducts.find(Name);
423  if(showerDataProductsIt != showerdataproducts.end()){
424  return showerDataProductsIt->second->CheckShowerElement();
425  }
426  auto const eventDataProductsIt = eventdataproducts.find(Name);
427  if(eventDataProductsIt!= eventdataproducts.end()){
428  return eventDataProductsIt->second->CheckShowerElement();
429  }
430  return false;
431  }
432 
433  //Check All the properties
434  bool CheckAllElements() const {
435  bool checked = true;
436  for(auto const& showerprop: showerproperties){
437  checked *= showerprop.second->CheckShowerElement();
438  }
439  for(auto const& showerdataprod: showerdataproducts){
440  checked *= showerdataprod.second->CheckShowerElement();
441  }
442  return checked;
443  }
444 
445 
446  //Clear Fucntion. This does not delete the element.
447  void ClearElement(const std::string& Name){
448  auto const showerPropertiesIt = showerproperties.find(Name);
449  if(showerPropertiesIt != showerproperties.end()){
450  return showerPropertiesIt->second->Clear();
451  }
452  auto const showerDataProductsIt = showerdataproducts.find(Name);
453  if(showerDataProductsIt != showerdataproducts.end()){
454  return showerDataProductsIt->second->Clear();
455  }
456  mf::LogError("ShowerElementHolder") << "Trying to clear Element: " << Name << ". This element does not exist in the element holder" << std::endl;
457  return;
458  }
459 
460  //Clear all the shower properties. This does not delete the element.
461  void ClearShower(){
462  for(auto const& showerprop: showerproperties){
463  (showerprop.second)->Clear();
464  }
465  for(auto const& showerdataproduct: showerdataproducts){
466  (showerdataproduct.second)->Clear();
467  }
468  }
469  //Clear all the shower properties. This does not delete the element.
470  void ClearEvent(){
471  for(auto const& eventdataproduct: eventdataproducts){
472  (eventdataproduct.second)->Clear();
473  }
474  }
475  //Clear all the shower properties. This does not delete the element.
476  void ClearAll(){
477  ClearShower();
478  ClearEvent();
479  }
480 
481  //Find if the product is one what is being stored.
482  bool CheckElementTag(const std::string& Name) const {
483  auto const showerDataProductsIt = showerdataproducts.find(Name);
484  if(showerDataProductsIt != showerdataproducts.end()){
485  return showerDataProductsIt->second->CheckTag();
486  }
487  return false;
488  }
489 
490  //Delete a product. I see no reason for it.
491  void DeleteElement(const std::string& Name){
492  auto const showerPropertiesIt = showerproperties.find(Name);
493  if(showerPropertiesIt != showerproperties.end()){
494  return showerPropertiesIt->second.reset(nullptr);
495  }
496  auto const showerDataProductsIt = showerdataproducts.find(Name);
497  if(showerDataProductsIt != showerdataproducts.end()){
498  return showerDataProductsIt->second.reset(nullptr);
499  }
500  mf::LogError("ShowerElementHolder") << "Trying to delete Element: " << Name << ". This element does not exist in the element holder" << std::endl;
501  return;
502  }
503 
504  //Set the indicator saying if the shower is going to be stored.
505  void SetElementTag(const std::string& Name, bool checkelement){
506  auto const showerDataProductsIt = showerdataproducts.find(Name);
507  if(showerDataProductsIt != showerdataproducts.end()){
508  return showerDataProductsIt->second->SetCheckTag(checkelement);
509  }
510  mf::LogError("ShowerElementHolder") << "Trying set the checking of the data product: " << Name << ". This data product does not exist in the element holder" << std::endl;
511  return;
512  }
513 
514  bool CheckAllElementTags() const {
515  bool checked = true;
516  for(auto const& showerdataproduct: showerdataproducts){
517  bool check = showerdataproduct.second->CheckTag();
518  if(check){
519  bool elementset = showerdataproduct.second->CheckShowerElement();
520  if(!elementset){
521  mf::LogError("ShowerElementHolder") << "The following element is not set and was asked to be checked: " << showerdataproduct.first << std::endl;
522  checked = false;
523  }
524  }
525  }
526  return checked;
527  }
528 
529  //Set the shower number. This is required the association making.
530  void SetShowerNumber(int& shower_iter){
531  showernumber = shower_iter;
532  }
533 
534  //Get the shower number.
535  int GetShowerNumber() const {
536  return showernumber;
537  }
538 
539  //This function will print out all the elements and there types for the user to check.
540  void PrintElements() const {
541 
542  unsigned int maxname = 0;
543  for(auto const& showerprop: showerproperties){
544  if(showerprop.first.size() > maxname){
545  maxname = showerprop.first.size();
546  }
547  }
548  for(auto const& showerdataprod: showerdataproducts){
549  if(showerdataprod.first.size() > maxname){
550  maxname = showerdataprod.first.size();
551  }
552  }
553 
554  std::map<std::string,std::string> Type_showerprops;
555  std::map<std::string,std::string> Type_showerdataprods;
556  for(auto const& showerprop: showerproperties){
557  std::string Type = (showerprop.second)->GetType();
558  Type_showerprops[showerprop.first] = Type;
559  }
560  for(auto const& showerdataprod: showerdataproducts){
561  std::string Type = (showerdataprod.second)->GetType();
562  Type_showerdataprods[showerdataprod.first] = Type;
563  }
564 
565  unsigned int maxtype = 0;
566  for(auto const& Type_showerprop: Type_showerprops){
567  if(Type_showerprop.second.size() > maxtype){
568  maxtype = Type_showerprop.second.size();
569  }
570  }
571  for(auto const& Type_showerdataprod: Type_showerdataprods){
572  if(Type_showerdataprod.second.size() > maxtype){
573  maxtype = Type_showerdataprod.second.size();
574  }
575  }
576 
577  unsigned int n = maxname + maxtype + 33;
578  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "*" <<std::endl;
579  std::cout << "Elements in the element holder" << std::endl;
580  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "*" <<std::endl;
581  for(auto const& Type_showerprop: Type_showerprops){
582  std::cout << std::left << std::setfill(' ') << std::setw(21) << "* Property Name: " << std::setw(maxname) << Type_showerprop.first;
583  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype) << Type_showerprop.second << " * " << std::endl;
584  }
585  for(auto const& Type_showerdataprod: Type_showerdataprods){
586  std::cout << std::left << std::setfill(' ') << std::setw(maxname) << std::setw(21) << "* Data Product Name: " << std::setw(maxname) << Type_showerdataprod.first;
587  std::cout << std::left << std::setfill(' ') << " * Type: " << std::setw(maxtype) << Type_showerdataprod.second << " *" << std::endl;
588  }
589  std::cout << std::left << std::setfill('*') << std::setw(n-1) << "*" <<std::endl;
590  std::cout << std::setfill(' ');
591  std::cout << std::setw(0);
592  return;
593  }
594 
595  template <class T>
596  std::string getType(T object) const {
597  return cet::demangle_symbol(typeid(object).name());
598  }
599 
600  template <class T>
601  std::string getType() const {
602  return cet::demangle_symbol(typeid(T).name());
603  }
604 
605  template <class T1, class T2>
606  const art::FindManyP<T1>& GetFindManyP(const art::ValidHandle<std::vector<T2> >& handle,
607  const art::Event &evt, const art::InputTag &moduleTag){
608 
609  const std::string name("FMP_" + moduleTag.label() + "_" + getType<T1>() + "_" + getType<T2>());
610 
611  if (CheckEventElement(name)){
612  return GetEventElement<art::FindManyP<T1> >(name);
613  } else {
614  art::FindManyP<T1> findManyP(handle, evt, moduleTag);
615  if (findManyP.isValid()){
616  SetEventElement(findManyP, name);
617  return GetEventElement<art::FindManyP<T1> >(name);
618  } else {
619  throw cet::exception("ShowerElementHolder") << "FindManyP is not valid: " << name << std::endl;
620  }
621  }
622  }
623 
624  template <class T1, class T2>
625  const art::FindOneP<T1>& GetFindOneP(const art::ValidHandle<std::vector<T2> >& handle,
626  const art::Event& evt, const art::InputTag& moduleTag){
627 
628  const std::string name("FOP_" + moduleTag.label() + "_" + getType<T1>() + "_" + getType<T2>());
629 
630  if (CheckEventElement(name)){
631  return GetEventElement<art::FindOneP<T1> >(name);
632  } else {
633  art::FindOneP<T1> findOneP(handle, evt, moduleTag);
634  if (findOneP.isValid()){
635  SetEventElement(findOneP, name);
636  return GetEventElement<art::FindOneP<T1> >(name);
637  } else {
638  throw cet::exception("ShowerElementHolder") << "FindOneP is not valid: " << name << std::endl;
639  }
640  }
641  }
642 
643  private:
644 
645  //Storage for all the shower properties.
646  std::map<std::string,std::unique_ptr<reco::shower::ShowerElementBase> > showerproperties;
647 
648  //Storage for all the data products
649  std::map<std::string,std::unique_ptr<reco::shower::ShowerElementBase> > showerdataproducts;
650 
651  //Storage for all the data products
652  std::map<std::string,std::unique_ptr<reco::shower::ShowerElementBase> > eventdataproducts;
653 
654  //Shower ID number. Use this to set ptr makers.
656 
657 };
658 
659 #endif
virtual std::string GetType() const =0
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > showerdataproducts
void DeleteElement(const std::string &Name)
virtual ~ShowerElementBase() noexcept=default
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > showerproperties
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
virtual void SetCheckTag(bool &check)
void SetElementTag(const std::string &Name, bool checkelement)
void SetEventElement(T &dataproduct, const std::string &Name)
const art::FindOneP< T1 > & GetFindOneP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
process_name shower
Definition: cheaterreco.fcl:51
const T & GetEventElement(std::string const &Name)
void SetElement(T &propertyval, T2 &propertyvalerror, const std::string &Name)
process_name standard_reco_uboone reco
ShowerProperty(T &Element, T2 &ElementErr)
bool CheckElement(const std::string &Name) const
BEGIN_PROLOG vertical distance to the surface Name
walls no left
Definition: selectors.fcl:105
process_name tightIsolTest check
std::map< std::string, std::unique_ptr< reco::shower::ShowerElementBase > > eventdataproducts
bool CheckElementTag(const std::string &Name) const
int GetElement(const std::string &Name, T &Element) const
bool CheckEventElement(const std::string &Name) const
T GetElement(const std::string &Name) const
ShowerDataProduct(T &Element, bool Checktag)
void SetShowerProperty(T &Element, T2 &ElementErr)
decoded decode D Type
int GetEventElement(const std::string &Name, T &Element) const
int GetShowerPropertyError(T2 &ElementErr) const
void ClearElement(const std::string &Name)
then echo fcl name
int GetElementAndError(const std::string &Name, T &Element, T2 &ElementErr) const
std::string getType(T object) const
TCEvent evt
Definition: DataStructs.cxx:8
BEGIN_PROLOG could also be cout
std::string GetType() const override