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