Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...

86 changes: 41 additions & 45 deletions interface/BranchManager.h
Original file line number Diff line number Diff line change
@@ -1,56 +1,52 @@
#ifndef BranchManager_h
#define BranchManager_h

#include <vector>
#include <string>
#include <unordered_map>
#include <TBranch.h>
#include <TTree.h>
#include <TLorentzVector.h>

#include <TTree.h>
#include <string>
#include <unordered_map>
#include <vector>

struct BranchManager {
std::vector<TBranch*> branchHolder;
std::unordered_map<std::string, TBranch*> specificBranch;
TTree* fChain;

void SetTree(TTree* fChain_) {
fChain = fChain_;
}

template<typename T>
void SetBranch(std::string name, T& holder) {
branchHolder.push_back({});
fChain->SetBranchAddress(name.c_str(), &holder, &branchHolder.back());
}

template<typename T>
void SetSpecificBranch(std::string name, T& holder) {
if (specificBranch.find(name) != specificBranch.end())
specificBranch[name] = {};
fChain->SetBranchAddress(name.c_str(), &holder, &specificBranch[name]);
}

void SetEntry(int entry) {
for(auto& it: branchHolder) {
it->GetEntry(entry);
std::vector<TBranch*> branchHolder;
std::unordered_map<std::string, TBranch*> specificBranch;
TTree* fChain;

void SetTree(TTree* fChain_) { fChain = fChain_; }

template <typename T>
void SetBranch(std::string name, T& holder) {
branchHolder.push_back({});
fChain->SetBranchAddress(name.c_str(), &holder, &branchHolder.back());
}

template <typename T>
void SetSpecificBranch(std::string name, T& holder) {
if (specificBranch.find(name) != specificBranch.end())
specificBranch[name] = {};
fChain->SetBranchAddress(name.c_str(), &holder, &specificBranch[name]);
}

void SetEntry(int entry) {
for (auto& it : branchHolder) {
it->GetEntry(entry);
}
}

void SetSpecificEntry(int entry, std::string name) {
specificBranch[name]->GetEntry(entry);
}

void CleanUp() {
branchHolder.clear();
specificBranch.clear();
}

void CleanSpecificBranch(std::string name) {
if (specificBranch.find(name) != specificBranch.end())
specificBranch.at(name) = nullptr;
}
}

void SetSpecificEntry(int entry, std::string name) {
specificBranch[name]->GetEntry(entry);
}

void CleanUp() {
branchHolder.clear();
specificBranch.clear();
}

void CleanSpecificBranch(std::string name) {
if (specificBranch.find(name) != specificBranch.end())
specificBranch.at(name) = nullptr;
}
};

#endif

65 changes: 34 additions & 31 deletions interface/Efficiency.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,87 @@
#include "Analysis/VVAnalysis/interface/SelectorBase.h"
#include "Analysis/VVAnalysis/interface/ThreeLepSelector.h"

#include <TROOT.h>
#include <TChain.h>
#include <TEfficiency.h>
#include <TFile.h>
#include <TSelector.h>
#include <TH1.h>
#include <TH2.h>
#include <TEfficiency.h>
#include <TROOT.h>
#include <TSelector.h>
#include <exception>
#include <iostream>

// Headers needed by this particular selector
#include <vector>
#include "Analysis/VVAnalysis/interface/ScaleFactor.h"
#include "Analysis/VVAnalysis/interface/SelectorBase.h"
#include "Analysis/VVAnalysis/interface/BranchManager.h"
#include "Analysis/VVAnalysis/interface/GoodParticle.h"
#include "Analysis/VVAnalysis/interface/ScaleFactor.h"
#include "Analysis/VVAnalysis/interface/SelectorBase.h"
//#include "TLorentzVector.h"
typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>> LorentzVector;

typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double>>
LorentzVector;

class Efficiency : public SelectorBase {
public:
public:
ThreeLepSelector TTTAna;
ClassDefOverride(Efficiency, 0);



// NanoAOD variables
// static const unsigned int N_KEEP_MU_E_ = 35;
//static const unsigned int N_KEEP_JET_ = 35;
// static const unsigned int N_KEEP_JET_ = 35;
static const unsigned int N_KEEP_GEN_ = 300;
static const unsigned int N_KEEP_GEN_JET = 35;

//// gen branches ///////////////////////////
Float_t GenMET_pt;

UInt_t nGenPart;
Float_t GenPart_pt[N_KEEP_GEN_];
Int_t GenPart_pdgId[N_KEEP_GEN_];
Int_t GenPart_pdgId[N_KEEP_GEN_];
Float_t GenPart_eta[N_KEEP_GEN_];
Float_t GenPart_phi[N_KEEP_GEN_];
Float_t GenPart_mass[N_KEEP_GEN_];
Int_t GenPart_mother[N_KEEP_GEN_];

Float_t GenJet_eta[N_KEEP_GEN_JET];
Float_t GenJet_phi[N_KEEP_GEN_JET];
Float_t GenJet_pt[N_KEEP_GEN_JET];
UInt_t nGenJet;
Int_t GenJet_partonFlavour[N_KEEP_GEN_JET];
Int_t GenJet_hadronFlavour[N_KEEP_GEN_JET];
Float_t GenJet_mass[N_KEEP_GEN_JET];



BranchManager b;
double weight;
std::vector<GenPart> Leptons;
std::vector<GenPart> Jets;

std::map<int, std::string> lepNameMap = {{PID_MUON, "Muon"}, {PID_ELECTRON, "Elec"}};
std::map<int, std::string> lepNameMap = {{PID_MUON, "Muon"},
{PID_ELECTRON, "Elec"}};

TH2D* Beff_b;
TH2D* Beff_j;

void clearValues();
void fillReco(std::vector<GenPart>& genList, const std::vector<GoodPart>& recoList);

void fillReco(std::vector<GenPart>& genList,
const std::vector<GoodPart>& recoList);

// overloaded or necessary functions
virtual void SetBranchesNanoAOD() override;
void LoadBranchesNanoAOD(Long64_t entry, std::pair<Systematic, std::string> variation) override;
void FillHistograms(Long64_t entry, std::pair<Systematic, std::string> variation) override;
virtual void SetupNewDirectory() override;
virtual void SetBranchesNanoAOD() override;
void LoadBranchesNanoAOD(
Long64_t entry, std::pair<Systematic, std::string> variation) override;
void FillHistograms(Long64_t entry,
std::pair<Systematic, std::string> variation) override;
virtual void SetupNewDirectory() override;
// Readers to access the data (delete the ones you do not need).
virtual void SlaveBegin(TTree *tree) override {return;}
virtual void Init(TTree *tree) override; //{return;}
///ignore
void LoadBranchesUWVV(Long64_t entry, std::pair<Systematic, std::string> variation) override {return;}
virtual void SetBranchesUWVV() override {return;}
virtual void SlaveBegin(TTree* tree) override { return; }
virtual void Init(TTree* tree) override; //{return;}
/// ignore
void LoadBranchesUWVV(
Long64_t entry, std::pair<Systematic, std::string> variation) override {
return;
}
virtual void SetBranchesUWVV() override { return; }
};


#endif

Loading