MINT2
Public Member Functions | Static Private Attributes | List of all members
DalitzEventPtrList Class Reference

#include <DalitzEventPtrList.h>

Inheritance diagram for DalitzEventPtrList:
MINT::EventPtrList< DalitzEvent > MINT::IMinimalEventList< DalitzEvent > MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > >

Public Member Functions

 DalitzEventPtrList ()
 
 DalitzEventPtrList (const DalitzEventPtrList &other)
 
virtual ~DalitzEventPtrList ()
 
const std::string & className () const
 
int generatePhaseSpaceEvents (int NumEvents, const DalitzEventPattern &pat, TRandom *rnd=0)
 
int generateEvents (unsigned int NumEvents, const DalitzEventPattern &pat, MINT::IReturnRealForEvent< IDalitzEvent > *amps, TRandom *rnd)
 
DalitzHistoSet histoSet () const
 
DalitzHistoSet weightedHistoSet () const
 
DalitzHistoSet reWeightedHistoSet (MINT::IReturnRealForEvent< IDalitzEvent > *w)
 
DalitzHistoSet weighedReWeightedHistoSet (MINT::IReturnRealForEvent< IDalitzEvent > *w)
 
bool save (const std::string &fname="DalitzEvents.root") const
 
bool fromFile (const std::string &fname="DalitzEvents.root")
 
TNtupleD * makeNtuple () const
 
TNtupleD * makeNtuple (const std::string &ntpName) const
 
bool saveAsNtuple (const std::string &fname="DalitzEvents.root") const
 
bool saveAsNtuple (const std::string &fname, const std::string &ntpName) const
 
bool fromNtuple (TTree *ntp)
 
bool fromNtupleFile (const std::string &fname="DalitzEvents.root")
 
- Public Member Functions inherited from MINT::EventPtrList< DalitzEvent >
 EventPtrList ()
 
 EventPtrList (const DalitzEvent &evt)
 
 EventPtrList (const EventPtrList< DalitzEvent > &other)
 
virtual ~EventPtrList ()
 
virtual counted_ptr< DalitzEventgetPtr (unsigned int i) const
 
virtual DalitzEvent getEvent (unsigned int i) const
 
virtual const DalitzEventgetEventRef (unsigned int i) const
 
virtual DalitzEventgetEventRef (unsigned int i)
 
EventPtrList< DalitzEvent > & operator= (const EventPtrList< DalitzEvent > &other)
 
virtual unsigned int size () const
 
virtual MINT::counted_ptr< DalitzEventpopLastEventPtr ()
 
virtual bool Add (const DalitzEvent &evt)
 
virtual bool Add (const MINT::counted_ptr< DalitzEvent > &evt)
 
virtual bool Add (const EventPtrList< DalitzEvent > &otherList)
 
- Public Member Functions inherited from MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > >
 PolymorphVector ()
 
 PolymorphVector (unsigned int N)
 
 PolymorphVector (unsigned int N, const MINT::counted_ptr< DalitzEvent > &c)
 
 PolymorphVector (const PolymorphVector &other)
 
 PolymorphVector (const typename std::vector< MINT::counted_ptr< DalitzEvent > > &other)
 
virtual ~PolymorphVector ()
 
std::vector< MINT::counted_ptr< DalitzEvent > > & theVector ()
 
const std::vector< MINT::counted_ptr< DalitzEvent > > & theVector () const
 
MINT::counted_ptr< DalitzEvent > & operator[] (unsigned int i)
 
const MINT::counted_ptr< DalitzEvent > & operator[] (unsigned int i) const
 
MINT::counted_ptr< DalitzEvent > & at (unsigned int i)
 
const MINT::counted_ptr< DalitzEvent > & at (unsigned int i) const
 
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator begin ()
 
std::vector< MINT::counted_ptr< DalitzEvent > >::const_iterator begin () const
 
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator end ()
 
std::vector< MINT::counted_ptr< DalitzEvent > >::const_iterator end () const
 
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator find (const MINT::counted_ptr< DalitzEvent > &c)
 
std::vector< MINT::counted_ptr< DalitzEvent > >::const_iterator find (const MINT::counted_ptr< DalitzEvent > &c) const
 
MINT::counted_ptr< DalitzEvent > & front ()
 
const MINT::counted_ptr< DalitzEvent > & front () const
 
MINT::counted_ptr< DalitzEvent > & back ()
 
