MINT2
EventPtrList.h
Go to the documentation of this file.
1 #ifndef EVENT_PTR_LIST_HH
2 #define EVENT_PTR_LIST_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:17:54 GMT
5 
6 #include <iostream>
7 //#include <vector>
8 #include <ctime>
9 #include <cmath>
10 
11 #include "TRandom.h"
12 
13 #include "Mint/IMinimalEventList.h"
14 //#include "Mint/EventAccess.h"
15 #include "Mint/IReturnReal.h"
17 
18 #include "Mint/GeneralisedPareto.h"
19 
20 #include "Mint/counted_ptr.h"
21 #include "Mint/PolymorphVector.h"
22 
23 namespace MINT{
24 
25 template<typename EVENT_TYPE>
27  : virtual public MINT::IMinimalEventList<EVENT_TYPE>
28  , public MINT::PolymorphVector<MINT::counted_ptr<EVENT_TYPE> >
29  {
30 
31  public:
33  {
34  }
35 
36  EventPtrList(const EVENT_TYPE& evt)
37  {
38  Add(evt);
39  }
40  virtual ~EventPtrList(){}
41 
42  virtual counted_ptr<EVENT_TYPE> getPtr(unsigned int i) const{
43  return this->at(i);
44  }
45 
46  virtual EVENT_TYPE getEvent(unsigned int i) const{
47  return *(getPtr(i));
48  }
49  virtual const EVENT_TYPE& getEventRef(unsigned int i) const{
50  return *(getPtr(i));
51  }
52  virtual EVENT_TYPE& getEventRef(unsigned int i){
53  return *(getPtr(i));
54  }
56  : IMinimalEventList<EVENT_TYPE>()
57  , PolymorphVector<MINT::counted_ptr<EVENT_TYPE> >(
58  (MINT::PolymorphVector<MINT::counted_ptr<EVENT_TYPE> >)other)
59  {
60  }
63  if(this == &other) return *this;
64  this->clear();
65  for(unsigned int i=0; i<other.size(); i++){
66  this->push_back(other.getPtr(i));
67  }
68  /*
69  this->_recordCollection = other._recordCollection;
70  this->_recordCollection.pop_front();
71  this->_recordCollection.push_front((IEventList< RETURN_TYPE >*) this);
72  */
73  return *this;
74  }
75 
76  virtual unsigned int size() const{
78  }
79 
81  if(this->empty()) return MINT::counted_ptr<EVENT_TYPE>(0);
82  MINT::counted_ptr<EVENT_TYPE> evtPtr(getPtr(this->size()-1));
83  this->resize(this->size() - 1);
84  return evtPtr;
85  }
86 
87 
88  virtual bool Add(const EVENT_TYPE& evt){
89  counted_ptr<EVENT_TYPE> copy (new EVENT_TYPE (evt));
90  this->push_back(copy);
91  return true;
92  }
93 
94 
95  virtual bool Add(const MINT::counted_ptr<EVENT_TYPE>& evt){
96  this->push_back(evt);
97  return true;
98  }
99 
100  virtual bool Add(const EventPtrList<EVENT_TYPE>& otherList){
101  if(otherList.empty()) return false;
102  for(unsigned int i=0; i < otherList.size(); i++){
103  this->push_back(otherList.getPtr(i));
104  }
105  return true;
106  }
107 
108  /*
109  virtual double getMax(IReturnRealForEvent* amps){
110  double max=-1;
111  int counter=0;
112  for(unsigned int i=0; i < this->size(); i++){
113  double d=amps->RealVal((*this)[i]);
114  if(d > max || 0 == counter) max=d;
115  counter++;
116  };
117  return max;
118  }
119 
120  virtual double getMin(IReturnRealForEvent* amps){
121  double min = +9999;
122  int counter=0;
123  for(unsigned int i=0; i < this->size(); i++){
124  double d=amps->RealVal((*this)[i]);
125  if(d < min || 0 == counter) min=d;
126  counter++;
127  }
128  return min;
129  }
130  */
131 };
132 
133 }//namespace MINT
134 
135 #endif
136 //
virtual const EVENT_TYPE & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
EventPtrList(const EVENT_TYPE &evt)
Definition: EventPtrList.h:36
void push_back(const MINT::counted_ptr< EVENT_TYPE > &c)
virtual bool Add(const MINT::counted_ptr< EVENT_TYPE > &evt)
Definition: EventPtrList.h:95
virtual bool Add(const EVENT_TYPE &evt)
Definition: EventPtrList.h:88
virtual EVENT_TYPE & getEventRef(unsigned int i)
Definition: EventPtrList.h:52
virtual unsigned int size() const
Definition: EventPtrList.h:76
virtual bool Add(const EventPtrList< EVENT_TYPE > &otherList)
Definition: EventPtrList.h:100
MINT::counted_ptr< EVENT_TYPE > & at(unsigned int i)
EventPtrList< EVENT_TYPE > & operator=(const EventPtrList< EVENT_TYPE > &other)
Definition: EventPtrList.h:62
virtual EVENT_TYPE getEvent(unsigned int i) const
Definition: EventPtrList.h:46
virtual MINT::counted_ptr< EVENT_TYPE > popLastEventPtr()
Definition: EventPtrList.h:80
virtual ~EventPtrList()
Definition: EventPtrList.h:40
virtual counted_ptr< EVENT_TYPE > getPtr(unsigned int i) const
Definition: EventPtrList.h:42
EventPtrList(const EventPtrList< EVENT_TYPE > &other)
Definition: EventPtrList.h:55