//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Evaluation of combined FOPI PID information // // // // // Environment: // Software developed for GEM-TPC detector in FOPI. // // Author List: // Felix Boehmer TUM (original author) // // //----------------------------------------------------------- #ifndef FOPIPIDHUB_HH #define FOPIPIDHUB_HH #include "FopiPidInfo.h" #include "FopiPidFractionSet.h" #include "TString.h" #include "TObject.h" #include #include class FopiPidProbSet; class GFTrack; class TFile; //helper class defining momentum ranges or momentum values for quick mapping class FopiPidMomWindow : public TObject { public: FopiPidMomWindow(); virtual ~FopiPidMomWindow() {;} //defines a range FopiPidMomWindow(double plow, double phigh); //defines a single momentum value FopiPidMomWindow(double sharpP); bool operator== (const FopiPidMomWindow& ref) const; bool operator< (const FopiPidMomWindow& ref) const; FopiPidMomWindow& operator= (const FopiPidMomWindow& ref) ; private: bool isRange; bool isSharp; double momLow; double momHigh; double momSharp; public : ClassDef(FopiPidMomWindow,1) }; //CLASS FOPIPIDHUB ------------------------------------------------------------- class FopiPidHub : public TObject { public: FopiPidHub(); virtual ~FopiPidHub() {;} void setDetProbFile(const TString& det, const TString& file); //Set calibration data (containing a TGraphErrors), defining a stable //region via runLow, runHigh int setCalibrationFile(const TString& file, const TString& det, const TString& keyPion, const TString& keyProton, int runLow, int runHigh); //Activate use of fractions from MC simulations. Expects a .root file //containing FopiPidFractionSets. //If not used, fractions will be taken from Tpc dEdx fits (large error on those) int setUseMCFractions(const TString& file); //read in all files (data & calibration & MC fractions), build the mappings. int init(); void setVerbose(bool verb=true) {fVerbose=verb;} //Get particle type weight at a given momentum; //Either taken from TPC dE/dx fits or from MC information if //setUseMCFractions() is called. //Can be used as prior probability for a Bayesian treatment //returns -1. if lookup failed double getFraction(const TString& part, double mom) const; //Get fractional likelihood for particle at certain momentum, given a //measured PID quantity val (dE/dx, vel..) //compared to ALL other particle hypotheses in the available models; //If specified, weighting is considered, see getFraction() //In this case the returned likelihood corresponds to a Bayesian probability //with particle fractions treated as priors //Interval around val is added automatically double getFracLikelihood(const TString& part, double mom, const FopiPidInfo& data, bool weighted=false) const; //get fractional likelihood of hypothesis part versus hypothesis contestant double getFracLikelihood(const TString& part, const TString& contestant, double mom, const FopiPidInfo& data, bool weighted=false) const; //get fractional likelihood of hypothesis part versus hypotheses contestant 1 & 2 double getFracLikelihood(const TString& part, const TString& contestant1, const TString& contestant2, double mom, const FopiPidInfo& data, bool weighted=false) const; TString getDetProbFile(const TString& det) const; FopiPidInfo getCalibratedData(const FopiPidInfo& i) const; //for testing purposes: bool addTestWindow(const FopiPidMomWindow& w, double val); double getDouble(const FopiPidMomWindow& win) const; //cross-check: do fractions amount to 1? double getSumFractions(double mom) const; private: void buildBookMap(); //convenience helper std::map* makePartMap(const TString&) const; //convenience helper int buildCalibrationMaps(); //internal: get likelihood information for all parts and all dets int getLikelihoodMap(double, const FopiPidInfo&, std::map >& ) const; TString fFractionsMC; std::map fFracMCMap; std::map fTpcMap; std::map fCdcMap; std::map fBarMap; std::map fRpcMap; std::map* > fBookMap; std::map fFileMap; // detector <- data file std::map fTestMap; std::map fCalibIOMap; // detector <- calibration file std::map > fCalibKeyMap; // detector <- calibration (pionKey,protKey) std::map > fCalibRangeMap; // detector <- (rangeLow,rangeHigh) // det <- (run <- (slope,t) of calib line) : std::map >* > fCalibValMap; std::map > fTpcCalibMap; std::map > fCdcCalibMap; std::map > fBarCalibMap; std::map > fRpcCalibMap; bool fVerbose; bool fInit; std::vector fFilePointers; //TODO possibility to make it more clean public: ClassDef(FopiPidHub,1) }; #endif