const MINT::counted_ptr< DalitzEvent > & back () const
 
unsigned int size () const
 
bool empty () const
 
void push_back (const MINT::counted_ptr< DalitzEvent > &c)
 
void pop_back ()
 
void erase (typename std::vector< MINT::counted_ptr< DalitzEvent > >::iterator pos)
 
void erase (typename std::vector< MINT::counted_ptr< DalitzEvent > >::iterator first, typename std::vector< MINT::counted_ptr< DalitzEvent > >::iterator last)
 
PolymorphVector< MINT::counted_ptr< DalitzEvent > > & operator= (const PolymorphVector< MINT::counted_ptr< DalitzEvent > > &other)
 
void clear ()
 
void resize (unsigned int N)
 
void resize (unsigned int N, const MINT::counted_ptr< DalitzEvent > &c)
 
 operator const typename std::vector< MINT::counted_ptr< DalitzEvent > > & () const
 
 operator typename std::vector< MINT::counted_ptr< DalitzEvent > > & ()
 
bool operator== (const MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > > &v2) const
 
bool operator!= (const MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > > &v2) const
 
bool operator< (const MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > > &v2) const
 
bool operator> (const MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > > &v2) const
 

Static Private Attributes

static const std::string _className
 

Additional Inherited Members

- Protected Member Functions inherited from MINT::IMinimalEventList< DalitzEvent >
 IMinimalEventList ()
 
- Protected Attributes inherited from MINT::PolymorphVector< MINT::counted_ptr< DalitzEvent > >
std::vector< MINT::counted_ptr< DalitzEvent > > _vec
 

Detailed Description

Definition at line 34 of file DalitzEventPtrList.h.

Constructor & Destructor Documentation

◆ DalitzEventPtrList() [1/2]

DalitzEventPtrList::DalitzEventPtrList ( )

◆ DalitzEventPtrList() [2/2]

DalitzEventPtrList::DalitzEventPtrList ( const DalitzEventPtrList other)

◆ ~DalitzEventPtrList()

DalitzEventPtrList::~DalitzEventPtrList ( )
virtual

Definition at line 33 of file DalitzEventPtrList.cpp.

33  {
34 
35 }

Member Function Documentation

◆ className()

const std::string& DalitzEventPtrList::className ( ) const
inline

Definition at line 45 of file DalitzEventPtrList.h.

45 {return _className;}
static const std::string _className

◆ fromFile()

bool DalitzEventPtrList::fromFile ( const std::string &  fname = "DalitzEvents.root")

Definition at line 153 of file DalitzEventPtrList.cpp.

153  {
154  return fromNtupleFile(fname);
155 }
bool fromNtupleFile(const std::string &fname="DalitzEvents.root")

◆ fromNtuple()

bool DalitzEventPtrList::fromNtuple ( TTree *  ntp)

Definition at line 186 of file DalitzEventPtrList.cpp.

186  {
187  bool dbThis=false;
188  if(dbThis) cout << "about to read ntuple with ptr " << ntp << endl;
189  if(0==ntp) return false;
190  if(ntp->GetEntries() <=0) return false;
191  if(dbThis) cout << " number of entries: " << ntp->GetEntries() << endl;
192  //if(dbThis) cout << " number of variables " << ntp->GetNvar() << endl;
193  bool success=true;
194  for(Long64_t i=0; i< ntp->GetEntries(); i++){
195  if(dbThis){
196  cout << "DalitzEventPtrList::fromNtuple "
197  << " getting " << i << " th entry" << endl;
198  }
199  ntp->GetEntry(i);
200  if(dbThis) cout << " got it" << endl;
202  // success &= evt.fromNtuple(ntp);
203  success &= evt->fromTree(ntp);
204  if(dbThis) cout << " made event" << endl;
205  if(! success){
206  cout << "ERROR in DalitzEventPtrList::fromNtuple"
207  << ", call to DalitzEvent::fromNtuple returned false!"
208  << endl;
209  return false;
210  }
211  this->Add(evt);
212  if(dbThis) cout << " added event" << endl;
213  }
214  if(dbThis) cout << "DalitzEventPtrList::fromNtuple worked!" << endl;
215  return success;
216 }
virtual bool Add(const DalitzEvent &evt)
Definition: EventPtrList.h:88

◆ fromNtupleFile()

bool DalitzEventPtrList::fromNtupleFile ( const std::string &  fname = "DalitzEvents.root")

