forked from GonzalezFJR/TOP13TeV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRunttHAnalysis.C
162 lines (140 loc) · 6.28 KB
/
RunttHAnalysis.C
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Load DatasetManager in ROOT 6
R__LOAD_LIBRARY(DatasetManager/DatasetManager.C+)
#include "DatasetManager/DatasetManager.h"
/*******************************************************************************
* Main function
*******************************************************************************/
void RunttHAnalysis(TString sampleName = "ZZ_ext" ,
Int_t nSlots = 1 ,
Long64_t nEvents = 0 ) {
// Variables to be used as parameters
Float_t G_Event_Weight = 1.0;
Bool_t G_IsData = false;
Bool_t G_IsMCatNLO = false;
// PAF mode choice and creation of project
//--------------------------------------------------------------------------
PAFIExecutionEnvironment* pafmode = 0;
cout << endl;
PAF_INFO("RunttHAnalysis", "======================================== Preprocess");
if (nSlots <=1 ) {
PAF_INFO("RunttHAnalysis", "+ Sequential mode chosen");
pafmode = new PAFSequentialEnvironment();
}
else if (nSlots <= 64) {
PAF_INFO("RunttHAnalysis", "+ PROOF Lite mode chosen");
pafmode = new PAFPROOFLiteEnvironment(nSlots);
}
else {
PAF_INFO("RunttHAnalysis", "+ PoD mode chosen");
pafmode = new PAFPoDEnvironment(nSlots);
}
PAFProject* myProject = new PAFProject(pafmode);
// Input data sample using DatasetManager
//--------------------------------------------------------------------------
TString userhome = "/mnt_pool/fanae105/user/$USER/";
PAF_INFO("RunttHAnalysis", "+ Configuring DatasetManager");
DatasetManager* dm = DatasetManager::GetInstance();
//dm->SetTab("DR80XasymptoticMiniAODv2");
dm->SetTab("DR80XSummer16asymptoticMiniAODv2_2");
cout << endl;
PAF_INFO("RunttHAnalysis", "+ Obtaining sample info:");
// Deal with data samples
if (sampleName == "DoubleEG" || sampleName == "DoubleMuon" ||
sampleName == "MuonEG" || sampleName.BeginsWith("Single")) {
PAF_INFO("RunttHAnalysis", " > The sample is " + sampleName + " DATA");
TString datasuffix[] = {
"16B_03Feb2017",
"16C_03Feb2017",
"16D_03Feb2017",
"16E_03Feb2017",
"16F_03Feb2017",
"16G_03Feb2017",
"16H_03Feb2017_v2",
"16H_03Feb2017_v3"
};
const UInt_t nDataSamples = 8;
for (UInt_t i = 0; i < nDataSamples; i++) {
TString asample = Form("Tree_%s_%s",sampleName.Data(), datasuffix[i].Data());
PAF_INFO("RunttHAnalysis", " > Importing " + asample + " ...");
myProject->AddDataFiles(dm->GetRealDataFiles(asample));
}
G_Event_Weight = 1.;
G_IsData = true;
cout << endl;
cout << " #===============================================" << endl;
cout << " # sampleName = " << sampleName << endl;
cout << " # x-section = " << dm->GetCrossSection() << endl;
cout << " # nevents = " << dm->GetEventsInTheSample() << endl;
cout << " # weight = " << G_Event_Weight << endl;
cout << " # isData = " << G_IsData << endl;
cout << " #===============================================" << endl;
cout << endl;
}
else { // Deal with MC samples
PAF_INFO("RunttHAnalysis", " > The sample is MC SIMULATION ");
G_IsData = false;
dm->LoadDataset(sampleName);
if (sampleName != "TestHeppy") myProject->AddDataFiles(dm->GetFiles());
if (sampleName.Contains("TTWToLNu") || sampleName == "TTWToQQ" ||
sampleName.Contains("TTZToQQ") || sampleName == "WWZ" ||
sampleName == "WZZ" || sampleName == "ZZZ" ||
sampleName.Contains("aMCatNLO") || sampleName.Contains("amcatnlo") ||
sampleName.Contains("TTZToLLNuNu") || sampleName.Contains("TTGJets") ||
sampleName == "ZGTo2LG" || sampleName.Contains("TGJets") ||
sampleName == "tZq_ll" || sampleName == "TTTT") {
G_Event_Weight = dm->GetCrossSection() / dm->GetSumWeights();
cout << endl;
cout << " weightSum(MC@NLO) = " << dm->GetSumWeights() << endl;
G_IsMCatNLO = true;
}
else if (sampleName == "TestHeppy") {
PAF_INFO("RunttHAnalysis", " > This is a TEST SAMPLE");
TString localpath = "/pool/ciencias/users/user/palencia/";
TString sample = "treeTtbar_jan19.root";
myProject->AddDataFile(localpath + sample);
G_Event_Weight = 1;
}
else {
G_Event_Weight = dm->GetCrossSection() / dm->GetEventsInTheSample();
}
if (nEvents ==0) nEvents= dm->GetEventsInTheSample();
cout << endl;
cout << " #===============================================" << endl;
cout << " # sampleName = " << sampleName << endl;
cout << " # x-section = " << dm->GetCrossSection() << endl;
cout << " # nevents = " << dm->GetEventsInTheSample() << endl;
cout << " # base file name = " << dm->GetBaseFileName() << endl;
cout << " # weight = " << G_Event_Weight << endl;
cout << " # isData = " << G_IsData << endl;
cout << " #===============================================" << endl;
cout << endl;
}
// Output file name
//--------------------------------------------------------------------------
TString outputDir = "./temp";
gSystem->mkdir(outputDir, kTRUE);
std::ostringstream oss;
TString outputFile = outputDir;
outputFile += "/Tree_" + sampleName + ".root";
PAF_INFO("RunttHAnalysis", Form("+ Output file = %s", outputFile.Data()));
myProject->SetOutputFile(outputFile);
// Parameters for the analysis
//--------------------------------------------------------------------------
PAF_INFO("RunttHAnalysis", Form("+ Setting parameters"));
myProject->SetInputParam("sampleName", sampleName );
myProject->SetInputParam("IsData", G_IsData );
myProject->SetInputParam("weight", G_Event_Weight );
myProject->SetInputParam("IsMCatNLO" , G_IsMCatNLO );
if(nEvents != 0) myProject->SetNEvents(nEvents);
// Name of selector class
PAF_INFO("RunttHAnalysis", "+ Loading selector and other packages");
//--------------------------------------------------------------------------
myProject->AddSelectorPackage("ttHAnalyzer");
// Additional packages
//--------------------------------------------------------------------------
myProject->AddPackage("BTagSFUtil");
// Start analysis
//--------------------------------------------------------------------------
PAF_INFO("RunttHAnalysis", Form("+ Starting compilation"));
myProject->Run();
}