12 #include "TObjString.h"    43     cout << 
"ERROR in DalitzEventList::DalitzEventList(TNtupleD* ntp)"    44      << 
"\n   > problem creating myself from ntuple"    54   cout << 
"DalitzEventList::generatePhaseSpaceEvents "    55        << 
" about to generate " << NumEvents 
    56        << 
" events to phase space" << endl;
    57   time_t tstart = time(0);
    58   int reportN = NumEvents/10; 
    59   if(reportN > 10000) reportN = 10000; 
    60   for(
int i=0; i< NumEvents; i++){
    61     if( i < 5 || (!(i%reportN))){
    62       cout << 
"DalitzEventList::generatePhaseSpaceEvents "     63        << 
" generating " << i+1 << 
"th event."    64        << 
" with " << pat << 
" and " << rnd << endl;
    68   double delT = difftime(time(0), tstart);
    69   cout << 
" This took " << delT << 
" s";
    71     cout << 
" this is " << NumEvents/delT << 
" evts/s"    72      << 
" or " << (NumEvents/delT) * 60<< 
" evts/min";
    80                 , 
const std::string& 
name    86   if(this->
empty()) 
return (TH1D*)0;
    89   double mi = ((*this)[0]).sijMin(sijIndices)/units;
    90   double ma = ((*this)[0]).sijMax(sijIndices)/units;
    98   TH1D* histo = 
new TH1D(
name.c_str(), 
name.c_str(), nbins, mi, ma);
   100   for(
unsigned int i = 0; i < this->
size(); i++){
   103     if(0 != weightFunction) w = weightFunction->
RealVal(evt);
   104     double x= evt.
sij(sijIndices)/units;
   105     if(opt == 
'm') x = sqrt(x);
   112                   ,
const std::vector<int> sijIndicesY
   113                   , 
const std::string& 
name   119   if(this->
empty()) 
return (TH2D*)0;
   123   double miX = ((*this)[0]).sijMin(sijIndicesX)/units;
   124   double maX = ((*this)[0]).sijMax(sijIndicesX)/units;
   125   double miY = ((*this)[0]).sijMin(sijIndicesY)/units;
   126   double maY = ((*this)[0]).sijMax(sijIndicesY)/units;
   133   miX -= (maX - miX)*eps;
   134   maX += (maX - miX)*eps;
   135   miY -= (maY - miY)*eps;
   136   maY += (maY - miY)*eps;
   138   TH2D* histo = 
new TH2D(
name.c_str()
   142   for(
unsigned int i = 0; i < this->
size(); i++){
   145     if(0 != weightFunction) w = weightFunction->
RealVal(evt);
   146     double x= evt.
sij(sijIndicesX)/units;
   147     double y= evt.
sij(sijIndicesY)/units;
   152     histo->Fill(x, y, w);
   161   std::string ntp_str=
"";
   162   int nd = ((*this)[0]).eventPattern().size()-1;
   163   if(nd < 3) 
return (TNtupleD*)0;
   167   for(namedVMap::const_iterator it = sijList.begin();
   168       it != sijList.end(); it++){    
   169     std::string entry_name = 
"s" + it->first + 
":";
   170     ntp_str += entry_name;
   173   for(namedVMap::const_iterator it = sijList.begin();
   174       it != sijList.end(); it++){    
   175     std::string entry_name = 
"m" + it->first + 
":";
   176     ntp_str += entry_name;
   179   ntp_str += 
"weight:";
   183   std::string ntp_id = 
className() + 
"_sij";
   184   std::string 
name   = name_prefix + 
"_sij";
   185   TNtupleD* ntp = 
new TNtupleD(ntp_id.c_str()
   189   Double_t* array = 
new Double_t[arraySize];
   191   for(
unsigned int i = 0; i < this->
size(); i++){
   193     for(namedVMap::const_iterator it = sijList.begin();
   194     it != sijList.end(); it++){
   195       array[arrayIndex]=((*this)[i]).sij(it->second)/units;
   198     for(namedVMap::const_iterator it = sijList.begin();
   199     it != sijList.end(); it++){    
   200       std::string entry_name = 
"m" + it->first;
   201       double sijtemp = ((*this)[i]).sij(it->second)/units;
   203     array[arrayIndex]=sqrt(sijtemp);
   205     array[arrayIndex] = -9999.;
   213     if(0 != weightFunction) fcn = weightFunction->
RealVal(evt);
   214     array[arrayIndex] = fcn;
   230   if(this->
empty()) 
return ps;
   232   int nd = ((*this)[0]).eventPattern().
size()-1;
   233   if(nd < 3) 
return ps;
   237   for(namedVMap::const_iterator it = sijList.begin();
   238       it != sijList.end(); it++){    
   239     std::string 
name = name_prefix + 
"_s" + it->first;
   241     TH1D* newPlots = 
makePlot(it->second
   247     if(0 != newPlots) ps.
push_back(newPlots);
   249     name = name_prefix + 
"_m" + it->first;
   250     TH1D* newPlotm = 
makePlot(it->second
   256     if(0 != newPlotm) ps.
push_back(newPlotm);
   257     namedVMap::const_iterator jt = it;
   259     for(; jt != sijList.end(); jt++){    
   260       std::string name2D = name_prefix + jt->first + 
"_vs_" + it->first;
   262       TH2D* newPlot2D = 
makePlot2D(it->second, jt->second, name2D
   263                    , weightFunction, nbins2D, units
   266       if(0 != newPlot2D) ps.
push_back(newPlot2D);
   269   TNtupleD* newPlotNtp = 
makePlotNtp(name_prefix, weightFunction, units);
   288   if(this->
empty()) 
return (TNtupleD*) 0;
   289   std::string varNameString= ((this->
begin()))->makeNtupleVarnames();
   290   TNtupleD* ntp = 
new TNtupleD(
className().c_str()
   292                    , varNameString.c_str());
   294   ntp->SetDirectory(0);
   296   int arraySize = ((this->
begin()))->ntupleVarArraySize();
   297   Double_t *array = 
new Double_t[arraySize];
   300   for(vector<DalitzEvent>::const_iterator it = this->
begin();
   301       it != this->
end(); it++){
   303     bool success = (it)->fillNtupleVarArray(array, arraySize);
   305       cout << 
"ERROR in DalitzEventList::makeNtuple"   306        << 
", call to DalitzEvent::fillNtupleVarArray"   307        << 
" returned failure"   330                    , 
const std::string& ntpName
   333     cout << 
"WARNING in DalitzEventList::saveAsNtuple!"   334      << 
"\n\tyou are trying to save me to the file: "   336      << 
"\n\tbut I have only " << this->
size()
   338      << 
" I won't create the file."   342   TFile f(fname.c_str(), 
"RECREATE");
   354   if(dbThis) cout << 
"about to read ntuple with ptr " << ntp << endl;
   355   if(0==ntp) 
return false;
   356   if(ntp->GetEntries() <=0) 
return false;
   357   if(dbThis) cout << 
" number of entries: " << ntp->GetEntries() << endl;
   360   for(Long64_t i=0; i< ntp->GetEntries(); i++){
   362       cout << 
"DalitzEventList::fromNtuple "   363        << 
" getting " << i << 
" th entry" << endl;
   366     if(dbThis) cout << 
" got it" << endl;
   370     if(dbThis) cout << 
" made event" << endl;
   372       cout << 
"ERROR in DalitzEventList::fromNtuple"   373        << 
", call to DalitzEvent::fromNtuple returned false!"   378     if(dbThis) cout << 
" added event" << endl;
   380   if(dbThis) cout << 
"DalitzEventList::fromNtuple worked!" << endl;
   386   if(dbThis) cout << 
"about to read ntuple with ptr " << ntp << endl;
   387   if(0==ntp) 
return false;
   388   if(ntp->GetEntries() <=0) 
return false;
   389   if(dbThis) cout << 
" number of entries: " << ntp->GetEntries() << endl;
   393   for(Long64_t i=0; i< ntp->GetEntries(); i++){
   395       cout << 
"DalitzEventList::fromNtuple "   396        << 
" getting " << i << 
" th entry" << endl;
   398     double rand = Rand.Rndm();
   402         if(dbThis) cout << 
" got it" << endl;
   406         if(dbThis) cout << 
" made event" << endl;
   408           cout << 
"ERROR in DalitzEventList::fromNtuple"   409            << 
", call to DalitzEvent::fromNtuple returned false!"   414         if(dbThis) cout << 
" added event" << endl;
   417   if(dbThis) cout << 
"DalitzEventList::fromNtuple worked!" << endl;
   422   TFile f(fname.c_str());
   424   TTree* ntp = (TTree*) f.Get(
className().c_str());
   426     cout << 
"ERROR in DalitzEventList::fromNtupleFile"   427      << 
"\n   > Can't get ntuple for filename = "   428      << 
"\n   > " << fname << endl;
   436   for(
unsigned int i=0; i< this->
size(); i++){
   444   for(
unsigned int i=0; i< this->
size(); i++){
   453   if(0 == w) 
return hs;
   454   for(
unsigned int i=0; i< this->
size(); i++){
   463   if(0 == w) 
return hs;
   464   for(
unsigned int i=0; i< this->
size(); i++){
 
virtual bool Add(const DalitzEvent &evt)
 
bool fromFile(const std::string &fname="DalitzEvents.root")
 
TNtupleD * makeNtuple() const
 
std::vector< DalitzEvent >::iterator end()
 
virtual double sij(const std::vector< int > &indices) const
 
void push_back(const T &c)
 
DalitzHistoSet weighedReWeightedHistoSet(MINT::IReturnRealForEvent< IDalitzEvent > *w)
 
bool save(const std::string &fname="DalitzEvents.root") const
 
TH2D * makePlot2D(const std::vector< int > sijIndicesX, const std::vector< int > sijIndicesY, const std::string &name, MINT::IReturnRealForEvent< IDalitzEvent > *weightFunction=0, int nbins=10, double units=GeV *GeV, char opt='s')
 
bool fromTree(TTree *tree)
 
virtual double RealVal(EVENT_TYPE &evt)=0
 
DalitzHistoSet reWeightedHistoSet(MINT::IReturnRealForEvent< IDalitzEvent > *w)
 
bool fromNtupleFile(const std::string &fname="DalitzEvents.root")
 
static const std::string _className
 
DalitzHistoSet weightedHistoSet() const
 
TNtupleD * makePlotNtp(const std::string &name_prefix="DalitzPlotNtp", MINT::IReturnRealForEvent< IDalitzEvent > *weightFunction=0, double units=GeV *GeV)
 
bool makePlots(const std::string &filename) const
 
bool fromNtuple(TTree *ntp)
 
virtual double getWeight() const
 
PlotSet makeAllPlots(const std::string &name_prefix, MINT::IReturnRealForEvent< IDalitzEvent > *weightFunction=0, int nbins1D=100, int nbins2D=10, double units=GeV *GeV)
 
std::vector< DalitzEvent >::iterator begin()
 
void addEvent(const IDalitzEvent &evt, double weight=1)
 
unsigned int size() const
 
virtual unsigned int size() const
 
const std::string & className() const
 
DalitzHistoSet histoSet() const
 
bool saveAsNtuple(const std::string &fname="DalitzEvents.root") const
 
int generatePhaseSpaceEvents(int NumEvents, const DalitzEventPattern &pat, TRandom *rnd=0)
 
TH1D * makePlot(const std::vector< int > sij, const std::string &name, MINT::IReturnRealForEvent< IDalitzEvent > *weightFunction=0, int nbins=100, double units=GeV *GeV, char opt='s')
 
bool save(const std::string &filename="DalitzHistos.root") const