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

#include <Chi2Binning.h>

Public Member Functions

 Chi2Binning ()
 
int createBinning (MINT::IMinimalEventList< DalitzEvent > *events, int minPerBin=10, int maxPerBin=100)
 
double setEventsAndPdf (MINT::IMinimalEventList< DalitzEvent > *data, MINT::IMinimalEventList< DalitzEvent > *mc, IDalitzPdf *pdf, IFastAmplitudeIntegrable *fas=0)
 
void setFas (IFastAmplitudeIntegrable *fas)
 
int numBins () const
 
double getChi2_perBin () const
 
double chi2_ofBin (unsigned int i) const
 
double getMaxChi2 () const
 
void print (std::ostream &os=std::cout) const
 
DalitzHistoStackSet getDataHistoStack ()
 
DalitzHistoStackSet getMCHistoStack ()
 
MINT::counted_ptr< TH1D > getChi2Distribution () const
 
void drawChi2Distribution (const std::string &fname="chi2Distribution.eps") const
 

Private Member Functions

void setHistoColours ()
 
Chi2BoxSet splitBoxes (MINT::IMinimalEventList< DalitzEvent > *events, int maxPerBin) const
 
Chi2BoxSet splitBoxes (MINT::IMinimalEventList< DalitzEvent > &events, int maxPerBin) const
 
int mergeBoxes (Chi2BoxSet &boxes, int minPerBin)
 
void resetEventCounts ()
 
void fillData (MINT::IMinimalEventList< DalitzEvent > &data)
 
void fillData (MINT::IMinimalEventList< DalitzEvent > *dataPtr)
 
void fillMC (MINT::IMinimalEventList< DalitzEvent > &mc, IDalitzPdf *pdf)
 
void fillMC (MINT::IMinimalEventList< DalitzEvent > *mcPtr, IDalitzPdf *pdf)
 
double normFactor () const
 
void setBoxesNormFactors ()
 
void sortByChi2 ()
 

Static Private Member Functions

static void makeColourPaletteBlueGrey ()
 
static void makeColourPaletteBlueWhite ()
 
static void makeColourPaletteRGB ()
 
static void makeColourPalette ()
 
static int * getColourPalette ()
 

Private Attributes

std::vector< Chi2BoxSet_boxSets
 
int _nData
 
int _nMC
 
double _totalMCWeight
 

Static Private Attributes

static int * __colourPalette =0
 
static int __Ncol =256
 

Detailed Description

Definition at line 21 of file Chi2Binning.h.

Constructor & Destructor Documentation

◆ Chi2Binning()

Chi2Binning::Chi2Binning ( )

Definition at line 81 of file Chi2Binning.cpp.

82  : _nData(0)
83  , _nMC(0)
84  , _totalMCWeight(0)
85 {
86 }
double _totalMCWeight
Definition: Chi2Binning.h:25

Member Function Documentation

◆ chi2_ofBin()

double Chi2Binning::chi2_ofBin ( unsigned int  i) const

Definition at line 358 of file Chi2Binning.cpp.

358  {
359  if(i > _boxSets.size()) return -9999;
360  return _boxSets[i].chi2(normFactor());
361 }
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
double normFactor() const

◆ createBinning()

int Chi2Binning::createBinning ( MINT::IMinimalEventList< DalitzEvent > *  events,
int  minPerBin = 10,
int  maxPerBin = 100 
)

Definition at line 87 of file Chi2Binning.cpp.

90  {
91 
92  if(0 == events) return 0;
93  if(0 == events->size()) return 0;
94 
95  Chi2BoxSet boxes = splitBoxes(events, maxPerBin);
96 
97  mergeBoxes(boxes, minPerBin);
98 
99  return numBins();
100 }
Chi2BoxSet splitBoxes(MINT::IMinimalEventList< DalitzEvent > *events, int maxPerBin) const
int numBins() const
virtual unsigned int size() const =0
int mergeBoxes(Chi2BoxSet &boxes, int minPerBin)

◆ drawChi2Distribution()

