12 #include "TObjString.h" 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;
48 if(reportN > 10000) reportN = 10000;
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;
58 double delT = difftime(time(0), tstart);
59 cout <<
" This took " << delT <<
" s";
61 cout <<
" this is " << NumEvents/delT <<
" evts/s" 62 <<
" or " << (NumEvents/delT) * 60<<
" evts/min";
84 if(this->
empty())
return (TNtupleD*) 0;
85 std::string varNameString= (*(this->
begin()))->makeNtupleVarnames();
86 TNtupleD* ntp =
new TNtupleD(
className().c_str()
88 , varNameString.c_str());
90 unsigned int arraySize = (*(this->
begin()))->ntupleVarArraySize();
91 vector<Double_t> array(arraySize);
95 it != this->
end(); it++){
97 bool success = (*it)->fillNtupleVarArray(array);
99 cout <<
"ERROR in DalitzEventListt::makeNtuple" 100 <<
", call to DalitzEvent::fillNtupleVarArray" 101 <<
" returned failure" 104 ntp->Fill(&(array[0]));
112 for(
unsigned int i=0; i< this->
size(); i++){
121 for(
unsigned int i=0; i< this->
size(); i++){
130 if(0 == w)
return hs;
131 for(
unsigned int i=0; i< this->
size(); i++){
141 if(0 == w)
return hs;
142 for(
unsigned int i=0; i< this->
size(); i++){
163 ,
const std::string& ntpName
166 cout <<
"WARNING in DalitzEventPtrList::saveAsNtuple!" 167 <<
"\n\tyou are trying to save me to the file: " 169 <<
"\n\tbut I have only " << this->
size()
171 <<
" I won't create the file." 175 TFile* f = TFile::Open(fname.c_str(),
"RECREATE");
178 if(0 != ntp) ntp->Write();
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;
194 for(Long64_t i=0; i< ntp->GetEntries(); i++){
196 cout <<
"DalitzEventPtrList::fromNtuple " 197 <<
" getting " << i <<
" th entry" << endl;
200 if(dbThis) cout <<
" got it" << endl;
204 if(dbThis) cout <<
" made event" << endl;
206 cout <<
"ERROR in DalitzEventPtrList::fromNtuple" 207 <<
", call to DalitzEvent::fromNtuple returned false!" 212 if(dbThis) cout <<
" added event" << endl;
214 if(dbThis) cout <<
"DalitzEventPtrList::fromNtuple worked!" << endl;
219 TFile f(fname.c_str());
221 TTree* ntp = (TTree*) f.Get(
className().c_str());
223 cout <<
"ERROR in DalitzEventPtrList::fromNtupleFile" 224 <<
"\n > Can't get ntuple for filename = " 225 <<
"\n > " << fname << endl;
virtual const DalitzEvent & getEventRef(unsigned int i) const
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator end()
static const std::string _className
virtual bool Add(const DalitzEvent &evt)
DalitzHistoSet weighedReWeightedHistoSet(MINT::IReturnRealForEvent< IDalitzEvent > *w)
bool fromTree(TTree *tree)
virtual double RealVal(EVENT_TYPE &evt)=0
int generatePhaseSpaceEvents(int NumEvents, const DalitzEventPattern &pat, TRandom *rnd=0)
DalitzHistoSet histoSet() const
virtual unsigned int size() const
bool fromFile(const std::string &fname="DalitzEvents.root")
const std::string & className() const
virtual double getWeight() const
std::vector< MINT::counted_ptr< DalitzEvent > >::iterator begin()
void addEvent(const IDalitzEvent &evt, double weight=1)
DalitzHistoSet weightedHistoSet() const
bool fromNtupleFile(const std::string &fname="DalitzEvents.root")
bool saveAsNtuple(const std::string &fname="DalitzEvents.root") const
virtual ~DalitzEventPtrList()
bool fromNtuple(TTree *ntp)
TNtupleD * makeNtuple() const
DalitzHistoSet reWeightedHistoSet(MINT::IReturnRealForEvent< IDalitzEvent > *w)
bool save(const std::string &fname="DalitzEvents.root") const