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

#include <DalitzHistogram.h>

Public Member Functions

 DalitzHistogram ()
 
 DalitzHistogram (const DalitzCoordSet &c, const DalitzEventPattern &p, int bins=200, double units=GeV *GeV)
 
 DalitzHistogram (const DalitzHistogram &other)
 
virtual ~DalitzHistogram ()
 
const std::string & name () const
 
void smartTitle (const DalitzCoordSet &c_in, const DalitzEventPattern &pat_in)
 
const std::string smartTitle () const
 
const std::string hname () const
 
const std::string & htitle () const
 
const std::string & dirName () const
 
const DalitzEventPatternpattern () const
 
void init (const DalitzCoordSet &c, const DalitzEventPattern &p, int bins=100, double units=GeV *GeV)
 
bool saveAsDir (const std::string &asSubdirOf=".") const
 
bool retrieveFromDir (const std::string &asSubdirOf=".", const char *theName=0)
 
void add (const DalitzHistogram &addMeToYou, double weight=1)
 
void multiply (const DalitzHistogram &multiplyWith)
 
void divide (const DalitzHistogram &divideBy)
 
void setNormFactor (double f=1)
 
void addEvent (const IDalitzEvent &evt, double weight=1)
 
MINT::const_counted_ptr< TH1 > histo () const
 
MINT::counted_ptr< TH1 > histo ()
 
const DalitzCoordSetcoord () const
 
DalitzCoordSetcoord ()
 
void scale (double sf)
 
void setTitle (const std::string &title)
 
void clearHisto ()
 
bool draw (const std::string &baseName="", const std::string &drawOpt="", const std::string &format="eps") const
 