void Chi2Binning::drawChi2Distribution ( const std::string &  fname = "chi2Distribution.eps") const

Definition at line 450 of file Chi2Binning.cpp.

450  {
451  TCanvas can;
452  can.SetLogy();
454  h->Draw();
455  can.Print(fname.c_str());
456 }
MINT::counted_ptr< TH1D > getChi2Distribution() const

◆ fillData() [1/2]

void Chi2Binning::fillData ( MINT::IMinimalEventList< DalitzEvent > &  data)
private

Definition at line 191 of file Chi2Binning.cpp.

191  {
192  for(unsigned int k=0; k < data.size(); k++){
193  bool foundBox=false;
194  DalitzEvent evt(data.getEvent(k));
195  for(unsigned int i=0; i < _boxSets.size(); i++){
196  if(_boxSets[i].addData(evt)){
197  foundBox=true;
198  _nData++;
199  break;
200  }
201  }
202  if(! foundBox){
203  cout << "WARNING in Chi2Binning::fillData:"
204  << "\n\t didn't find box for event "
205  << endl;
206  evt.print();
207  cout << "compare to first event: " << endl;
208  DalitzEvent firstEvt(data.getEvent(0));
209  firstEvt.print();
210  Chi2Box box(evt.eventPattern());
211  cout << "would have fit into large? "
212  << box.addData(evt) << endl;
213  }
214  }
215 }
bool addData(const IDalitzEvent &evt)
Definition: Chi2Box.cpp:68
virtual EVENT_TYPE getEvent(unsigned int i) const =0
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
void print(std::ostream &os=std::cout) const
virtual unsigned int size() const =0

◆ fillData() [2/2]

void Chi2Binning::fillData ( MINT::IMinimalEventList< DalitzEvent > *  dataPtr)
inlineprivate

Definition at line 47 of file Chi2Binning.h.

47  {
48  // for backward compatibility
49  if(0 != dataPtr) fillData(*dataPtr);// will be removed in future
50  }
void fillData(MINT::IMinimalEventList< DalitzEvent > &data)

◆ fillMC() [1/2]

void Chi2Binning::fillMC ( MINT::IMinimalEventList< DalitzEvent > &  mc,
IDalitzPdf pdf 
)
private

Definition at line 216 of file Chi2Binning.cpp.

217  {
218  bool dbThis=false;
219  if(dbThis){
220  cout << "Chi2Binning::fillMC called with "
221  << &mc << ", " << pdf << endl;
222  }
223  int printevery=10000;
224  for(unsigned int k=0; k < mc.size(); k++){
225  bool printit = (0 == k%printevery);
226  if(printit) cout << "...fillMC filling event number " << k;
227  DalitzEvent evt(mc.getEvent(k));
228  double weight = pdf->getVal_noPs(evt) * evt.getWeight() /
229  evt.getGeneratorPdfRelativeToPhaseSpace();
230 
231  if(printit) cout << ", with weight " << weight << endl;
232  int n=0;
233  for(unsigned int i=0; i < _boxSets.size(); i++){
234  if(_boxSets[i].addMC(evt, weight)){
235  _totalMCWeight += weight;
236  _nMC++;
237  n++;
238  break;
239  }
240  }
241  if(dbThis){
242  cout << "event " << k << " in " << n << " out of " << numBins()
243  << " box sets" << endl;
244  if(0 == n) evt.print();
245  cout << "mc weight now: " << _totalMCWeight << endl;
246  }
247  }
248  if(dbThis) cout << "Total MC weight: " << _totalMCWeight << endl;
249 }
double _totalMCWeight
Definition: Chi2Binning.h:25
virtual EVENT_TYPE getEvent(unsigned int i) const =0
int numBins() const
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
virtual unsigned int size() const =0
virtual double getVal_noPs(IDalitzEvent &evt)=0

◆ fillMC() [2/2]

void Chi2Binning::fillMC ( MINT::IMinimalEventList< DalitzEvent > *  mcPtr,
IDalitzPdf pdf 
)
inlineprivate