Definition at line 218 of file DalitzEventPtrList.cpp.

218  {
219  TFile f(fname.c_str());
220  f.cd();
221  TTree* ntp = (TTree*) f.Get(className().c_str());
222  if(0 == ntp){
223  cout << "ERROR in DalitzEventPtrList::fromNtupleFile"
224  << "\n > Can't get ntuple for filename = "
225  << "\n > " << fname << endl;
226  return false;
227  }
228  return fromNtuple(ntp);
229 }
const std::string & className() const
bool fromNtuple(TTree *ntp)

◆ generateEvents()

int DalitzEventPtrList::generateEvents ( unsigned int  NumEvents,
const DalitzEventPattern pat,
MINT::IReturnRealForEvent< IDalitzEvent > *  amps,
TRandom *  rnd 
)

◆ generatePhaseSpaceEvents()

int DalitzEventPtrList::generatePhaseSpaceEvents ( int  NumEvents,
const DalitzEventPattern pat,
TRandom *  rnd = 0 
)

Definition at line 38 of file DalitzEventPtrList.cpp.

41  {
42 
43  cout << "DalitzEventPtrList::generatePhaseSpaceEvents "
44  << " about to generate " << NumEvents
45  << " events to phase space" << endl;
46  time_t tstart = time(0);
47  int reportN = NumEvents/10; // 10 x at least;
48  if(reportN > 10000) reportN = 10000; // at least once every 10k event
49  for(int i=0; i< NumEvents; i++){
50  if( i < 5 || (!(i%reportN))){
51  cout << "DalitzEventPtrList::generatePhaseSpaceEvents "
52  << " generating " << i+1 << "th event."
53  << " with " << pat << " and " << rnd << endl;
54  }
55  counted_ptr<DalitzEvent> evt(new DalitzEvent(pat, rnd));
56  Add(evt);
57  }
58  double delT = difftime(time(0), tstart);
59  cout << " This took " << delT << " s";
60  if(delT > 0){
61  cout << " this is " << NumEvents/delT << " evts/s"
62  << " or " << (NumEvents/delT) * 60<< " evts/min";
63  }
64  cout << endl;
65 
66  return this->size();
67 }
virtual bool Add(const DalitzEvent &evt)
Definition: EventPtrList.h:88
virtual unsigned int size() const
Definition: EventPtrList.h:76

◆ histoSet()

DalitzHistoSet DalitzEventPtrList::histoSet ( ) const

Definition at line 110 of file DalitzEventPtrList.cpp.

110  {
111  DalitzHistoSet hs;
112  for(unsigned int i=0; i< this->size(); i++){
113  DalitzEvent evt(this->getEventRef(i));
114  hs.addEvent(evt);
115  }
116  return hs;
117 }
virtual const DalitzEvent & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
virtual unsigned int size() const
Definition: EventPtrList.h:76
void addEvent(const IDalitzEvent &evt, double weight=1)

◆ makeNtuple() [1/2]

TNtupleD * DalitzEventPtrList::makeNtuple ( ) const

Definition at line 72 of file DalitzEventPtrList.cpp.

72  {
73  return makeNtuple(className());
74 }
const std::string & className() const
TNtupleD * makeNtuple() const

◆ makeNtuple() [2/2]

TNtupleD * DalitzEventPtrList::makeNtuple ( const std::string &  ntpName) const

Definition at line 82 of file DalitzEventPtrList.cpp.

82  {
83 
84  if(this->empty()) return (TNtupleD*) 0;
85  std::string varNameString= (*(this->begin()))->makeNtupleVarnames();
86  TNtupleD* ntp = new TNtupleD(className().c_str()
87  , ntpName.c_str()
88  , varNameString.c_str());
89 
90  unsigned int arraySize = (*(this->begin()))->ntupleVarArraySize();
91  vector<Double_t> array(arraySize);
92 
93 
94  for(vector<counted_ptr<DalitzEvent> >::const_iterator it = this->begin();
95  it != this->end(); it++){
96 
97  bool success = (*it)->fillNtupleVarArray(array);
98  if(! success){
99  cout << "ERROR in DalitzEventListt::makeNtuple"
100  << ", call to DalitzEvent::fillNtupleVarArray"
101  << " returned failure"
102  << endl;
103  }else{
104  ntp->Fill(&(array[0]));
105  }
106  }
107  return ntp;
108 }
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator end()
const std::string & className() const
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator begin()

