22 static const int NRGBs = 7;
23 if(0 != __colourPalette)
delete[] __colourPalette;
24 __colourPalette =
new int[__Ncol];
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
35 for(
int i=0; i < __Ncol; i++) __colourPalette[i]=Fi + i;
38 static const int NRGBs = 7;
39 if(0 != __colourPalette)
delete[] __colourPalette;
40 __colourPalette =
new int[__Ncol];
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
51 for(
int i=0; i < __Ncol; i++) __colourPalette[i]=Fi + i;
54 static const int NRGBs = 5;
56 if(0 != __colourPalette)
delete[] __colourPalette;
57 __colourPalette =
new int[__Ncol];
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
68 for(
int i=0; i < __Ncol; i++) __colourPalette[i]=Fi + i;
71 makeColourPaletteBlueGrey();
77 if(0 == __colourPalette) makeColourPalette();
78 return __colourPalette;
92 if(0 == events)
return 0;
93 if(0 == events->
size())
return 0;
104 sort(boxes.
begin(), boxes.
end(), sorter);
109 for(
unsigned int i=0; i < boxes.
size(); i++){
110 boxSet.
add(boxes[i]);
111 if(boxSet.nData() >= minPerBin){
126 cout <<
"Chi2Binning::splitBoxes(MINT::IEventList<DalitzEvent>* events , int maxPerBin = " 127 << maxPerBin <<
") called" << endl;
131 if(0 == events)
return dummy;
140 if(0 == events.
size())
return dummy;
146 bool needToSplitMore=
false;
151 int failedSet=0, failedBox=0;
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))){
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;
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());
174 newBoxes.
add(boxes[i]);
178 }
while(needToSplitMore);
187 for(
unsigned int i=0; i <
_boxSets.size(); i++){
192 for(
unsigned int k=0; k < data.
size(); k++){
195 for(
unsigned int i=0; i <
_boxSets.size(); i++){
203 cout <<
"WARNING in Chi2Binning::fillData:" 204 <<
"\n\t didn't find box for event " 207 cout <<
"compare to first event: " << endl;
210 Chi2Box box(evt.eventPattern());
211 cout <<
"would have fit into large? " 220 cout <<
"Chi2Binning::fillMC called with " 221 << &mc <<
", " << pdf << endl;
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;
228 double weight = pdf->
getVal_noPs(evt) * evt.getWeight() /
229 evt.getGeneratorPdfRelativeToPhaseSpace();
231 if(printit) cout <<
", with weight " << weight << endl;
233 for(
unsigned int i=0; i <
_boxSets.size(); i++){
242 cout <<
"event " << k <<
" in " << n <<
" out of " <<
numBins()
243 <<
" box sets" << endl;
244 if(0 == n) evt.print();
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;
270 if(dbThis) cout <<
"...number of chi2 bins = " <<
numBins() << endl;
272 if(dbThis) cout <<
"...about to fill in the data " << endl;
274 if(dbThis) cout <<
"...done that - now the MC" << endl;
276 if(dbThis) cout <<
"... fillMC done, now setting norm factors" << endl;
278 if(dbThis) cout <<
" done the norm factors, now sorting by chi2" << endl;
280 if(dbThis) cout <<
" Chi2Binning::setEventsAndPdf done" << endl;
291 cout <<
"Chi2Binning::setFas: this is the fas:" << endl;
295 for(
unsigned int i=0; i <
_boxSets.size(); i++){
297 _boxSets[i].setIIntegrationCalculator(fap);
306 double sumVarData =0;
308 for(
unsigned int i=0; i <
_boxSets.size(); i++){
310 nDataCheck += n_data;
312 nMCCheck += weight_mc;
316 double varData_expected = weight_mc;
317 sumVarData += varData_expected;
323 os <<
" data " <<
_boxSets[i].nData();
325 os <<
", (nMC " <<
_boxSets[i].nMC() <<
")";
326 os <<
", chi2 " << chi2 << endl;
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
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!" 353 for(
unsigned int i=0; i <
_boxSets.size(); i++){
359 if(i >
_boxSets.size())
return -9999;
363 if(
_nMC <= 0)
return -9999;
364 if(
_nData <=0 )
return -9999;
368 for(
unsigned int i=0; i <
_boxSets.size(); i++){
377 for(
unsigned int i=0; i <
_boxSets.size(); i++){
379 if(chi2 > max) max=chi2;
400 for(
unsigned int i=0; i <
_boxSets.size(); i++){
402 int colIndex = (chi2/maxChi2)*(
__Ncol-1);
411 for(
unsigned int i=0; i <
_boxSets.size(); i++){
425 for(
unsigned int i=0; i <
_boxSets.size(); i++){
440 cout <<
"from " << from <<
" to " << to << endl;
444 for(
unsigned int i=0; i <
_boxSets.size(); i++){
455 can.Print(fname.c_str());
MINT::counted_ptr< TH1D > getChi2Distribution() const
static void makeColourPaletteBlueGrey()
double getChi2_perBin() const
void add(const Chi2Box &box)
double getMaxChi2() const
static void makeColourPaletteBlueWhite()
double chi2(double normFactorPassed=-1) const
static int * __colourPalette
Chi2BoxSet splitBoxes(MINT::IMinimalEventList< DalitzEvent > *events, int maxPerBin) const
std::vector< T >::iterator end()
virtual MINT::counted_ptr< IIntegrationCalculator > clone_IIntegrationCalculator() const =0
static void makeColourPaletteRGB()
double setEventsAndPdf(MINT::IMinimalEventList< DalitzEvent > *data, MINT::IMinimalEventList< DalitzEvent > *mc, IDalitzPdf *pdf, IFastAmplitudeIntegrable *fas=0)
void drawChi2Distribution(const std::string &fname="chi2Distribution.eps") const
std::ostream & operator<<(std::ostream &os, const Chi2Binning &c2b)
virtual MINT::counted_ptr< IIntegrationCalculator > makeIntegrationCalculator()=0
void fillMC(MINT::IMinimalEventList< DalitzEvent > &mc, IDalitzPdf *pdf)
double chi2_ofBin(unsigned int i) const
int createBinning(MINT::IMinimalEventList< DalitzEvent > *events, int minPerBin=10, int maxPerBin=100)
bool operator()(const Chi2BoxSet &a, const Chi2BoxSet &b) const
virtual void add(const DalitzCoordSet &coord, const MINT::counted_ptr< TH1 > &histo)
void setBoxesNormFactors()
static void makeColourPalette()
bool addData(const IDalitzEvent &evt)
void fillData(MINT::IMinimalEventList< DalitzEvent > &data)
std::vector< T >::iterator begin()
virtual EVENT_TYPE getEvent(unsigned int i) const =0
static int * getColourPalette()
virtual const DalitzEventPattern & eventPattern() const =0
DalitzHistoStackSet getMCHistoStack()
virtual void print(std::ostream &os=std::cout) const =0
unsigned int size() const
std::vector< Chi2BoxSet > _boxSets
void setColourPalette(int nCol, int *pal, double max, double min=0.000001)
void print(std::ostream &os=std::cout) const
DalitzHistoStackSet getDataHistoStack()
void setFas(IFastAmplitudeIntegrable *fas)
virtual unsigned int size() const =0
int mergeBoxes(Chi2BoxSet &boxes, int minPerBin)
void print(std::ostream &os=std::cout) const
double normFactor() const
virtual double getVal_noPs(IDalitzEvent &evt)=0
bool operator()(const Chi2Box &a, const Chi2Box &b) const