Definition at line 52 of file Chi2Binning.h.

52  {
53  if(0 != mcPtr) fillMC(*mcPtr, pdf);
54  }
void fillMC(MINT::IMinimalEventList< DalitzEvent > &mc, IDalitzPdf *pdf)

◆ getChi2_perBin()

double Chi2Binning::getChi2_perBin ( ) const

Definition at line 362 of file Chi2Binning.cpp.

362  {
363  if(_nMC <= 0) return -9999;
364  if(_nData <=0 ) return -9999;
365  if(_totalMCWeight <= 0.0) return -9999;
366 
367  double sum=0;
368  for(unsigned int i=0; i < _boxSets.size(); i++){
369  double chi2 = chi2_ofBin(i);
370  sum += chi2;
371  }
372 
373  return sum/numBins();
374 }
double chi2_ofBin(unsigned int i) const
double _totalMCWeight
Definition: Chi2Binning.h:25
int numBins() const
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ getChi2Distribution()

counted_ptr< TH1D > Chi2Binning::getChi2Distribution ( ) const

Definition at line 437 of file Chi2Binning.cpp.

437  {
438  int nbins=100;
439  double from=0, to=getMaxChi2();
440  cout << "from " << from << " to " << to << endl;
441  counted_ptr<TH1D> h(new TH1D("chi2 distribution", "chi2 distribution"
442  , nbins, from, to));
443  h->SetDirectory(0);
444  for(unsigned int i=0; i < _boxSets.size(); i++){
445  //cout << "filling chi2 " << _boxSets[i].chi2() << endl;
446  h->Fill(_boxSets[i].chi2());
447  }
448  return h;
449 }
double getMaxChi2() const
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ getColourPalette()

int * Chi2Binning::getColourPalette ( )
staticprivate

Definition at line 76 of file Chi2Binning.cpp.

76  {
78  return __colourPalette;
79 }
static int * __colourPalette
Definition: Chi2Binning.h:27
static void makeColourPalette()
Definition: Chi2Binning.cpp:70

◆ getDataHistoStack()

DalitzHistoStackSet Chi2Binning::getDataHistoStack ( )

Definition at line 407 of file Chi2Binning.cpp.

407  {
408  setHistoColours();
409  DalitzHistoStackSet hstack;
410 
411  for(unsigned int i=0; i < _boxSets.size(); i++){
412  hstack.add(_boxSets[i].histoData());
413  }
414  double mx = getMaxChi2();
415  if(mx > 20) mx=20;
417  //cout << "printing newly made data histo stack" << endl;
418  //hstack.draw("experimental_chi2DataHisto");
419  return hstack;
420 }
double getMaxChi2() const
void setHistoColours()
static int * __colourPalette
Definition: Chi2Binning.h:27
virtual void add(const DalitzCoordSet &coord, const MINT::counted_ptr< TH1 > &histo)
static int __Ncol
Definition: Chi2Binning.h:28
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
void setColourPalette(int nCol, int *pal, double max, double min=0.000001)

◆ getMaxChi2()

double Chi2Binning::getMaxChi2 ( ) const

Definition at line 375 of file Chi2Binning.cpp.

375  {
376  double max=-1;
377  for(unsigned int i=0; i < _boxSets.size(); i++){
378  double chi2 = chi2_ofBin(i);
379  if(chi2 > max) max=chi2;
380  }
381  return max;
382 }
double chi2_ofBin(unsigned int i) const
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ getMCHistoStack()

DalitzHistoStackSet Chi2Binning::getMCHistoStack ( )

Definition at line 421 of file Chi2Binning.cpp.

421  {
422  setHistoColours();
423  DalitzHistoStackSet hstack;
424 
425  for(unsigned int i=0; i < _boxSets.size(); i++){
426  hstack.add(_boxSets[i].histoMC());
427  }
428  double mx = getMaxChi2();
429  if(mx > 20) mx=20;
430 
432  // cout << "printing newly made MC histo stack" << endl;
433  // hstack.draw("experimental_chi2MCHisto");
434  return hstack;
435 }
double getMaxChi2() const
void setHistoColours()
static int * __colourPalette
Definition: Chi2Binning.h:27
virtual void add(const DalitzCoordSet &coord, const MINT::counted_ptr< TH1 > &histo)
static int __Ncol
Definition: Chi2Binning.h:28
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
void setColourPalette(int nCol, int *pal, double max, double min=0.000001)

