-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPileupDist.cc
More file actions
93 lines (80 loc) · 2.26 KB
/
PileupDist.cc
File metadata and controls
93 lines (80 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <TString.h>
// #include <TVector2.h>
#include <TH1.h>
#include <TH2.h>
#include <TH3.h>
#include <TF1.h>
// #include <TFitResult.h>
// #include <TClonesArray.h>
#include <TTree.h>
#include <TChain.h>
#include <TFile.h>
#include <TLorentzVector.h>
#include <TProfile.h>
#include <TEfficiency.h>
// std
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <map>
#include "Utilities/Analyzer.cc"
class ThisAnalysis : public Analyzer {
public:
ThisAnalysis(Configs *conf_) : Analyzer(conf_) {
};
std::array<int,9> RegionIdentifier;
std::array<float,18> EventWeight;
std::array<float,7> PUWeight;
double nTrueInt;
int nPVGood;
void BookBranches() {
t->Branch("RegionIdentifier", &RegionIdentifier);
t->Branch("EventWeight", &EventWeight);
t->Branch("PUWeight", &PUWeight);
t->Branch("nTrueInt", &nTrueInt);
t->Branch("nPVGood", &nPVGood);
}
void FillBranchContent() {
nTrueInt = 0;
nPVGood = r->PV_npvsGood;
for (unsigned i = 0; i < r-> RegionAssociations.RegionCount; ++i) {
RegionIdentifier[i] = r->RegionAssociations.Regions[i];
}
for (unsigned i = 0; i < r->EventWeights.size(); ++i) {
EventWeight[i] = r->EventWeights[i].first;
}
if (IsMC) {
nTrueInt = r->Pileup_nTrueInt;
PUWeight[0] = r->evts->Pileup_scaleFactor;
PUWeight[1] = r->evts->Pileup_scaleFactorUp;
PUWeight[2] = r->evts->Pileup_scaleFactorDown;
// for (unsigned i = 0; i < 4; ++i) {
// PUWeight[i + 3] = GetEventPUWeight(i);
// }
}
}
};
void PileupDist(int isampleyear = 3, int isampletype = 2, int ifile = 0, int nfile = 1) {
Configs *conf = new Configs(isampleyear, isampletype, ifile);
conf->Debug = false;
// conf->PUEvaluation = true;
// conf->DASInput = true;
conf->PrintProgress = true;
conf->FilesPerJob = nfile;
conf->EntryMax = 10000;
conf->SetSwitch("LocalOutput",true);
// conf->InputFile = "All";
ThisAnalysis *a = new ThisAnalysis(conf);
a->SetOutput("PUEval");
for (Long64_t iEvent = 0; iEvent < a->GetEntryMax(); ++iEvent) {
bool KeepEvent = a->ReadEvent(iEvent);
if (!KeepEvent) continue;
a->FillBranchContent();
a->FillTree();
}
a->SaveOutput();
a->CloseOutput();
}