bool drawWithFit (const DalitzHistogram &fit, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
 
bool drawWithFit (TCanvas &can, const DalitzHistogram &fit, const std::string &baseName="", const std::string &format="eps", const std::string &fitDrawOpt="HIST C SAME") const
 
bool drawEachAmp (TCanvas &can, const std::string &baseName="", const std::string &drawOpt="SAME", const std::string &format="eps") const
 
MINT::counted_ptr< TH1 > getHisto ()
 
double integral () const
 
DalitzHistogramoperator= (const DalitzHistogram &other)
 

Private Member Functions

void makeName ()
 
bool makeDirectory (const std::string &asSubdirOf=".") const
 
std::string valueFileName (const std::string &asSubdirOf=".", const char *theName=0) const
 
std::string histoFileName (const std::string &asSubdirOf=".", const char *theName=0) const
 
bool saveValues (const std::string &inDir=".") const
 
bool retrieveValues (const std::string &fromDirectory, const char *theName=0)
 
bool saveHisto (const std::string &inDir=".") const
 
bool retrieveHisto (const std::string &fromDir, const char *theName=0)
 

Private Attributes

double _units
 
int _nbins
 
MINT::counted_ptr< TH1 > _h
 
DalitzCoordSet _c
 
DalitzEventPattern _pat
 
std::string _name
 
std::string _smartTitle
 
TTree * _tree
 
std::vector< int > _patForTree
 

Detailed Description

Definition at line 24 of file DalitzHistogram.h.

Constructor & Destructor Documentation

◆ DalitzHistogram() [1/3]

DalitzHistogram::DalitzHistogram ( )

Definition at line 34 of file DalitzHistogram.cpp.

35  : _units(GeV*GeV), _h(0), _c(), _pat()
36  , _name("noName"), _tree(0), _patForTree()
37 {
38 }
MINT::counted_ptr< TH1 > _h
std::vector< int > _patForTree
DalitzCoordSet _c
static const double GeV
std::string _name
DalitzEventPattern _pat

◆ DalitzHistogram() [2/3]

DalitzHistogram::DalitzHistogram ( const DalitzCoordSet c,
const DalitzEventPattern p,
int  bins = 200,
double  units = GeV*GeV 
)

Definition at line 40 of file DalitzHistogram.cpp.

45  : _units(units), _nbins(bins), _h(0), _c(), _pat()
46  , _name("noName"), _tree(0), _patForTree()
47 {
48  init(c, pat);
49 }
MINT::counted_ptr< TH1 > _h
std::vector< int > _patForTree
void init(const DalitzCoordSet &c, const DalitzEventPattern &p, int bins=100, double units=GeV *GeV)
DalitzCoordSet _c
std::string _name
DalitzEventPattern _pat

◆ DalitzHistogram() [3/3]

DalitzHistogram::DalitzHistogram ( const DalitzHistogram other)

Definition at line 93 of file DalitzHistogram.cpp.

94  : _units(other._units)
95  , _nbins(other._nbins)
96  , _h(0)
97  , _c(other._c)
98  , _pat(other._pat)
99  , _name(other._name)
100  , _tree(0)
101  , _patForTree(other._patForTree)
102 {
103  bool dbThis=false;
104  if(0 != other._h){
105  _h = counted_ptr<TH1>((TH1*) other._h->Clone());
106  if(0 == _h){
107  cout << "Error in DalitzHistogram copy constructor"
108  << endl;
109  throw "oh man!";
110  }
111  _h->SetDirectory(0);
112  }
113  if(dbThis){
114  cout << "DalitzHistogram copy ctor" << endl;
115  cout << "pat before: " << other._pat
116  << ", and after " << _pat << endl;
117  }
118 }
MINT::counted_ptr< TH1 > _h
std::vector< int > _patForTree
DalitzCoordSet _c
std::string _name
DalitzEventPattern _pat

◆ ~DalitzHistogram()

DalitzHistogram::~DalitzHistogram ( )
virtual

Definition at line 120 of file DalitzHistogram.cpp.

120  {
121 
122 }

Member Function Documentation

◆ add()

void DalitzHistogram::add ( const DalitzHistogram addMeToYou,
double  weight = 1 
)

Definition at line 247 of file DalitzHistogram.cpp.

247  {
248  bool dbThis=false;
249 
250  if(0 == addMeToYou.histo()){
251  cout << "WARNING in DalitzHistogram::add(const DalitzHistogram&): "
252  << " Trying to add a DalitzHistogram w/o histogram to me"
253  << " I'll treat it as a zero (i.e. I'll do nothing)."
254  << endl;
255  return;
256  }
257  if(0 == histo()){
258  if(dbThis){
259  cout << "WARNING in DalitzHistogram::add(const DalitzHistogram&): "
260  << " Trying to add a DalitzHistogram to me although I have"
261  << " no histogram myself - treating myself as zero."
262  << endl;
263  }
264  (*this) = addMeToYou;
265  makeName();
266  _h->SetNameTitle(hname().c_str(), htitle().c_str());
267  // same as before, but repeated for robustness - in case
268  // the other histogram had a funny name.
269  return;
270  }
271  if(_c != addMeToYou._c){
272  cout << "WARNING in DalitzHistogram::add(const DalitzHistogram&): "
273  << " adding histograms for different co-ordinates!"
274  << "\n\t" << _c << " != " << addMeToYou._c
275  << "\n\t I'll go ahead with it, but it might not be what you want."
276  << endl;
277  }
278  _h->Add((addMeToYou.histo().get()), weight);
279  return;
280 }
MINT::counted_ptr< TH1 > _h
MINT::const_counted_ptr< TH1 > histo() const
const std::string hname() const
DalitzCoordSet _c
const std::string & htitle() const

◆ addEvent()

void DalitzHistogram::addEvent ( const IDalitzEvent evt,
double  weight = 1 
)

Definition at line 361 of file DalitzHistogram.cpp.

361  {
362  if(0 == _h){
363  cout << "Error in DalitzHistogram::addEvent: trying to fill empty histogram"
364  << endl;
365  return;
366  }
367  _h->Fill(evt.sij(_c.begin()->second)/_units, weight);
368 }
MINT::counted_ptr< TH1 > _h
virtual double sij(const MINT::PolymorphVector< int > &indices) const =0
DalitzCoordSet _c
std::map< Key, Val >::iterator begin()
Definition: PolymorphMap.h:26

◆ clearHisto()

void DalitzHistogram::clearHisto ( )

Definition at line 377 of file DalitzHistogram.cpp.

377  {
378  if(0 == _h) return;
379  _h->Clear();
380  //_h->Scale(0.0);
381 }
MINT::counted_ptr< TH1 > _h

◆ coord() [1/2]

const DalitzCoordSet& DalitzHistogram::coord ( ) const
inline

Definition at line 89 of file DalitzHistogram.h.

89 {return _c;}
DalitzCoordSet _c

◆ coord() [2/2]

DalitzCoordSet& DalitzHistogram::coord ( )
inline

Definition at line 90 of file DalitzHistogram.h.

90 {return _c;}
DalitzCoordSet _c

◆ dirName()

const std::string & DalitzHistogram::dirName ( ) const

Definition at line 477 of file DalitzHistogram.cpp.

477  {
478  return name();
479 }
const std::string & name() const

◆ divide()

void DalitzHistogram::divide ( const DalitzHistogram divideBy)

Definition at line 321 of file DalitzHistogram.cpp.

321  {
322  bool dbThis=false;
323 
324  if(0 == divideBy.histo()){
325  cout << "WARNING in DalitzHistogram::divide(const DalitzHistogram&): "
326  << " Trying to divide a DalitzHistogram w/o histogram to me"
327  << " I guess I should crash, but I'll do nothing."
328  << endl;
329  // this->clearHisto();
330  return;
331  }
332  if(0 == histo()){
333  if(dbThis){
334  cout << "WARNING in DalitzHistogram::divide(const DalitzHistogram&): "
335  << " Trying to divide a DalitzHistogram to me although I have"
336  << " no histogram myself - treating myself as zero."
337  << endl;
338  }
339  _h = counted_ptr<TH1>((TH1*) divideBy.histo()->Clone());
340  if(0 == _h){
341  cout << "Error in DalitzHistogram::divide: _h = " << _h << endl;
342  throw "mistake";
343  }
344  _h->SetDirectory(0);
345  _c = divideBy._c;
346  makeName();
347  _h->SetNameTitle(hname().c_str(), htitle().c_str());
348  _h->Clear();
349  return;
350  }
351  if(_c != divideBy._c){
352  cout << "WARNING in DalitzHistogram::divide(const DalitzHistogram&): "
353  << " divideing histograms for different co-ordinates!"
354  << "\n\t" << _c << " != " << divideBy._c
355  << "\n\t I'll go ahead with it, but it might not be what you want."
356  << endl;
357  }
358  _h->Divide((divideBy.histo().get()));
359  return;
360 }
MINT::counted_ptr< TH1 > _h
MINT::const_counted_ptr< TH1 > histo() const
const std::string hname() const
DalitzCoordSet _c
const std::string & htitle() const

◆ draw()

bool DalitzHistogram::draw ( const std::string &  baseName = "",
const std::string &  drawOpt = "",
const std::string &  format = "eps" 
) const

Definition at line 383 of file DalitzHistogram.cpp.

386  {
387  if(0 == _h) return false;
388  string fname = baseName + _c.nameFileSave() + "." + format;
389  TCanvas can;
390  _h->Draw(drawOpt.c_str());
391  can.Print(fname.c_str());
392  return true;
393 }
std::string nameFileSave() const
MINT::counted_ptr< TH1 > _h
DalitzCoordSet _c

◆ drawEachAmp()

bool DalitzHistogram::drawEachAmp ( TCanvas &  can,
const std::string &  baseName = "",
const std::string &  drawOpt = "SAME",
const std::string &  format = "eps" 
) const

Definition at line 763 of file DalitzHistogram.cpp.

767  {
768  if(0 == _h) return false;
769  string fname = baseName + _c.nameFileSave() + "." + format;
770  _h->Draw(drawOpt.c_str());
771 // can.Print(fname.c_str());
772  return true;
773 }
std::string nameFileSave() const
MINT::counted_ptr< TH1 > _h
DalitzCoordSet _c

◆ drawWithFit() [1/2]

bool DalitzHistogram::drawWithFit ( const DalitzHistogram fit,
const std::string &  baseName = "",
const std::string &  format = "eps",
const std::string &  fitDrawOpt = "HIST C SAME" 
) const

Definition at line 673 of file DalitzHistogram.cpp.

677  {
678  if(0 == _h) return false;
679  string fname = baseName + _c.nameFileSave() + "." + format;
680  TCanvas can;
681 
682  counted_ptr<TH1> h_c( (TH1*) histo()->Clone());
683  if(0 == h_c){
684  cout << "Error in DalitzHistogram::drawWithFit, failed to clone histo h_c"
685  << endl;
686  throw "rubbish";
687  }
688  h_c->SetDirectory(0);
689  counted_ptr<TH1> fit_c( (TH1*) fit.histo()->Clone());
690  if(0 == fit_c){
691  cout << "Error in DalitzHistogram::drawWithFit, failed to clone histo fit_c"
692  << endl;
693  throw "rubbish";
694  }
695  fit_c->SetDirectory(0);
696  fit_c->Scale(h_c->Integral()/fit_c->Integral());
697 
698  double maxiThis = h_c->GetMaximum();//Stored();
699  double maxiThat = fit_c->GetMaximum();//Stored();
700 
701  if(maxiThat > maxiThis) h_c->SetMaximum(maxiThat*1.05);
702  // else h_c->SetMaximum(maxiThis);
703 
704  h_c->Draw("E1");
705 
706  fit_c->SetLineWidth(3);
707  fit_c->SetLineColor(2);
708  fit_c->SetMarkerColor(2);
709 
710  fit_c->Draw(fitDrawOpt.c_str());
711  can.Print(fname.c_str());
712  return true;
713 }
std::string nameFileSave() const
MINT::counted_ptr< TH1 > _h
MINT::const_counted_ptr< TH1 > histo() const
DalitzCoordSet _c

◆ drawWithFit() [2/2]

bool DalitzHistogram::drawWithFit ( TCanvas &  can,
const DalitzHistogram fit,
const std::string &  baseName = "",
const std::string &  format = "eps",
const std::string &  fitDrawOpt = "HIST C SAME" 
) const

Definition at line 715 of file DalitzHistogram.cpp.

720  {
721  if(0 == _h) return false;
722  string fname = baseName + _c.nameFileSave() + "." + format;
723 
724  counted_ptr<TH1> h_c( (TH1*) histo()->Clone());
725  if(0 == h_c){
726  cout << "Error in DalitzHistogram::drawWithFit 2"
727  << ", failed to clone histo h_c"
728  << endl;
729  throw "rubbish";
730  }
731  h_c->SetDirectory(0);
732 
733  counted_ptr<TH1> fit_c( (TH1*) fit.histo()->Clone());
734  if(0 == fit_c){
735  cout << "Error in DalitzHistogram::drawWithFit 2"
736  << ", failed to clone histo fit_c"
737  << endl;
738  throw "rubbish";
739  }
740  fit_c->SetDirectory(0);
741  fit_c->Scale(h_c->Integral()/fit_c->Integral());
742 
743  double maxiThis = h_c->GetMaximum();//Stored();
744  double maxiThat = fit_c->GetMaximum();//Stored();
745 
746  if(maxiThat > maxiThis) h_c->SetMaximum(maxiThat*1.05);
747  // else h_c->SetMaximum(maxiThis);
748 
749  h_c->Draw("E1");
750 
751  fit_c->SetLineWidth(3);
752  fit_c->SetLineColor(2);
753  fit_c->SetMarkerColor(2);
754 
755  fit_c->Draw(fitDrawOpt.c_str());
756  can.Print(fname.c_str());
757  return true;
758 }
std::string nameFileSave() const
MINT::counted_ptr< TH1 > _h
MINT::const_counted_ptr< TH1 > histo() const
DalitzCoordSet _c

◆ getHisto()

MINT::counted_ptr< TH1 > DalitzHistogram::getHisto ( )

Definition at line 759 of file DalitzHistogram.cpp.

759  {
760  return _h;
761 }
MINT::counted_ptr< TH1 > _h

◆ histo() [1/2]

MINT::const_counted_ptr<TH1> DalitzHistogram::histo ( ) const
inline

Definition at line 87 of file DalitzHistogram.h.

87 {return _h;}
MINT::counted_ptr< TH1 > _h

◆ histo() [2/2]

MINT::counted_ptr<TH1> DalitzHistogram::histo ( )
inline

Definition at line 88 of file DalitzHistogram.h.

88 {return _h;}
MINT::counted_ptr< TH1 > _h

◆ histoFileName()

std::string DalitzHistogram::histoFileName ( const std::string &  asSubdirOf = ".",
const char *  theName = 0 
) const
private

Definition at line 503 of file DalitzHistogram.cpp.

504  {
505  std::string dir;
506  if(0 == theName){
507  dir=dirName();
508  }else{
509  dir=theName;
510  }
511  return asSubdirOf + "/" + dir + "/histo.root";
512 }
const std::string & dirName() const

◆ hname()

const std::string DalitzHistogram::hname ( ) const

Definition at line 480 of file DalitzHistogram.cpp.

480  {
481  std::string s;
482  for(std::string::const_iterator it = name().begin();
483  it != name().end(); it++){
484  if('(' == *it || ')'== *it) s += "_";
485  else if(',' == *it) s += "_";
486  else s+= *it;
487  }
488  return s;
489 }
static const double s
const std::string & name() const

◆ htitle()

const std::string & DalitzHistogram::htitle ( ) const

Definition at line 490 of file DalitzHistogram.cpp.

490  {
491  return name();
492 }
const std::string & name() const

◆ init()

void DalitzHistogram::init ( const DalitzCoordSet c,
const DalitzEventPattern p,
int  bins = 100,
double  units = GeV*GeV 
)

Definition at line 175 of file DalitzHistogram.cpp.

179  {
180 
181  // this needs to change!
182  _c = c_in;
183  _pat = pat_in;
184  _nbins = bins;
185  _units = units;
187 
188  smartTitle(c_in,pat_in);
189 
190 
191  double mi=0, ma=0;
192  for(std::map<DalitzCoordKey, DalitzCoordinate>::iterator it = _c.begin();
193  it != _c.end(); it++){
194  double eps = 0.1;
195 
196  mi = _pat.sijMin(it->second)/_units;
197  ma = _pat.sijMax(it->second)/_units;
198 
199  mi -= (ma-mi)*eps;
200  ma += (ma-mi)*eps;
201 
202  it->second.setMin(mi);
203  it->second.setMax(ma);
204  }
205 
206  makeName();
207 
208  counted_ptr<TH1D> local_h(new TH1D(name().c_str(), name().c_str()
209  , _nbins, mi, ma));
210  if(0 == local_h){
211  cout << "Error in DalitzHistogram::init: local_h = " << local_h << endl;
212  throw "annoying";
213  }
214  local_h->SetDirectory(0);
215  local_h->SetNameTitle(hname().c_str(), "");// smartTitle().c_str());
216  local_h->Sumw2();
217  local_h->SetLineWidth(2);
218 
219  std::string unitsName;
220  if (_units == TeV*TeV) unitsName = "TeV^{2}";
221  else if(_units == GeV*GeV) unitsName = "GeV^{2}";
222  else if(_units == MeV*MeV) unitsName = "MeV^{2}";
223  else if(_units == keV*keV) unitsName = "keV^{2}";
224  else if(_units == eV* eV) unitsName = "eV^{2}";
225  else{
226  unitsName = anythingToString((int) (_units/(GeV*GeV))) + " GeV^{2}";
227  }
228 
229  std::string XLabel = (string)smartTitle().c_str()+ " [" + (string)unitsName + "]";
230  local_h->GetXaxis()->SetTitle(XLabel.c_str());
231  local_h->GetXaxis()->SetTitleSize();
232 
233  double bw = (ma - mi)/((double)_nbins);
234  char s[100]={'\0'};
235  sprintf(s, "%f", bw);
236  std::string st(s);
237  std::string YLabel = "Yield / " + st + " " + unitsName;
238 
239  local_h->GetYaxis()->SetTitle(YLabel.c_str());
240 
241  _h = local_h;
242 
243  return;
244 }
static const double keV
double sijMax(const MINT::PolymorphVector< int > &indices) const
const std::string smartTitle() const
MINT::counted_ptr< TH1 > _h
std::vector< int > _patForTree
static const double s
const std::string & name() const
std::map< Key, Val >::iterator end()
Definition: PolymorphMap.h:29
static const double MeV
const std::string hname() const
std::vector< int > getVectorOfInts() const
double sijMin(const MINT::PolymorphVector< int > &indices) const
DalitzCoordSet _c
static const double GeV
std::map< Key, Val >::iterator begin()
Definition: PolymorphMap.h:26
std::string anythingToString(const T &anything)
Definition: Utils.h:62
static const double TeV
static const double eV
DalitzEventPattern _pat

◆ integral()

double DalitzHistogram::integral ( ) const

Definition at line 776 of file DalitzHistogram.cpp.

776  {
777  if(0 == _h) return 0;
778  return _h->Integral();
779 }
MINT::counted_ptr< TH1 > _h

◆ makeDirectory()

bool DalitzHistogram::makeDirectory ( const std::string &  asSubdirOf = ".") const
private

Definition at line 427 of file DalitzHistogram.cpp.

427  {
428  /*
429  A mode is created from or'd permission bit masks defined
430  in <sys/stat.h>:
431  #define S_IRWXU 0000700 RWX mask for owner
432  #define S_IRUSR 0000400 R for owner
433  #define S_IWUSR 0000200 W for owner
434  #define S_IXUSR 0000100 X for owner
435 
436  #define S_IRWXG 0000070 RWX mask for group
437  #define S_IRGRP 0000040 R for group
438  #define S_IWGRP 0000020 W for group
439  #define S_IXGRP 0000010 X for group
440 
441  #define S_IRWXO 0000007 RWX mask for other
442  #define S_IROTH 0000004 R for other
443  #define S_IWOTH 0000002 W for other
444  #define S_IXOTH 0000001 X for other
445 
446  #define S_ISUID 0004000 set user id on execution
447  #define S_ISGID 0002000 set group id on execution
448  #define S_ISVTX 0001000 save swapped text even after use
449  */
450 
451  mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO
452  | S_ISUID | S_ISGID;
453  // see above for meaning. I want everybody to be allowed to read/write/exec.
454  // Not sure about the last two bits.
455 
456  int zeroForSuccess = 0;
457  zeroForSuccess |= mkdir( (asSubdirOf ).c_str(), mode );
458  zeroForSuccess |= mkdir( (asSubdirOf + "/" + dirName() ).c_str(), mode );
459  return (0 == zeroForSuccess);
460 }
const std::string & dirName() const

◆ makeName()

void DalitzHistogram::makeName ( )
private

Definition at line 395 of file DalitzHistogram.cpp.

395  {
396  _name = _c.name();
397 }
DalitzCoordSet _c
std::string name() const
std::string _name

◆ multiply()

void DalitzHistogram::multiply ( const DalitzHistogram multiplyWith)

Definition at line 281 of file DalitzHistogram.cpp.

281  {
282  bool dbThis=false;
283 
284  if(0 == multiplyWith.histo()){
285  cout << "WARNING in DalitzHistogram::multiply(const DalitzHistogram&): "
286  << " Trying to mulitply a DalitzHistogram w/o histogram to me"
287  << " I'll treat it as a zero (i.e. I'll clear myself of entries)."
288  << endl;
289  this->clearHisto();
290  return;
291  }
292  if(0 == histo()){
293  if(dbThis){
294  cout << "WARNING in DalitzHistogram::multiply(const DalitzHistogram&): "
295  << " Trying to multiply a DalitzHistogram to me although I have"
296  << " no histogram myself - treating myself as zero."
297  << endl;
298  }
299  _h = counted_ptr<TH1>((TH1*) multiplyWith.histo()->Clone());
300  if(0 == _h){
301  cout << "Error DalitzHistogram::multiply: _h = " << _h << endl;
302  throw "should not happen";
303  }
304  _h->SetDirectory(0);
305  _c = multiplyWith._c;
306  makeName();
307  _h->SetNameTitle(hname().c_str(), htitle().c_str());
308  _h->Clear();
309  return;
310  }
311  if(_c != multiplyWith._c){
312  cout << "WARNING in DalitzHistogram::multiply(const DalitzHistogram&): "
313  << " multiplying histograms for different co-ordinates!"
314  << "\n\t" << _c << " != " << multiplyWith._c
315  << "\n\t I'll go ahead with it, but it might not be what you want."
316  << endl;
317  }
318  _h->Multiply((multiplyWith.histo().get()));
319  return;
320 }
MINT::counted_ptr< TH1 > _h
MINT::const_counted_ptr< TH1 > histo() const
const std::string hname() const
DalitzCoordSet _c
const std::string & htitle() const

◆ name()

const std::string& DalitzHistogram::name ( ) const
inline

Definition at line 60 of file DalitzHistogram.h.

60 {return _name;}
std::string _name

◆ operator=()

DalitzHistogram & DalitzHistogram::operator= ( const DalitzHistogram other)

Definition at line 123 of file DalitzHistogram.cpp.

123  {
124  if(0 != other.histo()){
125  _h = counted_ptr<TH1>((TH1*) other.histo()->Clone());
126  if(0 == _h){
127  cout << "Error in DalitzHistogram = operator"
128  << endl;
129  throw "oh man!";
130  }
131  _h->SetDirectory(0);
132  }else{
133  _h = counted_ptr<TH1>(0);
134  }
135  _nbins = other._nbins;
136  _c = other._c;
137  _pat = other._pat;
138  _name = other._name;
139  _tree = 0;
140  _patForTree = other._patForTree;
141  return *this;
142 }
MINT::counted_ptr< TH1 > _h
std::vector< int > _patForTree
MINT::const_counted_ptr< TH1 > histo() const
DalitzCoordSet _c
std::string _name
DalitzEventPattern _pat

◆ pattern()

const DalitzEventPattern& DalitzHistogram::pattern ( ) const
inline

Definition at line 67 of file DalitzHistogram.h.

67 {return _pat;}
DalitzEventPattern _pat

◆ retrieveFromDir()

bool DalitzHistogram::retrieveFromDir ( const std::string &  asSubdirOf = ".",
const char *  theName = 0 
)

Definition at line 468 of file DalitzHistogram.cpp.

469  {
470  bool success = true;
471  if(0 != theName) _name = theName;
472  success |= retrieveValues(asSubdirOf, theName);
473 
474  success |= retrieveHisto(asSubdirOf, theName);
475  return success;
476 }
bool retrieveHisto(const std::string &fromDir, const char *theName=0)
bool retrieveValues(const std::string &fromDirectory, const char *theName=0)
std::string _name

◆ retrieveHisto()

bool DalitzHistogram::retrieveHisto ( const std::string &  fromDir,
const char *  theName = 0 
)
private

Definition at line 640 of file DalitzHistogram.cpp.

641  {
642  bool dbThis=false;
643  std::string fn = histoFileName(fromDir, theName);
644  // _name = theName();
645  TFile* f = TFile::Open(fn.c_str(), "READ");
646  if(0 == f){
647  cout << "ERROR in DalitzHistogram::retrieveHisto: cannot open file "
648  << fn << endl;
649  throw "bugger";
650  }
651  TH1* th = (TH1*) f->Get(hname().c_str());
652  if(0 == th){
653  cout << "ERROR in DalitzHistogram::retrieveHisto"
654  << "\n\t can't find histogram " << hname()
655  << "\n\t in file " << fn << endl;
656  throw "errorRetrievingHisto";
657  }
658  th->SetDirectory(0);
659  counted_ptr<TH1> cth((TH1*) th->Clone());
660  cth->SetDirectory(0);
661  _h = cth;
662  f->Close();
663  if(dbThis){
664  cout << "DalitzHistogram::retrieveHisto"
665  << "\n\t retrieved histogram " << hname()
666  << "\n\t in file " << fn << endl;
667  cout << "\t the ptr " << _h.get() << endl;
668  cout << "\t the name " << _h->GetTitle() << endl;
669  }
670  return true;
671 }
std::string histoFileName(const std::string &asSubdirOf=".", const char *theName=0) const
MINT::counted_ptr< TH1 > _h
const std::string hname() const
X * get() const
Definition: counted_ptr.h:123

◆ retrieveValues()

bool DalitzHistogram::retrieveValues ( const std::string &  fromDirectory,
const char *  theName = 0 
)
private

Definition at line 553 of file DalitzHistogram.cpp.

554  {
555  bool dbThis=false;
556  std::string fname = valueFileName(fromDirectory, theName);
557  if(dbThis)cout << "trying fname = " << fname << endl;
558  NamedParameter<double> n_units("units"
559  , fname.c_str()
560  //, NamedParameterBase::QUIET
561  );
562  n_units.reloadFile(fname.c_str());
563  NamedParameter<int> n_nbins("nbins"
564  ,fname.c_str()
565  //, NamedParameterBase::QUIET
566  );
567  NamedParameter<int> n_c("c"
568  , fname.c_str()
569  //, NamedParameterBase::QUIET
570  );
571  NamedParameter<int> n_pat("pat"
572  , fname.c_str()
573  //, NamedParameterBase::QUIET
574  );
575  NamedParameter<std::string> n_name("name"
576  , fname.c_str()
577  //, NamedParameterBase::QUIET
578  );
579 
580  _units = n_units;
581  _nbins = n_nbins;
582  DalitzCoordinate co(n_c.getVector());
583  _c = (DalitzCoordSet) co;
584  DalitzEventPattern pa(n_pat.getVector());
585  _pat = pa;
586  //cout << "after reading in, the pattern is " << _pat << endl;
587  _name = n_name;
588 
589  return true;
590 }
std::string valueFileName(const std::string &asSubdirOf=".", const char *theName=0) const
DalitzCoordSet _c
bool reloadFile(const std::string &id)
std::string _name
DalitzEventPattern _pat

◆ saveAsDir()

bool DalitzHistogram::saveAsDir ( const std::string &  asSubdirOf = ".") const

Definition at line 462 of file DalitzHistogram.cpp.

462  {
463  makeDirectory(asSubdirOf); // ignore error codes from mkdir, they could
464  saveValues(asSubdirOf);
465  saveHisto(asSubdirOf);
466  return true;
467 }
bool saveHisto(const std::string &inDir=".") const
bool saveValues(const std::string &inDir=".") const
bool makeDirectory(const std::string &asSubdirOf=".") const

◆ saveHisto()

bool DalitzHistogram::saveHisto ( const std::string &  inDir = ".") const
private

Definition at line 592 of file DalitzHistogram.cpp.

592  {
593  bool dbThis=false;
594  if(false && dbThis){
595  cout << "DalitzHistogram::saveHisto( " << inDir << " ) got called"
596  << endl;
597  }
598 
599  std::string fn = histoFileName(inDir);
600 
601  if(0 == _h) return false;
602 
603  //_h->SaveAs(fn.c_str());
604  //return true;
605 
606  if(dbThis){
607  cout << "DalitzHistogram::saveHisto: tryring to save " << fn
608  << endl;
609  }
610  TFile* f = TFile::Open(fn.c_str(), "RECREATE");
611  if(0 == f){
612  cout << "DalitzHistogram::saveHisto(const std::string& inDir)"
613  << " failed to open file " << fn << endl;
614  return false;
615  }
616  if(dbThis){
617  cout << "file isOpen " << f->IsOpen() << endl;
618  cout << "file isWritable " << f->IsWritable() << endl;
619  }
620  if(! f->IsWritable()){
621  cout << "File " << fn << " not writeable" << endl;
622  throw "damn";
623  }
624  f->cd();
625  if(dbThis){
626  cout << "cd'ed to file" << endl;
627  cout << "number of entries in _h " << _h->GetEntries() << endl;
628  cout << "now about to write " << endl;
629  }
630  _h->Write();
631  if(dbThis) cout << "done writing. now closing" << endl;
632  f->Close();
633  //h->SetDirectory(0);
634  if(dbThis) cout << "closed it. Now returning true" << endl;
635  //delete f;
636  return true;
637 
638 }
std::string histoFileName(const std::string &asSubdirOf=".", const char *theName=0) const
MINT::counted_ptr< TH1 > _h

◆ saveValues()

bool DalitzHistogram::saveValues ( const std::string &  inDir = ".") const
private

Definition at line 514 of file DalitzHistogram.cpp.

514  {
515 
516  NamedParameter<double> n_units("units"
517  , NamedParameterBase::QUIET);
518  NamedParameter<int> n_nbins("nbins"
519  ,NamedParameterBase::QUIET);
520  NamedParameter<int> n_c("c"
521  , NamedParameterBase::QUIET);
522  NamedParameter<int> n_pat("pat"
523  , NamedParameterBase::QUIET);
524  NamedParameter<std::string> n_name("name"
525  , NamedParameterBase::QUIET);
526 
527  n_units = _units;
528  n_nbins = _nbins;
529  n_c = (std::vector<int>) _c.begin()->first; // needs to change
530  // cout << "pat = " << _pat << endl;
531  n_pat = _pat.getVectorOfInts();
532  // cout << "n_pat = " << n_pat << endl;
533  n_name = _name;
534 
535  std::string fname = valueFileName(inDir);
536  ofstream os(fname.c_str());
537  if(os.bad()){
538  cout << "ERROR in DalitzHistogram::saveValues of \n\t" << name()
539  << "\n\t unable to create file: "
540  << "\n\t" << fname << endl;
541  return false;
542  }
543  os << name()
544  << '\n' << n_units
545  << '\n' << n_nbins
546  << '\n' << n_c
547  << '\n' << n_pat
548  << '\n' << n_name
549  << endl;
550  os.close();
551  return true;
552 }
std::string valueFileName(const std::string &asSubdirOf=".", const char *theName=0) const
const std::string & name() const
std::vector< int > getVectorOfInts() const
DalitzCoordSet _c
std::map< Key, Val >::iterator begin()
Definition: PolymorphMap.h:26
std::string _name
DalitzEventPattern _pat

◆ scale()

void DalitzHistogram::scale ( double  sf)

Definition at line 370 of file DalitzHistogram.cpp.

370  {
371  if(0 == _h) return;
372  _h->Scale(sf);
373 }
MINT::counted_ptr< TH1 > _h

◆ setNormFactor()

void DalitzHistogram::setNormFactor ( double  f = 1)
inline

Definition at line 83 of file DalitzHistogram.h.

83 {_h->SetNormFactor(f);}
MINT::counted_ptr< TH1 > _h

◆ setTitle()

void DalitzHistogram::setTitle ( const std::string &  title)

Definition at line 374 of file DalitzHistogram.cpp.

374  {
375  if(0 != _h) _h->SetTitle(title.c_str());
376 }
MINT::counted_ptr< TH1 > _h

◆ smartTitle() [1/2]

void DalitzHistogram::smartTitle ( const DalitzCoordSet c_in,
const DalitzEventPattern pat_in 
)

Definition at line 149 of file DalitzHistogram.cpp.

151 {
152 // pat_in
153  TString c_out = c_in.name();
154  for (unsigned int i = 1; i< pat_in.size(); i++)
155  {
156  std::string sij = convertInt(i);
157  c_out.ReplaceAll(sij,pat_in[i].name());
158  }
159  c_out.ReplaceAll("sij","m^{2}");
160  c_out.ReplaceAll("K+","K^{+}");
161  c_out.ReplaceAll("pi+","#pi^{+}");
162  c_out.ReplaceAll("pi-","#pi^{-}");
163  c_out.ReplaceAll("Jpsi0","J/#psi");
164  c_out.ReplaceAll("psi0","#psi");
165  c_out.ReplaceAll("gamma0","#gamma");
166 
167  c_out.ReplaceAll(","," ");
168  _smartTitle = c_out;
169 }
const std::string & name() const
std::string convertInt(int number)
std::string name() const
unsigned int size() const
std::string _smartTitle

◆ smartTitle() [2/2]

const std::string DalitzHistogram::smartTitle ( ) const

Definition at line 171 of file DalitzHistogram.cpp.

172 {
173  return _smartTitle;
174 }
std::string _smartTitle

◆ valueFileName()

std::string DalitzHistogram::valueFileName ( const std::string &  asSubdirOf = ".",
const char *  theName = 0 
) const
private

Definition at line 493 of file DalitzHistogram.cpp.

494  {
495  std::string dir;
496  if(0 == theName){
497  dir=dirName();
498  }else{
499  dir=theName;
500  }
501  return asSubdirOf + "/" + dir + "/value.txt";
502 }
const std::string & dirName() const

Member Data Documentation

◆ _c

DalitzCoordSet DalitzHistogram::_c
private

Definition at line 29 of file DalitzHistogram.h.

◆ _h

MINT::counted_ptr<TH1> DalitzHistogram::_h
private

Definition at line 28 of file DalitzHistogram.h.

◆ _name

std::string DalitzHistogram::_name
private

Definition at line 31 of file DalitzHistogram.h.

◆ _nbins

int DalitzHistogram::_nbins
private

Definition at line 27 of file DalitzHistogram.h.

◆ _pat

DalitzEventPattern DalitzHistogram::_pat
private

Definition at line 30 of file DalitzHistogram.h.

◆ _patForTree

std::vector<int> DalitzHistogram::_patForTree
private

Definition at line 34 of file DalitzHistogram.h.

◆ _smartTitle

std::string DalitzHistogram::_smartTitle
private

Definition at line 32 of file DalitzHistogram.h.

◆ _tree

TTree* DalitzHistogram::_tree
mutableprivate

Definition at line 33 of file DalitzHistogram.h.

◆ _units

double DalitzHistogram::_units
private

Definition at line 26 of file DalitzHistogram.h.


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