◆ makeColourPalette()

void Chi2Binning::makeColourPalette ( )
staticprivate

Definition at line 70 of file Chi2Binning.cpp.

70  {
72  //makeColourPaletteRGB();
73  //makeColourPaletteBlueWhite();
74 }
static void makeColourPaletteBlueGrey()
Definition: Chi2Binning.cpp:21

◆ makeColourPaletteBlueGrey()

void Chi2Binning::makeColourPaletteBlueGrey ( )
staticprivate

Definition at line 21 of file Chi2Binning.cpp.

21  {
22  static const int NRGBs = 7;
23  if(0 != __colourPalette) delete[] __colourPalette;
24  __colourPalette = new int[__Ncol];
25 
26  Double_t stops[NRGBs] = { 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 };
27  Double_t red[NRGBs] = { 0.85, 0.00, 0.00, 0.00, 0.80, 0.80, 0.99 };
28  Double_t green[NRGBs] = { 0.85, 0.80, 0.40, 0.40, 0.80, 0.00, 0.00 };
29  Double_t blue[NRGBs] = { 0.85, 0.85, 0.80, 0.00, 0.00, 0.00, 0.00 };
30  Int_t Fi = TColor::CreateGradientColorTable(NRGBs
31  , stops
32  , red, green, blue
33  , __Ncol);
34 
35  for(int i=0; i < __Ncol; i++) __colourPalette[i]=Fi + i;
36 }
static int * __colourPalette
Definition: Chi2Binning.h:27
static int __Ncol
Definition: Chi2Binning.h:28

◆ makeColourPaletteBlueWhite()

void Chi2Binning::makeColourPaletteBlueWhite ( )
staticprivate

Definition at line 37 of file Chi2Binning.cpp.

37  {
38  static const int NRGBs = 7;
39  if(0 != __colourPalette) delete[] __colourPalette;
40  __colourPalette = new int[__Ncol];
41 
42  Double_t stops[NRGBs] = { 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 };
43  Double_t red[NRGBs] = { 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 };
44  Double_t green[NRGBs] = { 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 };
45  Double_t blue[NRGBs] = { 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 };
46  Int_t Fi = TColor::CreateGradientColorTable(NRGBs
47  , stops
48  , red, green, blue
49  , __Ncol);
50 
51  for(int i=0; i < __Ncol; i++) __colourPalette[i]=Fi + i;
52 }
static int * __colourPalette
Definition: Chi2Binning.h:27
static int __Ncol
Definition: Chi2Binning.h:28

◆ makeColourPaletteRGB()

void Chi2Binning::makeColourPaletteRGB ( )
staticprivate

Definition at line 53 of file Chi2Binning.cpp.

53  {
54  static const int NRGBs = 5;
55 
56  if(0 != __colourPalette) delete[] __colourPalette;
57  __colourPalette = new int[__Ncol];
58 
59  Double_t red[NRGBs] = {0., 0.0, 1.0, 1.0, 1.0};
60  Double_t green[NRGBs] = {0., 0.0, 0.0, 1.0, 1.0};
61  Double_t blue[NRGBs] = {0., 1.0, 0.0, 0.0, 1.0};
62  Double_t stops[NRGBs] = {0., .25, .50, .75, 1.0};
63  Int_t Fi = TColor::CreateGradientColorTable(NRGBs
64  , stops
65  , red, green, blue
66  , __Ncol);
67 
68  for(int i=0; i < __Ncol; i++) __colourPalette[i]=Fi + i;
69 }
static int * __colourPalette
Definition: Chi2Binning.h:27
static int __Ncol
Definition: Chi2Binning.h:28

◆ mergeBoxes()

