/////////////////////////////////////////////////////////////////////////////// // // // /////////////////////////////////////////////////////////////////////////////// #include "TBrowser.h" #include "Stntuple/mod/StntupleCut.hh" #include "Stntuple/mod/StntupleModule.hh" ClassImp(StntupleCut) //_____________________________________________________________________________ StntupleCut::StntupleCut() { } //_____________________________________________________________________________ StntupleCut::StntupleCut(const char* Name, TModule* Module, Int_t Index, Double_t PMin, Double_t PMax, Int_t Nx, Double_t XMin, Double_t XMax, Int_t Mode) { // fName = Name; fIndex = Index; fPMin = PMin; fPMax = PMax; fNInput = 0; fNPassed = 0; fNx = Nx; fXMin = XMin; fXMax = XMax; fHist = new TH1F(Name,Name,Nx,XMin,XMax); fNBelow = 0; fNAbove = 0; fMode = Mode; // now we need to append a command to a module // it would be really nice to be appending a // cut to the list of cuts applied by the filter // only if cut is requested... // yet to be implemented Module->AddNewCommand(Module->NewCommand(Name)); } //_____________________________________________________________________________ StntupleCut::~StntupleCut() { delete fHist; } //_____________________________________________________________________________ Int_t StntupleCut::Passed(Double_t* P) { int passed (0); fNInput++; double p = P[fIndex]; fHist->Fill(p); if (fMode == 0) { // normal mode if ((p >= fPMin) && (p < fPMax)) { fNPassed++; passed = 1; } } else if (fMode == 1) { // veto mode if ((p < fPMin) || (p >= fPMax)) { fNPassed++; passed = 1; } } else if (fMode == 2) { // cut disabled, use for more // complicated selections passed = 1; } else { passed = 0; } return passed; } //_____________________________________________________________________________ Int_t StntupleCut::Passed(Double_t P) { fNInput++; fHist->Fill(P); if ((P >= fPMin) && (P < fPMax)) { fNPassed++; return 1; } else return 0; } //_____________________________________________________________________________ void StntupleCut::Clear(const char* Opt) { } //_____________________________________________________________________________ void StntupleCut::Print(const char* Opt) const { if ( (strcmp(Opt,"") == 0) || strstr(Opt,"banner")) { printf("-------------------------------------------------------------\n"); printf(" Name Index Mode PMin PMax "); printf(" NInput NPassed Fraction\n"); printf("-------------------------------------------------------------\n"); } if ( (strcmp(Opt,"") == 0) || strstr(Opt,"data")) { printf(" %-20s %3i %4i %12.3f %12.3f %8.0f %8.0f %6.4f\n", fName.Data(), fIndex, fMode, fPMin, fPMax, fNInput, fNPassed, fNPassed/(fNInput+1e-12)); } } //_____________________________________________________________________________ void StntupleCut::GetParameters(Double_t& PMin, Double_t& PMax, Double_t& Nx, Double_t& XMin, Double_t& XMax) { PMin = fPMin; PMax = fPMax; Nx = (int) fNx; XMin = fXMin; XMax = fXMax; } //_____________________________________________________________________________ void StntupleCut::SetParameters(Double_t PMin, Double_t PMax, Double_t Nx, Double_t XMin, Double_t XMax) { fPMin = PMin; fPMax = PMax; fNx = (int) Nx; fXMin = XMin; fXMax = XMax; } //______________________________________________________________________________ void StntupleCut::Browse(TBrowser* b) { if (fHist) fHist->Browse(b); }