-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRecoWprime.cc
124 lines (110 loc) · 3.81 KB
/
RecoWprime.cc
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "Utilities/Analyzer.cc"
class ThisAnalyzer : public Analyzer {
public:
ThisAnalyzer(Configs *conf_): Analyzer(conf_) {
};
std::array<int,9> RegionIdentifier;
std::array<float,18> EventWeight;
float SimpleWprimeLL;
float SimpleWprimeFL;
int SimpleWprimeType;
float FLdRtb;
float LLdRtb;
float WprimeFL;
float WprimeLL;
int WprimeType; // 0 for FL, 1 for LL
float Likelihood;
void BookBranches() {
t->Branch("RegionIdentifier", &RegionIdentifier);
t->Branch("EventWeight", &EventWeight);
t->Branch("SimpleWprimeFL",&SimpleWprimeFL);
t->Branch("SimpleWprimeLL",&SimpleWprimeLL);
t->Branch("SimpleWprimeType",&SimpleWprimeType);
t->Branch("WprimeFL",&WprimeFL);
t->Branch("WprimeLL",&WprimeLL);
t->Branch("WprimeType",&WprimeType);
t->Branch("Likelihood", &Likelihood);
}
void FitEvent() {
Ftr->SetJets(r->Jets);
if (r->RegionAssociations.Regions[0] / 1000 == 1) Ftr->SetLep(r->Muons[0]);
else if (r->RegionAssociations.Regions[0] / 1000 == 2) Ftr->SetLep(r->Electrons[0]);
Ftr->SetMET(r->Met);
Likelihood = Ftr->Optimize();
// cout << "Likelihood = " << Likelihood <<endl;
if (Likelihood > 0) {
Ftr->BestWPrime();
WprimeFL = Ftr->BestHypo.FLWP().M();
WprimeLL = Ftr->BestHypo.LLWP().M();
WprimeType = Ftr->BestHypo.Type;
}
else {
WprimeFL = 0;
WprimeLL = 0;
WprimeType = -1;
}
}
void FillBranchContent() {
for(unsigned i = 0; i < 9; ++i){
RegionIdentifier[i] = 0;
//RegionName[i] = "";
}
for(unsigned i = 0; i < 18; ++i){
EventWeight[i] = 0.;
//EventWeightName[i] = "";
}
SimpleWprimeFL = 0.;
SimpleWprimeLL = 0.;
SimpleWprimeType = -1;
WprimeFL = 0.;
WprimeLL = 0.;
WprimeType = -1;
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;
//EventWeightName[i] = r->EventWeights[i].second;
}
TLorentzVector vWprimeLL, vWprimeFL;
// SimpleWprime assume Jets[0] to be the W' b. And Jet[1] from the top decayed from the W'
// Jets[3] Jets[4] are light jets.
vWprimeFL = r->Jets[0] + r->Jets[1] + r->Jets[3] + r->Jets[4]; // Jets 2 is most likely from the top not produced by W'
float dr = r->Jets[0].DeltaR(r->Jets[1] + r->Jets[3] + r->Jets[4]);
if(RegionIdentifier[0]/1000 == 1) vWprimeLL = r->Muons[0] + r->Met + r->Jets[0] + r->Jets[1];
else if(RegionIdentifier[0]/1000 == 2) vWprimeLL = r->Electrons[0] + r->Met + r->Jets[0] + r->Jets[1];
if ((vWprimeLL - r->Jets[0]).DeltaR(r->Jets[0]) > dr) SimpleWprimeType = 1;
else SimpleWprimeType = 0;
SimpleWprimeLL = vWprimeLL.M();
SimpleWprimeFL = vWprimeFL.M();
FitEvent();
}
};
void RecoWprime(int sampleyear = 3, int sampletype = 19, int ifile = 0) {
Configs* conf = new Configs(sampleyear, sampletype, ifile);
conf->Debug = false;
conf->LocalOutput = true;
conf->PrintProgress = true;
conf->ProgressInterval = 100;
// conf->InputFile = "All";
// conf->EntryMax = 123900;
ThisAnalyzer *a = new ThisAnalyzer(conf);
a->SetOutput("RecoWprime");
cout << "Begin Loop" <<endl;
for (Long64_t ievt = 0; ievt < a->GetEntryMax(); ++ievt) {
// if (ievt > 100) break;
if (!a->ReadEvent(ievt)) continue;
if (a->r->RegionAssociations.Regions[0] <=0) continue;
if (a->r->RegionAssociations.GetNJets(0) < 5) {
// cout << "Prefiltering at main code" <<endl;
// for (unsigned i = 1; i < 9; ++i) {
// if (a->r->RegionAssociations.GetNJets(i) >= 5) cout << "In region " << i << ", 5 Jets is achieved" <<endl;
// }
continue;
}
a->FillBranchContent();
a->FillTree();
}
a->SaveOutput();
a->CloseOutput();
}