int Chi2Binning::mergeBoxes ( Chi2BoxSet boxes,
int  minPerBin 
)
private

Definition at line 102 of file Chi2Binning.cpp.

102  {
103  lessByChi2BoxData sorter;
104  sort(boxes.begin(), boxes.end(), sorter);
105  // this way, the smalles boxes come first
106  // makes sure no empty box is left over at the end.
107 
108  Chi2BoxSet boxSet;
109  for(unsigned int i=0; i < boxes.size(); i++){
110  boxSet.add(boxes[i]);
111  if(boxSet.nData() >= minPerBin){
112  _boxSets.push_back(boxSet);
113  boxSet.clear();
114  }
115  }
116 
117  return _boxSets.size();
118 }
void add(const Chi2Box &box)
Definition: Chi2BoxSet.cpp:53
std::vector< T >::iterator end()
std::vector< T >::iterator begin()
unsigned int size() const
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ normFactor()

double Chi2Binning::normFactor ( ) const
private

Definition at line 348 of file Chi2Binning.cpp.

348  {
349  return ((double)_nData)/_totalMCWeight;
350 }
double _totalMCWeight
Definition: Chi2Binning.h:25

◆ numBins()

int Chi2Binning::numBins ( ) const

Definition at line 384 of file Chi2Binning.cpp.

384  {
385  return _boxSets.size();
386 }
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ print()

void Chi2Binning::print ( std::ostream &  os = std::cout) const

Definition at line 301 of file Chi2Binning.cpp.

301  {
302 
303  int nDataCheck=0;
304  double nMCCheck=0;
305  double chi2sum=0;
306  double sumVarData =0;
307  double sumVarMC =0;
308  for(unsigned int i=0; i < _boxSets.size(); i++){
309  int n_data = _boxSets[i].nData();
310  nDataCheck += n_data;
311  double weight_mc = _boxSets[i].weightedMC() * normFactor();
312  nMCCheck += weight_mc;
313 
314  double var_mc_noNorm = _boxSets[i].rmsMC(_nMC);
315  double var_mc = var_mc_noNorm* normFactor()*normFactor();
316  double varData_expected = weight_mc;
317  sumVarData += varData_expected;
318  sumVarMC += var_mc;
319  double chi2 = chi2_ofBin(i);
320  chi2sum += chi2;
321 
322  os << " bin " << i;
323  os << " data " << _boxSets[i].nData();
324  os << ", mcweight " << _boxSets[i].weightedMC() * normFactor();
325  os << ", (nMC " << _boxSets[i].nMC() << ")";
326  os << ", chi2 " << chi2 << endl;
327  _boxSets[i].printBoxInfo(os);
328  }
329  os << "\n=========================================================="<< endl;
330  os << "chi2 / nbins = " << chi2sum << " / " << numBins()
331  << " = " << chi2sum/numBins() << endl;
332  os << "===========================================================" << endl;
333  os << " total data weight: " << nDataCheck
334  << " .. _nData = " << _nData
335  << " should be same as normalised total MC weight = " << nMCCheck
336  << " (un-normalised = " << _totalMCWeight << ")"
337  << endl;
338  if(sumVarMC > sumVarData){
339  os << "Severe WARNING in Chi2Binning::getChi2_perBin()"
340  << "\n error on difference between data and MC dominated by MC"
341  << "\n mean data variance: " << sumVarData/numBins()
342  << ", ... mc: " << sumVarMC/numBins()
343  << ".\n Get more MC!"
344  << endl;
345  }
346 }
double chi2_ofBin(unsigned int i) const
double _totalMCWeight
Definition: Chi2Binning.h:25
int numBins() const
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
double normFactor() const

◆ resetEventCounts()

void Chi2Binning::resetEventCounts ( )
private

Definition at line 183 of file Chi2Binning.cpp.

183  {
184  _nData=0;
185  _nMC=0;
186  _totalMCWeight=0.0;
187  for(unsigned int i=0; i < _boxSets.size(); i++){
188  _boxSets[i].resetEventCounts();
189  }
190 }
double _totalMCWeight
Definition: Chi2Binning.h:25
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ setBoxesNormFactors()

