15 |
|
showLegend = false; |
16 |
|
logY = true; |
17 |
|
addTrackJets = false; |
18 |
+ |
addEventInfo = false; |
19 |
|
verbose = true; |
20 |
|
|
21 |
+ |
globalCuts=""; |
22 |
+ |
|
23 |
|
} |
24 |
|
|
25 |
|
//------------------------------------------------------------------ |
26 |
|
//Fill object PlotTool with Chains constructed from files from given source |
27 |
|
|
28 |
|
int PlotTool::init(string fileName, string dirPath, string treeName, |
29 |
< |
string fileLabel) { |
30 |
< |
this->New(this->GetEntries() ); |
31 |
< |
int currChain = this->GetEntries() - 1; |
29 |
> |
string fileLabel) { |
30 |
> |
this->New(this->GetEntries() ); |
31 |
> |
int currChain = this->GetEntries() - 1; |
32 |
> |
|
33 |
> |
if (currChain < 0) |
34 |
> |
return currChain; |
35 |
> |
|
36 |
> |
TStopwatch timer; |
37 |
> |
timer.Start(); |
38 |
> |
|
39 |
> |
|
40 |
> |
fileNames.clear(); |
41 |
> |
|
42 |
> |
//check if alternative label is different from default(searchString) |
43 |
> |
if (fileLabel=="") { |
44 |
> |
fileLabel=fileName; |
45 |
> |
} |
46 |
> |
((TChain*) this->At(currChain))->SetName(fileLabel.c_str()); |
47 |
> |
|
48 |
> |
TList *files = new TList(); |
49 |
> |
TSystemFile* sysFile = 0; |
50 |
> |
if(fileName.find(".") != string::npos) { |
51 |
> |
ifstream f(fileName.c_str()); |
52 |
> |
if( ! f.is_open() ) return -1; |
53 |
> |
string line; |
54 |
> |
|
55 |
> |
while (!f.eof()) { |
56 |
> |
getline(f,line); |
57 |
> |
sysFile = new TSystemFile(line.c_str(),dirPath.c_str()); |
58 |
> |
files->Add(sysFile); |
59 |
> |
} |
60 |
> |
|
61 |
> |
|
62 |
> |
} else { |
63 |
> |
TSystemDirectory dir("sourceDir", dirPath.c_str()); |
64 |
> |
files = dir.GetListOfFiles(); |
65 |
> |
} |
66 |
> |
if (files->GetEntries()>0) { |
67 |
> |
TIter next(files); |
68 |
> |
TSystemFile *file; |
69 |
> |
TString fname; |
70 |
> |
string filePath; |
71 |
> |
|
72 |
> |
if(verbose && fileName.find(".") == string::npos ) cout<<"Open"<<dirPath.c_str()<<" Search for .root files that contain: " |
73 |
> |
<<fileName.c_str()<<endl; |
74 |
> |
if(verbose && fileName.find(".") != string::npos ) cout<<"Open"<<dirPath.c_str()<<" Search lines with .root in: " |
75 |
> |
<<fileName.c_str()<<endl; |
76 |
> |
|
77 |
> |
|
78 |
> |
while ((file=(TSystemFile*)next())) { |
79 |
> |
fname = file->GetName(); |
80 |
> |
if (!fname.EndsWith(".root")) |
81 |
> |
continue; |
82 |
> |
if (!fname.Contains(fileName.c_str()) && fileName.find(".") == string::npos ) |
83 |
> |
continue; |
84 |
> |
|
85 |
> |
filePath = dirPath; |
86 |
> |
filePath += fname.Data(); |
87 |
> |
//fwlite::ChainEvent to lop over events, jets, etc |
88 |
> |
fileNames.push_back(filePath.c_str()); |
89 |
> |
|
90 |
> |
if (((TChain*) this->At(currChain))->AddFile(filePath.c_str(), -1, |
91 |
> |
treeName.c_str()) ) |
92 |
> |
if(verbose) cout<<"Chained "<<((TChain*) this->At(currChain))->GetNtrees()<<" file(s) with "<<((TChain*) this->At(currChain))->GetEntries()<<" events."<<endl; |
93 |
> |
else |
94 |
> |
return -1; |
95 |
|
|
96 |
< |
if (currChain < 0) |
97 |
< |
return currChain; |
96 |
> |
} |
97 |
> |
} else |
98 |
> |
return -1; |
99 |
> |
|
100 |
> |
for (int i=0; i<((TChain*) this->At(currChain))->GetListOfBranches()->GetEntries(); ++i) { |
101 |
> |
|
102 |
> |
string s(((TChain*) this->At(currChain))->GetListOfBranches()->At(i)->GetName()); |
103 |
> |
|
104 |
> |
string branch_alias = s; |
105 |
> |
string branch_name = s; |
106 |
> |
if (s.find(".", s.size()-1) != string::npos) |
107 |
> |
branch_name += "obj"; |
108 |
> |
|
109 |
> |
size_t a = s.find("_"); |
110 |
> |
if (a != string::npos) { |
111 |
> |
size_t b = s.find("_", a+1); |
112 |
> |
if (b != string::npos) { |
113 |
> |
size_t c = s.find("_", b+1); |
114 |
> |
if (c != string::npos) { |
115 |
> |
string _prod =s.substr(0,a); |
116 |
> |
string _label =s.substr(a+1, b-a-1); |
117 |
> |
string _instance =s.substr(b+1, c-b-1); |
118 |
> |
branch_alias = _label; |
119 |
> |
if(_instance.length() > 0 ) { |
120 |
> |
branch_alias += "_"; |
121 |
> |
branch_alias += _instance; |
122 |
> |
((TChain*) this->At(currChain))->SetAlias(_instance.c_str(), |
123 |
> |
branch_name.c_str()); |
124 |
> |
} |
125 |
> |
string branch_alias_full = _prod + "_" + branch_alias; |
126 |
> |
((TChain*) this->At(currChain))->SetAlias(branch_alias_full.c_str(), |
127 |
> |
branch_name.c_str()); |
128 |
> |
} |
129 |
> |
} |
130 |
> |
} |
131 |
|
|
132 |
< |
TStopwatch timer; |
133 |
< |
timer.Start(); |
132 |
> |
((TChain*) this->At(currChain))->SetAlias(branch_alias.c_str(), |
133 |
> |
branch_name.c_str()); |
134 |
|
|
135 |
+ |
} |
136 |
|
|
137 |
< |
fileNames.clear(); |
137 |
> |
if( addEventInfo || addTrackJets) { |
138 |
|
|
139 |
< |
//check if alternative label is different from default(searchString) |
40 |
< |
if (fileLabel=="") { |
41 |
< |
fileLabel=fileName; |
42 |
< |
} |
43 |
< |
((TChain*) this->At(currChain))->SetName(fileLabel.c_str()); |
139 |
> |
if(verbose) cout<<"calculating additional variables..."<<endl; |
140 |
|
|
141 |
< |
TList *files = new TList(); |
142 |
< |
TSystemFile* sysFile = 0; |
143 |
< |
if(fileName.find(".") != string::npos) { |
144 |
< |
ifstream f(fileName.c_str()); |
145 |
< |
if( ! f.is_open() ) return -1; |
146 |
< |
string line; |
141 |
> |
//make file for tree friends (adding additional, computed branches) |
142 |
> |
string friendFileName("/scratch/hh/current/cms/user/"); |
143 |
> |
friendFileName += gSystem->GetUserInfo()->fUser; |
144 |
> |
friendFileName += "/temp/", |
145 |
> |
friendFileName += fileName; |
146 |
> |
friendFileName += ".root"; |
147 |
> |
TFile *f = new TFile(friendFileName.c_str(),"recreate"); |
148 |
|
|
149 |
< |
while (!f.eof()) { |
53 |
< |
getline(f,line); |
54 |
< |
sysFile = new TSystemFile(line.c_str(),dirPath.c_str()); |
55 |
< |
files->Add(sysFile); |
56 |
< |
} |
149 |
> |
if( f->IsZombie() ) return -1; |
150 |
|
|
151 |
+ |
string friendTreeName("friendTree"); |
152 |
+ |
//char number = currChain; |
153 |
+ |
//friendTreeName += number; |
154 |
+ |
//TTree *friendTree = new TTree("friendTree","friendTree"); |
155 |
+ |
TTree *friendTree = new TTree(friendTreeName.c_str(),friendTreeName.c_str()); |
156 |
+ |
fwlite::ChainEvent ev(fileNames); |
157 |
+ |
int _event, _run, _lumi; |
158 |
+ |
int nJetsKT; |
159 |
+ |
TrackJetKT = new float [100]; |
160 |
|
|
161 |
< |
} else { |
162 |
< |
TSystemDirectory dir("sourceDir", dirPath.c_str()); |
61 |
< |
files = dir.GetListOfFiles(); |
62 |
< |
} |
63 |
< |
if (files->GetEntries()>0) { |
64 |
< |
TIter next(files); |
65 |
< |
TSystemFile *file; |
66 |
< |
TString fname; |
67 |
< |
string filePath; |
68 |
< |
|
69 |
< |
if(verbose && fileName.find(".") == string::npos ) cout<<"Open"<<dirPath.c_str()<<" Search for .root files that contain: " |
70 |
< |
<<fileName.c_str()<<endl; |
71 |
< |
if(verbose && fileName.find(".") != string::npos ) cout<<"Open"<<dirPath.c_str()<<" Search lines with .root in: " |
72 |
< |
<<fileName.c_str()<<endl; |
73 |
< |
|
74 |
< |
|
75 |
< |
while ((file=(TSystemFile*)next())) { |
76 |
< |
fname = file->GetName(); |
77 |
< |
if (!fname.EndsWith(".root")) |
78 |
< |
continue; |
79 |
< |
if (!fname.Contains(fileName.c_str()) && fileName.find(".") == string::npos ) |
80 |
< |
continue; |
161 |
> |
if( addEventInfo ) { |
162 |
> |
|
163 |
|
|
164 |
< |
filePath = dirPath; |
165 |
< |
filePath += fname.Data(); |
166 |
< |
//fwlite::ChainEvent to lop over events, jets, etc |
85 |
< |
fileNames.push_back(filePath.c_str()); |
86 |
< |
|
87 |
< |
if (((TChain*) this->At(currChain))->AddFile(filePath.c_str(), -1, |
88 |
< |
treeName.c_str()) ) |
89 |
< |
if(verbose) cout<<"Chained "<<((TChain*) this->At(currChain))->GetNtrees()<<" file(s) with "<<((TChain*) this->At(currChain))->GetEntries()<<" events."<<endl; |
90 |
< |
else |
91 |
< |
return -1; |
164 |
> |
friendTree->Branch("event", &_event, "event/I"); |
165 |
> |
friendTree->Branch("run", &_run, "run/I"); |
166 |
> |
friendTree->Branch("lumi", &_lumi, "lumi/I"); |
167 |
|
|
168 |
< |
} |
94 |
< |
} else |
95 |
< |
return -1; |
168 |
> |
} |
169 |
|
|
170 |
< |
for (int i=0; i<((TChain*) this->At(currChain))->GetListOfBranches()->GetEntries(); ++i) { |
170 |
> |
if( addTrackJets ) { |
171 |
|
|
99 |
– |
string s(((TChain*) this->At(currChain))->GetListOfBranches()->At(i)->GetName()); |
172 |
|
|
173 |
< |
string branch_alias = s; |
174 |
< |
string branch_name = s; |
175 |
< |
if (s.find(".", s.size()-1) != string::npos) |
104 |
< |
branch_name += "obj"; |
105 |
< |
|
106 |
< |
size_t a = s.find("_"); |
107 |
< |
if (a != string::npos) { |
108 |
< |
size_t b = s.find("_", a+1); |
109 |
< |
if (b != string::npos) { |
110 |
< |
size_t c = s.find("_", b+1); |
111 |
< |
if (c != string::npos) { |
112 |
< |
string _prod =s.substr(0,a); |
113 |
< |
string _label =s.substr(a+1, b-a-1); |
114 |
< |
string _instance =s.substr(b+1, c-b-1); |
115 |
< |
branch_alias = _label; |
116 |
< |
if(_instance.length() > 0 ) { |
117 |
< |
branch_alias += "_"; |
118 |
< |
branch_alias += _instance; |
119 |
< |
((TChain*) this->At(currChain))->SetAlias(_instance.c_str(), |
120 |
< |
branch_name.c_str()); |
121 |
< |
} |
122 |
< |
string branch_alias_full = _prod + "_" + branch_alias; |
123 |
< |
((TChain*) this->At(currChain))->SetAlias(branch_alias_full.c_str(), |
124 |
< |
branch_name.c_str()); |
125 |
< |
} |
126 |
< |
} |
127 |
< |
} |
173 |
> |
friendTree->Branch("nJetsKT", &nJetsKT, "nJetsKT/I"); |
174 |
> |
friendTree->Branch("TrackJetKT", TrackJetKT, "TrackJetKT[nJetsKT]/F"); |
175 |
> |
} |
176 |
|
|
129 |
– |
((TChain*) this->At(currChain))->SetAlias(branch_alias.c_str(), |
130 |
– |
branch_name.c_str()); |
177 |
|
|
178 |
< |
} |
178 |
> |
int tenth = ev.size() / 10; |
179 |
> |
int eventNum =0; |
180 |
> |
for (ev.toBegin(); !ev.atEnd(); ++ev, ++eventNum) { |
181 |
> |
|
182 |
> |
|
183 |
> |
if( addEventInfo ) { |
184 |
|
|
185 |
< |
// add branch with track Jets |
185 |
> |
_event = ev.id().event(); |
186 |
> |
_run = ev.id().run(); |
187 |
> |
_lumi = ev.luminosityBlock(); |
188 |
|
|
189 |
< |
if( addTrackJets ) { |
189 |
> |
} |
190 |
|
|
191 |
< |
//make file for tree friends (adding additional, computed branches) |
139 |
< |
string friendFileName("/scratch/hh/current/cms/user/"); |
140 |
< |
friendFileName += gSystem->GetUserInfo()->fUser; |
141 |
< |
friendFileName += "/temp/", |
142 |
< |
friendFileName += fileName; |
143 |
< |
friendFileName += ".root"; |
144 |
< |
TFile *f = new TFile(friendFileName.c_str(),"recreate"); |
145 |
< |
|
146 |
< |
if( f->IsZombie() ) return -1; |
147 |
< |
|
148 |
< |
string friendTreeName("friendTree"); |
149 |
< |
//char number = currChain; |
150 |
< |
//friendTreeName += number; |
151 |
< |
//TTree *friendTree = new TTree("friendTree","friendTree"); |
152 |
< |
TTree *friendTree = new TTree(friendTreeName.c_str(),friendTreeName.c_str()); |
153 |
< |
|
154 |
< |
int nJetsKT; |
155 |
< |
TrackJetKT = new float [100]; |
156 |
< |
fwlite::ChainEvent ev(fileNames); |
157 |
< |
|
158 |
< |
friendTree->Branch("nJetsKT", &nJetsKT, "nJetsKT/I"); |
159 |
< |
friendTree->Branch("TrackJetKT", TrackJetKT, "TrackJetKT[nJetsKT]/F"); |
160 |
< |
|
161 |
< |
if(verbose) cout<<"calculating additional variables..."<<endl; |
162 |
< |
|
163 |
< |
|
164 |
< |
|
165 |
< |
int tenth = ev.size() / 10; |
166 |
< |
int eventNum =0; |
167 |
< |
for (ev.toBegin(); !ev.atEnd(); ++ev, ++eventNum) { |
168 |
< |
|
169 |
< |
fwlite::Handle<reco::CaloJetCollection> jets; |
170 |
< |
jets.getByLabel(ev, "antikt5CaloJets"); |
171 |
< |
|
172 |
< |
fwlite::Handle<reco::TrackCollection> tracks; |
173 |
< |
tracks.getByLabel(ev, "generalTracks"); |
174 |
< |
|
175 |
< |
if (!jets.isValid()) |
176 |
< |
continue; |
177 |
< |
if (!tracks.isValid()) |
178 |
< |
continue; |
179 |
< |
double trackSum; |
180 |
< |
nJetsKT = 0; |
181 |
< |
for (reco::CaloJetCollection::const_iterator jet = jets->begin(); jet |
182 |
< |
!=jets->end(); jet++) { |
183 |
< |
trackSum = 0; |
184 |
< |
for (reco::TrackCollection::const_iterator track = tracks->begin(); track |
185 |
< |
!=tracks->end(); track++) { |
186 |
< |
if (deltaR(jet->eta(), jet->phi(), track->eta(), track->phi()) |
187 |
< |
< 0.5) |
188 |
< |
trackSum += track->pt(); |
189 |
< |
} |
190 |
< |
TrackJetKT[nJetsKT] = trackSum; |
191 |
< |
nJetsKT++; |
192 |
< |
} |
193 |
< |
friendTree->Fill(); |
191 |
> |
if( addTrackJets ) { |
192 |
|
|
193 |
< |
if( eventNum != 0 && eventNum%tenth == 0) cout<<"Processed "<<eventNum <<" of "<<ev.size()<<" events. "<<endl; |
193 |
> |
fwlite::Handle<reco::CaloJetCollection> jets; |
194 |
> |
jets.getByLabel(ev, "antikt5CaloJets"); |
195 |
|
|
196 |
+ |
fwlite::Handle<reco::TrackCollection> tracks; |
197 |
+ |
tracks.getByLabel(ev, "generalTracks"); |
198 |
+ |
|
199 |
+ |
if (!jets.isValid()) |
200 |
+ |
continue; |
201 |
+ |
if (!tracks.isValid()) |
202 |
+ |
continue; |
203 |
+ |
double trackSum; |
204 |
+ |
nJetsKT = 0; |
205 |
+ |
for (reco::CaloJetCollection::const_iterator jet = jets->begin(); jet |
206 |
+ |
!=jets->end(); jet++) { |
207 |
+ |
trackSum = 0; |
208 |
+ |
for (reco::TrackCollection::const_iterator track = tracks->begin(); track |
209 |
+ |
!=tracks->end(); track++) { |
210 |
+ |
if (deltaR(jet->eta(), jet->phi(), track->eta(), track->phi()) |
211 |
+ |
< 0.5) |
212 |
+ |
trackSum += track->pt(); |
213 |
|
} |
214 |
< |
f->cd(); |
215 |
< |
friendTree->Write(); |
200 |
< |
f->Close(); |
201 |
< |
((TChain*) this->At(currChain))->AddFriend(friendTreeName.c_str(), |
202 |
< |
friendFileName.c_str()); |
214 |
> |
TrackJetKT[nJetsKT] = trackSum; |
215 |
> |
nJetsKT++; |
216 |
|
} |
217 |
+ |
} |
218 |
+ |
friendTree->Fill(); |
219 |
+ |
|
220 |
+ |
if( eventNum != 0 && eventNum%tenth == 0) cout<<"Processed "<<eventNum <<" of "<<ev.size()<<" events. "<<endl; |
221 |
+ |
|
222 |
+ |
} |
223 |
+ |
f->cd(); |
224 |
+ |
friendTree->Write(); |
225 |
+ |
f->Close(); |
226 |
+ |
((TChain*) this->At(currChain))->AddFriend(friendTreeName.c_str(), |
227 |
+ |
friendFileName.c_str()); |
228 |
|
|
229 |
< |
timer.Stop(); |
230 |
< |
if(verbose) timer.Print(); |
229 |
> |
|
230 |
> |
|
231 |
> |
} |
232 |
> |
|
233 |
> |
|
234 |
> |
timer.Stop(); |
235 |
> |
if(verbose) timer.Print(); |
236 |
|
|
237 |
< |
return this->GetEntries(); |
237 |
> |
return this->GetEntries(); |
238 |
|
|
239 |
|
} |
240 |
|
//------------------------------------------------------------------ |
310 |
|
|
311 |
|
|
312 |
|
//Draw histogram: |
313 |
< |
int draw_err = ((TChain*) this->At(chainIndex))->Draw(histName.c_str(), cutName.c_str(), |
313 |
> |
string cutNameWithGlobal = cutName; |
314 |
> |
if(cutName!="" && globalCuts!="") cutNameWithGlobal += "&&"; |
315 |
> |
if(globalCuts!="") cutNameWithGlobal += globalCuts; |
316 |
> |
|
317 |
> |
int draw_err = ((TChain*) this->At(chainIndex))->Draw(histName.c_str(), cutNameWithGlobal.c_str(), |
318 |
|
currOpt.c_str(), currN); |
319 |
|
if (draw_err < 0) |
320 |
|
return draw_err; |
342 |
|
} |
343 |
|
|
344 |
|
|
345 |
< |
if(verbose) { |
345 |
> |
if(verbose && draw_err > 0) { |
346 |
|
timer.Stop(); |
347 |
< |
cout<<"Done: "<<currN<<" events."<<endl; |
347 |
> |
cout<<"Done: Selected "<<draw_err<<" objects in "<< currN <<" processed events."<<endl; |
348 |
|
timer.Print(); |
349 |
|
} |
350 |
|
return draw_err; |
577 |
|
string x = thisHist->GetXaxis()->GetTitle(); |
578 |
|
string y = thisHist->GetYaxis()->GetTitle(); |
579 |
|
|
580 |
< |
if (t.find(".phi()") != string::npos) |
581 |
< |
t.replace(t.find(".phi()"), 6, " #phi"); |
580 |
> |
// if (x.find("__") != string::npos) |
581 |
> |
// x = x.substr(0,x.find("__")); |
582 |
> |
// if (y.find("__") != string::npos) |
583 |
> |
// y = y.substr(0,y.find("__")); |
584 |
> |
|
585 |
|
if (x.find(".phi()") != string::npos) |
586 |
|
x.replace(x.find(".phi()"), 6, " #phi"); |
587 |
|
if (y.find(".phi()") != string::npos) |
588 |
|
y.replace(y.find(".phi()"), 6, " #phi"); |
589 |
|
|
554 |
– |
if (t.find(".eta()") != string::npos) |
555 |
– |
t.replace(t.find(".eta()"), 6, " #eta"); |
590 |
|
if (x.find(".eta()") != string::npos) |
591 |
|
x.replace(x.find(".eta()"), 6, " #eta"); |
592 |
|
if (y.find(".eta()") != string::npos) |
593 |
|
y.replace(y.find(".eta()"), 6, " #eta"); |
594 |
|
|
595 |
< |
if (t.find(".pt()") != string::npos) |
596 |
< |
t.replace(t.find(".pt()"), 5, " p_{T}"); |
595 |
> |
if (x.find(".theta()") != string::npos) |
596 |
> |
x.replace(x.find(".theta()"), 6, " #theta"); |
597 |
> |
if (y.find(".theta()") != string::npos) |
598 |
> |
y.replace(y.find(".theta()"), 6, " #theta"); |
599 |
> |
|
600 |
> |
if (x.find(".chi2()") != string::npos) |
601 |
> |
x.replace(x.find(".chi2()"), 7, " #chi^{2}"); |
602 |
> |
if (y.find(".chi2()") != string::npos) |
603 |
> |
y.replace(y.find(".chi2()"), 7, " #chi^{2}"); |
604 |
> |
|
605 |
|
if (x.find(".pt()") != string::npos) |
606 |
< |
x.replace(x.find(".pt()"), 5, " p_{T}"); |
606 |
> |
x.replace(x.find(".pt()"), 5, " p_{T} [GeV]"); |
607 |
|
if (y.find(".pt()") != string::npos) |
608 |
< |
y.replace(y.find(".pt()"), 5, " p_{T}"); |
608 |
> |
y.replace(y.find(".pt()"), 5, " p_{T} [GeV]"); |
609 |
> |
|
610 |
> |
if (x.find(".et()") != string::npos) |
611 |
> |
x.replace(x.find(".et()"), 5, " E_{T} [GeV]"); |
612 |
> |
if (y.find(".et()") != string::npos) |
613 |
> |
y.replace(y.find(".et()"), 5, " E_{T} [GeV]"); |
614 |
> |
|
615 |
> |
//splitlines for many cuts |
616 |
> |
string test1= "{" + globalCuts + "}"; |
617 |
> |
string test2= "&&" + globalCuts; |
618 |
> |
|
619 |
> |
if(t.find(test1) != string::npos) t.replace(t.find(test1),test1.length(),""); |
620 |
> |
if(t.find(test2) != string::npos) t.replace(t.find(test2),test2.length(),""); |
621 |
> |
|
622 |
> |
if (t.find("{") != string::npos && t.find("#splitline") == string::npos) { |
623 |
> |
t.replace(t.find_last_of("{"), 1, "}{"); |
624 |
> |
string t_old = t; |
625 |
> |
t = "#splitline{"; |
626 |
> |
t += t_old; |
627 |
> |
} |
628 |
|
|
629 |
|
thisHist ->SetTitle(t.c_str()); |
630 |
|
thisHist->GetXaxis()->SetTitle(x.c_str()); |
759 |
|
|
760 |
|
int savedCanvs =0; |
761 |
|
|
701 |
– |
TPostScript ps(namePs.c_str(),112); |
702 |
– |
TFile rt(nameRt.c_str(),"recreate"); |
762 |
|
|
763 |
|
TIter next(gROOT->GetListOfCanvases()); |
764 |
|
TCanvas* canv; |
765 |
|
while ((canv=(TCanvas*)next())) { |
766 |
+ |
string modName = (*canv).GetName(); |
767 |
+ |
if(modName.find("{") != string::npos) modName = modName.substr(0,modName.find("{")); |
768 |
+ |
(*canv).SetTitle( modName.c_str() ); |
769 |
+ |
|
770 |
+ |
} |
771 |
+ |
|
772 |
+ |
|
773 |
+ |
TPostScript ps(namePs.c_str(),112); |
774 |
+ |
TFile rt(nameRt.c_str(),"recreate"); |
775 |
+ |
|
776 |
+ |
next.Reset(); |
777 |
+ |
while ((canv=(TCanvas*)next())) { |
778 |
|
ps.NewPage(); |
779 |
+ |
|
780 |
+ |
|
781 |
+ |
(*canv).Write(); |
782 |
|
(*canv).Draw(); |
783 |
|
(*canv).Update(); |
784 |
< |
(*canv).Write(); |
784 |
> |
|
785 |
> |
|
786 |
|
++savedCanvs; |
787 |
|
|
788 |
|
} |
790 |
|
ps.Close(); |
791 |
|
rt.Close(); |
792 |
|
|
793 |
+ |
|
794 |
+ |
if(verbose && savedCanvs) { |
795 |
+ |
cout<<"Saved file "<<rt.GetName()<<" with "<<savedCanvs<<" canvases."<<endl; |
796 |
+ |
cout<<"Saved file "<<ps.GetName()<<" with "<<savedCanvs<<" pages."<<endl; |
797 |
+ |
} |
798 |
|
return savedCanvs; |
799 |
|
|
800 |
|
} |
813 |
|
int PlotTool::setVariables(string label) |
814 |
|
{ |
815 |
|
|
736 |
– |
cout<<endl; |
737 |
– |
cout<<"****** Show Chain Information:"<<endl; |
738 |
– |
|
739 |
– |
|
740 |
– |
this->ls(); |
741 |
– |
|
742 |
– |
cout<<endl; |
743 |
– |
cout<<"We have "<<this->GetEntries()<<" TChains with following aliases set:"<<endl; |
816 |
|
for (int i=0; i< this->GetEntries(); ++i) { |
817 |
|
cout<<"--------------------------------"<<endl; |
818 |
|
cout<<((TChain*) this->At(i))->GetName()<<endl; |