#include "hparticlecutrange.h" #include #include #include "TDirectory.h" #include "TROOT.h" using namespace std; ClassImp(HParticleCutRange) //_HADES_CLASS_DESCRIPTION //////////////////////////////////////////////////////////////////////////////// // // // HParticleCutRange // // Helper class for cuts. // A cut has a name (should be unique), a cut number (better unique) // and a condition as argument of creation. The cut object owns counters // for the number of calls and the number of failed evaluations. The // The counters cand be used to monitor the efficiency of the cut // If the TCutG object belonging to the cut is set evalG(var,var,version) // will evaluate the graph. cut. // The cuts can be inversed by setInverse(Bool_t). In fact // cuts will than select outside the band low-up range and // for the graph cut isInside(var,var)==kFALSE will be sued for selection. // //######################################################### // USAGE: // // outside eventloop: // HParticleCutRange cut1("BetaCut",1,0.9,1.1); // // will create a cut object selecting beta range and // .... // // inside eventloop: // if(cut1->eval(beta,0)) { // true if condition is fullfilled, stat counted for version 0 // // } // if(cut1->eval(beta,1)) { // true if condition is fullfilled, stat counted for version 1 // // } // // .... // // after eventloop // cut1.print(); // show cut name,number,cut statistics and range // //////////////////////////////////////////////////////////////////////////////// HParticleCutRange::HParticleCutRange(TString name, Int_t num,Double_t l,Double_t u) { SetName(name); TDirectory* saveDir = gDirectory; gROOT->cd(); fCut = new TCutG(); fCut->SetName(name); flow = l; fup = u; fCutNumber = num; fmaxVersion = 0; fbInverseCut= kFALSE; setMaxCut(4); saveDir->cd(); } HParticleCutRange::~HParticleCutRange() { ; } void HParticleCutRange::setMaxCut(UInt_t max) { // set the max number of versions of stst counters fmaxCut = max; if(fmaxCut == 0) fmaxCut = 1; resetCounter(); } Bool_t HParticleCutRange::eval(Double_t var,UInt_t version){ // returns kTRUE if the object fullfills the condition. // counters for calls and failed conditions are filled. // version is used to fill the stat for a given version // (0 up to 9 incl ) if(versionfmaxVersion) fmaxVersion = version; } if( (!fbInverseCut && (var > fup || var < flow)) || ( fbInverseCut && !(var > fup || var < flow)) ) { if(versionGetN() == 0) { Warning("eval(var,var)","Cut %s has no set TCutG !",GetName()); return kFALSE; } if(versionfmaxVersion) fmaxVersion = version; } if( (!fbInverseCut && !fCut->IsInside(var,var2)) || ( fbInverseCut && fCut->IsInside(var,var2)) ) { if(version 0) ? (fctFail[version]/(Float_t)fctCall[version])*100.:0; } UInt_t HParticleCutRange::getNCall(UInt_t version) { return (version