void Chi2Binning::setBoxesNormFactors ( )
private

Definition at line 352 of file Chi2Binning.cpp.

352  {
353  for(unsigned int i=0; i < _boxSets.size(); i++){
354  _boxSets[i].setNormFactor(normFactor());
355  }
356 }
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22
double normFactor() const

◆ setEventsAndPdf()

double Chi2Binning::setEventsAndPdf ( MINT::IMinimalEventList< DalitzEvent > *  data,
MINT::IMinimalEventList< DalitzEvent > *  mc,
IDalitzPdf pdf,
IFastAmplitudeIntegrable fas = 0 
)

Definition at line 255 of file Chi2Binning.cpp.

259  {
260  bool dbThis=false;
261  if(dbThis) cout << "Chi2Binning::setEventsAndPdf" << endl;
262  if(0 == data) return -9999;
263  if(0 == mc) return -9999;
264  if(0 == pdf) return -9999;
265  //(could do this: if 0 == pdf: mc generated with pdf from fit result.
266  // But for now, leave it like this for safety)
267 
268  if(0 == numBins()) createBinning(data);
269  if(0 != fas) setFas(fas);
270  if(dbThis) cout << "...number of chi2 bins = " << numBins() << endl;
272  if(dbThis) cout << "...about to fill in the data " << endl;
273  fillData(data);
274  if(dbThis) cout << "...done that - now the MC" << endl;
275  fillMC(mc, pdf);
276  if(dbThis) cout << "... fillMC done, now setting norm factors" << endl;
278  if(dbThis) cout << " done the norm factors, now sorting by chi2" << endl;
279  sortByChi2();
280  if(dbThis) cout << " Chi2Binning::setEventsAndPdf done" << endl;
281  return 0;
282 }
void resetEventCounts()
void fillMC(MINT::IMinimalEventList< DalitzEvent > &mc, IDalitzPdf *pdf)
int createBinning(MINT::IMinimalEventList< DalitzEvent > *events, int minPerBin=10, int maxPerBin=100)
Definition: Chi2Binning.cpp:87
void setBoxesNormFactors()
void fillData(MINT::IMinimalEventList< DalitzEvent > &data)
int numBins() const
void sortByChi2()
void setFas(IFastAmplitudeIntegrable *fas)

◆ setFas()

void Chi2Binning::setFas ( IFastAmplitudeIntegrable fas)

Definition at line 284 of file Chi2Binning.cpp.

284  {
285  bool dbThis=true;
286 
288  ic = fas->makeIntegrationCalculator();
289 
290  if(dbThis) {
291  cout << "Chi2Binning::setFas: this is the fas:" << endl;
292  fas->print(cout);
293  cout << endl;
294  }
295  for(unsigned int i=0; i < _boxSets.size(); i++){
297  _boxSets[i].setIIntegrationCalculator(fap);
298  }
299 }
virtual MINT::counted_ptr< IIntegrationCalculator > clone_IIntegrationCalculator() const =0
virtual MINT::counted_ptr< IIntegrationCalculator > makeIntegrationCalculator()=0
virtual void print(std::ostream &os=std::cout) const =0
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ setHistoColours()

void Chi2Binning::setHistoColours ( )
private

Definition at line 398 of file Chi2Binning.cpp.

398  {
399  double maxChi2 = getMaxChi2();
400  for(unsigned int i=0; i < _boxSets.size(); i++){
401  double chi2 = chi2_ofBin(i);
402  int colIndex = (chi2/maxChi2)*(__Ncol-1);
403  int col = (getColourPalette())[colIndex];
404  _boxSets[i].setHistoColour(col);
405  }
406 }
double getMaxChi2() const
double chi2_ofBin(unsigned int i) const
static int __Ncol
Definition: Chi2Binning.h:28
static int * getColourPalette()
Definition: Chi2Binning.cpp:76
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ sortByChi2()

void Chi2Binning::sortByChi2 ( )
private

