-
Notifications
You must be signed in to change notification settings - Fork 0
/
recupTheZpeak.C
69 lines (61 loc) · 2.29 KB
/
recupTheZpeak.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
TString outputDir = "fitPlots"; //directory that will contain the fit plots
TString thePlotToDraw[1] = {"Tight2012"}; // name of the ID in the TnP trees
TString theName[1] = {"Tight_POG_ID"}; // name of the ID that will appear on the plot ...
nbOfIds = 1; //number of IDs
TString thePath = "/afs/cern.ch/user/h/hbrun/public/testTnPoutput/";// the directory where to find the TnP output
TString kind;
recupTheZpeak(){
// TDirectory *theDr = (TDirectory*) myFile->Get("eleIDdir");///denom_pt/fit_eff_plots");
//theDr->ls();
int myIndex;
TSystemDirectory dir(thePath, thePath);
TSystemFile *file;
TString fname;
TIter next(dir.GetListOfFiles());
while ((file=(TSystemFile*)next())) {
fname = file->GetName();
if (fname.BeginsWith("TnP")) {
if (fname.Contains("data")) kind = "data";
else kind = "mc";
bool pass = false;
for (int p = 0 ; p< nbOfIds ; p++){
if (fname.Contains(thePlotToDraw[p])) {
pass = true;
theIndex = p;
break;
}
}
if (!(pass)) continue;
TFile *myFile = new TFile(fname);
TIter nextkey(myFile->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
TString theTypeClasse = key->GetClassName();
TString theNomClasse = key->GetTitle();
if ( theTypeClasse == "TDirectoryFile"){
TDirectory *theDr = (TDirectory*) myFile->Get(theNomClasse);
TIter nextkey2(theDr->GetListOfKeys());
TKey *key2;
while (key2 = (TKey*)nextkey2()) {
TString theTypeClasse2 = key2->GetClassName();
TString theNomClasse2 = key2->GetTitle();
if ( theTypeClasse == "TDirectoryFile"){
TDirectory *theDr2 = (TDirectory*) myFile->Get(theNomClasse+"/"+theNomClasse2);
TIter nextkey3(theDr2->GetListOfKeys());
TKey *key3;
while (key3 = (TKey*)nextkey3()) {
TString theTypeClasse3 = key3->GetClassName();
TString theNomClasse3 = key3->GetTitle();
if (((theNomClasse3.Contains("vpvPlusExpo"))||(theNomClasse3.Contains("higgsSF")))&&(!(theNomClasse3.Contains("all")))) {
TCanvas *theCanvas = (TCanvas*) myFile->Get(theNomClasse+"/"+theNomClasse2+"/"+theNomClasse3+"/fit_canvas");
theCanvas->Print(outputDir+"/"+kind+"_"+theName[theIndex]+"__"+theNomClasse3+".png");
}
}
}
}
}
}
delete myFile;
}
}
}