-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from alspellm/ana_dev_pr_20230726
Merger of 3 different development branches into one PR
- Loading branch information
Showing
53 changed files
with
9,628 additions
and
422 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#ifndef ITERATIVECUTSELECTOR_H | ||
#define ITERATIVECUTSELECTOR_H | ||
|
||
#include <string> | ||
#include <iostream> | ||
#include <map> | ||
#include <memory> | ||
#include "BaseSelector.h" | ||
|
||
#include "TH1F.h" | ||
#include "json.hpp" | ||
|
||
// for convenience | ||
using json = nlohmann::json; | ||
|
||
/** | ||
* @brief brief description | ||
* | ||
* more details | ||
*/ | ||
class IterativeCutSelector : public BaseSelector { | ||
|
||
public: | ||
|
||
IterativeCutSelector(); | ||
|
||
IterativeCutSelector(const std::string& inputName); | ||
|
||
IterativeCutSelector(const std::string& inputName, const std::string& cfgFile); | ||
|
||
virtual ~IterativeCutSelector(); | ||
|
||
/** | ||
* @brief get cut variable from name | ||
* | ||
* @param cutname | ||
*/ | ||
std::string getCutVar(std::string cutname); | ||
|
||
/** | ||
* @brief is cut of type 'greater than' | ||
* | ||
* @param cutname | ||
* @return true | ||
* @return false | ||
*/ | ||
bool isCutGreaterThan(std::string cutname); | ||
|
||
/** | ||
* @brief set cut value | ||
* | ||
* @param cutname | ||
* @param value | ||
*/ | ||
void setCutValue(std::string cutname, double value); | ||
|
||
/** | ||
* @brief does value pass cut | ||
* | ||
* @param cutname | ||
* @param val | ||
* @return true | ||
* @return false | ||
*/ | ||
bool passCutGTorLT(std::string cutname, double val); | ||
|
||
/** | ||
* @brief prints cuts and values | ||
* | ||
*/ | ||
void printCuts(); | ||
|
||
/** | ||
* @brief get cut ID | ||
* @param cutname | ||
* @return cut ID | ||
* | ||
*/ | ||
int getCutID(std::string cutname){return cuts[cutname].second;}; | ||
|
||
/** | ||
* @brief remove cuts that aren't specified in the list of cut | ||
* variables | ||
* @param cut_variables_list | ||
* | ||
*/ | ||
void filterCuts(std::vector<std::string> cut_variable_list); | ||
|
||
/** | ||
* @brief get pointer to the base class cuts | ||
* | ||
*/ | ||
std::map<std::string, std::pair<double,int>>* getPointerToCuts(){ return &cuts; } | ||
|
||
|
||
private: | ||
//When this variable value is encountered, do not apply cut to event | ||
double skipCutVarValue_ = -9876543210.0; //Must match definition in MutableTTree | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#ifndef MUTABLE_TTREE_H | ||
#define MUTABLE_TTREE_H | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <cstdlib> | ||
#include <TTree.h> | ||
#include <TFile.h> | ||
#include <TBranch.h> | ||
#include <functional> | ||
|
||
/** | ||
* @brief Reads flat TTree and allows user to create new variables in the TTree | ||
*/ | ||
class MutableTTree { | ||
|
||
public: | ||
|
||
MutableTTree(TFile* infile, std::string tree_name); | ||
|
||
/** | ||
* @brief return number of entries in tree | ||
*/ | ||
int GetEntries(){return tree_->GetEntries();} | ||
|
||
/** | ||
* @brief get tree entry | ||
* @param entry | ||
*/ | ||
void GetEntry(int entry){tree_->GetEntry(entry);} | ||
|
||
/** | ||
* @brief Fill ttree with new variables included | ||
*/ | ||
void Fill(); | ||
|
||
/** | ||
* @brief Apply any corrections to specified variable | ||
* @param variable | ||
* @param correction/shift | ||
*/ | ||
void shiftVariable(std::string variable, double shift); | ||
|
||
/** | ||
* @brief Get the value of a flat tuple variable | ||
* @param branch_name | ||
* @return value | ||
*/ | ||
double getValue(std::string branch_name); | ||
|
||
/** | ||
* @brief Print TTree Event | ||
*/ | ||
void printEvent(); | ||
|
||
/** | ||
* @brief Set branch value | ||
* @param branch_name | ||
* @param value | ||
*/ | ||
void setBranchValue(std::string branch_name, double value){*tuple_[branch_name] = value;} | ||
|
||
/** | ||
* @brief Add new branch to ttree | ||
* @param branch | ||
*/ | ||
void addNewBranch(std::string branch); | ||
|
||
/** | ||
* @brief Set the mass window within which to read the input ttree | ||
* @param lowMass | ||
* @param highMass | ||
*/ | ||
void defineMassWindow(double lowMass, double highMass); | ||
|
||
/** | ||
* @brief Get list of all variables defined in ttree | ||
*/ | ||
std::vector<std::string> getAllVariables(); | ||
|
||
/** | ||
* @brief Check if a variable exists in the ttree | ||
* @param variable | ||
* @return true | ||
* @return false | ||
*/ | ||
bool variableExists(std::string variable); | ||
|
||
~MutableTTree(); | ||
|
||
protected: | ||
TTree* tree_{nullptr}; //!< flat ttree | ||
TTree* newtree_{nullptr}; //!< temporary ttree used to create and fill new branches | ||
std::map<std::string,double*> tuple_; //!< holds all variables and values | ||
std::map<std::string,TBranch*> new_branches; //!< list of new branches added to ttree | ||
std::map<std::string, double*> new_variables_;//!< list of new variables | ||
std::map<std::string,std::function<double()>> functions_;//!< functions that calculate new variables | ||
std::map<std::string,std::function<double()>> variable_shifts_;//!< variable corrections | ||
|
||
private: | ||
/** | ||
* @brief read in the initial flat TTree | ||
* @param tree | ||
* @param tuple_map | ||
*/ | ||
void initializeFlatTuple(TTree* tree, std::map<std::string, double*> &tuple_map); | ||
|
||
/** | ||
* @brief copy the TTree | ||
*/ | ||
void copyTTree(); | ||
|
||
double lowMass_{-999.9};//!< mass window low | ||
double highMass_{-999.9};//!< mass window high | ||
}; | ||
|
||
#endif // __MUTABLE_TTREE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#ifndef SIMP_ANA_TTREE_H | ||
#define SIMP_ANA_TTREE_H | ||
|
||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <cstdlib> | ||
#include <TTree.h> | ||
#include <TFile.h> | ||
#include <TBranch.h> | ||
|
||
#include "MutableTTree.h" | ||
|
||
/** | ||
*@brief Read in flat TTree and create new cut variables for SIMP analysis | ||
*/ | ||
class SimpAnaTTree : public MutableTTree { | ||
|
||
public: | ||
|
||
SimpAnaTTree(TFile* infile, std::string tree_name) : MutableTTree(infile,tree_name){}; | ||
~SimpAnaTTree(); | ||
|
||
/** | ||
*@brief New Variables | ||
*/ | ||
/* | ||
void addVariable_unc_vtx_zalpha(double y_intercept, double slope, double alpha_z); | ||
void addVariable_unc_vtx_zbravo(); | ||
void addVariable_unc_vtx_zbravoAlpha(double slope); | ||
void addVariable_unc_vtx_zbravosum(); | ||
void addVariable_unc_vtx_zbravosumAlpha(double slope); | ||
void addVariable_unc_vtx_ZalphaTop(double slope); | ||
void addVariable_unc_vtx_ZalphaBot(double slope); | ||
void addVariable_unc_vtx_ZalphaTopBot(double top_slope, double bot_slope); | ||
void addVariable_unc_vtx_ZbravoAlphaTop(double slope); | ||
void addVariable_unc_vtx_ZbravoAlphaBot(double slope); | ||
void addVariable_unc_vtx_ZalphaBotEle(double slope); | ||
void addVariable_unc_vtx_ZalphaTopEle(double slope); | ||
void addVariable_unc_vtx_ZalphaTopPos(double slope); | ||
void addVariable_unc_vtx_ZalphaBotPos(double slope); | ||
*/ | ||
|
||
void addVariable_unc_vtx_ele_zalpha(double slope); | ||
void addVariable_unc_vtx_pos_zalpha(double slope); | ||
void addVariable_unc_vtx_zalpha_max(double slope); | ||
void addVariable_unc_vtx_zalpha_min(double slope); | ||
|
||
void addVariable_unc_vtx_ele_iso_z0err(); | ||
void addVariable_unc_vtx_pos_iso_z0err(); | ||
void addVariable_unc_vtx_ele_z0_z0err(); | ||
void addVariable_unc_vtx_pos_z0_z0err(); | ||
void addVariable_unc_vtx_ele_isolation_cut(); | ||
void addVariable_unc_vtx_pos_isolation_cut(); | ||
|
||
void addVariable_unc_vtx_ele_z0tanlambda(); | ||
void addVariable_unc_vtx_pos_z0tanlambda(); | ||
void addVariable_unc_vtx_ele_z0tanlambda_right(double slope); | ||
void addVariable_unc_vtx_pos_z0tanlambda_right(double slope); | ||
void addVariable_unc_vtx_ele_z0tanlambda_left(double slope); | ||
void addVariable_unc_vtx_pos_z0tanlambda_left(double slope); | ||
|
||
void addVariable_unc_vtx_abs_delta_z0tanlambda(); | ||
|
||
//misc | ||
bool impactParameterCut2016Canonical(double mass); | ||
bool testImpactParameterCut(); | ||
|
||
private: | ||
double skipCutVarValue_ = -9876543210.0;//<! if cut variable is not defined for an event, assign this value | ||
}; | ||
|
||
#endif // __SIMP_ANA_TTREE_H |
Oops, something went wrong.