Definition at line 251 of file Chi2Binning.cpp.

251  {
252  lessByChi2BoxSetChi2 sorter;
253  stable_sort(_boxSets.rbegin(), _boxSets.rend(), sorter);
254 }
std::vector< Chi2BoxSet > _boxSets
Definition: Chi2Binning.h:22

◆ splitBoxes() [1/2]

Chi2BoxSet Chi2Binning::splitBoxes ( MINT::IMinimalEventList< DalitzEvent > *  events,
int  maxPerBin 
) const
private

Definition at line 121 of file Chi2Binning.cpp.

123  {
124  bool dbThis=false;
125  if(dbThis){
126  cout << "Chi2Binning::splitBoxes(MINT::IEventList<DalitzEvent>* events , int maxPerBin = "
127  << maxPerBin << ") called" << endl;
128  }
129 
130  Chi2BoxSet dummy;
131  if(0 == events) return dummy;
132  return splitBoxes(*events, maxPerBin);
133 }
Chi2BoxSet splitBoxes(MINT::IMinimalEventList< DalitzEvent > *events, int maxPerBin) const

◆ splitBoxes() [2/2]

Chi2BoxSet Chi2Binning::splitBoxes ( MINT::IMinimalEventList< DalitzEvent > &  events,
int  maxPerBin 
) const
private

Definition at line 135 of file Chi2Binning.cpp.

137  {
138  bool dbThis=false;
139  Chi2BoxSet dummy;
140  if(0 == events.size()) return dummy;
141  const IDalitzEvent& evt0 = events.getEvent(0);
142 
143  Chi2Box box(evt0.eventPattern());
144 
145  Chi2BoxSet boxes(box.split(0));
146  bool needToSplitMore=false;
147  int counter=0;
148  do{
149  counter++;
150  boxes.resetEventCounts();
151  int failedSet=0, failedBox=0;
152 
153  for(unsigned int i=0; i < events.size(); i++){
154  bool added = boxes.addData(events.getEvent(i));
155  if(! added) failedSet++;
156  if(! box.addData(events.getEvent(i))){
157  failedBox++;
158  }
159  }
160  if(failedSet > 0 || dbThis){
161  cout << " Chi2Binning::splitBoxes: ERROR split level " << counter
162  << ", num boxes: " << boxes.size()
163  << ", failedSet: " << failedSet
164  << ", failedBox: " << failedBox << endl;
165  }
166 
167  Chi2BoxSet newBoxes;
168  needToSplitMore=false;
169  for(unsigned int i=0; i < boxes.size(); i++){
170  if( boxes[i].nData() > maxPerBin ){
171  needToSplitMore=true;
172  newBoxes.add(boxes[i].split());
173  }else{
174  newBoxes.add(boxes[i]);
175  }
176  }
177  boxes = newBoxes;
178  }while(needToSplitMore);
179 
180  return boxes;
181 }
void add(const Chi2Box &box)
Definition: Chi2BoxSet.cpp:53
void resetEventCounts()
Definition: Chi2BoxSet.cpp:63
virtual EVENT_TYPE getEvent(unsigned int i) const =0
virtual const DalitzEventPattern & eventPattern() const =0
virtual unsigned int size() const =0

Member Data Documentation

◆ __colourPalette

int * Chi2Binning::__colourPalette =0
staticprivate

Definition at line 27 of file Chi2Binning.h.

◆ __Ncol

int Chi2Binning::__Ncol =256
staticprivate

Definition at line 28 of file Chi2Binning.h.

◆ _boxSets

std::vector<Chi2BoxSet> Chi2Binning::_boxSets
private

Definition at line 22 of file Chi2Binning.h.

◆ _nData

int Chi2Binning::_nData
private

Definition at line 23 of file Chi2Binning.h.

◆ _nMC

int Chi2Binning::_nMC
private

Definition at line 24 of file Chi2Binning.h.

◆ _totalMCWeight

double Chi2Binning::_totalMCWeight
private

Definition at line 25 of file Chi2Binning.h.


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