ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RootMacros/ProfileBeforeNAfter.C
Revision: 1.1
Committed: Sat Sep 6 18:57:47 2008 UTC (16 years, 7 months ago) by anderson
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
Make profile plot before and a after a cut

File Contents

# Content
1 /*************************************************
2 Plots 2 profile plots onto same canvas before
3 and after a specific cut.
4
5 Should be used with my rootlogon.C
6
7
8 Example Use:
9 ProfileBeforeNAfter(TreePhotonAndJet,"(recPhtn.et-genParticle1.et)/genParticle1.et:genParticle1.et","recPhtn.isLoosePhoton>0","recPhtn.isTightPhoton>0&&recPhtn.r9>0.93","Loose #gamma","Tight #gamma","(RecEt-GenEt)/GenEt","E_{T} (GeV)")
10
11 Michael B. Anderson
12 June 30, 2008
13 *************************************************/
14
15 void ProfileBeforeNAfter(TTree* aTree,
16 TString thingToPlot,
17 TString cuts1,
18 TString cuts2,
19 TString label1="",
20 TString label2="",
21 TString title="",
22 TString xAxisLabel="") {
23
24 int events1 = aTree->Draw(thingToPlot,cuts1,"box");
25 htemp->ProfileX()->Draw();
26 h1=(TH1*)htemp_pfx->Clone();
27
28 int events2 = aTree->Draw(thingToPlot,cuts2,"box");
29 htemp->ProfileX()->Draw();
30 h2=(TH1*)htemp_pfx->Clone();
31
32 if (title == "") {
33 h1->SetTitle(thingToPlot);
34 } else {
35 h1->SetTitle(title);
36 }
37 if (xAxisLabel != "") h1->GetXaxis()->SetTitle(xAxisLabel);
38
39 cout << "Plotting " << thingToPlot << endl;
40 cout << events1 << " events pass " << cuts1 << endl;
41 cout << events2 << " events pass " << cuts2 << endl;
42 cout << "y mean1 = " << h1->GetMean(2) << endl;
43 cout << "y mean2 = " << h2->GetMean(2) << endl;
44
45 // This is a thing loaded in the rootlogon.C
46 Plot2hists1D(h1,h2,label1,label2);
47
48 }