Example of analysis class for the H1 data using code generated by MakeProxy.
This file uses 4 large data sets from the H1 collaboration at DESY Hamburg. One can access these data sets (277 MBytes) from the standard Root web site at: ftp:///root.cern.ch/root/h1analysis
The Physics plots below generated by this example cannot be produced when using smaller data sets.
A chain of 4 files (originally converted from PAW ntuples) is used to illustrate the various ways to loop on Root data sets. Each data set contains a Root Tree named "h42"
This produces one file: h1sel.h which does a #include "h1analysProxy.C" The h1sel class is derived from the Root class TSelector and can then be used as:
The event list is saved to a file "elist.root" by the Terminate function. To see the list of selected events, you can do elist->Print("all"). The selection function has selected 7525 events out of the 283813 events in the chain of files. (2.65 per cent)
The commands executed with the 3 different methods B,C and D produce two canvases shown below: begin_html the Dstar plot end_html begin_html the Tau D0 plot end_html
{
printf(
"Starting (begin) h1analysis with process option: %s\n",option.
Data());
if (fChain) fChain->SetEntryList(0);
delete gDirectory->GetList()->FindObject(
"elist");
elist =
new TEntryList(
"elist",
"H1 selection from Cut");
if (fInput) {
fInput->Add(
new TNamed(
"fillList",
""));
fInput->Add(elist);
}
} else elist = 0;
if (fInput) {
tree->SetEntryList(elist);
} else {
Warning(
"Begin",
"option 'useList' not supported in PROOF - ignoring");
Warning(
"Begin",
"the entry list must be set on the chain *before* calling Process");
}
}
}
{
printf(
"Starting (slave) h1analysis with process option: %s\n",option.
Data());
hdmd =
new TH1F(
"hdmd",
"dm_d",40,0.13,0.17);
h2 =
new TH2F(
"h2",
"ptD0 vs dm_d",30,0.135,0.165,30,-3,6);
fOutput->Add(hdmd);
fOutput->Add(h2);
if (fInput) {
if ((elist = (
TEntryList *) fInput->FindObject(
"elist")))
}
if (elist)
fOutput->Add(elist);
else
} else elist = 0;
else {
Warning(
"Begin",
"option 'useList' not supported in PROOF - ignoring");
Warning(
"Begin",
"the entry list must be set on the chain *before* calling Process");
}
}
}
return 0;
}
{
if (!useList) {
float f2 = md0_d-1.8646;
if (
gDebug>0) fprintf(stderr,
"entry #%lld f1=%f f2=%f test=%d\n",
fChain->GetReadEntry(),
f1,f2,
test);
if (ptds_d <= 2.5)
return kFALSE;
int cik = ik-1;
int cipi = ipi-1;
f2 = nhitrp[cipi];
test = nhitrp[cik]*nhitrp[cipi] <= 1;
if (
gDebug>0) fprintf(stderr,
"entry #%lld f1=%f f2=%f test=%d\n",
fChain->GetReadEntry(),
f1,f2,
test);
if (nhitrp[cik]*nhitrp[cipi] <= 1)
return kFALSE;
if (rend[cik] -rstart[cik] <= 22)
return kFALSE;
if (rend[cipi]-rstart[cipi] <= 22)
return kFALSE;
if (nlhk[cik] <= 0.1)
return kFALSE;
if (nlhpi[cipi] <= 0.1)
return kFALSE;
if (nlhpi[ipis-1] <= 0.1)
return kFALSE;
}
if (fillList) elist->
Enter(entry);
h2->
Fill(dm_d,rpd0_t/0.029979*1.8646/ptd0_d);
}
void h1analysisProxy_SlaveTerminate()
{
printf("Terminate (slave) h1analysis\n");
}
void h1analysisProxy_Terminate()
{
printf("Terminate (final) h1analysis\n");
hdmd =
dynamic_cast<TH1F*
>(fOutput->FindObject(
"hdmd"));
h2 =
dynamic_cast<TH2F*
>(fOutput->FindObject(
"h2"));
if (hdmd == 0 || h2 == 0) {
Error(
"Terminate",
"hdmd = %p , h2 = %p", hdmd, h2);
return;
}
c1->SetBottomMargin(0.15);
c2->SetBottomMargin(0.15);
if (fillList) {
elist =
dynamic_cast<TEntryList*
>(fOutput->FindObject(
"elist"));
if (elist) {
TFile efile(
"elist.root",
"recreate");
} else {
Error(
"Terminate",
"entry list requested but not found in output");
}
}
}
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
R__EXTERN TStyle * gStyle
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
A List of entry numbers in a TTree or TChain.
virtual void SetDirectory(TDirectory *dir)
Add reference to directory dir. dir can be 0.
virtual Bool_t Enter(Long64_t entry, TTree *tree=0)
Add entry #entry to the list.
virtual void SetParameters(const Double_t *params)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
1-D histogram with a double per channel (see TH1 documentation)}
1-D histogram with a float per channel (see TH1 documentation)}
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
TList * GetListOfFunctions() const
virtual void Draw(Option_t *option="")
Draw this histogram with options.
2-D histogram with a float per channel (see TH1 documentation)}
Int_t Fill(Double_t)
Invalid Fill method.
virtual void FitSlicesX(TF1 *f1=0, Int_t firstybin=0, Int_t lastybin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray *arr=0)
Project slices along X in case of a 2-D histogram, then fit each slice with function f1 and make a hi...
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
The TNamed class is the base class for all named ROOT classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
The histogram statistics painter class.
void SetOptStat(Int_t stat=1)
Set the stat option.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
A TTree represents a columnar dataset.
Double_t fdm5(Double_t *xx, Double_t *par)
Double_t fdm2(Double_t *xx, Double_t *par)
void Init(TClassEdit::TInterpreterLookupHelper *helper)