CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CollHandle.h
Go to the documentation of this file.
1 /*
2  * $Id: CollHandle.h,v 1.6 2010/02/11 00:15:21 wmtan Exp $
3  */
4 
5 #ifndef EcalDigis_CollHandle_h
6 #define EcalDigis_CollHandle_h
7 
11 
24 template<class T>
25 class CollHandle {
26  //constructor(s) and destructor(s)
27 public:
34  bool failIfNotFound = true,
35  bool notFoundWarn = true): tag_(tag),
38  failIfNotFound_(failIfNotFound),
39  notFoundWarn_(notFoundWarn){}
40 
41  //method(s)
42 public:
51  void read(const edm::Event& event){
52  // try{
53  edm::Handle<T> hColl;
54  event.getByLabel(tag_, hColl);
55 
56  //If we must be tolerant to product absence, then
57  //we must check validaty before calling Handle::operator*
58  //to prevent exception throw:
59  if(!failIfNotFound_ // product-not-found tolerant mode
60  && !hColl.isValid()){// and the product was not found
61  if(notFoundWarn_
62  && !notFoundAlreadyWarned_){//warning logged only once
63  edm::LogWarning("ProductNotFound") << tag_
64  << " product "
65  "of type '" << typeid(T).name() << "' was not found!";
67  }
69  } else {
70  currentColl_ = &(*hColl);
71  }
72  }
73 
74 
78  const T* operator->() const{ return currentColl_;}
79 
83  const T& operator*() const { return *currentColl_;}
84 
85  edm::InputTag tag() const { return tag_; }
86 
87 private:
88 
89  //attribute(s)
90 protected:
91 private:
95 
98  const T* currentColl_;
99 
103  const T emptyColl_;
104 
108 
112 
116 };
117 
118 #endif
const T * operator->() const
Definition: CollHandle.h:78
edm::InputTag tag() const
Definition: CollHandle.h:85
const T * currentColl_
Definition: CollHandle.h:98
bool notFoundAlreadyWarned_
Definition: CollHandle.h:107
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
const T & operator*() const
Definition: CollHandle.h:83
void read(const edm::Event &event)
Definition: CollHandle.h:51
const edm::InputTag tag_
Definition: CollHandle.h:94
CollHandle(const edm::InputTag &tag, bool failIfNotFound=true, bool notFoundWarn=true)
Definition: CollHandle.h:33
bool notFoundWarn_
Definition: CollHandle.h:115
const T emptyColl_
Definition: CollHandle.h:103
long double T
bool failIfNotFound_
Definition: CollHandle.h:111