◆ reWeightedHistoSet()

DalitzHistoSet DalitzEventPtrList::reWeightedHistoSet ( MINT::IReturnRealForEvent< IDalitzEvent > *  w)

Definition at line 127 of file DalitzEventPtrList.cpp.

127  {
128  // mainly for diagnostics
129  DalitzHistoSet hs;
130  if(0 == w) return hs;
131  for(unsigned int i=0; i< this->size(); i++){
132  DalitzEvent evt(this->getEventRef(i));
133  hs.addEvent(evt, w->RealVal(evt) );
134  }
135  return hs;
136 }
virtual const DalitzEvent & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
virtual double RealVal(EVENT_TYPE &evt)=0
virtual unsigned int size() const
Definition: EventPtrList.h:76
void addEvent(const IDalitzEvent &evt, double weight=1)

◆ save()

bool DalitzEventPtrList::save ( const std::string &  fname = "DalitzEvents.root") const

Definition at line 150 of file DalitzEventPtrList.cpp.

150  {
151  return saveAsNtuple(fname);
152 }
bool saveAsNtuple(const std::string &fname="DalitzEvents.root") const

◆ saveAsNtuple() [1/2]

bool DalitzEventPtrList::saveAsNtuple ( const std::string &  fname = "DalitzEvents.root") const

Definition at line 157 of file DalitzEventPtrList.cpp.

158  {
159  return saveAsNtuple(fname, className());
160 }
const std::string & className() const
bool saveAsNtuple(const std::string &fname="DalitzEvents.root") const

◆ saveAsNtuple() [2/2]

bool DalitzEventPtrList::saveAsNtuple ( const std::string &  fname,
const std::string &  ntpName 
) const

Definition at line 162 of file DalitzEventPtrList.cpp.

164  {
165  if(this->empty()){
166  cout << "WARNING in DalitzEventPtrList::saveAsNtuple!"
167  << "\n\tyou are trying to save me to the file: "
168  << fname
169  << "\n\tbut I have only " << this->size()
170  << " events."
171  << " I won't create the file."
172  << endl;
173  return false;
174  }
175  TFile* f = TFile::Open(fname.c_str(), "RECREATE");
176  f->cd();
177  TNtupleD* ntp = makeNtuple(ntpName);
178  if(0 != ntp) ntp->Write();
179  f->Close();
180  //ntp->Delete("all");
181 
182  // delete ntp;
183  return true;
184 }
virtual unsigned int size() const
Definition: EventPtrList.h:76
TNtupleD * makeNtuple() const

◆ weighedReWeightedHistoSet()

DalitzHistoSet DalitzEventPtrList::weighedReWeightedHistoSet ( MINT::IReturnRealForEvent< IDalitzEvent > *  w)

Definition at line 138 of file DalitzEventPtrList.cpp.

138  {
139  // mainly for diagnostics
140  DalitzHistoSet hs;
141  if(0 == w) return hs;
142  for(unsigned int i=0; i< this->size(); i++){
143  DalitzEvent evt(this->getEventRef(i));
144  hs.addEvent(evt, w->RealVal(evt) * evt.getWeight());
145  }
146  return hs;
147 }
virtual const DalitzEvent & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
virtual double RealVal(EVENT_TYPE &evt)=0
virtual unsigned int size() const
Definition: EventPtrList.h:76
void addEvent(const IDalitzEvent &evt, double weight=1)

◆ weightedHistoSet()

DalitzHistoSet DalitzEventPtrList::weightedHistoSet ( ) const

Definition at line 118 of file DalitzEventPtrList.cpp.

118  {
119  // mainly for diagnostics
120  DalitzHistoSet hs;
121  for(unsigned int i=0; i< this->size(); i++){
122  DalitzEvent evt(this->getEventRef(i));
123  hs.addEvent(evt, evt.getWeight());
124  }
125  return hs;
126 }
virtual const DalitzEvent & getEventRef(unsigned int i) const
Definition: EventPtrList.h:49
virtual unsigned int size() const
Definition: EventPtrList.h:76
void addEvent(const IDalitzEvent &evt, double weight=1)

Member Data Documentation

◆ _className

const std::string DalitzEventPtrList::_className
staticprivate

Definition at line 37 of file DalitzEventPtrList.h.


The documentation for this class was generated from the following files: