-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsh_cuts.C
105 lines (84 loc) · 2.56 KB
/
sh_cuts.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
#include "sh_cuts.h"
//==================================
// part of shspe; OR can be loaded separately with .L ++
//
//
//==================================
/*
* save the defined cut into cuts.root
*/
void cutsave(TCutG *cut, const char* name){
TDirectory *dir=gDirectory;
TCutG *newcut=(TCutG*)cut->Clone( name ); // better to clone before (other dir...)
TFile *nf=new TFile( CUTFILE_GLOBAL , "UPDATE");
newcut->Write();
nf->ls();
nf->Close();
dir->cd();
// dir->ls();
}//cutsave--------------
void cutload(){
gROOT->GetListOfSpecials()->ls();// ORIGINAL
TDirectory *dir=gDirectory;
TFile *nf=new TFile( CUTFILE_GLOBAL, "READ"); // WAS UPDATE, touched cuts.root..
// UNUSED int n=gDirectory->GetNkeys();
if (gDirectory->GetListOfKeys()){
TObject *o;
int max=gDirectory->GetList()->GetEntries();
max=gDirectory->GetListOfKeys()->GetEntries();
for (int iii=0 ; iii<max ; iii++ ){
TString sa1=gDirectory->GetListOfKeys()->At(iii)->GetName();
gDirectory->GetObject( sa1.Data() , o );
TString sa2=o->ClassName();
// important check - else it makes double entries...
if ((sa2.Index("TCutG")==0)&&(gROOT->GetListOfSpecials()->FindObject(o)==NULL)) {
// if ((sa2.Index("TCutG")==0)&&(gDirectory->FindObject(o)==NULL)) {
// gDirectory->Add( (TH1F*)o );
gROOT->GetListOfSpecials()->Add( (TCutG*)o );
}// TCutG
}
}//gDirectory->GetListOfKeys()
nf->ls();
nf->Close();
dir->cd();
gROOT->GetListOfSpecials()->ls();
}//cutload--------------
/* remove rename.............
* gDirectory->rmdir("cutt7d") !!!
* cutt7p->Clone("cutt7pV");cutt7pV->Write()
*/
void cutrm(const char* name, int version=0){
if (version==0){
printf("make a backup and use the version number ;1 ;2%s\n","");
return;
}
TDirectory *dir=gDirectory;
TFile *nf=new TFile(CUTFILE_GLOBAL, "UPDATE");
char name2[100];
sprintf( name2 , "%s;%d", name, version );
printf("deleting %s\n", name2 );
gDirectory->rmdir( name2 );
nf->ls();
nf->Close();
dir->cd();
}
void cutcp(const char* name, const char* newname){
TDirectory *dir=gDirectory;
TFile *nf=new TFile(CUTFILE_GLOBAL, "UPDATE");
TObject *o;
gDirectory->GetObject( name , o );
TCutG* cut=(TCutG*)o;
TCutG* newcut=(TCutG*)cut->Clone( newname );
newcut->Write();
// newcut->Print(); newcut->Draw("pawl");
nf->ls();
nf->Close();
dir->cd();
}
void cutls(){
TDirectory *dir=gDirectory;
TFile *nf=new TFile(CUTFILE_GLOBAL, "");
nf->ls();
nf->Close();
dir->cd();
}