#ifndef RXDataPlayer_HPP #define RXDataPlayer_HPP #include "IsoHelper.hpp" #include "TString.h" #include #include #include "RXDataPlayer.hpp" class TTreeFormula; class TH1D; class TChain; constexpr int MAXSLOTS = 100; /** * @brief Class for order in the std::tuple< Var,Sel,Weight> when wrapping the containers */ enum class Order : int{ Selection =0, Weight =1, Variable =2 }; /** * @brief Class housing infos for the rx weight processing/plotting */ class RXWeight{ public: /** * @brief Constructs the object. */ RXWeight(){}; /** * The WeightExpression to use in TTreeFormula when loading the value */ TString weightExpr; /** * The WeightLabel associated to this Weight, it will populate the final Histogram */ TString weightLabel; /** * The unique IDX identifying this object, the idx is used such that Weight1 == Weight2 if idx == idx, useful to store map and retrieve object associated to a given objec */ int w_idx; /** * @brief Constructs the object with an IDX, an Expression, The Actual Label * * @param[in] idx The index * @param[in] _weightExpr The weight expression * @param[in] _weightLabel The weight label */ RXWeight( int idx, TString _weightExpr, TString _weightLabel){ w_idx= idx;//idx*MAXSLOTS*MAXSLOTS; weightExpr = _weightExpr; weightLabel = _weightLabel; }; /** * @brief Returnm this oject Weight Expression * * @return { description_of_the_return_value } */ TString Expression()const{ return weightExpr;} /** * @brief Return the label of This Object * * @return { description_of_the_return_value } */ TString Label()const{ return weightLabel;} /** * @brief Print for Debugging */ void Print()const{ std::cout<<"*WIDX "<( const RXSelection & a, const RXSelection & b){ // return a.cut_idx() > b.cut_idx(); // } friend bool operator==( const RXSelection & a, const RXSelection & b){ return a.cut_idx() == b.cut_idx(); } bool operator<(const RXSelection& rhs) const{ return c_idx < rhs.cut_idx(); }; int cut_idx()const{ return c_idx; }; // int idx_linked()const{ // return c_idx*MAXSLOTS*MAXSLOTS; // } void Print()const{ std::cout<<"*CIDX"< > RXWSelVars ; extern int GetVarIdx( int idx); extern int GetCutIdx( int idx); extern int GetWeightIdx( int idx); //mapped int from weight, var, cut class RXDataPlayer{ public: RXDataPlayer(){}; RXDataPlayer(TString _name){m_name = _name;}; /** * @brief * * @param[in] _varExpression The variable expression to use in Drawing * @param[in] _VarLabel The variable label to attach to the X-Axis * @param[in] nBins The bins on which to plot * @param[in] min The minimum on which to plot * @param[in] max The maximum on which to plot * @param[in] Units The units to use on this variable * @param[in] isoBin The iso bin flag [not used yet] * @param[in] useLogy The use logy [not used yet, no "full-plot report available at the moment"] */ void Book1DHist( TString _varExpression, TString _VarLabel, int nBins, double min, double max ,TString Units ="", bool isoBin = false, bool useLogy =false ); /** * @brief Book1D histo passing a RooRealVar, we will use the name, title, nBins, units to book the histogram * * @param[in] var The variable */ void Book1DHist( const RooRealVar & var ); // void Book1DHist( TString _varExpression, int nBins, double min, double max ,TString Units, bool isoBin = false, bool useLogy = false ); /** * @brief Add a Selection Switcher for all the variables in the pool * * @param[in] idx The index "fetching" this selection * @param[in] _selection The selection expression (TCut) * @param[in] Label The label of the selection */ void BookRXSelection( TCut _selection , TString Label); /** * @brief BookRXWeight * * @param[in] _weight The weight * @param[in] RXWeightLabel The rx weight label */ void BookRXWeight( TString _weight , TString RXWeightLabel); int GetNSelections() const { return m_nRXSelections; }; int GetNWeightExp() const { return m_nRXWeights; }; int GetNVarPlot() const { return m_nVars;}; vector GetValues(int _idx_var); vector GetSelectionValues(int _idx_sel); vector GetWeightValues( int _idx_weight); void Print(){ std::cout<<"N Booked Vars. "<< GetNVarPlot() << std::endl; for(const auto & vv : m_bookedVariable){ vv.second.Print(); } std::cout<<"N Booked Cuts "<< GetNSelections() << std::endl; for(const auto & vv : m_bookedRXSelections){ vv.second.Print(); } std::cout<<"N Booked Weights "<< GetNWeightExp() << std::endl; for(const auto & vv : m_bookedRXWeights){ vv.second.Print(); } } //0,1,2 for Order in the tuple std::vector< std::tuple > BuildCombination( ); //const map & _RXSelections, const map & _RXWeights, const map & _Variables); void Process( TChain & _inputChain, double frac = -1 ) noexcept; TH1D * GetHistogram( int _idx_var, int _idx_cut, int _idx_weight); void Reset(); private : // TString m_name = ""; std::map m_bookedRXWeights = {}; std::map m_bookedRXSelections = {}; std::map m_bookedVariable = {}; std::map > m_bookedWeightsResults = {}; std::map > m_bookedSelectionResults = {}; std::map > m_bookedVariableValues = {}; std::map > m_bookedWCut = {} ; //range |XXYY| = XX = RXSelection idx, YY = RXWeight IDX int m_nRXSelections =0;//0-99 int m_nRXWeights =0;//0-99 int m_nVars =0;//0-99 TString m_name; }; #endif