using namespace std; #include "hrtparamfinder.h" #include "TNtuple.h" #include "TFile.h" #include #include #include Int_t HRtMatchCell::Compare(const TObject *obj) const { const HRtMatchCell *cell = dynamic_cast(obj); Float_t diff = getSignalBackground() - cell->getSignalBackground(); Int_t r = 0; if (diff<0.) r = -1; else if (diff>0.) r = +1; return r; } //_HADES_CLASS_DESCRIPTION ////////////////////////////////////////////////////////// HRtMatchGrid::HRtMatchGrid(void) { fCells = 0; fMin = fMax = fBinSize = 0; fBins = 0; } HRtMatchGrid::~HRtMatchGrid(void) { delete[] fCells; delete[] fMin; delete[] fMax; delete[] fBinSize; delete[] fBins; } void HRtMatchGrid::setDimension(Int_t n,Int_t bins[]) { fDimension = n; //Reallocate memory memory delete[] fMin; fMin = new Float_t[fDimension]; delete[] fMax; fMax = new Float_t[fDimension]; delete[] fBinSize; fBinSize = new Float_t[fDimension]; delete[] fBins; fBins = new Int_t[fDimension]; fTotalBins = 1; for (Int_t i=0;isetDimension(fDimension,fBins); for (UInt_t i=0;isetRange(i,fMin[i],fMax[i]); } //copy data for (UInt_t i=0;ibin(i) = fCells[i].weight; r->bin(fTotalBins) = 0; return r; } //////////////////////////////////////////////////////// HRtParamFinder::HRtParamFinder(void) { bnValid = "valid"; fTotalGood = 0; bnVar = 0; lsVar = 0; } HRtParamFinder::~HRtParamFinder(void) { delete[] bnVar; delete[] lsVar; } void HRtParamFinder::setDimension(Int_t n,...) { va_list ap; Int_t *bins = new Int_t[n]; va_start(ap,n); for (Int_t i=0;iSetBranchAddress(bnVar[i].Data(), &lsVar[i]); } tuple->SetBranchAddress(bnValid.Data(), &valid); entries = tuple->GetEntries(); if (entries > maxEntries) entries = maxEntries; for (Int_t i=0;iGetEntry(i); for (UInt_t j=0; jfMinValid && valid0.) { while (efficiency < targetEfficiency && (cell=(HRtMatchCell *)next())!=0) { accumGood += cell->nGood; accumFakes += cell->nFakes; efficiency = float(accumGood) / float(fTotalGood); cell->weight = 1; } } else { while ((cell=(HRtMatchCell *)next())!=0) { if (cell->getSignalBackground()>=1.) { accumGood += cell->nGood; accumFakes += cell->nFakes; efficiency = float(accumGood) / float(fTotalGood); cell->weight = 1; } } } while ((cell=(HRtMatchCell *)next())!=0) cell->weight = 0; noise = float(accumFakes) / float(accumGood + accumFakes); cout << "Target efficiency was: " << targetEfficiency << endl; cout << "Achieved efficiency: " << efficiency << " = "; cout << accumGood << "/" << fTotalGood << endl; cout << "Noise ratio: " << noise << " = "; cout << accumFakes << "/( " << accumFakes << " + " << accumGood << ")"<